first attempts to build against upstream qxmpp

This commit is contained in:
Blue 2022-08-29 21:34:25 +03:00
parent b6ba022bff
commit 87973b3b67
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
4 changed files with 84 additions and 21 deletions

View File

@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.4) cmake_minimum_required(VERSION 3.5)
project(squawk VERSION 0.2.3 LANGUAGES CXX) project(squawk VERSION 0.2.3 LANGUAGES CXX)
cmake_policy(SET CMP0076 NEW) cmake_policy(SET CMP0076 NEW)
cmake_policy(SET CMP0079 NEW) cmake_policy(SET CMP0079 NEW)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(QT_VERSION_MAJOR 5)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
@ -30,21 +31,44 @@ option(SYSTEM_QXMPP "Use system qxmpp lib" ON)
option(WITH_KWALLET "Build KWallet support module" ON) option(WITH_KWALLET "Build KWallet support module" ON)
option(WITH_KIO "Build KIO support module" ON) option(WITH_KIO "Build KIO support module" ON)
option(WITH_KCONFIG "Build KConfig support module" ON) option(WITH_KCONFIG "Build KConfig support module" ON)
option(WITH_OMEMO "Build OMEMO support module" ON)
# Dependencies # Dependencies
## Qt ## Qt
set(QT_VERSION_MAJOR 5) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets DBus Gui Xml Network Core)
find_package(Qt5 COMPONENTS Widgets DBus Gui Xml Network Core REQUIRED)
find_package(Boost COMPONENTS) find_package(Boost COMPONENTS)
target_include_directories(squawk PRIVATE ${Boost_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Boost_INCLUDE_DIRS})
target_include_directories(squawk PRIVATE ${Qt5_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}_INCLUDE_DIRS})
target_include_directories(squawk PRIVATE ${Qt5Widgets_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS})
target_include_directories(squawk PRIVATE ${Qt5DBus_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}DBus_INCLUDE_DIRS})
target_include_directories(squawk PRIVATE ${Qt5Gui_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Gui_INCLUDE_DIRS})
target_include_directories(squawk PRIVATE ${Qt5Xml_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Xml_INCLUDE_DIRS})
target_include_directories(squawk PRIVATE ${Qt5Network_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Network_INCLUDE_DIRS})
target_include_directories(squawk PRIVATE ${Qt5Core_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt${QT_VERSION_MAJOR}Core_INCLUDE_DIRS})
#OMEMO
if (WITH_OMEMO)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(OMEMO libomemo)
if (OMEMO_FOUND)
pkg_check_modules(SIGNAL libsignal-protocol-c)
if (SIGNAL_FOUND)
message("Building with support of OMEMO")
else ()
message("signal-protocol package wasn't found, trying to build without OMEMO support")
set(WITH_OMEMO OFF)
endif()
else ()
message("libomemo package wasn't found, trying to build without OMEMO support")
set(WITH_OMEMO OFF)
endif ()
else ()
message("PKG_CONFIG module wasn't found, can not check libomemo and libsignal-protocol support, trying to build without OMEMO support")
set(WITH_OMEMO OFF)
endif ()
endif ()
## QXmpp ## QXmpp
if (SYSTEM_QXMPP) if (SYSTEM_QXMPP)
@ -58,13 +82,6 @@ if (SYSTEM_QXMPP)
endif () endif ()
endif () endif ()
if (NOT SYSTEM_QXMPP)
target_link_libraries(squawk PRIVATE qxmpp)
add_subdirectory(external/qxmpp)
else ()
target_link_libraries(squawk PRIVATE QXmpp::QXmpp)
endif ()
## KIO ## KIO
if (WITH_KIO) if (WITH_KIO)
find_package(KF5KIO CONFIG) find_package(KF5KIO CONFIG)
@ -109,14 +126,38 @@ if (WITH_KCONFIG)
endif() endif()
endif() endif()
## Signal (TODO) if (NOT SYSTEM_QXMPP)
# find_package(Signal REQUIRED) message("Building with bundled QXmpp")
if (WITH_OMEMO)
set(BUILD_OMEMO ON)
else ()
set(BUILD_OMEMO OFF)
endif ()
add_subdirectory(external/qxmpp)
if (WITH_OMEMO)
target_include_directories(QXmppOmemo PRIVATE ${SIGNAL_INCLUDE_DIRS})
target_include_directories(QXmppOmemo PRIVATE ${OMEMO_INCLUDE_DIRS})
endif ()
target_link_libraries(squawk PRIVATE qxmpp)
else ()
target_link_libraries(squawk PRIVATE QXmpp::QXmpp)
endif ()
## LMDB ## LMDB
find_package(LMDB REQUIRED) find_package(LMDB REQUIRED)
# Linking # Linking
target_link_libraries(squawk PRIVATE Qt5::Core Qt5::Widgets Qt5::DBus Qt5::Network Qt5::Gui Qt5::Xml) target_link_libraries(squawk
PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::DBus
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Xml
)
target_link_libraries(squawk PRIVATE lmdb) target_link_libraries(squawk PRIVATE lmdb)
target_link_libraries(squawk PRIVATE simpleCrypt) target_link_libraries(squawk PRIVATE simpleCrypt)
# Link thread libraries on Linux # Link thread libraries on Linux
@ -166,7 +207,7 @@ install(FILES LICENSE.md DESTINATION ${CMAKE_INSTALL_DATADIR}/macaw.me/squawk)
if (CMAKE_BUILD_TYPE STREQUAL "Release") if (CMAKE_BUILD_TYPE STREQUAL "Release")
if (APPLE) if (APPLE)
add_custom_command(TARGET squawk POST_BUILD COMMENT "Running macdeployqt..." add_custom_command(TARGET squawk POST_BUILD COMMENT "Running macdeployqt..."
COMMAND "${Qt5Widgets_DIR}/../../../bin/macdeployqt" "${CMAKE_CURRENT_BINARY_DIR}/squawk.app" COMMAND "${Qt${QT_VERSION_MAJOR}Widgets_DIR}/../../../bin/macdeployqt" "${CMAKE_CURRENT_BINARY_DIR}/squawk.app"
) )
endif(APPLE) endif(APPLE)
endif() endif()

