Sun, 09 Nov 2008 20:55:10 +0000
Added menu items to buddy list context menu to start voice and video sessions
After discussing the matter with Maiku, we decided to have two choises.
"Audio call" which will show up if audio sessions is possible with a buddy and
the other item is either "Audio/Video" or "Video" depending on if the buddy
supports both at the same time or not
| 15412 | 1 | /* |
| 15884 | 2 | * Purple - XMPP debugging tool |
| 15412 | 3 | * |
| 4 | * Copyright (C) 2002-2003, Sean Egan | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18122
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 15412 | 19 | * |
| 20 | */ | |
| 21 | ||
| 22 | #include "internal.h" | |
| 23 | #include "gtkplugin.h" | |
| 24 | #include "version.h" | |
| 25 | #include "prpl.h" | |
| 26 | #include "xmlnode.h" | |
| 27 | ||
| 28 | #include "gtkimhtml.h" | |
| 15427 | 29 | #if !GTK_CHECK_VERSION(2,4,0) |
| 16290 | 30 | #include "pidgincombobox.h" |
| 15427 | 31 | #endif |
| 17242 | 32 | #include "gtkutils.h" |
| 15412 | 33 | |
| 34 | typedef struct { | |
| 15884 | 35 | PurpleConnection *gc; |
| 15412 | 36 | GtkWidget *window; |
| 37 | GtkWidget *hbox; | |
| 38 | GtkWidget *dropdown; | |
| 39 | GtkWidget *imhtml; | |
| 40 | GtkWidget *entry; | |
| 41 | GtkWidget *sw; | |
| 42 | int count; | |
| 43 | GList *accounts; | |
| 44 | } XmppConsole; | |
| 45 | ||
| 46 | XmppConsole *console = NULL; | |
| 47 | static void *xmpp_console_handle = NULL; | |
| 48 | ||
| 49 | #define BRACKET_COLOR "#940f8c" | |
| 50 | #define TAG_COLOR "#8b1dab" | |
| 51 | #define ATTR_NAME_COLOR "#a02961" | |
| 52 | #define ATTR_VALUE_COLOR "#324aa4" | |
| 53 | #define XMLNS_COLOR "#2cb12f" | |
| 54 | ||
| 55 | static char * | |
| 56 | xmlnode_to_pretty_str(xmlnode *node, int *len, int depth) | |
| 57 | { | |
| 58 | GString *text = g_string_new(""); | |
| 59 | xmlnode *c; | |
| 60 | char *node_name, *esc, *esc2, *tab = NULL; | |
| 61 | gboolean need_end = FALSE, pretty = TRUE; | |
| 62 | ||
| 63 | g_return_val_if_fail(node != NULL, NULL); | |
| 64 | ||
| 65 | if(pretty && depth) { | |
| 66 | tab = g_strnfill(depth, '\t'); | |
| 67 | text = g_string_append(text, tab); | |
| 68 | } | |
| 69 | ||
| 70 | node_name = g_markup_escape_text(node->name, -1); | |
| 71 | g_string_append_printf(text, "<font color='" | |
| 72 | BRACKET_COLOR "'><</font><font color='" | |
| 73 | TAG_COLOR "'><b>%s</b></font>", node_name); | |
| 74 | ||
| 75 | if (node->xmlns) { | |
| 76 | if((!node->parent || | |
| 77 | !node->parent->xmlns || | |
| 78 | strcmp(node->xmlns, node->parent->xmlns)) && | |
| 79 | strcmp(node->xmlns, "jabber:client")) | |
| 80 | { | |
| 81 | char *xmlns = g_markup_escape_text(node->xmlns, -1); | |
| 82 | g_string_append_printf(text, " <font color='" | |
| 83 | ATTR_NAME_COLOR "'><b>xmlns</b></font>='<font color='" | |
| 84 | XMLNS_COLOR "'><b>%s</b></font>'", xmlns); | |
| 85 | g_free(xmlns); | |
| 86 | } | |
| 87 | } | |
| 88 | for(c = node->child; c; c = c->next) | |
| 89 | { | |
| 90 | if(c->type == XMLNODE_TYPE_ATTRIB) { | |
| 91 | esc = g_markup_escape_text(c->name, -1); | |
| 92 | esc2 = g_markup_escape_text(c->data, -1); | |
| 93 | g_string_append_printf(text, " <font color='" | |
| 94 | ATTR_NAME_COLOR "'><b>%s</b></font>='<font color='" | |
| 95 | ATTR_VALUE_COLOR "'>%s</font>'", esc, esc2); | |
| 96 | g_free(esc); | |
| 97 | g_free(esc2); | |
| 98 | } else if(c->type == XMLNODE_TYPE_TAG || c->type == XMLNODE_TYPE_DATA) { | |
| 99 | if(c->type == XMLNODE_TYPE_DATA) | |
| 100 | pretty = FALSE; | |
| 101 | need_end = TRUE; | |
| 102 | } | |
| 103 | } | |
| 104 | ||
| 105 | if(need_end) { | |
| 106 | g_string_append_printf(text, | |
| 107 | "<font color='"BRACKET_COLOR"'>></font>%s", pretty ? "<br>" : ""); | |
| 108 | ||
| 109 | for(c = node->child; c; c = c->next) | |
| 110 | { | |
| 111 | if(c->type == XMLNODE_TYPE_TAG) { | |
| 112 | int esc_len; | |
| 113 | esc = xmlnode_to_pretty_str(c, &esc_len, depth+1); | |
| 114 | text = g_string_append_len(text, esc, esc_len); | |
| 115 | g_free(esc); | |
| 116 | } else if(c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) { | |
| 117 | esc = g_markup_escape_text(c->data, c->data_sz); | |
| 118 | text = g_string_append(text, esc); | |
| 119 | g_free(esc); | |
| 120 | } | |
| 121 | } | |
| 122 | ||
| 123 | if(tab && pretty) | |
| 124 | text = g_string_append(text, tab); | |
| 125 | g_string_append_printf(text, "<font color='"BRACKET_COLOR"'><</font>/<font color='" | |
| 126 | TAG_COLOR"'><b>%s</b></font><font color='"BRACKET_COLOR | |
| 127 | "'>></font><br>", node_name); | |
| 128 | } else { | |
| 129 | g_string_append_printf(text, "/<font color='"BRACKET_COLOR"'>></font><br>"); | |
| 130 | } | |
| 131 | ||
| 132 | g_free(node_name); | |
| 133 | ||
| 134 | g_free(tab); | |
| 135 | ||
| 136 | if(len) | |
| 137 | *len = text->len; | |
| 138 | ||
| 139 | return g_string_free(text, FALSE); | |
| 140 | } | |
| 141 | ||
| 142 | static void | |
| 15884 | 143 | xmlnode_received_cb(PurpleConnection *gc, xmlnode **packet, gpointer null) |
| 15412 | 144 | { |
| 145 | char *str, *formatted; | |
| 146 | ||
| 147 | if (!console || console->gc != gc) | |
| 148 | return; | |
| 149 | str = xmlnode_to_pretty_str(*packet, NULL, 0); | |
| 150 | formatted = g_strdup_printf("<body bgcolor='#ffcece'><pre>%s</pre></body>", str); | |
| 151 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0); | |
| 152 | g_free(formatted); | |
| 153 | g_free(str); | |
| 154 | } | |
| 155 | ||
| 156 | static void | |
| 15884 | 157 | xmlnode_sent_cb(PurpleConnection *gc, char **packet, gpointer null) |
| 15412 | 158 | { |
| 159 | char *str; | |
| 160 | char *formatted; | |
| 161 | xmlnode *node; | |
| 162 | ||
| 163 | if (!console || console->gc != gc) | |
| 164 | return; | |
| 165 | node = xmlnode_from_str(*packet, -1); | |
| 166 | ||
| 167 | if (!node) | |
| 168 | return; | |
| 169 | ||
| 170 | str = xmlnode_to_pretty_str(node, NULL, 0); | |
| 171 | formatted = g_strdup_printf("<body bgcolor='#dcecc4'><pre>%s</pre></body>", str); | |
| 172 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0); | |
| 173 | g_free(formatted); | |
| 174 | g_free(str); | |
| 175 | xmlnode_free(node); | |
| 176 | } | |
| 177 | ||
| 178 | static void message_send_cb(GtkWidget *widget, gpointer p) | |
| 179 | { | |
| 180 | GtkTextIter start, end; | |
| 15884 | 181 | PurplePluginProtocolInfo *prpl_info = NULL; |
| 182 | PurpleConnection *gc = console->gc; | |
| 15412 | 183 | GtkTextBuffer *buffer; |
| 184 | char *text; | |
| 185 | ||
| 186 | gc = console->gc; | |
|
17529
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
187 | |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
188 | if (gc) |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
189 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
190 | |
| 15412 | 191 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); |
| 192 | gtk_text_buffer_get_start_iter(buffer, &start); | |
| 193 | gtk_text_buffer_get_end_iter(buffer, &end); | |
|
17529
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
194 | |
| 15412 | 195 | text = gtk_imhtml_get_text(GTK_IMHTML(console->entry), &start, &end); |
|
17529
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
196 | |
|
5fd44f61d007
Fix a crash when trying to use XMPP console with no XMPP accounts connected
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16749
diff
changeset
|
197 | if (prpl_info && prpl_info->send_raw != NULL) |
| 15412 | 198 | prpl_info->send_raw(gc, text, strlen(text)); |
| 199 | ||
| 200 | g_free(text); | |
| 201 | gtk_imhtml_clear(GTK_IMHTML(console->entry)); | |
| 202 | } | |
| 203 | ||
| 204 | static void entry_changed_cb(GtkTextBuffer *buffer, void *data) | |
| 205 | { | |
| 206 | char *xmlstr, *str; | |
| 207 | GtkTextIter iter; | |
| 208 | int wrapped_lines; | |
| 209 | int lines; | |
| 210 | GdkRectangle oneline; | |
| 211 | int height; | |
| 212 | int pad_top, pad_inside, pad_bottom; | |
| 213 | GtkTextIter start, end; | |
| 214 | xmlnode *node; | |
| 215 | ||
| 216 | wrapped_lines = 1; | |
| 217 | gtk_text_buffer_get_start_iter(buffer, &iter); | |
| 218 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); | |
| 219 | while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) | |
| 220 | wrapped_lines++; | |
| 221 | ||
| 222 | lines = gtk_text_buffer_get_line_count(buffer); | |
| 223 | ||
| 224 | /* Show a maximum of 64 lines */ | |
| 225 | lines = MIN(lines, 6); | |
| 226 | wrapped_lines = MIN(wrapped_lines, 6); | |
| 227 | ||
| 228 | pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(console->entry)); | |
| 229 | pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(console->entry)); | |
| 230 | pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(console->entry)); | |
| 231 | ||
| 232 | height = (oneline.height + pad_top + pad_bottom) * lines; | |
| 233 | height += (oneline.height + pad_inside) * (wrapped_lines - lines); | |
| 234 | ||
| 235 | gtk_widget_set_size_request(console->sw, -1, height+6); | |
| 236 | ||
| 237 | ||
| 238 | ||
| 239 | gtk_text_buffer_get_start_iter(buffer, &start); | |
| 240 | gtk_text_buffer_get_end_iter(buffer, &end); | |
| 241 | str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); | |
| 242 | if (!str) | |
| 243 | return; | |
| 244 | xmlstr = g_strdup_printf("<xml>%s</xml>", str); | |
| 245 | node = xmlnode_from_str(xmlstr, -1); | |
| 246 | if (node) { | |
| 247 | gtk_imhtml_clear_formatting(GTK_IMHTML(console->entry)); | |
| 248 | } else { | |
| 249 | gtk_imhtml_toggle_background(GTK_IMHTML(console->entry), "#ffcece"); | |
| 250 | } | |
| 251 | g_free(str); | |
| 252 | g_free(xmlstr); | |
| 253 | if (node) | |
| 254 | xmlnode_free(node); | |
| 255 | } | |
| 256 | ||
| 257 | static void iq_clicked_cb(GtkWidget *w, gpointer nul) | |
| 258 | { | |
| 259 | GtkWidget *hbox, *to_entry, *label, *type_combo; | |
| 260 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 261 | GtkTextIter iter; | |
| 262 | GtkTextBuffer *buffer; | |
| 263 | const char *to; | |
| 264 | int result; | |
| 265 | char *stanza; | |
| 266 | ||
| 267 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<iq/>", | |
| 268 | GTK_WINDOW(console->window), | |
| 269 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 270 | GTK_STOCK_CANCEL, | |
| 271 | GTK_RESPONSE_REJECT, | |
| 272 | GTK_STOCK_OK, | |
| 273 | GTK_RESPONSE_ACCEPT, | |
| 274 | NULL); | |
| 275 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 276 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 277 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 278 | ||
| 279 | hbox = gtk_hbox_new(FALSE, 3); | |
| 280 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 281 | ||
| 282 | label = gtk_label_new("To:"); | |
| 283 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 284 | gtk_size_group_add_widget(sg, label); | |
| 285 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 286 | ||
| 287 | to_entry = gtk_entry_new(); | |
| 288 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 289 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 290 | ||
| 291 | hbox = gtk_hbox_new(FALSE, 3); | |
| 292 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 293 | label = gtk_label_new("Type:"); | |
| 294 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 295 | ||
| 296 | gtk_size_group_add_widget(sg, label); | |
| 297 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 298 | type_combo = gtk_combo_box_new_text(); | |
| 299 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "get"); | |
| 300 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "set"); | |
| 301 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "result"); | |
| 302 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 303 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 304 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 305 | ||
| 306 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); | |
| 307 | ||
| 308 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 309 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 310 | gtk_widget_destroy(dialog); | |
| 311 | return; | |
| 312 | } | |
| 313 | ||
| 314 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); | |
| 315 | ||
| 316 | stanza = g_strdup_printf("<iq %s%s%s id='console%x' type='%s'></iq>", | |
| 317 | to && *to ? "to='" : "", | |
| 318 | to && *to ? to : "", | |
| 319 | to && *to ? "'" : "", | |
| 320 | g_random_int(), | |
| 321 | gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo))); | |
| 322 | ||
| 323 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 324 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 325 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</iq>") - stanza); | |
| 326 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 327 | g_free(stanza); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
328 | |
| 15412 | 329 | gtk_widget_destroy(dialog); |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
330 | g_object_unref(sg); |
| 15412 | 331 | |
| 332 | } | |
| 333 | ||
| 334 | static void presence_clicked_cb(GtkWidget *w, gpointer nul) | |
| 335 | { | |
| 336 | GtkWidget *hbox, | |
| 337 | *to_entry, | |
| 338 | *status_entry, | |
| 339 | *priority_entry, | |
| 340 | *label, | |
| 341 | *show_combo, | |
| 342 | *type_combo; | |
| 343 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 344 | GtkTextIter iter; | |
| 345 | GtkTextBuffer *buffer; | |
| 346 | const char *to, *type, *status, *show, *priority; | |
| 347 | int result; | |
| 348 | char *stanza; | |
| 349 | ||
| 350 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<presence/>", | |
| 351 | GTK_WINDOW(console->window), | |
| 352 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 353 | GTK_STOCK_CANCEL, | |
| 354 | GTK_RESPONSE_REJECT, | |
| 355 | GTK_STOCK_OK, | |
| 356 | GTK_RESPONSE_ACCEPT, | |
| 357 | NULL); | |
| 358 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 359 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 360 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 361 | ||
| 362 | hbox = gtk_hbox_new(FALSE, 3); | |
| 363 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 364 | ||
| 365 | label = gtk_label_new("To:"); | |
| 366 | gtk_size_group_add_widget(sg, label); | |
| 367 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 368 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 369 | ||
| 370 | to_entry = gtk_entry_new(); | |
| 371 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 372 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 373 | ||
| 374 | hbox = gtk_hbox_new(FALSE, 3); | |
| 375 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 376 | label = gtk_label_new("Type:"); | |
| 377 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 378 | gtk_size_group_add_widget(sg, label); | |
| 379 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 380 | type_combo = gtk_combo_box_new_text(); | |
| 381 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "default"); | |
| 382 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unavailable"); | |
| 383 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribe"); | |
| 384 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribe"); | |
| 385 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribed"); | |
| 386 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribed"); | |
| 387 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "probe"); | |
| 388 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 389 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 390 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 391 | ||
| 392 | hbox = gtk_hbox_new(FALSE, 3); | |
| 393 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 394 | label = gtk_label_new("Show:"); | |
| 395 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 396 | gtk_size_group_add_widget(sg, label); | |
| 397 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 398 | show_combo = gtk_combo_box_new_text(); | |
| 399 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "default"); | |
| 400 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "away"); | |
| 401 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "dnd"); | |
| 402 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "xa"); | |
| 403 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "chat"); | |
| 404 | ||
| 405 | gtk_combo_box_set_active(GTK_COMBO_BOX(show_combo), 0); | |
| 406 | gtk_box_pack_start(GTK_BOX(hbox), show_combo, FALSE, FALSE, 0); | |
| 407 | ||
| 408 | hbox = gtk_hbox_new(FALSE, 3); | |
| 409 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 410 | ||
| 411 | label = gtk_label_new("Status:"); | |
| 412 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 413 | gtk_size_group_add_widget(sg, label); | |
| 414 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 415 | ||
| 416 | status_entry = gtk_entry_new(); | |
| 417 | gtk_entry_set_activates_default (GTK_ENTRY (status_entry), TRUE); | |
| 418 | gtk_box_pack_start(GTK_BOX(hbox), status_entry, FALSE, FALSE, 0); | |
| 419 | ||
| 420 | ||
| 421 | hbox = gtk_hbox_new(FALSE, 3); | |
| 422 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 423 | ||
| 424 | label = gtk_label_new("Priority:"); | |
| 425 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 426 | gtk_size_group_add_widget(sg, label); | |
| 427 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 428 | ||
| 429 | priority_entry = gtk_spin_button_new_with_range(-128, 127, 1); | |
| 430 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(priority_entry), 0); | |
| 431 | gtk_box_pack_start(GTK_BOX(hbox), priority_entry, FALSE, FALSE, 0); | |
| 432 | ||
| 433 | ||
| 434 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); | |
| 435 | ||
| 436 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 437 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 438 | gtk_widget_destroy(dialog); | |
| 439 | return; | |
| 440 | } | |
| 441 | ||
| 442 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); | |
| 443 | type = gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)); | |
| 444 | if (!strcmp(type, "default")) | |
| 445 | type = ""; | |
| 446 | show = gtk_combo_box_get_active_text(GTK_COMBO_BOX(show_combo)); | |
| 447 | if (!strcmp(show, "default")) | |
| 448 | show = ""; | |
| 449 | status = gtk_entry_get_text(GTK_ENTRY(status_entry)); | |
| 450 | priority = gtk_entry_get_text(GTK_ENTRY(priority_entry)); | |
| 451 | if (!strcmp(priority, "0")) | |
| 452 | priority = ""; | |
| 453 | ||
| 454 | ||
| 455 | ||
| 456 | stanza = g_strdup_printf("<presence %s%s%s id='console%x' %s%s%s>" | |
| 457 | "%s%s%s%s%s%s%s%s%s" | |
| 458 | "</presence>", | |
| 459 | *to ? "to='" : "", | |
| 460 | *to ? to : "", | |
| 461 | *to ? "'" : "", | |
| 462 | g_random_int(), | |
| 463 | ||
| 464 | *type ? "type='" : "", | |
| 465 | *type ? type : "", | |
| 466 | *type ? "'" : "", | |
| 467 | ||
| 468 | *show ? "<show>" : "", | |
| 469 | *show ? show : "", | |
| 470 | *show ? "</show>" : "", | |
| 471 | ||
| 472 | *status ? "<status>" : "", | |
| 473 | *status ? status : "", | |
| 474 | *status ? "</status>" : "", | |
| 475 | ||
| 476 | *priority ? "<priority>" : "", | |
| 477 | *priority ? priority : "", | |
| 478 | *priority ? "</priority>" : ""); | |
| 479 | ||
| 480 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 481 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 482 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</presence>") - stanza); | |
| 483 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 484 | g_free(stanza); | |
| 485 | ||
| 486 | gtk_widget_destroy(dialog); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
487 | g_object_unref(sg); |
| 15412 | 488 | } |
| 489 | ||
| 490 | static void message_clicked_cb(GtkWidget *w, gpointer nul) | |
| 491 | { | |
| 492 | GtkWidget *hbox, | |
| 493 | *to_entry, | |
| 494 | *body_entry, | |
| 495 | *thread_entry, | |
| 496 | *subject_entry, | |
| 497 | *label, | |
| 498 | *type_combo; | |
| 499 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 500 | GtkTextIter iter; | |
| 501 | GtkTextBuffer *buffer; | |
| 502 | const char *to, *body, *thread, *subject; | |
| 503 | char *stanza; | |
| 504 | int result; | |
| 505 | ||
| 506 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<message/>", | |
| 507 | GTK_WINDOW(console->window), | |
| 508 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 509 | GTK_STOCK_CANCEL, | |
| 510 | GTK_RESPONSE_REJECT, | |
| 511 | GTK_STOCK_OK, | |
| 512 | GTK_RESPONSE_ACCEPT, | |
| 513 | NULL); | |
| 514 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 515 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 516 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 517 | ||
| 518 | hbox = gtk_hbox_new(FALSE, 3); | |
| 519 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 520 | ||
| 521 | label = gtk_label_new("To:"); | |
| 522 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 523 | gtk_size_group_add_widget(sg, label); | |
| 524 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 525 | ||
| 526 | to_entry = gtk_entry_new(); | |
| 527 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 528 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 529 | ||
| 530 | hbox = gtk_hbox_new(FALSE, 3); | |
| 531 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 532 | label = gtk_label_new("Type:"); | |
| 533 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 534 | gtk_size_group_add_widget(sg, label); | |
| 535 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 536 | type_combo = gtk_combo_box_new_text(); | |
| 537 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "chat"); | |
| 538 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "headline"); | |
| 539 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "groupchat"); | |
| 540 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "normal"); | |
| 541 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 542 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 543 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 544 | ||
| 545 | hbox = gtk_hbox_new(FALSE, 3); | |
| 546 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 547 | ||
| 548 | label = gtk_label_new("Body:"); | |
| 549 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 550 | gtk_size_group_add_widget(sg, label); | |
| 551 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 552 | ||
| 553 | body_entry = gtk_entry_new(); | |
| 554 | gtk_entry_set_activates_default (GTK_ENTRY (body_entry), TRUE); | |
| 555 | gtk_box_pack_start(GTK_BOX(hbox), body_entry, FALSE, FALSE, 0); | |
| 556 | ||
| 557 | ||
| 558 | hbox = gtk_hbox_new(FALSE, 3); | |
| 559 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 560 | ||
| 561 | label = gtk_label_new("Subject:"); | |
| 562 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 563 | gtk_size_group_add_widget(sg, label); | |
| 564 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 565 | ||
| 566 | subject_entry = gtk_entry_new(); | |
| 567 | gtk_entry_set_activates_default (GTK_ENTRY (subject_entry), TRUE); | |
| 568 | gtk_box_pack_start(GTK_BOX(hbox), subject_entry, FALSE, FALSE, 0); | |
| 569 | ||
| 570 | hbox = gtk_hbox_new(FALSE, 3); | |
| 571 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 572 | ||
| 573 | label = gtk_label_new("Thread:"); | |
| 574 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 575 | gtk_size_group_add_widget(sg, label); | |
| 576 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 577 | ||
| 578 | thread_entry = gtk_entry_new(); | |
| 579 | gtk_entry_set_activates_default (GTK_ENTRY (thread_entry), TRUE); | |
| 580 | gtk_box_pack_start(GTK_BOX(hbox), thread_entry, FALSE, FALSE, 0); | |
| 581 | ||
| 582 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); | |
| 583 | ||
| 584 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 585 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 586 | gtk_widget_destroy(dialog); | |
| 587 | return; | |
| 588 | } | |
| 589 | ||
| 590 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); | |
| 591 | body = gtk_entry_get_text(GTK_ENTRY(body_entry)); | |
| 592 | thread = gtk_entry_get_text(GTK_ENTRY(thread_entry)); | |
| 593 | subject = gtk_entry_get_text(GTK_ENTRY(subject_entry)); | |
| 594 | ||
| 595 | stanza = g_strdup_printf("<message %s%s%s id='console%x' type='%s'>" | |
| 596 | "%s%s%s%s%s%s%s%s%s" | |
| 597 | "</message>", | |
| 598 | ||
| 599 | *to ? "to='" : "", | |
| 600 | *to ? to : "", | |
| 601 | *to ? "'" : "", | |
| 602 | g_random_int(), | |
| 603 | gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)), | |
| 604 | ||
| 605 | *body ? "<body>" : "", | |
| 606 | *body ? body : "", | |
| 607 | *body ? "</body>" : "", | |
| 608 | ||
| 609 | *subject ? "<subject>" : "", | |
| 610 | *subject ? subject : "", | |
| 611 | *subject ? "</subject>" : "", | |
| 612 | ||
| 613 | *thread ? "<thread>" : "", | |
| 614 | *thread ? thread : "", | |
| 615 | *thread ? "</thread>" : ""); | |
| 616 | ||
| 617 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 618 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 619 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</message>") - stanza); | |
| 620 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 621 | g_free(stanza); | |
| 622 | ||
| 623 | gtk_widget_destroy(dialog); | |
|
20289
5c844288fbec
applied changes from 32f31e981f0618a4167aa98bcc22c2dab13d1550
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
20288
diff
changeset
|
624 | g_object_unref(sg); |
| 15412 | 625 | } |
| 626 | ||
| 627 | static void | |
| 15884 | 628 | signed_on_cb(PurpleConnection *gc) |
| 15412 | 629 | { |
| 630 | if (!console) | |
| 631 | return; | |
| 632 | ||
| 15884 | 633 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), purple_account_get_username(gc->account)); |
| 15412 | 634 | console->accounts = g_list_append(console->accounts, gc); |
| 635 | console->count++; | |
| 636 | ||
| 637 | if (console->count > 1) | |
| 638 | gtk_widget_show_all(console->hbox); | |
| 639 | } | |
| 640 | ||
| 641 | static void | |
| 15884 | 642 | signed_off_cb(PurpleConnection *gc) |
| 15412 | 643 | { |
| 644 | int i = 0; | |
| 645 | GList *l; | |
| 646 | ||
| 647 | if (!console) | |
| 648 | return; | |
| 649 | ||
| 650 | l = console->accounts; | |
| 651 | while (l) { | |
| 15884 | 652 | PurpleConnection *g = l->data; |
| 15412 | 653 | if (gc == g) |
| 654 | break; | |
| 655 | i++; | |
| 656 | l = l->next; | |
| 657 | } | |
| 658 | ||
| 659 | if (l == NULL) | |
| 660 | return; | |
| 661 | ||
| 662 | gtk_combo_box_remove_text(GTK_COMBO_BOX(console->dropdown), i); | |
| 663 | console->accounts = g_list_remove(console->accounts, gc); | |
| 15884 | 664 | printf("%s\n", purple_account_get_username(gc->account)); |
| 15412 | 665 | console->count--; |
| 666 | ||
| 667 | if (gc == console->gc) { | |
| 668 | console->gc = NULL; | |
| 669 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), | |
| 670 | _("<font color='#777777'>Logged out.</font>"), 0); | |
| 671 | } | |
| 672 | } | |
| 673 | ||
| 674 | static gboolean | |
| 15884 | 675 | plugin_load(PurplePlugin *plugin) |
| 15412 | 676 | { |
| 15884 | 677 | PurplePlugin *jabber; |
| 15412 | 678 | |
| 15884 | 679 | jabber = purple_find_prpl("prpl-jabber"); |
| 15412 | 680 | if (!jabber) |
| 681 | return FALSE; | |
| 682 | ||
| 683 | xmpp_console_handle = plugin; | |
| 15884 | 684 | purple_signal_connect(jabber, "jabber-receiving-xmlnode", xmpp_console_handle, |
| 685 | PURPLE_CALLBACK(xmlnode_received_cb), NULL); | |
| 686 | purple_signal_connect(jabber, "jabber-sending-text", xmpp_console_handle, | |
| 687 | PURPLE_CALLBACK(xmlnode_sent_cb), NULL); | |
| 688 | purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
| 689 | plugin, PURPLE_CALLBACK(signed_on_cb), NULL); | |
| 690 | purple_signal_connect(purple_connections_get_handle(), "signed-off", | |
| 691 | plugin, PURPLE_CALLBACK(signed_off_cb), NULL); | |
| 15412 | 692 | |
| 693 | return TRUE; | |
| 694 | } | |
| 695 | ||
| 696 | static gboolean | |
| 15884 | 697 | plugin_unload(PurplePlugin *plugin) |
| 15412 | 698 | { |
| 15414 | 699 | if (console) |
| 700 | gtk_widget_destroy(console->window); | |
| 15412 | 701 | return TRUE; |
| 702 | } | |
| 703 | ||
| 704 | static void | |
| 705 | console_destroy(GtkObject *window, gpointer nul) | |
| 706 | { | |
| 707 | g_list_free(console->accounts); | |
| 708 | g_free(console); | |
| 709 | console = NULL; | |
| 710 | } | |
| 711 | ||
| 712 | static void | |
| 713 | dropdown_changed_cb(GtkComboBox *widget, gpointer nul) | |
| 714 | { | |
| 15884 | 715 | PurpleAccount *account; |
| 15412 | 716 | |
| 717 | if (!console) | |
| 718 | return; | |
| 719 | ||
| 15884 | 720 | account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)), |
| 15412 | 721 | "prpl-jabber"); |
| 722 | if (!account || !account->gc) | |
| 723 | return; | |
| 724 | ||
| 725 | console->gc = account->gc; | |
| 726 | gtk_imhtml_clear(GTK_IMHTML(console->imhtml)); | |
| 727 | } | |
| 728 | ||
| 729 | static void | |
|
22108
cb9819851163
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
730 | create_console(PurplePluginAction *action) |
| 15412 | 731 | { |
| 732 | GtkWidget *vbox = gtk_vbox_new(FALSE, 6); | |
| 733 | GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); | |
| 734 | GtkWidget *label; | |
| 735 | GtkTextBuffer *buffer; | |
| 736 | GtkWidget *toolbar; | |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
737 | GList *connections; |
| 15427 | 738 | #if GTK_CHECK_VERSION(2,4,0) |
| 15412 | 739 | GtkToolItem *button; |
| 15427 | 740 | #endif |
| 15412 | 741 | |
| 742 | if (console) { | |
| 743 | gtk_window_present(GTK_WINDOW(console->window)); | |
| 744 | return; | |
| 745 | } | |
| 746 | ||
| 747 | console = g_new0(XmppConsole, 1); | |
| 748 | ||
| 17213 | 749 | console->window = pidgin_create_window(_("XMPP Console"), PIDGIN_HIG_BORDER, NULL, TRUE); |
| 15412 | 750 | g_signal_connect(G_OBJECT(console->window), "destroy", G_CALLBACK(console_destroy), NULL); |
| 751 | gtk_window_set_default_size(GTK_WINDOW(console->window), 580, 400); | |
| 752 | gtk_container_add(GTK_CONTAINER(console->window), vbox); | |
| 753 | ||
| 754 | console->hbox = gtk_hbox_new(FALSE, 3); | |
| 755 | gtk_box_pack_start(GTK_BOX(vbox), console->hbox, FALSE, FALSE, 0); | |
| 756 | label = gtk_label_new(_("Account: ")); | |
| 757 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
| 758 | gtk_box_pack_start(GTK_BOX(console->hbox), label, FALSE, FALSE, 0); | |
| 759 | console->dropdown = gtk_combo_box_new_text(); | |
| 15884 | 760 | for (connections = purple_connections_get_all(); connections; connections = connections->next) { |
| 761 | PurpleConnection *gc = connections->data; | |
| 762 | if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), "prpl-jabber")) { | |
| 15412 | 763 | console->count++; |
| 764 | console->accounts = g_list_append(console->accounts, gc); | |
| 765 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), | |
| 15884 | 766 | purple_account_get_username(purple_connection_get_account(gc))); |
| 15412 | 767 | if (!console->gc) |
| 768 | console->gc = gc; | |
| 769 | } | |
| 770 | } | |
| 771 | gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown),0); | |
| 772 | gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0); | |
| 773 | g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL); | |
| 774 | ||
| 775 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); | |
| 776 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 777 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
| 778 | ||
| 779 | console->imhtml = gtk_imhtml_new(NULL, NULL); | |
| 780 | gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
| 781 | if (console->count == 0) | |
| 782 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), | |
| 783 | _("<font color='#777777'>Not connected to XMPP</font>"), 0); | |
| 784 | gtk_container_add(GTK_CONTAINER(sw), console->imhtml); | |
| 785 | ||
| 786 | toolbar = gtk_toolbar_new(); | |
| 15427 | 787 | #if GTK_CHECK_VERSION(2,4,0) |
| 15412 | 788 | button = gtk_tool_button_new(NULL, "<iq/>"); |
| 789 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(iq_clicked_cb), NULL); | |
| 790 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 15427 | 791 | #else |
| 792 | gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<iq/>", | |
| 793 | _("Insert an <iq/> stanza."), "foo", NULL, GTK_SIGNAL_FUNC(iq_clicked_cb), NULL); | |
| 794 | #endif | |
| 15412 | 795 | |
| 15427 | 796 | #if GTK_CHECK_VERSION(2,4,0) |
| 15412 | 797 | button = gtk_tool_button_new(NULL, "<presence/>"); |
| 798 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(presence_clicked_cb), NULL); | |
| 799 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 15427 | 800 | #else |
| 801 | gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<presence/>", | |
| 802 | _("Insert a <presence/> stanza."), NULL, gtk_label_new(NULL), GTK_SIGNAL_FUNC(presence_clicked_cb), NULL); | |
| 803 | #endif | |
| 15412 | 804 | |
| 15427 | 805 | #if GTK_CHECK_VERSION(2,4,0) |
| 15412 | 806 | button = gtk_tool_button_new(NULL, "<message/>"); |
| 807 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(message_clicked_cb), NULL); | |
| 808 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 15427 | 809 | #else |
| 810 | gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<message/>", | |
| 811 | _("Insert a <message/> stanza."), "foo", gtk_label_new(NULL), GTK_SIGNAL_FUNC(message_clicked_cb), NULL); | |
| 812 | #endif | |
| 813 | ||
| 15412 | 814 | gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); |
| 815 | ||
| 816 | sw = gtk_scrolled_window_new(NULL, NULL); | |
| 817 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); | |
| 818 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 819 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
| 820 | ||
| 821 | console->entry = gtk_imhtml_new(NULL, NULL); | |
| 822 | gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(console->entry), TRUE); | |
| 823 | g_signal_connect(G_OBJECT(console->entry),"message_send", G_CALLBACK(message_send_cb), console); | |
| 824 | ||
| 825 | gtk_box_pack_start(GTK_BOX(vbox), sw, FALSE, FALSE, 0); | |
| 826 | gtk_container_add(GTK_CONTAINER(sw), console->entry); | |
| 827 | gtk_imhtml_set_editable(GTK_IMHTML(console->entry), TRUE); | |
| 828 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 829 | g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(entry_changed_cb), NULL); | |
| 830 | console->sw = sw; | |
| 831 | entry_changed_cb(buffer, NULL); | |
| 832 | ||
| 833 | gtk_widget_show_all(console->window); | |
| 834 | if (console->count < 2) | |
| 835 | gtk_widget_hide(console->hbox); | |
| 836 | } | |
| 837 | ||
| 838 | static GList * | |
| 15884 | 839 | actions(PurplePlugin *plugin, gpointer context) |
| 15412 | 840 | { |
| 841 | GList *l = NULL; | |
| 15884 | 842 | PurplePluginAction *act = NULL; |
| 15412 | 843 | |
| 15884 | 844 | act = purple_plugin_action_new(_("XMPP Console"), create_console); |
| 15412 | 845 | l = g_list_append(l, act); |
| 846 | ||
| 847 | return l; | |
| 848 | } | |
| 849 | ||
| 850 | ||
| 15884 | 851 | static PurplePluginInfo info = |
| 15412 | 852 | { |
| 15884 | 853 | PURPLE_PLUGIN_MAGIC, |
| 854 | PURPLE_MAJOR_VERSION, | |
| 855 | PURPLE_MINOR_VERSION, | |
| 856 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
857 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 15412 | 858 | 0, /**< flags */ |
| 859 | NULL, /**< dependencies */ | |
| 15884 | 860 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 15412 | 861 | |
| 862 | "gtk-xmpp", /**< id */ | |
| 863 | N_("XMPP Console"), /**< name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
864 | DISPLAY_VERSION, /**< version */ |
| 15412 | 865 | /** summary */ |
| 866 | N_("Send and receive raw XMPP stanzas."), | |
| 867 | /** description */ | |
| 868 | N_("This plugin is useful for debbuging XMPP servers or clients."), | |
| 869 | "Sean Egan <seanegan@gmail.com>", /**< author */ | |
| 15884 | 870 | PURPLE_WEBSITE, /**< homepage */ |
| 15412 | 871 | |
| 872 | plugin_load, /**< load */ | |
| 873 | plugin_unload, /**< unload */ | |
| 874 | NULL, /**< destroy */ | |
| 875 | ||
| 876 | NULL, /**< ui_info */ | |
| 877 | NULL, /**< extra_info */ | |
| 878 | NULL, | |
|
16749
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
879 | actions, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
880 | |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
881 | /* padding */ |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
882 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
883 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
884 | NULL, |
|
14a3fdc0aed7
Default plugins are done, for the release i'm not that concerned about plugins that do _NOT_ compile by default
Gary Kramlich <grim@reaperworld.com>
parents:
16290
diff
changeset
|
885 | NULL |
| 15412 | 886 | }; |
| 887 | ||
| 888 | static void | |
| 15884 | 889 | init_plugin(PurplePlugin *plugin) |
| 15412 | 890 | { |
| 891 | } | |
| 892 | ||
| 15884 | 893 | PURPLE_INIT_PLUGIN(interval, init_plugin, info) |