From 31b0f0b0c889f6b54ac4315130f7d6a5abca6668 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 6 May 2016 01:16:13 +0100 Subject: [PATCH] Move uuid functions --- src/command/commands.c | 4 ++-- src/xmpp/connection.c | 14 ++++++++++++++ src/xmpp/session.c | 14 -------------- src/xmpp/xmpp.h | 4 ++-- tests/unittests/xmpp/stub_xmpp.c | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/command/commands.c b/src/command/commands.c index cf89b39a..9127fab9 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -3465,9 +3465,9 @@ cmd_join(ProfWin *window, const char *const command, gchar **args) ProfAccount *account = accounts_get_account(account_name); GString *room_str = g_string_new(""); - char *uuid = session_create_uuid(); + char *uuid = connection_create_uuid(); g_string_append_printf(room_str, "private-chat-%s@%s", uuid, account->muc_service); - session_free_uuid(uuid); + connection_free_uuid(uuid); presence_join_room(room_str->str, account->muc_nick, NULL); muc_join(room_str->str, account->muc_nick, NULL, FALSE); diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 313d056c..90bbd951 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -176,6 +176,20 @@ connection_get_fulljid(void) return xmpp_conn_get_jid(conn.conn); } +char* +connection_create_uuid(void) +{ + return xmpp_uuid_gen(conn.ctx); +} + +void +connection_free_uuid(char *uuid) +{ + if (uuid) { + xmpp_free(conn.ctx, uuid); + } +} + char * connection_get_domain(void) { diff --git a/src/xmpp/session.c b/src/xmpp/session.c index 809e77ee..1dd10ee4 100644 --- a/src/xmpp/session.c +++ b/src/xmpp/session.c @@ -317,20 +317,6 @@ session_get_account_name(void) return saved_account.name; } -char* -session_create_uuid(void) -{ - return xmpp_uuid_gen(connection_get_ctx()); -} - -void -session_free_uuid(char *uuid) -{ - if (uuid) { - xmpp_free(connection_get_ctx(), uuid); - } -} - void session_add_available_resource(Resource *resource) { diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 9651f7d9..ddee4bfa 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -119,8 +119,6 @@ void session_shutdown(void); void session_process_events(int millis); char* session_get_account_name(void); GList* session_get_available_resources(void); -char* session_create_uuid(void); -void session_free_uuid(char *uuid); gboolean session_send_stanza(const char *const stanza); #ifdef HAVE_LIBMESODE @@ -133,6 +131,8 @@ gboolean session_service_supports(const char *const feature); jabber_conn_status_t connection_get_status(void); char *connection_get_presence_msg(void); const char* connection_get_fulljid(void); +char* connection_create_uuid(void); +void connection_free_uuid(char *uuid); 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); diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index 8e33ff79..8cdd4f5a 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -49,12 +49,12 @@ session_get_tls_peer_cert(void) } -char* session_create_uuid(void) +char* connection_create_uuid(void) { return NULL; } -void session_free_uuid(char * uuid) {} +void connection_free_uuid(char * uuid) {} jabber_conn_status_t connection_get_status(void) {