Mercurial > pidgin
changeset 1000:91b7377e7b45
[gaim-migrate @ 1010]
Plugins work again, I think. There may still be some bugginess.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 16 Oct 2000 20:11:18 +0000 |
parents | 0b5db8cdd30f |
children | b8a819390499 |
files | plugins/ChangeLog plugins/Makefile.am plugins/SIGNALS plugins/autorecon.c plugins/lagmeter.c plugins/notify.c plugins/oscar.c plugins/spellchk.c src/aim.c src/away.c src/buddy.c src/buddy_chat.c src/conversation.c src/dialogs.c src/gaim.h src/oscar.c src/plugins.c src/prpl.c src/prpl.h src/server.c src/toc.c |
diffstat | 21 files changed, 222 insertions(+), 137 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/ChangeLog Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/ChangeLog Mon Oct 16 20:11:18 2000 +0000 @@ -1,3 +1,27 @@ +version 0.11.0: + Gaim is now multi-connection based. This represents a significant + change. Most of the code was modified, though most of the modifications + were small (referencing an int as part of a struct as opposed to as a + global int). Such changes will require most plugins to be modified to + match the new function declarations and such. + + The plugin system itself was only slightly modified. However, the + arguments passed to signal handlers have been modified in some cases. + Look at the updates SIGNALS file to see what the new arguments passed + to your handlers are. In some cases the only change necessary will be + to modify the function declaration; in many cases the changes will be + much more substantial. + + The new system allows for protocol plugins. New protocols (including + Yahoo, MSN, IRC, ICQ, etc) can be loaded dynamically. However, most + of these plugins are going to be controlled by the gaim maintainers. + If you have interest in writing a protocol plugin, please talk to one + of us before you start. + + That's about all that I'm going to talk about. My SN is EWarmenhoven + if you have any questions (like what the hell struct gaim_connection is + and what its relation to struct aim_user is). + version 0.10.0: Rather than have a separate CFLAGS and LDFLAGS for the plugins than for gaim, and doing all kinds of crazy things to work around the
--- a/plugins/Makefile.am Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/Makefile.am Mon Oct 16 20:11:18 2000 +0000 @@ -3,13 +3,13 @@ .c.so: $(CC) $(CFLAGS) -I../src -DVERSION=\"$(VERSION)\" -fPIC -DPIC -o $@ $< $(LDFLAGS) $(PLUGIN_LIBS) -#if PLUGINS -#plugin_DATA = autorecon.so iconaway.so notify.so spellchk.so lagmeter.so -#plugindir = $(libdir)/gaim +if PLUGINS +plugin_DATA = autorecon.so iconaway.so notify.so spellchk.so lagmeter.so +plugindir = $(libdir)/gaim -#clean distclean clean-recursive distclean-recursive: -# $(RM) $(plugin_DATA) -#endif +clean distclean clean-recursive distclean-recursive: + $(RM) $(plugin_DATA) +endif
--- a/plugins/SIGNALS Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/SIGNALS Mon Oct 16 20:11:18 2000 +0000 @@ -9,6 +9,8 @@ event_buddy_signoff, event_buddy_away, event_buddy_back, + event_buddy_idle, + event_buddy_unidle, event_blist_update, event_chat_invited, event_chat_join, @@ -51,26 +53,30 @@ So here are the args that get passed to your functions in various events: event_signon: - (none) + struct gaim_connection *gc - Note that you can get the username (which would probably be the only - useful information here) from other places. (Read gaim.h for details.) + 'gc' is the new connection. event_signoff: - (none) + struct gaim_connection *gc + + 'gc' is the connection that is about to go offline. This is called before + serv_close is, so you still have a chance to get one last message out. event_away: (none) - Note that the away message that's being used can be retrieved from a - global variable. (Read gaim.h for details.) + This is fucked up for now. Currently all connections are told to use the + same away message when the user wants to be Away. The away message that + is used can be obtained from global variables. event_back: (none) event_im_recv: - char **who, char **text + struct gaim_connection *gc, char **who, char **text + 'gc' is the connection that received the message. 'who' is the username of the person who sent the message. 'text' is the actual strict text (with HTML tags and all) of the message they sent. @@ -79,9 +85,14 @@ Note that *other* plugins can also modify these values, so you should check that they are not NULL, and try not to leave them as NULL. + gc was placed as the first arg as opposed to the third for intuitiveness. + Unfortunately, it means that most plugins that use this event need to be + slightly modified and then recompiled. + event_im_send: - char *who, char **text + struct gaim_connection *gc, char *who, char **text + 'gc' is the connection that you are about to send the message through. 'who' is the username of the person you're sending the message to. 'text' is the actual strict text (with HTML tags and all) of the message you're sending. @@ -92,7 +103,8 @@ event_buddy_signon: char *who - 'who' is who signed on. + 'who' is who signed on. (There is currently no way to see which connection + reported that the buddy came online. Hopefully this will happen soon.) event_buddy_signoff: char *who @@ -109,33 +121,47 @@ 'who' is who is no longer away. +event_buddy_idle: + char *who + + 'who' is who went idle. + +event_buddy_unidle: + char *who + + 'who' is who is no longer idle. + event_blist_update: (none) This event is called when the buddylist is updated (automatically every - 20 seconds) + 20 seconds for every connection, though the updates are usually syncopated) event_chat_invited: - char *who, char *room, char *message + struct gaim_connection *gc, char *who, char *room, char *message + 'gc' is the connection that received the invitation. 'who' is who invited you to a chat room. 'room' is the room they invited you to. 'message' is the (optional) message they sent to invite you, and may be an empty string. event_chat_join: - char *room + struct gaim_connection *gc, char *room + 'gc' is the connection that joined the room. 'room' is the chat room that you have just joined. event_chat_leave: - char *room + struct gaim_connection *gc, char *room + 'gc' is the connection that joined the room. 'room' is the chat room that you have just left. event_chat_buddy_join: - char *room, char *who + struct gaim_connection *gc, char *room, char *who + 'gc' is the connection that the chat room is attached to. 'room' is the room the person joined. 'who' is the screenname of the person who joined. @@ -146,14 +172,16 @@ for though.) event_chat_buddy_leave: - char *room, char *who + struct gaim_connection *gc, char *room, char *who + 'gc' is the connection that the chat room is attached to. 'room' is the room the person left. 'who' is the screenname of the person who left. event_chat_recv: - char *room, char *who, char *text + struct gaim_connection *gc, char *room, char *who, char *text + 'gc' is the connection that received the message. 'room' should be obvious by now. 'who' should be too. 'text' is the message that got sent. @@ -162,8 +190,9 @@ messages that you send. I didn't design it, AOL did. event_chat_send: - char *room, char **text + struct gaim_connection *gc, char *room, char **text + 'gc' is the connection that the message is about to be sent on. 'room'. Need I say more. 'text' is what you're about to say, linkified/HTML-ized, but not TOC-escaped.
--- a/plugins/autorecon.c Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/autorecon.c Mon Oct 16 20:11:18 2000 +0000 @@ -17,29 +17,18 @@ return "When AOL kicks you off, this auto-reconnects you."; } -extern void dologin(GtkWidget *, GtkWidget *); - -void do_signon() { - if (!blist) - dologin(NULL, NULL); - if (!USE_OSCAR) { - if (blist) { - gtk_timeout_remove(recon); - forced_off = 0; - if (away_state) - do_away_message(NULL, last_away); - return; - } - } else { - gtk_timeout_remove(recon); - forced_off = 0; - if (blist && away_state) do_away_message(NULL, last_away); - return; - } +void do_signon(char *name) { + struct aim_user *u = find_user(name); + g_free(name); + serv_login(u); + gtk_timeout_remove(recon); + forced_off = 0; + if (away_state) do_away_message(NULL, last_away); } -void reconnect(void *m) { - recon = gtk_timeout_add(8000, (GtkFunction)do_signon, NULL); +void reconnect(struct gaim_connection *gc, void *m) { + char *name = g_strdup(gc->username); + recon = gtk_timeout_add(8000, (GtkFunction)do_signon, name); forced_off = 1; }
--- a/plugins/lagmeter.c Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/lagmeter.c Mon Oct 16 20:11:18 2000 +0000 @@ -69,9 +69,9 @@ gtk_progress_bar_update(GTK_PROGRESS_BAR(my_lagometer), pct); } -void check_lag(char **who, char **message, void *m) { +void check_lag(struct gaim_connection *gc, char **who, char **message, void *m) { char *name = g_strdup(normalize(*who)); - if (!strcasecmp(normalize(current_user->username), name) && + if (!strcasecmp(normalize(gc->username), name) && (*message != NULL) && !strcmp(*message, MY_LAG_STRING)) { struct timeval tv; @@ -89,9 +89,9 @@ g_free(name); } -void send_lag() { +void send_lag(struct gaim_connection *gc) { gettimeofday(&my_lag_tv, NULL); - serv_send_im(current_user->username, MY_LAG_STRING, 1); + serv_send_im(gc, gc->username, MY_LAG_STRING, 1); } void gaim_plugin_remove() { @@ -106,11 +106,11 @@ lagbox = NULL; } -void avail_now(void *m) { +void avail_now(struct gaim_connection *gc, void *m) { update_lag(0); gaim_signal_connect(handle, event_im_recv, check_lag, NULL); gaim_signal_connect(handle, event_signoff, gaim_plugin_remove, NULL); - check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, NULL); + check_timeout = gtk_timeout_add(1000 * delay, (GtkFunction)send_lag, gc); } void gaim_plugin_init(void *h) { @@ -122,7 +122,7 @@ if (!blist) gaim_signal_connect(handle, event_signon, avail_now, NULL); else - avail_now(NULL); + avail_now(connections->data, NULL); } void adjust_timeout(GtkWidget *button, GtkWidget *spinner) {
--- a/plugins/notify.c Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/notify.c Mon Oct 16 20:11:18 2000 +0000 @@ -6,7 +6,7 @@ void *handle; -void received_im(char **who, char **what, void *m) { +void received_im(struct gaim_connection *gc, char **who, char **what, void *m) { char buf[256]; struct conversation *cnv = find_conversation(*who); GtkWindow *win; @@ -23,7 +23,7 @@ } } -void sent_im(char *who, char **what, void *m) { +void sent_im(struct gaim_connection *gc, char *who, char **what, void *m) { char buf[256]; struct conversation *c = find_conversation(who); GtkWindow *win = (GtkWindow *)c->window;
--- a/plugins/oscar.c Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/oscar.c Mon Oct 16 20:11:18 2000 +0000 @@ -351,17 +351,17 @@ case 0x18: /* connecting too frequently */ do_error_dialog(_("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."), _("Gaim - Error")); - plugin_event(event_error, (void *)983, 0, 0); + plugin_event(event_error, (void *)983, 0, 0, 0); break; case 0x05: /* Incorrect nick/password */ do_error_dialog(_("Incorrect nickname or password."), _("Gaim - Error")); - plugin_event(event_error, (void *)980, 0, 0); + plugin_event(event_error, (void *)980, 0, 0, 0); break; case 0x1c: /* client too old */ do_error_dialog(_("The client version you are using is too old. Please upgrade at http://www.marko.net/gaim/"), _("Gaim - Error")); - plugin_event(event_error, (void *)989, 0, 0); + plugin_event(event_error, (void *)989, 0, 0, 0); break; } sprintf(debug_buff, "Login Error Code 0x%04x\n", @@ -805,12 +805,12 @@ /* message too large */ sprintf(buf, _("You missed a message from %s because it was too large."), userinfo->sn); do_error_dialog(buf, _("Gaim - Error")); - plugin_event(event_error, (void *)961, 0, 0); + plugin_event(event_error, (void *)961, 0, 0, 0); break; default: sprintf(buf, _("You missed a message from %s for unknown reasons."), userinfo->sn); do_error_dialog(buf, _("Gaim - Error")); - plugin_event(event_error, (void *)970, 0, 0); + plugin_event(event_error, (void *)970, 0, 0, 0); break; } @@ -876,7 +876,7 @@ char buf[1024]; sprintf(buf, _("%s has no info/away message."), info->sn); do_error_dialog(buf, _("Gaim - Error")); - plugin_event(event_error, (void *)977, 0, 0); + plugin_event(event_error, (void *)977, 0, 0, 0); return 1; } @@ -1524,9 +1524,7 @@ aim_chat_send_im(odata->sess, cn, message); } -struct prpl *oscar_init() { - struct prpl *ret = g_new0(struct prpl, 1); - +void oscar_init(struct prpl *ret) { ret->protocol = PROTO_OSCAR; ret->name = oscar_name; ret->login = oscar_login; @@ -1554,8 +1552,6 @@ ret->chat_whisper = oscar_chat_whisper; ret->chat_send = oscar_chat_send; ret->keepalive = oscar_keepalive; - - return ret; } char *name() { @@ -1567,6 +1563,6 @@ } int gaim_plugin_init(void *handle) { - protocols = g_slist_append(protocols, oscar_init()); + load_protocol(oscar_init); return 0; }
--- a/plugins/spellchk.c Sun Oct 15 03:55:23 2000 +0000 +++ b/plugins/spellchk.c Mon Oct 16 20:11:18 2000 +0000 @@ -31,7 +31,7 @@ char *have_word(char *, int); void substitute(char **, int, int, char *); -void substitute_words(char *who, char **message, void *m) { +void substitute_words(struct gaim_connection *gc, char *who, char **message, void *m) { int i, l; int word; GList *w;
--- a/src/aim.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/aim.c Mon Oct 16 20:11:18 2000 +0000 @@ -87,7 +87,7 @@ char *error; /* first we tell those who have requested it we're quitting */ - plugin_event(event_quit, 0, 0, 0); + plugin_event(event_quit, 0, 0, 0, 0); /* then we remove everyone in a mass suicide */ c = plugins; @@ -140,9 +140,9 @@ account_online(gc); - plugin_event(event_signon, 0, 0, 0); + plugin_event(event_signon, gc, 0, 0, 0); - return; + return; }
--- a/src/away.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/away.c Mon Oct 16 20:11:18 2000 +0000 @@ -62,7 +62,7 @@ serv_set_away(NULL); awaymessage = NULL; - plugin_event(event_back, 0, 0, 0); + plugin_event(event_back, 0, 0, 0, 0); } void do_away_message(GtkWidget *w, struct away_message *a) @@ -162,7 +162,7 @@ serv_set_away(buf2); g_free(buf2); gtk_widget_show(imaway); - plugin_event(event_away, 0, 0, 0); + plugin_event(event_away, 0, 0, 0, 0); } void rem_away_mess(GtkWidget *w, struct away_message *a)
--- a/src/buddy.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/buddy.c Mon Oct 16 20:11:18 2000 +0000 @@ -291,7 +291,7 @@ { GList *mem; - plugin_event(event_signoff, gc, 0, 0); + plugin_event(event_signoff, gc, 0, 0, 0); serv_close(gc); if (connections) return; @@ -982,7 +982,7 @@ char *error; /* first we tell those who have requested it we're quitting */ - plugin_event(event_quit, 0, 0, 0); + plugin_event(event_quit, 0, 0, 0, 0); /* then we remove everyone in a mass suicide */ c = plugins; @@ -1439,7 +1439,7 @@ /* this check should also depend on whether they left, * and signed on again before they got erased */ if (!GTK_WIDGET_VISIBLE(b->item) || b->present == 1) { - plugin_event(event_buddy_signon, b->name, 0, 0); + plugin_event(event_buddy_signon, b->name, 0, 0, 0); play_sound(BUDDY_ARRIVE); b->present = 2; @@ -1593,7 +1593,7 @@ } else { if (GTK_WIDGET_VISIBLE(b->item)) { - plugin_event(event_buddy_signoff, b->name, 0, 0); + plugin_event(event_buddy_signoff, b->name, 0, 0, 0); play_sound(BUDDY_LEAVE); pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, NULL, (gchar **)logout_icon_xpm);
--- a/src/buddy_chat.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/buddy_chat.c Mon Oct 16 20:11:18 2000 +0000 @@ -434,7 +434,7 @@ char *name = g_strdup(buddy); char tmp[BUF_LONG]; - plugin_event(event_chat_buddy_join, b->name, name, 0); + plugin_event(event_chat_buddy_join, b->gc, b->name, name, 0); b->in_room = g_list_append(b->in_room, name); update_chat_list(b); @@ -456,7 +456,7 @@ GList *names = b->in_room; char tmp[BUF_LONG]; - plugin_event(event_chat_buddy_leave, b->name, buddy, 0); + plugin_event(event_chat_buddy_leave, b->gc, b->name, buddy, 0); while(names) { if (!strcasecmp((char *)names->data, buddy)) {
--- a/src/conversation.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/conversation.c Mon Oct 16 20:11:18 2000 +0000 @@ -139,7 +139,7 @@ if (connections) c->gc = (struct gaim_connection *)connections->data; conversations = g_list_append(conversations, c); - plugin_event(event_new_conversation, name, 0, 0); + plugin_event(event_new_conversation, name, 0, 0, 0); return c; } @@ -684,7 +684,7 @@ { char *buffy = g_strdup(buf); enum gaim_event evnt = c->is_chat ? event_chat_send : event_im_send; - plugin_event(evnt, c->name, &buffy, 0); + plugin_event(evnt, c->gc, c->name, &buffy, 0); if (!buffy) { g_free(buf2); g_free(buf);
--- a/src/dialogs.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/dialogs.c Mon Oct 16 20:11:18 2000 +0000 @@ -438,7 +438,7 @@ char buf[256]; char buf2[32]; - plugin_event(event_error, (void *)no, 0, 0); + plugin_event(event_error, (void *)no, 0, 0, 0); w = strtok(NULL, ":");
--- a/src/gaim.h Sun Oct 15 03:55:23 2000 +0000 +++ b/src/gaim.h Mon Oct 16 20:11:18 2000 +0000 @@ -177,6 +177,8 @@ event_buddy_signoff, event_buddy_away, event_buddy_back, + event_buddy_idle, + event_buddy_unidle, event_blist_update, event_chat_invited, event_chat_join, @@ -785,7 +787,7 @@ extern void gaim_plugin_unload(void *); #endif extern char *event_name(enum gaim_event); -extern void plugin_event(enum gaim_event, void *, void *, void *); +extern void plugin_event(enum gaim_event, void *, void *, void *, void *); /* Functions in prefs.c */ extern void debug_print( char * chars );
--- a/src/oscar.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/oscar.c Mon Oct 16 20:11:18 2000 +0000 @@ -353,17 +353,17 @@ case 0x18: /* connecting too frequently */ do_error_dialog(_("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."), _("Gaim - Error")); - plugin_event(event_error, (void *)983, 0, 0); + plugin_event(event_error, (void *)983, 0, 0, 0); break; case 0x05: /* Incorrect nick/password */ do_error_dialog(_("Incorrect nickname or password."), _("Gaim - Error")); - plugin_event(event_error, (void *)980, 0, 0); + plugin_event(event_error, (void *)980, 0, 0, 0); break; case 0x1c: /* client too old */ do_error_dialog(_("The client version you are using is too old. Please upgrade at http://www.marko.net/gaim/"), _("Gaim - Error")); - plugin_event(event_error, (void *)989, 0, 0); + plugin_event(event_error, (void *)989, 0, 0, 0); break; } sprintf(debug_buff, "Login Error Code 0x%04x\n", @@ -807,12 +807,12 @@ /* message too large */ sprintf(buf, _("You missed a message from %s because it was too large."), userinfo->sn); do_error_dialog(buf, _("Gaim - Error")); - plugin_event(event_error, (void *)961, 0, 0); + plugin_event(event_error, (void *)961, 0, 0, 0); break; default: sprintf(buf, _("You missed a message from %s for unknown reasons."), userinfo->sn); do_error_dialog(buf, _("Gaim - Error")); - plugin_event(event_error, (void *)970, 0, 0); + plugin_event(event_error, (void *)970, 0, 0, 0); break; } @@ -878,7 +878,7 @@ char buf[1024]; sprintf(buf, _("%s has no info/away message."), info->sn); do_error_dialog(buf, _("Gaim - Error")); - plugin_event(event_error, (void *)977, 0, 0); + plugin_event(event_error, (void *)977, 0, 0, 0); return 1; } @@ -1526,9 +1526,7 @@ aim_chat_send_im(odata->sess, cn, message); } -struct prpl *oscar_init() { - struct prpl *ret = g_new0(struct prpl, 1); - +void oscar_init(struct prpl *ret) { ret->protocol = PROTO_OSCAR; ret->name = oscar_name; ret->login = oscar_login; @@ -1556,8 +1554,6 @@ ret->chat_whisper = oscar_chat_whisper; ret->chat_send = oscar_chat_send; ret->keepalive = oscar_keepalive; - - return ret; } #endif
--- a/src/plugins.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/plugins.c Mon Oct 16 20:11:18 2000 +0000 @@ -561,6 +561,12 @@ case event_buddy_back: sprintf(buf, "event_buddy_back"); break; + case event_buddy_idle: + sprintf(buf, "event_buddy_idle"); + break; + case event_buddy_unidle: + sprintf(buf, "event_buddy_unidle"); + break; case event_blist_update: sprintf(buf, "event_blist_update"); break; @@ -604,7 +610,7 @@ return buf; } -void plugin_event(enum gaim_event event, void *arg1, void *arg2, void *arg3) { +void plugin_event(enum gaim_event event, void *arg1, void *arg2, void *arg3, void *arg4) { #ifdef USE_PERL char buf[BUF_LONG]; char *tmp; @@ -618,9 +624,16 @@ if (g->event == event && g->function != NULL) { switch(event) { - /* no args */ + /* struct gaim_connection * */ case event_signon: case event_signoff: + { + void (*function)(struct gaim_connection *, void *) = g->function; + (*function)(arg1, g->data); + } + break; + + /* no args */ case event_away: case event_back: case event_blist_update: @@ -631,19 +644,31 @@ } break; - /* char **, char ** */ + /* struct gaim_connection *, char **, char ** */ case event_im_recv: { - void (*function)(char **, char **, void *) = g->function; - (*function)(arg1, arg2, g->data); + void (*function)(struct gaim_connection *, char **, char **, + void *) = g->function; + (*function)(arg1, arg2, arg3, g->data); } break; - /* char *, char ** */ + /* struct gaim_connection *, char *, char ** */ case event_im_send: case event_chat_send: { - void (*function)(char *, char **, void *) = g->function; + void (*function)(struct gaim_connection *, char *, char **, + void *) = g->function; + (*function)(arg1, arg2, arg3, g->data); + } + break; + + /* struct gaim_connection *, char * */ + case event_chat_join: + case event_chat_leave: + { + void (*function)(struct gaim_connection *, char *, void *) = + g->function; (*function)(arg1, arg2, g->data); } break; @@ -653,8 +678,8 @@ case event_buddy_signoff: case event_buddy_away: case event_buddy_back: - case event_chat_join: - case event_chat_leave: + case event_buddy_idle: + case event_buddy_unidle: case event_new_conversation: { void (*function)(char *, void *) = g->function; @@ -662,21 +687,23 @@ } break; - /* char *, char *, char * */ + /* struct gaim_connection *, char *, char *, char * */ case event_chat_invited: case event_chat_recv: { - void (*function)(char *, char *, char *, void *) = g->function; - (*function)(arg1, arg2, arg3, g->data); + void (*function)(struct gaim_connection *, char *, char *, + char *, void *) = g->function; + (*function)(arg1, arg2, arg3, arg4, g->data); } break; - /* char *, char * */ + /* struct gaim_connection *, char *, char * */ case event_chat_buddy_join: case event_chat_buddy_leave: { - void (*function)(char *, char *, void *) = g->function; - (*function)(arg1, arg2, g->data); + void (*function)(struct gaim_connection *, char *, char *, + void *) = g->function; + (*function)(arg1, arg2, arg3, g->data); } break; @@ -708,10 +735,10 @@ #ifdef USE_PERL switch (event) { case event_signon: - buf[0] = 0; + g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); break; case event_signoff: - buf[0] = 0; + g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); break; case event_away: buf[0] = 0; @@ -720,10 +747,10 @@ buf[0] = 0; break; case event_im_recv: - g_snprintf(buf, sizeof buf, "\"%s\" %s", *(char **)arg1, *(char **)arg2); + g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", ((struct gaim_connection *)arg1)->username, *(char **)arg2, *(char **)arg3); break; case event_im_send: - g_snprintf(buf, sizeof buf, "\"%s\" %s", (char *)arg1, *(char **)arg2); + g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", ((struct gaim_connection *)arg1)->username, (char *)arg2, *(char **)arg3); break; case event_buddy_signon: g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); @@ -737,29 +764,35 @@ case event_buddy_back: g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); break; + case event_buddy_idle: + g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); + break; + case event_buddy_unidle: + g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); + break; case event_blist_update: buf[0] = 0; break; case event_chat_invited: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg1, (char *)arg2, (char *)arg3); + g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg2, (char *)arg3, (char *)arg4); break; case event_chat_join: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); + g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); break; case event_chat_leave: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); + g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); break; case event_chat_buddy_join: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\"", (char *)arg1, (char *)arg2); + g_snprintf(buf, sizeof buf, "\"%s\" \"%s\"", (char *)arg2, (char *)arg3); break; case event_chat_buddy_leave: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\"", (char *)arg1, (char *)arg2); + g_snprintf(buf, sizeof buf, "\"%s\" \"%s\"", (char *)arg2, (char *)arg3); break; case event_chat_recv: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg1, (char *)arg2, (char *)arg3); + g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg2, (char *)arg3, (char *)arg4); break; case event_chat_send: - g_snprintf(buf, sizeof buf, "\"%s\" %s", (char *)arg1, *(char **)arg2); + g_snprintf(buf, sizeof buf, "\"%s\" %s", (char *)arg2, *(char **)arg3); break; case event_warned: g_snprintf(buf, sizeof buf, "\"%s\" %d", (char *)arg1, (int)arg2);
--- a/src/prpl.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/prpl.c Mon Oct 16 20:11:18 2000 +0000 @@ -20,8 +20,9 @@ */ #include "prpl.h" -extern struct prpl *toc_init(); -extern struct prpl *oscar_init(); + +extern void toc_init(struct prpl *); +extern void oscar_init(struct prpl *); GSList *protocols = NULL; @@ -40,10 +41,20 @@ return NULL; } +void load_protocol(proto_init pi) +{ + struct prpl *p = g_new0(struct prpl, 1); + pi(p); + if (find_prpl(p->protocol)) + g_free(p); + else + protocols = g_slist_append(protocols, p); +} + void static_proto_init() { - protocols = g_slist_append(protocols, toc_init()); + load_protocol(toc_init); #ifndef DYNAMIC_OSCAR - protocols = g_slist_append(protocols, oscar_init()); + load_protocol(oscar_init); #endif }
--- a/src/prpl.h Sun Oct 15 03:55:23 2000 +0000 +++ b/src/prpl.h Mon Oct 16 20:11:18 2000 +0000 @@ -32,6 +32,8 @@ #define PROTO_IRC 5 #define PROTO_FTP 6 +typedef void (*proto_init)(struct prpl *); + struct prpl { int protocol; char *(* name)(); @@ -80,8 +82,12 @@ extern GSList *protocols; +/* this is mostly just for aim.c, when it initializes the protocols */ void static_proto_init(); +/* this is what should actually load the protocol. pass it the protocol's initializer */ +void load_protocol(proto_init); + struct prpl *find_prpl(int); #endif
--- a/src/server.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/server.c Mon Oct 16 20:11:18 2000 +0000 @@ -84,7 +84,7 @@ /* Not idle, really... :) */ update_all_buddies(); - plugin_event(event_blist_update, 0, 0, 0); + plugin_event(event_blist_update, 0, 0, 0, 0); time(&t); @@ -452,7 +452,7 @@ char *buffy = g_strdup(message); char *angel = g_strdup(name); - plugin_event(event_im_recv, &angel, &buffy, 0); + plugin_event(event_im_recv, gc, &angel, &buffy, 0); if (!buffy || !angel) return; g_snprintf(message, strlen(message) + 1, "%s", buffy); @@ -603,13 +603,16 @@ } + if (!b->idle && idle) plugin_event(event_buddy_idle, b->name, 0, 0, 0); + if (b->idle && !idle) plugin_event(event_buddy_unidle, b->name, 0, 0, 0); + b->idle = idle; b->evil = evil; if ((b->uc & UC_UNAVAILABLE) && !(type & UC_UNAVAILABLE)) { - plugin_event(event_buddy_back, b->name, 0, 0); + plugin_event(event_buddy_back, b->name, 0, 0, 0); } else if (!(b->uc & UC_UNAVAILABLE) && (type & UC_UNAVAILABLE)) { - plugin_event(event_buddy_away, b->name, 0, 0); + plugin_event(event_buddy_away, b->name, 0, 0, 0); } b->uc = type; @@ -642,7 +645,7 @@ GtkWidget *d, *label, *close; - plugin_event(event_warned, name, (void *)lev, 0); + plugin_event(event_warned, name, (void *)lev, 0, 0); g_snprintf(buf2, 1023, "You have just been warned by %s.\nYour new warning level is %d%%", ((name == NULL) ? "an anonymous person" : name) , lev); @@ -704,7 +707,7 @@ char buf2[BUF_LONG]; - plugin_event(event_chat_invited, who, name, message); + plugin_event(event_chat_invited, g, who, name, message); if (message) g_snprintf(buf2, sizeof(buf2), "User '%s' invites %s to buddy chat room: '%s'\n%s", who, g->username, name, message); @@ -750,7 +753,7 @@ { struct conversation *b; - plugin_event(event_chat_join, name, 0, 0); + plugin_event(event_chat_join, gc, name, 0, 0); b = (struct conversation *)g_new0(struct conversation, 1); gc->buddy_chats = g_slist_append(gc->buddy_chats, b); @@ -800,7 +803,7 @@ if (!b) return; - plugin_event(event_chat_leave, b->name, 0, 0); + plugin_event(event_chat_leave, g, b->name, 0, 0); sprintf(debug_buff, "Leaving room %s.\n", b->name); debug_print(debug_buff); @@ -827,7 +830,7 @@ if (!b) return; - plugin_event(event_chat_recv, b->name, who, message); + plugin_event(event_chat_recv, g, b->name, who, message); if (whisper) w = WFLAG_WHISPER;
--- a/src/toc.c Sun Oct 15 03:55:23 2000 +0000 +++ b/src/toc.c Mon Oct 16 20:11:18 2000 +0000 @@ -40,7 +40,7 @@ #include "gaim.h" #include "gnome_applet_mgr.h" -#define REVISION "gaim:$Revision: 1008 $" +#define REVISION "gaim:$Revision: 1010 $" struct toc_data { int toc_fd; @@ -1115,9 +1115,7 @@ sflap_send(gc, "", 0, TYPE_KEEPALIVE); } -struct prpl *toc_init() { - struct prpl *ret = g_new0(struct prpl, 1); - +void toc_init(struct prpl *ret) { ret->protocol = PROTO_TOC; ret->name = toc_name; ret->login = toc_login; @@ -1145,6 +1143,4 @@ ret->chat_whisper = toc_chat_whisper; ret->chat_send = toc_chat_send; ret->keepalive = toc_keepalive; - - return ret; }