diff --git a/.builds/openbsd.yml b/.builds/openbsd.yml index 71c070df..5f8f6c4e 100644 --- a/.builds/openbsd.yml +++ b/.builds/openbsd.yml @@ -23,7 +23,7 @@ packages: - sqlite3 sources: - - https://github.com/profanity-im/libmesode.git#0.10.1 + - https://github.com/strophe/libstrophe.git#0.11.0 - https://github.com/profanity-im/profanity environment: @@ -38,7 +38,7 @@ tasks: export AUTOCONF_VERSION=2.69 export AUTOMAKE_VERSION=1.16 - cd ~/libmesode + cd ~/libstrophe ./bootstrap.sh ./configure make diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebcc86d6..c40cf4b0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,15 +22,15 @@ jobs: docker build -f Dockerfile.${{ matrix.flavor }} -t profanity . docker run profanity ./ci-build.sh - macos: - runs-on: macos-latest - name: macOS - steps: - - uses: actions/checkout@v2 - - name: Run brew bundle - run: brew bundle - - name: Run tests - env: - # Ensure that "keg-only" Homebrew versions are used. - PKG_CONFIG_PATH: "/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/expat/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/sqlite/lib/pkgconfig:$PKG_CONFIG_PATH" - run: ./ci-build.sh +# macos: +# runs-on: macos-latest +# name: macOS +# steps: +# - uses: actions/checkout@v2 +# - name: Run brew bundle +# run: brew bundle +# - name: Run tests +# env: +# # Ensure that "keg-only" Homebrew versions are used. +# PKG_CONFIG_PATH: "/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/expat/lib/pkgconfig:/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/sqlite/lib/pkgconfig:$PKG_CONFIG_PATH" +# run: ./ci-build.sh diff --git a/Dockerfile.debian b/Dockerfile.debian index 4b8f0596..2d85ff43 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -29,11 +29,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python-dev-is-python3 \ libsqlite3-dev -RUN mkdir -p /usr/src/{stabber,libmesode,profanity} +RUN mkdir -p /usr/src/{stabber,libstrophe,profanity} WORKDIR /usr/src RUN git clone git://github.com/boothj5/stabber.git -RUN git clone git://github.com/profanity-im/libmesode.git +RUN git clone git://github.com/strophe/libstrophe.git WORKDIR /usr/src/stabber RUN ./bootstrap.sh @@ -41,7 +41,7 @@ RUN ./configure --prefix=/usr --disable-dependency-tracking RUN make RUN make install -WORKDIR /usr/src/libmesode +WORKDIR /usr/src/libstrophe RUN ./bootstrap.sh RUN ./configure --prefix=/usr RUN make diff --git a/Dockerfile.fedora b/Dockerfile.fedora index 0307cd53..4a49cc0f 100644 --- a/Dockerfile.fedora +++ b/Dockerfile.fedora @@ -53,9 +53,9 @@ RUN make RUN make install WORKDIR /usr/src -RUN mkdir -p /usr/src/libmesode -RUN git clone git://github.com/profanity-im/libmesode.git -WORKDIR /usr/src/libmesode +RUN mkdir -p /usr/src/libstrophe +RUN git clone git://github.com/strophe/libstrophe.git +WORKDIR /usr/src/libstrophe RUN ./bootstrap.sh RUN ./configure --prefix=/usr RUN make diff --git a/Dockerfile.tumbleweed b/Dockerfile.tumbleweed index 217476f3..620b83cf 100644 --- a/Dockerfile.tumbleweed +++ b/Dockerfile.tumbleweed @@ -20,7 +20,6 @@ RUN zypper --non-interactive in --no-recommends \ libexpat-devel \ libgcrypt-devel \ libgpgme-devel \ - libmesode-devel \ libstrophe-devel \ libmicrohttpd-devel \ libnotify-devel \ diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 3d445b53..840cd736 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -29,11 +29,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python-dev \ libsqlite3-dev -RUN mkdir -p /usr/src/{stabber,libmesode,profanity} +RUN mkdir -p /usr/src/{stabber,libstrophe,profanity} WORKDIR /usr/src RUN git clone git://github.com/boothj5/stabber.git -RUN git clone git://github.com/profanity-im/libmesode.git +RUN git clone git://github.com/strophe/libstrophe.git # TODO: Re-enable once libmicrohttpd-dev has been updated. #WORKDIR /usr/src/stabber @@ -42,7 +42,7 @@ RUN git clone git://github.com/profanity-im/libmesode.git #RUN make #RUN make install -WORKDIR /usr/src/libmesode +WORKDIR /usr/src/libstrophe RUN ./bootstrap.sh RUN ./configure --prefix=/usr RUN make diff --git a/configure.ac b/configure.ac index ce79743d..566c3c80 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([profanity], [0.12.0], [jubalh@iodoru.org]) +AC_INIT([profanity],[0.12.0],[jubalh@iodoru.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/main.c]) @@ -10,7 +10,7 @@ AM_INIT_AUTOMAKE([foreign subdir-objects]) ### Checks for programs. AC_PROG_CC -AC_PROG_LIBTOOL +LT_INIT ## Check for LFS AC_SYS_LARGEFILE @@ -134,21 +134,14 @@ LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" AS_IF([test "x$PTHREAD_CC" != x], [ CC="$PTHREAD_CC" ]) -### Check for libmesode, fall back to libstrophe -### TODO libmesode support will be removed in the future, rewrite this section -PKG_CHECK_MODULES([libmesode], [libmesode >= 0.10.0], - [LIBS="$libmesode_LIBS $LIBS" CFLAGS="$CFLAGS $libmesode_CFLAGS" XMPP_LIB="libmesode" AC_DEFINE([HAVE_LIBMESODE], [1], [libmesode])], - [PKG_CHECK_MODULES([libstrophe], [libstrophe >= 0.10.0], - [LIBS="$libstrophe_LIBS $LIBS" CFLAGS="$CFLAGS $libstrophe_CFLAGS" XMPP_LIB="libstrophe" AC_DEFINE([HAVE_LIBSTROPHE], [1], [libstrophe])], - [XMPP_LIB=""])]) +### Check for libstrophe +PKG_CHECK_MODULES([libstrophe], [libstrophe >= 0.11.0], + [LIBS="$libstrophe_LIBS $LIBS" CFLAGS="$CFLAGS $libstrophe_CFLAGS" XMPP_LIB="libstrophe" AC_DEFINE([HAVE_LIBSTROPHE], [1], [libstrophe])], + [XMPP_LIB=""]) AC_MSG_CHECKING([whether ${XMPP_LIB} works]) AC_LINK_IFELSE([AC_LANG_SOURCE([[ - #ifdef HAVE_LIBMESODE - #include - #else #include - #endif int main() { xmpp_initialize(); diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index b8a103a7..c61b5c44 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -177,7 +177,6 @@ cmd_execute_connect(ProfWin* window, const char* const account) gboolean cmd_tls_certpath(ProfWin* window, const char* const command, gchar** args) { -#ifdef HAVE_LIBMESODE if (g_strcmp0(args[1], "set") == 0) { if (args[2] == NULL) { cons_bad_cmd_usage(command); @@ -212,16 +211,11 @@ cmd_tls_certpath(ProfWin* window, const char* const command, gchar** args) cons_bad_cmd_usage(command); return TRUE; } -#else - cons_show("Certificate path setting only supported when built with libmesode."); - return TRUE; -#endif } gboolean cmd_tls_trust(ProfWin* window, const char* const command, gchar** args) { -#ifdef HAVE_LIBMESODE jabber_conn_status_t conn_status = connection_get_status(); if (conn_status != JABBER_CONNECTED) { cons_show("You are currently not connected."); @@ -245,16 +239,11 @@ cmd_tls_trust(ProfWin* window, const char* const command, gchar** args) tlscerts_add(cert); tlscerts_free(cert); return TRUE; -#else - cons_show("Manual certificate trust only supported when built with libmesode."); - return TRUE; -#endif } gboolean cmd_tls_trusted(ProfWin* window, const char* const command, gchar** args) { -#ifdef HAVE_LIBMESODE GList* certs = tlscerts_list(); GList* curr = certs; @@ -272,16 +261,11 @@ cmd_tls_trusted(ProfWin* window, const char* const command, gchar** args) } g_list_free_full(certs, (GDestroyNotify)tlscerts_free); return TRUE; -#else - cons_show("Manual certificate trust only supported when built with libmesode."); - return TRUE; -#endif } gboolean cmd_tls_revoke(ProfWin* window, const char* const command, gchar** args) { -#ifdef HAVE_LIBMESODE if (args[1] == NULL) { cons_bad_cmd_usage(command); } else { @@ -293,16 +277,11 @@ cmd_tls_revoke(ProfWin* window, const char* const command, gchar** args) } } return TRUE; -#else - cons_show("Manual certificate trust only supported when built with libmesode."); - return TRUE; -#endif } gboolean cmd_tls_cert(ProfWin* window, const char* const command, gchar** args) { -#ifdef HAVE_LIBMESODE if (args[1]) { TLSCertificate* cert = tlscerts_get_trusted(args[1]); if (!cert) { @@ -332,10 +311,6 @@ cmd_tls_cert(ProfWin* window, const char* const command, gchar** args) tlscerts_free(cert); return TRUE; } -#else - cons_show("Certificate fetching not supported."); - return TRUE; -#endif } gboolean diff --git a/src/config/preferences.c b/src/config/preferences.c index 16da777d..63d665f6 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1088,7 +1088,6 @@ prefs_set_roster_header_char(char* ch) } } - void prefs_clear_roster_header_char(void) { diff --git a/src/main.c b/src/main.c index 6ec9eff5..13871732 100644 --- a/src/main.c +++ b/src/main.c @@ -125,12 +125,7 @@ main(int argc, char** argv) g_print("Build information:\n"); -#ifdef HAVE_LIBMESODE - g_print("XMPP library: libmesode\n"); -#endif -#ifdef HAVE_LIBSTROPHE g_print("XMPP library: libstrophe\n"); -#endif if (is_notify_enabled()) { g_print("Desktop notification support: Enabled\n"); diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c index 5d368253..f67cc00f 100644 --- a/src/ui/rosterwin.c +++ b/src/ui/rosterwin.c @@ -314,7 +314,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin) indent--; } } - char *ch = prefs_get_roster_contact_char(); + char* ch = prefs_get_roster_contact_char(); if (ch) { g_string_append_printf(msg, "%s", ch); free(ch); @@ -377,7 +377,7 @@ _rosterwin_contact(ProfLayoutSplit* layout, PContact contact) indent--; } } - char *ch = prefs_get_roster_contact_char(); + char* ch = prefs_get_roster_contact_char(); if (ch) { g_string_append_printf(msg, "%s", ch); free(ch); diff --git a/src/xmpp/blocking.c b/src/xmpp/blocking.c index 7c55b1bf..e68999d2 100644 --- a/src/xmpp/blocking.c +++ b/src/xmpp/blocking.c @@ -38,13 +38,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include diff --git a/src/xmpp/bookmark.c b/src/xmpp/bookmark.c index 4e40e3ec..916c8195 100644 --- a/src/xmpp/bookmark.c +++ b/src/xmpp/bookmark.c @@ -41,13 +41,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "common.h" #include "log.h" diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index 98a5c399..638b2c90 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -45,13 +45,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "common.h" #include "log.h" diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h index 0760f7d7..bbc1cf8e 100644 --- a/src/xmpp/capabilities.h +++ b/src/xmpp/capabilities.h @@ -38,13 +38,7 @@ #include "config.h" -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "xmpp/xmpp.h" diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 5570fb1a..516006a9 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -43,13 +43,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "common.h" #include "log.h" @@ -94,10 +88,8 @@ static void _xmpp_file_logger(void* const userdata, const xmpp_log_level_t level static void _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status, const int error, xmpp_stream_error_t* const stream_error, void* const userdata); -#ifdef HAVE_LIBMESODE -TLSCertificate* _xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert); -static int _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg); -#endif +TLSCertificate* _xmppcert_to_profcert(const xmpp_tlscert_t* xmpptlscert); +static int _connection_certfail_cb(const xmpp_tlscert_t* xmpptlscert, const char* errormsg); static void _random_bytes_init(void); static void _random_bytes_close(void); @@ -220,28 +212,20 @@ connection_connect(const char* const jid, const char* const passwd, const char* #undef LOG_FLAG_IF_SET } -#ifdef HAVE_LIBMESODE char* cert_path = prefs_get_tls_certpath(); if (cert_path) { - xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path); + xmpp_conn_set_capath(conn.xmpp_conn, cert_path); free(cert_path); } + xmpp_conn_set_certfail_handler(conn.xmpp_conn, _connection_certfail_cb); + int connect_status = xmpp_connect_client( conn.xmpp_conn, altdomain, port, - _connection_certfail_cb, _connection_handler, conn.xmpp_ctx); -#else - int connect_status = xmpp_connect_client( - conn.xmpp_conn, - altdomain, - port, - _connection_handler, - conn.xmpp_ctx); -#endif if (connect_status == 0) { conn.conn_status = JABBER_CONNECTING; @@ -555,28 +539,20 @@ connection_register(const char* const altdomain, int port, const char* const tls reg->username = strdup(username); reg->password = strdup(password); -#ifdef HAVE_LIBMESODE char* cert_path = prefs_get_tls_certpath(); if (cert_path) { - xmpp_conn_tlscert_path(conn.xmpp_conn, cert_path); + xmpp_conn_set_capath(conn.xmpp_conn, cert_path); free(cert_path); } + xmpp_conn_set_certfail_handler(conn.xmpp_conn, _connection_certfail_cb); + int connect_status = xmpp_connect_raw( conn.xmpp_conn, altdomain, port, - _connection_certfail_cb, _register_handler, reg); -#else - int connect_status = xmpp_connect_raw( - conn.xmpp_conn, - altdomain, - port, - _register_handler, - reg); -#endif if (connect_status == 0) { conn.conn_status = JABBER_RAW_CONNECTING; @@ -645,17 +621,15 @@ connection_clear_data(void) } } -#ifdef HAVE_LIBMESODE TLSCertificate* connection_get_tls_peer_cert(void) { - xmpp_tlscert_t* xmpptlscert = xmpp_conn_tls_peer_cert(conn.xmpp_conn); + xmpp_tlscert_t* xmpptlscert = xmpp_conn_get_peer_cert(conn.xmpp_conn); TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert); - xmpp_conn_free_tlscert(conn.xmpp_ctx, xmpptlscert); + xmpp_tlscert_free(xmpptlscert); return cert; } -#endif gboolean connection_is_secured(void) @@ -971,9 +945,8 @@ _connection_handler(xmpp_conn_t* const xmpp_conn, const xmpp_conn_event_t status } } -#ifdef HAVE_LIBMESODE static int -_connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg) +_connection_certfail_cb(const xmpp_tlscert_t* xmpptlscert, const char* errormsg) { TLSCertificate* cert = _xmppcert_to_profcert(xmpptlscert); @@ -984,20 +957,21 @@ _connection_certfail_cb(xmpp_tlscert_t* xmpptlscert, const char* const errormsg) } TLSCertificate* -_xmppcert_to_profcert(xmpp_tlscert_t* xmpptlscert) +_xmppcert_to_profcert(const xmpp_tlscert_t* xmpptlscert) { + int version = (int)strtol( + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_VERSION), NULL, 10); return tlscerts_new( - xmpp_conn_tlscert_fingerprint(xmpptlscert), - xmpp_conn_tlscert_version(xmpptlscert), - xmpp_conn_tlscert_serialnumber(xmpptlscert), - xmpp_conn_tlscert_subjectname(xmpptlscert), - xmpp_conn_tlscert_issuername(xmpptlscert), - xmpp_conn_tlscert_notbefore(xmpptlscert), - xmpp_conn_tlscert_notafter(xmpptlscert), - xmpp_conn_tlscert_key_algorithm(xmpptlscert), - xmpp_conn_tlscert_signature_algorithm(xmpptlscert)); + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_FINGERPRINT_SHA1), + version, + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SERIALNUMBER), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SUBJECT), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_ISSUER), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_NOTBEFORE), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_NOTAFTER), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_KEYALG), + xmpp_tlscert_get_string(xmpptlscert, XMPP_CERT_SIGALG)); } -#endif static xmpp_log_t* _xmpp_get_file_logger(void) diff --git a/src/xmpp/form.c b/src/xmpp/form.c index dc8c583c..5290c83f 100644 --- a/src/xmpp/form.c +++ b/src/xmpp/form.c @@ -38,13 +38,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include diff --git a/src/xmpp/form.h b/src/xmpp/form.h index b305addf..73a3d6c7 100644 --- a/src/xmpp/form.h +++ b/src/xmpp/form.h @@ -36,13 +36,7 @@ #ifndef XMPP_FORM_H #define XMPP_FORM_H -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "xmpp/xmpp.h" diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index dd3c2423..ebc052fc 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -44,13 +44,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "profanity.h" #include "log.h" diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 051d1ece..1a964846 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -39,13 +39,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "profanity.h" #include "log.h" diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 2982274d..a9b07daa 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -42,13 +42,7 @@ #include #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "profanity.h" #include "log.h" diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 2b5a1696..fd7ceecf 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -41,13 +41,7 @@ #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "profanity.h" #include "log.h" diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 3a1cb4a5..d28ed3d2 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -48,13 +48,7 @@ #include -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "common.h" #include "log.h" diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index bd61f2f4..e2c22bd8 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -38,13 +38,7 @@ #include "config.h" -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index bb561080..16293d73 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -40,13 +40,7 @@ #include "config.h" -#ifdef HAVE_LIBMESODE -#include -#endif - -#ifdef HAVE_LIBSTROPHE #include -#endif #include "config/accounts.h" #include "config/tlscerts.h" @@ -199,9 +193,7 @@ char* connection_get_barejid(void); char* connection_get_user(void); char* connection_create_uuid(void); void connection_free_uuid(char* uuid); -#ifdef HAVE_LIBMESODE 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);