From: Nathan W. <fac...@us...> - 2003-10-14 05:07:42
|
Update of /cvsroot/gaim/gaim/src/protocols/jabber In directory sc8-pr-cvs1:/tmp/cvs-serv21452/src/protocols/jabber Modified Files: jabber.c jutil.c jutil.h message.c Log Message: prpl-specific normalize is back, after my crusade to kill it. Index: jabber.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/jabber.c,v retrieving revision 1.201 retrieving revision 1.202 diff -u -d -p -r1.201 -r1.202 --- jabber.c 6 Oct 2003 21:55:28 -0000 1.201 +++ jabber.c 14 Oct 2003 05:07:38 -0000 1.202 @@ -1038,7 +1038,7 @@ static GaimPluginProtocolInfo prpl_info jabber_roster_group_rename, NULL, NULL, /* convo_closed */ /* XXX: thread_ids */ - NULL /* normalize */ + jabber_normalize /* normalize */ }; static GaimPluginInfo info = Index: jutil.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/jutil.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- jutil.c 29 Sep 2003 15:23:19 -0000 1.4 +++ jutil.c 14 Oct 2003 05:07:38 -0000 1.5 @@ -183,3 +183,14 @@ char *jabber_get_bare_jid(const char *ji else return g_strdup(jid); } + +const char *jabber_normalize(const GaimAccount *account, const char *in) +{ + static char buf[2048]; /* maximum legal length of a jabber jid */ + char *tmp; + + tmp = jabber_get_bare_jid(in); + g_snprintf(buf, sizeof(buf), "%s", tmp); + g_free(tmp); + return buf; +} Index: jutil.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/jutil.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- jutil.h 29 Sep 2003 15:23:19 -0000 1.1 +++ jutil.h 14 Oct 2003 05:07:38 -0000 1.2 @@ -22,6 +22,8 @@ #ifndef _GAIM_JABBER_JID_H_ #define _GAIM_JABBER_JID_H_ +#include "account.h" + typedef struct _JabberID { char *node; @@ -37,5 +39,7 @@ char *jabber_get_bare_jid(const char *ji time_t str_to_time(const char *timestamp); const char *jabber_get_state_string(int state); + +const char *jabber_normalize(const GaimAccount *account, const char *in); #endif /* _GAIM_JABBER_JID_H_ */ Index: message.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/message.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- message.c 14 Oct 2003 03:46:00 -0000 1.9 +++ message.c 14 Oct 2003 05:07:38 -0000 1.10 @@ -52,6 +52,24 @@ void jabber_message_free(JabberMessage * g_free(jm); } +static GaimConversation * +find_unnormalized_conv(const char *name, GaimAccount *account) +{ + GaimConversation *c = NULL; + GList *cnv; + + g_return_val_if_fail(name != NULL, NULL); + + for(cnv = gaim_get_conversations(); cnv; cnv = cnv->next) { + c = (GaimConversation*)cnv->data; + if(!gaim_utf8_strcasecmp(name, gaim_conversation_get_name(c)) && + account == gaim_conversation_get_account(c)) + return c; + } + + return NULL; +} + static void handle_chat(JabberMessage *jm) { JabberID *jid = jabber_id_new(jm->from); @@ -63,13 +81,13 @@ static void handle_chat(JabberMessage *j jb = jabber_buddy_find(jm->js, jm->from, TRUE); jbr = jabber_buddy_find_resource(jb, jabber_get_resource(jm->from)); - if(gaim_find_conversation_with_account(jm->from, jm->js->gc->account)) { + if(find_unnormalized_conv(jm->from, jm->js->gc->account)) { from = g_strdup(jm->from); } else if(jid->node) { GaimConversation *conv; from = g_strdup_printf("%s@%s", jid->node, jid->domain); - conv = gaim_find_conversation_with_account(from, jm->js->gc->account); + conv = find_unnormalized_conv(from, jm->js->gc->account); if(conv) gaim_conversation_set_name(conv, jm->from); g_free(from); |