summaryrefslogtreecommitdiff
path: root/plugins/Db_autobackups/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-03-09 16:01:24 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-03-09 16:01:32 +0300
commitd387ed11456e40f36f359cb3aa9f74a54b8f369b (patch)
tree58b3c950a6f00ee6664e794ec4a385cc3b10cb34 /plugins/Db_autobackups/src
parentb5c43418ddb50192686929bac0a6b3190aa6b600 (diff)
popup control moved from main menu to Options - Popups - Enabled items
Diffstat (limited to 'plugins/Db_autobackups/src')
-rw-r--r--plugins/Db_autobackups/src/backup.cpp4
-rw-r--r--plugins/Db_autobackups/src/main.cpp39
-rw-r--r--plugins/Db_autobackups/src/stdafx.h12
3 files changed, 18 insertions, 37 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp
index 21d3f0d826..0dab268428 100644
--- a/plugins/Db_autobackups/src/backup.cpp
+++ b/plugins/Db_autobackups/src/backup.cpp
@@ -232,7 +232,7 @@ static int Backup(wchar_t *backup_filename)
bZip = true;
}
- if (!g_plugin.disable_popups)
+ if (g_plugin.bPopups)
ShowPopup(dbname, TranslateT("Backup in progress"), nullptr);
HWND progress_dialog = nullptr;
@@ -276,7 +276,7 @@ static int Backup(wchar_t *backup_filename)
wchar_t *pd = wcsrchr(dest_file, '\\');
- if (!g_plugin.disable_popups) {
+ if (g_plugin.bPopups) {
CMStringW puText;
if (pd && mir_wstrlen(dest_file) > 50) {
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp
index 1b898f31c2..b629e5c657 100644
--- a/plugins/Db_autobackups/src/main.cpp
+++ b/plugins/Db_autobackups/src/main.cpp
@@ -2,7 +2,6 @@
CMPlugin g_plugin;
-HGENMENU g_hPopupMenu;
HANDLE hFolder;
char g_szMirVer[100];
@@ -35,22 +34,13 @@ CMPlugin::CMPlugin() :
num_backups(MODULENAME, "NumBackups", 3),
file_mask(MODULENAME, "FileMask", L"%miranda_profilename%_%currtime%_%compname%"),
disable_progress(MODULENAME, "NoProgress", 0),
- disable_popups(MODULENAME, "NoPopups", 0),
+ bPopups(MODULENAME, "Popups", 1),
use_zip(MODULENAME, "UseZip", 0),
backup_profile(MODULENAME, "BackupProfile", 0),
use_cloudfile(MODULENAME, "UseCloudFile", 0),
cloudfile_service(MODULENAME, "CloudFileService", nullptr)
{
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static void UpdateMenuIcons()
-{
- if (g_plugin.disable_popups)
- Menu_ModifyItem(g_hPopupMenu, LPGENW("Enable &AutoBackups notification"), Skin_GetIconHandle(SKINICON_OTHER_NOPOPUP));
- else
- Menu_ModifyItem(g_hPopupMenu, LPGENW("Disable &AutoBackups notification"), Skin_GetIconHandle(SKINICON_OTHER_POPUP));
+ folder[0] = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -91,13 +81,6 @@ static int FoldersGetBackupPath(WPARAM, LPARAM)
return 0;
}
-static INT_PTR OnTogglePopups(WPARAM, LPARAM)
-{
- g_plugin.disable_popups = !g_plugin.disable_popups;
- UpdateMenuIcons();
- return 0;
-}
-
static int PluginLoaded(WPARAM, LPARAM)
{
g_plugin.bCloudFilePresent = ServiceExists(MS_CLOUDFILE_UPLOAD);
@@ -126,15 +109,6 @@ static int ModulesLoad(WPARAM, LPARAM)
mi.position = 500100001;
Menu_AddMainMenuItem(&mi);
- // Popup menu item
- SET_UID(mi, 0xe9250a75, 0x30da, 0x42f2, 0x85, 0x27, 0x54, 0x24, 0x62, 0x59, 0x9e, 0xae);
- mi.position = 0;
- mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0);
- mi.pszService = "DbAutoBackup/EnableDisableMenuCommand";
- g_hPopupMenu = Menu_AddMainMenuItem(&mi);
- UpdateMenuIcons();
- CreateServiceFunction(mi.pszService, &OnTogglePopups);
-
if (hFolder = FoldersRegisterCustomPathW(LPGEN("Database backups"), LPGEN("Backup folder"), DIR SUB_DIR)) {
HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersGetBackupPath);
FoldersGetBackupPath(0, 0);
@@ -171,6 +145,11 @@ static int OkToExit(WPARAM, LPARAM)
int CMPlugin::Load()
{
+ if (getBool("NoPopups")) {
+ bPopups = false;
+ delSetting("NoPopups");
+ }
+
Miranda_GetVersionText(g_szMirVer, sizeof(g_szMirVer));
HookEvent(ME_SYSTEM_OKTOEXIT, OkToExit);
@@ -178,7 +157,9 @@ int CMPlugin::Load()
HookEvent(ME_SYSTEM_MODULELOAD, PluginLoaded);
HookEvent(ME_SYSTEM_MODULEUNLOAD, PluginLoaded);
- g_plugin.registerIcon(LPGEN("Database") "/" LPGEN("Database backups"), iconList);
+ addPopupOption(LPGEN("AutoBackups notifications"), bPopups);
+
+ registerIcon(LPGEN("Database") "/" LPGEN("Database backups"), iconList);
CreateServiceFunction(MS_AB_BACKUP, ABService);
CreateServiceFunction(MS_AB_SAVEAS, DBSaveAs);
diff --git a/plugins/Db_autobackups/src/stdafx.h b/plugins/Db_autobackups/src/stdafx.h
index 9c84fc678c..f569f099bd 100644
--- a/plugins/Db_autobackups/src/stdafx.h
+++ b/plugins/Db_autobackups/src/stdafx.h
@@ -38,20 +38,20 @@ struct CMPlugin : public PLUGIN<CMPlugin>
CMPlugin();
bool bCloudFilePresent = false;
- HANDLE hevBackup;
+ HANDLE hevBackup = nullptr;
wchar_t folder[MAX_PATH];
CMOption<uint8_t> backup_types;
- CMOption<uint16_t> period;
+ CMOption<uint16_t> period;
CMOption<uint8_t> period_type;
- CMOption<wchar_t*> file_mask;
- CMOption<uint16_t> num_backups;
+ CMOption<wchar_t*> file_mask;
+ CMOption<uint16_t> num_backups;
CMOption<uint8_t> disable_progress;
- CMOption<uint8_t> disable_popups;
+ CMOption<bool> bPopups;
CMOption<uint8_t> use_zip;
CMOption<uint8_t> backup_profile;
CMOption<uint8_t> use_cloudfile;
- CMOption<char*> cloudfile_service;
+ CMOption<char*> cloudfile_service;
int Load() override;
};