equal
deleted
inserted
replaced
75 /* For groupchats */ |
75 /* For groupchats */ |
76 gchar *nickname; |
76 gchar *nickname; |
77 gchar *topic; |
77 gchar *topic; |
78 guint inside_room; |
78 guint inside_room; |
79 |
79 |
|
80 /* on_server is TRUE if the item is present on the server roster */ |
|
81 guint on_server; |
|
82 |
80 /* To keep track of last status message */ |
83 /* To keep track of last status message */ |
81 gchar *offline_status_message; |
84 gchar *offline_status_message; |
82 |
85 |
83 /* Flag used for the UI */ |
86 /* Flag used for the UI */ |
84 guint flags; |
87 guint flags; |
335 } |
338 } |
336 return p_group; |
339 return p_group; |
337 } |
340 } |
338 |
341 |
339 // Returns a pointer to the new user, or existing user with that name |
342 // Returns a pointer to the new user, or existing user with that name |
|
343 // Note: if onserver is -1, the flag won't be changed. |
340 GSList *roster_add_user(const char *jid, const char *name, const char *group, |
344 GSList *roster_add_user(const char *jid, const char *name, const char *group, |
341 guint type, enum subscr esub) |
345 guint type, enum subscr esub, gint onserver) |
342 { |
346 { |
343 roster *roster_usr; |
347 roster *roster_usr; |
344 roster *my_group; |
348 roster *my_group; |
345 GSList *slist; |
349 GSList *slist; |
346 |
350 |
365 buddy_setname(slist->data, (char*)name); |
369 buddy_setname(slist->data, (char*)name); |
366 // Let's check if the group name has changed |
370 // Let's check if the group name has changed |
367 oldgroupname = ((roster*)((GSList*)roster_usr->list)->data)->name; |
371 oldgroupname = ((roster*)((GSList*)roster_usr->list)->data)->name; |
368 if (group && strcmp(oldgroupname, group)) |
372 if (group && strcmp(oldgroupname, group)) |
369 buddy_setgroup(slist->data, (char*)group); |
373 buddy_setgroup(slist->data, (char*)group); |
|
374 if (onserver != -1) |
|
375 buddy_setonserverflag(slist->data, onserver); |
370 return slist; |
376 return slist; |
371 } |
377 } |
372 // #2 add group if necessary |
378 // #2 add group if necessary |
373 slist = roster_add_group(group); |
379 slist = roster_add_group(group); |
374 if (!slist) return NULL; |
380 if (!slist) return NULL; |
391 unread_list = g_slist_append(unread_list, roster_usr); |
397 unread_list = g_slist_append(unread_list, roster_usr); |
392 } |
398 } |
393 roster_usr->type = type; |
399 roster_usr->type = type; |
394 roster_usr->subscription = esub; |
400 roster_usr->subscription = esub; |
395 roster_usr->list = slist; // (my_group SList element) |
401 roster_usr->list = slist; // (my_group SList element) |
|
402 if (onserver == 1) |
|
403 roster_usr->on_server = TRUE; |
396 // #4 Insert node (sorted) |
404 // #4 Insert node (sorted) |
397 my_group->list = g_slist_insert_sorted(my_group->list, roster_usr, |
405 my_group->list = g_slist_insert_sorted(my_group->list, roster_usr, |
398 (GCompareFunc)&roster_compare_name); |
406 (GCompareFunc)&roster_compare_name); |
399 return roster_find(jid, jidsearch, type); |
407 return roster_find(jid, jidsearch, type); |
400 } |
408 } |
494 |
502 |
495 sl_user = roster_find(jid, jidsearch, |
503 sl_user = roster_find(jid, jidsearch, |
496 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
504 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
497 // If we can't find it, we add it |
505 // If we can't find it, we add it |
498 if (sl_user == NULL) |
506 if (sl_user == NULL) |
499 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER, sub_none); |
507 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER, |
|
508 sub_none, -1); |
500 |
509 |
501 // If there is no resource name, we can leave now |
510 // If there is no resource name, we can leave now |
502 if (!resname) return; |
511 if (!resname) return; |
503 |
512 |
504 roster_usr = (roster*)sl_user->data; |
513 roster_usr = (roster*)sl_user->data; |
584 |
593 |
585 sl_user = roster_find(jid, jidsearch, |
594 sl_user = roster_find(jid, jidsearch, |
586 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
595 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
587 // If we can't find it, we add it |
596 // If we can't find it, we add it |
588 if (sl_user == NULL) { |
597 if (sl_user == NULL) { |
589 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER, sub_none); |
598 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER, sub_none, -1); |
590 new_roster_item = TRUE; |
599 new_roster_item = TRUE; |
591 } |
600 } |
592 |
601 |
593 roster_usr = (roster*)sl_user->data; |
602 roster_usr = (roster*)sl_user->data; |
594 roster_grp = (roster*)roster_usr->list->data; |
603 roster_grp = (roster*)roster_usr->list->data; |
1273 { |
1282 { |
1274 roster *roster_usr = rosterdata; |
1283 roster *roster_usr = rosterdata; |
1275 return roster_usr->flags; |
1284 return roster_usr->flags; |
1276 } |
1285 } |
1277 |
1286 |
|
1287 // buddy_setonserverflag() |
|
1288 // Set the on_server flag |
|
1289 void buddy_setonserverflag(gpointer rosterdata, guint onserver) |
|
1290 { |
|
1291 roster *roster_usr = rosterdata; |
|
1292 roster_usr->on_server = onserver; |
|
1293 } |
|
1294 |
|
1295 guint buddy_getonserverflag(gpointer rosterdata) |
|
1296 { |
|
1297 roster *roster_usr = rosterdata; |
|
1298 return roster_usr->on_server; |
|
1299 } |
|
1300 |
1278 // buddy_search_jid(jid) |
1301 // buddy_search_jid(jid) |
1279 // Look for a buddy with specified jid. |
1302 // Look for a buddy with specified jid. |
1280 // Search begins at buddylist; if no match is found in the the buddylist, |
1303 // Search begins at buddylist; if no match is found in the the buddylist, |
1281 // return NULL; |
1304 // return NULL; |
1282 GList *buddy_search_jid(const char *jid) |
1305 GList *buddy_search_jid(const char *jid) |