comparison mcabber/src/roster.c @ 848:a9161d2dc414

Introduce special buffer stuff Update roster and commands: add support for a new "special" kind of buffer. A special buffer "[status]" is automatically created at startup.
author Mikael Berthe <mikael@lilotux.net>
date Mon, 08 May 2006 23:45:58 +0200
parents 915a7f17474a
children a8fadbd97858
comparison
equal deleted inserted replaced
847:e1b7f71b0b1c 848:a9161d2dc414
87 static GHashTable *unread_jids; 87 static GHashTable *unread_jids;
88 GList *buddylist; 88 GList *buddylist;
89 GList *current_buddy; 89 GList *current_buddy;
90 GList *alternate_buddy; 90 GList *alternate_buddy;
91 91
92 static roster roster_special;
93
92 void unread_jid_add(const char *jid); 94 void unread_jid_add(const char *jid);
93 int unread_jid_del(const char *jid); 95 int unread_jid_del(const char *jid);
94 96
97
98 /* ### Initialization ### */
99
100 void roster_init(void)
101 {
102 roster_special.name = "[status]";
103 roster_special.type = ROSTER_TYPE_SPECIAL;
104 }
95 105
96 /* ### Resources functions ### */ 106 /* ### Resources functions ### */
97 107
98 static void free_all_resources(GSList **reslist) 108 static void free_all_resources(GSList **reslist)
99 { 109 {
713 if (buddylist) { 723 if (buddylist) {
714 g_list_free(buddylist); 724 g_list_free(buddylist);
715 buddylist = NULL; 725 buddylist = NULL;
716 } 726 }
717 727
728 buddylist = g_list_append(buddylist, &roster_special);
729
718 // Create the new list 730 // Create the new list
719 while (sl_roster_elt) { 731 while (sl_roster_elt) {
720 GSList *sl_roster_usrelt; 732 GSList *sl_roster_usrelt;
721 roster *roster_usrelt; 733 roster *roster_usrelt;
722 guint pending_group = FALSE; 734 guint pending_group = FALSE;
934 roster *roster_usr = rosterdata; 946 roster *roster_usr = rosterdata;
935 947
936 if (roster_usr->type & ROSTER_TYPE_GROUP) 948 if (roster_usr->type & ROSTER_TYPE_GROUP)
937 return roster_usr->name; 949 return roster_usr->name;
938 950
951 if (roster_usr->type & ROSTER_TYPE_SPECIAL)
952 return NULL;
953
939 // This is a user 954 // This is a user
940 return ((roster*)((GSList*)roster_usr->list)->data)->name; 955 return ((roster*)((GSList*)roster_usr->list)->data)->name;
941 } 956 }
942 957
943 // buddy_getgroup() 958 // buddy_getgroup()
946 { 961 {
947 roster *roster_usr = rosterdata; 962 roster *roster_usr = rosterdata;
948 963
949 if (roster_usr->type & ROSTER_TYPE_GROUP) 964 if (roster_usr->type & ROSTER_TYPE_GROUP)
950 return rosterdata; 965 return rosterdata;
966
967 if (roster_usr->type & ROSTER_TYPE_SPECIAL)
968 return NULL;
951 969
952 // This is a user 970 // This is a user
953 return (gpointer)((GSList*)roster_usr->list)->data; 971 return (gpointer)((GSList*)roster_usr->list)->data;
954 } 972 }
955 973
1204 GSList *sl_roster_usrelt; 1222 GSList *sl_roster_usrelt;
1205 roster *roster_usrelt; 1223 roster *roster_usrelt;
1206 1224
1207 while (sl_roster_elt) { // group list loop 1225 while (sl_roster_elt) { // group list loop
1208 roster_elt = (roster*) sl_roster_elt->data; 1226 roster_elt = (roster*) sl_roster_elt->data;
1227 if (roster_elt->type & ROSTER_TYPE_SPECIAL)
1228 continue; // Skip special items
1209 sl_roster_usrelt = roster_elt->list; 1229 sl_roster_usrelt = roster_elt->list;
1210 while (sl_roster_usrelt) { // user list loop 1230 while (sl_roster_usrelt) { // user list loop
1211 roster_usrelt = (roster*) sl_roster_usrelt->data; 1231 roster_usrelt = (roster*) sl_roster_usrelt->data;
1212 1232
1213 if (roster_usrelt->type & roster_type) 1233 if (roster_usrelt->type & roster_type)