mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into osx-functional
This commit is contained in:
commit
700ff23188
@ -2599,7 +2599,20 @@ cmd_autocomplete(ProfWin *window, const char *const input)
|
|||||||
void
|
void
|
||||||
cmd_reset_autocomplete(ProfWin *window)
|
cmd_reset_autocomplete(ProfWin *window)
|
||||||
{
|
{
|
||||||
roster_reset_search_attempts();
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
roster_reset_search_attempts();
|
||||||
|
|
||||||
|
if (window->type == WIN_CHAT) {
|
||||||
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||||
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
|
PContact contact = roster_get_contact(chatwin->barejid);
|
||||||
|
if (contact) {
|
||||||
|
p_contact_resource_ac_reset(contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
muc_invites_reset_ac();
|
muc_invites_reset_ac();
|
||||||
accounts_reset_all_search();
|
accounts_reset_all_search();
|
||||||
accounts_reset_enabled_search();
|
accounts_reset_enabled_search();
|
||||||
@ -2692,15 +2705,6 @@ cmd_reset_autocomplete(ProfWin *window)
|
|||||||
script_show_ac = NULL;
|
script_show_ac = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->type == WIN_CHAT) {
|
|
||||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
|
||||||
if (contact) {
|
|
||||||
p_contact_resource_ac_reset(contact);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window->type == WIN_MUC) {
|
if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
@ -2836,6 +2840,8 @@ _cmd_complete_parameters(ProfWin *window, const char *const input)
|
|||||||
int i;
|
int i;
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
|
||||||
// autocomplete boolean settings
|
// autocomplete boolean settings
|
||||||
gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype",
|
gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype",
|
||||||
"/flash", "/splash", "/chlog", "/grlog", "/history", "/vercheck",
|
"/flash", "/splash", "/chlog", "/grlog", "/history", "/vercheck",
|
||||||
@ -2869,7 +2875,7 @@ _cmd_complete_parameters(ProfWin *window, const char *const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// otherwise autocomplete using roster
|
// otherwise autocomplete using roster
|
||||||
} else {
|
} else if (conn_status == JABBER_CONNECTED) {
|
||||||
gchar *contact_choices[] = { "/msg", "/info", "/status" };
|
gchar *contact_choices[] = { "/msg", "/info", "/status" };
|
||||||
// Remove quote character before and after names when doing autocomplete
|
// Remove quote character before and after names when doing autocomplete
|
||||||
char *unquoted = strip_arg_quotes(input);
|
char *unquoted = strip_arg_quotes(input);
|
||||||
@ -2891,9 +2897,11 @@ _cmd_complete_parameters(ProfWin *window, const char *const input)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = autocomplete_param_with_func(input, "/invite", roster_contact_autocomplete);
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
if (result) {
|
result = autocomplete_param_with_func(input, "/invite", roster_contact_autocomplete);
|
||||||
return result;
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *invite_choices[] = { "/decline", "/join" };
|
gchar *invite_choices[] = { "/decline", "/join" };
|
||||||
@ -3014,15 +3022,18 @@ _who_autocomplete(ProfWin *window, const char *const input)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int i = 0;
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
gchar *group_commands[] = { "/who any", "/who online", "/who offline",
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
"/who chat", "/who away", "/who xa", "/who dnd", "/who available",
|
int i = 0;
|
||||||
"/who unavailable" };
|
gchar *group_commands[] = { "/who any", "/who online", "/who offline",
|
||||||
|
"/who chat", "/who away", "/who xa", "/who dnd", "/who available",
|
||||||
|
"/who unavailable" };
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(group_commands); i++) {
|
for (i = 0; i < ARRAY_SIZE(group_commands); i++) {
|
||||||
result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete);
|
result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3055,18 +3066,23 @@ _roster_autocomplete(ProfWin *window, const char *const input)
|
|||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete);
|
|
||||||
if (result) {
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
return result;
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
}
|
result = autocomplete_param_with_func(input, "/roster nick", roster_barejid_autocomplete);
|
||||||
result = autocomplete_param_with_func(input, "/roster clearnick", roster_barejid_autocomplete);
|
if (result) {
|
||||||
if (result) {
|
return result;
|
||||||
return result;
|
}
|
||||||
}
|
result = autocomplete_param_with_func(input, "/roster clearnick", roster_barejid_autocomplete);
|
||||||
result = autocomplete_param_with_func(input, "/roster remove", roster_barejid_autocomplete);
|
if (result) {
|
||||||
if (result) {
|
return result;
|
||||||
return result;
|
}
|
||||||
|
result = autocomplete_param_with_func(input, "/roster remove", roster_barejid_autocomplete);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = autocomplete_param_with_ac(input, "/roster remove_all", roster_remove_all_ac, TRUE);
|
result = autocomplete_param_with_ac(input, "/roster remove_all", roster_remove_all_ac, TRUE);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
@ -3119,27 +3135,32 @@ static char*
|
|||||||
_group_autocomplete(ProfWin *window, const char *const input)
|
_group_autocomplete(ProfWin *window, const char *const input)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
result = autocomplete_param_with_func(input, "/group show", roster_group_autocomplete);
|
|
||||||
if (result) {
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
return result;
|
|
||||||
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
result = autocomplete_param_with_func(input, "/group show", roster_group_autocomplete);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = autocomplete_param_no_with_func(input, "/group add", 4, roster_contact_autocomplete);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = autocomplete_param_no_with_func(input, "/group remove", 4, roster_contact_autocomplete);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = autocomplete_param_with_func(input, "/group add", roster_group_autocomplete);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = autocomplete_param_with_func(input, "/group remove", roster_group_autocomplete);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = autocomplete_param_no_with_func(input, "/group add", 4, roster_contact_autocomplete);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = autocomplete_param_no_with_func(input, "/group remove", 4, roster_contact_autocomplete);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = autocomplete_param_with_func(input, "/group add", roster_group_autocomplete);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = autocomplete_param_with_func(input, "/group remove", roster_group_autocomplete);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
result = autocomplete_param_with_ac(input, "/group", group_ac, TRUE);
|
result = autocomplete_param_with_ac(input, "/group", group_ac, TRUE);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
@ -3361,9 +3382,13 @@ _otr_autocomplete(ProfWin *window, const char *const input)
|
|||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
found = autocomplete_param_with_func(input, "/otr start", roster_contact_autocomplete);
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
if (found) {
|
|
||||||
return found;
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
found = autocomplete_param_with_func(input, "/otr start", roster_contact_autocomplete);
|
||||||
|
if (found) {
|
||||||
|
return found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
found = autocomplete_param_with_ac(input, "/otr log", otr_log_ac, TRUE);
|
found = autocomplete_param_with_ac(input, "/otr log", otr_log_ac, TRUE);
|
||||||
@ -3372,24 +3397,25 @@ _otr_autocomplete(ProfWin *window, const char *const input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// /otr policy always user@server.com
|
// /otr policy always user@server.com
|
||||||
gboolean result;
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
gchar **args = parse_args(input, 3, 3, &result);
|
gboolean result;
|
||||||
if (result && (strcmp(args[0], "policy") == 0)) {
|
gchar **args = parse_args(input, 3, 3, &result);
|
||||||
GString *beginning = g_string_new("/otr ");
|
if (result && (strcmp(args[0], "policy") == 0)) {
|
||||||
g_string_append(beginning, args[0]);
|
GString *beginning = g_string_new("/otr ");
|
||||||
g_string_append(beginning, " ");
|
g_string_append(beginning, args[0]);
|
||||||
g_string_append(beginning, args[1]);
|
g_string_append(beginning, " ");
|
||||||
|
g_string_append(beginning, args[1]);
|
||||||
|
|
||||||
found = autocomplete_param_with_func(input, beginning->str, roster_contact_autocomplete);
|
found = autocomplete_param_with_func(input, beginning->str, roster_contact_autocomplete);
|
||||||
g_string_free(beginning, TRUE);
|
g_string_free(beginning, TRUE);
|
||||||
if (found) {
|
if (found) {
|
||||||
g_strfreev(args);
|
g_strfreev(args);
|
||||||
return found;
|
return found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
g_strfreev(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_strfreev(args);
|
|
||||||
|
|
||||||
found = autocomplete_param_with_ac(input, "/otr policy", otr_policy_ac, TRUE);
|
found = autocomplete_param_with_ac(input, "/otr policy", otr_policy_ac, TRUE);
|
||||||
if (found) {
|
if (found) {
|
||||||
return found;
|
return found;
|
||||||
@ -3408,9 +3434,13 @@ _pgp_autocomplete(ProfWin *window, const char *const input)
|
|||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
found = autocomplete_param_with_func(input, "/pgp start", roster_contact_autocomplete);
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
if (found) {
|
|
||||||
return found;
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
found = autocomplete_param_with_func(input, "/pgp start", roster_contact_autocomplete);
|
||||||
|
if (found) {
|
||||||
|
return found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
found = autocomplete_param_with_ac(input, "/pgp log", pgp_log_ac, TRUE);
|
found = autocomplete_param_with_ac(input, "/pgp log", pgp_log_ac, TRUE);
|
||||||
@ -3438,9 +3468,11 @@ _pgp_autocomplete(ProfWin *window, const char *const input)
|
|||||||
g_strfreev(args);
|
g_strfreev(args);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
found = autocomplete_param_with_func(input, "/pgp setkey", roster_barejid_autocomplete);
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
if (found) {
|
found = autocomplete_param_with_func(input, "/pgp setkey", roster_barejid_autocomplete);
|
||||||
return found;
|
if (found) {
|
||||||
|
return found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
found = autocomplete_param_with_ac(input, "/pgp", pgp_ac, TRUE);
|
found = autocomplete_param_with_ac(input, "/pgp", pgp_ac, TRUE);
|
||||||
@ -3529,7 +3561,8 @@ _resource_autocomplete(ProfWin *window, const char *const input)
|
|||||||
{
|
{
|
||||||
char *found = NULL;
|
char *found = NULL;
|
||||||
|
|
||||||
if (window->type == WIN_CHAT) {
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
if (conn_status == JABBER_CONNECTED && window->type == WIN_CHAT) {
|
||||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
PContact contact = roster_get_contact(chatwin->barejid);
|
||||||
|
@ -2309,6 +2309,13 @@ cmd_resource(ProfWin *window, const char *const command, gchar **args)
|
|||||||
cons_show("Resource can only be changed in chat windows.");
|
cons_show("Resource can only be changed in chat windows.");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
|
cons_show("You are not currently connected.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||||
|
|
||||||
if (g_strcmp0(cmd, "set") == 0) {
|
if (g_strcmp0(cmd, "set") == 0) {
|
||||||
|
@ -76,7 +76,7 @@ cl_ev_disconnect(void)
|
|||||||
ui_disconnected();
|
ui_disconnected();
|
||||||
ui_close_all_wins();
|
ui_close_all_wins();
|
||||||
jabber_disconnect();
|
jabber_disconnect();
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
muc_invites_clear();
|
muc_invites_clear();
|
||||||
chat_sessions_clear();
|
chat_sessions_clear();
|
||||||
tlscerts_clear_current();
|
tlscerts_clear_current();
|
||||||
|
@ -64,6 +64,8 @@ sv_ev_login_account_success(char *account_name, int secured)
|
|||||||
{
|
{
|
||||||
ProfAccount *account = accounts_get_account(account_name);
|
ProfAccount *account = accounts_get_account(account_name);
|
||||||
|
|
||||||
|
roster_create();
|
||||||
|
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
otr_on_connect(account);
|
otr_on_connect(account);
|
||||||
#endif
|
#endif
|
||||||
@ -150,7 +152,7 @@ sv_ev_lost_connection(void)
|
|||||||
{
|
{
|
||||||
cons_show_error("Lost connection.");
|
cons_show_error("Lost connection.");
|
||||||
|
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
muc_invites_clear();
|
muc_invites_clear();
|
||||||
chat_sessions_clear();
|
chat_sessions_clear();
|
||||||
ui_disconnected();
|
ui_disconnected();
|
||||||
@ -168,8 +170,7 @@ sv_ev_failed_login(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sv_ev_room_invite(jabber_invite_t invite_type,
|
sv_ev_room_invite(jabber_invite_t invite_type, const char *const invitor, const char *const room,
|
||||||
const char *const invitor, const char *const room,
|
|
||||||
const char *const reason, const char *const password)
|
const char *const reason, const char *const password)
|
||||||
{
|
{
|
||||||
if (!muc_active(room) && !muc_invites_contain(room)) {
|
if (!muc_active(room) && !muc_invites_contain(room)) {
|
||||||
|
@ -84,9 +84,13 @@ cb_policy(void *opdata, ConnContext *context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cb_is_logged_in(void *opdata, const char *accountname,
|
cb_is_logged_in(void *opdata, const char *accountname, const char *protocol, const char *recipient)
|
||||||
const char *protocol, const char *recipient)
|
|
||||||
{
|
{
|
||||||
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
|
return PRESENCE_OFFLINE;
|
||||||
|
}
|
||||||
|
|
||||||
PContact contact = roster_get_contact(recipient);
|
PContact contact = roster_get_contact(recipient);
|
||||||
|
|
||||||
// not in roster
|
// not in roster
|
||||||
|
@ -337,7 +337,6 @@ _init(char *log_level)
|
|||||||
jabber_init();
|
jabber_init();
|
||||||
cmd_init();
|
cmd_init();
|
||||||
log_info("Initialising contact list");
|
log_info("Initialising contact list");
|
||||||
roster_init();
|
|
||||||
muc_init();
|
muc_init();
|
||||||
tlscerts_init();
|
tlscerts_init();
|
||||||
scripts_init();
|
scripts_init();
|
||||||
@ -361,10 +360,13 @@ _shutdown(void)
|
|||||||
ui_clear_win_title();
|
ui_clear_win_title();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui_close_all_wins();
|
|
||||||
jabber_disconnect();
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
cl_ev_disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
jabber_shutdown();
|
jabber_shutdown();
|
||||||
roster_free();
|
|
||||||
muc_close();
|
muc_close();
|
||||||
caps_close();
|
caps_close();
|
||||||
ui_close();
|
ui_close();
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@ -44,24 +46,28 @@
|
|||||||
#include "tools/autocomplete.h"
|
#include "tools/autocomplete.h"
|
||||||
#include "config/preferences.h"
|
#include "config/preferences.h"
|
||||||
|
|
||||||
// nicknames
|
typedef struct prof_roster_t {
|
||||||
static Autocomplete name_ac;
|
// contacts, indexed on barejid
|
||||||
|
GHashTable *contacts;
|
||||||
|
|
||||||
// barejids
|
// nicknames
|
||||||
static Autocomplete barejid_ac;
|
Autocomplete name_ac;
|
||||||
|
|
||||||
// fulljids
|
// barejids
|
||||||
static Autocomplete fulljid_ac;
|
Autocomplete barejid_ac;
|
||||||
|
|
||||||
// groups
|
// fulljids
|
||||||
static Autocomplete groups_ac;
|
Autocomplete fulljid_ac;
|
||||||
GHashTable *group_count;
|
|
||||||
|
|
||||||
// contacts, indexed on barejid
|
// nickname to barejid map
|
||||||
static GHashTable *contacts;
|
GHashTable *name_to_barejid;
|
||||||
|
|
||||||
// nickname to jid map
|
// groups
|
||||||
static GHashTable *name_to_barejid;
|
Autocomplete groups_ac;
|
||||||
|
GHashTable *group_count;
|
||||||
|
} ProfRoster;
|
||||||
|
|
||||||
|
static ProfRoster *roster = NULL;
|
||||||
|
|
||||||
static gboolean _key_equals(void *key1, void *key2);
|
static gboolean _key_equals(void *key1, void *key2);
|
||||||
static gboolean _datetimes_equal(GDateTime *dt1, GDateTime *dt2);
|
static gboolean _datetimes_equal(GDateTime *dt1, GDateTime *dt2);
|
||||||
@ -71,23 +77,42 @@ static gint _compare_name(PContact a, PContact b);
|
|||||||
static gint _compare_presence(PContact a, PContact b);
|
static gint _compare_presence(PContact a, PContact b);
|
||||||
|
|
||||||
void
|
void
|
||||||
roster_clear(void)
|
roster_create(void)
|
||||||
{
|
{
|
||||||
autocomplete_clear(name_ac);
|
assert(roster == NULL);
|
||||||
autocomplete_clear(barejid_ac);
|
|
||||||
autocomplete_clear(fulljid_ac);
|
roster = malloc(sizeof(ProfRoster));
|
||||||
autocomplete_clear(groups_ac);
|
roster->contacts = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, g_free, (GDestroyNotify)p_contact_free);
|
||||||
g_hash_table_destroy(contacts);
|
roster->name_ac = autocomplete_new();
|
||||||
contacts = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, g_free, (GDestroyNotify)p_contact_free);
|
roster->barejid_ac = autocomplete_new();
|
||||||
g_hash_table_destroy(name_to_barejid);
|
roster->fulljid_ac = autocomplete_new();
|
||||||
name_to_barejid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
roster->name_to_barejid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
||||||
g_hash_table_destroy(group_count);
|
roster->groups_ac = autocomplete_new();
|
||||||
group_count = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
|
roster->group_count = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
roster_destroy(void)
|
||||||
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
|
g_hash_table_destroy(roster->contacts);
|
||||||
|
autocomplete_free(roster->name_ac);
|
||||||
|
autocomplete_free(roster->barejid_ac);
|
||||||
|
autocomplete_free(roster->fulljid_ac);
|
||||||
|
g_hash_table_destroy(roster->name_to_barejid);
|
||||||
|
autocomplete_free(roster->groups_ac);
|
||||||
|
g_hash_table_destroy(roster->group_count);
|
||||||
|
|
||||||
|
free(roster);
|
||||||
|
roster = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
roster_update_presence(const char *const barejid, Resource *resource, GDateTime *last_activity)
|
roster_update_presence(const char *const barejid, Resource *resource, GDateTime *last_activity)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
assert(barejid != NULL);
|
assert(barejid != NULL);
|
||||||
assert(resource != NULL);
|
assert(resource != NULL);
|
||||||
|
|
||||||
@ -100,7 +125,7 @@ roster_update_presence(const char *const barejid, Resource *resource, GDateTime
|
|||||||
}
|
}
|
||||||
p_contact_set_presence(contact, resource);
|
p_contact_set_presence(contact, resource);
|
||||||
Jid *jid = jid_create_from_bare_and_resource(barejid, resource->name);
|
Jid *jid = jid_create_from_bare_and_resource(barejid, resource->name);
|
||||||
autocomplete_add(fulljid_ac, jid->fulljid);
|
autocomplete_add(roster->fulljid_ac, jid->fulljid);
|
||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -109,8 +134,10 @@ roster_update_presence(const char *const barejid, Resource *resource, GDateTime
|
|||||||
PContact
|
PContact
|
||||||
roster_get_contact(const char *const barejid)
|
roster_get_contact(const char *const barejid)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
gchar *barejidlower = g_utf8_strdown(barejid, -1);
|
gchar *barejidlower = g_utf8_strdown(barejid, -1);
|
||||||
PContact contact = g_hash_table_lookup(contacts, barejidlower);
|
PContact contact = g_hash_table_lookup(roster->contacts, barejidlower);
|
||||||
g_free(barejidlower);
|
g_free(barejidlower);
|
||||||
|
|
||||||
return contact;
|
return contact;
|
||||||
@ -119,6 +146,8 @@ roster_get_contact(const char *const barejid)
|
|||||||
char*
|
char*
|
||||||
roster_get_msg_display_name(const char *const barejid, const char *const resource)
|
roster_get_msg_display_name(const char *const barejid, const char *const resource)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
GString *result = g_string_new("");
|
GString *result = g_string_new("");
|
||||||
|
|
||||||
PContact contact = roster_get_contact(barejid);
|
PContact contact = roster_get_contact(barejid);
|
||||||
@ -146,6 +175,8 @@ roster_get_msg_display_name(const char *const barejid, const char *const resourc
|
|||||||
gboolean
|
gboolean
|
||||||
roster_contact_offline(const char *const barejid, const char *const resource, const char *const status)
|
roster_contact_offline(const char *const barejid, const char *const resource, const char *const status)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
PContact contact = roster_get_contact(barejid);
|
PContact contact = roster_get_contact(barejid);
|
||||||
|
|
||||||
if (contact == NULL) {
|
if (contact == NULL) {
|
||||||
@ -157,7 +188,7 @@ roster_contact_offline(const char *const barejid, const char *const resource, co
|
|||||||
gboolean result = p_contact_remove_resource(contact, resource);
|
gboolean result = p_contact_remove_resource(contact, resource);
|
||||||
if (result == TRUE) {
|
if (result == TRUE) {
|
||||||
Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
|
Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
|
||||||
autocomplete_remove(fulljid_ac, jid->fulljid);
|
autocomplete_remove(roster->fulljid_ac, jid->fulljid);
|
||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,36 +199,19 @@ roster_contact_offline(const char *const barejid, const char *const resource, co
|
|||||||
void
|
void
|
||||||
roster_reset_search_attempts(void)
|
roster_reset_search_attempts(void)
|
||||||
{
|
{
|
||||||
autocomplete_reset(name_ac);
|
assert(roster != NULL);
|
||||||
autocomplete_reset(barejid_ac);
|
|
||||||
autocomplete_reset(fulljid_ac);
|
|
||||||
autocomplete_reset(groups_ac);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
autocomplete_reset(roster->name_ac);
|
||||||
roster_init(void)
|
autocomplete_reset(roster->barejid_ac);
|
||||||
{
|
autocomplete_reset(roster->fulljid_ac);
|
||||||
name_ac = autocomplete_new();
|
autocomplete_reset(roster->groups_ac);
|
||||||
barejid_ac = autocomplete_new();
|
|
||||||
fulljid_ac = autocomplete_new();
|
|
||||||
groups_ac = autocomplete_new();
|
|
||||||
contacts = g_hash_table_new_full(g_str_hash, (GEqualFunc)_key_equals, g_free, (GDestroyNotify)p_contact_free);
|
|
||||||
name_to_barejid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
|
||||||
group_count = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
roster_free(void)
|
|
||||||
{
|
|
||||||
autocomplete_free(name_ac);
|
|
||||||
autocomplete_free(barejid_ac);
|
|
||||||
autocomplete_free(fulljid_ac);
|
|
||||||
autocomplete_free(groups_ac);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
roster_change_name(PContact contact, const char *const new_name)
|
roster_change_name(PContact contact, const char *const new_name)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
assert(contact != NULL);
|
assert(contact != NULL);
|
||||||
|
|
||||||
const char *current_name = NULL;
|
const char *current_name = NULL;
|
||||||
@ -214,9 +228,11 @@ roster_change_name(PContact contact, const char *const new_name)
|
|||||||
void
|
void
|
||||||
roster_remove(const char *const name, const char *const barejid)
|
roster_remove(const char *const name, const char *const barejid)
|
||||||
{
|
{
|
||||||
autocomplete_remove(barejid_ac, barejid);
|
assert(roster != NULL);
|
||||||
autocomplete_remove(name_ac, name);
|
|
||||||
g_hash_table_remove(name_to_barejid, name);
|
autocomplete_remove(roster->barejid_ac, barejid);
|
||||||
|
autocomplete_remove(roster->name_ac, name);
|
||||||
|
g_hash_table_remove(roster->name_to_barejid, name);
|
||||||
|
|
||||||
// remove each fulljid
|
// remove each fulljid
|
||||||
PContact contact = roster_get_contact(barejid);
|
PContact contact = roster_get_contact(barejid);
|
||||||
@ -226,7 +242,7 @@ roster_remove(const char *const name, const char *const barejid)
|
|||||||
GString *fulljid = g_string_new(strdup(barejid));
|
GString *fulljid = g_string_new(strdup(barejid));
|
||||||
g_string_append(fulljid, "/");
|
g_string_append(fulljid, "/");
|
||||||
g_string_append(fulljid, resources->data);
|
g_string_append(fulljid, resources->data);
|
||||||
autocomplete_remove(fulljid_ac, fulljid->str);
|
autocomplete_remove(roster->fulljid_ac, fulljid->str);
|
||||||
g_string_free(fulljid, TRUE);
|
g_string_free(fulljid, TRUE);
|
||||||
resources = g_list_next(resources);
|
resources = g_list_next(resources);
|
||||||
}
|
}
|
||||||
@ -236,14 +252,14 @@ roster_remove(const char *const name, const char *const barejid)
|
|||||||
GSList *curr = groups;
|
GSList *curr = groups;
|
||||||
while (curr) {
|
while (curr) {
|
||||||
gchar *group = curr->data;
|
gchar *group = curr->data;
|
||||||
if (g_hash_table_contains(group_count, group)) {
|
if (g_hash_table_contains(roster->group_count, group)) {
|
||||||
int count = GPOINTER_TO_INT(g_hash_table_lookup(group_count, group));
|
int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, group));
|
||||||
count--;
|
count--;
|
||||||
if (count < 1) {
|
if (count < 1) {
|
||||||
g_hash_table_remove(group_count, group);
|
g_hash_table_remove(roster->group_count, group);
|
||||||
autocomplete_remove(groups_ac, group);
|
autocomplete_remove(roster->groups_ac, group);
|
||||||
} else {
|
} else {
|
||||||
g_hash_table_insert(group_count, strdup(group), GINT_TO_POINTER(count));
|
g_hash_table_insert(roster->group_count, strdup(group), GINT_TO_POINTER(count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curr = g_slist_next(curr);
|
curr = g_slist_next(curr);
|
||||||
@ -251,13 +267,15 @@ roster_remove(const char *const name, const char *const barejid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove the contact
|
// remove the contact
|
||||||
g_hash_table_remove(contacts, barejid);
|
g_hash_table_remove(roster->contacts, barejid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
|
roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
|
||||||
gboolean pending_out)
|
gboolean pending_out)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
PContact contact = roster_get_contact(barejid);
|
PContact contact = roster_get_contact(barejid);
|
||||||
assert(contact != NULL);
|
assert(contact != NULL);
|
||||||
|
|
||||||
@ -281,14 +299,14 @@ roster_update(const char *const barejid, const char *const name, GSList *groups,
|
|||||||
if (!p_contact_in_group(contact, new_group)) {
|
if (!p_contact_in_group(contact, new_group)) {
|
||||||
|
|
||||||
// group doesn't yet exist
|
// group doesn't yet exist
|
||||||
if (!g_hash_table_contains(group_count, new_group)) {
|
if (!g_hash_table_contains(roster->group_count, new_group)) {
|
||||||
g_hash_table_insert(group_count, strdup(new_group), GINT_TO_POINTER(1));
|
g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(1));
|
||||||
autocomplete_add(groups_ac, curr_new_group->data);
|
autocomplete_add(roster->groups_ac, curr_new_group->data);
|
||||||
|
|
||||||
// increment count
|
// increment count
|
||||||
} else {
|
} else {
|
||||||
int count = GPOINTER_TO_INT(g_hash_table_lookup(group_count, new_group));
|
int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, new_group));
|
||||||
g_hash_table_insert(group_count, strdup(new_group), GINT_TO_POINTER(count + 1));
|
g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(count + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curr_new_group = g_slist_next(curr_new_group);
|
curr_new_group = g_slist_next(curr_new_group);
|
||||||
@ -300,14 +318,14 @@ roster_update(const char *const barejid, const char *const name, GSList *groups,
|
|||||||
char *old_group = curr_old_group->data;
|
char *old_group = curr_old_group->data;
|
||||||
// removed from group
|
// removed from group
|
||||||
if (!g_slist_find_custom(groups, old_group, (GCompareFunc)g_strcmp0)) {
|
if (!g_slist_find_custom(groups, old_group, (GCompareFunc)g_strcmp0)) {
|
||||||
if (g_hash_table_contains(group_count, old_group)) {
|
if (g_hash_table_contains(roster->group_count, old_group)) {
|
||||||
int count = GPOINTER_TO_INT(g_hash_table_lookup(group_count, old_group));
|
int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, old_group));
|
||||||
count--;
|
count--;
|
||||||
if (count < 1) {
|
if (count < 1) {
|
||||||
g_hash_table_remove(group_count, old_group);
|
g_hash_table_remove(roster->group_count, old_group);
|
||||||
autocomplete_remove(groups_ac, old_group);
|
autocomplete_remove(roster->groups_ac, old_group);
|
||||||
} else {
|
} else {
|
||||||
g_hash_table_insert(group_count, strdup(old_group), GINT_TO_POINTER(count));
|
g_hash_table_insert(roster->group_count, strdup(old_group), GINT_TO_POINTER(count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,31 +340,32 @@ gboolean
|
|||||||
roster_add(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
|
roster_add(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
|
||||||
gboolean pending_out)
|
gboolean pending_out)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
PContact contact = roster_get_contact(barejid);
|
PContact contact = roster_get_contact(barejid);
|
||||||
if (contact) {
|
if (contact) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
contact = p_contact_new(barejid, name, groups, subscription, NULL,
|
contact = p_contact_new(barejid, name, groups, subscription, NULL, pending_out);
|
||||||
pending_out);
|
|
||||||
|
|
||||||
// add groups
|
// add groups
|
||||||
GSList *curr_new_group = groups;
|
GSList *curr_new_group = groups;
|
||||||
while (curr_new_group) {
|
while (curr_new_group) {
|
||||||
char *new_group = curr_new_group->data;
|
char *new_group = curr_new_group->data;
|
||||||
if (g_hash_table_contains(group_count, new_group)) {
|
if (g_hash_table_contains(roster->group_count, new_group)) {
|
||||||
int count = GPOINTER_TO_INT(g_hash_table_lookup(group_count, new_group));
|
int count = GPOINTER_TO_INT(g_hash_table_lookup(roster->group_count, new_group));
|
||||||
g_hash_table_insert(group_count, strdup(new_group), GINT_TO_POINTER(count + 1));
|
g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(count + 1));
|
||||||
} else {
|
} else {
|
||||||
g_hash_table_insert(group_count, strdup(new_group), GINT_TO_POINTER(1));
|
g_hash_table_insert(roster->group_count, strdup(new_group), GINT_TO_POINTER(1));
|
||||||
autocomplete_add(groups_ac, new_group);
|
autocomplete_add(roster->groups_ac, new_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_new_group = g_slist_next(curr_new_group);
|
curr_new_group = g_slist_next(curr_new_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_insert(contacts, strdup(barejid), contact);
|
g_hash_table_insert(roster->contacts, strdup(barejid), contact);
|
||||||
autocomplete_add(barejid_ac, barejid);
|
autocomplete_add(roster->barejid_ac, barejid);
|
||||||
_add_name_and_barejid(name, barejid);
|
_add_name_and_barejid(name, barejid);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -355,8 +374,10 @@ roster_add(const char *const barejid, const char *const name, GSList *groups, co
|
|||||||
char*
|
char*
|
||||||
roster_barejid_from_name(const char *const name)
|
roster_barejid_from_name(const char *const name)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
return g_hash_table_lookup(name_to_barejid, name);
|
return g_hash_table_lookup(roster->name_to_barejid, name);
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -365,12 +386,14 @@ roster_barejid_from_name(const char *const name)
|
|||||||
GSList*
|
GSList*
|
||||||
roster_get_contacts_by_presence(const char *const presence)
|
roster_get_contacts_by_presence(const char *const presence)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key;
|
gpointer key;
|
||||||
gpointer value;
|
gpointer value;
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, contacts);
|
g_hash_table_iter_init(&iter, roster->contacts);
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
PContact contact = (PContact)value;
|
PContact contact = (PContact)value;
|
||||||
if (g_strcmp0(p_contact_presence(contact), presence) == 0) {
|
if (g_strcmp0(p_contact_presence(contact), presence) == 0) {
|
||||||
@ -385,6 +408,8 @@ roster_get_contacts_by_presence(const char *const presence)
|
|||||||
GSList*
|
GSList*
|
||||||
roster_get_contacts(roster_ord_t order, gboolean include_offline)
|
roster_get_contacts(roster_ord_t order, gboolean include_offline)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key;
|
gpointer key;
|
||||||
@ -397,7 +422,7 @@ roster_get_contacts(roster_ord_t order, gboolean include_offline)
|
|||||||
cmp_func = (GCompareFunc) _compare_name;
|
cmp_func = (GCompareFunc) _compare_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, contacts);
|
g_hash_table_iter_init(&iter, roster->contacts);
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
PContact contact = value;
|
PContact contact = value;
|
||||||
const char *presence = p_contact_presence(contact);
|
const char *presence = p_contact_presence(contact);
|
||||||
@ -415,12 +440,14 @@ roster_get_contacts(roster_ord_t order, gboolean include_offline)
|
|||||||
GSList*
|
GSList*
|
||||||
roster_get_contacts_online(void)
|
roster_get_contacts_online(void)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key;
|
gpointer key;
|
||||||
gpointer value;
|
gpointer value;
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, contacts);
|
g_hash_table_iter_init(&iter, roster->contacts);
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
if(strcmp(p_contact_presence(value), "offline"))
|
if(strcmp(p_contact_presence(value), "offline"))
|
||||||
result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_name);
|
result = g_slist_insert_sorted(result, value, (GCompareFunc)_compare_name);
|
||||||
@ -433,11 +460,13 @@ roster_get_contacts_online(void)
|
|||||||
gboolean
|
gboolean
|
||||||
roster_has_pending_subscriptions(void)
|
roster_has_pending_subscriptions(void)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key;
|
gpointer key;
|
||||||
gpointer value;
|
gpointer value;
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, contacts);
|
g_hash_table_iter_init(&iter, roster->contacts);
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
PContact contact = (PContact) value;
|
PContact contact = (PContact) value;
|
||||||
if (p_contact_pending_out(contact)) {
|
if (p_contact_pending_out(contact)) {
|
||||||
@ -451,18 +480,24 @@ roster_has_pending_subscriptions(void)
|
|||||||
char*
|
char*
|
||||||
roster_contact_autocomplete(const char *const search_str)
|
roster_contact_autocomplete(const char *const search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(name_ac, search_str, TRUE);
|
assert(roster != NULL);
|
||||||
|
|
||||||
|
return autocomplete_complete(roster->name_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
roster_fulljid_autocomplete(const char *const search_str)
|
roster_fulljid_autocomplete(const char *const search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(fulljid_ac, search_str, TRUE);
|
assert(roster != NULL);
|
||||||
|
|
||||||
|
return autocomplete_complete(roster->fulljid_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GSList*
|
GSList*
|
||||||
roster_get_nogroup(roster_ord_t order, gboolean include_offline)
|
roster_get_nogroup(roster_ord_t order, gboolean include_offline)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key;
|
gpointer key;
|
||||||
@ -475,7 +510,7 @@ roster_get_nogroup(roster_ord_t order, gboolean include_offline)
|
|||||||
cmp_func = (GCompareFunc) _compare_name;
|
cmp_func = (GCompareFunc) _compare_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, contacts);
|
g_hash_table_iter_init(&iter, roster->contacts);
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
PContact contact = value;
|
PContact contact = value;
|
||||||
const char *presence = p_contact_presence(contact);
|
const char *presence = p_contact_presence(contact);
|
||||||
@ -496,6 +531,8 @@ roster_get_nogroup(roster_ord_t order, gboolean include_offline)
|
|||||||
GSList*
|
GSList*
|
||||||
roster_get_group(const char *const group, roster_ord_t order, gboolean include_offline)
|
roster_get_group(const char *const group, roster_ord_t order, gboolean include_offline)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
GSList *result = NULL;
|
GSList *result = NULL;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key;
|
gpointer key;
|
||||||
@ -508,7 +545,7 @@ roster_get_group(const char *const group, roster_ord_t order, gboolean include_o
|
|||||||
cmp_func = (GCompareFunc) _compare_name;
|
cmp_func = (GCompareFunc) _compare_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_iter_init(&iter, contacts);
|
g_hash_table_iter_init(&iter, roster->contacts);
|
||||||
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
while (g_hash_table_iter_next(&iter, &key, &value)) {
|
||||||
PContact contact = value;
|
PContact contact = value;
|
||||||
const char *presence = p_contact_presence(contact);
|
const char *presence = p_contact_presence(contact);
|
||||||
@ -533,19 +570,25 @@ roster_get_group(const char *const group, roster_ord_t order, gboolean include_o
|
|||||||
GSList*
|
GSList*
|
||||||
roster_get_groups(void)
|
roster_get_groups(void)
|
||||||
{
|
{
|
||||||
return autocomplete_create_list(groups_ac);
|
assert(roster != NULL);
|
||||||
|
|
||||||
|
return autocomplete_create_list(roster->groups_ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
roster_group_autocomplete(const char *const search_str)
|
roster_group_autocomplete(const char *const search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(groups_ac, search_str, TRUE);
|
assert(roster != NULL);
|
||||||
|
|
||||||
|
return autocomplete_complete(roster->groups_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
roster_barejid_autocomplete(const char *const search_str)
|
roster_barejid_autocomplete(const char *const search_str)
|
||||||
{
|
{
|
||||||
return autocomplete_complete(barejid_ac, search_str, TRUE);
|
assert(roster != NULL);
|
||||||
|
|
||||||
|
return autocomplete_complete(roster->barejid_ac, search_str, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -574,15 +617,17 @@ _datetimes_equal(GDateTime *dt1, GDateTime *dt2)
|
|||||||
static void
|
static void
|
||||||
_replace_name(const char *const current_name, const char *const new_name, const char *const barejid)
|
_replace_name(const char *const current_name, const char *const new_name, const char *const barejid)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
// current handle exists already
|
// current handle exists already
|
||||||
if (current_name) {
|
if (current_name) {
|
||||||
autocomplete_remove(name_ac, current_name);
|
autocomplete_remove(roster->name_ac, current_name);
|
||||||
g_hash_table_remove(name_to_barejid, current_name);
|
g_hash_table_remove(roster->name_to_barejid, current_name);
|
||||||
_add_name_and_barejid(new_name, barejid);
|
_add_name_and_barejid(new_name, barejid);
|
||||||
// no current handle
|
// no current handle
|
||||||
} else if (new_name) {
|
} else if (new_name) {
|
||||||
autocomplete_remove(name_ac, barejid);
|
autocomplete_remove(roster->name_ac, barejid);
|
||||||
g_hash_table_remove(name_to_barejid, barejid);
|
g_hash_table_remove(roster->name_to_barejid, barejid);
|
||||||
_add_name_and_barejid(new_name, barejid);
|
_add_name_and_barejid(new_name, barejid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,12 +635,14 @@ _replace_name(const char *const current_name, const char *const new_name, const
|
|||||||
static void
|
static void
|
||||||
_add_name_and_barejid(const char *const name, const char *const barejid)
|
_add_name_and_barejid(const char *const name, const char *const barejid)
|
||||||
{
|
{
|
||||||
|
assert(roster != NULL);
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
autocomplete_add(name_ac, name);
|
autocomplete_add(roster->name_ac, name);
|
||||||
g_hash_table_insert(name_to_barejid, strdup(name), strdup(barejid));
|
g_hash_table_insert(roster->name_to_barejid, strdup(name), strdup(barejid));
|
||||||
} else {
|
} else {
|
||||||
autocomplete_add(name_ac, barejid);
|
autocomplete_add(roster->name_ac, barejid);
|
||||||
g_hash_table_insert(name_to_barejid, strdup(barejid), strdup(barejid));
|
g_hash_table_insert(roster->name_to_barejid, strdup(barejid), strdup(barejid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ gboolean roster_update_presence(const char *const barejid, Resource *resource, G
|
|||||||
PContact roster_get_contact(const char *const barejid);
|
PContact roster_get_contact(const char *const barejid);
|
||||||
gboolean roster_contact_offline(const char *const barejid, const char *const resource, const char *const status);
|
gboolean roster_contact_offline(const char *const barejid, const char *const resource, const char *const status);
|
||||||
void roster_reset_search_attempts(void);
|
void roster_reset_search_attempts(void);
|
||||||
void roster_init(void);
|
void roster_create(void);
|
||||||
void roster_free(void);
|
void roster_destroy(void);
|
||||||
void roster_change_name(PContact contact, const char *const new_name);
|
void roster_change_name(PContact contact, const char *const new_name);
|
||||||
void roster_remove(const char *const name, const char *const barejid);
|
void roster_remove(const char *const name, const char *const barejid);
|
||||||
void roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
|
void roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription,
|
||||||
|
@ -362,13 +362,18 @@ chatwin_get_string(ProfChatWin *chatwin)
|
|||||||
|
|
||||||
GString *res = g_string_new("Chat ");
|
GString *res = g_string_new("Chat ");
|
||||||
|
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
if (contact == NULL) {
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
g_string_append(res, chatwin->barejid);
|
PContact contact = roster_get_contact(chatwin->barejid);
|
||||||
|
if (contact == NULL) {
|
||||||
|
g_string_append(res, chatwin->barejid);
|
||||||
|
} else {
|
||||||
|
const char *display_name = p_contact_name_or_jid(contact);
|
||||||
|
g_string_append(res, display_name);
|
||||||
|
g_string_append_printf(res, " - %s", p_contact_presence(contact));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const char *display_name = p_contact_name_or_jid(contact);
|
g_string_append(res, chatwin->barejid);
|
||||||
g_string_append(res, display_name);
|
|
||||||
g_string_append_printf(res, " - %s", p_contact_presence(contact));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatwin->unread > 0) {
|
if (chatwin->unread > 0) {
|
||||||
|
@ -746,8 +746,7 @@ cons_show_status(const char *const barejid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cons_show_room_invite(const char *const invitor, const char * const room,
|
cons_show_room_invite(const char *const invitor, const char * const room, const char *const reason)
|
||||||
const char *const reason)
|
|
||||||
{
|
{
|
||||||
char *display_from = NULL;
|
char *display_from = NULL;
|
||||||
PContact contact = roster_get_contact(invitor);
|
PContact contact = roster_get_contact(invitor);
|
||||||
|
@ -466,6 +466,11 @@ rosterwin_roster(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
||||||
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||||
|
|
||||||
|
@ -403,15 +403,18 @@ _show_contact_presence(ProfChatWin *chatwin)
|
|||||||
theme_item_t presence_colour = THEME_TITLE_OFFLINE;
|
theme_item_t presence_colour = THEME_TITLE_OFFLINE;
|
||||||
const char *presence = "offline";
|
const char *presence = "offline";
|
||||||
|
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
if (contact) {
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
if (resource) {
|
PContact contact = roster_get_contact(chatwin->barejid);
|
||||||
Resource *resourcep = p_contact_get_resource(contact, resource);
|
if (contact) {
|
||||||
if (resourcep) {
|
if (resource) {
|
||||||
presence = string_from_resource_presence(resourcep->presence);
|
Resource *resourcep = p_contact_get_resource(contact, resource);
|
||||||
|
if (resourcep) {
|
||||||
|
presence = string_from_resource_presence(resourcep->presence);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
presence = p_contact_presence(contact);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
presence = p_contact_presence(contact);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,10 +248,15 @@ win_get_title(ProfWin *window)
|
|||||||
if (window->type == WIN_CHAT) {
|
if (window->type == WIN_CHAT) {
|
||||||
ProfChatWin *chatwin = (ProfChatWin*) window;
|
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
PContact contact = roster_get_contact(chatwin->barejid);
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
if (contact) {
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
const char *name = p_contact_name_or_jid(contact);
|
PContact contact = roster_get_contact(chatwin->barejid);
|
||||||
return strdup(name);
|
if (contact) {
|
||||||
|
const char *name = p_contact_name_or_jid(contact);
|
||||||
|
return strdup(name);
|
||||||
|
} else {
|
||||||
|
return strdup(chatwin->barejid);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return strdup(chatwin->barejid);
|
return strdup(chatwin->barejid);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
void clears_chat_sessions(void **state)
|
void clears_chat_sessions(void **state)
|
||||||
{
|
{
|
||||||
chat_sessions_init();
|
chat_sessions_init();
|
||||||
roster_init();
|
roster_create();
|
||||||
chat_session_recipient_active("bob@server.org", "laptop", FALSE);
|
chat_session_recipient_active("bob@server.org", "laptop", FALSE);
|
||||||
chat_session_recipient_active("mike@server.org", "work", FALSE);
|
chat_session_recipient_active("mike@server.org", "work", FALSE);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ void cmd_roster_shows_roster_when_no_args(void **state)
|
|||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("bob@server.org", "bob", NULL, "both", FALSE);
|
roster_add("bob@server.org", "bob", NULL, "both", FALSE);
|
||||||
GSList *roster = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
GSList *roster = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ void cmd_roster_shows_roster_when_no_args(void **state)
|
|||||||
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
roster_free();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_add_shows_message_when_no_jid(void **state)
|
void cmd_roster_add_shows_message_when_no_jid(void **state)
|
||||||
@ -145,7 +145,7 @@ void cmd_roster_nick_shows_message_when_no_contact_exists(void **state)
|
|||||||
{
|
{
|
||||||
gchar *args[] = { "nick", "bob@server.org", "bobster", NULL };
|
gchar *args[] = { "nick", "bob@server.org", "bobster", NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ void cmd_roster_nick_shows_message_when_no_contact_exists(void **state)
|
|||||||
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
roster_free();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_nick_sends_name_change_request(void **state)
|
void cmd_roster_nick_sends_name_change_request(void **state)
|
||||||
@ -163,9 +163,9 @@ void cmd_roster_nick_sends_name_change_request(void **state)
|
|||||||
char *nick = "bobster";
|
char *nick = "bobster";
|
||||||
gchar *args[] = { "nick", jid, nick, NULL };
|
gchar *args[] = { "nick", jid, nick, NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_create();
|
||||||
GSList *groups = NULL;
|
GSList *groups = NULL;
|
||||||
groups = g_slist_append(groups, "group1");
|
groups = g_slist_append(groups, strdup("group1"));
|
||||||
roster_add(jid, "bob", groups, "both", FALSE);
|
roster_add(jid, "bob", groups, "both", FALSE);
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -181,7 +181,7 @@ void cmd_roster_nick_sends_name_change_request(void **state)
|
|||||||
|
|
||||||
PContact contact = roster_get_contact(jid);
|
PContact contact = roster_get_contact(jid);
|
||||||
assert_string_equal(p_contact_name(contact), nick);
|
assert_string_equal(p_contact_name(contact), nick);
|
||||||
roster_free();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_clearnick_shows_message_when_no_jid(void **state)
|
void cmd_roster_clearnick_shows_message_when_no_jid(void **state)
|
||||||
@ -200,7 +200,7 @@ void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state)
|
|||||||
{
|
{
|
||||||
gchar *args[] = { "clearnick", "bob@server.org", NULL };
|
gchar *args[] = { "clearnick", "bob@server.org", NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state)
|
|||||||
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
roster_free();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state)
|
void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state)
|
||||||
@ -217,9 +217,9 @@ void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state
|
|||||||
char *jid = "bob@server.org";
|
char *jid = "bob@server.org";
|
||||||
gchar *args[] = { "clearnick", jid, NULL };
|
gchar *args[] = { "clearnick", jid, NULL };
|
||||||
|
|
||||||
roster_init();
|
roster_create();
|
||||||
GSList *groups = NULL;
|
GSList *groups = NULL;
|
||||||
groups = g_slist_append(groups, "group1");
|
groups = g_slist_append(groups, strdup("group1"));
|
||||||
roster_add(jid, "bob", groups, "both", FALSE);
|
roster_add(jid, "bob", groups, "both", FALSE);
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
@ -236,5 +236,5 @@ void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state
|
|||||||
PContact contact = roster_get_contact(jid);
|
PContact contact = roster_get_contact(jid);
|
||||||
assert_null(p_contact_name(contact));
|
assert_null(p_contact_name(contact));
|
||||||
|
|
||||||
roster_free();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
@ -11,50 +11,46 @@
|
|||||||
|
|
||||||
void empty_list_when_none_added(void **state)
|
void empty_list_when_none_added(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
||||||
assert_null(list);
|
assert_null(list);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void contains_one_element(void **state)
|
void contains_one_element(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
||||||
assert_int_equal(1, g_slist_length(list));
|
assert_int_equal(1, g_slist_length(list));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void first_element_correct(void **state)
|
void first_element_correct(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
||||||
PContact james = list->data;
|
PContact james = list->data;
|
||||||
|
|
||||||
assert_string_equal("James", p_contact_barejid(james));
|
assert_string_equal("James", p_contact_barejid(james));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void contains_two_elements(void **state)
|
void contains_two_elements(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
||||||
|
|
||||||
assert_int_equal(2, g_slist_length(list));
|
assert_int_equal(2, g_slist_length(list));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void first_and_second_elements_correct(void **state)
|
void first_and_second_elements_correct(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
||||||
@ -64,26 +60,24 @@ void first_and_second_elements_correct(void **state)
|
|||||||
|
|
||||||
assert_string_equal("Dave", p_contact_barejid(first));
|
assert_string_equal("Dave", p_contact_barejid(first));
|
||||||
assert_string_equal("James", p_contact_barejid(second));
|
assert_string_equal("James", p_contact_barejid(second));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void contains_three_elements(void **state)
|
void contains_three_elements(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
GSList *list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
|
||||||
|
|
||||||
assert_int_equal(3, g_slist_length(list));
|
assert_int_equal(3, g_slist_length(list));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void first_three_elements_correct(void **state)
|
void first_three_elements_correct(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
@ -95,13 +89,12 @@ void first_three_elements_correct(void **state)
|
|||||||
assert_string_equal("James", p_contact_barejid(james));
|
assert_string_equal("James", p_contact_barejid(james));
|
||||||
assert_string_equal("Dave", p_contact_barejid(dave));
|
assert_string_equal("Dave", p_contact_barejid(dave));
|
||||||
assert_string_equal("Bob", p_contact_barejid(bob));
|
assert_string_equal("Bob", p_contact_barejid(bob));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_twice_at_beginning_adds_once(void **state)
|
void add_twice_at_beginning_adds_once(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
@ -115,13 +108,12 @@ void add_twice_at_beginning_adds_once(void **state)
|
|||||||
assert_string_equal("Bob", p_contact_barejid(first));
|
assert_string_equal("Bob", p_contact_barejid(first));
|
||||||
assert_string_equal("Dave", p_contact_barejid(second));
|
assert_string_equal("Dave", p_contact_barejid(second));
|
||||||
assert_string_equal("James", p_contact_barejid(third));
|
assert_string_equal("James", p_contact_barejid(third));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_twice_in_middle_adds_once(void **state)
|
void add_twice_in_middle_adds_once(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
@ -135,13 +127,12 @@ void add_twice_in_middle_adds_once(void **state)
|
|||||||
assert_string_equal("Bob", p_contact_barejid(first));
|
assert_string_equal("Bob", p_contact_barejid(first));
|
||||||
assert_string_equal("Dave", p_contact_barejid(second));
|
assert_string_equal("Dave", p_contact_barejid(second));
|
||||||
assert_string_equal("James", p_contact_barejid(third));
|
assert_string_equal("James", p_contact_barejid(third));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_twice_at_end_adds_once(void **state)
|
void add_twice_at_end_adds_once(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
@ -155,13 +146,12 @@ void add_twice_at_end_adds_once(void **state)
|
|||||||
assert_string_equal("Bob", p_contact_barejid(first));
|
assert_string_equal("Bob", p_contact_barejid(first));
|
||||||
assert_string_equal("Dave", p_contact_barejid(second));
|
assert_string_equal("Dave", p_contact_barejid(second));
|
||||||
assert_string_equal("James", p_contact_barejid(third));
|
assert_string_equal("James", p_contact_barejid(third));
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_first_exists(void **state)
|
void find_first_exists(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
@ -172,13 +162,12 @@ void find_first_exists(void **state)
|
|||||||
assert_string_equal("Bob", result);
|
assert_string_equal("Bob", result);
|
||||||
free(result);
|
free(result);
|
||||||
free(search);
|
free(search);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_second_exists(void **state)
|
void find_second_exists(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
@ -186,13 +175,12 @@ void find_second_exists(void **state)
|
|||||||
char *result = roster_contact_autocomplete("Dav");
|
char *result = roster_contact_autocomplete("Dav");
|
||||||
assert_string_equal("Dave", result);
|
assert_string_equal("Dave", result);
|
||||||
free(result);
|
free(result);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_third_exists(void **state)
|
void find_third_exists(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
@ -200,35 +188,32 @@ void find_third_exists(void **state)
|
|||||||
char *result = roster_contact_autocomplete("Ja");
|
char *result = roster_contact_autocomplete("Ja");
|
||||||
assert_string_equal("James", result);
|
assert_string_equal("James", result);
|
||||||
free(result);
|
free(result);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_returns_null(void **state)
|
void find_returns_null(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
roster_add("Dave", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
|
|
||||||
char *result = roster_contact_autocomplete("Mike");
|
char *result = roster_contact_autocomplete("Mike");
|
||||||
assert_null(result);
|
assert_null(result);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_on_empty_returns_null(void **state)
|
void find_on_empty_returns_null(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
char *result = roster_contact_autocomplete("James");
|
char *result = roster_contact_autocomplete("James");
|
||||||
assert_null(result);
|
assert_null(result);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_twice_returns_second_when_two_match(void **state)
|
void find_twice_returns_second_when_two_match(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Jamie", NULL, NULL, NULL, FALSE);
|
roster_add("Jamie", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
@ -238,13 +223,12 @@ void find_twice_returns_second_when_two_match(void **state)
|
|||||||
assert_string_equal("Jamie", result2);
|
assert_string_equal("Jamie", result2);
|
||||||
free(result1);
|
free(result1);
|
||||||
free(result2);
|
free(result2);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_five_times_finds_fifth(void **state)
|
void find_five_times_finds_fifth(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("Jama", NULL, NULL, NULL, FALSE);
|
roster_add("Jama", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Jamb", NULL, NULL, NULL, FALSE);
|
roster_add("Jamb", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Mike", NULL, NULL, NULL, FALSE);
|
roster_add("Mike", NULL, NULL, NULL, FALSE);
|
||||||
@ -267,13 +251,12 @@ void find_five_times_finds_fifth(void **state)
|
|||||||
free(result3);
|
free(result3);
|
||||||
free(result4);
|
free(result4);
|
||||||
free(result5);
|
free(result5);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void find_twice_returns_first_when_two_match_and_reset(void **state)
|
void find_twice_returns_first_when_two_match_and_reset(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("James", NULL, NULL, NULL, FALSE);
|
roster_add("James", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Jamie", NULL, NULL, NULL, FALSE);
|
roster_add("Jamie", NULL, NULL, NULL, FALSE);
|
||||||
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
roster_add("Bob", NULL, NULL, NULL, FALSE);
|
||||||
@ -284,26 +267,24 @@ void find_twice_returns_first_when_two_match_and_reset(void **state)
|
|||||||
assert_string_equal("James", result2);
|
assert_string_equal("James", result2);
|
||||||
free(result1);
|
free(result1);
|
||||||
free(result2);
|
free(result2);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_no_group(void **state)
|
void add_contact_with_no_group(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
roster_add("person@server.org", NULL, NULL, NULL, FALSE);
|
roster_add("person@server.org", NULL, NULL, NULL, FALSE);
|
||||||
|
|
||||||
GSList *groups_res = roster_get_groups();
|
GSList *groups_res = roster_get_groups();
|
||||||
assert_int_equal(g_slist_length(groups_res), 0);
|
assert_int_equal(g_slist_length(groups_res), 0);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_group(void **state)
|
void add_contact_with_group(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups = NULL;
|
GSList *groups = NULL;
|
||||||
groups = g_slist_append(groups, strdup("friends"));
|
groups = g_slist_append(groups, strdup("friends"));
|
||||||
@ -317,13 +298,12 @@ void add_contact_with_group(void **state)
|
|||||||
assert_string_equal(found->data, "friends");
|
assert_string_equal(found->data, "friends");
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_two_groups(void **state)
|
void add_contact_with_two_groups(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups = NULL;
|
GSList *groups = NULL;
|
||||||
groups = g_slist_append(groups, strdup("friends"));
|
groups = g_slist_append(groups, strdup("friends"));
|
||||||
@ -341,13 +321,12 @@ void add_contact_with_two_groups(void **state)
|
|||||||
assert_string_equal(found->data, "work");
|
assert_string_equal(found->data, "work");
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_three_groups(void **state)
|
void add_contact_with_three_groups(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups = NULL;
|
GSList *groups = NULL;
|
||||||
groups = g_slist_append(groups, strdup("friends"));
|
groups = g_slist_append(groups, strdup("friends"));
|
||||||
@ -369,13 +348,12 @@ void add_contact_with_three_groups(void **state)
|
|||||||
assert_string_equal(found->data, "stuff");
|
assert_string_equal(found->data, "stuff");
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_three_groups_update_adding_two(void **state)
|
void add_contact_with_three_groups_update_adding_two(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -411,13 +389,12 @@ void add_contact_with_three_groups_update_adding_two(void **state)
|
|||||||
assert_string_equal(found->data, "people");
|
assert_string_equal(found->data, "people");
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_three_groups_update_removing_one(void **state)
|
void add_contact_with_three_groups_update_removing_one(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -441,13 +418,12 @@ void add_contact_with_three_groups_update_removing_one(void **state)
|
|||||||
assert_string_equal(found->data, "stuff");
|
assert_string_equal(found->data, "stuff");
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_three_groups_update_removing_two(void **state)
|
void add_contact_with_three_groups_update_removing_two(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -467,13 +443,12 @@ void add_contact_with_three_groups_update_removing_two(void **state)
|
|||||||
assert_string_equal(found->data, "stuff");
|
assert_string_equal(found->data, "stuff");
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_three_groups_update_removing_three(void **state)
|
void add_contact_with_three_groups_update_removing_three(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -487,13 +462,12 @@ void add_contact_with_three_groups_update_removing_three(void **state)
|
|||||||
assert_int_equal(g_slist_length(groups_res), 0);
|
assert_int_equal(g_slist_length(groups_res), 0);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contact_with_three_groups_update_two_new(void **state)
|
void add_contact_with_three_groups_update_two_new(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -515,13 +489,12 @@ void add_contact_with_three_groups_update_two_new(void **state)
|
|||||||
assert_true(found != NULL);
|
assert_true(found != NULL);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_remove_contact_groups(void **state)
|
void add_remove_contact_groups(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -535,13 +508,12 @@ void add_remove_contact_groups(void **state)
|
|||||||
assert_int_equal(g_slist_length(groups_res), 0);
|
assert_int_equal(g_slist_length(groups_res), 0);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contacts_with_different_groups(void **state)
|
void add_contacts_with_different_groups(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -569,13 +541,12 @@ void add_contacts_with_different_groups(void **state)
|
|||||||
assert_true(found != NULL);
|
assert_true(found != NULL);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contacts_with_same_groups(void **state)
|
void add_contacts_with_same_groups(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -600,13 +571,12 @@ void add_contacts_with_same_groups(void **state)
|
|||||||
assert_true(found != NULL);
|
assert_true(found != NULL);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_contacts_with_overlapping_groups(void **state)
|
void add_contacts_with_overlapping_groups(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -633,13 +603,12 @@ void add_contacts_with_overlapping_groups(void **state)
|
|||||||
assert_true(found != NULL);
|
assert_true(found != NULL);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_contact_with_remaining_in_group(void **state)
|
void remove_contact_with_remaining_in_group(void **state)
|
||||||
{
|
{
|
||||||
roster_init();
|
roster_create();
|
||||||
|
|
||||||
GSList *groups1 = NULL;
|
GSList *groups1 = NULL;
|
||||||
groups1 = g_slist_append(groups1, strdup("friends"));
|
groups1 = g_slist_append(groups1, strdup("friends"));
|
||||||
@ -666,6 +635,5 @@ void remove_contact_with_remaining_in_group(void **state)
|
|||||||
assert_true(found != NULL);
|
assert_true(found != NULL);
|
||||||
|
|
||||||
g_slist_free_full(groups_res, g_free);
|
g_slist_free_full(groups_res, g_free);
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
roster_free();
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
void console_shows_online_presence_when_set_online(void **state)
|
void console_shows_online_presence_when_set_online(void **state)
|
||||||
{
|
{
|
||||||
prefs_set_string(PREF_STATUSES_CONSOLE, "online");
|
prefs_set_string(PREF_STATUSES_CONSOLE, "online");
|
||||||
roster_init();
|
roster_create();
|
||||||
char *barejid = "test1@server";
|
char *barejid = "test1@server";
|
||||||
roster_add(barejid, "bob", NULL, "both", FALSE);
|
roster_add(barejid, "bob", NULL, "both", FALSE);
|
||||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||||
@ -28,13 +28,13 @@ void console_shows_online_presence_when_set_online(void **state)
|
|||||||
|
|
||||||
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
||||||
|
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_shows_online_presence_when_set_all(void **state)
|
void console_shows_online_presence_when_set_all(void **state)
|
||||||
{
|
{
|
||||||
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
||||||
roster_init();
|
roster_create();
|
||||||
char *barejid = "test1@server";
|
char *barejid = "test1@server";
|
||||||
roster_add(barejid, "bob", NULL, "both", FALSE);
|
roster_add(barejid, "bob", NULL, "both", FALSE);
|
||||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||||
@ -45,13 +45,13 @@ void console_shows_online_presence_when_set_all(void **state)
|
|||||||
|
|
||||||
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
||||||
|
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_shows_dnd_presence_when_set_all(void **state)
|
void console_shows_dnd_presence_when_set_all(void **state)
|
||||||
{
|
{
|
||||||
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
prefs_set_string(PREF_STATUSES_CONSOLE, "all");
|
||||||
roster_init();
|
roster_create();
|
||||||
char *barejid = "test1@server";
|
char *barejid = "test1@server";
|
||||||
roster_add(barejid, "bob", NULL, "both", FALSE);
|
roster_add(barejid, "bob", NULL, "both", FALSE);
|
||||||
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10);
|
||||||
@ -62,30 +62,34 @@ void console_shows_dnd_presence_when_set_all(void **state)
|
|||||||
|
|
||||||
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
sv_ev_contact_online(barejid, resource, NULL, NULL);
|
||||||
|
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_offline_removes_chat_session(void **state)
|
void handle_offline_removes_chat_session(void **state)
|
||||||
{
|
{
|
||||||
|
roster_create();
|
||||||
chat_sessions_init();
|
chat_sessions_init();
|
||||||
char *barejid = "friend@server.chat.com";
|
char *barejid = "friend@server.chat.com";
|
||||||
char *resource = "home";
|
char *resource = "home";
|
||||||
roster_init();
|
|
||||||
roster_add(barejid, "bob", NULL, "both", FALSE);
|
roster_add(barejid, "bob", NULL, "both", FALSE);
|
||||||
Resource *resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10);
|
Resource *resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10);
|
||||||
roster_update_presence(barejid, resourcep, NULL);
|
roster_update_presence(barejid, resourcep, NULL);
|
||||||
chat_session_recipient_active(barejid, resource, FALSE);
|
chat_session_recipient_active(barejid, resource, FALSE);
|
||||||
|
ProfConsoleWin *console = malloc(sizeof(ProfConsoleWin));
|
||||||
|
will_return(win_create_console, &console->window);
|
||||||
|
wins_init();
|
||||||
sv_ev_contact_offline(barejid, resource, NULL);
|
sv_ev_contact_offline(barejid, resource, NULL);
|
||||||
ChatSession *session = chat_session_get(barejid);
|
ChatSession *session = chat_session_get(barejid);
|
||||||
|
|
||||||
assert_null(session);
|
assert_null(session);
|
||||||
|
|
||||||
roster_clear();
|
roster_destroy();
|
||||||
chat_sessions_clear();
|
chat_sessions_clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lost_connection_clears_chat_sessions(void **state)
|
void lost_connection_clears_chat_sessions(void **state)
|
||||||
{
|
{
|
||||||
|
roster_create();
|
||||||
chat_sessions_init();
|
chat_sessions_init();
|
||||||
chat_session_recipient_active("bob@server.org", "laptop", FALSE);
|
chat_session_recipient_active("bob@server.org", "laptop", FALSE);
|
||||||
chat_session_recipient_active("steve@server.org", "mobile", FALSE);
|
chat_session_recipient_active("steve@server.org", "mobile", FALSE);
|
||||||
|
@ -463,7 +463,7 @@ void occupantswin_occupants(const char * const room) {}
|
|||||||
// window interface
|
// window interface
|
||||||
ProfWin* win_create_console(void)
|
ProfWin* win_create_console(void)
|
||||||
{
|
{
|
||||||
return NULL;
|
return (ProfWin*)mock();
|
||||||
}
|
}
|
||||||
ProfWin* win_create_xmlconsole(void)
|
ProfWin* win_create_xmlconsole(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user