diff --git a/CMakeLists.txt b/CMakeLists.txt index bc566f94..cccaec22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(OTPClient VERSION "3.5.2" LANGUAGES "C") +project(OTPClient VERSION "3.5.3" LANGUAGES "C") include(GNUInstallDirs) configure_file("src/common/version.h.in" "version.h") @@ -10,8 +10,7 @@ include_directories(${PROJECT_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -option(USE_FLATPAK_APP_FOLDER "Use flatpak app's config folder to store the database" OFF) -option(BUILD_GUI "Build the GUI" ON) +option(IS_FLATPAK "Use flatpak app's config folder to store the database" OFF) option(BUILD_CLI "Build the CLI" ON) set(CMAKE_C_STANDARD 11) @@ -23,15 +22,10 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2") if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pie -fPIE") endif() -if(USE_FLATPAK_APP_FOLDER) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_FLATPAK_APP_FOLDER") -endif() -if(BUILD_GUI) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_GUI") -endif() -if(BUILD_CLI) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBUILD_CLI") +if(IS_FLATPAK) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIS_FLATPAK") endif() + add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\") @@ -57,219 +51,67 @@ pkg_check_modules(PROTOC REQUIRED libprotobuf-c>=1.3.0) pkg_check_modules(LIBSECRET REQUIRED libsecret-1>=0.20.0) pkg_check_modules(LIBQRENCODE REQUIRED libqrencode>=4.0.2) -set(GUI_HEADER_FILES - src/common/common.h - src/add-common.h - src/gui-common.h - src/data.h - src/db-misc.h - src/file-size.h - src/get-builder.h - src/gquarks.h - src/imports.h - src/liststore-misc.h - src/manual-add-cb.h - src/message-dialogs.h - src/otpclient.h - src/parse-uri.h - src/password-cb.h - src/qrcode-parser.h - src/treeview.h - src/common/exports.h - src/lock-app.h - src/common/get-providers-data.h - src/change-db-cb.h - src/new-db-cb.h - src/db-actions.h - src/google-migration.pb-c.h - src/secret-schema.h - src/change-pwd-cb.h - src/settings-cb.h - src/shortcuts-cb.h - src/webcam-add-cb.h - src/edit-row-cb.h - src/show-qr-cb.h src/dbinfo-cb.h - src/change-file-cb.h) - -set(GUI_SOURCE_FILES - src/common/common.c - src/add-common.c - src/common/andotp.c - src/app.c - src/gui-common.c - src/db-misc.c - src/edit-row-cb.c - src/file-size.c - src/get-builder.c - src/gquarks.c - src/imports.c - src/liststore-misc.c - src/main.c - src/manual-add-cb.c - src/message-dialogs.c - src/parse-data.c - src/parse-uri.c - src/password-cb.c - src/qrcode-parser.c - src/add-from-qr.c - src/settings-cb.c - src/shortcuts-cb.c - src/treeview.c - src/webcam-add-cb.c - src/exports.c - src/lock-app.c - src/common/freeotp.c - src/common/aegis.c - src/change-db-cb.c - src/new-db-cb.c - src/db-actions.c - src/change-file-cb.c - src/google-migration.pb-c.c - src/secret-schema.c - src/about_diag_cb.c - src/show-qr-cb.c - src/setup-signals-shortcuts.c - src/change-pwd-cb.c - src/dbinfo-cb.c - src/common/twofas.c - src/common/authpro.c) - -set(CLI_HEADER_FILES - src/cli/get-data.h - src/common/common.h - src/db-misc.h - src/gquarks.h - src/file-size.h - src/common/exports.h - src/parse-uri.h - src/common/get-providers-data.h - src/google-migration.pb-c.h - src/secret-schema.h - src/cli/main.h +set(COMMON_INCDIRS + ${GTK3_INCLUDE_DIRS} + ${GCRYPT_INCLUDE_DIRS} + ${COTP_INCLUDE_DIRS} + ${JANSSON_INCLUDE_DIRS} + ${UUID_INCLUDE_DIRS} + ${PROTOC_INCLUDE_DIRS} + ${LIBSECRET_INCLUDE_DIRS} + ${LIBQRENCODE_INCLUDE_DIRS} ) -set(CLI_SOURCE_FILES - src/cli/main.c - src/cli/get-data.c - src/common/common.c - src/db-misc.c - src/gquarks.c - src/cli/exec-action.c - src/file-size.c - src/parse-uri.c - src/common/andotp.c - src/common/aegis.c - src/common/freeotp.c - src/secret-schema.c - src/google-migration.pb-c.c - src/common/twofas.c - src/common/authpro.c) +set(COMMON_LIBS + ${GTK3_LIBRARIES} + ${GCRYPT_LIBRARIES} + ${COTP_LIBRARIES} + ${JANSSON_LIBRARIES} + ${UUID_LIBRARIES} + ${PROTOC_LIBRARIES} + ${LIBSECRET_LIBRARIES} + ${LIBQRENCODE_LIBRARIES} +) -if(BUILD_GUI AND BUILD_CLI) - list(APPEND CLI_SOURCE_FILES - src/treeview.c - src/liststore-misc.c - src/gui-common.c - src/add-common.c - src/imports.c - src/password-cb.c - src/get-builder.c - src/message-dialogs.c) +## GUI START +add_subdirectory(src/gui) +target_link_libraries(${PROJECT_NAME} + ${PNG_LIBRARIES} + ${ZBAR_LIBRARIES} + ${COMMON_LIBS} +) +set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "otpclient") - list(APPEND CLI_HEADER_FILES - src/treeview.h - src/liststore-misc.h - src/gui-common.h - src/add-common.h - src/imports.h - src/password-cb.h - src/get-builder.h - src/message-dialogs.h) -endif() +install(TARGETS ${PROJECT_NAME} DESTINATION bin) -if(BUILD_GUI) - include_directories(${GTK3_INCLUDE_DIRS} - ${GCRYPT_INCLUDE_DIRS} - ${COTP_INCLUDE_DIRS} - ${LIBZIP_INCLUDE_DIRS} - ${PNG_INCLUDE_DIRS} - ${JANSSON_INCLUDE_DIRS} - ${ZBAR_INCLUDE_DIRS} - ${UUID_INCLUDE_DIRS} - ${PROTOC_INCLUDE_DIRS} - ${LIBSECRET_INCLUDE_DIRS} - ${LIBQRENCODE_INCLUDE_DIRS}) +install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/applications) - add_executable(${PROJECT_NAME} ${GUI_SOURCE_FILES} ${GUI_HEADER_FILES}) - target_link_libraries(${PROJECT_NAME} - ${GTK3_LIBRARIES} - ${GCRYPT_LIBRARIES} - ${COTP_LIBRARIES} - ${LIBZIP_LIBRARIES} - ${PNG_LIBRARIES} - ${JANSSON_LIBRARIES} - ${ZBAR_LIBRARIES} - ${UUID_LIBRARIES} - ${PROTOC_LIBRARIES} - ${LIBSECRET_LIBRARIES} - ${LIBQRENCODE_LIBRARIES}) +install(FILES + src/gui/ui/otpclient.ui + src/gui/ui/add_popover.ui + src/gui/ui/settings_popover.ui + src/gui/ui/shortcuts.ui + DESTINATION share/otpclient) - set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "otpclient") - install(TARGETS ${PROJECT_NAME} DESTINATION bin) -endif() +install(FILES man/otpclient.1.gz DESTINATION share/man/man1) +install(FILES + data/icons/com.github.paolostivanin.OTPClient.svg + data/icons/com.github.paolostivanin.OTPClient-symbolic.svg + DESTINATION share/icons/hicolor/scalable/apps) +## GUI END +## CLI START if(BUILD_CLI) - include_directories(${GTK3_INCLUDE_DIRS} - ${GCRYPT_INCLUDE_DIRS} - ${COTP_INCLUDE_DIRS} - ${JANSSON_INCLUDE_DIRS} - ${UUID_INCLUDE_DIRS} - ${PROTOC_INCLUDE_DIRS} - ${LIBSECRET_INCLUDE_DIRS}) - if(BUILD_GUI) - include_directories( - ${LIBZIP_INCLUDE_DIRS} - ${PNG_INCLUDE_DIRS} - ${ZBAR_INCLUDE_DIRS} - ${LIBQRENCODE_INCLUDE_DIRS}) - endif() + add_subdirectory(src/cli) + target_link_libraries(${PROJECT_NAME}-cli + ${COMMON_LIBS} + ) + set_target_properties(${PROJECT_NAME}-cli PROPERTIES OUTPUT_NAME "otpclient-cli") - add_executable(${PROJECT_NAME}-cli ${CLI_SOURCE_FILES} ${CLI_HEADER_FILES}) - target_link_libraries(${PROJECT_NAME}-cli - ${GLIB2_LIBRARIES} - ${GIO_LIBRARIES} - ${GCRYPT_LIBRARIES} - ${COTP_LIBRARIES} - ${JANSSON_LIBRARIES} - ${UUID_LIBRARIES} - ${LIBSECRET_LIBRARIES} - ${PROTOC_LIBRARIES}) - if(BUILD_GUI) - target_link_libraries(${PROJECT_NAME}-cli - ${GTK3_LIBRARIES} - ${LIBZIP_LIBRARIES} - ${PNG_LIBRARIES} - ${ZBAR_LIBRARIES} - ${PROTOC_LIBRARIES} - ${LIBSECRET_LIBRARIES} - ${UUID_LIBRARIES} - ${LIBQRENCODE_LIBRARIES}) - endif() + install(TARGETS ${PROJECT_NAME}-cli DESTINATION bin) - set_target_properties(${PROJECT_NAME}-cli PROPERTIES OUTPUT_NAME "otpclient-cli") - install(TARGETS ${PROJECT_NAME}-cli DESTINATION bin) + install(FILES man/otpclient-cli.1.gz DESTINATION share/man/man1) endif() +## CLI END -install(FILES data/com.github.paolostivanin.OTPClient.desktop DESTINATION share/applications) -install(FILES data/com.github.paolostivanin.OTPClient.appdata.xml DESTINATION share/metainfo) - -install(FILES src/ui/otpclient.ui DESTINATION share/otpclient) -install(FILES src/ui/add_popover.ui DESTINATION share/otpclient) -install(FILES src/ui/settings_popover.ui DESTINATION share/otpclient) -install(FILES src/ui/shortcuts.ui DESTINATION share/otpclient) - -install(FILES man/otpclient.1.gz DESTINATION share/man/man1) -install(FILES man/otpclient-cli.1.gz DESTINATION share/man/man1) - -install(FILES data/icons/com.github.paolostivanin.OTPClient.svg DESTINATION share/icons/hicolor/scalable/apps) -install(FILES data/icons/com.github.paolostivanin.OTPClient-symbolic.svg DESTINATION share/icons/hicolor/scalable/apps) +install(FILES data/com.github.paolostivanin.OTPClient.appdata.xml DESTINATION share/metainfo) \ No newline at end of file diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt new file mode 100644 index 00000000..82b60f0d --- /dev/null +++ b/src/cli/CMakeLists.txt @@ -0,0 +1,53 @@ +set(CLI_HEADER_FILES + main.h + get-data.h + ../gui/db-misc.h + ../gui/gquarks.h + ../gui/file-size.h + ../gui/parse-uri.h + ../gui/google-migration.pb-c.h + ../gui/secret-schema.h + ../gui/treeview.h + ../gui/liststore-misc.h + ../gui/gui-common.h + ../gui/add-common.h + ../gui/imports.h + ../gui/password-cb.h + ../gui/get-builder.h + ../gui/message-dialogs.h + ../common/exports.h + ../common/common.h + ../common/get-providers-data.h +) + +set(CLI_SOURCE_FILES + main.c + get-data.c + exec-action.c + ../gui/db-misc.c + ../gui/gquarks.c + ../gui/file-size.c + ../gui/parse-uri.c + ../gui/secret-schema.c + ../gui/google-migration.pb-c.c + ../gui/treeview.c + ../gui/liststore-misc.c + ../gui/gui-common.c + ../gui/add-common.c + ../gui/imports.c + ../gui/password-cb.c + ../gui/get-builder.c + ../gui/message-dialogs.c + ../common/common.c + ../common/andotp.c + ../common/aegis.c + ../common/freeotp.c + ../common/twofas.c + ../common/authpro.c +) + +include_directories( + ${COMMON_INCDIRS} +) + +add_executable(${PROJECT_NAME}-cli ${CLI_SOURCE_FILES} ${CLI_HEADER_FILES}) \ No newline at end of file diff --git a/src/cli/exec-action.c b/src/cli/exec-action.c index 6fe233a4..db12bc1c 100644 --- a/src/cli/exec-action.c +++ b/src/cli/exec-action.c @@ -4,13 +4,13 @@ #include #include #include "main.h" -#include "../secret-schema.h" +#include "../gui/secret-schema.h" #include "../common/common.h" -#include "../db-misc.h" +#include "../gui/db-misc.h" #include "get-data.h" #include "../common/exports.h" -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK static gchar *get_db_path (void); #endif @@ -22,7 +22,7 @@ static gboolean get_use_secretservice (void); gboolean exec_action (CmdlineOpts *cmdline_opts, DatabaseData *db_data) { -#ifdef USE_FLATPAK_APP_FOLDER +#ifdef IS_FLATPAK db_data->db_path = g_build_filename (g_get_user_data_dir (), "otpclient-db.enc", NULL); // on the first run the cfg file is not created in the flatpak version because we use a non-changeable db path gchar *cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); @@ -82,7 +82,7 @@ gboolean exec_action (CmdlineOpts *cmdline_opts, if (cmdline_opts->export) { gchar *export_directory; -#ifdef USE_FLATPAK_APP_FOLDER +#ifdef IS_FLATPAK export_directory = g_get_user_data_dir (); #else export_directory = (cmdline_opts->export_dir != NULL) ? cmdline_opts->export_dir : (gchar *)g_get_home_dir (); @@ -168,7 +168,7 @@ gboolean exec_action (CmdlineOpts *cmdline_opts, return TRUE; } -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK static gchar * get_db_path (void) { diff --git a/src/cli/get-data.c b/src/cli/get-data.c index 5d4bdc9c..6b04dbbb 100644 --- a/src/cli/get-data.c +++ b/src/cli/get-data.c @@ -2,7 +2,7 @@ #include #include #include -#include "../db-misc.h" +#include "../gui/db-misc.h" #include "../common/common.h" static gint compare_strings (const gchar *s1, diff --git a/src/cli/get-data.h b/src/cli/get-data.h index 639e5887..e850645a 100644 --- a/src/cli/get-data.h +++ b/src/cli/get-data.h @@ -1,7 +1,6 @@ #pragma once #include -#include "../db-misc.h" G_BEGIN_DECLS diff --git a/src/cli/main.c b/src/cli/main.c index 719c8fe1..f060d66f 100644 --- a/src/cli/main.c +++ b/src/cli/main.c @@ -24,7 +24,7 @@ main (gint argc, { GOptionEntry entries[] = { -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK { "database", 'd', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "(optional) path to the database. Default value is taken from otpclient.cfg", NULL }, #endif { "show", 's', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Show a token for a given account.", NULL }, @@ -35,7 +35,7 @@ main (gint argc, { "list", 'l', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "List all accounts and issuers for a given database.", NULL }, { "export", 'e', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Export a database.", NULL }, { "type", 't', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "The export type for the database. Must be either one of: andotp_plain, andotp_encrypted, freeotpplus, aegis_plain, aegis_encrypted, twofas_plain, twofas_encrypted, authpro_plain, authpro_encrypted (to be used with --export, mandatory)", NULL }, -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK { "output-dir", 'o', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "The output directory (defaults to the user's home. To be used with --export, optional)", NULL }, #endif { "version", 'v', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Show the program version.", NULL }, @@ -161,7 +161,7 @@ parse_options (GApplicationCommandLine *cmdline, g_application_command_line_print (cmdline, "Please provide at least export type.\n"); return FALSE; } -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK g_variant_dict_lookup (options, "output-dir", "s", &cmdline_opts->export_dir); #endif } diff --git a/src/cli/main.h b/src/cli/main.h index 89321fd6..47d708e1 100644 --- a/src/cli/main.h +++ b/src/cli/main.h @@ -1,13 +1,13 @@ #pragma once #include -#include "../data.h" +#include "../gui/data.h" G_BEGIN_DECLS #define MAX_ABS_PATH_LEN 256 -typedef struct _cmdline_opts { +typedef struct cmdline_opts_t { gchar *database; gboolean show; gchar *account; diff --git a/src/common/aegis.c b/src/common/aegis.c index 363c0c49..84ce24e1 100644 --- a/src/common/aegis.c +++ b/src/common/aegis.c @@ -3,8 +3,8 @@ #include #include #include -#include "../imports.h" -#include "../gquarks.h" +#include "../gui/imports.h" +#include "../gui/gquarks.h" #include "common.h" diff --git a/src/common/andotp.c b/src/common/andotp.c index a827818b..2c2f4b55 100644 --- a/src/common/andotp.c +++ b/src/common/andotp.c @@ -4,9 +4,9 @@ #include #include #include -#include "../file-size.h" -#include "../imports.h" -#include "../gquarks.h" +#include "../gui/file-size.h" +#include "../gui/imports.h" +#include "../gui/gquarks.h" #include "common.h" // salt and iv are both 12 bytes diff --git a/src/common/authpro.c b/src/common/authpro.c index 14172ecc..e012e8ef 100644 --- a/src/common/authpro.c +++ b/src/common/authpro.c @@ -2,8 +2,8 @@ #include #include #include "common.h" -#include "../gquarks.h" -#include "../imports.h" +#include "../gui/gquarks.h" +#include "../gui/imports.h" static GSList *get_otps_from_encrypted_backup (const gchar *path, const gchar *password, diff --git a/src/common/common.c b/src/common/common.c index 61d948a3..5ffd5293 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -6,9 +6,9 @@ #include "gcrypt.h" #include "jansson.h" #include "common.h" -#include "../google-migration.pb-c.h" -#include "../file-size.h" -#include "../gquarks.h" +#include "../gui/google-migration.pb-c.h" +#include "../gui/file-size.h" +#include "../gui/gquarks.h" gint32 get_max_file_size_from_memlock (void) @@ -391,7 +391,7 @@ get_kf_ptr (void) GError *err = NULL; GKeyFile *kf = g_key_file_new (); gchar *cfg_file_path; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); diff --git a/src/common/exports.h b/src/common/exports.h index dca6beb6..6bf79dc7 100644 --- a/src/common/exports.h +++ b/src/common/exports.h @@ -1,6 +1,5 @@ #pragma once -#include #include G_BEGIN_DECLS diff --git a/src/common/freeotp.c b/src/common/freeotp.c index 2cc671ba..53e19d72 100644 --- a/src/common/freeotp.c +++ b/src/common/freeotp.c @@ -2,9 +2,9 @@ #include #include #include -#include "../file-size.h" -#include "../parse-uri.h" -#include "../gquarks.h" +#include "../gui/file-size.h" +#include "../gui/parse-uri.h" +#include "../gui/gquarks.h" GSList * diff --git a/src/common/twofas.c b/src/common/twofas.c index f65645d3..747d0c85 100644 --- a/src/common/twofas.c +++ b/src/common/twofas.c @@ -3,8 +3,8 @@ #include #include #include "common.h" -#include "../gquarks.h" -#include "../imports.h" +#include "../gui/gquarks.h" +#include "../gui/imports.h" #define TWOFAS_KDF_ITERS 10000 #define TWOFAS_SALT 256 diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt new file mode 100644 index 00000000..1dc3418b --- /dev/null +++ b/src/gui/CMakeLists.txt @@ -0,0 +1,17 @@ +file(GLOB GUI_HEADER_FILES + *.h + ../common/*.h +) + +file(GLOB GUI_SOURCE_FILES + *.c + ../common/*.c +) + +include_directories( + ${PNG_INCLUDE_DIRS} + ${ZBAR_INCLUDE_DIRS} + ${COMMON_INCDIRS} +) + +add_executable(${PROJECT_NAME} ${GUI_SOURCE_FILES} ${GUI_HEADER_FILES}) \ No newline at end of file diff --git a/src/about_diag_cb.c b/src/gui/about_diag_cb.c similarity index 100% rename from src/about_diag_cb.c rename to src/gui/about_diag_cb.c diff --git a/src/add-common.c b/src/gui/add-common.c similarity index 100% rename from src/add-common.c rename to src/gui/add-common.c diff --git a/src/add-common.h b/src/gui/add-common.h similarity index 100% rename from src/add-common.h rename to src/gui/add-common.h diff --git a/src/add-from-qr.c b/src/gui/add-from-qr.c similarity index 99% rename from src/add-from-qr.c rename to src/gui/add-from-qr.c index 867ddffe..485ccf15 100644 --- a/src/add-from-qr.c +++ b/src/gui/add-from-qr.c @@ -7,7 +7,7 @@ #include "message-dialogs.h" #include "add-common.h" #include "get-builder.h" -#include "common/common.h" +#include "../common/common.h" #include "gui-common.h" diff --git a/src/app.c b/src/gui/app.c similarity index 99% rename from src/app.c rename to src/gui/app.c index e304fa87..88e4cd47 100644 --- a/src/app.c +++ b/src/gui/app.c @@ -6,7 +6,7 @@ #include "otpclient.h" #include "gquarks.h" #include "imports.h" -#include "common/exports.h" +#include "../common/exports.h" #include "message-dialogs.h" #include "password-cb.h" #include "get-builder.h" @@ -14,7 +14,7 @@ #include "lock-app.h" #include "change-db-cb.h" #include "new-db-cb.h" -#include "common/common.h" +#include "../common/common.h" #include "secret-schema.h" #include "change-pwd-cb.h" #include "settings-cb.h" @@ -26,7 +26,7 @@ #include "dbinfo-cb.h" #include "change-file-cb.h" -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK static gchar *get_db_path (AppData *app_data); #endif @@ -131,7 +131,7 @@ activate (GtkApplication *app, return; } -#ifdef USE_FLATPAK_APP_FOLDER +#ifdef IS_FLATPAK app_data->db_data->db_path = g_build_filename (g_get_user_data_dir (), "otpclient-db.enc", NULL); // on the first run the cfg file is not created in the flatpak version because we use a non-changeable db path gchar *cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); @@ -371,7 +371,7 @@ migrate_secretservice_kf (AppData *app_data, g_key_file_set_boolean (kf, "config", "use_secret_service", app_data->use_secret_service); g_key_file_remove_key (kf, "config", "disable_secret_service", NULL); gchar *cfg_file_path; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); @@ -411,7 +411,7 @@ set_warn_data (gboolean show_warning) if (kf != NULL) { g_key_file_set_boolean (kf, "config", "show_memlock_warning", show_warning); gchar *cfg_file_path; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); @@ -499,7 +499,7 @@ create_main_window (gint width, } -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK static gchar * get_db_path (AppData *app_data) { @@ -715,7 +715,7 @@ store_data (const gchar *param1_name, GError *err = NULL; GKeyFile *kf = g_key_file_new (); gchar *cfg_file_path; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); diff --git a/src/change-db-cb.c b/src/gui/change-db-cb.c similarity index 100% rename from src/change-db-cb.c rename to src/gui/change-db-cb.c diff --git a/src/change-db-cb.h b/src/gui/change-db-cb.h similarity index 100% rename from src/change-db-cb.h rename to src/gui/change-db-cb.h diff --git a/src/change-file-cb.c b/src/gui/change-file-cb.c similarity index 100% rename from src/change-file-cb.c rename to src/gui/change-file-cb.c diff --git a/src/change-file-cb.h b/src/gui/change-file-cb.h similarity index 100% rename from src/change-file-cb.h rename to src/gui/change-file-cb.h diff --git a/src/change-pwd-cb.c b/src/gui/change-pwd-cb.c similarity index 98% rename from src/change-pwd-cb.c rename to src/gui/change-pwd-cb.c index a4d7ab98..9e57c9e0 100644 --- a/src/change-pwd-cb.c +++ b/src/gui/change-pwd-cb.c @@ -5,7 +5,7 @@ #include "message-dialogs.h" #include "db-misc.h" #include "password-cb.h" -#include "common/common.h" +#include "../common/common.h" #include "secret-schema.h" #include "otpclient.h" diff --git a/src/change-pwd-cb.h b/src/gui/change-pwd-cb.h similarity index 100% rename from src/change-pwd-cb.h rename to src/gui/change-pwd-cb.h diff --git a/src/data.h b/src/gui/data.h similarity index 100% rename from src/data.h rename to src/gui/data.h diff --git a/src/db-actions.c b/src/gui/db-actions.c similarity index 98% rename from src/db-actions.c rename to src/gui/db-actions.c index 01c70e76..0c0d87c1 100644 --- a/src/db-actions.c +++ b/src/gui/db-actions.c @@ -45,7 +45,7 @@ update_cfg_file (AppData *app_data) { GKeyFile *kf = g_key_file_new (); gchar *cfg_file_path; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); diff --git a/src/db-actions.h b/src/gui/db-actions.h similarity index 100% rename from src/db-actions.h rename to src/gui/db-actions.h diff --git a/src/db-misc.c b/src/gui/db-misc.c similarity index 99% rename from src/db-misc.c rename to src/gui/db-misc.c index c40bce19..bebadbc4 100644 --- a/src/db-misc.c +++ b/src/gui/db-misc.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,7 +6,7 @@ #include "otpclient.h" #include "file-size.h" #include "gquarks.h" -#include "common/common.h" +#include "../common/common.h" typedef struct header_data_t { guint8 iv[IV_SIZE]; @@ -107,13 +106,12 @@ update_and_reload_db (AppData *app_data, g_printerr ("%s\n", (*err)->message); return; } -#ifdef BUILD_GUI + if (regenerate_model) { update_model (app_data); g_slist_free_full (app_data->db_data->data_to_add, json_free); app_data->db_data->data_to_add = NULL; } -#endif } @@ -125,11 +123,10 @@ load_new_db (AppData *app_data, if (*err != NULL) { return; } -#ifdef BUILD_GUI + update_model (app_data); g_slist_free_full (app_data->db_data->data_to_add, json_free); app_data->db_data->data_to_add = NULL; -#endif } diff --git a/src/db-misc.h b/src/gui/db-misc.h similarity index 100% rename from src/db-misc.h rename to src/gui/db-misc.h diff --git a/src/dbinfo-cb.c b/src/gui/dbinfo-cb.c similarity index 97% rename from src/dbinfo-cb.c rename to src/gui/dbinfo-cb.c index 22c152e1..6adc42a9 100644 --- a/src/dbinfo-cb.c +++ b/src/gui/dbinfo-cb.c @@ -15,7 +15,7 @@ dbinfo_cb (GSimpleAction *simple __attribute__((unused)), gtk_entry_set_text (GTK_ENTRY(db_location_entry), app_data->db_data->db_path); gchar *cfg_file_path = NULL; -#ifdef USE_FLATPAK_APP_FOLDER +#ifdef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); diff --git a/src/dbinfo-cb.h b/src/gui/dbinfo-cb.h similarity index 100% rename from src/dbinfo-cb.h rename to src/gui/dbinfo-cb.h diff --git a/src/edit-row-cb.c b/src/gui/edit-row-cb.c similarity index 99% rename from src/edit-row-cb.c rename to src/gui/edit-row-cb.c index 8d7e3542..3d4fbe1f 100644 --- a/src/edit-row-cb.c +++ b/src/gui/edit-row-cb.c @@ -7,7 +7,7 @@ #include "message-dialogs.h" #include "gui-common.h" #include "gquarks.h" -#include "common/common.h" +#include "../common/common.h" typedef struct edit_data_t { GtkListStore *list_store; diff --git a/src/edit-row-cb.h b/src/gui/edit-row-cb.h similarity index 100% rename from src/edit-row-cb.h rename to src/gui/edit-row-cb.h diff --git a/src/exports.c b/src/gui/exports.c similarity index 99% rename from src/exports.c rename to src/gui/exports.c index 4fa68e55..e795be95 100644 --- a/src/exports.c +++ b/src/gui/exports.c @@ -3,7 +3,7 @@ #include #include "password-cb.h" #include "message-dialogs.h" -#include "common/exports.h" +#include "../common/exports.h" static void show_ret_msg_dialog (GtkWidget *mainwin, const gchar *fpath, @@ -19,7 +19,7 @@ export_data_cb (GSimpleAction *simple, AppData *app_data = (AppData *)user_data; const gchar *base_dir = NULL; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK base_dir = g_get_home_dir (); #else base_dir = g_get_user_data_dir (); diff --git a/src/file-size.c b/src/gui/file-size.c similarity index 100% rename from src/file-size.c rename to src/gui/file-size.c diff --git a/src/file-size.h b/src/gui/file-size.h similarity index 100% rename from src/file-size.h rename to src/gui/file-size.h diff --git a/src/get-builder.c b/src/gui/get-builder.c similarity index 93% rename from src/get-builder.c rename to src/gui/get-builder.c index b8f45955..d9541c75 100644 --- a/src/get-builder.c +++ b/src/gui/get-builder.c @@ -5,7 +5,7 @@ GtkBuilder * get_builder_from_partial_path (const gchar *partial_path) { const gchar *prefix; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK // cmake trims the last '/', so we have to manually add it later on prefix = INSTALL_PREFIX; #else diff --git a/src/get-builder.h b/src/gui/get-builder.h similarity index 100% rename from src/get-builder.h rename to src/gui/get-builder.h diff --git a/src/google-migration.pb-c.c b/src/gui/google-migration.pb-c.c similarity index 100% rename from src/google-migration.pb-c.c rename to src/gui/google-migration.pb-c.c diff --git a/src/google-migration.pb-c.h b/src/gui/google-migration.pb-c.h similarity index 100% rename from src/google-migration.pb-c.h rename to src/gui/google-migration.pb-c.h diff --git a/src/gquarks.c b/src/gui/gquarks.c similarity index 100% rename from src/gquarks.c rename to src/gui/gquarks.c diff --git a/src/gquarks.h b/src/gui/gquarks.h similarity index 100% rename from src/gquarks.h rename to src/gui/gquarks.h diff --git a/src/gui-common.c b/src/gui/gui-common.c similarity index 99% rename from src/gui-common.c rename to src/gui/gui-common.c index e4d36a57..3b8b8ac4 100644 --- a/src/gui-common.c +++ b/src/gui/gui-common.c @@ -2,7 +2,7 @@ #include #include "message-dialogs.h" #include "add-common.h" -#include "common/common.h" +#include "../common/common.h" void diff --git a/src/gui-common.h b/src/gui/gui-common.h similarity index 100% rename from src/gui-common.h rename to src/gui/gui-common.h diff --git a/src/imports.c b/src/gui/imports.c similarity index 98% rename from src/imports.c rename to src/gui/imports.c index 881be297..b0b27a00 100644 --- a/src/imports.c +++ b/src/gui/imports.c @@ -5,10 +5,10 @@ #include "password-cb.h" #include "message-dialogs.h" #include "gquarks.h" -#include "common/common.h" +#include "../common/common.h" #include "gui-common.h" #include "db-misc.h" -#include "common/get-providers-data.h" +#include "../common/get-providers-data.h" static gboolean parse_data_and_update_db (AppData *app_data, diff --git a/src/imports.h b/src/gui/imports.h similarity index 100% rename from src/imports.h rename to src/gui/imports.h diff --git a/src/liststore-misc.c b/src/gui/liststore-misc.c similarity index 99% rename from src/liststore-misc.c rename to src/gui/liststore-misc.c index a354e88e..f8d02cc0 100644 --- a/src/liststore-misc.c +++ b/src/gui/liststore-misc.c @@ -4,7 +4,7 @@ #include "treeview.h" #include "liststore-misc.h" #include "gquarks.h" -#include "common/common.h" +#include "../common/common.h" typedef struct otp_data_t { diff --git a/src/liststore-misc.h b/src/gui/liststore-misc.h similarity index 100% rename from src/liststore-misc.h rename to src/gui/liststore-misc.h diff --git a/src/lock-app.c b/src/gui/lock-app.c similarity index 100% rename from src/lock-app.c rename to src/gui/lock-app.c diff --git a/src/lock-app.h b/src/gui/lock-app.h similarity index 100% rename from src/lock-app.h rename to src/gui/lock-app.h diff --git a/src/main.c b/src/gui/main.c similarity index 100% rename from src/main.c rename to src/gui/main.c diff --git a/src/manual-add-cb.c b/src/gui/manual-add-cb.c similarity index 100% rename from src/manual-add-cb.c rename to src/gui/manual-add-cb.c diff --git a/src/manual-add-cb.h b/src/gui/manual-add-cb.h similarity index 100% rename from src/manual-add-cb.h rename to src/gui/manual-add-cb.h diff --git a/src/message-dialogs.c b/src/gui/message-dialogs.c similarity index 100% rename from src/message-dialogs.c rename to src/gui/message-dialogs.c diff --git a/src/message-dialogs.h b/src/gui/message-dialogs.h similarity index 100% rename from src/message-dialogs.h rename to src/gui/message-dialogs.h diff --git a/src/new-db-cb.c b/src/gui/new-db-cb.c similarity index 100% rename from src/new-db-cb.c rename to src/gui/new-db-cb.c diff --git a/src/new-db-cb.h b/src/gui/new-db-cb.h similarity index 100% rename from src/new-db-cb.h rename to src/gui/new-db-cb.h diff --git a/src/otpclient.h b/src/gui/otpclient.h similarity index 100% rename from src/otpclient.h rename to src/gui/otpclient.h diff --git a/src/parse-data.c b/src/gui/parse-data.c similarity index 99% rename from src/parse-data.c rename to src/gui/parse-data.c index a23decf1..c2a0aa0e 100644 --- a/src/parse-data.c +++ b/src/gui/parse-data.c @@ -8,7 +8,7 @@ #include "gquarks.h" #include "message-dialogs.h" #include "gui-common.h" -#include "common/common.h" +#include "../common/common.h" static gboolean is_input_valid (GtkWidget *dialog, diff --git a/src/parse-uri.c b/src/gui/parse-uri.c similarity index 99% rename from src/parse-uri.c rename to src/gui/parse-uri.c index 6ec597cf..cd7e3076 100644 --- a/src/parse-uri.c +++ b/src/gui/parse-uri.c @@ -1,6 +1,6 @@ #include #include "imports.h" -#include "common/common.h" +#include "../common/common.h" #include "gui-common.h" diff --git a/src/parse-uri.h b/src/gui/parse-uri.h similarity index 100% rename from src/parse-uri.h rename to src/gui/parse-uri.h diff --git a/src/password-cb.c b/src/gui/password-cb.c similarity index 99% rename from src/password-cb.c rename to src/gui/password-cb.c index 55d8235d..f492224a 100644 --- a/src/password-cb.c +++ b/src/gui/password-cb.c @@ -3,7 +3,7 @@ #include "gui-common.h" #include "message-dialogs.h" #include "get-builder.h" -#include "common/common.h" +#include "../common/common.h" typedef struct entrywidgets_t { GtkWidget *entry_old; diff --git a/src/password-cb.h b/src/gui/password-cb.h similarity index 100% rename from src/password-cb.h rename to src/gui/password-cb.h diff --git a/src/qrcode-parser.c b/src/gui/qrcode-parser.c similarity index 99% rename from src/qrcode-parser.c rename to src/gui/qrcode-parser.c index 4c4a987c..1906b21f 100644 --- a/src/qrcode-parser.c +++ b/src/gui/qrcode-parser.c @@ -3,7 +3,7 @@ #include #include #include -#include "common/common.h" +#include "../common/common.h" typedef struct image_data_t { gulong width; diff --git a/src/qrcode-parser.h b/src/gui/qrcode-parser.h similarity index 100% rename from src/qrcode-parser.h rename to src/gui/qrcode-parser.h diff --git a/src/secret-schema.c b/src/gui/secret-schema.c similarity index 100% rename from src/secret-schema.c rename to src/gui/secret-schema.c diff --git a/src/secret-schema.h b/src/gui/secret-schema.h similarity index 100% rename from src/secret-schema.h rename to src/gui/secret-schema.h diff --git a/src/settings-cb.c b/src/gui/settings-cb.c similarity index 99% rename from src/settings-cb.c rename to src/gui/settings-cb.c index 4762edec..c964acf2 100644 --- a/src/settings-cb.c +++ b/src/gui/settings-cb.c @@ -5,7 +5,7 @@ #include "message-dialogs.h" #include "get-builder.h" #include "secret-schema.h" -#include "common/common.h" +#include "../common/common.h" typedef struct settings_data_t { GtkWidget *dss_switch; @@ -41,7 +41,7 @@ settings_dialog_cb (GSimpleAction *simple __attribute__((unused)), settings_data->app_data = app_data; gchar *cfg_file_path; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); @@ -180,7 +180,7 @@ handle_al_ss (AppData *app_data, g_key_file_set_boolean (kf, "config", "use_secret_service", app_data->use_secret_service); g_key_file_set_integer (kf, "config", "inactivity_timeout", app_data->inactivity_timeout); gchar *cfg_file_path; -#ifndef USE_FLATPAK_APP_FOLDER +#ifndef IS_FLATPAK cfg_file_path = g_build_filename (g_get_user_config_dir (), "otpclient.cfg", NULL); #else cfg_file_path = g_build_filename (g_get_user_data_dir (), "otpclient.cfg", NULL); diff --git a/src/settings-cb.h b/src/gui/settings-cb.h similarity index 100% rename from src/settings-cb.h rename to src/gui/settings-cb.h diff --git a/src/setup-signals-shortcuts.c b/src/gui/setup-signals-shortcuts.c similarity index 100% rename from src/setup-signals-shortcuts.c rename to src/gui/setup-signals-shortcuts.c diff --git a/src/shortcuts-cb.c b/src/gui/shortcuts-cb.c similarity index 100% rename from src/shortcuts-cb.c rename to src/gui/shortcuts-cb.c diff --git a/src/shortcuts-cb.h b/src/gui/shortcuts-cb.h similarity index 100% rename from src/shortcuts-cb.h rename to src/gui/shortcuts-cb.h diff --git a/src/show-qr-cb.c b/src/gui/show-qr-cb.c similarity index 100% rename from src/show-qr-cb.c rename to src/gui/show-qr-cb.c diff --git a/src/show-qr-cb.h b/src/gui/show-qr-cb.h similarity index 100% rename from src/show-qr-cb.h rename to src/gui/show-qr-cb.h diff --git a/src/treeview.c b/src/gui/treeview.c similarity index 99% rename from src/treeview.c rename to src/gui/treeview.c index 967d8da4..340726f9 100644 --- a/src/treeview.c +++ b/src/gui/treeview.c @@ -3,7 +3,7 @@ #include "otpclient.h" #include "liststore-misc.h" #include "message-dialogs.h" -#include "common/common.h" +#include "../common/common.h" typedef struct parsed_json_data_t { diff --git a/src/treeview.h b/src/gui/treeview.h similarity index 100% rename from src/treeview.h rename to src/gui/treeview.h diff --git a/src/ui/add_popover.ui b/src/gui/ui/add_popover.ui similarity index 100% rename from src/ui/add_popover.ui rename to src/gui/ui/add_popover.ui diff --git a/src/ui/otpclient.ui b/src/gui/ui/otpclient.ui similarity index 100% rename from src/ui/otpclient.ui rename to src/gui/ui/otpclient.ui diff --git a/src/ui/settings_popover.ui b/src/gui/ui/settings_popover.ui similarity index 100% rename from src/ui/settings_popover.ui rename to src/gui/ui/settings_popover.ui diff --git a/src/ui/shortcuts.ui b/src/gui/ui/shortcuts.ui similarity index 100% rename from src/ui/shortcuts.ui rename to src/gui/ui/shortcuts.ui diff --git a/src/webcam-add-cb.c b/src/gui/webcam-add-cb.c similarity index 99% rename from src/webcam-add-cb.c rename to src/gui/webcam-add-cb.c index 9e099b33..5d9c964a 100644 --- a/src/webcam-add-cb.c +++ b/src/gui/webcam-add-cb.c @@ -4,7 +4,7 @@ #include "imports.h" #include "message-dialogs.h" #include "get-builder.h" -#include "common/common.h" +#include "../common/common.h" #include "gui-common.h" diff --git a/src/webcam-add-cb.h b/src/gui/webcam-add-cb.h similarity index 100% rename from src/webcam-add-cb.h rename to src/gui/webcam-add-cb.h