Mercurial > pidgin
view plugins/raw.c @ 4617:858979ab3867
[gaim-migrate @ 4908]
Big Changes:
-Rewrote some of the perl stuff so perl scripts can change a few of their
parameters
-Receiving a file with AIM over oscar works pretty well
Now, the "nitty gritty":
Very minor change to prefs.c: In the plugins details tab, I changed "URL"
to "Web Site." I was just going to fix the tabbing, but silvestrij
suggested changing it to "Web site," and I thought that sounded good.
I think it fits better, too. I dunno, maybe that's just me.
"Get Capabilities" has stopped working for some reason. I'm just going to
blame AOL. It's really not important anyway, and some people wanted it
taken off. It is now #ifdef 0'ed out. I'll remove it completely if it
continues to no longer function.
I took out a few plugin_event calls from oscar.c and put them in core code.
"event_error" should be, uh, "evented" when there is an error signing on.
Hopefully no one was using this. It's really pretty useless. The parameter
is now the reason for not being able to connect rather than the archaic
toc error code.
I screwed around with how perl functions are called some. There was way the
hell too much malloc'ing going on here. I think all in all it's an
improvement, though I'm still not a big fan of how changes to parameters
propagate to the actual memory.
I really think it would be nice if the perl stuff was made into a C plugin.
It's just so much cleaner. Especially if someone wanted to write, say, a
python or tcl interpreter. That's how xchat2 does it. I just think that
would be really slick. Like butter. Or ice. Very unlike Velcro.
I added a "Change Password" Protocol Action for ICQ over oscar. This was
really pretty easy. I'd like to thank my housemate Andrew for complaining
a lot that having to use Windows ICQ to change his password was a pain.
I rewrote a lot of the oscar file transfer stuff to use Christian's new
xfer interface. This involved moving a few functions from ft.c to im.c,
where they belong. I also removed all the #if 0'ed getfile functions.
I'll be rewritting them soonish. Receiving a file should work perfectly,
aside from maybe a small memleak when stuff is canceled. Sending a file is
currently disabled. No ETA on when I'll have that working.
I renamed pretty much all of the functions in im.c so they have kind of a
scheme now. They should all be aim_im_bleh, since "im" is the family
name. There comes a time when you must break the crap out of any clients
that might be using libfaim in order to make stuff cleaner. Maybe.
I got rid of the snac destructor stuff for now. I'll probably add it back
later. I wasn't entirely comfortable with how it was done.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 26 Feb 2003 05:01:37 +0000 |
parents | 07a3d1fae88f |
children | fac4c73dd5ad |
line wrap: on
line source
#define GAIM_PLUGINS #include "gaim.h" #include "prpl.h" #ifdef MAX #undef MAX #undef MIN #endif #include "protocols/jabber/jabber.h" static GtkWidget *window = NULL; static GtkWidget *optmenu = NULL; static struct gaim_connection *gc = NULL; static GModule *me = NULL; /* this is an evil hack. * gc->proto_data for Jabber connections can be cast to a jconn *. * gc->proto_data for MSN, TOC, and IRC connections can be cast to an int *. */ struct gaim_plugin_description desc; struct gaim_plugin_description *gaim_plugin_desc() { desc.api_version = PLUGIN_API_VERSION; desc.name = g_strdup("Raw Input"); desc.version = g_strdup(VERSION); desc.description = g_strdup("Lets you send raw input to text-vased protocols (Jabber, MSN, IRC, TOC). Hit 'Enter' in the entry box to send. Watch the debug window."); desc.authors = g_strdup("Eric Warmehoven <eric@warmenhoven.org>"); desc.url = g_strdup(WEBSITE); return &desc; } char *name() { return "Raw"; } char *description() { return "Lets you send raw XML to Jabber, or raw commands to MSN, IRC, and TOC." " Not very useful except for debugging. Hit 'enter' in the entry to send." " Watch the debug window."; } static int goodbye() { gaim_plugin_unload(me); return FALSE; } static void send_it(GtkEntry *entry) { char *txt; if (!gc) return; txt = gtk_entry_get_text(entry); switch (gc->protocol) { case PROTO_TOC: { int *a = (int *)gc->proto_data; unsigned short seqno = htons(a[1]++ & 0xffff); unsigned short len = htons(strlen(txt) + 1); write(*a, "*\002", 2); write(*a, &seqno, 2); write(*a, &len, 2); write(*a, txt, ntohs(len)); debug_printf("TOC C: %s\n", txt); } break; case PROTO_MSN: write(*(int *)gc->proto_data, txt, strlen(txt)); write(*(int *)gc->proto_data, "\r\n", 2); debug_printf("MSN C: %s\n", txt); break; case PROTO_IRC: write(*(int *)gc->proto_data, txt, strlen(txt)); write(*(int *)gc->proto_data, "\r\n", 2); debug_printf("IRC C: %s\n", txt); break; case PROTO_JABBER: jab_send_raw(*(jconn *)gc->proto_data, txt); break; } gtk_entry_set_text(entry, ""); } static void set_gc(gpointer d, struct gaim_connection *c) { gc = c; } static void redo_optmenu(struct gaim_connection *arg, gpointer x) { GtkWidget *menu; GSList *g = connections; struct gaim_connection *c; menu = gtk_menu_new(); gc = NULL; while (g) { char buf[256]; GtkWidget *opt; c = (struct gaim_connection *)g->data; g = g->next; if (x && c == arg) continue; if (c->protocol != PROTO_TOC && c->protocol != PROTO_MSN && c->protocol != PROTO_IRC && c->protocol != PROTO_JABBER) continue; if (!gc) gc = c; g_snprintf(buf, sizeof buf, "%s (%s)", c->username, (*c->prpl->name)()); opt = gtk_menu_item_new_with_label(buf); g_signal_connect(GTK_OBJECT(opt), "activate", G_CALLBACK(set_gc), c); gtk_widget_show(opt); gtk_menu_append(GTK_MENU(menu), opt); } gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0); } char *gaim_plugin_init(GModule *h) { GtkWidget *hbox; GtkWidget *entry; me = h; gaim_signal_connect(h, event_signon, redo_optmenu, NULL); gaim_signal_connect(h, event_signoff, redo_optmenu, me); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(GTK_OBJECT(window), "delete_event", G_CALLBACK(goodbye), NULL); hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), hbox); optmenu = gtk_option_menu_new(); gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 5); redo_optmenu(NULL, NULL); entry = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5); g_signal_connect(GTK_OBJECT(entry), "activate", G_CALLBACK(send_it), NULL); gtk_widget_show_all(window); return NULL; } void gaim_plugin_remove() { if (window) gtk_widget_destroy(window); window = NULL; me = NULL; }