void remove_contact_with_remaining_in_group(void **state) { roster_create(); GSList *groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("*****@*****.**", NULL, groups1, NULL, FALSE); GSList *groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("different")); roster_add("*****@*****.**", NULL, groups2, NULL, FALSE); roster_remove("*****@*****.**", "*****@*****.**"); GSList *groups_res = roster_get_groups(); assert_int_equal(g_slist_length(groups_res), 3); GSList *found = g_slist_find_custom(groups_res, "friends", g_strcmp0); assert_true(found != NULL); found = g_slist_find_custom(groups_res, "work", g_strcmp0); assert_true(found != NULL); found = g_slist_find_custom(groups_res, "stuff", g_strcmp0); assert_true(found != NULL); g_slist_free_full(groups_res, g_free); roster_destroy(); }
void add_contact_with_three_groups_update_two_new(void **state) { roster_create(); GSList *groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("*****@*****.**", NULL, groups1, NULL, FALSE); GSList *groups2 = NULL; groups2 = g_slist_append(groups2, strdup("newfriends")); groups2 = g_slist_append(groups2, strdup("somepeople")); roster_update("*****@*****.**", NULL, groups2, NULL, FALSE); GSList *groups_res = roster_get_groups(); assert_int_equal(g_slist_length(groups_res), 2); GSList *found = g_slist_find_custom(groups_res, "newfriends", g_strcmp0); assert_true(found != NULL); found = g_slist_find_custom(groups_res, "somepeople", g_strcmp0); assert_true(found != NULL); g_slist_free_full(groups_res, g_free); roster_destroy(); }
void add_contact_with_three_groups(void **state) { roster_create(); GSList *groups = NULL; groups = g_slist_append(groups, strdup("friends")); groups = g_slist_append(groups, strdup("work")); groups = g_slist_append(groups, strdup("stuff")); roster_add("*****@*****.**", NULL, groups, NULL, FALSE); GSList *groups_res = roster_get_groups(); assert_int_equal(g_slist_length(groups_res), 3); GSList *found = g_slist_find_custom(groups_res, "friends", g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_slist_find_custom(groups_res, "work", g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "work"); found = g_slist_find_custom(groups_res, "stuff", g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "stuff"); g_slist_free_full(groups_res, g_free); roster_destroy(); }
void add_contact_with_no_group(void **state) { roster_create(); roster_add("*****@*****.**", NULL, NULL, NULL, FALSE); GSList *groups_res = roster_get_groups(); assert_int_equal(g_slist_length(groups_res), 0); g_slist_free_full(groups_res, g_free); roster_destroy(); }
void rosterwin_roster(void) { ProfWin *console = wins_get_console(); if (console) { ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout; assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK); char *by = prefs_get_string(PREF_ROSTER_BY); if (g_strcmp0(by, "presence") == 0) { werase(layout->subwin); _rosterwin_contacts_by_presence(layout, "chat", " -Available for chat"); _rosterwin_contacts_by_presence(layout, "online", " -Online"); _rosterwin_contacts_by_presence(layout, "away", " -Away"); _rosterwin_contacts_by_presence(layout, "xa", " -Extended Away"); _rosterwin_contacts_by_presence(layout, "dnd", " -Do not disturb"); if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) { _rosterwin_contacts_by_presence(layout, "offline", " -Offline"); } } else if (g_strcmp0(by, "group") == 0) { werase(layout->subwin); GSList *groups = roster_get_groups(); GSList *curr_group = groups; while (curr_group) { _rosterwin_contacts_by_group(layout, curr_group->data); curr_group = g_slist_next(curr_group); } g_slist_free_full(groups, free); _rosterwin_contacts_by_no_group(layout); } else { GSList *contacts = roster_get_contacts(); if (contacts) { werase(layout->subwin); wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); win_printline_nowrap(layout->subwin, " -Roster"); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); GSList *curr_contact = contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); curr_contact = g_slist_next(curr_contact); } } g_slist_free(contacts); } free(by); } }
void add_remove_contact_groups(void **state) { roster_create(); GSList *groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("*****@*****.**", NULL, groups1, NULL, FALSE); roster_remove("*****@*****.**", "*****@*****.**"); GSList *groups_res = roster_get_groups(); assert_int_equal(g_slist_length(groups_res), 0); g_slist_free_full(groups_res, g_free); roster_destroy(); }