1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Add support for libsignal-protocol-c 2.3.2

This commit is contained in:
Paul Fariello 2019-03-11 06:46:02 +01:40
parent b3be504e84
commit 97c661271b
4 changed files with 44 additions and 15 deletions

View File

@ -266,23 +266,27 @@ if test "x$enable_otr" != xno; then
[AC_MSG_NOTICE([libotr not found, otr encryption support not enabled])])]) [AC_MSG_NOTICE([libotr not found, otr encryption support not enabled])])])
fi fi
AM_CONDITIONAL([BUILD_OMEMO], [false]) AM_CONDITIONAL([BUILD_OMEMO], [true])
if test "x$enable_omemo" != xno; then if test "x$enable_omemo" != xno; then
AC_CHECK_LIB([signal-protocol-c], [signal_context_create], PKG_CHECK_MODULES([libsignal], [libsignal-protocol-c >= 2.3.2],
[AM_CONDITIONAL([BUILD_OMEMO], [true]) [LIBS="-lsignal-protocol-c $LIBS"],
AC_DEFINE([HAVE_OMEMO], [1], [Have omemo]), [AC_MSG_NOTICE([libsignal >= 2.3.2 not found, checking for libsignal 2.3.x...])
LIBS="-lsignal-protocol-c $LIBS"], PKG_CHECK_MODULES([libsignal], [libsignal-protocol-c >= 2.3.0],
[AS_IF([test "x$enable_omemo" = xyes], [LIBS="-lsignal-protocol-c $LIBS"
[AC_MSG_ERROR([libsignal-protocol-c is required for omemo support])], AC_DEFINE([HAVE_LIBSIGNAL_LT_2_3_2], [1], [Have libsignal-protocol-c < 2.3.2])],
[AC_MSG_NOTICE([libsignal-protocol-c not found, omemo support not enabled])])]) [AM_CONDITIONAL([BUILD_OMEMO], [false])
AS_IF([test "x$enable_omemo" = xyes],
[AC_MSG_ERROR([libsignal-protocol-c is required for omemo support])],
[AC_MSG_NOTICE([libsignal-protocol-c not found, omemo support not enabled])])])])
AC_CHECK_LIB([gcrypt], [gcry_check_version], AC_CHECK_LIB([gcrypt], [gcry_check_version],
[AM_CONDITIONAL([BUILD_OMEMO], [true]) [LIBS="-lgcrypt $LIBS"],
AC_DEFINE([HAVE_OMEMO], [1], [Have omemo]), [AM_CONDITIONAL([BUILD_OMEMO], [false])
LIBS="-lgcrypt $LIBS"], AS_IF([test "x$enable_omemo" = xyes],
[AS_IF([test "x$enable_omemo" = xyes], [AC_MSG_ERROR([gcrypt is required for omemo support])],
[AC_MSG_ERROR([gcrypt is required for omemo support])], [AC_MSG_NOTICE([gcrypt not found, omemo support not enabled])])])
[AC_MSG_NOTICE([gcrypt not found, omemo support not enabled])])])
AM_COND_IF([BUILD_OMEMO], [AC_DEFINE([HAVE_OMEMO], [1], [Have OMEMO])])
fi fi
AS_IF([test "x$with_themes" = xno], AS_IF([test "x$with_themes" = xno],

View File

@ -1,6 +1,7 @@
#include <glib.h> #include <glib.h>
#include <signal/signal_protocol.h> #include <signal/signal_protocol.h>
#include "config.h"
#include "omemo/omemo.h" #include "omemo/omemo.h"
#include "omemo/store.h" #include "omemo/store.h"
@ -30,9 +31,15 @@ identity_key_store_new(identity_key_store_t *identity_key_store)
identity_key_store->public = NULL; identity_key_store->public = NULL;
} }
#ifdef HAVE_LIBSIGNAL_LT_2_3_2
int int
load_session(signal_buffer **record, const signal_protocol_address *address, load_session(signal_buffer **record, const signal_protocol_address *address,
void *user_data) void *user_data)
#else
int
load_session(signal_buffer **record, signal_buffer **user_record,
const signal_protocol_address *address, void *user_data)
#endif
{ {
GHashTable *session_store = (GHashTable *)user_data; GHashTable *session_store = (GHashTable *)user_data;
GHashTable *device_store = NULL; GHashTable *device_store = NULL;
@ -76,9 +83,17 @@ get_sub_device_sessions(signal_int_list **sessions, const char *name,
return SG_SUCCESS; return SG_SUCCESS;
} }
#ifdef HAVE_LIBSIGNAL_LT_2_3_2
int int
store_session(const signal_protocol_address *address, uint8_t *record, store_session(const signal_protocol_address *address, uint8_t *record,
size_t record_len, void *user_data) size_t record_len, void *user_data)
#else
int
store_session(const signal_protocol_address *address,
uint8_t *record, size_t record_len,
uint8_t *user_record, size_t user_record_len,
void *user_data)
#endif
{ {
GHashTable *session_store = (GHashTable *)user_data; GHashTable *session_store = (GHashTable *)user_data;
GHashTable *device_store = NULL; GHashTable *device_store = NULL;

View File

@ -1,5 +1,7 @@
#include <signal/signal_protocol.h> #include <signal/signal_protocol.h>
#include "config.h"
#define OMEMO_STORE_GROUP_IDENTITY "identity" #define OMEMO_STORE_GROUP_IDENTITY "identity"
#define OMEMO_STORE_KEY_DEVICE_ID "device_id" #define OMEMO_STORE_KEY_DEVICE_ID "device_id"
#define OMEMO_STORE_KEY_REGISTRATION_ID "registration_id" #define OMEMO_STORE_KEY_REGISTRATION_ID "registration_id"
@ -28,7 +30,11 @@ void identity_key_store_new(identity_key_store_t *identity_key_store);
* @param address the address of the remote client * @param address the address of the remote client
* @return 1 if the session was loaded, 0 if the session was not found, negative on failure * @return 1 if the session was loaded, 0 if the session was not found, negative on failure
*/ */
#ifdef HAVE_LIBSIGNAL_LT_2_3_2
int load_session(signal_buffer **record, const signal_protocol_address *address, void *user_data); int load_session(signal_buffer **record, const signal_protocol_address *address, void *user_data);
#else
int load_session(signal_buffer **record, signal_buffer **user_record, const signal_protocol_address *address, void *user_data);
#endif
/** /**
* Returns all known devices with active sessions for a recipient * Returns all known devices with active sessions for a recipient
@ -50,7 +56,11 @@ int get_sub_device_sessions(signal_int_list **sessions, const char *name, size_t
* @param record_len length of the serialized session record * @param record_len length of the serialized session record
* @return 0 on success, negative on failure * @return 0 on success, negative on failure
*/ */
#ifdef HAVE_LIBSIGNAL_LT_2_3_2
int store_session(const signal_protocol_address *address, uint8_t *record, size_t record_len, void *user_data); int store_session(const signal_protocol_address *address, uint8_t *record, size_t record_len, void *user_data);
#else
int store_session(const signal_protocol_address *address, uint8_t *record, size_t record_len, uint8_t *user_record, size_t user_record_len, void *user_data);
#endif
/** /**
* Determine whether there is a committed session record for a * Determine whether there is a committed session record for a

View File

@ -836,7 +836,7 @@ _private_chat_handler(xmpp_stanza_t *const stanza, const char *const fulljid)
static gboolean static gboolean
_handle_carbons(xmpp_stanza_t *const stanza) _handle_carbons(xmpp_stanza_t *const stanza)
{ {
char *message_txt; char *message_txt = NULL;
xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS); xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);
if (!carbons) { if (!carbons) {
return FALSE; return FALSE;