View File

@ -40,6 +40,9 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
um(new QXmppUploadRequestManager()), um(new QXmppUploadRequestManager()),
dm(client.findExtension<QXmppDiscoveryManager>()), dm(client.findExtension<QXmppDiscoveryManager>()),
rcpm(new QXmppMessageReceiptManager()), rcpm(new QXmppMessageReceiptManager()),
#ifdef WITH_OMEMO
om(new QXmppOmemoManager()),
#endif
reconnectScheduled(false), reconnectScheduled(false),
reconnectTimer(new QTimer), reconnectTimer(new QTimer),
network(p_net), network(p_net),
@ -88,6 +91,11 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
client.addExtension(rcpm); client.addExtension(rcpm);
QObject::connect(rcpm, &QXmppMessageReceiptManager::messageDelivered, mh, &MessageHandler::onReceiptReceived); QObject::connect(rcpm, &QXmppMessageReceiptManager::messageDelivered, mh, &MessageHandler::onReceiptReceived);
#ifdef WITH_OMEMO
client.addExtension(om);
qDebug("Added OMEMO manager");
#endif
reconnectTimer->setSingleShot(true); reconnectTimer->setSingleShot(true);
QObject::connect(reconnectTimer, &QTimer::timeout, this, &Account::onReconnectTimer); QObject::connect(reconnectTimer, &QTimer::timeout, this, &Account::onReconnectTimer);
@ -118,6 +126,9 @@ Account::~Account()
delete rh; delete rh;
delete reconnectTimer; delete reconnectTimer;
#ifdef WITH_OMEMO
delete om;
#endif
delete rcpm; delete rcpm;
delete dm; delete dm;
delete um; delete um;

View File

@ -42,6 +42,9 @@
#include <QXmppUploadRequestManager.h> #include <QXmppUploadRequestManager.h>
#include <QXmppVCardManager.h> #include <QXmppVCardManager.h>
#include <QXmppMessageReceiptManager.h> #include <QXmppMessageReceiptManager.h>
#ifdef WITH_OMEMO
#include <QXmppOmemoManager.h>
#endif
#include <shared/shared.h> #include <shared/shared.h>
#include <shared/identity.h> #include <shared/identity.h>
@ -176,6 +179,9 @@ private:
QXmppUploadRequestManager* um; QXmppUploadRequestManager* um;
QXmppDiscoveryManager* dm; QXmppDiscoveryManager* dm;
QXmppMessageReceiptManager* rcpm; QXmppMessageReceiptManager* rcpm;
#ifdef WITH_OMEMO
QXmppOmemoManager* om;
#endif
bool reconnectScheduled; bool reconnectScheduled;
QTimer* reconnectTimer; QTimer* reconnectTimer;

View File

@ -32,6 +32,11 @@ Core::DiscoveryHandler::DiscoveryHandler(Core::Account* account):
acc->dm->setClientCapabilitiesNode("https://git.macaw.me/blue/squawk"); acc->dm->setClientCapabilitiesNode("https://git.macaw.me/blue/squawk");
} }
Core::DiscoveryHandler::~DiscoveryHandler()
{
}
void Core::DiscoveryHandler::onItemsReceived(const QXmppDiscoveryIq& items) void Core::DiscoveryHandler::onItemsReceived(const QXmppDiscoveryIq& items)
{ {
QString server = acc->getServer(); QString server = acc->getServer();