From 38472f6359d69489782b55d82fa81267daaad384 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 13 Jan 2009 08:06:47 +0100 Subject: [PATCH] Current mess --- .includepath | 6 - .project | 17 - IRC-chat.txt | 75 ---- dbus-pidgin-methods.txt | 354 +++++++++---------- xmppconsole.c | 893 ------------------------------------------------ 5 files changed, 160 insertions(+), 1185 deletions(-) delete mode 100644 .includepath delete mode 100644 .project delete mode 100644 IRC-chat.txt delete mode 100644 xmppconsole.c diff --git a/.includepath b/.includepath deleted file mode 100644 index b199ecb..0000000 --- a/.includepath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/.project b/.project deleted file mode 100644 index 7cda984..0000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - pidgin-plugins - - - - - - org.epic.perleditor.perlbuilder - - - - - - org.epic.perleditor.perlnature - - diff --git a/IRC-chat.txt b/IRC-chat.txt deleted file mode 100644 index 9dcbfb5..0000000 --- a/IRC-chat.txt +++ /dev/null @@ -1,75 +0,0 @@ -Conversation with #pidgin at Pá 26. září 2008, 19:33:24 CEST on mcepl@irc.freenode.net (irc) -(19:40:31) tokam-|-away je teď znám jako tokam -(19:46:12) Ghost je teď znám jako Plasmastar -(19:59:52) Getty je teď znám jako _Getty -(20:00:24) _Getty je teď znám jako Getty -(20:26:48) dryOut23: hello -(20:27:43) dryOut23: is it possible to add a vhost for pidgin at the .purplpe/accounts.xml -(20:29:16) Err: what exactly might that mean? -(20:31:51) dryOut23: v -(20:31:55) dryOut23: you know hostserv -(20:32:05) dryOut23: i wanna pass my password for vhost after login to the server -(20:32:28) Err: actually, I have no idea what hostserv is, or vhost -(20:32:34) Err: is this with a particular protocol? -(20:32:54) dryOut23: HostServ allows users to use their own unique host -(20:33:27) dryOut23: while on the Network. IRC Operators add them to the database and upon connection the user gets their vhost. -(20:33:39) Err: oh, you're talking about IRC-specific junk -(20:33:47) dryOut23: indeed -(20:33:49) dryOut23: it is -(20:34:38) Err: is the registration for a vhost similar to identifying with nickserv - that is, you just send a message to a bot that handles the rest of the junk? -(20:35:00) dryOut23: yes -(20:35:09) dryOut23: nickserv is in the accounts.xml -(20:35:16) dryOut23: with -(20:35:39) dryOut23: now the same for hostserv -(20:35:45) Err: there's an FAQ entry about this -(20:35:48) dryOut23: is it/ -(20:35:52) dryOut23: didnt find it -(20:36:07) Err: (and I don't believe that the field is for nickserv, but rather another IRC authentication protocol) -(20:36:23) dryOut23: well it works -(20:36:25) Err: "How do I send a message to a user or bot on login?" sure seems like your question -(20:36:32) dryOut23: nickserv will accept the password -(20:36:44) dryOut23: ok thanks man -(20:37:43) dryOut23: ahh thats even better than this password tag -(20:37:52) dryOut23: very nice -(20:37:56) dryOut23: big thanks for the help -(20:39:42) tokam je teď znám jako tokam-|-away -(20:42:20) abinader: has anyone ever tried to create python bindings for libpurple? -(20:44:24) datallah: abinader: I bet google knows the answer to that -(20:46:50) dryOut23: ahh i got another question on my heart -(20:47:21) dryOut23: is there the glance of a chance that pixbuff will once be able to resize gif/jpeg for icq -(20:47:34) dryOut23: i would say please with sugar on top of it -(20:57:35) wjt: i'm sure that's already meant to work -(21:01:40) ndy je teď znám jako ndyzzz -(21:28:51) danage: who is the coder of the pidgin libnotify plugin? -(21:57:42) robin je teď znám jako robin_k -(22:08:05) Vorondil: danage: If you have it, and it's showing in the plugins list, the plugin details should say. Otherwise, google. -(22:09:19) danage: excellent, it does -(22:09:23) danage: d'oh -(22:17:45) mcepl: all: I was told that if I want to send and read IQ messages in XMPP I need xmpp-receiving-xml signal in DBUS -- the only I found is writing-im-msg, wrote-im-msg, sending-im-msg, sent-im-msg, receiving-im-msg, received-im-msg, Is any one of these the right signal? -(22:19:29) issyl0 je teď znám jako issyl0|phone -(22:19:59) issyl0|phone je teď znám jako issyl0 -(22:25:01) GeekWannabe1: I am windows user and I like pidgin. It's pure, simple, minimalistic and overall great, gtk+ seems stable on windows also these days. One simple question please. How the hell do I change background color of all my text windows to black and font to light gray? Thanks -(22:25:45) Vorondil: Pidgin's colors and whatnot come from your gtk theme. -(22:26:37) GeekWannabe1: Yeah I googled that, so what do I need to enter into this .gtkrc-2.0 file in order to get black bg and light gray font? -(22:27:07) GeekWannabe1: If one of you guys would write frontend for this it would be great -(22:33:39) Vorondil: You'll need to type in the name of a theme you have installed with aforementioned colors. -(22:34:24) Vorondil: Clearly, I sensed his departure and was moved to say something useful. -(22:35:40) ktdreyer: I'm looking for meanwhile folks, but #meanwhile is empty. Any ideas? -(22:58:25) nosnilmot: mcepl: it's actually "jabber-receiving-xmlnode" and doesn't appear to be documented anywhere I can find, it appears to be emitted with two parameters: (PurpleConnection *gc, xmlnode **node) ("jabber-sending-xmlnode" is the sending equivalent, emitted in the same way) -(23:08:43) mcepl: nosnilmot: oh thanks? And the method to send raw XMPP packet out is ServSendIm ? -(23:10:20) datallah: mcepl: check out the XMPP Console plugin -(23:11:56) mcepl: hmm, a then is using DBUS? -(23:12:00) mcepl: *that -(23:12:04) datallah: no -(23:12:10) mcepl: that's a problem -(23:12:43) datallah: Well, it is a good reference for how to do it in a C plugin - you just need to figure out the dbus equivalent. -(23:12:56) mcepl: well, I hoped to do a Perl/Python plugin -(23:13:35) datallah: I doubt the API is exposed to Perl, but you could fix that if it isn't. -(23:13:47) mcepl: or to DBUS? -(23:13:58) datallah: I really don't know much about the dbus api -(23:14:13) mcepl: I guess Perl could use DBUS as well, right? -(23:14:31) mcepl: OK, I guess I should read you reply as "Use the Source, Luke!" ;-) -(23:14:51) datallah: There is an internal Perl API, I'm not sure why you're talking about dbus in relation to perl. -(23:15:32) mcepl: well, I thought if some method is exported via DBUS and not via Perl, I could DBUS in Perl. -(23:15:50) datallah: or you could fix the Perl API -(23:16:08) mcepl: well, I am not sure much about programming in C ... I will think about it. diff --git a/dbus-pidgin-methods.txt b/dbus-pidgin-methods.txt index 0dfc974..ec5760e 100644 --- a/dbus-pidgin-methods.txt +++ b/dbus-pidgin-methods.txt @@ -38,7 +38,7 @@ - + @@ -134,16 +134,16 @@ - + - + - + @@ -156,7 +156,7 @@ - + @@ -165,7 +165,7 @@ - + @@ -175,13 +175,13 @@ - + - + @@ -193,7 +193,7 @@ - + @@ -272,7 +272,7 @@ - + @@ -291,7 +291,7 @@ - + @@ -303,14 +303,14 @@ - + - + @@ -324,12 +324,12 @@ - + - + @@ -385,7 +385,7 @@ - + @@ -424,7 +424,7 @@ - + @@ -448,7 +448,7 @@ - + @@ -665,7 +665,7 @@ - + @@ -693,7 +693,7 @@ - + @@ -703,7 +703,7 @@ - + @@ -726,7 +726,7 @@ - + @@ -754,7 +754,7 @@ - + @@ -772,7 +772,7 @@ - + @@ -799,7 +799,7 @@ - + @@ -814,7 +814,7 @@ - + @@ -832,7 +832,7 @@ - + @@ -851,11 +851,11 @@ - + - + @@ -877,7 +877,7 @@ - + @@ -885,7 +885,7 @@ - + @@ -918,8 +918,8 @@ - - + + @@ -931,15 +931,15 @@ - + - + - + @@ -961,7 +961,7 @@ - + @@ -1020,7 +1020,7 @@ - + @@ -1037,7 +1037,7 @@ - + @@ -1054,7 +1054,7 @@ - + @@ -1063,12 +1063,12 @@ - - + + - + @@ -1080,7 +1080,7 @@ - + @@ -1119,7 +1119,7 @@ - + @@ -1127,7 +1127,7 @@ - + @@ -1138,7 +1138,7 @@ - + @@ -1161,8 +1161,8 @@ - - + + @@ -1181,14 +1181,14 @@ - + - + @@ -1246,7 +1246,7 @@ - + @@ -1256,8 +1256,8 @@ - - + + @@ -1266,21 +1266,21 @@ - + - - + + - + @@ -1305,7 +1305,7 @@ - + @@ -1325,7 +1325,7 @@ - + @@ -1338,7 +1338,7 @@ - + @@ -1368,7 +1368,7 @@ - + @@ -1394,7 +1394,7 @@ - + @@ -1475,7 +1475,7 @@ - + @@ -1491,11 +1491,11 @@ - + - + @@ -1503,9 +1503,9 @@ - + - + @@ -1520,7 +1520,7 @@ - + @@ -1543,13 +1543,13 @@ - + - + - + @@ -1563,7 +1563,7 @@ - + @@ -1577,7 +1577,7 @@ - + @@ -1590,7 +1590,7 @@ - + @@ -1598,7 +1598,7 @@ - + @@ -1671,12 +1671,12 @@ - + - + @@ -1752,10 +1752,10 @@ - + - + @@ -1780,11 +1780,11 @@ - + - + @@ -1817,15 +1817,15 @@ - + - + - + @@ -1880,7 +1880,7 @@ - + @@ -1912,7 +1912,7 @@ - + @@ -1938,7 +1938,7 @@ - + @@ -1964,10 +1964,10 @@ - + - + @@ -1988,43 +1988,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -2033,7 +1999,7 @@ - + @@ -2060,7 +2026,7 @@ - + @@ -2076,7 +2042,7 @@ - + @@ -2086,11 +2052,11 @@ - + - + @@ -2163,7 +2129,7 @@ - + @@ -2204,11 +2170,11 @@ - + - + @@ -2216,19 +2182,19 @@ - + - - - + + + - + - + @@ -2325,22 +2291,22 @@ - + - + - + - + @@ -2409,7 +2375,7 @@ - + @@ -2434,7 +2400,7 @@ - + @@ -2442,12 +2408,12 @@ - - + + - + @@ -2497,7 +2463,7 @@ - + @@ -2530,23 +2496,23 @@ - + - + - + - + @@ -2577,25 +2543,25 @@ - + - + - + - + - + @@ -2614,8 +2580,8 @@ - - + + @@ -2625,8 +2591,8 @@ - - + + @@ -2645,7 +2611,7 @@ - + @@ -2655,15 +2621,15 @@ - + - + - + - + @@ -2682,7 +2648,7 @@ - + @@ -2694,12 +2660,12 @@ - - - - - - + + + + + + @@ -2716,8 +2682,8 @@ - - + + @@ -2745,19 +2711,19 @@ - + - + - + @@ -2774,7 +2740,7 @@ - + @@ -2831,16 +2797,16 @@ - + - + - + @@ -2920,7 +2886,7 @@ - + @@ -3045,23 +3011,23 @@ - - + + - + - - + + - + @@ -3081,18 +3047,18 @@ - + - + - + - + diff --git a/xmppconsole.c b/xmppconsole.c deleted file mode 100644 index e193b04..0000000 --- a/xmppconsole.c +++ /dev/null @@ -1,893 +0,0 @@ -/* - * Purple - XMPP debugging tool - * - * Copyright (C) 2002-2003, Sean Egan - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ - -#include "internal.h" -#include "gtkplugin.h" -#include "version.h" -#include "prpl.h" -#include "xmlnode.h" - -#include "gtkimhtml.h" -#if !GTK_CHECK_VERSION(2,4,0) -#include "pidgincombobox.h" -#endif -#include "gtkutils.h" - -typedef struct { - PurpleConnection *gc; - GtkWidget *window; - GtkWidget *hbox; - GtkWidget *dropdown; - GtkWidget *imhtml; - GtkWidget *entry; - GtkWidget *sw; - int count; - GList *accounts; -} XmppConsole; - -XmppConsole *console = NULL; -static void *xmpp_console_handle = NULL; - -#define BRACKET_COLOR "#940f8c" -#define TAG_COLOR "#8b1dab" -#define ATTR_NAME_COLOR "#a02961" -#define ATTR_VALUE_COLOR "#324aa4" -#define XMLNS_COLOR "#2cb12f" - -static char * -xmlnode_to_pretty_str(xmlnode *node, int *len, int depth) -{ - GString *text = g_string_new(""); - xmlnode *c; - char *node_name, *esc, *esc2, *tab = NULL; - gboolean need_end = FALSE, pretty = TRUE; - - g_return_val_if_fail(node != NULL, NULL); - - if(pretty && depth) { - tab = g_strnfill(depth, '\t'); - text = g_string_append(text, tab); - } - - node_name = g_markup_escape_text(node->name, -1); - g_string_append_printf(text, "<%s", node_name); - - if (node->xmlns) { - if((!node->parent || - !node->parent->xmlns || - strcmp(node->xmlns, node->parent->xmlns)) && - strcmp(node->xmlns, "jabber:client")) - { - char *xmlns = g_markup_escape_text(node->xmlns, -1); - g_string_append_printf(text, " xmlns='%s'", xmlns); - g_free(xmlns); - } - } - for(c = node->child; c; c = c->next) - { - if(c->type == XMLNODE_TYPE_ATTRIB) { - esc = g_markup_escape_text(c->name, -1); - esc2 = g_markup_escape_text(c->data, -1); - g_string_append_printf(text, " %s='%s'", esc, esc2); - g_free(esc); - g_free(esc2); - } else if(c->type == XMLNODE_TYPE_TAG || c->type == XMLNODE_TYPE_DATA) { - if(c->type == XMLNODE_TYPE_DATA) - pretty = FALSE; - need_end = TRUE; - } - } - - if(need_end) { - g_string_append_printf(text, - ">%s", pretty ? "
" : ""); - - for(c = node->child; c; c = c->next) - { - if(c->type == XMLNODE_TYPE_TAG) { - int esc_len; - esc = xmlnode_to_pretty_str(c, &esc_len, depth+1); - text = g_string_append_len(text, esc, esc_len); - g_free(esc); - } else if(c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) { - esc = g_markup_escape_text(c->data, c->data_sz); - text = g_string_append(text, esc); - g_free(esc); - } - } - - if(tab && pretty) - text = g_string_append(text, tab); - g_string_append_printf(text, "</%s>
", node_name); - } else { - g_string_append_printf(text, "/>
"); - } - - g_free(node_name); - - g_free(tab); - - if(len) - *len = text->len; - - return g_string_free(text, FALSE); -} - -static void -xmlnode_received_cb(PurpleConnection *gc, xmlnode **packet, gpointer null) -{ - char *str, *formatted; - - if (!console || console->gc != gc) - return; - str = xmlnode_to_pretty_str(*packet, NULL, 0); - formatted = g_strdup_printf("
%s
", str); - gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0); - g_free(formatted); - g_free(str); -} - -static void -xmlnode_sent_cb(PurpleConnection *gc, char **packet, gpointer null) -{ - char *str; - char *formatted; - xmlnode *node; - - if (!console || console->gc != gc) - return; - node = xmlnode_from_str(*packet, -1); - - if (!node) - return; - - str = xmlnode_to_pretty_str(node, NULL, 0); - formatted = g_strdup_printf("
%s
", str); - gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0); - g_free(formatted); - g_free(str); - xmlnode_free(node); -} - -static void message_send_cb(GtkWidget *widget, gpointer p) -{ - GtkTextIter start, end; - PurplePluginProtocolInfo *prpl_info = NULL; - PurpleConnection *gc = console->gc; - GtkTextBuffer *buffer; - char *text; - - gc = console->gc; - - if (gc) - prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); - - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); - gtk_text_buffer_get_start_iter(buffer, &start); - gtk_text_buffer_get_end_iter(buffer, &end); - - text = gtk_imhtml_get_text(GTK_IMHTML(console->entry), &start, &end); - - if (prpl_info && prpl_info->send_raw != NULL) - prpl_info->send_raw(gc, text, strlen(text)); - - g_free(text); - gtk_imhtml_clear(GTK_IMHTML(console->entry)); -} - -static void entry_changed_cb(GtkTextBuffer *buffer, void *data) -{ - char *xmlstr, *str; - GtkTextIter iter; - int wrapped_lines; - int lines; - GdkRectangle oneline; - int height; - int pad_top, pad_inside, pad_bottom; - GtkTextIter start, end; - xmlnode *node; - - wrapped_lines = 1; - gtk_text_buffer_get_start_iter(buffer, &iter); - gtk_text_view_get_iter_location(GTK_TEXT_VIEW(console->entry), &iter, &oneline); - while (gtk_text_view_forward_display_line(GTK_TEXT_VIEW(console->entry), &iter)) - wrapped_lines++; - - lines = gtk_text_buffer_get_line_count(buffer); - - /* Show a maximum of 64 lines */ - lines = MIN(lines, 6); - wrapped_lines = MIN(wrapped_lines, 6); - - pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(console->entry)); - pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(console->entry)); - pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(console->entry)); - - height = (oneline.height + pad_top + pad_bottom) * lines; - height += (oneline.height + pad_inside) * (wrapped_lines - lines); - - gtk_widget_set_size_request(console->sw, -1, height+6); - - - - gtk_text_buffer_get_start_iter(buffer, &start); - gtk_text_buffer_get_end_iter(buffer, &end); - str = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); - if (!str) - return; - xmlstr = g_strdup_printf("%s", str); - node = xmlnode_from_str(xmlstr, -1); - if (node) { - gtk_imhtml_clear_formatting(GTK_IMHTML(console->entry)); - } else { - gtk_imhtml_toggle_background(GTK_IMHTML(console->entry), "#ffcece"); - } - g_free(str); - g_free(xmlstr); - if (node) - xmlnode_free(node); -} - -static void iq_clicked_cb(GtkWidget *w, gpointer nul) -{ - GtkWidget *hbox, *to_entry, *label, *type_combo; - GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - GtkTextIter iter; - GtkTextBuffer *buffer; - const char *to; - int result; - char *stanza; - - GtkWidget *dialog = gtk_dialog_new_with_buttons("", - GTK_WINDOW(console->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); - gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("To:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - to_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Type:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - type_combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "get"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "set"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "result"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); - gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); - - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); - - result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return; - } - - to = gtk_entry_get_text(GTK_ENTRY(to_entry)); - - stanza = g_strdup_printf("", - to && *to ? "to='" : "", - to && *to ? to : "", - to && *to ? "'" : "", - g_random_int(), - gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo))); - - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); - gtk_text_buffer_set_text(buffer, stanza, -1); - gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "") - stanza); - gtk_text_buffer_place_cursor(buffer, &iter); - g_free(stanza); - - gtk_widget_destroy(dialog); - g_object_unref(sg); - -} - -static void presence_clicked_cb(GtkWidget *w, gpointer nul) -{ - GtkWidget *hbox, - *to_entry, - *status_entry, - *priority_entry, - *label, - *show_combo, - *type_combo; - GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - GtkTextIter iter; - GtkTextBuffer *buffer; - const char *to, *type, *status, *show, *priority; - int result; - char *stanza; - - GtkWidget *dialog = gtk_dialog_new_with_buttons("", - GTK_WINDOW(console->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); - gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("To:"); - gtk_size_group_add_widget(sg, label); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - to_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Type:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - type_combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "default"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unavailable"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribe"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribe"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "subscribed"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "unsubscribed"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "probe"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); - gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Show:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - show_combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "default"); - gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "away"); - gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "dnd"); - gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "xa"); - gtk_combo_box_append_text(GTK_COMBO_BOX(show_combo), "chat"); - - gtk_combo_box_set_active(GTK_COMBO_BOX(show_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), show_combo, FALSE, FALSE, 0); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Status:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - status_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (status_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), status_entry, FALSE, FALSE, 0); - - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Priority:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - priority_entry = gtk_spin_button_new_with_range(-128, 127, 1); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(priority_entry), 0); - gtk_box_pack_start(GTK_BOX(hbox), priority_entry, FALSE, FALSE, 0); - - - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); - - result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return; - } - - to = gtk_entry_get_text(GTK_ENTRY(to_entry)); - type = gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)); - if (!strcmp(type, "default")) - type = ""; - show = gtk_combo_box_get_active_text(GTK_COMBO_BOX(show_combo)); - if (!strcmp(show, "default")) - show = ""; - status = gtk_entry_get_text(GTK_ENTRY(status_entry)); - priority = gtk_entry_get_text(GTK_ENTRY(priority_entry)); - if (!strcmp(priority, "0")) - priority = ""; - - - - stanza = g_strdup_printf("" - "%s%s%s%s%s%s%s%s%s" - "", - *to ? "to='" : "", - *to ? to : "", - *to ? "'" : "", - g_random_int(), - - *type ? "type='" : "", - *type ? type : "", - *type ? "'" : "", - - *show ? "" : "", - *show ? show : "", - *show ? "" : "", - - *status ? "" : "", - *status ? status : "", - *status ? "" : "", - - *priority ? "" : "", - *priority ? priority : "", - *priority ? "" : ""); - - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); - gtk_text_buffer_set_text(buffer, stanza, -1); - gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "") - stanza); - gtk_text_buffer_place_cursor(buffer, &iter); - g_free(stanza); - - gtk_widget_destroy(dialog); - g_object_unref(sg); -} - -static void message_clicked_cb(GtkWidget *w, gpointer nul) -{ - GtkWidget *hbox, - *to_entry, - *body_entry, - *thread_entry, - *subject_entry, - *label, - *type_combo; - GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - GtkTextIter iter; - GtkTextBuffer *buffer; - const char *to, *body, *thread, *subject; - char *stanza; - int result; - - GtkWidget *dialog = gtk_dialog_new_with_buttons("", - GTK_WINDOW(console->window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_REJECT, - GTK_STOCK_OK, - GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); - gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - gtk_container_set_border_width(GTK_CONTAINER(dialog), 12); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("To:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - to_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (to_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), to_entry, FALSE, FALSE, 0); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - label = gtk_label_new("Type:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - type_combo = gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "chat"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "headline"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "groupchat"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "normal"); - gtk_combo_box_append_text(GTK_COMBO_BOX(type_combo), "error"); - gtk_combo_box_set_active(GTK_COMBO_BOX(type_combo), 0); - gtk_box_pack_start(GTK_BOX(hbox), type_combo, FALSE, FALSE, 0); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Body:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - body_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (body_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), body_entry, FALSE, FALSE, 0); - - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Subject:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - subject_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (subject_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), subject_entry, FALSE, FALSE, 0); - - hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new("Thread:"); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_size_group_add_widget(sg, label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - thread_entry = gtk_entry_new(); - gtk_entry_set_activates_default (GTK_ENTRY (thread_entry), TRUE); - gtk_box_pack_start(GTK_BOX(hbox), thread_entry, FALSE, FALSE, 0); - - gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); - - result = gtk_dialog_run(GTK_DIALOG(dialog)); - if (result != GTK_RESPONSE_ACCEPT) { - gtk_widget_destroy(dialog); - return; - } - - to = gtk_entry_get_text(GTK_ENTRY(to_entry)); - body = gtk_entry_get_text(GTK_ENTRY(body_entry)); - thread = gtk_entry_get_text(GTK_ENTRY(thread_entry)); - subject = gtk_entry_get_text(GTK_ENTRY(subject_entry)); - - stanza = g_strdup_printf("" - "%s%s%s%s%s%s%s%s%s" - "", - - *to ? "to='" : "", - *to ? to : "", - *to ? "'" : "", - g_random_int(), - gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo)), - - *body ? "" : "", - *body ? body : "", - *body ? "" : "", - - *subject ? "" : "", - *subject ? subject : "", - *subject ? "" : "", - - *thread ? "" : "", - *thread ? thread : "", - *thread ? "" : ""); - - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); - gtk_text_buffer_set_text(buffer, stanza, -1); - gtk_text_buffer_get_iter_at_offset(buffer, &iter, strstr(stanza, "") - stanza); - gtk_text_buffer_place_cursor(buffer, &iter); - g_free(stanza); - - gtk_widget_destroy(dialog); - g_object_unref(sg); -} - -static void -signed_on_cb(PurpleConnection *gc) -{ - if (!console) - return; - - gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), purple_account_get_username(gc->account)); - console->accounts = g_list_append(console->accounts, gc); - console->count++; - - if (console->count > 1) - gtk_widget_show_all(console->hbox); -} - -static void -signed_off_cb(PurpleConnection *gc) -{ - int i = 0; - GList *l; - - if (!console) - return; - - l = console->accounts; - while (l) { - PurpleConnection *g = l->data; - if (gc == g) - break; - i++; - l = l->next; - } - - if (l == NULL) - return; - - gtk_combo_box_remove_text(GTK_COMBO_BOX(console->dropdown), i); - console->accounts = g_list_remove(console->accounts, gc); - printf("%s\n", purple_account_get_username(gc->account)); - console->count--; - - if (gc == console->gc) { - console->gc = NULL; - gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), - _("Logged out."), 0); - } -} - -static gboolean -plugin_load(PurplePlugin *plugin) -{ - PurplePlugin *jabber; - - jabber = purple_find_prpl("prpl-jabber"); - if (!jabber) - return FALSE; - - xmpp_console_handle = plugin; - purple_signal_connect(jabber, "jabber-receiving-xmlnode", xmpp_console_handle, - PURPLE_CALLBACK(xmlnode_received_cb), NULL); - purple_signal_connect(jabber, "jabber-sending-text", xmpp_console_handle, - PURPLE_CALLBACK(xmlnode_sent_cb), NULL); - purple_signal_connect(purple_connections_get_handle(), "signed-on", - plugin, PURPLE_CALLBACK(signed_on_cb), NULL); - purple_signal_connect(purple_connections_get_handle(), "signed-off", - plugin, PURPLE_CALLBACK(signed_off_cb), NULL); - - return TRUE; -} - -static gboolean -plugin_unload(PurplePlugin *plugin) -{ - if (console) - gtk_widget_destroy(console->window); - return TRUE; -} - -static void -console_destroy(GtkObject *window, gpointer nul) -{ - g_list_free(console->accounts); - g_free(console); - console = NULL; -} - -static void -dropdown_changed_cb(GtkComboBox *widget, gpointer nul) -{ - PurpleAccount *account; - - if (!console) - return; - - account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)), - "prpl-jabber"); - if (!account || !account->gc) - return; - - console->gc = account->gc; - gtk_imhtml_clear(GTK_IMHTML(console->imhtml)); -} - -static void -create_console(PurplePluginAction *action) -{ - GtkWidget *vbox = gtk_vbox_new(FALSE, 6); - GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); - GtkWidget *label; - GtkTextBuffer *buffer; - GtkWidget *toolbar; - GList *connections; -#if GTK_CHECK_VERSION(2,4,0) - GtkToolItem *button; -#endif - - if (console) { - gtk_window_present(GTK_WINDOW(console->window)); - return; - } - - console = g_new0(XmppConsole, 1); - - console->window = pidgin_create_window(_("XMPP Console"), PIDGIN_HIG_BORDER, NULL, TRUE); - g_signal_connect(G_OBJECT(console->window), "destroy", G_CALLBACK(console_destroy), NULL); - gtk_window_set_default_size(GTK_WINDOW(console->window), 580, 400); - gtk_container_add(GTK_CONTAINER(console->window), vbox); - - console->hbox = gtk_hbox_new(FALSE, 3); - gtk_box_pack_start(GTK_BOX(vbox), console->hbox, FALSE, FALSE, 0); - label = gtk_label_new(_("Account: ")); - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(console->hbox), label, FALSE, FALSE, 0); - console->dropdown = gtk_combo_box_new_text(); - for (connections = purple_connections_get_all(); connections; connections = connections->next) { - PurpleConnection *gc = connections->data; - if (!strcmp(purple_account_get_protocol_id(purple_connection_get_account(gc)), "prpl-jabber")) { - console->count++; - console->accounts = g_list_append(console->accounts, gc); - gtk_combo_box_append_text(GTK_COMBO_BOX(console->dropdown), - purple_account_get_username(purple_connection_get_account(gc))); - if (!console->gc) - console->gc = gc; - } - } - gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown),0); - gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0); - g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL); - - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - console->imhtml = gtk_imhtml_new(NULL, NULL); - gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); - if (console->count == 0) - gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), - _("Not connected to XMPP"), 0); - gtk_container_add(GTK_CONTAINER(sw), console->imhtml); - - toolbar = gtk_toolbar_new(); -#if GTK_CHECK_VERSION(2,4,0) - button = gtk_tool_button_new(NULL, ""); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(iq_clicked_cb), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); -#else - gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "", - _("Insert an stanza."), "foo", NULL, GTK_SIGNAL_FUNC(iq_clicked_cb), NULL); -#endif - -#if GTK_CHECK_VERSION(2,4,0) - button = gtk_tool_button_new(NULL, ""); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(presence_clicked_cb), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); -#else - gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "", - _("Insert a stanza."), NULL, gtk_label_new(NULL), GTK_SIGNAL_FUNC(presence_clicked_cb), NULL); -#endif - -#if GTK_CHECK_VERSION(2,4,0) - button = gtk_tool_button_new(NULL, ""); - g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(message_clicked_cb), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); -#else - gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "", - _("Insert a stanza."), "foo", gtk_label_new(NULL), GTK_SIGNAL_FUNC(message_clicked_cb), NULL); -#endif - - gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); - - sw = gtk_scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - console->entry = gtk_imhtml_new(NULL, NULL); - gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(console->entry), TRUE); - g_signal_connect(G_OBJECT(console->entry),"message_send", G_CALLBACK(message_send_cb), console); - - gtk_box_pack_start(GTK_BOX(vbox), sw, FALSE, FALSE, 0); - gtk_container_add(GTK_CONTAINER(sw), console->entry); - gtk_imhtml_set_editable(GTK_IMHTML(console->entry), TRUE); - buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(console->entry)); - g_signal_connect(G_OBJECT(buffer), "changed", G_CALLBACK(entry_changed_cb), NULL); - console->sw = sw; - entry_changed_cb(buffer, NULL); - - gtk_widget_show_all(console->window); - if (console->count < 2) - gtk_widget_hide(console->hbox); -} - -static GList * -actions(PurplePlugin *plugin, gpointer context) -{ - GList *l = NULL; - PurplePluginAction *act = NULL; - - act = purple_plugin_action_new(_("XMPP Console"), create_console); - l = g_list_append(l, act); - - return l; -} - - -static PurplePluginInfo info = -{ - PURPLE_PLUGIN_MAGIC, - PURPLE_MAJOR_VERSION, - PURPLE_MINOR_VERSION, - PURPLE_PLUGIN_STANDARD, /**< type */ - PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ - 0, /**< flags */ - NULL, /**< dependencies */ - PURPLE_PRIORITY_DEFAULT, /**< priority */ - - "gtk-xmpp", /**< id */ - N_("XMPP Console"), /**< name */ - DISPLAY_VERSION, /**< version */ - /** summary */ - N_("Send and receive raw XMPP stanzas."), - /** description */ - N_("This plugin is useful for debbuging XMPP servers or clients."), - "Sean Egan ", /**< author */ - PURPLE_WEBSITE, /**< homepage */ - - plugin_load, /**< load */ - plugin_unload, /**< unload */ - NULL, /**< destroy */ - - NULL, /**< ui_info */ - NULL, /**< extra_info */ - NULL, - actions, - - /* padding */ - NULL, - NULL, - NULL, - NULL -}; - -static void -init_plugin(PurplePlugin *plugin) -{ -} - -PURPLE_INIT_PLUGIN(interval, init_plugin, info) -- 2.11.4.GIT