From 6e28df66e89943e42243d0a36734b7b7b5310c2f Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 12 Oct 2015 23:37:11 +0100 Subject: [PATCH] Use libstrophe/libmesode uuid generator --- configure.ac | 3 --- install-all.sh | 12 ++++++------ src/command/commands.c | 11 +++-------- src/xmpp/connection.c | 14 ++++++++++++++ src/xmpp/xmpp.h | 2 ++ 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/configure.ac b/configure.ac index bc0afaae..28ed7efe 100644 --- a/configure.ac +++ b/configure.ac @@ -106,9 +106,6 @@ AS_IF([test "x$PLATFORM" != xosx], AC_SUBST(AM_LDFLAGS)], [AC_MSG_ERROR([libreadline is required for profanity])])]) -AC_CHECK_LIB([uuid], [uuid_generate], [], - [AC_MSG_ERROR([libuuid is required for profanity])]) - AS_IF([test "x$PLATFORM" = xosx], [LIBS="-lcurl $LIBS"]) ### Check for desktop notification support diff --git a/install-all.sh b/install-all.sh index bd5093dd..9c975c1a 100755 --- a/install-all.sh +++ b/install-all.sh @@ -24,7 +24,7 @@ debian_prepare() echo echo Profanity installer... installing dependencies echo - sudo apt-get -y install git automake autoconf libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev libreadline-dev libtool libgpgme11-dev uuid-dev + sudo apt-get -y install git automake autoconf libssl-dev libexpat1-dev libncursesw5-dev libglib2.0-dev libnotify-dev libcurl3-dev libxss-dev libotr5-dev libreadline-dev libtool libgpgme11-dev } @@ -34,7 +34,7 @@ fedora_prepare() echo Profanity installer... installing dependencies echo - sudo dnf -y install gcc git autoconf automake openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr3-devel readline-devel libtool libuuid-devel gpgme-devel + sudo dnf -y install gcc git autoconf automake openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr3-devel readline-devel libtool gpgme-devel } opensuse_prepare() @@ -42,7 +42,7 @@ opensuse_prepare() echo echo Profanity installer...installing dependencies echo - sudo zypper -n in gcc git automake make autoconf libopenssl-devel expat libexpat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool libuuid-devel libgpgme-devel + sudo zypper -n in gcc git automake make autoconf libopenssl-devel expat libexpat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool libgpgme-devel } centos_prepare() @@ -54,7 +54,7 @@ centos_prepare() sudo yum -y install epel-release sudo yum -y install git sudo yum -y install gcc autoconf automake cmake - sudo yum -y install openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool libuuid-devel gpgme-devel + sudo yum -y install openssl-devel expat-devel ncurses-devel glib2-devel libnotify-devel libcurl-devel libXScrnSaver-devel libotr-devel readline-devel libtool gpgme-devel } cygwin_prepare() @@ -70,9 +70,9 @@ cygwin_prepare() mv apt-cyg /usr/local/bin/ if [ -n "$CYG_MIRROR" ]; then - apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libgpgme-devel libtool libuuid-devel + apt-cyg -m $CYG_MIRROR install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libgpgme-devel libtool else - apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libgpgme-devel libtool libuuid-devel + apt-cyg install git make gcc-core m4 automake autoconf pkg-config openssl-devel libexpat-devel zlib-devel libncursesw-devel libglib2.0-devel libcurl-devel libidn-devel libssh2-devel libkrb5-devel openldap-devel libgcrypt-devel libreadline-devel libgpgme-devel libtool fi } diff --git a/src/command/commands.c b/src/command/commands.c index eb4aa03f..7df1477a 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include "chat_session.h" @@ -2267,22 +2266,18 @@ cmd_join(ProfWin *window, const char * const command, gchar **args) } if (args[0] == NULL) { - uuid_t uuid; - uuid_generate(uuid); - char *uuid_str = malloc(sizeof(char) * 37); - uuid_unparse_lower(uuid, uuid_str); - char *account_name = jabber_get_account_name(); ProfAccount *account = accounts_get_account(account_name); GString *room_str = g_string_new(""); - g_string_append_printf(room_str, "private-chat-%s@%s", uuid_str, account->muc_service); + char *uuid = jabber_create_uuid(); + g_string_append_printf(room_str, "private-chat-%s@%s", uuid, account->muc_service); + jabber_free_uuid(uuid); presence_join_room(room_str->str, account->muc_nick, NULL); muc_join(room_str->str, account->muc_nick, NULL, FALSE); g_string_free(room_str, TRUE); - free(uuid_str); account_free(account); return TRUE; diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index abc08732..5ad5e108 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -310,6 +310,20 @@ jabber_get_account_name(void) return saved_account.name; } +char* +jabber_create_uuid(void) +{ + return xmpp_uuid_gen(jabber_conn.ctx); +} + +void +jabber_free_uuid(char *uuid) +{ + if (uuid) { + xmpp_free(jabber_conn.ctx, uuid); + } +} + void connection_set_presence_message(const char * const message) { diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 2a8cbb59..839df9a7 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -150,6 +150,8 @@ jabber_conn_status_t jabber_get_connection_status(void); char * jabber_get_presence_message(void); char* jabber_get_account_name(void); GList * jabber_get_available_resources(void); +char* jabber_create_uuid(void); +void jabber_free_uuid(char *uuid); // message functions char* message_send_chat(const char * const barejid, const char * const msg);