Mercurial > pidgin.yaz
changeset 9584:fe35f55ee984
[gaim-migrate @ 10427]
" When joining a jabber conference many jabber servers
send a recap of the last 20 or so messages. If you
have sounds enabled, this will result in either 20
sounds in row, or worse if mixing is available, a
horrible mix of 20 overlapping sounds. These recap
messages can be identifed be the presence of the
"jabber:x:delay". This patch identifies delayed
messages, passes that information through flags from
the prpl to the core, and then on to the gui. Detailed
changes:
Add GAIM_MESSAGE_DELAYED to GaimMessageFlags to
indicate a delayed message.
Change gtkconv.c to not play sounds when either
GAIM_MESSAGE_DELAYED or GAIM_MESSAGE_SYSTEM are set.
Add GaimConvChatFlags, parallel to GaimConvImFlags, to
pass flags from protocols to core. Currently contains
two flags:
GAIM_CONV_CHAT_WHISPER
GAIM_CONV_CHAT_DELAYED
Change fourth arg of serv_got_chat_in() from "int
whisper" to "GaimConvChatFlags chatflags".
Change jabber prpl to set delayed flag when the
"jabber:x:delay" element is present. Change toc
protocol since it uses the whisper flag." --Nathan Fredrickson
Date: 2004-07-24 00:49
Sender: marv_sfAccepting Donations
Logged In: YES
user_id=790708
I'm not sure I like naming the flags "DELAYED". I mean
that's okay inside jabber since that's what the jabber
protocol refers to it as, but for the the GAIM_*_DELAYED
flags, I think they should be named something else.
I thought about NOSOUND, but I decided that was wrong,
because the flag should say what kind of message it is, not
what to do with it, that's up to the UI to decide.
What's up with not playing sounds on GAIM_MESSAGE_SYSTEM?
This sounds unrelated to this. Are there times when we want
to play sounds on system messages?
Date: 2004-07-24 09:13
Sender: noif
Logged In: YES
user_id=365548
I purposely did not use a name that implied what the UI
should do with the flag. The only characteristic that makes
these messages unique is that they've been stored in the
server for some period of time and are not current. I'm
open to a better flag name than "DELAYED"... I thought about
"RECAP", but that seemed less generalized than "DELAYED".
As for not playing sounds on GAIM_MESSAGE_SYSTEM, that can
be removed if it's controversial. I think I slipped that
in since the setting of the topic was still playing a sound
every time you joined a jabber conference.
I think we can change the flag name ourselves if something else is better.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 24 Jul 2004 15:18:32 +0000 |
parents | 91c9e060111b |
children | a089ae71d36c |
files | src/conversation.h src/gtkconv.c src/protocols/jabber/message.c src/protocols/jabber/message.h src/protocols/toc/toc.c src/protocols/zephyr/zephyr.c src/prpl.h src/server.c src/server.h |
diffstat | 9 files changed, 32 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/conversation.h Sat Jul 24 15:14:43 2004 +0000 +++ b/src/conversation.h Sat Jul 24 15:18:32 2004 +0000 @@ -116,7 +116,8 @@ GAIM_MESSAGE_NICK = 0x0020, /**< Contains your nick. */ GAIM_MESSAGE_NO_LOG = 0x0040, /**< Do not log. */ GAIM_MESSAGE_WHISPER = 0x0080, /**< Whispered message. */ - GAIM_MESSAGE_ERROR = 0x0200 /**< Error message. */ + GAIM_MESSAGE_ERROR = 0x0200, /**< Error message. */ + GAIM_MESSAGE_DELAYED = 0x0400 /**< Delayed message. */ } GaimMessageFlags; /**
--- a/src/gtkconv.c Sat Jul 24 15:14:43 2004 +0000 +++ b/src/gtkconv.c Sat Jul 24 15:18:32 2004 +0000 @@ -4955,10 +4955,12 @@ !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { if (!(flags & GAIM_MESSAGE_WHISPER) && (flags & GAIM_MESSAGE_SEND)) gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); - else if (flags & GAIM_MESSAGE_RECV) { + else if ((flags & GAIM_MESSAGE_RECV) && + !(flags & GAIM_MESSAGE_DELAYED) && + !(flags & GAIM_MESSAGE_SYSTEM)) { + if ((flags & GAIM_MESSAGE_NICK) && - gaim_prefs_get_bool("/gaim/gtk/sound/enabled/nick_said") && - !(flags & GAIM_MESSAGE_SYSTEM)) { + gaim_prefs_get_bool("/gaim/gtk/sound/enabled/nick_said")) { gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); }
--- a/src/protocols/jabber/message.c Sat Jul 24 15:14:43 2004 +0000 +++ b/src/protocols/jabber/message.c Sat Jul 24 15:18:32 2004 +0000 @@ -180,7 +180,8 @@ if(jm->xhtml || jm->body) { if(jid->resource) - serv_got_chat_in(jm->js->gc, chat->id, jid->resource, 0, + serv_got_chat_in(jm->js->gc, chat->id, jid->resource, + jm->delayed ? GAIM_CONV_CHAT_DELAYED : 0, jm->xhtml ? jm->xhtml : jm->body, jm->sent); else if(chat->muc) gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", @@ -243,6 +244,7 @@ jm = g_new0(JabberMessage, 1); jm->js = js; jm->sent = time(NULL); + jm->delayed = FALSE; type = xmlnode_get_attrib(packet, "type"); @@ -303,6 +305,7 @@ jm->events |= JABBER_MESSAGE_EVENT_COMPOSING; } else if(xmlns && !strcmp(xmlns, "jabber:x:delay")) { const char *timestamp = xmlnode_get_attrib(child, "stamp"); + jm->delayed = TRUE; if(timestamp) jm->sent = gaim_str_to_time(timestamp, TRUE); } else if(xmlns && !strcmp(xmlns, "jabber:x:conference") &&
--- a/src/protocols/jabber/message.h Sat Jul 24 15:14:43 2004 +0000 +++ b/src/protocols/jabber/message.h Sat Jul 24 15:18:32 2004 +0000 @@ -37,6 +37,7 @@ JABBER_MESSAGE_OTHER } type; time_t sent; + gboolean delayed; char *from; char *to; char *subject;
--- a/src/protocols/toc/toc.c Sat Jul 24 15:14:43 2004 +0000 +++ b/src/protocols/toc/toc.c Sat Jul 24 15:18:32 2004 +0000 @@ -791,7 +791,8 @@ serv_got_joined_chat(gc, id, name); } else if (!g_ascii_strcasecmp(c, "CHAT_IN")) { - int id, w; + int id; + GaimConvChatFlags flags; char *m, *who, *whisper; sscanf(strtok(NULL, ":"), "%d", &id); @@ -802,9 +803,9 @@ m++; m++; - w = (whisper && (*whisper == 'T')) ? 1 : 0; + flags = (whisper && (*whisper == 'T')) ? GAIM_CONV_CHAT_WHISPER : 0; - serv_got_chat_in(gc, id, who, w, m, time((time_t)NULL)); + serv_got_chat_in(gc, id, who, flags, m, time((time_t)NULL)); } else if (!g_ascii_strcasecmp(c, "CHAT_UPDATE_BUDDY")) { int id; char *in, *buddy;
--- a/src/protocols/zephyr/zephyr.c Sat Jul 24 15:14:43 2004 +0000 +++ b/src/protocols/zephyr/zephyr.c Sat Jul 24 15:18:32 2004 +0000 @@ -715,7 +715,7 @@ send_inst_utf8 = "malformed instance"; } - serv_got_chat_in(zgc, zt2->id, send_inst_utf8, FALSE, buf3, time(NULL)); + serv_got_chat_in(zgc, zt2->id, send_inst_utf8, 0, buf3, time(NULL)); g_free(send_inst); gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account); gcc = gaim_conversation_get_chat_data(gconv1);
--- a/src/prpl.h Sat Jul 24 15:14:43 2004 +0000 +++ b/src/prpl.h Sat Jul 24 15:18:32 2004 +0000 @@ -57,8 +57,14 @@ { GAIM_CONV_IM_AUTO_RESP = 0x0001, /**< Auto response. */ GAIM_CONV_IM_IMAGES = 0x0002 /**< Contains images. */ +} GaimConvImFlags; -} GaimConvImFlags; +typedef enum +{ + GAIM_CONV_CHAT_WHISPER = 0x0001, /**< Whispered message.*/ + GAIM_CONV_CHAT_DELAYED = 0x0002 /**< Delayed message. */ + +} GaimConvChatFlags; typedef enum { GAIM_ICON_SCALE_DISPLAY = 0x01, /**< We scale the icon when we display it */
--- a/src/server.c Sat Jul 24 15:14:43 2004 +0000 +++ b/src/server.c Sat Jul 24 15:18:32 2004 +0000 @@ -1521,9 +1521,9 @@ } void serv_got_chat_in(GaimConnection *g, int id, const char *who, - int whisper, const char *message, time_t mtime) + GaimConvChatFlags chatflags, const char *message, time_t mtime) { - GaimMessageFlags w; + GaimMessageFlags msgflags = 0; GSList *bcs; GaimConversation *conv = NULL; GaimConvChat *chat = NULL; @@ -1578,12 +1578,12 @@ /* Make sure URLs are clickable */ buf = gaim_markup_linkify(message); - if (whisper) - w = GAIM_MESSAGE_WHISPER; - else - w = 0; + if (chatflags & GAIM_CONV_CHAT_WHISPER) + msgflags |= GAIM_MESSAGE_WHISPER; + if (chatflags & GAIM_CONV_CHAT_DELAYED) + msgflags |= GAIM_MESSAGE_DELAYED; - gaim_conv_chat_write(chat, who, buf, w, mtime); + gaim_conv_chat_write(chat, who, buf, msgflags, mtime); g_free(angel); g_free(buf);
--- a/src/server.h Sat Jul 24 15:14:43 2004 +0000 +++ b/src/server.h Sat Jul 24 15:18:32 2004 +0000 @@ -94,7 +94,7 @@ int id, const char *name); void serv_got_chat_left(GaimConnection *g, int id); void serv_got_chat_in(GaimConnection *g, int id, const char *who, - int whisper, const char *message, time_t mtime); + GaimConvChatFlags chatflags, const char *message, time_t mtime); void serv_send_file(GaimConnection *gc, const char *who, const char *file); #ifdef __cplusplus