# HG changeset patch # User mikael # Date 1114720480 0 # Node ID 6533a231a65e54617f3d15f7602d0ce4e85c5c80 # Parent 3b480b73df199a524c1e607a57aea0499044d0bf [/trunk] Changeset 153 by mikael * We now rebuild the buddy list when receiving a message from an offline/invisible buddy. diff -r 3b480b73df19 -r 6533a231a65e mcabber/src/TODO --- a/mcabber/src/TODO Thu Apr 28 20:11:31 2005 +0000 +++ b/mcabber/src/TODO Thu Apr 28 20:34:40 2005 +0000 @@ -1,8 +1,6 @@ BUGS: -* We should rebuild the buddy list when receiving a message from an offline - buddy (or invisible/just hidden). * Presence notification is always accepted. * Messages in hidden (shrunk) groups are not visible. Maybe we should create "*_msg_[gs]etflag()" functions, which diff -r 3b480b73df19 -r 6533a231a65e mcabber/src/hooks.c --- a/mcabber/src/hooks.c Thu Apr 28 20:11:31 2005 +0000 +++ b/mcabber/src/hooks.c Thu Apr 28 20:34:40 2005 +0000 @@ -30,10 +30,21 @@ inline void hk_message_in(const char *jid, time_t timestamp, const char *msg) { char *buffer = utf8_decode(msg); - // XXX Maybe filter out special chars? + int new_guy = FALSE; + + // If this user isn't in the roster, we add it + if (!roster_exists(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_AGENT)) { + roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER); + new_guy = TRUE; + } + scr_WriteIncomingMessage(jid, buffer); hlog_write_message(jid, timestamp, FALSE, buffer); free(buffer); + if (new_guy) { + buddylist_build(); + update_roster = TRUE; + } } inline void hk_message_out(const char *jid, time_t timestamp, const char *msg) diff -r 3b480b73df19 -r 6533a231a65e mcabber/src/roster.c --- a/mcabber/src/roster.c Thu Apr 28 20:11:31 2005 +0000 +++ b/mcabber/src/roster.c Thu Apr 28 20:34:40 2005 +0000 @@ -264,6 +264,14 @@ return roster_usr->type; } +inline guint roster_exists(const char *jidname, enum findwhat type, + guint roster_type) +{ + if (roster_find(jidname, type, roster_type)) + return TRUE; + return FALSE; +} + // char *roster_getgroup(...) / Or *GSList? Which use?? // ... setgroup(char*) ?? // guchar roster_getflags(...) diff -r 3b480b73df19 -r 6533a231a65e mcabber/src/roster.h --- a/mcabber/src/roster.h Thu Apr 28 20:11:31 2005 +0000 +++ b/mcabber/src/roster.h Thu Apr 28 20:34:40 2005 +0000 @@ -43,6 +43,8 @@ void roster_settype(const char *jid, guint type); enum imstatus roster_getstatus(const char *jid); guint roster_gettype(const char *jid); +inline guint roster_exists(const char *jidname, enum findwhat type, + guint roster_type); void buddylist_set_hide_offline_buddies(int hide); inline int buddylist_get_hide_offline_buddies(void);