From: Eric W. <war...@us...> - 2001-09-22 09:14:30
|
Update of /cvsroot/gaim/gaim/src In directory usw-pr-cvs1:/tmp/cvs-serv3080/src Modified Files: buddy_chat.c conversation.c gaim.h perl.c plugins.c server.c Log Message: you say potato, i say potato you say tomato, i say tomato potato, potato tomato, tomato let's call the whole thing off. *sigh*. it just doesn't work as well when it's typed. but you wouldn't want to hear me sing it. Index: buddy_chat.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/buddy_chat.c,v retrieving revision 1.110 retrieving revision 1.111 diff -u -d -r1.110 -r1.111 --- buddy_chat.c 2001/09/20 01:20:29 1.110 +++ buddy_chat.c 2001/09/22 09:14:27 1.111 @@ -633,7 +633,7 @@ int pos; GList *ignored; - plugin_event(event_chat_buddy_join, b->gc, b->name, name, 0); + plugin_event(event_chat_buddy_join, b->gc, (void *)b->id, name, 0); b->in_room = g_list_insert_sorted(b->in_room, name, insertname); pos = g_list_index(b->in_room, name); @@ -739,7 +739,7 @@ char tmp[BUF_LONG]; - plugin_event(event_chat_buddy_leave, b->gc, b->name, buddy, 0); + plugin_event(event_chat_buddy_leave, b->gc, (void *)b->id, buddy, 0); while (names) { if (!g_strcasecmp((char *)names->data, buddy)) { Index: conversation.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.c,v retrieving revision 1.262 retrieving revision 1.263 diff -u -d -r1.262 -r1.263 --- conversation.c 2001/09/21 17:51:13 1.262 +++ conversation.c 2001/09/22 09:14:27 1.263 @@ -847,7 +847,9 @@ { char *buffy = g_strdup(buf); enum gaim_event evnt = c->is_chat ? event_chat_send : event_im_send; - int plugin_return = plugin_event(evnt, c->gc, c->name, &buffy, 0); + int plugin_return = plugin_event(evnt, c->gc, + c->is_chat ? (void *)c->id : c->name, + &buffy, 0); if (!buffy) { g_free(buf2); g_free(buf); Index: gaim.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/gaim.h,v retrieving revision 1.260 retrieving revision 1.261 diff -u -d -r1.260 -r1.261 --- gaim.h 2001/09/21 00:14:12 1.260 +++ gaim.h 2001/09/22 09:14:27 1.261 @@ -212,6 +212,7 @@ event_draw_menu, event_im_displayed_sent, event_im_displayed_rcvd, + event_chat_send_invite, /* any others? it's easy to add... */ }; @@ -810,7 +811,6 @@ extern void gaim_signal_disconnect(GModule *, enum gaim_event, void *); extern void gaim_plugin_unload(GModule *); #endif -extern char *event_name(enum gaim_event); extern int plugin_event(enum gaim_event, void *, void *, void *, void *); extern void remove_all_plugins(); Index: perl.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/perl.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- perl.c 2001/09/20 19:09:42 1.55 +++ perl.c 2001/09/22 09:14:27 1.56 @@ -306,7 +306,7 @@ dXSARGS; items = 0; - switch(atoi(SvPV(ST(0), junk))) { + switch(SvIV(ST(0))) { case 0: XST_mPV(0, VERSION); i = 1; @@ -318,26 +318,57 @@ while (c) { gc = (struct gaim_connection *)c->data; - XST_mPV(i++, gc->username); + XST_mIV(i++, (guint)gc); c = c->next; } } break; case 2: { - GList *u = aim_users; - struct aim_user *a; - char *name = g_strdup(normalize(SvPV(ST(1), junk))); - - while (u) { - a = (struct aim_user *)u->data; - if (!strcasecmp(normalize(a->username), name)) - XST_mIV(i++, a->protocol); - u = u->next; + struct gaim_connection *gc = (struct gaim_connection *)SvPV(ST(1), junk); + if (g_slist_find(connections, gc)) + XST_mIV(i++, gc->protocol); + else + XST_mIV(i++, -1); + } + break; + case 3: + { + struct gaim_connection *gc = (struct gaim_connection *)SvPV(ST(1), junk); + if (g_slist_find(connections, gc)) + XST_mPV(i++, gc->username); + else + XST_mPV(i++, ""); + } + case 4: + { + struct gaim_connection *gc = (struct gaim_connection *)SvPV(ST(1), junk); + if (g_slist_find(connections, gc)) + XST_mIV(i++, g_list_index(aim_users, gc->user)); + else + XST_mIV(i++, -1); + } + break; + case 5: + { + GList *a = aim_users; + while (a) { + struct aim_user *u = a->data; + XST_mPV(i++, u->username); + a = a->next; } - g_free(name); } break; + case 6: + { + GList *a = aim_users; + while (a) { + struct aim_user *u = a->data; + XST_mIV(i++, u->protocol); + a = a->next; + } + } + break; default: XST_mPV(0, "Error2"); i = 1; @@ -362,20 +393,18 @@ XS (XS_GAIM_buddy_list) { - char *acct; struct gaim_connection *gc; struct buddy *buddy; struct group *g; GSList *list = NULL; GSList *mem; int i = 0; - unsigned int junk; dXSARGS; items = 0; - acct = SvPV(ST(0), junk); - gc = find_gaim_conn_by_name(acct); - if (gc) list = gc->groups; + gc = (struct gaim_connection *)SvIV(ST(0)); + if (g_slist_find(connections, gc)) + list = gc->groups; while (list) { g = (struct group *)list->data; @@ -392,20 +421,18 @@ XS (XS_GAIM_online_list) { - char *acct; struct gaim_connection *gc; struct buddy *b; struct group *g; GSList *list = NULL; GSList *mem; int i = 0; - unsigned int junk; dXSARGS; items = 0; - acct = SvPV(ST(0), junk); - gc = find_gaim_conn_by_name(acct); - if (gc) list = gc->groups; + gc = (struct gaim_connection *)SvIV(ST(0)); + if (g_slist_find(connections, gc)) + list = gc->groups; while (list) { g = (struct group *)list->data; @@ -430,22 +457,17 @@ command = SvPV(ST(0), junk); if (!command) XSRETURN(0); if (!strncasecmp(command, "signon", 6)) { - char *who = SvPV(ST(1), junk); - struct aim_user *u = find_user(who, -1); - if (u) serv_login(u); + int index = SvIV(ST(1)); + if (g_list_nth_data(aim_users, index)) + serv_login(g_list_nth_data(aim_users, index)); } else if (!strncasecmp(command, "signoff", 7)) { - char *who = SvPV(ST(1), junk); - struct gaim_connection *gc = find_gaim_conn_by_name(who); - if (gc) signoff(gc); + struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); + if (g_slist_find(connections, gc)) signoff(gc); else signoff_all(NULL, NULL); } else if (!strncasecmp(command, "info", 4)) { - GSList *c = connections; - struct gaim_connection *gc; - while (c) { - gc = (struct gaim_connection *)c->data; - serv_set_info(gc, SvPV(ST(1), junk)); - c = c->next; - } + struct gaim_connection *gc = (struct gaim_connection *)SvIV(ST(1)); + if (g_slist_find(connections, gc)) + serv_set_info(gc, SvPV(ST(2), junk)); } else if (!strncasecmp(command, "away", 4)) { char *message = SvPV(ST(1), junk); static struct away_message a; @@ -459,7 +481,7 @@ while (c) { gc = (struct gaim_connection *)c->data; - serv_set_idle(gc, atoi(SvPV(ST(1), junk))); + serv_set_idle(gc, SvIV(ST(1))); gc->is_idle = 1; c = c->next; } @@ -469,7 +491,7 @@ while (c) { gc = (struct gaim_connection *)c->data; - serv_warn(gc, SvPV(ST(1), junk), atoi(SvPV(ST(2), junk))); + serv_warn(gc, SvPV(ST(1), junk), SvIV(ST(2))); c = c->next; } } @@ -479,23 +501,16 @@ XS (XS_GAIM_user_info) { - GSList *c = connections; struct gaim_connection *gc; unsigned int junk; struct buddy *buddy = NULL; - char *nick; dXSARGS; items = 0; - nick = SvPV(ST(0), junk); - if (!nick[0]) - XSRETURN(0); - while (c) { - gc = (struct gaim_connection *)c->data; - buddy = find_buddy(gc, nick); - if (buddy) c = NULL; - else c = c->next; - } + gc = (struct gaim_connection *)SvIV(ST(0)); + if (g_slist_find(connections, gc)) + buddy = find_buddy(gc, SvPV(ST(1), junk)); + if (!buddy) XSRETURN(0); XST_mPV(0, buddy->name); @@ -519,7 +534,7 @@ items = 0; nick = SvPV(ST(0), junk); - send = atoi(SvPV(ST(1), junk)); + send = SvIV(ST(1)); what = SvPV(ST(2), junk); who = SvPV(ST(3), junk); @@ -537,69 +552,86 @@ c = new_conversation(nick); write_to_conv(c, what, wflags, who, time((time_t)NULL)); + XSRETURN(0); } XS (XS_GAIM_serv_send_im) { - char *nick, *what, *isauto; + struct gaim_connection *gc; + char *nick, *what; + int isauto; int junk; dXSARGS; items = 0; - nick = SvPV(ST(0), junk); - what = SvPV(ST(1), junk); - isauto = SvPV(ST(2), junk); + gc = (struct gaim_connection *)SvIV(ST(0)); + nick = SvPV(ST(1), junk); + what = SvPV(ST(2), junk); + isauto = SvIV(ST(3)); - if (!connections) + if (!g_slist_find(connections, gc)) { + XSRETURN(0); return; - serv_send_im(connections->data, nick, what, atoi(isauto)); + } + serv_send_im(connections->data, nick, what, isauto); + XSRETURN(0); } XS (XS_GAIM_print_to_conv) { - char *nick, *what, *isauto; + struct gaim_connection *gc; + char *nick, *what; + int isauto; struct conversation *c; unsigned int junk; dXSARGS; items = 0; - nick = SvPV(ST(0), junk); - what = SvPV(ST(1), junk); - isauto = SvPV(ST(2), junk); + gc = (struct gaim_connection *)SvIV(ST(0)); + nick = SvPV(ST(1), junk); + what = SvPV(ST(2), junk); + isauto = SvIV(ST(3)); + if (!g_slist_find(connections, gc)) { + XSRETURN(0); + return; + } c = find_conversation(nick); if (!c) c = new_conversation(nick); write_to_conv(c, what, WFLAG_SEND, NULL, time((time_t)NULL)); - serv_send_im(c->gc, nick, what, atoi(isauto) ? IM_FLAG_AWAY : 0); + serv_send_im(c->gc, nick, what, isauto ? IM_FLAG_AWAY : 0); + XSRETURN(0); } XS (XS_GAIM_print_to_chat) { - char *nick, *what, *tmp; - GSList *c = connections; struct gaim_connection *gc; + int id; + char *what; struct conversation *b = NULL; GSList *bcs; unsigned int junk; dXSARGS; items = 0; - nick = SvPV(ST(0), junk); - what = SvPV(ST(1), junk); - tmp = g_strdup(normalize(nick)); - while (c) { - gc = (struct gaim_connection *)c->data; - bcs = gc->buddy_chats; - while (bcs) { - b = (struct conversation *)bcs->data; - if (!strcmp(normalize(b->name), tmp)) - break; - bcs = bcs->next; - b = NULL; - } - serv_chat_send(b->gc, b->id, what); - c = c->next; + gc = (struct gaim_connection *)SvIV(ST(0)); + id = SvIV(ST(1)); + what = SvPV(ST(2), junk); + + if (!g_slist_find(connections, gc)) { + XSRETURN(0); + return; } + bcs = gc->buddy_chats; + while (bcs) { + b = (struct conversation *)bcs->data; + if (b->id == id) + break; + bcs = bcs->next; + b = NULL; + } + if (b) + serv_chat_send(gc, id, what); XSRETURN(0); } Index: plugins.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/plugins.c,v retrieving revision 1.77 retrieving revision 1.78 diff -u -d -r1.77 -r1.78 --- plugins.c 2001/09/13 22:57:53 1.77 +++ plugins.c 2001/09/22 09:14:27 1.78 @@ -645,7 +645,7 @@ #endif /* GAIM_PLUGINS */ -char *event_name(enum gaim_event event) +static char *event_name(enum gaim_event event) { static char buf[128]; switch (event) { @@ -733,6 +733,9 @@ case event_im_displayed_rcvd: sprintf(buf, "event_im_displayed_rcvd"); break; + case event_chat_send_invite: + sprintf(buf, "event_chat_send_invite"); + break; default: sprintf(buf, "event_unknown"); break; @@ -744,134 +747,74 @@ { #ifdef USE_PERL char buf[BUF_LONG]; - char *tmp; #endif #ifdef GAIM_PLUGINS GList *c = callbacks; struct gaim_callback *g; while (c) { + void (*zero)(void *); + void (*one)(void *, void *); + void (*two)(void *, void *, void *); + void (*three)(void *, void *, void *, void *); + void (*four)(void *, void *, void *, void *, void *); + g = (struct gaim_callback *)c->data; if (g->event == event && g->function !=NULL) { switch (event) { - /* 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_blist_update: case event_quit: - { - void (*function)(void *) = g->function; - (*function)(g->data); - } - break; - - /* struct gaim_connection *, char **, char **, guint32 */ - case event_im_recv: - { - void (*function)(struct gaim_connection *, char **, char **, - guint32, void *) = g->function; - (*function)(arg1, arg2, arg3, (guint32)arg4, g->data); - } + zero = g->function; + (*zero)(g->data); break; - /* struct gaim_connection *, char *, char ** */ - case event_im_send: - case event_im_displayed_sent: - case event_chat_send: - { - void (*function)(struct gaim_connection *, char *, char **, - void *) = g->function; - (*function)(arg1, arg2, arg3, g->data); - } + /* one arg */ + case event_signon: + case event_signoff: + case event_new_conversation: + case event_error: + one = g->function; + (*one)(arg1, g->data); break; - /* struct gaim_connection *, char * */ - case event_chat_join: - case event_chat_leave: + /* two args */ case event_buddy_signon: case event_buddy_signoff: case event_buddy_away: case event_buddy_back: case event_buddy_idle: case event_buddy_unidle: + case event_chat_leave: case event_set_info: - { - void (*function)(struct gaim_connection *, char *, void *) = - g->function; - (*function)(arg1, arg2, g->data); - } - break; - - /* char * */ - case event_new_conversation: - { - void (*function)(char *, void *) = g->function; - (*function)(arg1, g->data); - } - break; - - /* struct gaim_connection *, char *, char *, char * */ - case event_chat_invited: - case event_chat_recv: - { - void (*function)(struct gaim_connection *, char *, char *, - char *, void *) = g->function; - (*function)(arg1, arg2, arg3, arg4, g->data); - } + case event_draw_menu: + two = g->function; + (*two)(arg1, arg2, g->data); break; - /* struct gaim_connection *, char *, char * */ + /* three args */ + case event_im_send: + case event_im_displayed_sent: + case event_chat_join: case event_chat_buddy_join: case event_chat_buddy_leave: + case event_chat_send: case event_away: case event_back: - { - void (*function)(struct gaim_connection *, char *, char *, - void *) = g->function; - (*function)(arg1, arg2, arg3, g->data); - } - break; - - /* struct gaim_connection *, char *, char *, guint32 */ - case event_im_displayed_rcvd: - { - void (*function)(struct gaim_connection *, char *, char *, - guint32, void *) = g->function; - (*function)(arg1, arg2, arg3, (guint32)arg4, g->data); - } - break; - - /* struct gaim_connection *, char *, int */ case event_warned: - { - void (*function)(struct gaim_connection *, char *, int, - void *) = g->function; - (*function)(arg1, arg2, (int)arg3, g->data); - } + three = g->function; + (*three)(arg1, arg2, arg3, g->data); break; - /* int */ - case event_error: - { - void (*function)(int, void *) = g->function; - (*function)((int)arg1, g->data); - } - break; - /* GtkWidget *, char * */ - case event_draw_menu: - { - void(*function)(GtkWidget *, char *) = g->function; - (*function)(arg1, arg2); - } + /* four args */ + case event_im_recv: + case event_chat_recv: + case event_im_displayed_rcvd: + case event_chat_send_invite: + case event_chat_invited: + four = g->function; + (*four)(arg1, arg2, arg3, arg4, g->data); break; default: @@ -885,83 +828,52 @@ #ifdef USE_PERL switch (event) { case event_signon: - g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); - break; case event_signoff: - g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); - break; case event_away: - g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); - break; case event_back: - g_snprintf(buf, sizeof buf, "\"%s\"", ((struct gaim_connection *)arg1)->username); + g_snprintf(buf, sizeof buf, "%p", arg1); break; case event_im_recv: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", - ((struct gaim_connection *)arg1)->username, + g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, *(char **)arg2 ? *(char **)arg2 : "(null)", *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_im_send: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", - ((struct gaim_connection *)arg1)->username, (char *)arg2, - *(char **)arg3 ? *(char **)arg3 : "(null)"); + g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, + (char *)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_buddy_signon: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_buddy_signoff: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_set_info: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_buddy_away: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_buddy_back: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_buddy_idle: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_buddy_unidle: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; - case event_blist_update: - buf[0] = 0; + g_snprintf(buf, sizeof buf, "%p \"%s\"", arg1, (char *)arg2); break; case event_chat_invited: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg2, (char *)arg3, - arg4 ? (char *)arg4 : ""); + g_snprintf(buf, sizeof buf, "%p \"%s\" \"%s\" %s", arg1, + (char *)arg2, (char *)arg3, arg4 ? (char *)arg4 : ""); break; case event_chat_join: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; - case event_chat_leave: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_chat_buddy_join: - 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 *)arg2, (char *)arg3); + g_snprintf(buf, sizeof buf, "%p %d \"%s\"", arg1, (int)arg2, (char *)arg3); + break; + case event_chat_leave: + g_snprintf(buf, sizeof buf, "%p %d", arg1, (int)arg2); break; case event_chat_recv: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", (char *)arg2, (char *)arg3, - (char *)arg4); + case event_chat_send_invite: + g_snprintf(buf, sizeof buf, "%p %d \"%s\" %s", arg1, + (int)arg2, (char *)arg3, (char *)arg4); break; case event_chat_send: - g_snprintf(buf, sizeof buf, "\"%s\" %s", (char *)arg2, + g_snprintf(buf, sizeof buf, "%p %d %s", arg1, (int)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_warned: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %d", - ((struct gaim_connection *)arg1)->username, - arg2 ? (char *)arg2 : "", (int)arg3); - break; - case event_error: - g_snprintf(buf, sizeof buf, "%d", (int)arg1); + g_snprintf(buf, sizeof buf, "%p \"%s\" %d", arg1, arg2 ? (char *)arg2 : "", (int)arg3); break; case event_quit: buf[0] = 0; @@ -969,25 +881,18 @@ case event_new_conversation: g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg1); break; - case event_draw_menu: - g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); - break; case event_im_displayed_sent: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", - ((struct gaim_connection *)arg1)->username, (char *)arg2, - *(char **)arg3 ? *(char **)arg3 : "(null)"); + g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, + (char *)arg2, *(char **)arg3 ? *(char **)arg3 : "(null)"); break; case event_im_displayed_rcvd: - g_snprintf(buf, sizeof buf, "\"%s\" \"%s\" %s", - ((struct gaim_connection *)arg1)->username, (char *)arg2, - (char *)arg3 ? (char *)arg3 : "(null)"); + g_snprintf(buf, sizeof buf, "%p \"%s\" %s", arg1, + (char *)arg2, (char *)arg3 ? (char *)arg3 : "(null)"); break; default: - break; + return 0; } - tmp = event_name(event); - debug_printf("%s: %s\n", tmp, buf); - return perl_event(tmp, buf); + return perl_event(event_name(event), buf); #else return 0; #endif Index: server.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/server.c,v retrieving revision 1.190 retrieving revision 1.191 diff -u -d -r1.190 -r1.191 --- server.c 2001/09/21 00:14:12 1.190 +++ server.c 2001/09/22 09:14:27 1.191 @@ -302,6 +302,7 @@ void serv_chat_invite(struct gaim_connection *g, int id, char *message, char *name) { + plugin_event(event_chat_send_invite, g, (void *)id, name, message); if (g->prpl && g->prpl->chat_invite) (*g->prpl->chat_invite)(g, id, message, name); } @@ -836,7 +837,7 @@ { struct conversation *b; - plugin_event(event_chat_join, gc, name, 0, 0); + plugin_event(event_chat_join, gc, (void *)id, name, 0); b = (struct conversation *)g_new0(struct conversation, 1); gc->buddy_chats = g_slist_append(gc->buddy_chats, b); @@ -894,7 +895,7 @@ if (!b) return; - plugin_event(event_chat_leave, g, b->name, 0, 0); + plugin_event(event_chat_leave, g, (void *)b->id, 0, 0); debug_printf("Leaving room %s.\n", b->name); @@ -921,7 +922,7 @@ if (!b) return; - if (plugin_event(event_chat_recv, g, b->name, who, message)) + if (plugin_event(event_chat_recv, g, (void *)b->id, who, message)) return; buf = g_malloc(MAX(strlen(message) * 2, 8192)); |