Sun, 20 May 2007 14:53:34 +0000
#include "gtkutils.h"
| 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 | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 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; | |
| 187 | ||
| 15884 | 188 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
| 15412 | 189 | |
| 190 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 191 | gtk_text_buffer_get_start_iter(buffer, &start); | |
| 192 | gtk_text_buffer_get_end_iter(buffer, &end); | |
| 193 | ||
| 194 | text = gtk_imhtml_get_text(GTK_IMHTML(console->entry), &start, &end); | |
| 195 | ||
| 196 | if (gc && prpl_info->convo_closed != NULL) | |
| 197 | prpl_info->send_raw(gc, text, strlen(text)); | |
| 198 | ||
| 199 | g_free(text); | |
| 200 | gtk_imhtml_clear(GTK_IMHTML(console->entry)); | |
| 201 | } | |
| 202 | ||
| 203 | static void entry_changed_cb(GtkTextBuffer *buffer, void *data) | |
| 204 | { | |
| 205 | char *xmlstr, *str; | |
| 206 | GtkTextIter iter; | |
| 207 | int wrapped_lines; | |
| 208 | int lines; | |
| 209 | GdkRectangle oneline; | |
| 210 | int height; | |
| 211 | int pad_top, pad_inside, pad_bottom; | |
| 212 | GtkTextIter start, end; | |
| 213 | xmlnode *node; | |
| 214 | ||
| 215 | wrapped_lines = 1; | |
| 216 | gtk_text_buffer_get_start_iter(buffer, &iter); | |
| 217 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); | |
| 218 | while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) | |
| 219 | wrapped_lines++; | |
| 220 | ||
| 221 | lines = gtk_text_buffer_get_line_count(buffer); | |
| 222 | ||
| 223 | /* Show a maximum of 64 lines */ | |
| 224 | lines = MIN(lines, 6); | |
| 225 | wrapped_lines = MIN(wrapped_lines, 6); | |
| 226 | ||
| 227 | pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(console->entry)); | |
| 228 | pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(console->entry)); | |
| 229 | pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(console->entry)); | |
| 230 | ||
| 231 | height = (oneline.height + pad_top + pad_bottom) * lines; | |
| 232 | height += (oneline.height + pad_inside) * (wrapped_lines - lines); | |
| 233 | ||
| 234 | gtk_widget_set_size_request(console->sw, -1, height+6); | |
| 235 | ||
| 236 | ||
| 237 | ||
| 238 | gtk_text_buffer_get_start_iter(buffer, &start); | |
| 239 | gtk_text_buffer_get_end_iter(buffer, &end); | |
| 240 | str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); | |
| 241 | if (!str) | |
| 242 | return; | |
| 243 | xmlstr = g_strdup_printf("<xml>%s</xml>", str); | |
| 244 | node = xmlnode_from_str(xmlstr, -1); | |
| 245 | if (node) { | |
| 246 | gtk_imhtml_clear_formatting(GTK_IMHTML(console->entry)); | |
| 247 | } else { | |
| 248 | gtk_imhtml_toggle_background(GTK_IMHTML(console->entry), "#ffcece"); | |
| 249 | } | |
| 250 | g_free(str); | |
| 251 | g_free(xmlstr); | |
| 252 | if (node) | |
| 253 | xmlnode_free(node); | |
| 254 | } | |
| 255 | ||
| 256 | static void iq_clicked_cb(GtkWidget *w, gpointer nul) | |
| 257 | { | |
| 258 | GtkWidget *hbox, *to_entry, *label, *type_combo; | |
| 259 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 260 | GtkTextIter iter; | |
| 261 | GtkTextBuffer *buffer; | |
| 262 | const char *to; | |
| 263 | int result; | |
| 264 | char *stanza; | |
| 265 | ||
| 266 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<iq/>", | |
| 267 | GTK_WINDOW(console->window), | |
| 268 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 269 | GTK_STOCK_CANCEL, | |
| 270 | GTK_RESPONSE_REJECT, | |
| 271 | GTK_STOCK_OK, | |
| 272 | GTK_RESPONSE_ACCEPT, | |
| 273 | NULL); | |
| 274 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 275 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 276 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 277 | ||
| 278 | hbox = gtk_hbox_new(FALSE, 3); | |
| 279 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 280 | ||
| 281 | label = gtk_label_new("To:"); | |
| 282 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 283 | gtk_size_group_add_widget(sg, label); | |
| 284 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 285 | ||
| 286 | to_entry = gtk_entry_new(); | |
| 287 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 288 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 289 | ||
| 290 | hbox = gtk_hbox_new(FALSE, 3); | |
| 291 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 292 | label = gtk_label_new("Type:"); | |
| 293 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 294 | ||
| 295 | gtk_size_group_add_widget(sg, label); | |
| 296 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 297 | type_combo = gtk_combo_box_new_text(); | |
| 298 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "get"); | |
| 299 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "set"); | |
| 300 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "result"); | |
| 301 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 302 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 303 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 304 | ||
| 305 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); | |
| 306 | ||
| 307 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 308 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 309 | gtk_widget_destroy(dialog); | |
| 310 | return; | |
| 311 | } | |
| 312 | ||
| 313 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); | |
| 314 | ||
| 315 | stanza = g_strdup_printf("<iq %s%s%s id='console%x' type='%s'></iq>", | |
| 316 | to && *to ? "to='" : "", | |
| 317 | to && *to ? to : "", | |
| 318 | to && *to ? "'" : "", | |
| 319 | g_random_int(), | |
| 320 | gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo))); | |
| 321 | ||
| 322 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 323 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 324 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</iq>") - stanza); | |
| 325 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 326 | g_free(stanza); | |
| 327 | ||
| 328 | gtk_widget_destroy(dialog); | |
| 329 | ||
| 330 | } | |
| 331 | ||
| 332 | static void presence_clicked_cb(GtkWidget *w, gpointer nul) | |
| 333 | { | |
| 334 | GtkWidget *hbox, | |
| 335 | *to_entry, | |
| 336 | *status_entry, | |
| 337 | *priority_entry, | |
| 338 | *label, | |
| 339 | *show_combo, | |
| 340 | *type_combo; | |
| 341 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 342 | GtkTextIter iter; | |
| 343 | GtkTextBuffer *buffer; | |
| 344 | const char *to, *type, *status, *show, *priority; | |
| 345 | int result; | |
| 346 | char *stanza; | |
| 347 | ||
| 348 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<presence/>", | |
| 349 | GTK_WINDOW(console->window), | |
| 350 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 351 | GTK_STOCK_CANCEL, | |
| 352 | GTK_RESPONSE_REJECT, | |
| 353 | GTK_STOCK_OK, | |
| 354 | GTK_RESPONSE_ACCEPT, | |
| 355 | NULL); | |
| 356 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 357 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 358 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 359 | ||
| 360 | hbox = gtk_hbox_new(FALSE, 3); | |
| 361 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 362 | ||
| 363 | label = gtk_label_new("To:"); | |
| 364 | gtk_size_group_add_widget(sg, label); | |
| 365 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 366 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 367 | ||
| 368 | to_entry = gtk_entry_new(); | |
| 369 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 370 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 371 | ||
| 372 | hbox = gtk_hbox_new(FALSE, 3); | |
| 373 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 374 | label = gtk_label_new("Type:"); | |
| 375 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 376 | gtk_size_group_add_widget(sg, label); | |
| 377 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 378 | type_combo = gtk_combo_box_new_text(); | |
| 379 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "default"); | |
| 380 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unavailable"); | |
| 381 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribe"); | |
| 382 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribe"); | |
| 383 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribed"); | |
| 384 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribed"); | |
| 385 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "probe"); | |
| 386 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 387 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 388 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 389 | ||
| 390 | hbox = gtk_hbox_new(FALSE, 3); | |
| 391 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 392 | label = gtk_label_new("Show:"); | |
| 393 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 394 | gtk_size_group_add_widget(sg, label); | |
| 395 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 396 | show_combo = gtk_combo_box_new_text(); | |
| 397 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "default"); | |
| 398 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "away"); | |
| 399 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "dnd"); | |
| 400 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "xa"); | |
| 401 | gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "chat"); | |
| 402 | ||
| 403 | gtk_combo_box_set_active(GTK_COMBO_BOX(show_combo), 0); | |
| 404 | gtk_box_pack_start(GTK_BOX(hbox), show_combo, FALSE, FALSE, 0); | |
| 405 | ||
| 406 | hbox = gtk_hbox_new(FALSE, 3); | |
| 407 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 408 | ||
| 409 | label = gtk_label_new("Status:"); | |
| 410 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 411 | gtk_size_group_add_widget(sg, label); | |
| 412 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 413 | ||
| 414 | status_entry = gtk_entry_new(); | |
| 415 | gtk_entry_set_activates_default (GTK_ENTRY (status_entry), TRUE); | |
| 416 | gtk_box_pack_start(GTK_BOX(hbox), status_entry, FALSE, FALSE, 0); | |
| 417 | ||
| 418 | ||
| 419 | hbox = gtk_hbox_new(FALSE, 3); | |
| 420 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 421 | ||
| 422 | label = gtk_label_new("Priority:"); | |
| 423 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 424 | gtk_size_group_add_widget(sg, label); | |
| 425 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 426 | ||
| 427 | priority_entry = gtk_spin_button_new_with_range(-128, 127, 1); | |
| 428 | gtk_spin_button_set_value(GTK_SPIN_BUTTON(priority_entry), 0); | |
| 429 | gtk_box_pack_start(GTK_BOX(hbox), priority_entry, FALSE, FALSE, 0); | |
| 430 | ||
| 431 | ||
| 432 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); | |
| 433 | ||
| 434 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 435 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 436 | gtk_widget_destroy(dialog); | |
| 437 | return; | |
| 438 | } | |
| 439 | ||
| 440 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); | |
| 441 | type = gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)); | |
| 442 | if (!strcmp(type, "default")) | |
| 443 | type = ""; | |
| 444 | show = gtk_combo_box_get_active_text(GTK_COMBO_BOX(show_combo)); | |
| 445 | if (!strcmp(show, "default")) | |
| 446 | show = ""; | |
| 447 | status = gtk_entry_get_text(GTK_ENTRY(status_entry)); | |
| 448 | priority = gtk_entry_get_text(GTK_ENTRY(priority_entry)); | |
| 449 | if (!strcmp(priority, "0")) | |
| 450 | priority = ""; | |
| 451 | ||
| 452 | ||
| 453 | ||
| 454 | stanza = g_strdup_printf("<presence %s%s%s id='console%x' %s%s%s>" | |
| 455 | "%s%s%s%s%s%s%s%s%s" | |
| 456 | "</presence>", | |
| 457 | *to ? "to='" : "", | |
| 458 | *to ? to : "", | |
| 459 | *to ? "'" : "", | |
| 460 | g_random_int(), | |
| 461 | ||
| 462 | *type ? "type='" : "", | |
| 463 | *type ? type : "", | |
| 464 | *type ? "'" : "", | |
| 465 | ||
| 466 | *show ? "<show>" : "", | |
| 467 | *show ? show : "", | |
| 468 | *show ? "</show>" : "", | |
| 469 | ||
| 470 | *status ? "<status>" : "", | |
| 471 | *status ? status : "", | |
| 472 | *status ? "</status>" : "", | |
| 473 | ||
| 474 | *priority ? "<priority>" : "", | |
| 475 | *priority ? priority : "", | |
| 476 | *priority ? "</priority>" : ""); | |
| 477 | ||
| 478 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 479 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 480 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</presence>") - stanza); | |
| 481 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 482 | g_free(stanza); | |
| 483 | ||
| 484 | gtk_widget_destroy(dialog); | |
| 485 | } | |
| 486 | ||
| 487 | static void message_clicked_cb(GtkWidget *w, gpointer nul) | |
| 488 | { | |
| 489 | GtkWidget *hbox, | |
| 490 | *to_entry, | |
| 491 | *body_entry, | |
| 492 | *thread_entry, | |
| 493 | *subject_entry, | |
| 494 | *label, | |
| 495 | *type_combo; | |
| 496 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 497 | GtkTextIter iter; | |
| 498 | GtkTextBuffer *buffer; | |
| 499 | const char *to, *body, *thread, *subject; | |
| 500 | char *stanza; | |
| 501 | int result; | |
| 502 | ||
| 503 | GtkWidget *dialog = gtk_dialog_new_with_buttons("<message/>", | |
| 504 | GTK_WINDOW(console->window), | |
| 505 | GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 506 | GTK_STOCK_CANCEL, | |
| 507 | GTK_RESPONSE_REJECT, | |
| 508 | GTK_STOCK_OK, | |
| 509 | GTK_RESPONSE_ACCEPT, | |
| 510 | NULL); | |
| 511 | gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
| 512 | gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); | |
| 513 | gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); | |
| 514 | ||
| 515 | hbox = gtk_hbox_new(FALSE, 3); | |
| 516 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 517 | ||
| 518 | label = gtk_label_new("To:"); | |
| 519 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 520 | gtk_size_group_add_widget(sg, label); | |
| 521 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 522 | ||
| 523 | to_entry = gtk_entry_new(); | |
| 524 | gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); | |
| 525 | gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); | |
| 526 | ||
| 527 | hbox = gtk_hbox_new(FALSE, 3); | |
| 528 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 529 | label = gtk_label_new("Type:"); | |
| 530 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 531 | gtk_size_group_add_widget(sg, label); | |
| 532 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 533 | type_combo = gtk_combo_box_new_text(); | |
| 534 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "chat"); | |
| 535 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "headline"); | |
| 536 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "groupchat"); | |
| 537 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "normal"); | |
| 538 | gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); | |
| 539 | gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); | |
| 540 | gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); | |
| 541 | ||
| 542 | hbox = gtk_hbox_new(FALSE, 3); | |
| 543 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 544 | ||
| 545 | label = gtk_label_new("Body:"); | |
| 546 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 547 | gtk_size_group_add_widget(sg, label); | |
| 548 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 549 | ||
| 550 | body_entry = gtk_entry_new(); | |
| 551 | gtk_entry_set_activates_default (GTK_ENTRY (body_entry), TRUE); | |
| 552 | gtk_box_pack_start(GTK_BOX(hbox), body_entry, FALSE, FALSE, 0); | |
| 553 | ||
| 554 | ||
| 555 | hbox = gtk_hbox_new(FALSE, 3); | |
| 556 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 557 | ||
| 558 | label = gtk_label_new("Subject:"); | |
| 559 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 560 | gtk_size_group_add_widget(sg, label); | |
| 561 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 562 | ||
| 563 | subject_entry = gtk_entry_new(); | |
| 564 | gtk_entry_set_activates_default (GTK_ENTRY (subject_entry), TRUE); | |
| 565 | gtk_box_pack_start(GTK_BOX(hbox), subject_entry, FALSE, FALSE, 0); | |
| 566 | ||
| 567 | hbox = gtk_hbox_new(FALSE, 3); | |
| 568 | gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); | |
| 569 | ||
| 570 | label = gtk_label_new("Thread:"); | |
| 571 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 572 | gtk_size_group_add_widget(sg, label); | |
| 573 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
| 574 | ||
| 575 | thread_entry = gtk_entry_new(); | |
| 576 | gtk_entry_set_activates_default (GTK_ENTRY (thread_entry), TRUE); | |
| 577 | gtk_box_pack_start(GTK_BOX(hbox), thread_entry, FALSE, FALSE, 0); | |
| 578 | ||
| 579 | gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); | |
| 580 | ||
| 581 | result = gtk_dialog_run(GTK_DIALOG(dialog)); | |
| 582 | if (result != GTK_RESPONSE_ACCEPT) { | |
| 583 | gtk_widget_destroy(dialog); | |
| 584 | return; | |
| 585 | } | |
| 586 | ||
| 587 | to = gtk_entry_get_text(GTK_ENTRY(to_entry)); | |
| 588 | body = gtk_entry_get_text(GTK_ENTRY(body_entry)); | |
| 589 | thread = gtk_entry_get_text(GTK_ENTRY(thread_entry)); | |
| 590 | subject = gtk_entry_get_text(GTK_ENTRY(subject_entry)); | |
| 591 | ||
| 592 | stanza = g_strdup_printf("<message %s%s%s id='console%x' type='%s'>" | |
| 593 | "%s%s%s%s%s%s%s%s%s" | |
| 594 | "</message>", | |
| 595 | ||
| 596 | *to ? "to='" : "", | |
| 597 | *to ? to : "", | |
| 598 | *to ? "'" : "", | |
| 599 | g_random_int(), | |
| 600 | gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)), | |
| 601 | ||
| 602 | *body ? "<body>" : "", | |
| 603 | *body ? body : "", | |
| 604 | *body ? "</body>" : "", | |
| 605 | ||
| 606 | *subject ? "<subject>" : "", | |
| 607 | *subject ? subject : "", | |
| 608 | *subject ? "</subject>" : "", | |
| 609 | ||
| 610 | *thread ? "<thread>" : "", | |
| 611 | *thread ? thread : "", | |
| 612 | *thread ? "</thread>" : ""); | |
| 613 | ||
| 614 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 615 | gtk_text_buffer_set_text(buffer, stanza, -1); | |
| 616 | gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "</message>") - stanza); | |
| 617 | gtk_text_buffer_place_cursor(buffer, &iter); | |
| 618 | g_free(stanza); | |
| 619 | ||
| 620 | gtk_widget_destroy(dialog); | |
| 621 | } | |
| 622 | ||
| 623 | static void | |
| 15884 | 624 | signed_on_cb(PurpleConnection *gc) |
| 15412 | 625 | { |
| 626 | if (!console) | |
| 627 | return; | |
| 628 | ||
| 15884 | 629 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), purple_account_get_username(gc->account)); |
| 15412 | 630 | console->accounts = g_list_append(console->accounts, gc); |
| 631 | console->count++; | |
| 632 | ||
| 633 | if (console->count > 1) | |
| 634 | gtk_widget_show_all(console->hbox); | |
| 635 | } | |
| 636 | ||
| 637 | static void | |
| 15884 | 638 | signed_off_cb(PurpleConnection *gc) |
| 15412 | 639 | { |
| 640 | int i = 0; | |
| 641 | GList *l; | |
| 642 | ||
| 643 | if (!console) | |
| 644 | return; | |
| 645 | ||
| 646 | l = console->accounts; | |
| 647 | while (l) { | |
| 15884 | 648 | PurpleConnection *g = l->data; |
| 15412 | 649 | if (gc == g) |
| 650 | break; | |
| 651 | i++; | |
| 652 | l = l->next; | |
| 653 | } | |
| 654 | ||
| 655 | if (l == NULL) | |
| 656 | return; | |
| 657 | ||
| 658 | gtk_combo_box_remove_text(GTK_COMBO_BOX(console->dropdown), i); | |
| 659 | console->accounts = g_list_remove(console->accounts, gc); | |
| 15884 | 660 | printf("%s\n", purple_account_get_username(gc->account)); |
| 15412 | 661 | console->count--; |
| 662 | ||
| 663 | if (gc == console->gc) { | |
| 664 | console->gc = NULL; | |
| 665 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), | |
| 666 | _("<font color='#777777'>Logged out.</font>"), 0); | |
| 667 | } | |
| 668 | } | |
| 669 | ||
| 670 | static gboolean | |
| 15884 | 671 | plugin_load(PurplePlugin *plugin) |
| 15412 | 672 | { |
| 15884 | 673 | PurplePlugin *jabber; |
| 15412 | 674 | |
| 15884 | 675 | jabber = purple_find_prpl("prpl-jabber"); |
| 15412 | 676 | if (!jabber) |
| 677 | return FALSE; | |
| 678 | ||
| 679 | xmpp_console_handle = plugin; | |
| 15884 | 680 | purple_signal_connect(jabber, "jabber-receiving-xmlnode", xmpp_console_handle, |
| 681 | PURPLE_CALLBACK(xmlnode_received_cb), NULL); | |
| 682 | purple_signal_connect(jabber, "jabber-sending-text", xmpp_console_handle, | |
| 683 | PURPLE_CALLBACK(xmlnode_sent_cb), NULL); | |
| 684 | purple_signal_connect(purple_connections_get_handle(), "signed-on", | |
| 685 | plugin, PURPLE_CALLBACK(signed_on_cb), NULL); | |
| 686 | purple_signal_connect(purple_connections_get_handle(), "signed-off", | |
| 687 | plugin, PURPLE_CALLBACK(signed_off_cb), NULL); | |
| 15412 | 688 | |
| 689 | return TRUE; | |
| 690 | } | |
| 691 | ||
| 692 | static gboolean | |
| 15884 | 693 | plugin_unload(PurplePlugin *plugin) |
| 15412 | 694 | { |
| 15414 | 695 | if (console) |
| 696 | gtk_widget_destroy(console->window); | |
| 15412 | 697 | return TRUE; |
| 698 | } | |
| 699 | ||
| 700 | static void | |
| 701 | console_destroy(GtkObject *window, gpointer nul) | |
| 702 | { | |
| 703 | g_list_free(console->accounts); | |
| 704 | g_free(console); | |
| 705 | console = NULL; | |
| 706 | } | |
| 707 | ||
| 708 | static void | |
| 709 | dropdown_changed_cb(GtkComboBox *widget, gpointer nul) | |
| 710 | { | |
| 15884 | 711 | PurpleAccount *account; |
| 15412 | 712 | |
| 713 | if (!console) | |
| 714 | return; | |
| 715 | ||
| 15884 | 716 | account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)), |
| 15412 | 717 | "prpl-jabber"); |
| 718 | if (!account || !account->gc) | |
| 719 | return; | |
| 720 | ||
| 721 | console->gc = account->gc; | |
| 722 | gtk_imhtml_clear(GTK_IMHTML(console->imhtml)); | |
| 723 | } | |
| 724 | ||
| 725 | static void | |
| 726 | create_console() | |
| 727 | { | |
| 728 | GtkWidget *vbox = gtk_vbox_new(FALSE, 6); | |
| 729 | GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); | |
| 730 | GtkWidget *label; | |
| 731 | GtkTextBuffer *buffer; | |
| 732 | GtkWidget *toolbar; | |
| 15427 | 733 | GList *connections; |
| 734 | #if GTK_CHECK_VERSION(2,4,0) | |
| 15412 | 735 | GtkToolItem *button; |
| 15427 | 736 | #endif |
| 15412 | 737 | |
| 738 | if (console) { | |
| 739 | gtk_window_present(GTK_WINDOW(console->window)); | |
| 740 | return; | |
| 741 | } | |
| 742 | ||
| 743 | console = g_new0(XmppConsole, 1); | |
| 744 | ||
| 17213 | 745 | console->window = pidgin_create_window(_("XMPP Console"), PIDGIN_HIG_BORDER, NULL, TRUE); |
| 15412 | 746 | g_signal_connect(G_OBJECT(console->window), "destroy", G_CALLBACK(console_destroy), NULL); |
| 747 | gtk_window_set_default_size(GTK_WINDOW(console->window), 580, 400); | |
| 748 | gtk_container_add(GTK_CONTAINER(console->window), vbox); | |
| 749 | ||
| 750 | console->hbox = gtk_hbox_new(FALSE, 3); | |
| 751 | gtk_box_pack_start(GTK_BOX(vbox), console->hbox, FALSE, FALSE, 0); | |
| 752 | label = gtk_label_new(_("Account: ")); | |
| 753 | gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); | |
| 754 | gtk_box_pack_start(GTK_BOX(console->hbox), label, FALSE, FALSE, 0); | |
| 755 | console->dropdown = gtk_combo_box_new_text(); | |
| 15884 | 756 | for (connections = purple_connections_get_all(); connections; connections = connections->next) { |
| 757 | PurpleConnection *gc = connections->data; | |
| 758 | if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), "prpl-jabber")) { | |
| 15412 | 759 | console->count++; |
| 760 | console->accounts = g_list_append(console->accounts, gc); | |
| 761 | gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), | |
| 15884 | 762 | purple_account_get_username(purple_connection_get_account(gc))); |
| 15412 | 763 | if (!console->gc) |
| 764 | console->gc = gc; | |
| 765 | } | |
| 766 | } | |
| 767 | gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown),0); | |
| 768 | gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0); | |
| 769 | g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL); | |
| 770 | ||
| 771 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); | |
| 772 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 773 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
| 774 | ||
| 775 | console->imhtml = gtk_imhtml_new(NULL, NULL); | |
| 776 | gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
| 777 | if (console->count == 0) | |
| 778 | gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), | |
| 779 | _("<font color='#777777'>Not connected to XMPP</font>"), 0); | |
| 780 | gtk_container_add(GTK_CONTAINER(sw), console->imhtml); | |
| 781 | ||
| 782 | toolbar = gtk_toolbar_new(); | |
| 15427 | 783 | #if GTK_CHECK_VERSION(2,4,0) |
| 15412 | 784 | button = gtk_tool_button_new(NULL, "<iq/>"); |
| 785 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(iq_clicked_cb), NULL); | |
| 786 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 15427 | 787 | #else |
| 788 | gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<iq/>", | |
| 789 | _("Insert an <iq/> stanza."), "foo", NULL, GTK_SIGNAL_FUNC(iq_clicked_cb), NULL); | |
| 790 | #endif | |
| 15412 | 791 | |
| 15427 | 792 | #if GTK_CHECK_VERSION(2,4,0) |
| 15412 | 793 | button = gtk_tool_button_new(NULL, "<presence/>"); |
| 794 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(presence_clicked_cb), NULL); | |
| 795 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 15427 | 796 | #else |
| 797 | gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<presence/>", | |
| 798 | _("Insert a <presence/> stanza."), NULL, gtk_label_new(NULL), GTK_SIGNAL_FUNC(presence_clicked_cb), NULL); | |
| 799 | #endif | |
| 15412 | 800 | |
| 15427 | 801 | #if GTK_CHECK_VERSION(2,4,0) |
| 15412 | 802 | button = gtk_tool_button_new(NULL, "<message/>"); |
| 803 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(message_clicked_cb), NULL); | |
| 804 | gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); | |
| 15427 | 805 | #else |
| 806 | gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "<message/>", | |
| 807 | _("Insert a <message/> stanza."), "foo", gtk_label_new(NULL), GTK_SIGNAL_FUNC(message_clicked_cb), NULL); | |
| 808 | #endif | |
| 809 | ||
| 15412 | 810 | gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); |
| 811 | ||
| 812 | sw = gtk_scrolled_window_new(NULL, NULL); | |
| 813 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); | |
| 814 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
| 815 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
| 816 | ||
| 817 | console->entry = gtk_imhtml_new(NULL, NULL); | |
| 818 | gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(console->entry), TRUE); | |
| 819 | g_signal_connect(G_OBJECT(console->entry),"message_send", G_CALLBACK(message_send_cb), console); | |
| 820 | ||
| 821 | gtk_box_pack_start(GTK_BOX(vbox), sw, FALSE, FALSE, 0); | |
| 822 | gtk_container_add(GTK_CONTAINER(sw), console->entry); | |
| 823 | gtk_imhtml_set_editable(GTK_IMHTML(console->entry), TRUE); | |
| 824 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); | |
| 825 | g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(entry_changed_cb), NULL); | |
| 826 | console->sw = sw; | |
| 827 | entry_changed_cb(buffer, NULL); | |
| 828 | ||
| 829 | gtk_widget_show_all(console->window); | |
| 830 | if (console->count < 2) | |
| 831 | gtk_widget_hide(console->hbox); | |
| 832 | } | |
| 833 | ||
| 834 | static GList * | |
| 15884 | 835 | actions(PurplePlugin *plugin, gpointer context) |
| 15412 | 836 | { |
| 837 | GList *l = NULL; | |
| 15884 | 838 | PurplePluginAction *act = NULL; |
| 15412 | 839 | |
| 15884 | 840 | act = purple_plugin_action_new(_("XMPP Console"), create_console); |
| 15412 | 841 | l = g_list_append(l, act); |
| 842 | ||
| 843 | return l; | |
| 844 | } | |
| 845 | ||
| 846 | ||
| 15884 | 847 | static PurplePluginInfo info = |
| 15412 | 848 | { |
| 15884 | 849 | PURPLE_PLUGIN_MAGIC, |
| 850 | PURPLE_MAJOR_VERSION, | |
| 851 | PURPLE_MINOR_VERSION, | |
| 852 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
853 | PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ |
| 15412 | 854 | 0, /**< flags */ |
| 855 | NULL, /**< dependencies */ | |
| 15884 | 856 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 15412 | 857 | |
| 858 | "gtk-xmpp", /**< id */ | |
| 859 | N_("XMPP Console"), /**< name */ | |
| 860 | VERSION, /**< version */ | |
| 861 | /** summary */ | |
| 862 | N_("Send and receive raw XMPP stanzas."), | |
| 863 | /** description */ | |
| 864 | N_("This plugin is useful for debbuging XMPP servers or clients."), | |
| 865 | "Sean Egan <seanegan@gmail.com>", /**< author */ | |
| 15884 | 866 | PURPLE_WEBSITE, /**< homepage */ |
| 15412 | 867 | |
| 868 | plugin_load, /**< load */ | |
| 869 | plugin_unload, /**< unload */ | |
| 870 | NULL, /**< destroy */ | |
| 871 | ||
| 872 | NULL, /**< ui_info */ | |
| 873 | NULL, /**< extra_info */ | |
| 874 | 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
|
875 | 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
|
876 | |
|
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
|
877 | /* 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
|
878 | 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
|
879 | 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
|
880 | 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
|
881 | NULL |
| 15412 | 882 | }; |
| 883 | ||
| 884 | static void | |
| 15884 | 885 | init_plugin(PurplePlugin *plugin) |
| 15412 | 886 | { |
| 887 | } | |
| 888 | ||
| 15884 | 889 | PURPLE_INIT_PLUGIN(interval, init_plugin, info) |