comparison mcabber/src/roster.c @ 603:9516db839e08

Store subscription data
author Mikael Berthe <mikael@lilotux.net>
date Thu, 15 Dec 2005 12:52:37 +0100
parents 414fbf558f1e
children cf722bff6579
comparison
equal deleted inserted replaced
602:7b20c27cae48 603:9516db839e08
257 return roster_find(name, namesearch, ROSTER_TYPE_GROUP); 257 return roster_find(name, namesearch, ROSTER_TYPE_GROUP);
258 } 258 }
259 259
260 // Returns a pointer to the new user, or existing user with that name 260 // Returns a pointer to the new user, or existing user with that name
261 GSList *roster_add_user(const char *jid, const char *name, const char *group, 261 GSList *roster_add_user(const char *jid, const char *name, const char *group,
262 guint type) 262 guint type, enum subscr esub)
263 { 263 {
264 roster *roster_usr; 264 roster *roster_usr;
265 roster *my_group; 265 roster *my_group;
266 GSList *slist; 266 GSList *slist;
267 267
292 p = strstr(str, "/"); 292 p = strstr(str, "/");
293 if (p) *p = '\0'; 293 if (p) *p = '\0';
294 roster_usr->name = g_strdup(str); 294 roster_usr->name = g_strdup(str);
295 g_free(str); 295 g_free(str);
296 } 296 }
297 roster_usr->type = type; 297 roster_usr->type = type;
298 roster_usr->list = slist; // (my_group SList element) 298 roster_usr->subscription = esub;
299 roster_usr->list = slist; // (my_group SList element)
299 // #4 Insert node (sorted) 300 // #4 Insert node (sorted)
300 my_group->list = g_slist_insert_sorted(my_group->list, roster_usr, 301 my_group->list = g_slist_insert_sorted(my_group->list, roster_usr,
301 (GCompareFunc)&roster_compare_name); 302 (GCompareFunc)&roster_compare_name);
302 return roster_find(jid, jidsearch, type); 303 return roster_find(jid, jidsearch, type);
303 } 304 }
400 401
401 sl_user = roster_find(jid, jidsearch, 402 sl_user = roster_find(jid, jidsearch,
402 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); 403 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT);
403 // If we can't find it, we add it 404 // If we can't find it, we add it
404 if (sl_user == NULL) 405 if (sl_user == NULL)
405 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER); 406 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER, sub_none);
406 407
407 // If there is no resource name, we can leave now 408 // If there is no resource name, we can leave now
408 if (!resname) return; 409 if (!resname) return;
409 410
410 roster_usr = (roster*)sl_user->data; 411 roster_usr = (roster*)sl_user->data;
726 // Remove the buddy from current group 727 // Remove the buddy from current group
727 sl_group = &((roster*)((GSList*)roster_usr->list)->data)->list; 728 sl_group = &((roster*)((GSList*)roster_usr->list)->data)->list;
728 *sl_group = g_slist_remove(*sl_group, rosterdata); 729 *sl_group = g_slist_remove(*sl_group, rosterdata);
729 730
730 // Add the buddy to its new group; actually we "clone" this buddy... 731 // Add the buddy to its new group; actually we "clone" this buddy...
731 sl_clone = roster_add_user(roster_usr->jid, roster_usr->name, 732 sl_clone = roster_add_user(roster_usr->jid, roster_usr->name, newgroupname,
732 newgroupname, roster_usr->type); 733 roster_usr->type, roster_usr->subscription);
733 roster_clone = (roster*)sl_clone->data; 734 roster_clone = (roster*)sl_clone->data;
734 roster_clone->subscription = roster_usr->subscription; 735 roster_clone->subscription = roster_usr->subscription;
735 roster_clone->flags = roster_usr->flags; 736 roster_clone->flags = roster_usr->flags;
736 737
737 roster_clone->resource = roster_usr->resource; 738 roster_clone->resource = roster_usr->resource;
872 873
873 guint buddy_gettype(gpointer rosterdata) 874 guint buddy_gettype(gpointer rosterdata)
874 { 875 {
875 roster *roster_usr = rosterdata; 876 roster *roster_usr = rosterdata;
876 return roster_usr->type; 877 return roster_usr->type;
878 }
879
880 guint buddy_getsubscription(gpointer rosterdata)
881 {
882 roster *roster_usr = rosterdata;
883 return roster_usr->subscription;
877 } 884 }
878 885
879 enum imstatus buddy_getstatus(gpointer rosterdata, const char *resname) 886 enum imstatus buddy_getstatus(gpointer rosterdata, const char *resname)
880 { 887 {
881 roster *roster_usr = rosterdata; 888 roster *roster_usr = rosterdata;