Mercurial > pidgin
changeset 2104:0b81421021fd
[gaim-migrate @ 2114]
heh. i confused myself.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 01 Aug 2001 22:06:17 +0000 |
parents | d403300222d2 |
children | ff225036d434 |
files | ChangeLog plugins/SIGNALS src/conversation.c src/gaim.h src/plugins.c src/server.c |
diffstat | 6 files changed, 66 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Aug 01 21:24:42 2001 +0000 +++ b/ChangeLog Wed Aug 01 22:06:17 2001 +0000 @@ -9,8 +9,10 @@ * Added Russian Translation * Can select which protocols are compiled statically (e.g.: ./configure --with-static-prpls=oscar,jabber) - * New plugin event: event_im_displayed. Use this to change - the message after it's displayed (e.g. encrypt it) + * New plugin events: event_im_displayed_sent and + event_im_displayed_rcvd. Use these to change messages after + they're displayed (e.g. encrypt sent messages, or send + auto-responses and have them display locally properly) version 0.11.0-pre14 (06/17/2001): * Fixed a segfault with Oscar's account confirmation
--- a/plugins/SIGNALS Wed Aug 01 21:24:42 2001 +0000 +++ b/plugins/SIGNALS Wed Aug 01 22:06:17 2001 +0000 @@ -25,7 +25,8 @@ event_new_conversation, event_set_info, event_draw_menu, - event_im_displayed + event_im_displayed_sent, + event_im_displayed_rcvd }; To add a signal handler, call the fuction gaim_signal_connect with the @@ -268,7 +269,7 @@ 'menu' is the menu that is about to be displayed. 'name' is the name of the buddy that was clicked. -event_im_displayed: +event_im_displayed_sent: struct gaim_connection *gc, char *who, char **what This is called after what you send is displayed but before it's @@ -276,12 +277,23 @@ in an IM window, first it gets passed to event_im_send handlers, then it gets displayed, then it gets passed to these handlers, and then it gets sent over the wire. This is useful for when you want - to encrypt something on the way out, or when you want to send a - response and have it displayed after what triggered the response. + to encrypt something on the way out. - 'gc' is the connection the message was received on. - 'who' is who sent the message. + 'gc' is the connection the message is sent on. + 'who' is who the message is for. 'what' is what was sent. It's expected that you modify this. If you set *what to NULL the message won't be sent, but the preferred way of doing this is to attach to event_im_send so that it really won't be displayed at all. + +event_im_displayed_rcvd: + struct gaim_connection *gc, char *who, char *what + + This is called after what you receive is displayed. This is useful + for displaying an autoresponse after the message that triggered it. + There are a bunch of things that are odd about this, especially + when dealing with being away, so be careful. + + 'gc' is the connection the message was received on. + 'who' is who sent the message. + 'what' is what was sent.
--- a/src/conversation.c Wed Aug 01 21:24:42 2001 +0000 +++ b/src/conversation.c Wed Aug 01 22:06:17 2001 +0000 @@ -856,7 +856,7 @@ write_to_conv(c, buf, WFLAG_SEND, NULL, time((time_t)NULL)); buffy = g_strdup(buf); - plugin_event(event_im_displayed, c->gc, c->name, &buffy, 0); + plugin_event(event_im_displayed_sent, c->gc, c->name, &buffy, 0); if (buffy) { serv_send_im(c->gc, c->name, buffy, 0); g_free(buffy);
--- a/src/gaim.h Wed Aug 01 21:24:42 2001 +0000 +++ b/src/gaim.h Wed Aug 01 22:06:17 2001 +0000 @@ -201,7 +201,8 @@ event_new_conversation, event_set_info, event_draw_menu, - event_im_displayed, + event_im_displayed_sent, + event_im_displayed_rcvd, /* any others? it's easy to add... */ };
--- a/src/plugins.c Wed Aug 01 21:24:42 2001 +0000 +++ b/src/plugins.c Wed Aug 01 22:06:17 2001 +0000 @@ -725,8 +725,11 @@ case event_draw_menu: sprintf(buf, "event_draw_menu"); break; - case event_im_displayed: - sprintf(buf, "event_im_displayed"); + case event_im_displayed_sent: + sprintf(buf, "event_im_displayed_sent"); + break; + case event_im_displayed_rcvd: + sprintf(buf, "event_im_displayed_rcvd"); break; default: sprintf(buf, "event_unknown"); @@ -780,7 +783,7 @@ /* struct gaim_connection *, char *, char ** */ case event_im_send: - case event_im_displayed: + case event_im_displayed_sent: case event_chat_send: { void (*function)(struct gaim_connection *, char *, char **, @@ -829,6 +832,7 @@ case event_chat_buddy_leave: case event_away: case event_back: + case event_im_displayed_rcvd: { void (*function)(struct gaim_connection *, char *, char *, void *) = g->function; @@ -957,7 +961,12 @@ case event_draw_menu: g_snprintf(buf, sizeof buf, "\"%s\"", (char *)arg2); break; - case event_im_displayed: + 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)"); + 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)");
--- a/src/server.c Wed Aug 01 21:24:42 2001 +0000 +++ b/src/server.c Wed Aug 01 22:06:17 2001 +0000 @@ -396,14 +396,6 @@ struct conversation *cnv; int new_conv = 0; - /* we should update the conversation window buttons and menu, if it exists. */ - cnv = find_conversation(name); - if (cnv) - set_convo_gc(cnv, gc); - /* we do the new_conv check here in case any plugins decide to create it */ - else - new_conv = 1; - /* plugin stuff. we pass a char ** but we don't want to pass what's been given us * by the prpls. so we create temp holders and pass those instead. it's basically * just to avoid segfaults. */ @@ -418,10 +410,16 @@ g_free(angel); return; } - g_snprintf(message, strlen(message) + 1, "%s", buffy); - g_free(buffy); - g_snprintf(name, strlen(name) + 1, "%s", angel); - g_free(angel); + name = angel; + message = buffy; + + /* we should update the conversation window buttons and menu, if it exists. */ + cnv = find_conversation(name); + if (cnv) + set_convo_gc(cnv, gc); + /* we do the new_conv check here in case any plugins decide to create it */ + else + new_conv = 1; /* TiK, using TOC, sends an automated message in order to get your away message. Now, * this is one of the biggest hacks I think I've seen. But, in order to be nice to @@ -431,6 +429,8 @@ char *tmpmsg = stylize(awaymessage->message, MSG_LEN); serv_send_im(gc, name, tmpmsg, 1); g_free(tmpmsg); + g_free(name); + g_free(message); return; } @@ -497,8 +497,11 @@ /* ok, so we're not queuing it. well then, we'll try to handle it normally. * Some people think that ignoring it is a perfectly acceptible way to handle * it. i think they're on crack, but hey, that's why it's optional. */ - if (general_options & OPT_GEN_DISCARD_WHEN_AWAY) + if (general_options & OPT_GEN_DISCARD_WHEN_AWAY) { + g_free(name); + g_free(message); return; + } /* ok, so we're not ignoring it. make sure the conversation exists and is * updated (partly handled above already), play the receive sound (sound.c @@ -518,8 +521,11 @@ /* regardless of whether we queue it or not, we should send an auto-response. That is, * of course, unless the horse.... no wait. */ - if ((general_options & OPT_GEN_NO_AUTO_RESP) || !strlen(gc->away)) + if ((general_options & OPT_GEN_NO_AUTO_RESP) || !strlen(gc->away)) { + g_free(name); + g_free(message); return; + } /* this used to be based on the conversation window. but um, if you went away, and * someone sent you a message and got your auto-response, and then you closed the @@ -533,8 +539,11 @@ qar->sent_away = 0; away_time_queue = g_slist_append(away_time_queue, qar); } - if ((t - qar->sent_away) < 120) + if ((t - qar->sent_away) < 120) { + g_free(name); + g_free(message); return; + } qar->sent_away = t; /* apply default fonts and colors */ @@ -567,6 +576,10 @@ write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); } + + plugin_event(event_im_displayed_rcvd, gc, name, message, 0); + g_free(name); + g_free(message); }