aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/GpgFrontend.h.in15
-rw-r--r--src/GpgFrontendBuildInstallInfo.h.in5
-rw-r--r--src/before_exit.cpp2
-rw-r--r--src/init.cpp28
-rw-r--r--src/main.cpp33
-rw-r--r--src/signal.cpp4
6 files changed, 55 insertions, 32 deletions
diff --git a/src/GpgFrontend.h.in b/src/GpgFrontend.h.in
index 9275421e..a1f0930f 100644
--- a/src/GpgFrontend.h.in
+++ b/src/GpgFrontend.h.in
@@ -29,17 +29,20 @@
#ifndef GPGFRONTEND_H_IN
#define GPGFRONTEND_H_IN
-// i18n
#ifdef WINDOWS
#include <winsock2.h>
#include <windows.h>
#endif
+
+// i18n support
#include <libintl.h>
#define _(String) gettext (String)
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)
+
+// fix macro bugs in mingw
#ifdef WINDOWS
#include <clocale>
#undef vsnprintf
@@ -47,17 +50,19 @@
#undef snprintf
#endif
-// logging
+
+// logging system
#define ELPP_DEFAULT_LOGGING_FLAGS 8192
#include <easylogging++.h>
+
+// build info
#define PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#define OS_PLATFORM @OS_PLATFORM@
#define LOCALE_DIR "@LOCALE_DIR@"
-/**
- * Resources File(s) Path Vars
- */
+
+// macros to find resource files
#if defined(MACOS) && defined(RELEASE)
#define RESOURCE_DIR(appDir) (appDir + "/../Resources/")
#elif defined(LINUX) && defined(RELEASE)
diff --git a/src/GpgFrontendBuildInstallInfo.h.in b/src/GpgFrontendBuildInstallInfo.h.in
index 072356fb..abc1af0f 100644
--- a/src/GpgFrontendBuildInstallInfo.h.in
+++ b/src/GpgFrontendBuildInstallInfo.h.in
@@ -1,6 +1,7 @@
/**
- * Copyright (C) 2021 Saturneric
- * This file is part of GpgFrontend.
+ * Copyright (C) 2021 Saturneric
+ *
+ * This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/before_exit.cpp b/src/before_exit.cpp
index d8ab8f00..abdf7d62 100644
--- a/src/before_exit.cpp
+++ b/src/before_exit.cpp
@@ -29,7 +29,7 @@
#include "ui/settings/GlobalSettingStation.h"
/**
- * @brief
+ * @brief Actions performed before exiting the application
*
*/
void before_exit() {
diff --git a/src/init.cpp b/src/init.cpp
index 43477c53..d95a3351 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -31,9 +31,9 @@
#include "ui/settings/GlobalSettingStation.h"
/**
- * @brief Get the files of directory object
+ * @brief Get the files of a given directory
*
- * @param _path
+ * @param _path target directory
* @return std::vector<boost::filesystem::path>
*/
std::vector<boost::filesystem::path> get_files_of_directory(
@@ -52,7 +52,7 @@ std::vector<boost::filesystem::path> get_files_of_directory(
}
/**
- * @brief
+ * @brief setup logging system and do proper initialization
*
*/
void init_logging() {
@@ -66,9 +66,11 @@ void init_logging() {
defaultConf.setToDefault();
el::Loggers::reconfigureLogger("default", defaultConf);
+ // apply settings
defaultConf.setGlobally(el::ConfigurationType::Format,
"%datetime %level %func %msg");
+ // get the log directory
auto logfile_path =
(GpgFrontend::UI::GlobalSettingStation::GetInstance().GetLogDir() /
to_iso_string(now));
@@ -78,34 +80,39 @@ void init_logging() {
el::Loggers::reconfigureLogger("default", defaultConf);
- LOG(INFO) << _("logfile Path") << logfile_path;
+ LOG(INFO) << _("log file path") << logfile_path;
}
/**
- * @brief
- *
+ * @brief load all certificates from the given path
+ * and add them to the given certificate store in GlobalSettingStation
*/
void init_certs() {
- std::vector<vmime::shared_ptr<vmime::security::cert::X509Certificate>>
- root_certs;
+ // get the certificate directory
auto cert_file_paths = get_files_of_directory(
GpgFrontend::UI::GlobalSettingStation::GetInstance().GetCertsDir());
+ // get the instance of the GlobalSettingStation
auto& _instance = GpgFrontend::UI::GlobalSettingStation::GetInstance();
for (const auto& cert_file_path : cert_file_paths) {
+ // add the certificate to the store
_instance.AddRootCert(cert_file_path);
}
+
+ // show the number of loaded certificates
LOG(INFO) << _("root certs loaded") << _instance.GetRootCerts().size();
}
/**
- * @brief
+ * @brief setup the locale and load the translations
*
*/
void init_locale() {
+ // get the instance of the GlobalSettingStation
auto& settings =
GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
+ // create general settings if not exist
if (!settings.exists("general") ||
settings.lookup("general").getType() != libconfig::Setting::TypeGroup)
settings.add("general", libconfig::Setting::TypeGroup);
@@ -115,6 +122,7 @@ void init_locale() {
if (!general.exists("lang"))
general.add("lang", libconfig::Setting::TypeString) = "";
+ // sync the settings to the file
GpgFrontend::UI::GlobalSettingStation::GetInstance().SyncSettings();
LOG(INFO) << "current system locale" << setlocale(LC_ALL, nullptr);
@@ -126,7 +134,7 @@ void init_locale() {
};
LOG(INFO) << "lang from settings" << lang;
- LOG(INFO) << "PROJECT_NAME" << PROJECT_NAME;
+ LOG(INFO) << "project name" << PROJECT_NAME;
LOG(INFO) << "locales path"
<< GpgFrontend::UI::GlobalSettingStation::GetInstance()
.GetLocaleDir()
diff --git a/src/main.cpp b/src/main.cpp
index 668fffd3..9a979364 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -43,10 +43,14 @@
#include "ui/settings/GlobalSettingStation.h"
#endif
-// Easy Logging Cpp
+/**
+ * \brief initialize the easylogging++ library.
+ */
INITIALIZE_EASYLOGGINGPP
-// Recover buff
+/**
+ * \brief Store the jump buff and make it possible to recover from a crash.
+ */
jmp_buf recover_env;
/**
@@ -87,7 +91,7 @@ extern void before_exit();
* @return
*/
int main(int argc, char* argv[]) {
- // Register Signals
+ // re
signal(SIGSEGV, handle_signal);
signal(SIGFPE, handle_signal);
signal(SIGILL, handle_signal);
@@ -95,10 +99,10 @@ int main(int argc, char* argv[]) {
// clean something before exit
atexit(before_exit);
- // Qt
+ // initialize qt resources
Q_INIT_RESOURCE(gpgfrontend);
- // Qt App
+ // create qt application
QApplication app(argc, argv);
#ifndef MACOS
@@ -110,13 +114,13 @@ int main(int argc, char* argv[]) {
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
- // config logging system
+ // initialize logging system
init_logging();
- // root certs for tls connection
+ // init certs for tls connection
init_certs();
- // App config
+ // set the extra information of the build
QApplication::setApplicationVersion(BUILD_VERSION);
QApplication::setApplicationName(PROJECT_NAME);
@@ -151,12 +155,12 @@ int main(int argc, char* argv[]) {
gpg_path.string()));
#endif
+ // create the thread to load the gpg context
auto* init_ctx_thread = new GpgFrontend::UI::CtxCheckThread();
-
QApplication::connect(init_ctx_thread, &QThread::finished, init_ctx_thread,
&QThread::deleteLater);
- // Waiting Dialog
+ // create and show loading window before starting the main window
auto* waiting_dialog = new QProgressDialog();
waiting_dialog->setMaximum(0);
waiting_dialog->setMinimum(0);
@@ -180,10 +184,11 @@ int main(int argc, char* argv[]) {
exit(0);
});
- // Show Waiting Dialog
+ // show the loading window
waiting_dialog->show();
waiting_dialog->setFocus();
+ // start the thread to load the gpg context
init_ctx_thread->start();
QEventLoop loop;
QApplication::connect(init_ctx_thread, &QThread::finished, &loop,
@@ -204,17 +209,19 @@ int main(int argc, char* argv[]) {
#endif
if (!r) {
try {
- // i18n
+ // init the i18n support
init_locale();
QApplication::setQuitOnLastWindowClosed(true);
+ // create main window and show it
auto main_window = std::make_unique<GpgFrontend::UI::MainWindow>();
main_window->init();
main_window->show();
return_from_event_loop_code = QApplication::exec();
} catch (...) {
+ // catch all unhandled exceptions and notify the user
QMessageBox::information(
nullptr, _("Unhandled Exception Thrown"),
_("Oops, an unhandled exception was thrown "
@@ -227,6 +234,7 @@ int main(int argc, char* argv[]) {
}
} else {
+ // when signal is caught, restart the main window
QMessageBox::information(
nullptr, _("A serious error has occurred"),
_("Oh no! GpgFrontend caught a serious error in the software, so it "
@@ -240,5 +248,6 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "loop refresh";
} while (return_from_event_loop_code == RESTART_CODE);
+ // exit the program
return return_from_event_loop_code;
}
diff --git a/src/signal.cpp b/src/signal.cpp
index 5df80d51..135bdead 100644
--- a/src/signal.cpp
+++ b/src/signal.cpp
@@ -33,9 +33,9 @@
extern jmp_buf recover_env;
/**
- * @brief
+ * @brief handle the signal caught.
*
- * @param sig
+ * @param sig signal number
*/
void handle_signal(int sig) {
static int _repeat_handle_num = 1, last_sig = sig;