8 #include "protocols/jabber/jabber.h"
10 static GtkWidget
*window
= NULL
;
11 static GtkWidget
*optmenu
= NULL
;
12 static struct gaim_connection
*gc
= NULL
;
13 static GModule
*me
= NULL
;
15 /* this is an evil hack.
16 * gc->proto_data for Jabber connections can be cast to a jconn *.
17 * gc->proto_data for MSN, TOC, and IRC connections can be cast to an int *.
27 return "Lets you send raw XML to Jabber, or raw commands to MSN, IRC, and TOC."
28 " Not very useful except for debugging. Hit 'enter' in the entry to send."
29 " Watch the debug window.";
34 gaim_plugin_unload(me
);
38 static void send_it(GtkEntry
*entry
)
42 txt
= gtk_entry_get_text(entry
);
43 switch (gc
->protocol
) {
46 int *a
= (int *)gc
->proto_data
;
47 unsigned short seqno
= htons(a
[1]++ & 0xffff);
48 unsigned short len
= htons(strlen(txt
) + 1);
49 write(*a
, "*\002", 2);
52 write(*a
, txt
, ntohs(len
));
53 debug_printf("TOC C: %s\n", txt
);
57 write(*(int *)gc
->proto_data
, txt
, strlen(txt
));
58 write(*(int *)gc
->proto_data
, "\r\n", 2);
59 debug_printf("MSN C: %s\n", txt
);
62 write(*(int *)gc
->proto_data
, txt
, strlen(txt
));
63 write(*(int *)gc
->proto_data
, "\r\n", 2);
64 debug_printf("IRC C: %s\n", txt
);
67 jab_send_raw(*(jconn
*)gc
->proto_data
, txt
);
70 gtk_entry_set_text(entry
, "");
73 static void set_gc(gpointer d
, struct gaim_connection
*c
)
78 static void redo_optmenu(struct gaim_connection
*arg
, gpointer x
)
81 GSList
*g
= connections
;
82 struct gaim_connection
*c
;
84 menu
= gtk_menu_new();
90 c
= (struct gaim_connection
*)g
->data
;
94 if (c
->protocol
!= PROTO_TOC
&& c
->protocol
!= PROTO_MSN
&&
95 c
->protocol
!= PROTO_IRC
&& c
->protocol
!= PROTO_JABBER
)
99 g_snprintf(buf
, sizeof buf
, "%s (%s)", c
->username
, (*c
->prpl
->name
)());
100 opt
= gtk_menu_item_new_with_label(buf
);
101 gtk_signal_connect(GTK_OBJECT(opt
), "activate", GTK_SIGNAL_FUNC(set_gc
), c
);
102 gtk_widget_show(opt
);
103 gtk_menu_append(GTK_MENU(menu
), opt
);
106 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu
));
107 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu
), menu
);
108 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu
), 0);
111 char *gaim_plugin_init(GModule
*h
)
118 gaim_signal_connect(h
, event_signon
, redo_optmenu
, NULL
);
119 gaim_signal_connect(h
, event_signoff
, redo_optmenu
, me
);
121 window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
122 gtk_signal_connect(GTK_OBJECT(window
), "delete_event", GTK_SIGNAL_FUNC(goodbye
), NULL
);
124 hbox
= gtk_hbox_new(FALSE
, 0);
125 gtk_container_add(GTK_CONTAINER(window
), hbox
);
127 optmenu
= gtk_option_menu_new();
128 gtk_box_pack_start(GTK_BOX(hbox
), optmenu
, FALSE
, FALSE
, 5);
130 redo_optmenu(NULL
, NULL
);
132 entry
= gtk_entry_new();
133 gtk_box_pack_start(GTK_BOX(hbox
), entry
, FALSE
, FALSE
, 5);
134 gtk_signal_connect(GTK_OBJECT(entry
), "activate", GTK_SIGNAL_FUNC(send_it
), NULL
);
136 gtk_widget_show_all(window
);
141 void gaim_plugin_remove()
144 gtk_widget_destroy(window
);