diff --git a/CMakeLists.txt b/CMakeLists.txt index b978c33..5fb09fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,13 @@ set(CMAKE_AUTORCC ON) include(GNUInstallDirs) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") -add_executable(squawk) +set(WIN32_FLAG "") +if (WIN32) + if (CMAKE_BUILD_TYPE STREQUAL "Release") + set(WIN32_FLAG WIN32) + endif() +endif(WIN32) +add_executable(squawk ${WIN32_FLAG}) target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}) option(SYSTEM_QXMPP "Use system qxmpp lib" ON) @@ -97,11 +103,13 @@ endif () message("Build type: ${CMAKE_BUILD_TYPE}") +if(CMAKE_COMPILER_IS_GNUCXX) target_compile_options(squawk PRIVATE "-Wall;-Wextra" "$<$:-g>" "$<$:-O3>" ) +endif(CMAKE_COMPILER_IS_GNUCXX) add_subdirectory(core) add_subdirectory(external/simpleCrypt) @@ -114,3 +122,5 @@ add_subdirectory(ui) # Install the executable install(TARGETS squawk DESTINATION ${CMAKE_INSTALL_BINDIR}) + +target_sources(squawk PRIVATE ${SQUAWK_WIN_RC} ${APP_ICON_MACOSX}) diff --git a/README.md b/README.md index f2101d6..892168c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ ### Prerequisites - QT 5.12 *(lower versions might work but it wasn't tested)* -- uuid _(usually included in some other package, for example it's ***libutil-linux*** in archlinux)_ - lmdb - CMake 3.0 or higher - qxmpp 1.1.0 or higher @@ -45,7 +44,7 @@ $ git clone https://git.macaw.me/blue/squawk $ cd squawk $ mkdir build $ cd build -$ cmake .. +$ cmake .. [-DLMDB_DIR:PATH=/path/to/lmdb] $ cmake --build . ``` @@ -58,7 +57,7 @@ $ git clone --recurse-submodules https://git.macaw.me/blue/squawk $ cd squawk $ mkdir build $ cd build -$ cmake .. -D SYSTEM_QXMPP=False +$ cmake .. -D SYSTEM_QXMPP=False [-DLMDB_DIR:PATH=/path/to/lmdb] $ cmake --build . ``` diff --git a/cmake/FindLMDB.cmake b/cmake/FindLMDB.cmake index 79788f1..d6f2cd3 100644 --- a/cmake/FindLMDB.cmake +++ b/cmake/FindLMDB.cmake @@ -25,10 +25,15 @@ find_path(LMDB_ROOT_DIR ) find_library(LMDB_LIBRARIES - NAMES lmdb + NAMES liblmdb.a liblmdb.so liblmdb.so.a liblmdb.dll.a # We want lmdb to be static, if possible HINTS ${LMDB_ROOT_DIR}/lib ) +add_library(lmdb UNKNOWN IMPORTED) +set_target_properties(lmdb PROPERTIES + IMPORTED_LOCATION ${LMDB_LIBRARIES} + ) + find_path(LMDB_INCLUDE_DIRS NAMES lmdb.h HINTS ${LMDB_ROOT_DIR}/include diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 3b160e2..e30cc7e 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,3 +1,8 @@ +set(SIGNALCATCHER_SOURCE signalcatcher.cpp) +if(WIN32) + set(SIGNALCATCHER_SOURCE signalcatcher_win32.cpp) +endif(WIN32) + target_sources(squawk PRIVATE account.cpp account.h @@ -13,7 +18,7 @@ target_sources(squawk PRIVATE networkaccess.h rosteritem.cpp rosteritem.h - signalcatcher.cpp + ${SIGNALCATCHER_SOURCE} signalcatcher.h squawk.cpp squawk.h diff --git a/core/signalcatcher_win32.cpp b/core/signalcatcher_win32.cpp new file mode 100644 index 0000000..ca7b5a2 --- /dev/null +++ b/core/signalcatcher_win32.cpp @@ -0,0 +1,42 @@ +/* + * Squawk messenger. + * Copyright (C) 2021 Shunf4 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "signalcatcher.h" +#include + +SignalCatcher::SignalCatcher(QCoreApplication *p_app, QObject *parent): + QObject(parent), + app(p_app) +{ +} + +SignalCatcher::~SignalCatcher() +{} + +void SignalCatcher::handleSigInt() +{ +} + +void SignalCatcher::intSignalHandler(int unused) +{ +} + +int SignalCatcher::setup_unix_signal_handlers() +{ + return 0; +} diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 86433f3..42cb360 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -1,11 +1,41 @@ target_sources(squawk PRIVATE resources.qrc) configure_file(images/logo.svg squawk.svg COPYONLY) +configure_file(squawk.rc squawk.rc COPYONLY) -execute_process(COMMAND convert -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +if(WIN32) + set(CONVERT_BIN magick convert) +else(WIN32) + set(CONVERT_BIN convert) +endif(WIN32) +execute_process(COMMAND ${CONVERT_BIN} -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND ${CONVERT_BIN} -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND ${CONVERT_BIN} -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND ${CONVERT_BIN} -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +if (WIN32) + execute_process(COMMAND ${CONVERT_BIN} squawk48.png squawk64.png squawk256.png squawk.ico WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc" PARENT_SCOPE) +endif(WIN32) + +if (APPLE) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icns.iconset") + execute_process(COMMAND convert -background none -size 16x16 squawk.svg icns.iconset/icon_16x16.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_16x16@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_32x32.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !64x64 squawk.svg "icns.iconset/icon_32x32@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !128x128 squawk.svg "icns.iconset/icon_128x128.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !256x256 squawk.svg "icns.iconset/icon_128x128@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !256x256 squawk.svg "icns.iconset/icon_256x256.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_256x256@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_512x512.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !1024x1024 squawk.svg "icns.iconset/icon_512x512@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND iconutil -c icns "icns.iconset" -o "squawk.icns" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set(MACOSX_BUNDLE_ICON_FILE squawk.icns PARENT_SCOPE) + set(APP_ICON_MACOSX ${CMAKE_CURRENT_BINARY_DIR}/squawk.icns PARENT_SCOPE) + set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources") +endif (APPLE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk48.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/48x48/apps RENAME squawk.png) diff --git a/resources/squawk.rc b/resources/squawk.rc new file mode 100644 index 0000000..6061f20 --- /dev/null +++ b/resources/squawk.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON "squawk.ico" diff --git a/shared/utils.cpp b/shared/utils.cpp index 924be85..a7a4ecb 100644 --- a/shared/utils.cpp +++ b/shared/utils.cpp @@ -17,15 +17,11 @@ */ #include "utils.h" +#include QString Shared::generateUUID() { - uuid_t uuid; - uuid_generate(uuid); - - char uuid_str[36]; - uuid_unparse_lower(uuid, uuid_str); - return uuid_str; + return QUuid::createUuid().toString(); } diff --git a/shared/utils.h b/shared/utils.h index a8a17d5..6dcb141 100644 --- a/shared/utils.h +++ b/shared/utils.h @@ -24,9 +24,8 @@ #include #include -//#include "KIO/OpenFileManagerWindowJob" +// #include "KIO/OpenFileManagerWindowJob" -#include #include namespace Shared { diff --git a/signalcatcher_win32.cpp b/signalcatcher_win32.cpp new file mode 100644 index 0000000..ca7b5a2 --- /dev/null +++ b/signalcatcher_win32.cpp @@ -0,0 +1,42 @@ +/* + * Squawk messenger. + * Copyright (C) 2021 Shunf4 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "signalcatcher.h" +#include + +SignalCatcher::SignalCatcher(QCoreApplication *p_app, QObject *parent): + QObject(parent), + app(p_app) +{ +} + +SignalCatcher::~SignalCatcher() +{} + +void SignalCatcher::handleSigInt() +{ +} + +void SignalCatcher::intSignalHandler(int unused) +{ +} + +int SignalCatcher::setup_unix_signal_handlers() +{ + return 0; +}