Mercurial > pidgin
changeset 8999:8f838ae3e710
[gaim-migrate @ 9774]
" This patch renames the existing received-*-msg signals
to receiving-*msg to fit the naming of other signals
where a pointer to the message is passed (writing,
sending, displaying)
It adds new received-*-msg signals which are emitted
after the receiving signals, in line with the other
conversation signals (wrote, sent, displayed)
This is necessary to allow plugins which depend on the
final received message to work alongside plugins which
may modify the message.
One known example of this is festival-gaim alongside
gaim-encryption - festival-gaim would try to "speak"
the encrypted text:
http://sf.net/tracker/?func=detail&aid=943216&group_id=89763&atid=591320
I've tested this with gaim-encryption and festival-gaim
(locally modified so gaim-encryption uses the receiving
signal and festival uses the received signal)
All in-tree users of received-*-msg are updated to use
receiving-*-msg if they do modify the message, the
conversation-signals documentation is updated, the
signals-test.c & signal-test.tcl plugins are also updated." --Stu Tomlinson
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 21 May 2004 14:33:32 +0000 |
parents | 3738d1eac0ad |
children | b540c735a6ad |
files | ChangeLog doc/conversation-signals.dox plugins/docklet/docklet.c plugins/gaiminc.c plugins/notify.c plugins/signals-test.c plugins/tcl/TCL-HOWTO plugins/tcl/signal-test.tcl src/conversation.c src/server.c |
diffstat | 10 files changed, 126 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri May 21 14:26:31 2004 +0000 +++ b/ChangeLog Fri May 21 14:33:32 2004 +0000 @@ -42,6 +42,7 @@ Direct IM and inherits all its bugs. * Direct IM for AIM should be slightly less buggy, and may actually work now, if at least one side isn't behind a NAT or firewall. + * Made the recieve-*-msg signals match the sending ones (Stu Tomlinson) Preference Changes(Stu Tomlinson): * Added a "none" smiley theme to replace the "Show graphical
--- a/doc/conversation-signals.dox Fri May 21 14:26:31 2004 +0000 +++ b/doc/conversation-signals.dox Fri May 21 14:33:32 2004 +0000 @@ -7,6 +7,7 @@ @signal displayed-im-msg @signal sending-im-msg @signal sent-im-msg + @signal receiving-im-msg @signal received-im-msg @signal writing-chat-msg @signal wrote-chat-msg @@ -14,6 +15,7 @@ @signal displayed-chat-msg @signal sending-chat-msg @signal sent-chat-msg + @signal receiving-chat-msg @signal received-chat-msg @signal conversation-switching @signal conversation-switched @@ -118,9 +120,9 @@ @param message The message that was sent. @endsignaldef - @signaldef received-im-msg + @signaldef receiving-im-msg @signalproto -gboolean (*received_im_msg)(GaimAccount *account, char **sender, +gboolean (*receiving_im_msg)(GaimAccount *account, char **sender, char **message, int *flags); @endsignalproto @signaldesc @@ -137,6 +139,19 @@ @param flags The message flags. @endsignaldef + @signaldef received-im-msg + @signalproto +void (*received_im_msg)(GaimAccount *account, char *sender, + char *message, int flags); + @endsignalproto + @signaldesc + Emitted after an IM is received. + @param account The account the message was received on. + @param sender The username of the sender. + @param message The message that was sent. + @param flags The message flags. + @endsignaldef + @signaldef writing-chat-msg @signalproto gboolean (*writing_chat_msg)(GaimAccount *account, GaimConversation *conv, char **message); @@ -222,9 +237,9 @@ @param id The ID of the chat. @endsignaldef - @signaldef received-chat-msg + @signaldef receiving-chat-msg @signalproto -gboolean (*received_chat_msg)(GaimAccount *account, char **sender, +gboolean (*receiving_chat_msg)(GaimAccount *account, char **sender, char **message, GaimConversation *conv); @endsignalproto @signaldesc @@ -241,6 +256,19 @@ @param conv The chat conversation. @endsignaldef + @signaldef received-chat-msg + @signalproto +void (*received_chat_msg)(GaimAccount *account, char *sender, + char *message, GaimConversation *conv); + @endsignalproto + @signaldesc + Emitted after a chat message is received. + @param account The account the message was received on. + @param sender The username of the sender. + @param message The message that was sent. + @param conv The chat conversation. + @endsignaldef + @signaldef conversation-switching @signalproto void (*conversation_switching)(GaimConversation *old_conv,
--- a/plugins/docklet/docklet.c Fri May 21 14:26:31 2004 +0000 +++ b/plugins/docklet/docklet.c Fri May 21 14:33:32 2004 +0000 @@ -376,8 +376,8 @@ } static gboolean -gaim_conv_im_recv(GaimAccount *account, char **sender, - char **message, int *flags, void *data) +gaim_conv_im_recv(GaimAccount *account, char *sender, + char *message, int flags, void *data) { /* if message queuing while away is enabled, this event could be the first message so we need to see if the status (and hence icon) needs changing.
--- a/plugins/gaiminc.c Fri May 21 14:26:31 2004 +0000 +++ b/plugins/gaiminc.c Fri May 21 14:33:32 2004 +0000 @@ -64,7 +64,7 @@ plugin, GAIM_CALLBACK(echo_hi), NULL); /* this is for doing something fun when we get a message */ - gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", + gaim_signal_connect(gaim_conversations_get_handle(), "receiving-im-msg", plugin, GAIM_CALLBACK(reverse), NULL); /* this is for doing something fun when a buddy comes online */
--- a/plugins/notify.c Fri May 21 14:26:31 2004 +0000 +++ b/plugins/notify.c Fri May 21 14:33:32 2004 +0000 @@ -231,7 +231,7 @@ } static gboolean -chat_recv_im(GaimAccount *account, char **who, char **text, int id, void *m) +chat_recv_im(GaimAccount *account, char *who, char *text, int id, void *m) { GaimConversation *conv = gaim_find_chat(gaim_account_get_connection(account), id); @@ -253,9 +253,9 @@ } static gboolean -im_recv_im(GaimAccount *account, char **who, char **what, int *flags, void *m) +im_recv_im(GaimAccount *account, char *who, char *what, int flags, void *m) { - GaimConversation *conv = gaim_find_conversation_with_account(*who, account); + GaimConversation *conv = gaim_find_conversation_with_account(who, account); notify(conv, TRUE);
--- a/plugins/signals-test.c Fri May 21 14:26:31 2004 +0000 +++ b/plugins/signals-test.c Fri May 21 14:33:32 2004 +0000 @@ -108,6 +108,19 @@ gaim_debug_misc("signals test", "buddy-signed-off (%s)\n", buddy->name); } +static void +buddy_extended_menu_cb(GaimBuddy *buddy, void *data) +{ + gaim_debug_misc("signals test", "buddy-extended-menu (%s)\n", buddy->name); +} + +static void +group_extended_menu_cb(GaimGroup *group, void *data) +{ + gaim_debug_misc("signals test", "group-extended-menu (%s)\n", group->name); +} + + /************************************************************************** * Connection subsystem signal callbacks **************************************************************************/ @@ -175,16 +188,25 @@ } static gboolean -received_im_msg_cb(GaimAccount *account, char **sender, char **buffer, +receiving_im_msg_cb(GaimAccount *account, char **sender, char **buffer, int *flags, void *data) { - gaim_debug_misc("signals test", "received-im-msg (%s, %s, %s, %d)\n", + gaim_debug_misc("signals test", "receiving-im-msg (%s, %s, %s, %d)\n", gaim_account_get_username(account), *sender, *buffer, *flags); return FALSE; } +static void +received_im_msg_cb(GaimAccount *account, char *sender, char *buffer, + int flags, void *data) +{ + gaim_debug_misc("signals test", "received-im-msg (%s, %s, %s, %d)\n", + gaim_account_get_username(account), sender, buffer, + flags); +} + static gboolean displaying_chat_msg_cb(GaimAccount *account, GaimConversation *conv, char **buffer, void *data) @@ -219,11 +241,11 @@ } static gboolean -received_chat_msg_cb(GaimAccount *account, char **sender, char **buffer, +receiving_chat_msg_cb(GaimAccount *account, char **sender, char **buffer, GaimConversation *chat, void *data) { gaim_debug_misc("signals test", - "received-chat-msg (%s, %s, %s, %s, %s)\n", + "receiving-chat-msg (%s, %s, %s, %s)\n", gaim_account_get_username(account), *sender, *buffer, gaim_conversation_get_name(chat)); @@ -231,6 +253,16 @@ } static void +received_chat_msg_cb(GaimAccount *account, char *sender, char *buffer, + GaimConversation *chat, void *data) +{ + gaim_debug_misc("signals test", + "received-chat-msg (%s, %s, %s, %s)\n", + gaim_account_get_username(account), sender, buffer, + gaim_conversation_get_name(chat)); +} + +static void conversation_switching_cb(GaimConversation *old_conv, GaimConversation *new_conv, void *data) { @@ -384,6 +416,10 @@ plugin, GAIM_CALLBACK(buddy_signed_on_cb), NULL); gaim_signal_connect(blist_handle, "buddy-signed-off", plugin, GAIM_CALLBACK(buddy_signed_off_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-extended-menu", + plugin, GAIM_CALLBACK(buddy_extended_menu_cb), NULL); + gaim_signal_connect(blist_handle, "group-extended-menu", + plugin, GAIM_CALLBACK(group_extended_menu_cb), NULL); /* Connection subsystem signals */ gaim_signal_connect(conn_handle, "signing-on", @@ -404,6 +440,8 @@ plugin, GAIM_CALLBACK(sending_im_msg_cb), NULL); gaim_signal_connect(conv_handle, "sent-im-msg", plugin, GAIM_CALLBACK(sent_im_msg_cb), NULL); + gaim_signal_connect(conv_handle, "receiving-im-msg", + plugin, GAIM_CALLBACK(receiving_im_msg_cb), NULL); gaim_signal_connect(conv_handle, "received-im-msg", plugin, GAIM_CALLBACK(received_im_msg_cb), NULL); gaim_signal_connect(conv_handle, "displaying-chat-msg", @@ -414,6 +452,8 @@ plugin, GAIM_CALLBACK(sending_chat_msg_cb), NULL); gaim_signal_connect(conv_handle, "sent-chat-msg", plugin, GAIM_CALLBACK(sent_chat_msg_cb), NULL); + gaim_signal_connect(conv_handle, "receiving-chat-msg", + plugin, GAIM_CALLBACK(receiving_chat_msg_cb), NULL); gaim_signal_connect(conv_handle, "received-chat-msg", plugin, GAIM_CALLBACK(received_chat_msg_cb), NULL); gaim_signal_connect(conv_handle, "conversation-switching",
--- a/plugins/tcl/TCL-HOWTO Fri May 21 14:26:31 2004 +0000 +++ b/plugins/tcl/TCL-HOWTO Fri May 21 14:33:32 2004 +0000 @@ -296,7 +296,7 @@ intended to be a list only of their arguments. Signal callbacks will be made in their own namespace, and arguments to those signal callbacks will live in the namespace 'event' underneath that -namespace. To briefly illustrate, the signal received-im-msg is +namespace. To briefly illustrate, the signal receiving-im-msg is provided with three arguments; the account on which the IM was received, the screen name of the user sending the IM, and the text of the IM. These arguments live in the variables event::account, @@ -304,14 +304,14 @@ which notifies the user of an incoming IM containing the word 'shizzle' might look like this: -gaim::signal connect [gaim::conversation handle] received-im-msg { +gaim::signal connect [gaim::conversation handle] receiving-im-msg { if {[ string match "*shizzle*" $event::buffer ]} { gaim::notify -info "tcl plugin" "Fo' shizzle" \ "$event::sender is down with the shizzle" } } -Note that for some signals (notably received-im-msg, sending-im-msg, +Note that for some signals (notably receiving-im-msg, sending-im-msg, and their chat counterparts), changes to the event arguments will change the message itself from Gaim's vantage. For those signals whose return value is meaningful, returning a value from the Tcl event
--- a/plugins/tcl/signal-test.tcl Fri May 21 14:26:31 2004 +0000 +++ b/plugins/tcl/signal-test.tcl Fri May 21 14:33:32 2004 +0000 @@ -46,14 +46,22 @@ gaim::debug -info "tcl signal" "quitting" } +gaim::signal connect [gaim::conversation handle] receiving-chat-msg { account who what id } { + gaim::debug -info "tcl signal" "receiving-chat-msg [gaim::account username $account] $id $who \"$what\"" + return 0 +} + +gaim::signal connect [gaim::conversation handle] receiving-im-msg { account who what flags } { + gaim::debug -info "tcl signal" "receiving-im-msg [gaim::account username $account] $flags $who \"$what\"" + return 0 +} + gaim::signal connect [gaim::conversation handle] received-chat-msg { account who what id } { gaim::debug -info "tcl signal" "received-chat-msg [gaim::account username $account] $id $who \"$what\"" - return 0 } gaim::signal connect [gaim::conversation handle] received-im-msg { account who what flags } { gaim::debug -info "tcl signal" "received-im-msg [gaim::account username $account] $flags $who \"$what\"" - return 0 } gaim::signal connect [gaim::conversation handle] sending-chat-msg { account what id } {
--- a/src/conversation.c Fri May 21 14:26:31 2004 +0000 +++ b/src/conversation.c Fri May 21 14:33:32 2004 +0000 @@ -2706,7 +2706,7 @@ gaim_value_new(GAIM_TYPE_STRING), gaim_value_new(GAIM_TYPE_STRING)); - gaim_signal_register(handle, "received-im-msg", + gaim_signal_register(handle, "receiving-im-msg", gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER, gaim_value_new(GAIM_TYPE_BOOLEAN), 4, gaim_value_new(GAIM_TYPE_SUBTYPE, @@ -2715,6 +2715,15 @@ gaim_value_new_outgoing(GAIM_TYPE_STRING), gaim_value_new_outgoing(GAIM_TYPE_UINT)); + gaim_signal_register(handle, "received-im-msg", + gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT, + NULL, 4, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_ACCOUNT), + gaim_value_new(GAIM_TYPE_STRING), + gaim_value_new(GAIM_TYPE_STRING), + gaim_value_new(GAIM_TYPE_UINT)); + gaim_signal_register(handle, "writing-chat-msg", gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER, gaim_value_new(GAIM_TYPE_BOOLEAN), 3, @@ -2765,7 +2774,7 @@ gaim_value_new(GAIM_TYPE_STRING), gaim_value_new(GAIM_TYPE_UINT)); - gaim_signal_register(handle, "received-chat-msg", + gaim_signal_register(handle, "receiving-chat-msg", gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER, gaim_value_new(GAIM_TYPE_BOOLEAN), 4, gaim_value_new(GAIM_TYPE_SUBTYPE, @@ -2775,6 +2784,16 @@ gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONVERSATION)); + gaim_signal_register(handle, "received-chat-msg", + gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER, + NULL, 4, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_ACCOUNT), + gaim_value_new(GAIM_TYPE_STRING), + gaim_value_new(GAIM_TYPE_STRING), + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_CONVERSATION)); + gaim_signal_register(handle, "conversation-switching", gaim_marshal_VOID__POINTER_POINTER, NULL, 2, gaim_value_new(GAIM_TYPE_SUBTYPE,
--- a/src/server.c Fri May 21 14:26:31 2004 +0000 +++ b/src/server.c Fri May 21 14:33:32 2004 +0000 @@ -827,7 +827,7 @@ plugin_return = GPOINTER_TO_INT( gaim_signal_emit_return_1(gaim_conversations_get_handle(), - "received-im-msg", gc->account, + "receiving-im-msg", gc->account, &angel, &buffy, &imflags)); if (!buffy || !angel || plugin_return) { @@ -837,10 +837,13 @@ g_free(angel); return; } - name = angel; + name = angel; message = buffy; + gaim_signal_emit(gaim_conversations_get_handle(), "received-im-msg", gc->account, + name, message, imflags); + /* Make sure URLs are clickable */ buffy = gaim_markup_linkify(message); g_free(message); @@ -1485,7 +1488,7 @@ plugin_return = GPOINTER_TO_INT( gaim_signal_emit_return_1(gaim_conversations_get_handle(), - "received-chat-msg", g->account, + "receiving-chat-msg", g->account, &angel, &buffy, conv)); if (!buffy || !angel || plugin_return) { @@ -1498,6 +1501,9 @@ who = angel; message = buffy; + gaim_signal_emit(gaim_conversations_get_handle(), "received-chat-msg", g->account, + who, message, conv); + /* Make sure URLs are clickable */ buf = gaim_markup_linkify(message);