mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-01 19:24:15 -04:00
Renamed contact_list_ functions to roster_
This commit is contained in:
parent
097ea18dab
commit
05f2d29396
@ -24,7 +24,7 @@ profanity_SOURCES = src/contact.c src/contact.h src/log.c src/common.c \
|
||||
|
||||
TESTS = tests/testsuite
|
||||
check_PROGRAMS = tests/testsuite
|
||||
tests_testsuite_SOURCES = tests/test_contact_list.c src/contact_list.c src/contact.c \
|
||||
tests_testsuite_SOURCES = tests/test_roster.c src/contact_list.c src/contact.c \
|
||||
tests/test_common.c tests/test_history.c src/tools/history.c src/common.c \
|
||||
tests/test_autocomplete.c src/tools/autocomplete.c tests/testsuite.c \
|
||||
tests/test_parser.c src/command/parser.c tests/test_jid.c src/jid.c \
|
||||
|
@ -961,7 +961,7 @@ cmd_autocomplete(char *input, int *size)
|
||||
void
|
||||
cmd_reset_autocomplete()
|
||||
{
|
||||
contact_list_reset_search_attempts();
|
||||
roster_reset_search_attempts();
|
||||
muc_reset_invites_ac();
|
||||
accounts_reset_all_search();
|
||||
accounts_reset_enabled_search();
|
||||
@ -1165,18 +1165,18 @@ _cmd_complete_parameters(char *input, int *size)
|
||||
}
|
||||
} else {
|
||||
_parameter_autocomplete(input, size, "/msg",
|
||||
contact_list_find_contact);
|
||||
roster_find_contact);
|
||||
_parameter_autocomplete(input, size, "/info",
|
||||
contact_list_find_contact);
|
||||
roster_find_contact);
|
||||
_parameter_autocomplete(input, size, "/caps",
|
||||
contact_list_find_resource);
|
||||
roster_find_resource);
|
||||
_parameter_autocomplete(input, size, "/status",
|
||||
contact_list_find_contact);
|
||||
roster_find_contact);
|
||||
_parameter_autocomplete(input, size, "/software",
|
||||
contact_list_find_resource);
|
||||
roster_find_resource);
|
||||
}
|
||||
|
||||
_parameter_autocomplete(input, size, "/invite", contact_list_find_contact);
|
||||
_parameter_autocomplete(input, size, "/invite", roster_find_contact);
|
||||
_parameter_autocomplete(input, size, "/decline", muc_find_invite);
|
||||
_parameter_autocomplete(input, size, "/join", muc_find_invite);
|
||||
|
||||
@ -1474,7 +1474,7 @@ _cmd_sub(gchar **args, struct cmd_help_t help)
|
||||
cons_show("Sent subscription request to %s.", bare_jid);
|
||||
log_info("Sent subscription request to %s.", bare_jid);
|
||||
} else if (strcmp(subcmd, "show") == 0) {
|
||||
PContact contact = contact_list_get_contact(bare_jid);
|
||||
PContact contact = roster_get_contact(bare_jid);
|
||||
if ((contact == NULL) || (p_contact_subscription(contact) == NULL)) {
|
||||
if (win_type == WIN_CHAT) {
|
||||
ui_current_print_line("No subscription information for %s.", bare_jid);
|
||||
@ -1791,7 +1791,7 @@ _cmd_who(gchar **args, struct cmd_help_t help)
|
||||
// not in groupchat window
|
||||
} else {
|
||||
cons_show("");
|
||||
GSList *list = get_contact_list();
|
||||
GSList *list = roster_get_contacts();
|
||||
|
||||
// no arg, show all contacts
|
||||
if (presence == NULL) {
|
||||
@ -2066,7 +2066,7 @@ _cmd_info(gchar **args, struct cmd_help_t help)
|
||||
if (usr != NULL) {
|
||||
cons_show("No parameter required for /info in chat.");
|
||||
} else {
|
||||
pcontact = contact_list_get_contact(ui_current_recipient());
|
||||
pcontact = roster_get_contact(ui_current_recipient());
|
||||
if (pcontact != NULL) {
|
||||
cons_show_info(pcontact);
|
||||
} else {
|
||||
@ -2090,7 +2090,7 @@ _cmd_info(gchar **args, struct cmd_help_t help)
|
||||
break;
|
||||
case WIN_CONSOLE:
|
||||
if (usr != NULL) {
|
||||
pcontact = contact_list_get_contact(usr);
|
||||
pcontact = roster_get_contact(usr);
|
||||
if (pcontact != NULL) {
|
||||
cons_show_info(pcontact);
|
||||
} else {
|
||||
@ -2142,7 +2142,7 @@ _cmd_caps(gchar **args, struct cmd_help_t help)
|
||||
if (jid->fulljid == NULL) {
|
||||
cons_show("You must provide a full jid to the /caps command.");
|
||||
} else {
|
||||
pcontact = contact_list_get_contact(jid->barejid);
|
||||
pcontact = roster_get_contact(jid->barejid);
|
||||
if (pcontact == NULL) {
|
||||
cons_show("Contact not found in roster: %s", jid->barejid);
|
||||
} else {
|
||||
|
@ -37,7 +37,7 @@ static gboolean _key_equals(void *key1, void *key2);
|
||||
static gboolean _datetimes_equal(GDateTime *dt1, GDateTime *dt2);
|
||||
|
||||
void
|
||||
contact_list_init(void)
|
||||
roster_init(void)
|
||||
{
|
||||
ac = autocomplete_new();
|
||||
resource_ac = autocomplete_new();
|
||||
@ -46,7 +46,7 @@ contact_list_init(void)
|
||||
}
|
||||
|
||||
void
|
||||
contact_list_clear(void)
|
||||
roster_clear(void)
|
||||
{
|
||||
autocomplete_clear(ac);
|
||||
autocomplete_clear(resource_ac);
|
||||
@ -56,21 +56,21 @@ contact_list_clear(void)
|
||||
}
|
||||
|
||||
void
|
||||
contact_list_free()
|
||||
roster_free()
|
||||
{
|
||||
autocomplete_free(ac);
|
||||
autocomplete_free(resource_ac);
|
||||
}
|
||||
|
||||
void
|
||||
contact_list_reset_search_attempts(void)
|
||||
roster_reset_search_attempts(void)
|
||||
{
|
||||
autocomplete_reset(ac);
|
||||
autocomplete_reset(resource_ac);
|
||||
}
|
||||
|
||||
gboolean
|
||||
contact_list_add(const char * const barejid, const char * const name,
|
||||
roster_add(const char * const barejid, const char * const name,
|
||||
const char * const subscription, const char * const offline_message,
|
||||
gboolean pending_out)
|
||||
{
|
||||
@ -89,13 +89,13 @@ contact_list_add(const char * const barejid, const char * const name,
|
||||
}
|
||||
|
||||
void
|
||||
contact_list_remove(const char * const barejid)
|
||||
roster_remove(const char * const barejid)
|
||||
{
|
||||
g_hash_table_remove(contacts, barejid);
|
||||
}
|
||||
|
||||
gboolean
|
||||
contact_list_update_presence(const char * const barejid, Resource *resource,
|
||||
roster_update_presence(const char * const barejid, Resource *resource,
|
||||
GDateTime *last_activity)
|
||||
{
|
||||
assert(barejid != NULL);
|
||||
@ -118,7 +118,7 @@ contact_list_update_presence(const char * const barejid, Resource *resource,
|
||||
}
|
||||
|
||||
gboolean
|
||||
contact_list_contact_offline(const char * const barejid,
|
||||
roster_contact_offline(const char * const barejid,
|
||||
const char * const resource, const char * const status)
|
||||
{
|
||||
PContact contact = g_hash_table_lookup(contacts, barejid);
|
||||
@ -140,7 +140,7 @@ contact_list_contact_offline(const char * const barejid,
|
||||
}
|
||||
|
||||
void
|
||||
contact_list_update_subscription(const char * const barejid,
|
||||
roster_update_subscription(const char * const barejid,
|
||||
const char * const subscription, gboolean pending_out)
|
||||
{
|
||||
PContact contact = g_hash_table_lookup(contacts, barejid);
|
||||
@ -155,7 +155,7 @@ contact_list_update_subscription(const char * const barejid,
|
||||
}
|
||||
|
||||
gboolean
|
||||
contact_list_has_pending_subscriptions(void)
|
||||
roster_has_pending_subscriptions(void)
|
||||
{
|
||||
GHashTableIter iter;
|
||||
gpointer key;
|
||||
@ -173,7 +173,7 @@ contact_list_has_pending_subscriptions(void)
|
||||
}
|
||||
|
||||
GSList *
|
||||
get_contact_list(void)
|
||||
roster_get_contacts(void)
|
||||
{
|
||||
GSList *result = NULL;
|
||||
GHashTableIter iter;
|
||||
@ -190,19 +190,19 @@ get_contact_list(void)
|
||||
}
|
||||
|
||||
char *
|
||||
contact_list_find_contact(char *search_str)
|
||||
roster_find_contact(char *search_str)
|
||||
{
|
||||
return autocomplete_complete(ac, search_str);
|
||||
}
|
||||
|
||||
char *
|
||||
contact_list_find_resource(char *search_str)
|
||||
roster_find_resource(char *search_str)
|
||||
{
|
||||
return autocomplete_complete(resource_ac, search_str);
|
||||
}
|
||||
|
||||
PContact
|
||||
contact_list_get_contact(const char const *barejid)
|
||||
roster_get_contact(const char const *barejid)
|
||||
{
|
||||
return g_hash_table_lookup(contacts, barejid);
|
||||
}
|
||||
|
@ -27,24 +27,24 @@
|
||||
|
||||
#include "contact.h"
|
||||
|
||||
void contact_list_init(void);
|
||||
void contact_list_clear(void);
|
||||
void contact_list_free(void);
|
||||
void contact_list_reset_search_attempts(void);
|
||||
void contact_list_remove(const char * const barejid);
|
||||
gboolean contact_list_add(const char * const barejid, const char * const name,
|
||||
void roster_init(void);
|
||||
void roster_clear(void);
|
||||
void roster_free(void);
|
||||
void roster_reset_search_attempts(void);
|
||||
void roster_remove(const char * const barejid);
|
||||
gboolean roster_add(const char * const barejid, const char * const name,
|
||||
const char * const subscription, const char * const offline_message,
|
||||
gboolean pending_out);
|
||||
gboolean contact_list_update_presence(const char * const barejid,
|
||||
gboolean roster_update_presence(const char * const barejid,
|
||||
Resource *resource, GDateTime *last_activity);
|
||||
void contact_list_update_subscription(const char * const barejid,
|
||||
void roster_update_subscription(const char * const barejid,
|
||||
const char * const subscription, gboolean pending_out);
|
||||
gboolean contact_list_has_pending_subscriptions(void);
|
||||
GSList * get_contact_list(void);
|
||||
char * contact_list_find_contact(char *search_str);
|
||||
char * contact_list_find_resource(char *search_str);
|
||||
PContact contact_list_get_contact(const char const *barejid);
|
||||
gboolean contact_list_contact_offline(const char * const barejid,
|
||||
gboolean roster_has_pending_subscriptions(void);
|
||||
GSList * roster_get_contacts(void);
|
||||
char * roster_find_contact(char *search_str);
|
||||
char * roster_find_resource(char *search_str);
|
||||
PContact roster_get_contact(const char const *barejid);
|
||||
gboolean roster_contact_offline(const char * const barejid,
|
||||
const char * const resource, const char * const status);
|
||||
|
||||
#endif
|
||||
|
@ -234,7 +234,7 @@ void
|
||||
prof_handle_lost_connection(void)
|
||||
{
|
||||
cons_show_error("Lost connection.");
|
||||
contact_list_clear();
|
||||
roster_clear();
|
||||
muc_clear_invites();
|
||||
chat_sessions_clear();
|
||||
ui_disconnected();
|
||||
@ -246,7 +246,7 @@ prof_handle_disconnect(const char * const jid)
|
||||
{
|
||||
cons_show("%s logged out successfully.", jid);
|
||||
jabber_disconnect();
|
||||
contact_list_clear();
|
||||
roster_clear();
|
||||
muc_clear_invites();
|
||||
chat_sessions_clear();
|
||||
ui_disconnected();
|
||||
@ -354,10 +354,10 @@ void
|
||||
prof_handle_contact_online(char *contact, Resource *resource,
|
||||
GDateTime *last_activity)
|
||||
{
|
||||
gboolean updated = contact_list_update_presence(contact, resource, last_activity);
|
||||
gboolean updated = roster_update_presence(contact, resource, last_activity);
|
||||
|
||||
if (updated) {
|
||||
PContact result = contact_list_get_contact(contact);
|
||||
PContact result = roster_get_contact(contact);
|
||||
if (p_contact_subscription(result) != NULL) {
|
||||
if (strcmp(p_contact_subscription(result), "none") != 0) {
|
||||
const char *show = string_from_resource_presence(resource->presence);
|
||||
@ -371,11 +371,11 @@ prof_handle_contact_online(char *contact, Resource *resource,
|
||||
void
|
||||
prof_handle_contact_offline(char *contact, char *resource, char *status)
|
||||
{
|
||||
gboolean updated = contact_list_contact_offline(contact, resource, status);
|
||||
gboolean updated = roster_contact_offline(contact, resource, status);
|
||||
|
||||
if (resource != NULL && updated) {
|
||||
Jid *jid = jid_create_from_bare_and_resource(contact, resource);
|
||||
PContact result = contact_list_get_contact(contact);
|
||||
PContact result = roster_get_contact(contact);
|
||||
if (p_contact_subscription(result) != NULL) {
|
||||
if (strcmp(p_contact_subscription(result), "none") != 0) {
|
||||
ui_contact_offline(jid->fulljid, "offline", status);
|
||||
@ -489,7 +489,7 @@ _process_input(char *inp)
|
||||
}
|
||||
|
||||
inp_win_reset();
|
||||
contact_list_reset_search_attempts();
|
||||
roster_reset_search_attempts();
|
||||
ui_current_page_off();
|
||||
|
||||
return result;
|
||||
@ -584,7 +584,7 @@ _init(const int disable_tls, char *log_level)
|
||||
jabber_init(disable_tls);
|
||||
cmd_init();
|
||||
log_info("Initialising contact list");
|
||||
contact_list_init();
|
||||
roster_init();
|
||||
muc_init();
|
||||
atexit(_shutdown);
|
||||
}
|
||||
@ -594,7 +594,7 @@ _shutdown(void)
|
||||
{
|
||||
jabber_disconnect();
|
||||
jabber_shutdown();
|
||||
contact_list_free();
|
||||
roster_free();
|
||||
caps_close();
|
||||
ui_close();
|
||||
chat_log_close();
|
||||
|
@ -266,7 +266,7 @@ cons_show_wins(void)
|
||||
{
|
||||
case WIN_CHAT:
|
||||
wprintw(console->win, "%d: Chat %s", i + 1, window->from);
|
||||
PContact contact = contact_list_get_contact(window->from);
|
||||
PContact contact = roster_get_contact(window->from);
|
||||
|
||||
if (contact != NULL) {
|
||||
if (p_contact_name(contact) != NULL) {
|
||||
@ -588,8 +588,8 @@ cons_show_received_subs(void)
|
||||
void
|
||||
cons_show_sent_subs(void)
|
||||
{
|
||||
if (contact_list_has_pending_subscriptions()) {
|
||||
GSList *contacts = get_contact_list();
|
||||
if (roster_has_pending_subscriptions()) {
|
||||
GSList *contacts = roster_get_contacts();
|
||||
PContact contact = NULL;
|
||||
cons_show("Awaiting subscription responses from:");
|
||||
while (contacts != NULL) {
|
||||
@ -697,7 +697,7 @@ cons_show_disco_items(GSList *items, const char * const jid)
|
||||
void
|
||||
cons_show_status(const char * const contact)
|
||||
{
|
||||
PContact pcontact = contact_list_get_contact(contact);
|
||||
PContact pcontact = roster_get_contact(contact);
|
||||
|
||||
if (pcontact != NULL) {
|
||||
win_show_contact(console, pcontact);
|
||||
|
@ -378,7 +378,7 @@ ui_incoming_msg(const char * const from, const char * const message,
|
||||
} else {
|
||||
// if show users status first, when receiving message via delayed delivery
|
||||
if (win_created) {
|
||||
PContact pcontact = contact_list_get_contact(from);
|
||||
PContact pcontact = roster_get_contact(from);
|
||||
win_show_contact(window, pcontact);
|
||||
}
|
||||
GDateTime *time = g_date_time_new_from_timeval_utc(tv_stamp);
|
||||
@ -688,7 +688,7 @@ void
|
||||
ui_new_chat_win(const char * const to)
|
||||
{
|
||||
// if the contact is offline, show a message
|
||||
PContact contact = contact_list_get_contact(to);
|
||||
PContact contact = roster_get_contact(to);
|
||||
int win_index = _find_prof_win_index(to);
|
||||
ProfWin *window = NULL;
|
||||
|
||||
@ -798,7 +798,7 @@ ui_outgoing_msg(const char * const from, const char * const to,
|
||||
const char * const message)
|
||||
{
|
||||
// if the contact is offline, show a message
|
||||
PContact contact = contact_list_get_contact(to);
|
||||
PContact contact = roster_get_contact(to);
|
||||
int win_index = _find_prof_win_index(to);
|
||||
ProfWin *window = NULL;
|
||||
|
||||
@ -1126,7 +1126,7 @@ void
|
||||
ui_status(void)
|
||||
{
|
||||
char *recipient = ui_current_recipient();
|
||||
PContact pcontact = contact_list_get_contact(recipient);
|
||||
PContact pcontact = roster_get_contact(recipient);
|
||||
|
||||
if (pcontact != NULL) {
|
||||
win_show_contact(current, pcontact);
|
||||
|
@ -372,7 +372,7 @@ _handle_edit(int result, const wint_t ch, char *input, int *size)
|
||||
|
||||
case 127:
|
||||
case KEY_BACKSPACE:
|
||||
contact_list_reset_search_attempts();
|
||||
roster_reset_search_attempts();
|
||||
if (display_size > 0) {
|
||||
|
||||
// if at end, delete last char
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "chat_session.h"
|
||||
#include "common.h"
|
||||
#include "config/preferences.h"
|
||||
#include "contact_list.h"
|
||||
#include "jid.h"
|
||||
#include "log.h"
|
||||
#include "muc.h"
|
||||
|
@ -163,7 +163,7 @@ _iq_handle_version_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza
|
||||
if (muc_room_is_active(jidp)) {
|
||||
contact = muc_get_participant(jidp->barejid, jidp->resourcepart);
|
||||
} else {
|
||||
contact = contact_list_get_contact(jidp->barejid);
|
||||
contact = roster_get_contact(jidp->barejid);
|
||||
}
|
||||
|
||||
Resource *resource = p_contact_get_resource(contact, jidp->resourcepart);
|
||||
|
@ -72,7 +72,7 @@ _roster_handle_set(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
const char *jid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
|
||||
const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
|
||||
if (g_strcmp0(sub, "remove") == 0) {
|
||||
contact_list_remove(jid);
|
||||
roster_remove(jid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ _roster_handle_set(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
pending_out = TRUE;
|
||||
}
|
||||
|
||||
contact_list_update_subscription(jid, sub, pending_out);
|
||||
roster_update_subscription(jid, sub, pending_out);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -109,7 +109,7 @@ _roster_handle_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
pending_out = TRUE;
|
||||
}
|
||||
|
||||
gboolean added = contact_list_add(barejid, name, sub, NULL, pending_out);
|
||||
gboolean added = roster_add(barejid, name, sub, NULL, pending_out);
|
||||
|
||||
if (!added) {
|
||||
log_warning("Attempt to add contact twice: %s", barejid);
|
||||
|
@ -10,36 +10,36 @@
|
||||
|
||||
static void setup(void)
|
||||
{
|
||||
contact_list_init();
|
||||
roster_init();
|
||||
}
|
||||
|
||||
static void beforetest(void)
|
||||
{
|
||||
contact_list_clear();
|
||||
roster_clear();
|
||||
}
|
||||
|
||||
static void aftertest(void)
|
||||
{
|
||||
contact_list_clear();
|
||||
roster_clear();
|
||||
}
|
||||
|
||||
static void empty_list_when_none_added(void)
|
||||
{
|
||||
GSList *list = get_contact_list();
|
||||
GSList *list = roster_get_contacts();
|
||||
assert_is_null(list);
|
||||
}
|
||||
|
||||
static void contains_one_element(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
assert_int_equals(1, g_slist_length(list));
|
||||
}
|
||||
|
||||
static void first_element_correct(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
PContact james = list->data;
|
||||
|
||||
assert_string_equals("James", p_contact_barejid(james));
|
||||
@ -47,18 +47,18 @@ static void first_element_correct(void)
|
||||
|
||||
static void contains_two_elements(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
|
||||
assert_int_equals(2, g_slist_length(list));
|
||||
}
|
||||
|
||||
static void first_and_second_elements_correct(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
|
||||
PContact first = list->data;
|
||||
PContact second = (g_slist_next(list))->data;
|
||||
@ -69,20 +69,20 @@ static void first_and_second_elements_correct(void)
|
||||
|
||||
static void contains_three_elements(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
|
||||
assert_int_equals(3, g_slist_length(list));
|
||||
}
|
||||
|
||||
static void first_three_elements_correct(void)
|
||||
{
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
PContact bob = list->data;
|
||||
PContact dave = (g_slist_next(list))->data;
|
||||
PContact james = (g_slist_next(g_slist_next(list)))->data;
|
||||
@ -94,11 +94,11 @@ static void first_three_elements_correct(void)
|
||||
|
||||
static void add_twice_at_beginning_adds_once(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
PContact first = list->data;
|
||||
PContact second = (g_slist_next(list))->data;
|
||||
PContact third = (g_slist_next(g_slist_next(list)))->data;
|
||||
@ -111,11 +111,11 @@ static void add_twice_at_beginning_adds_once(void)
|
||||
|
||||
static void add_twice_in_middle_adds_once(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
PContact first = list->data;
|
||||
PContact second = (g_slist_next(list))->data;
|
||||
PContact third = (g_slist_next(g_slist_next(list)))->data;
|
||||
@ -128,11 +128,11 @@ static void add_twice_in_middle_adds_once(void)
|
||||
|
||||
static void add_twice_at_end_adds_once(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
PContact first = list->data;
|
||||
PContact second = (g_slist_next(list))->data;
|
||||
PContact third = (g_slist_next(g_slist_next(list)))->data;
|
||||
@ -145,8 +145,8 @@ static void add_twice_at_end_adds_once(void)
|
||||
|
||||
static void test_show_online_when_no_value(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
PContact james = list->data;
|
||||
|
||||
assert_string_equals("offline", p_contact_presence(james));
|
||||
@ -154,8 +154,8 @@ static void test_show_online_when_no_value(void)
|
||||
|
||||
static void test_status_when_no_value(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = get_contact_list();
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
GSList *list = roster_get_contacts();
|
||||
PContact james = list->data;
|
||||
|
||||
assert_is_null(p_contact_status(james));
|
||||
@ -163,14 +163,14 @@ static void test_status_when_no_value(void)
|
||||
|
||||
static void find_first_exists(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
|
||||
char *search = (char *) malloc(2 * sizeof(char));
|
||||
strcpy(search, "B");
|
||||
|
||||
char *result = contact_list_find_contact(search);
|
||||
char *result = roster_find_contact(search);
|
||||
assert_string_equals("Bob", result);
|
||||
free(result);
|
||||
free(search);
|
||||
@ -178,50 +178,50 @@ static void find_first_exists(void)
|
||||
|
||||
static void find_second_exists(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
|
||||
char *result = contact_list_find_contact("Dav");
|
||||
char *result = roster_find_contact("Dav");
|
||||
assert_string_equals("Dave", result);
|
||||
free(result);
|
||||
}
|
||||
|
||||
static void find_third_exists(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
|
||||
char *result = contact_list_find_contact("Ja");
|
||||
char *result = roster_find_contact("Ja");
|
||||
assert_string_equals("James", result);
|
||||
free(result);
|
||||
}
|
||||
|
||||
static void find_returns_null(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
|
||||
char *result = contact_list_find_contact("Mike");
|
||||
char *result = roster_find_contact("Mike");
|
||||
assert_is_null(result);
|
||||
}
|
||||
|
||||
static void find_on_empty_returns_null(void)
|
||||
{
|
||||
char *result = contact_list_find_contact("James");
|
||||
char *result = roster_find_contact("James");
|
||||
assert_is_null(result);
|
||||
}
|
||||
|
||||
static void find_twice_returns_second_when_two_match(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamie", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamie", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
|
||||
char *result1 = contact_list_find_contact("Jam");
|
||||
char *result2 = contact_list_find_contact(result1);
|
||||
char *result1 = roster_find_contact("Jam");
|
||||
char *result2 = roster_find_contact(result1);
|
||||
assert_string_equals("Jamie", result2);
|
||||
free(result1);
|
||||
free(result2);
|
||||
@ -229,22 +229,22 @@ static void find_twice_returns_second_when_two_match(void)
|
||||
|
||||
static void find_five_times_finds_fifth(void)
|
||||
{
|
||||
contact_list_add("Jama", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamb", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Mike", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamm", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamn", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Matt", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamo", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamy", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamz", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jama", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamb", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Mike", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamm", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamn", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Matt", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamo", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamy", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamz", NULL, NULL, NULL, FALSE);
|
||||
|
||||
char *result1 = contact_list_find_contact("Jam");
|
||||
char *result2 = contact_list_find_contact(result1);
|
||||
char *result3 = contact_list_find_contact(result2);
|
||||
char *result4 = contact_list_find_contact(result3);
|
||||
char *result5 = contact_list_find_contact(result4);
|
||||
char *result1 = roster_find_contact("Jam");
|
||||
char *result2 = roster_find_contact(result1);
|
||||
char *result3 = roster_find_contact(result2);
|
||||
char *result4 = roster_find_contact(result3);
|
||||
char *result5 = roster_find_contact(result4);
|
||||
assert_string_equals("Jamo", result5);
|
||||
free(result1);
|
||||
free(result2);
|
||||
@ -255,21 +255,21 @@ static void find_five_times_finds_fifth(void)
|
||||
|
||||
static void find_twice_returns_first_when_two_match_and_reset(void)
|
||||
{
|
||||
contact_list_add("James", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Jamie", NULL, NULL, NULL, FALSE);
|
||||
contact_list_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Jamie", NULL, NULL, NULL, FALSE);
|
||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||
|
||||
char *result1 = contact_list_find_contact("Jam");
|
||||
contact_list_reset_search_attempts();
|
||||
char *result2 = contact_list_find_contact(result1);
|
||||
char *result1 = roster_find_contact("Jam");
|
||||
roster_reset_search_attempts();
|
||||
char *result2 = roster_find_contact(result1);
|
||||
assert_string_equals("James", result2);
|
||||
free(result1);
|
||||
free(result2);
|
||||
}
|
||||
|
||||
void register_contact_list_tests(void)
|
||||
void register_roster_tests(void)
|
||||
{
|
||||
TEST_MODULE("contact_list tests");
|
||||
TEST_MODULE("roster tests");
|
||||
SETUP(setup);
|
||||
BEFORETEST(beforetest);
|
||||
AFTERTEST(aftertest);
|
@ -4,7 +4,7 @@
|
||||
int main(void)
|
||||
{
|
||||
register_history_tests();
|
||||
register_contact_list_tests();
|
||||
register_roster_tests();
|
||||
register_common_tests();
|
||||
register_autocomplete_tests();
|
||||
register_parser_tests();
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define TESTSUITE_H
|
||||
|
||||
void register_history_tests(void);
|
||||
void register_contact_list_tests(void);
|
||||
void register_roster_tests(void);
|
||||
void register_common_tests(void);
|
||||
void register_autocomplete_tests(void);
|
||||
void register_parser_tests(void);
|
||||
|
Loading…
Reference in New Issue
Block a user