diff options
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/connection.c | 26 | ||||
-rw-r--r-- | src/xmpp/connection.h | 5 | ||||
-rw-r--r-- | src/xmpp/presence.c | 4 | ||||
-rw-r--r-- | src/xmpp/session.c | 22 | ||||
-rw-r--r-- | src/xmpp/session.h | 2 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 2 |
6 files changed, 34 insertions, 27 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 10a6b379..56026c0c 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -59,6 +59,7 @@ typedef struct prof_conn_t { char *presence_message; int priority; char *domain; + GHashTable *available_resources; } ProfConnection; static ProfConnection conn; @@ -81,6 +82,7 @@ void connection_init(void) conn.xmpp_conn = NULL; conn.xmpp_ctx = NULL; conn.domain = NULL; + conn.available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)resource_destroy); } jabber_conn_status_t @@ -197,6 +199,30 @@ connection_get_fulljid(void) return xmpp_conn_get_jid(conn.xmpp_conn); } +GList* +connection_get_available_resources(void) +{ + return g_hash_table_get_values(conn.available_resources); +} + +void +connection_add_available_resource(Resource *resource) +{ + g_hash_table_replace(conn.available_resources, strdup(resource->name), resource); +} + +void +connection_remove_available_resource(const char *const resource) +{ + g_hash_table_remove(conn.available_resources, resource); +} + +void +connection_remove_all_available_resources(void) +{ + g_hash_table_remove_all(conn.available_resources); +} + char* connection_create_uuid(void) { diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h index 9a731c2c..20b4cd74 100644 --- a/src/xmpp/connection.h +++ b/src/xmpp/connection.h @@ -48,6 +48,7 @@ void connection_set_status(jabber_conn_status_t status); void connection_set_presence_msg(const char *const message); void connection_set_priority(const int priority); void connection_set_domain(char *domain); +void connection_set_priority(int priority); void connection_free_conn(void); void connection_free_ctx(void); @@ -57,6 +58,8 @@ void connection_free_log(void); xmpp_conn_t* connection_get_conn(void); xmpp_ctx_t* connection_get_ctx(void); -void connection_set_priority(int priority); +void connection_add_available_resource(Resource *resource); +void connection_remove_available_resource(const char *const resource); +void connection_remove_all_available_resources(void); #endif diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index ad6699ac..6ca5127c 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -538,7 +538,7 @@ _unavailable_handler(xmpp_stanza_t *const stanza) } } else { if (from_jid->resourcepart) { - session_remove_available_resource(from_jid->resourcepart); + connection_remove_available_resource(from_jid->resourcepart); } } @@ -644,7 +644,7 @@ _available_handler(xmpp_stanza_t *const stanza) Resource *resource = stanza_resource_from_presence(xmpp_presence); if (g_strcmp0(xmpp_presence->jid->barejid, my_jid->barejid) == 0) { - session_add_available_resource(resource); + connection_add_available_resource(resource); } else { char *pgpsig = NULL; xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_SIGNED); diff --git a/src/xmpp/session.c b/src/xmpp/session.c index c513b233..975b066f 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -66,7 +66,6 @@ #include "xmpp/stanza.h" #include "xmpp/xmpp.h" -static GHashTable *available_resources; static GSList *disco_items; // for auto reconnect @@ -101,7 +100,6 @@ session_init(void) connection_init(); presence_sub_requests_init(); caps_init(); - available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)resource_destroy); disco_items = NULL; xmpp_initialize(); } @@ -275,12 +273,6 @@ session_process_events(int millis) } } -GList* -session_get_available_resources(void) -{ - return g_hash_table_get_values(available_resources); -} - GSList* session_get_disco_items(void) { @@ -315,18 +307,6 @@ session_get_account_name(void) } void -session_add_available_resource(Resource *resource) -{ - g_hash_table_replace(available_resources, strdup(resource->name), resource); -} - -void -session_remove_available_resource(const char *const resource) -{ - g_hash_table_remove(available_resources, resource); -} - -void session_login_success(gboolean secured) { // logged in with account @@ -463,7 +443,7 @@ _session_free_session_data(void) { g_slist_free_full(disco_items, (GDestroyNotify)_session_info_destroy); disco_items = NULL; - g_hash_table_remove_all(available_resources); + connection_remove_all_available_resources(); chat_sessions_clear(); presence_clear_sub_requests(); } diff --git a/src/xmpp/session.h b/src/xmpp/session.h index d9ec7b8d..da404c60 100644 --- a/src/xmpp/session.h +++ b/src/xmpp/session.h @@ -52,7 +52,5 @@ void session_lost_connection(void); GSList* session_get_disco_items(void); void session_set_disco_items(GSList *_disco_items); void session_autoping_fail(void); -void session_remove_available_resource(const char *const resource); -void session_add_available_resource(Resource *resource); #endif diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index ff75ab58..86f57fa8 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -118,7 +118,6 @@ void session_disconnect(void); void session_shutdown(void); void session_process_events(int millis); char* session_get_account_name(void); -GList* session_get_available_resources(void); gboolean session_service_supports(const char *const feature); @@ -132,6 +131,7 @@ TLSCertificate* connection_get_tls_peer_cert(void); #endif gboolean connection_is_secured(void); gboolean connection_send_stanza(const char *const stanza); +GList* connection_get_available_resources(void); char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url); char* message_send_chat_otr(const char *const barejid, const char *const msg); |