summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-03-31 15:42:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-03-31 15:42:14 +0300
commit5f7acbc21e1809e8f6afb3c98302a474a530113e (patch)
tree8c9477f2bb3f186805c34b04ef0821979378baff
parenta5c2c9d611260f72501304911862f4fda6b95421 (diff)
db_autobackups:
- fixes #2811 (Db_autobackups: выводить подсказку о том, когда случится следующий бэкап); - code cleaning; - version bump
-rw-r--r--plugins/Db_autobackups/res/db_autobackups.rc52
-rw-r--r--plugins/Db_autobackups/src/backup.cpp2
-rw-r--r--plugins/Db_autobackups/src/main.cpp6
-rw-r--r--plugins/Db_autobackups/src/options.cpp72
-rw-r--r--plugins/Db_autobackups/src/resource.h3
-rw-r--r--plugins/Db_autobackups/src/stdafx.h6
-rw-r--r--plugins/Db_autobackups/src/version.h2
7 files changed, 76 insertions, 67 deletions
diff --git a/plugins/Db_autobackups/res/db_autobackups.rc b/plugins/Db_autobackups/res/db_autobackups.rc
index a4f2ca9d8a..695d07024a 100644
--- a/plugins/Db_autobackups/res/db_autobackups.rc
+++ b/plugins/Db_autobackups/res/db_autobackups.rc
@@ -23,35 +23,36 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
// Dialog
//
-IDD_OPTIONS DIALOGEX 0, 0, 271, 229
+IDD_OPTIONS DIALOGEX 0, 0, 271, 226
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Automatic backups",IDC_STATIC,6,4,258,215,WS_GROUP
- CONTROL "Disabled",IDC_RAD_DISABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,19,128,10
- CONTROL "When Miranda starts",IDC_RAD_START,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,32,153,10
- CONTROL "When Miranda exits",IDC_RAD_EXIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,45,156,10
- CONTROL "Every:",IDC_RAD_PERIODIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,58,43,10
- EDITTEXT IDC_ED_PERIOD,116,57,30,12,ES_NUMBER,WS_EX_RIGHT
- CONTROL "",SPIN_PERIOD,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,136,58,10,12
- COMBOBOX IDC_PT,148,57,46,30,CBS_DROPDOWNLIST | WS_TABSTOP
- LTEXT "Number of backups to keep:",IDC_STATIC,17,79,147,8
- EDITTEXT IDC_ED_NUMBACKUPS,171,77,36,12,ES_NUMBER,WS_EX_RIGHT
- CONTROL "",SPIN_NUMBACKUPS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,205,77,12,12
- LTEXT "Backup to folder:",IDC_STATIC,18,102,124,11
- EDITTEXT IDC_ED_FOLDER,17,115,177,13,ES_AUTOHSCROLL
- PUSHBUTTON "Browse...",IDC_BUT_BROWSE,199,114,49,14
+ CONTROL "Disabled",IDC_RAD_DISABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,19,128,10
+ CONTROL "When Miranda starts",IDC_RAD_START,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,31,153,10
+ CONTROL "When Miranda exits",IDC_RAD_EXIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,43,156,10
+ CONTROL "Every:",IDC_RAD_PERIODIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,56,43,10
+ EDITTEXT IDC_ED_PERIOD,177,55,30,13,ES_NUMBER,WS_EX_RIGHT
+ CONTROL "",SPIN_PERIOD,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,201,56,10,12
+ COMBOBOX IDC_PT,209,55,46,30,CBS_DROPDOWNLIST | WS_TABSTOP
+ LTEXT "",IDC_NEXTTIME,29,71,225,11,0,WS_EX_STATICEDGE
+ LTEXT "Number of backups to keep:",IDC_STATIC,13,89,180,8
+ EDITTEXT IDC_ED_NUMBACKUPS,211,87,36,12,ES_NUMBER,WS_EX_RIGHT
+ CONTROL "",SPIN_NUMBACKUPS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,245,87,12,12
+ LTEXT "Backup to folder:",IDC_STATIC,13,102,124,11
+ EDITTEXT IDC_ED_FOLDER,13,115,177,13,ES_AUTOHSCROLL
+ PUSHBUTTON "Browse...",IDC_BUT_BROWSE,207,114,49,14
CONTROL "Go to the ""Options -> Customize -> Folders"" to change settings",IDC_LNK_FOLDERS,
- "Hyperlink",NOT WS_VISIBLE | WS_TABSTOP,17,111,231,17
- LTEXT "Backup file mask:",IDC_STATIC,17,135,231,8
- EDITTEXT IDC_FILEMASK,17,145,231,14,ES_AUTOHSCROLL
- CONTROL "Compress backup to zip-archive",IDC_CHK_USEZIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,165,231,10
- CONTROL "Backup profile folder",IDC_BACKUPPROFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,177,176,10
- CONTROL "Disable progress bar",IDC_CHK_NOPROG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,191,231,10
- CONTROL "Use CloudFile",IDC_CLOUDFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,203,105,10
- COMBOBOX IDC_CLOUDFILESEVICE,131,201,117,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "Backup NOW",IDC_BUT_NOW,173,19,75,14
+ "Hyperlink",NOT WS_VISIBLE | WS_TABSTOP,13,112,243,17
+ LTEXT "Backup file mask:",IDC_STATIC,13,135,243,8
+ EDITTEXT IDC_FILEMASK,13,145,243,14,ES_AUTOHSCROLL
+ CONTROL "Compress backup to zip-archive",IDC_CHK_USEZIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,165,243,10
+ CONTROL "Backup profile folder",IDC_BACKUPPROFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,26,178,176,10
+ CONTROL "Disable progress bar",IDC_CHK_NOPROG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,191,243,10
+ CONTROL "Use CloudFile",IDC_CLOUDFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,203,105,10
+ COMBOBOX IDC_CLOUDFILESEVICE,139,200,117,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "Backup NOW",IDC_BUT_NOW,181,19,75,14
END
IDD_COPYPROGRESS DIALOGEX 0, 0, 186, 58
@@ -77,9 +78,8 @@ BEGIN
BEGIN
LEFTMARGIN, 6
RIGHTMARGIN, 264
- VERTGUIDE, 17
- VERTGUIDE, 193
- VERTGUIDE, 248
+ VERTGUIDE, 13
+ VERTGUIDE, 256
TOPMARGIN, 4
BOTTOMMARGIN, 219
END
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp
index dbbb416260..dea8d01c97 100644
--- a/plugins/Db_autobackups/src/backup.cpp
+++ b/plugins/Db_autobackups/src/backup.cpp
@@ -37,7 +37,7 @@ static void ShowPopup(const wchar_t *ptszText, wchar_t *ptszHeader, wchar_t *pts
if (ptszPath != nullptr)
ppd.PluginData = (void*)mir_wstrdup(ptszPath);
ppd.PluginWindowProc = DlgProcPopup;
- ppd.lchIcon = IcoLib_GetIcon(iconList[0].szName);
+ ppd.lchIcon = g_plugin.getIcon(IDI_BACKUP);
PUAddPopupW(&ppd);
}
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp
index c18e12f932..fa7dc4199a 100644
--- a/plugins/Db_autobackups/src/main.cpp
+++ b/plugins/Db_autobackups/src/main.cpp
@@ -6,6 +6,12 @@ HGENMENU g_hPopupMenu;
HANDLE hFolder;
char g_szMirVer[100];
+static IconItem iconList[] =
+{
+ { LPGEN("Backup profile"), "backup", IDI_BACKUP },
+ { LPGEN("Save profile as..."), "saveas", IDI_BACKUP }
+};
+
/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx = {
diff --git a/plugins/Db_autobackups/src/options.cpp b/plugins/Db_autobackups/src/options.cpp
index 7ca40e3a68..79aa228e57 100644
--- a/plugins/Db_autobackups/src/options.cpp
+++ b/plugins/Db_autobackups/src/options.cpp
@@ -8,11 +8,12 @@ class COptionsDlg : public CDlgBase
{
auto *periodText = FindControl(IDC_ED_PERIOD);
auto *numBackupsText = FindControl(IDC_ED_NUMBACKUPS);
-
+
bool bEnabled = !m_disable.IsChecked();
m_backupOnStart.Enable(bEnabled);
m_backupOnExit.Enable(bEnabled);
m_backupPeriodic.Enable(bEnabled);
+ m_nextTime.Enable(bEnabled);
numBackupsText->Enable(bEnabled);
m_numBackups.Enable(bEnabled);
m_backup.Enable(bEnabled);
@@ -37,7 +38,7 @@ class COptionsDlg : public CDlgBase
}
else {
m_cloudFileService.Enable(m_useCloudFile.IsChecked());
- UseZip_OnChange(0);
+ onChange_UseZip(0);
BYTE backupTypes = g_plugin.backup_types;
if (backupTypes == BT_DISABLED)
@@ -102,22 +103,14 @@ class COptionsDlg : public CDlgBase
return 0;
}
- CCtrlCheck m_disable;
- CCtrlCheck m_backupOnStart;
- CCtrlCheck m_backupOnExit;
- CCtrlCheck m_backupPeriodic;
- CCtrlButton m_backup;
- CCtrlSpin m_period;
- CCtrlCombo m_periodType;
+ CCtrlBase m_nextTime;
CCtrlEdit m_folder, m_filemask;
- CCtrlButton m_browseFolder;
+ CCtrlSpin m_period, m_numBackups;
+ CCtrlCheck m_disable, m_backupOnStart, m_backupOnExit, m_backupPeriodic;
+ CCtrlCheck m_disableProgress, m_useZip, m_backupProfile, m_useCloudFile;
+ CCtrlCombo m_periodType, m_cloudFileService;
+ CCtrlButton m_browseFolder, m_backup;
CCtrlHyperlink m_foldersPageLink;
- CCtrlSpin m_numBackups;
- CCtrlCheck m_disableProgress;
- CCtrlCheck m_useZip;
- CCtrlCheck m_backupProfile;
- CCtrlCheck m_useCloudFile;
- CCtrlCombo m_cloudFileService;
HWND m_hPathTip;
@@ -132,6 +125,7 @@ public:
m_backupProfile(this, IDC_BACKUPPROFILE),
m_period(this, SPIN_PERIOD, 60, 1),
m_periodType(this, IDC_PT),
+ m_nextTime(this, IDC_NEXTTIME),
m_folder(this, IDC_ED_FOLDER),
m_browseFolder(this, IDC_BUT_BROWSE),
m_filemask(this, IDC_FILEMASK),
@@ -150,16 +144,15 @@ public:
CreateLink(m_backupProfile, g_plugin.backup_profile);
CreateLink(m_useCloudFile, g_plugin.use_cloudfile);
- m_disable.OnChange = Callback(this, &COptionsDlg::Disable_OnChange);
- m_backupOnStart.OnChange = Callback(this, &COptionsDlg::BackupType_OnChange);
- m_backupOnExit.OnChange = Callback(this, &COptionsDlg::BackupType_OnChange);
- m_backupPeriodic.OnChange = Callback(this, &COptionsDlg::BackupType_OnChange);
- m_useCloudFile.OnChange = Callback(this, &COptionsDlg::UseCloudFile_OnChange);
- m_useZip.OnChange = Callback(this, &COptionsDlg::UseZip_OnChange);
+ m_disable.OnChange = Callback(this, &COptionsDlg::onChange_Disable);
+ m_backupOnStart.OnChange = m_backupOnExit.OnChange = m_backupPeriodic.OnChange = Callback(this, &COptionsDlg::onChange_BackupType);
+ m_useCloudFile.OnChange = Callback(this, &COptionsDlg::onChange_UseCloudFile);
+ m_useZip.OnChange = Callback(this, &COptionsDlg::onChange_UseZip);
+ m_period.OnChange = Callback(this, &COptionsDlg::onChange_Period);
- m_backup.OnClick = Callback(this, &COptionsDlg::Backup_OnClick);
- m_browseFolder.OnClick = Callback(this, &COptionsDlg::BrowseFolder_OnClick);
- m_foldersPageLink.OnClick = Callback(this, &COptionsDlg::FoldersPageLink_OnClick);
+ m_backup.OnClick = Callback(this, &COptionsDlg::onClick_Backup);
+ m_browseFolder.OnClick = Callback(this, &COptionsDlg::onClick_BrowseFolder);
+ m_foldersPageLink.OnClick = Callback(this, &COptionsDlg::onClick_FoldersPageLink);
}
bool OnInitDialog() override
@@ -168,6 +161,7 @@ public:
m_backupOnStart.SetState(g_plugin.backup_types & BT_START ? TRUE : FALSE);
m_backupOnExit.SetState(g_plugin.backup_types & BT_EXIT ? TRUE : FALSE);
m_backupPeriodic.SetState(g_plugin.backup_types & BT_PERIODIC ? TRUE : FALSE);
+ onChange_Period(0);
m_numBackups.SetPosition(g_plugin.num_backups);
@@ -270,35 +264,47 @@ public:
}
}
- void Disable_OnChange(CCtrlBase*)
+ void onChange_Disable(CCtrlBase*)
{
SetDialogState();
}
- void BackupType_OnChange(CCtrlBase*)
+ void onChange_Period(CCtrlSpin*)
+ {
+ time_t nextBackup = time_t(g_plugin.getDword("LastBackupTimestamp")) + m_period.GetPosition() * 86400;
+
+ wchar_t buf[100];
+ TimeZone_PrintTimeStamp(nullptr, nextBackup, L"D t", buf, _countof(buf), 0);
+ m_nextTime.SetText(CMStringW(FORMAT, L"%s %s", TranslateT("Next backup is scheduled to"), buf));
+ }
+
+ void onChange_BackupType(CCtrlBase*)
{
- if (!m_backupOnStart.IsChecked() && !m_backupOnExit.IsChecked() && !m_backupPeriodic.IsChecked()) {
+ bool bEnabled = m_backupPeriodic.IsChecked();
+ m_nextTime.Enable(bEnabled);
+
+ if (!m_backupOnStart.IsChecked() && !m_backupOnExit.IsChecked() && !bEnabled) {
m_disable.SetState(true);
SetDialogState();
}
}
- void UseCloudFile_OnChange(CCtrlBase*)
+ void onChange_UseCloudFile(CCtrlBase*)
{
m_cloudFileService.Enable(m_useCloudFile.IsChecked());
}
- void UseZip_OnChange(CCtrlCheck*)
+ void onChange_UseZip(CCtrlCheck*)
{
m_backupProfile.Enable(m_useZip.GetState());
}
- void Backup_OnClick(CCtrlButton*)
+ void onClick_Backup(CCtrlButton*)
{
BackupStart(nullptr);
}
- void BrowseFolder_OnClick(CCtrlButton*)
+ void onClick_BrowseFolder(CCtrlButton*)
{
wchar_t folder_buff[MAX_PATH] = { 0 };
@@ -320,7 +326,7 @@ public:
}
}
- void FoldersPageLink_OnClick(CCtrlHyperlink*)
+ void onClick_FoldersPageLink(CCtrlHyperlink*)
{
g_plugin.openOptions(L"Customize", L"Folders");
}
diff --git a/plugins/Db_autobackups/src/resource.h b/plugins/Db_autobackups/src/resource.h
index 7f267cb442..47f0a7b122 100644
--- a/plugins/Db_autobackups/src/resource.h
+++ b/plugins/Db_autobackups/src/resource.h
@@ -24,6 +24,7 @@
#define IDC_BACKUPPROFILE 1675
#define IDC_CLOUDFILESEVICE 1676
#define IDC_FILEMASK 1677
+#define IDC_NEXTTIME 1678
#define IDC_PROGRESSMESSAGE 0xDAED
#define IDC_PROGRESS 0xDEAD
@@ -33,7 +34,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 273
#define _APS_NEXT_COMMAND_VALUE 40018
-#define _APS_NEXT_CONTROL_VALUE 1678
+#define _APS_NEXT_CONTROL_VALUE 1679
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/plugins/Db_autobackups/src/stdafx.h b/plugins/Db_autobackups/src/stdafx.h
index d166442589..48ccefd7df 100644
--- a/plugins/Db_autobackups/src/stdafx.h
+++ b/plugins/Db_autobackups/src/stdafx.h
@@ -25,6 +25,7 @@ namespace fs = std::filesystem;
#include <m_icolib.h>
#include <m_autobackups.h>
#include <m_gui.h>
+#include <m_timezones.h>
#include <m_variables.h>
#include <m_folders.h>
@@ -75,9 +76,4 @@ int CreateZipFile(const wchar_t *szDestPath, OBJLIST<ZipFile> &lstFiles, const s
extern char g_szMirVer[];
-static IconItem iconList[] = {
- { LPGEN("Backup profile"), "backup", IDI_BACKUP },
- { LPGEN("Save profile as..."), "saveas", IDI_BACKUP }
-};
-
#endif
diff --git a/plugins/Db_autobackups/src/version.h b/plugins/Db_autobackups/src/version.h
index 7a1e5dbb59..1d1650f3b4 100644
--- a/plugins/Db_autobackups/src/version.h
+++ b/plugins/Db_autobackups/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 4
+#define __BUILD_NUM 5
#include <stdver.h>