# HG changeset patch # User mikael # Date 1114901100 0 # Node ID c3624b2a70596cd47d8772bc2971ef7124d0ab61 # Parent 7571de4aed731075d31b34f83de6cdf87d1a73f8 [/trunk] Changeset 160 by mikael * Add roster_msg_setflag() (which updates ROSTER_FLAG_MSG flag for buddy and his _group_. diff -r 7571de4aed73 -r c3624b2a7059 mcabber/src/TODO --- a/mcabber/src/TODO Fri Apr 29 19:56:28 2005 +0000 +++ b/mcabber/src/TODO Sat Apr 30 22:45:00 2005 +0000 @@ -2,9 +2,9 @@ BUGS: * Presence notification is always accepted. -* Messages in hidden (shrunk) groups are not visible. - Maybe we should create "*_msg_[gs]etflag()" functions, which - would update groups message flags too. (?) +* Do not show message flag for unfolded groups. +* Resize not handled. +* I have seen a segfault, but don't know how to reproduce it... TODO: diff -r 7571de4aed73 -r c3624b2a7059 mcabber/src/roster.c --- a/mcabber/src/roster.c Fri Apr 29 19:56:28 2005 +0000 +++ b/mcabber/src/roster.c Sat Apr 30 22:45:00 2005 +0000 @@ -226,7 +226,52 @@ else roster_usr->flags &= ~flags; } - + +// roster_msg_setflag() +// Set the ROSTER_FLAG_MSG to the given value for the given jid. +// It will update the buddy's group message flag. +void roster_msg_setflag(const char *jid, guint value) +{ + GSList *sl_user; + roster *roster_usr, *roster_grp; + + sl_user = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); + if (sl_user == NULL) + return; + + roster_usr = (roster*)sl_user->data; + roster_grp = (roster*)roster_usr->list->data; + if (value) { + // Message flag is TRUE. This is easy, we just have to set both flags + // to TRUE... + roster_usr->flags |= ROSTER_FLAG_MSG; + roster_grp->flags |= ROSTER_FLAG_MSG; // group + } else { + // Message flag is FALSE. + guint msg = FALSE; + roster_usr->flags &= ~ROSTER_FLAG_MSG; + // For the group value we need to watch all buddies in this group; + // if one is flagged, then the group will be flagged. + // I will re-use sl_user and roster_usr here, as they aren't used + // anymore. + sl_user = roster_grp->list; + while (sl_user) { + roster_usr = (roster*)sl_user->data; + if (roster_usr->flags & ROSTER_FLAG_MSG) { + msg = TRUE; + break; + } + sl_user = g_slist_next(sl_user); + } + if (!msg) + roster_grp->flags &= ~ROSTER_FLAG_MSG; + else + roster_grp->flags |= ROSTER_FLAG_MSG; + // Actually the "else" part is useless, because the group + // ROSTER_FLAG_MSG should already be set... + } +} + void roster_settype(const char *jid, guint type) { GSList *sl_user; @@ -272,12 +317,6 @@ return FALSE; } -// char *roster_getgroup(...) / Or *GSList? Which use?? -// ... setgroup(char*) ?? -// guchar roster_getflags(...) -// guchar roster_getname(...) / setname ?? -// roster_del_group? - /* ### BuddyList functions ### */ diff -r 7571de4aed73 -r c3624b2a7059 mcabber/src/roster.h --- a/mcabber/src/roster.h Fri Apr 29 19:56:28 2005 +0000 +++ b/mcabber/src/roster.h Sat Apr 30 22:45:00 2005 +0000 @@ -36,6 +36,7 @@ void roster_del_user(const char *jid); void roster_setstatus(const char *jid, enum imstatus bstat); void roster_setflags(const char *jid, guint flags, guint value); +void roster_msg_setflag(const char *jid, guint value); void roster_settype(const char *jid, guint type); enum imstatus roster_getstatus(const char *jid); guint roster_gettype(const char *jid); diff -r 7571de4aed73 -r c3624b2a7059 mcabber/src/screen.c --- a/mcabber/src/screen.c Fri Apr 29 19:56:28 2005 +0000 +++ b/mcabber/src/screen.c Sat Apr 30 22:45:00 2005 +0000 @@ -290,7 +290,7 @@ top_panel(win_entry->panel); currentWindow = win_entry; chatmode = TRUE; - roster_setflags(winId, ROSTER_FLAG_MSG, FALSE); + roster_msg_setflag(winId, FALSE); roster_setflags(winId, ROSTER_FLAG_LOCK, TRUE); update_roster = TRUE; @@ -386,7 +386,7 @@ update_panels(); doupdate(); } else { - roster_setflags(winId, ROSTER_FLAG_MSG, TRUE); + roster_msg_setflag(winId, TRUE); update_roster = TRUE; } }