Verified Commit fe62e239 authored by Phobos D'thorga's avatar Phobos D'thorga 🐲
Browse files

* Added functionality for flashing the taskbar upon suitable notification....

* Added functionality for flashing the taskbar upon suitable notification. This will be configurable by the end-user in the future.
* Changed the directory where the settings are saved by Small World Deluxe, so that they reside under the folder, "GekkoFyre Networks", from now on. For Microsoft Windows, this is in the end-user's AppData directory, while in Linux, it can be variable and dependent upon distro used.
parent 86f90539
Pipeline #988 passed with stages
in 32 minutes and 47 seconds
......@@ -256,6 +256,9 @@ namespace GekkoFyre {
#define GK_EVENTLOG_SEVERITY_ERROR_IDX (5)
#define GK_EVENTLOG_SEVERITY_FATAL_IDX (6)
#define GK_EVENTLOG_TASKBAR_FLASHER_PERIOD_COUNT (15) // Total amount of periods to flash for!
#define GK_EVENTLOG_TASKBAR_FLASHER_DURAT_COUNT (750) // Duration, in milliseconds, between each flashing period.
#define GK_ACTIVE_MSGS_TABLEVIEW_MODEL_OFFSET_IDX (0)
#define GK_ACTIVE_MSGS_TABLEVIEW_MODEL_DATETIME_IDX (1)
#define GK_ACTIVE_MSGS_TABLEVIEW_MODEL_AGE_IDX (2)
......
......@@ -198,7 +198,8 @@ QString FileIo::read_initial_settings(const Database::Settings::init_cfg &key)
switch (key) {
case DbName:
value = QString::fromStdString(fs::path(Filesystem::defaultDirAppend + native_slash.string() + Filesystem::fileName).string());
value = QString::fromStdString(fs::path(General::companyName + native_slash.string() + Filesystem::defaultDirAppend +
native_slash.string() + Filesystem::fileName).string());
break;
case DbExt:
value = "";
......
......@@ -79,7 +79,7 @@ public:
std::string get_file_contents(const boost::filesystem::path &filePath);
QString defaultDirectory(const QString &base_path, const bool &use_native_slashes = false,
const QString &append_dir = Filesystem::defaultDirAppend);
const QString &append_dir = QString(General::companyName + QString("/") + Filesystem::defaultDirAppend));
protected:
static std::vector<boost::filesystem::path> analyze_dir(const boost::filesystem::path &dirPath, const std::vector<std::string> &dirsToSkip = { });
......
......@@ -49,6 +49,10 @@
#include <QDateTime>
#include <QStandardPaths>
#if defined(_WIN32) || defined(__MINGW64__) || defined(__CYGWIN__)
#include <windows.h>
#endif
using namespace GekkoFyre;
using namespace GkAudioFramework;
using namespace Database;
......@@ -82,12 +86,13 @@ namespace sys = boost::system;
* @param parent
*/
GkEventLogger::GkEventLogger(const QPointer<QSystemTrayIcon> &sysTrayIcon, const QPointer<GekkoFyre::StringFuncs> &stringFuncs,
QPointer<GekkoFyre::FileIo> fileIo, QObject *parent)
QPointer<GekkoFyre::FileIo> fileIo, const quintptr &win_id, QObject *parent)
{
try {
setParent(parent);
m_trayIcon = std::move(sysTrayIcon);
gkStringFuncs = std::move(stringFuncs);
m_windowId = win_id;
//
// File I/O
......@@ -96,7 +101,8 @@ GkEventLogger::GkEventLogger(const QPointer<QSystemTrayIcon> &sysTrayIcon, const
fs::path slash = "/";
fs::path native_slash = slash.make_preferred().native();
const fs::path dir_to_append = fs::path(Filesystem::defaultDirAppend + native_slash.string() + Filesystem::fileLogData);
const fs::path dir_to_append = fs::path(General::companyName + native_slash.string() + Filesystem::defaultDirAppend +
native_slash.string() + Filesystem::fileLogData);
const fs::path log_data_loc = gkFileIo->defaultDirectory(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation),
true, QString::fromStdString(dir_to_append.string())).toStdString();
if (fs::exists(log_data_loc)) { // Entity already exists!
......@@ -146,9 +152,16 @@ GkEventLogger::~GkEventLogger()
* @param event The event message itself.
* @param severity The severity of the issue, where it's just a warning all the way to a fatal error.
* @param arguments Any arguments that are associated with the event message. This tends to be left blank.
* @param sys_notification
* @param publishToConsole
* @param publishToStatusBar
* @param displayMsgBox
* @param flashTaskbar Whether to flash the taskbar and/or active window. This is dependent upon host operating system
* functionality, of course!
*/
void GkEventLogger::publishEvent(const QString &event, const GkSeverity &severity, const QVariant &arguments, const bool &sys_notification,
const bool &publishToConsole, const bool &publishToStatusBar, const bool &displayMsgBox)
const bool &publishToConsole, const bool &publishToStatusBar, const bool &displayMsgBox,
const bool &flashTaskbar)
{
//
// TODO: Introduce proper mutex'ing for multithreading!
......@@ -196,8 +209,24 @@ void GkEventLogger::publishEvent(const QString &event, const GkSeverity &severit
}
}
// TODO: Write out in a neater format! Such as XML, CSV, etc.
if (flashTaskbar) {
#if defined(_WIN32) || defined(__MINGW64__) || defined(__CYGWIN__)
FLASHWINFO flash_info;
flash_info.cbSize = sizeof(FLASHWINFO);
flash_info.hwnd = (HWND)m_windowId;
flash_info.uCount = GK_EVENTLOG_TASKBAR_FLASHER_PERIOD_COUNT; // Flash for only 20-periods
flash_info.dwTimeout = GK_EVENTLOG_TASKBAR_FLASHER_DURAT_COUNT; // Duration in milliseconds between flashes
flash_info.dwFlags = FLASHW_TRAY; // Flash only taskbar button
FlashWindowEx(&flash_info);
#elif __linux__
// TODO: Implement functionality for Linux operating systems!
#endif
}
gkWriteCsvIo.write(event_log.mesg.message.toStdString().c_str(), event_log.mesg.message.length());
const QString tmp_event_out = QString("%1\n\n").arg(event_log.mesg.message);
gkWriteCsvIo.write(tmp_event_out.toStdString().c_str(), tmp_event_out.length());
return;
}
......
......@@ -66,13 +66,13 @@ class GkEventLogger : public QObject {
public:
explicit GkEventLogger(const QPointer<QSystemTrayIcon> &sysTrayIcon, const QPointer<GekkoFyre::StringFuncs> &stringFuncs,
QPointer<GekkoFyre::FileIo> fileIo, QObject *parent = nullptr);
QPointer<GekkoFyre::FileIo> fileIo, const quintptr &win_id, QObject *parent = nullptr);
~GkEventLogger() override;
public slots:
void publishEvent(const QString &event, const GekkoFyre::System::Events::Logging::GkSeverity &severity = GekkoFyre::System::Events::Logging::GkSeverity::Warning,
const QVariant &arguments = "", const bool &sys_notification = false, const bool &publishToConsole = true,
const bool &publishToStatusBar = false, const bool &displayMsgBox = false);
const bool &publishToStatusBar = false, const bool &displayMsgBox = false, const bool &flashTaskbar = false);
void recvXmppLog(QXmppLogger::MessageType msg_type, QString msg);
signals:
......@@ -90,6 +90,10 @@ private:
QPointer<GekkoFyre::FileIo> gkFileIo;
QFile gkWriteCsvIo;
//
// Microsoft Windows
quintptr m_windowId;
#if defined(GFYRE_ENBL_MSVC_WINTOAST)
std::unique_ptr<WinToastLib::WinToastTemplate> toastTempl;
#endif
......
......@@ -145,7 +145,8 @@ GkXmppClient::GkXmppClient(const GkUserConn &connection_details, QPointer<GekkoF
fs::path slash = "/";
native_slash = slash.make_preferred().native();
const fs::path dir_to_append = fs::path(Filesystem::defaultDirAppend + native_slash.string() + Filesystem::xmppVCardDir);
const fs::path dir_to_append = fs::path(General::companyName + native_slash.string() + Filesystem::defaultDirAppend +
native_slash.string() + Filesystem::xmppVCardDir);
vcard_save_path = gkFileIo->defaultDirectory(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation),
true, QString::fromStdString(dir_to_append.string())).toStdString(); // Path to save final database towards
if (!fs::exists(vcard_save_path)) {
......@@ -1433,20 +1434,6 @@ void GkXmppClient::sendXmppMsg(const QString &bareJid, const QXmppMessage &msg,
sendPacket(msg);
}
if (!m_rosterList.isEmpty()) {
for (const auto &roster: m_rosterList) {
if (!roster.bareJid.isEmpty()) {
if (roster.bareJid == bareJid) {
if (beginTimestamp.isValid() && endTimestamp.isValid()) {
getArchivedMessages(m_connDetails.jid, QString(), roster.bareJid, beginTimestamp, endTimestamp, QXmppResultSetQuery());
} else {
getArchivedMessages(m_connDetails.jid, QString(), roster.bareJid, QDateTime::currentDateTimeUtc(), QDateTime::currentDateTimeUtc(), QXmppResultSetQuery());
}
}
}
}
}
return;
}
......
......@@ -144,7 +144,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
fs::path slash = "/";
native_slash = slash.make_preferred().native();
const fs::path dir_to_append = fs::path(Filesystem::defaultDirAppend + native_slash.string() + Filesystem::fileName);
const fs::path dir_to_append = fs::path(General::companyName + native_slash.string() + Filesystem::defaultDirAppend +
native_slash.string() + Filesystem::fileName);
const fs::path swrld_save_path = gkFileIo->defaultDirectory(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation),
true, QString::fromStdString(dir_to_append.string())).toStdString(); // Path to save final database towards
......@@ -332,7 +333,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// The handler is a Crashpad-specific background process
sentry_options_set_handler_path(sen_opt, handler_to_use.string().c_str());
const fs::path sentry_crash_dir = fs::path(Filesystem::defaultDirAppend + native_slash.string() + Filesystem::gk_sentry_dump_dir);
const fs::path sentry_crash_dir = fs::path(General::companyName + native_slash.string() + Filesystem::defaultDirAppend +
native_slash.string() + Filesystem::gk_sentry_dump_dir);
const fs::path gk_minidump = gkFileIo->defaultDirectory(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation),
true, QString::fromStdString(sentry_crash_dir.string())).toStdString();
......@@ -398,7 +400,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->tableView_maingui_logs->horizontalHeader()->setSectionResizeMode(GK_EVENTLOG_TABLEVIEW_MODEL_MESSAGE_IDX, QHeaderView::Stretch);
ui->tableView_maingui_logs->show();
gkEventLogger = new GkEventLogger(m_trayIcon, gkStringFuncs, gkFileIo, this);
gkEventLogger = new GkEventLogger(m_trayIcon, gkStringFuncs, gkFileIo, this->winId(), this);
QObject::connect(gkEventLogger, SIGNAL(sendEvent(const GekkoFyre::System::Events::Logging::GkEventLogging &)),
gkEventLoggerModel, SLOT(insertData(const GekkoFyre::System::Events::Logging::GkEventLogging &)));
QObject::connect(gkEventLogger, SIGNAL(removeEvent(const GekkoFyre::System::Events::Logging::GkEventLogging &)),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment