summaryrefslogtreecommitdiff
path: root/plugins/Db_autobackups
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-02-24 01:22:45 +0300
committeraunsane <aunsane@gmail.com>2018-02-24 01:22:45 +0300
commitb2eb0ef7a0f7f2b2bae0a48966038a673701df21 (patch)
treea4d9dae9fd0af1fbfbfaf3e70034b7f5ea788dd0 /plugins/Db_autobackups
parent1785dc55c0a4cdcbc5f9788e0196e7d3a38fe53c (diff)
Db_autobackups: Reworking settings of DB Autobackup (#1144)
Diffstat (limited to 'plugins/Db_autobackups')
-rw-r--r--plugins/Db_autobackups/db_autobackups.vcxproj3
-rw-r--r--plugins/Db_autobackups/db_autobackups.vcxproj.filters44
-rw-r--r--plugins/Db_autobackups/res/db_autobackups.rc95
-rw-r--r--plugins/Db_autobackups/src/backup.cpp29
-rw-r--r--plugins/Db_autobackups/src/main.cpp15
-rw-r--r--plugins/Db_autobackups/src/options.cpp615
-rw-r--r--plugins/Db_autobackups/src/options.h95
-rw-r--r--plugins/Db_autobackups/src/resource.h11
-rw-r--r--plugins/Db_autobackups/src/stdafx.h10
-rw-r--r--plugins/Db_autobackups/src/version.h10
10 files changed, 486 insertions, 441 deletions
diff --git a/plugins/Db_autobackups/db_autobackups.vcxproj b/plugins/Db_autobackups/db_autobackups.vcxproj
index ffdaf3c3d5..041a3c6756 100644
--- a/plugins/Db_autobackups/db_autobackups.vcxproj
+++ b/plugins/Db_autobackups/db_autobackups.vcxproj
@@ -31,6 +31,9 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\backup.ico" />
+ </ItemGroup>
<ItemDefinitionGroup>
<ClCompile>
<ExceptionHandling>Sync</ExceptionHandling>
diff --git a/plugins/Db_autobackups/db_autobackups.vcxproj.filters b/plugins/Db_autobackups/db_autobackups.vcxproj.filters
index de5ad9f66c..bdcaa2f26a 100644
--- a/plugins/Db_autobackups/db_autobackups.vcxproj.filters
+++ b/plugins/Db_autobackups/db_autobackups.vcxproj.filters
@@ -1,4 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" />
+ <ItemGroup>
+ <ClCompile Include="src\stdafx.cxx">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\*.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\*.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\*.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\*.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\*.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\*.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\*.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\*.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\*.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ <ResourceCompile Include="res\*.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="res\backup.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/plugins/Db_autobackups/res/db_autobackups.rc b/plugins/Db_autobackups/res/db_autobackups.rc
index 1b3abb71e5..c9079484c5 100644
--- a/plugins/Db_autobackups/res/db_autobackups.rc
+++ b/plugins/Db_autobackups/res/db_autobackups.rc
@@ -12,10 +12,10 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// Russian (Russia) resources
+// Neutral (Default) resources
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
-LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
+LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
#pragma code_page(1251)
/////////////////////////////////////////////////////////////////////////////
@@ -23,16 +23,6 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
// Dialog
//
-IDD_COPYPROGRESS DIALOGEX 0, 0, 186, 58
-STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
-CAPTION "Backup progress"
-FONT 8, "MS Shell Dlg", 400, 0, 0x1
-BEGIN
- CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,24,172,9
- CTEXT "",IDC_PROGRESSMESSAGE,31,7,114,13
- PUSHBUTTON "Cancel",IDCANCEL,58,39,67,12
-END
-
IDD_OPTIONS DIALOGEX 0, 0, 271, 220
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
@@ -50,16 +40,27 @@ BEGIN
RTEXT "Number of backups to keep:",IDC_STATIC,13,92,147,8
EDITTEXT IDC_ED_NUMBACKUPS,164,90,36,12,ES_NUMBER,WS_EX_RIGHT
CONTROL "",SPIN_NUMBACKUPS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,188,90,12,12
- LTEXT "Backup to folder:",IDC_STATIC,18,120,124,11
- EDITTEXT IDC_ED_FOLDER,17,133,177,13,ES_AUTOHSCROLL
- PUSHBUTTON "Browse...",IDC_BUT_BROWSE,199,132,49,14
+ LTEXT "Backup to folder:",IDC_STATIC,18,117,124,11
+ EDITTEXT IDC_ED_FOLDER,17,130,177,13,ES_AUTOHSCROLL
+ PUSHBUTTON "Browse...",IDC_BUT_BROWSE,199,129,49,14
CONTROL "Go to the ""Options -> Customize -> Folders"" to change settings",IDC_LNK_FOLDERS,
- "Hyperlink",NOT WS_VISIBLE | WS_TABSTOP,18,135,231,17
- CONTROL "Compress backup to zip-archive",IDC_CHK_USEZIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,156,231,10
- CONTROL "Disable progress bar",IDC_CHK_NOPROG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,167,231,10
- CONTROL "Disable popups",IDC_CHK_NOPOPUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,176,231,11
- CONTROL "Use Dropbox",IDC_DROPBOX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,187,176,10
- CONTROL "Backup profile folder",IDC_BACKUPPROFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,198,176,10
+ "Hyperlink",NOT WS_VISIBLE | WS_TABSTOP,18,132,231,17
+ CONTROL "Compress backup to zip-archive",IDC_CHK_USEZIP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,153,231,10
+ CONTROL "Disable progress bar",IDC_CHK_NOPROG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,164,231,10
+ CONTROL "Disable popups",IDC_CHK_NOPOPUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,173,231,11
+ CONTROL "Backup profile folder",IDC_BACKUPPROFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,184,176,10
+ CONTROL "Use CloudFile",IDC_CLOUDFILE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,195,68,10
+ COMBOBOX IDC_CLOUDFILESEVICE,131,194,117,30,CBS_DROPDOWNLIST | CBS_SORT | WS_DISABLED | WS_VSCROLL | WS_TABSTOP
+END
+
+IDD_COPYPROGRESS DIALOGEX 0, 0, 186, 58
+STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
+CAPTION "Backup progress"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,24,172,9
+ CTEXT "",IDC_PROGRESSMESSAGE,31,7,114,13
+ PUSHBUTTON "Cancel",IDCANCEL,58,39,67,12
END
@@ -71,14 +72,6 @@ END
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
- IDD_COPYPROGRESS, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 179
- TOPMARGIN, 7
- BOTTOMMARGIN, 51
- END
-
IDD_OPTIONS, DIALOG
BEGIN
LEFTMARGIN, 6
@@ -89,6 +82,14 @@ BEGIN
TOPMARGIN, 38
BOTTOMMARGIN, 209
END
+
+ IDD_COPYPROGRESS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 179
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 51
+ END
END
#endif // APSTUDIO_INVOKED
@@ -100,8 +101,29 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-IDI_ICON1 ICON "backup.ico"
+IDI_BACKUP ICON "backup.ico"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+IDD_OPTIONS AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+#endif // Neutral (Default) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian (Russia) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+#pragma code_page(1251)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@@ -127,17 +149,6 @@ END
#endif // APSTUDIO_INVOKED
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// AFX_DIALOG_LAYOUT
-//
-
-IDD_OPTIONS AFX_DIALOG_LAYOUT
-BEGIN
- 0
-END
-
#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp
index 7ae405fd26..b6e0797ad5 100644
--- a/plugins/Db_autobackups/src/backup.cpp
+++ b/plugins/Db_autobackups/src/backup.cpp
@@ -190,11 +190,11 @@ int Backup(wchar_t *backup_filename)
if (backup_filename == nullptr) {
int err;
- wchar_t *backupfolder, buffer[MAX_COMPUTERNAME_LENGTH + 1];
+ wchar_t backupfolder[MAX_PATH], buffer[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = _countof(buffer);
bZip = options.use_zip != 0;
- backupfolder = Utils_ReplaceVarsW(options.folder);
+ PathToAbsoluteW(VARSW(options.folder), backupfolder);
// ensure the backup folder exists (either create it or return non-zero signifying error)
err = CreateDirectoryTreeW(backupfolder);
if (err != ERROR_ALREADY_EXISTS && err != 0) {
@@ -206,7 +206,6 @@ int Backup(wchar_t *backup_filename)
GetLocalTime(&st);
GetComputerName(buffer, &size);
mir_snwprintf(dest_file, L"%s\\%s_%02d.%02d.%02d@%02d-%02d-%02d_%s.%s", backupfolder, dbname, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, buffer, bZip ? L"zip" : L"dat");
- mir_free(backupfolder);
}
else {
wcsncpy_s(dest_file, backup_filename, _TRUNCATE);
@@ -221,17 +220,17 @@ int Backup(wchar_t *backup_filename)
SetDlgItemText(progress_dialog, IDC_PROGRESSMESSAGE, TranslateT("Copying database file..."));
- mir_snwprintf(source_file, L"%s\\%s", profilePath, dbname);
- wchar_t *pathtmp = Utils_ReplaceVarsW(source_file);
+ VARSW profile_path(L"%miranda_userdata%");
+ mir_snwprintf(source_file, L"%s\\%s", profile_path, dbname);
BOOL res = 0;
if (bZip)
{
res = options.backup_profile
- ? MakeZip_Dir(_T2A(profilePath), dest_file, _T2A(dbname), progress_dialog)
- : MakeZip(pathtmp, dest_file, dbname, progress_dialog);
+ ? MakeZip_Dir(_T2A(profile_path), dest_file, _T2A(dbname), progress_dialog)
+ : MakeZip(source_file, dest_file, dbname, progress_dialog);
}
else
- res = CopyFile(pathtmp, dest_file, 0);
+ res = CopyFile(source_file, dest_file, 0);
if (res) {
if (!bZip) { // Set the backup file to the current time for rotator's correct work
FILETIME ft;
@@ -243,12 +242,17 @@ int Backup(wchar_t *backup_filename)
}
SendDlgItemMessage(progress_dialog, IDC_PROGRESS, PBM_SETPOS, (WPARAM)(100), 0);
UpdateWindow(progress_dialog);
- db_set_dw(0, "AutoBackups", "LastBackupTimestamp", (DWORD)time(nullptr));
+ db_set_dw(0, MODULE, "LastBackupTimestamp", (DWORD)time(nullptr));
- if (options.use_dropbox)
+ if (options.use_cloudfile)
{
- DropboxUploadInfo ui = { dest_file, L"Backups" };
- if (CallService(MS_DROPBOX_UPLOAD, NULL, (LPARAM)&ui))
+ CFUPLOADDATA ui =
+ {
+ options.cloudfile_service,
+ dest_file,
+ L"Backups"
+ };
+ if (CallService(MS_CLOUDFILE_UPLOAD, (LPARAM)&ui))
ShowPopup(TranslateT("Uploading to Dropbox failed"), TranslateT("Error"), nullptr);
}
@@ -279,7 +283,6 @@ int Backup(wchar_t *backup_filename)
}
else
DeleteFile(dest_file);
- mir_free(pathtmp);
DestroyWindow(progress_dialog);
return 0;
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp
index 9aa48d8c6d..561e31dfeb 100644
--- a/plugins/Db_autobackups/src/main.cpp
+++ b/plugins/Db_autobackups/src/main.cpp
@@ -2,7 +2,6 @@
int hLangpack;
HINSTANCE g_hInstance;
-wchar_t *profilePath;
HANDLE hFolder;
char g_szMirVer[100];
@@ -80,13 +79,18 @@ static int ModulesLoad(WPARAM, LPARAM)
mi.position = 500100001;
Menu_AddMainMenuItem(&mi);
- profilePath = Utils_ReplaceVarsW(L"%miranda_userdata%");
-
if (hFolder = FoldersRegisterCustomPathT(LPGEN("Database backups"), LPGEN("Backup folder"), DIR SUB_DIR)) {
HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersGetBackupPath);
FoldersGetBackupPath(0, 0);
}
- options.use_dropbox = (BOOL)(db_get_b(0, "AutoBackups", "UseDropbox", 0) && ServiceExists(MS_DROPBOX_UPLOAD));
+ else {
+ DBVARIANT dbv;
+ if (!db_get_ws(0, MODULE, "Folder", &dbv)) {
+ wcsncpy_s(options.folder, dbv.ptszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+ else mir_snwprintf(options.folder, L"%s%s", DIR, SUB_DIR);
+ }
if (options.backup_types & BT_START)
BackupStart(nullptr);
@@ -124,7 +128,8 @@ extern "C" __declspec(dllexport) int Load(void)
CreateServiceFunction(MS_AB_SAVEAS, DBSaveAs);
HookEvent(ME_OPT_INITIALISE, OptionsInit);
- LoadOptions();
+
+ SetBackupTimer();
return 0;
}
diff --git a/plugins/Db_autobackups/src/options.cpp b/plugins/Db_autobackups/src/options.cpp
index 068c2c5f89..7131fe02da 100644
--- a/plugins/Db_autobackups/src/options.cpp
+++ b/plugins/Db_autobackups/src/options.cpp
@@ -1,409 +1,324 @@
#include "stdafx.h"
-HWND hPathTip;
-Options options;
-
-
-
-HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle)
+Options::Options() :
+ backup_types(MODULE, "BackupType", BT_PERIODIC),
+ period(MODULE, "Period", 1),
+ period_type(MODULE, "PeriodType", PT_DAYS),
+ num_backups(MODULE, "NumBackups", 3),
+ disable_progress(MODULE, "NoProgress", 0),
+ disable_popups(MODULE, "NoPopups", 0),
+ use_zip(MODULE, "UseZip", 0),
+ backup_profile(MODULE, "BackupProfile", 0),
+ use_cloudfile(MODULE, "UseCloudFile", 0),
+ cloudfile_service(MODULE, "CloudFileService", nullptr)
{
- HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST,
- TOOLTIPS_CLASS, nullptr,
- (WS_POPUP | TTS_NOPREFIX),
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- hwndParent, nullptr, g_hInstance, nullptr);
+}
- SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE));
+Options options;
+
+COptionsDlg::COptionsDlg()
+ : CPluginDlgBase(g_hInstance, IDD_OPTIONS, MODULE),
+ m_disable(this, IDC_RAD_DISABLED), m_backupOnStart(this, IDC_RAD_START),
+ m_backupOnExit(this, IDC_RAD_EXIT), m_backupPeriodic(this, IDC_RAD_PERIODIC),
+ m_backup(this, IDC_BUT_NOW), m_backupProfile(this, IDC_BACKUPPROFILE),
+ m_period(this, SPIN_PERIOD), m_periodType(this, IDC_PT),
+ m_folder(this, IDC_ED_FOLDER), m_browseFolder(this, IDC_BUT_BROWSE),
+ m_foldersPageLink(this, IDC_LNK_FOLDERS, nullptr), m_numBackups(this, SPIN_NUMBACKUPS),
+ m_disableProgress(this, IDC_CHK_NOPROG), m_disablePopups(this, IDC_CHK_NOPOPUP),
+ m_useZip(this, IDC_CHK_USEZIP), m_useCloudFile(this, IDC_CLOUDFILE),
+ m_cloudFileService(this, IDC_CLOUDFILESEVICE)
+{
+ CreateLink(m_period, options.period);
+ CreateLink(m_periodType, options.period_type);
+ CreateLink(m_numBackups, options.num_backups);
+ CreateLink(m_disableProgress, options.disable_progress);
+ CreateLink(m_disablePopups, options.disable_popups);
+ CreateLink(m_useZip, options.use_zip);
+ CreateLink(m_backupProfile, options.backup_profile);
+ CreateLink(m_useCloudFile, options.use_cloudfile);
+
+ m_disable.OnChange = Callback(this, &COptionsDlg::Disable_OnChange);
+ m_useCloudFile.OnChange = Callback(this, &COptionsDlg::UseCloudFile_OnChange);
+
+ m_backup.OnClick = Callback(this, &COptionsDlg::Backup_OnClick);
+ m_browseFolder.OnClick = Callback(this, &COptionsDlg::BrowseFolder_OnClick);
+ m_foldersPageLink.OnClick = Callback(this, &COptionsDlg::FoldersPageLink_OnClick);
+}
- TOOLINFO ti = { 0 };
- ti.cbSize = sizeof(TOOLINFO);
- ti.uFlags = TTF_SUBCLASS | TTF_CENTERTIP;
- ti.hwnd = hwndParent;
- ti.hinst = g_hInstance;
- ti.lpszText = ptszText;
- GetClientRect(hwndParent, &ti.rect);
- ti.rect.left = -80;
+void COptionsDlg::OnInitDialog()
+{
+ m_disable.SetState(options.backup_types == BT_DISABLED);
+ m_backupOnStart.SetState(options.backup_types & BT_START ? TRUE : FALSE);
+ m_backupOnExit.SetState(options.backup_types & BT_EXIT ? TRUE : FALSE);
+ m_backupPeriodic.SetState(options.backup_types & BT_PERIODIC ? TRUE : FALSE);
+
+ m_period.SetRange(60, 1);
+ m_numBackups.SetRange(9999, 1);
+
+ m_periodType.AddString(TranslateT("days"));
+ m_periodType.AddString(TranslateT("hours"));
+ m_periodType.AddString(TranslateT("minutes"));
+ m_periodType.SetCurSel(options.period_type);
+
+ if (ServiceExists(MS_FOLDERS_GET_PATH)) {
+ m_folder.Hide();
+ m_browseFolder.Hide();
+ m_foldersPageLink.Show();
+ }
+ else {
+ m_folder.SetText(options.folder);
+
+ wchar_t tszTooltipText[4096];
+ mir_snwprintf(tszTooltipText, L"%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s",
+ L"%miranda_path%", TranslateT("path to Miranda root folder"),
+ L"%miranda_profilesdir%", TranslateT("path to folder containing Miranda profiles"),
+ L"%miranda_profilename%", TranslateT("name of current Miranda profile (filename, without extension)"),
+ L"%miranda_userdata%", TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"),
+ L"%appdata%", TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"),
+ L"%username%", TranslateT("username for currently logged-on Windows user"),
+ L"%mydocuments%", TranslateT("\"My Documents\" folder for currently logged-on Windows user"),
+ L"%desktop%", TranslateT("\"Desktop\" folder for currently logged-on Windows user"),
+ L"%xxxxxxx%", TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"));
+ CreateToolTip(tszTooltipText, TranslateT("Variables"));
+ }
- SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM)&ti);
- SendMessage(hwndTT, TTM_SETTITLE, 1, (LPARAM)ptszTitle);
- SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, (LPARAM)650);
+ m_disablePopups.Show(ServiceExists(MS_POPUP_ADDPOPUPT));
+
+ m_periodType.AddString(TranslateT("days"));
+ m_periodType.AddString(TranslateT("hours"));
+ m_periodType.AddString(TranslateT("minutes"));
+ m_periodType.SetCurSel(options.period_type);
+
+ m_useCloudFile.Show(ServiceExists(MS_CLOUDFILE_UPLOAD));
+ m_cloudFileService.Show(ServiceExists(MS_CLOUDFILE_ENUMSERVICES));
+ if (ServiceExists(MS_CLOUDFILE_ENUMSERVICES)) {
+ m_cloudFileService.Enable();
+ m_cloudFileService.AddString(L"");
+ CallService(MS_CLOUDFILE_ENUMSERVICES, (WPARAM)&COptionsDlg::EnumCloudFileServices, (LPARAM)&m_cloudFileService);
+ }
- return hwndTT;
+ SetDialogState();
}
-
-int LoadOptions(void)
+void COptionsDlg::OnApply()
{
- options.backup_types = (BackupType)db_get_b(0, "AutoBackups", "BackupType", (BYTE)(BT_PERIODIC));
- options.period = (unsigned int)db_get_w(0, "AutoBackups", "Period", 1);
- options.period_type = (PeriodType)db_get_b(0, "AutoBackups", "PeriodType", (BYTE)PT_DAYS);
+ BYTE backupTypes = BT_DISABLED;
+
+ if (m_backupOnStart.IsChecked())
+ backupTypes |= BT_START;
+ else
+ backupTypes &= ~BT_START;
- if (!ServiceExists(MS_FOLDERS_GET_PATH)) {
- DBVARIANT dbv;
+ if (m_backupOnExit.IsChecked())
+ backupTypes |= BT_EXIT;
+ else
+ backupTypes &= ~BT_EXIT;
+
+ if (m_backupPeriodic.IsChecked())
+ backupTypes |= BT_PERIODIC;
+ else
+ backupTypes &= ~BT_PERIODIC;
- if (!db_get_ws(0, "AutoBackups", "Folder", &dbv)) {
- wchar_t *tmp = Utils_ReplaceVarsW(dbv.ptszVal);
+ options.backup_types = backupTypes;
- if (mir_wstrlen(tmp) >= 2 && tmp[1] == ':')
- wcsncpy_s(options.folder, dbv.ptszVal, _TRUNCATE);
- else
- mir_snwprintf(options.folder, L"%s\\%s", profilePath, dbv.ptszVal);
+ SetBackupTimer();
- db_free(&dbv);
- mir_free(tmp);
+ ptrW folder(m_folder.GetText());
+ {
+ wchar_t backupfolder[MAX_PATH];
+ PathToAbsoluteW(VARSW(folder), backupfolder);
+ int err = CreateDirectoryTreeW(backupfolder);
+ if (err != ERROR_ALREADY_EXISTS && err != 0) {
+ wchar_t msg[512];
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, 0, msg, 512, nullptr);
+ MessageBox(nullptr, msg, TranslateT("Error creating backup folder"), MB_OK | MB_ICONERROR);
+ return;
}
- else mir_snwprintf(options.folder, L"%s%s", DIR, SUB_DIR);
+ db_set_ws(0, MODULE, "Folder", folder);
}
- options.num_backups = db_get_w(0, "AutoBackups", "NumBackups", 3);
- options.disable_progress = (BOOL)db_get_b(0, "AutoBackups", "NoProgress", 0);
- options.disable_popups = (BOOL)db_get_b(0, "AutoBackups", "NoPopups", 0);
- options.use_zip = (BOOL)db_get_b(0, "AutoBackups", "UseZip", 0);
- options.use_dropbox = (BOOL)(db_get_b(0, "AutoBackups", "UseDropbox", 0) && ServiceExists(MS_DROPBOX_UPLOAD));
- options.backup_profile = (BOOL)db_get_b(0, "AutoBackups", "BackupProfile", 0);
+ int currentService = m_cloudFileService.GetCurSel();
+ options.cloudfile_service = currentService > 0
+ ? (char*)m_cloudFileService.GetItemData(currentService)
+ : nullptr;
+}
- SetBackupTimer();
- return 0;
+void COptionsDlg::OnTimer(CTimer*)
+{
+ if (IsWindow(m_hPathTip))
+ KillTimer(m_hwnd, 4); // It will prevent tooltip autoclosing
}
-int SaveOptions(void)
+void COptionsDlg::OnDestroy()
{
- wchar_t prof_dir[MAX_PATH];
+ if (m_hPathTip) {
+ KillTimer(m_hwnd, 0);
+ DestroyWindow(m_hPathTip);
+ m_hPathTip = nullptr;
+ }
+}
- db_set_b(0, "AutoBackups", "BackupType", (BYTE)options.backup_types);
- if (options.period < 1)
- options.period = 1;
- db_set_w(0, "AutoBackups", "Period", (WORD)options.period);
- db_set_b(0, "AutoBackups", "PeriodType", (BYTE)options.period_type);
+void COptionsDlg::Disable_OnChange(CCtrlBase*)
+{
+ SetDialogState();
+}
- mir_snwprintf(prof_dir, L"%s\\", profilePath);
- size_t prof_len = mir_wstrlen(prof_dir);
- size_t opt_len = mir_wstrlen(options.folder);
+void COptionsDlg::UseCloudFile_OnChange(CCtrlBase*)
+{
+ m_cloudFileService.Enable(m_useCloudFile.IsChecked());
+}
- if (opt_len > prof_len && wcsncmp(options.folder, prof_dir, prof_len) == 0) {
- db_set_ws(0, "AutoBackups", "Folder", (options.folder + prof_len));
- }
- else
- db_set_ws(0, "AutoBackups", "Folder", options.folder);
+void COptionsDlg::Backup_OnClick(CCtrlButton*)
+{
+ BackupStart(nullptr);
+}
- wchar_t *tmp = Utils_ReplaceVarsW(options.folder);
- if (mir_wstrlen(tmp) < 2 || tmp[1] != ':') {
- wcsncpy_s(prof_dir, options.folder, _TRUNCATE);
- mir_snwprintf(options.folder, L"%s\\%s", profilePath, prof_dir);
- }
- mir_free(tmp);
- db_set_w(0, "AutoBackups", "NumBackups", options.num_backups);
- db_set_b(0, "AutoBackups", "NoProgress", (BYTE)options.disable_progress);
- db_set_b(0, "AutoBackups", "NoPopups", (BYTE)options.disable_popups);
- db_set_b(0, "AutoBackups", "UseZip", (BYTE)options.use_zip);
- db_set_b(0, "AutoBackups", "UseDropbox", (BYTE)options.use_dropbox);
- db_set_b(0, "AutoBackups", "BackupProfile", (BYTE)options.backup_profile);
+void COptionsDlg::BrowseFolder_OnClick(CCtrlButton*)
+{
+ wchar_t folder_buff[MAX_PATH] = { 0 };
- SetBackupTimer();
- return 0;
+ BROWSEINFO bi;
+ bi.hwndOwner = m_hwnd;
+ bi.pidlRoot = nullptr;
+ bi.pszDisplayName = folder_buff;
+ bi.lpszTitle = TranslateT("Select backup folder");
+ bi.ulFlags = BIF_NEWDIALOGSTYLE;
+ bi.lpfn = BrowseProc;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ LPCITEMIDLIST pidl = SHBrowseForFolder(&bi);
+ if (pidl != nullptr) {
+ SHGetPathFromIDList(pidl, folder_buff);
+ m_folder.SetText(folder_buff);
+ CoTaskMemFree((void*)pidl);
+ }
}
-Options new_options;
+void COptionsDlg::FoldersPageLink_OnClick(CCtrlHyperlink*)
+{
+ Options_Open(L"Customize", L"Folders");
+}
-int SetDlgState(HWND hwndDlg)
+void COptionsDlg::SetDialogState()
{
- wchar_t buff[10];
-
- if (new_options.backup_types == BT_DISABLED) {
- CheckDlgButton(hwndDlg, IDC_RAD_DISABLED, BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_RAD_DISABLED), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_NUMBACKUPS), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_FOLDER), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BUT_BROWSE), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LNK_FOLDERS), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_NOPROG), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_NOPOPUP), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEZIP), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PERIOD), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PT), FALSE);
-
- CheckDlgButton(hwndDlg, IDC_RAD_START, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_EXIT, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_PERIODIC, BST_UNCHECKED);
+ CCtrlEdit &periodText = *(CCtrlEdit*)FindControl(IDC_ED_PERIOD);
+ CCtrlEdit &numBackupsText = *(CCtrlEdit*)FindControl(IDC_ED_NUMBACKUPS);
+ if (m_disable.IsChecked()) {
+ m_disable.SetState(TRUE);
+ m_backupOnStart.Disable();
+ m_backupOnExit.Disable();
+ m_backupPeriodic.Disable();
+ m_backup.Disable();
+ numBackupsText.Disable();
+ m_numBackups.Disable();
+ m_folder.Disable();
+ m_browseFolder.Disable();
+ m_foldersPageLink.Disable();
+ m_disableProgress.Disable();
+ m_disablePopups.Disable();
+ m_useZip.Disable();
+ periodText.Disable();
+ m_period.Disable();
+ m_periodType.Disable();
+ m_backupProfile.Disable();
+ m_useCloudFile.Disable();
+ m_cloudFileService.Disable();
+
+ m_backupOnStart.SetState(FALSE);
+ m_backupOnExit.SetState(FALSE);
+ m_backupPeriodic.SetState(FALSE);
}
else {
- EnableWindow(GetDlgItem(hwndDlg, IDC_RAD_DISABLED), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_NUMBACKUPS), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_FOLDER), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BUT_BROWSE), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LNK_FOLDERS), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_NOPROG), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_NOPOPUP), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEZIP), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_PERIOD), new_options.backup_types & BT_PERIODIC);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PT), new_options.backup_types & BT_PERIODIC);
- EnableWindow(GetDlgItem(hwndDlg, IDC_DROPBOX), ServiceExists(MS_DROPBOX_UPLOAD));
- EnableWindow(GetDlgItem(hwndDlg, IDC_BACKUPPROFILE), new_options.use_zip);
-
- CheckDlgButton(hwndDlg, IDC_RAD_DISABLED, BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_START, new_options.backup_types & BT_START ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_EXIT, new_options.backup_types & BT_EXIT ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RAD_PERIODIC, new_options.backup_types & BT_PERIODIC ? BST_CHECKED : BST_UNCHECKED);
+ m_backupOnStart.Enable();
+ m_backupOnExit.Enable();
+ m_backupPeriodic.Enable();
+ numBackupsText.Enable();
+ m_numBackups.Enable();
+ m_backup.Enable();
+ m_folder.Enable();
+ m_browseFolder.Enable();
+ m_foldersPageLink.Enable();
+ m_disableProgress.Enable();
+ m_disablePopups.Enable();
+ m_useZip.Enable();
+ periodText.Enable();
+ m_period.Enable();
+ m_periodType.Enable();
+ m_backupProfile.Enable();
+ m_useCloudFile.Enable();
+ m_cloudFileService.Enable(m_useCloudFile.IsChecked());
+
+ m_disable.SetState(FALSE);
+ m_backupOnStart.SetState(options.backup_types & BT_START ? TRUE : FALSE);
+ m_backupOnExit.SetState(options.backup_types & BT_EXIT ? TRUE : FALSE);
+ m_backupPeriodic.SetState(options.backup_types & BT_PERIODIC ? TRUE : FALSE);
}
+}
- SendDlgItemMessage(hwndDlg, SPIN_PERIOD, UDM_SETRANGE32, 1, (LPARAM)60);
- SetDlgItemText(hwndDlg, IDC_ED_PERIOD, _itow(new_options.period, buff, 10));
+void COptionsDlg::CreateToolTip(LPTSTR ptszText, LPTSTR ptszTitle)
+{
+ HWND hwndFolder = m_folder.GetHwnd();
- SendDlgItemMessage(hwndDlg, SPIN_NUMBACKUPS, UDM_SETRANGE32, 1, (LPARAM)9999);
- SetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, _itow(new_options.num_backups, buff, 10));
+ m_hPathTip = CreateWindowEx(WS_EX_TOPMOST,
+ TOOLTIPS_CLASS, nullptr,
+ (WS_POPUP | TTS_NOPREFIX),
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ hwndFolder, nullptr, g_hInstance, nullptr);
- SetDlgItemText(hwndDlg, IDC_ED_FOLDER, new_options.folder);
+ if (m_hPathTip == nullptr)
+ {
+ return;
+ }
- CheckDlgButton(hwndDlg, IDC_CHK_NOPROG, new_options.disable_progress ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_NOPOPUP, new_options.disable_popups ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_USEZIP, new_options.use_zip ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DROPBOX, new_options.use_dropbox && ServiceExists(MS_DROPBOX_UPLOAD) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_BACKUPPROFILE, new_options.backup_profile && new_options.use_zip ? BST_CHECKED : BST_UNCHECKED);
- if (!ServiceExists(MS_POPUP_ADDPOPUPT))
- ShowWindow(GetDlgItem(hwndDlg, IDC_CHK_NOPOPUP), SW_HIDE);
+ SetWindowPos(m_hPathTip, HWND_TOPMOST, 0, 0, 0, 0, (SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE));
- return 0;
+ TOOLINFO ti = { 0 };
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.uFlags = TTF_SUBCLASS | TTF_CENTERTIP;
+ ti.hwnd = hwndFolder;
+ ti.hinst = g_hInstance;
+ ti.lpszText = ptszText;
+ GetClientRect(hwndFolder, &ti.rect);
+ ti.rect.left = -80;
+
+ SendMessage(m_hPathTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
+ SendMessage(m_hPathTip, TTM_SETTITLE, 1, (LPARAM)ptszTitle);
+ SendMessage(m_hPathTip, TTM_SETMAXTIPWIDTH, 0, (LPARAM)650);
+
+ SetTimer(m_hwnd, 0, 3000, nullptr);
}
-int CALLBACK BrowseProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM)
+int CALLBACK COptionsDlg::BrowseProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM)
{
switch (uMsg)
{
case BFFM_INITIALIZED:
- wchar_t *folder = Utils_ReplaceVarsW(options.folder);
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)folder);
- mir_free(folder);
+ wchar_t backupfolder[MAX_PATH];
+ PathToAbsoluteW(VARSW(options.folder), backupfolder);
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)backupfolder);
break;
}
- return 0;
+ return FALSE;
}
-INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+int COptionsDlg::EnumCloudFileServices(const CFSERVICEINFO *serviceInfo, void *param)
{
- wchar_t folder_buff[MAX_PATH] = { 0 };
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- memcpy(&new_options, &options, sizeof(Options));
-
- if (ServiceExists(MS_FOLDERS_GET_PATH)) {
- ShowWindow(GetDlgItem(hwndDlg, IDC_ED_FOLDER), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_BUT_BROWSE), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_LNK_FOLDERS), SW_SHOW);
- }
- else {
- wchar_t tszTooltipText[4096];
- mir_snwprintf(tszTooltipText, L"%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s",
- L"%miranda_path%", TranslateT("path to Miranda root folder"),
- L"%miranda_profilesdir%", TranslateT("path to folder containing Miranda profiles"),
- L"%miranda_profilename%", TranslateT("name of current Miranda profile (filename, without extension)"),
- L"%miranda_userdata%", TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"),
- L"%appdata%", TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"),
- L"%username%", TranslateT("username for currently logged-on Windows user"),
- L"%mydocuments%", TranslateT("\"My Documents\" folder for currently logged-on Windows user"),
- L"%desktop%", TranslateT("\"Desktop\" folder for currently logged-on Windows user"),
- L"%xxxxxxx%", TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)")
- );
- hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_ED_FOLDER), tszTooltipText, TranslateT("Variables"));
- }
-
- SetDlgState(hwndDlg);
-
- SendDlgItemMessage(hwndDlg, IDC_PT, CB_ADDSTRING, 0, (LPARAM)TranslateT("days"));
- SendDlgItemMessage(hwndDlg, IDC_PT, CB_ADDSTRING, 0, (LPARAM)TranslateT("hours"));
- SendDlgItemMessage(hwndDlg, IDC_PT, CB_ADDSTRING, 0, (LPARAM)TranslateT("minutes"));
- switch (new_options.period_type) {
- case PT_DAYS: SendDlgItemMessage(hwndDlg, IDC_PT, CB_SETCURSEL, 0, 0); break;
- case PT_HOURS: SendDlgItemMessage(hwndDlg, IDC_PT, CB_SETCURSEL, 1, 0); break;
- case PT_MINUTES: SendDlgItemMessage(hwndDlg, IDC_PT, CB_SETCURSEL, 2, 0); break;
- }
-
- if (hPathTip)
- SetTimer(hwndDlg, 0, 3000, nullptr);
- return TRUE;
-
- case WM_COMMAND:
- if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
- switch (LOWORD(wParam)) {
- case IDC_ED_PERIOD:
- case IDC_ED_FOLDER:
- case IDC_ED_NUMBACKUPS:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- if (HIWORD(wParam) == CBN_SELCHANGE)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
-
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC_RAD_DISABLED:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_DISABLED))
- new_options.backup_types = BT_DISABLED;
-
- SetDlgState(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_RAD_START:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_START))
- new_options.backup_types |= BT_START;
- else
- new_options.backup_types &= ~BT_START;
- SetDlgState(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_RAD_EXIT:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_EXIT))
- new_options.backup_types |= BT_EXIT;
- else
- new_options.backup_types &= ~BT_EXIT;
- SetDlgState(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_RAD_PERIODIC:
- if (IsDlgButtonChecked(hwndDlg, IDC_RAD_PERIODIC))
- new_options.backup_types |= BT_PERIODIC;
- else
- new_options.backup_types &= ~BT_PERIODIC;
- SetDlgState(hwndDlg);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
-
- case IDC_BUT_BROWSE:
- {
- BROWSEINFO bi;
- bi.hwndOwner = hwndDlg;
- bi.pidlRoot = nullptr;
- bi.pszDisplayName = folder_buff;
- bi.lpszTitle = TranslateT("Select backup folder");
- bi.ulFlags = BIF_NEWDIALOGSTYLE;
- bi.lpfn = BrowseProc;
- bi.lParam = 0;
- bi.iImage = 0;
-
- LPCITEMIDLIST pidl = SHBrowseForFolder(&bi);
- if (pidl != nullptr) {
- SHGetPathFromIDList(pidl, folder_buff);
-
- SetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff);
-
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
-
- CoTaskMemFree((void *)pidl);
- }
- break;
- }
- case IDC_BUT_NOW:
- BackupStart(nullptr);
- break;
- case IDC_CHK_NOPROG:
- new_options.disable_progress = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOPROG);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_CHK_NOPOPUP:
- new_options.disable_popups = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOPOPUP);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_CHK_USEZIP:
- new_options.use_zip = IsDlgButtonChecked(hwndDlg, IDC_CHK_USEZIP);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_BACKUPPROFILE), new_options.use_zip);
- break;
- case IDC_DROPBOX:
- new_options.use_dropbox = IsDlgButtonChecked(hwndDlg, IDC_DROPBOX);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_BACKUPPROFILE:
- new_options.backup_profile = IsDlgButtonChecked(hwndDlg, IDC_BACKUPPROFILE) && IsDlgButtonChecked(hwndDlg, IDC_CHK_USEZIP);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- case IDC_LNK_FOLDERS:
- Options_Open(L"Customize", L"Folders");
- break;
- }
- }
- break;
-
- case WM_TIMER:
- if (IsWindow(hPathTip))
- KillTimer(hPathTip, 4); // It will prevent tooltip autoclosing
- break;
-
- case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- wchar_t buff[10];
- GetDlgItemText(hwndDlg, IDC_ED_PERIOD, buff, _countof(buff));
- new_options.period = _wtoi(buff);
- GetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, buff, _countof(buff));
- new_options.num_backups = _wtoi(buff);
-
- switch (SendDlgItemMessage(hwndDlg, IDC_PT, CB_GETCURSEL, 0, 0)) {
- case 0: new_options.period_type = PT_DAYS; break;
- case 1: new_options.period_type = PT_HOURS; break;
- case 2: new_options.period_type = PT_MINUTES; break;
- }
-
- GetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff, _countof(folder_buff));
- {
- wchar_t backupfolder[MAX_PATH] = { 0 };
- BOOL folder_ok = TRUE;
- wchar_t *tmp = Utils_ReplaceVarsW(folder_buff);
-
- if (mir_wstrlen(tmp) >= 2 && tmp[1] == ':')
- wcsncpy_s(backupfolder, tmp, _TRUNCATE);
- else
- mir_snwprintf(backupfolder, L"%s\\%s", profilePath, tmp);
- mir_free(tmp);
-
- int err = CreateDirectoryTreeW(backupfolder);
- if (err != ERROR_ALREADY_EXISTS && err != 0) {
- wchar_t msg_buff[512];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, 0, msg_buff, 512, nullptr);
- MessageBox(nullptr, msg_buff, TranslateT("Error creating backup folder"), MB_OK | MB_ICONERROR);
- folder_ok = FALSE;
- }
-
- if (folder_ok) {
- wcsncpy_s(new_options.folder, folder_buff, _TRUNCATE);
- memcpy(&options, &new_options, sizeof(Options));
- SaveOptions();
- }
- else {
- memcpy(&new_options, &options, sizeof(Options));
- SetDlgState(hwndDlg);
- }
- }
- return TRUE;
-
- }
- break;
-
- case WM_DESTROY:
- if (hPathTip) {
- KillTimer(hwndDlg, 0);
- DestroyWindow(hPathTip);
- hPathTip = nullptr;
- }
- return FALSE;
- }
-
- return FALSE;
+ CCtrlCombo &combo = *(CCtrlCombo*)param;
+ combo.AddString(serviceInfo->userName, (LPARAM)serviceInfo->accountName);
+ if (mir_strcmp(serviceInfo->accountName, options.cloudfile_service) == 0)
+ combo.SetCurSel(combo.GetCount() - 1);
+ return 0;
}
int OptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.position = -790000000;
- odp.hInstance = g_hInstance;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.flags = ODPF_BOLDGROUPS;
odp.szTitle.a = LPGEN("Automatic backups");
odp.szGroup.a = LPGEN("Database");
- odp.flags = ODPF_BOLDGROUPS;
- odp.pfnDlgProc = DlgProcOptions;
+ odp.pDialog = new COptionsDlg();
Options_AddPage(wParam, &odp);
return 0;
diff --git a/plugins/Db_autobackups/src/options.h b/plugins/Db_autobackups/src/options.h
index d680a73f87..8a33514f26 100644
--- a/plugins/Db_autobackups/src/options.h
+++ b/plugins/Db_autobackups/src/options.h
@@ -22,20 +22,81 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-typedef enum { BT_DISABLED = 0, BT_START = 1, BT_EXIT = 2, BT_PERIODIC = 4 } BackupType;
-typedef enum { PT_DAYS, PT_HOURS, PT_MINUTES } PeriodType;
-
-typedef struct Options_tag {
- int backup_types;
- unsigned int period;
- PeriodType period_type;
- wchar_t folder[MAX_PATH];
- int num_backups;
- BOOL disable_progress;
- BOOL disable_popups;
- BOOL use_zip;
- BOOL use_dropbox;
- BOOL backup_profile;
-} Options;
-
-extern Options options; \ No newline at end of file
+enum BackupType
+{
+ BT_DISABLED = 0,
+ BT_START = 1,
+ BT_EXIT = 2,
+ BT_PERIODIC = 4
+};
+
+enum PeriodType
+{
+ PT_DAYS,
+ PT_HOURS,
+ PT_MINUTES
+};
+
+struct Options
+{
+ CMOption<BYTE> backup_types;
+ CMOption<WORD> period;
+ CMOption<BYTE> period_type;
+ wchar_t folder[MAX_PATH];
+ CMOption<WORD> num_backups;
+ CMOption<BYTE> disable_progress;
+ CMOption<BYTE> disable_popups;
+ CMOption<BYTE> use_zip;
+ CMOption<BYTE> backup_profile;
+ CMOption<BYTE> use_cloudfile;
+ CMOption<char*> cloudfile_service;
+
+ Options();
+};
+
+class COptionsDlg : public CPluginDlgBase
+{
+ CCtrlCheck m_disable;
+ CCtrlCheck m_backupOnStart;
+ CCtrlCheck m_backupOnExit;
+ CCtrlCheck m_backupPeriodic;
+ CCtrlButton m_backup;
+ CCtrlSpin m_period;
+ CCtrlCombo m_periodType;
+ CCtrlEdit m_folder;
+ CCtrlButton m_browseFolder;
+ CCtrlHyperlink m_foldersPageLink;
+ CCtrlSpin m_numBackups;
+ CCtrlCheck m_disableProgress;
+ CCtrlCheck m_disablePopups;
+ CCtrlCheck m_useZip;
+ CCtrlCheck m_backupProfile;
+ CCtrlCheck m_useCloudFile;
+ CCtrlCombo m_cloudFileService;
+
+ HWND m_hPathTip;
+
+protected:
+ void OnInitDialog() override;
+ void OnApply() override;
+ void OnTimer(CTimer*) override;
+ void OnDestroy() override;
+
+ void Disable_OnChange(CCtrlBase*);
+ void UseCloudFile_OnChange(CCtrlBase*);
+
+ void Backup_OnClick(CCtrlButton*);
+ void BrowseFolder_OnClick(CCtrlButton*);
+ void FoldersPageLink_OnClick(CCtrlHyperlink*);
+
+ void SetDialogState();
+
+ void CreateToolTip(LPTSTR ptszText, LPTSTR ptszTitle);
+
+ static int CALLBACK BrowseProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM);
+
+ static int EnumCloudFileServices(const CFSERVICEINFO *serviceInfo, void *param);
+
+public:
+ COptionsDlg();
+}; \ No newline at end of file
diff --git a/plugins/Db_autobackups/src/resource.h b/plugins/Db_autobackups/src/resource.h
index fce60af1e5..ed8683260b 100644
--- a/plugins/Db_autobackups/src/resource.h
+++ b/plugins/Db_autobackups/src/resource.h
@@ -1,9 +1,9 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by D:\Miranda NG Git_orig\plugins\Db_autobackups\res\db_autobackups.rc
+// Used by D:\Projects\c++\miranda-ng\plugins\Db_autobackups\res\db_autobackups.rc
//
#define IDD_OPTIONS 101
-#define IDI_ICON1 270
+#define IDI_BACKUP 270
#define IDD_COPYPROGRESS 271
#define SPIN_PERIOD 1369
#define SPIN_NUMBACKUPS 1370
@@ -21,10 +21,9 @@
#define IDC_BUT_NOW 1671
#define IDC_CHK_NOPOPUP 1672
#define IDC_CHK_USEZIP 1673
-#define IDC_CHECK1 1674
-#define IDC_DROPBOX 1674
-#define IDC_CHECK2 1675
+#define IDC_CLOUDFILE 1674
#define IDC_BACKUPPROFILE 1675
+#define IDC_CLOUDFILESEVICE 1676
#define IDC_PROGRESSMESSAGE 0xDAED
#define IDC_PROGRESS 0xDEAD
@@ -34,7 +33,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 273
#define _APS_NEXT_COMMAND_VALUE 40018
-#define _APS_NEXT_CONTROL_VALUE 1676
+#define _APS_NEXT_CONTROL_VALUE 1677
#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 55ed621497..1fad41efd7 100644
--- a/plugins/Db_autobackups/src/stdafx.h
+++ b/plugins/Db_autobackups/src/stdafx.h
@@ -25,9 +25,12 @@
#include <m_popup.h>
#include <m_icolib.h>
#include <m_autobackups.h>
+#include <m_gui.h>
#include <m_folders.h>
-#include <m_dropbox.h>
+#include <m_cloudfile.h>
+
+#define MODULE "AutoBackups"
#include "options.h"
#include "resource.h"
@@ -36,9 +39,11 @@
#define SUB_DIR L"\\AutoBackups"
#define DIR L"%miranda_userdata%"
+struct Options;
+extern Options options;
+
int SetBackupTimer(void);
int OptionsInit(WPARAM wParam, LPARAM lParam);
-int LoadOptions(void);
void BackupStart(wchar_t *backup_filename);
struct ZipFile
@@ -51,7 +56,6 @@ struct ZipFile
int CreateZipFile(const char *szDestPath, OBJLIST<ZipFile> &lstFiles, const std::function<bool(size_t)> &fnCallback);
extern HINSTANCE g_hInstance;
-extern wchar_t *profilePath;
extern char g_szMirVer[];
static IconItem iconList[] = {
diff --git a/plugins/Db_autobackups/src/version.h b/plugins/Db_autobackups/src/version.h
index e54800bb5c..29d6251213 100644
--- a/plugins/Db_autobackups/src/version.h
+++ b/plugins/Db_autobackups/src/version.h
@@ -1,13 +1,13 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 10
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 11
#include <stdver.h>
-#define __PLUGIN_NAME "Db autobackuper"
-#define __FILENAME "Db_autobackups.dll"
+#define __PLUGIN_NAME "Db autobackuper"
+#define __FILENAME "Db_autobackups.dll"
#define __DESCRIPTION "Database autobackuper plugin."
-#define __AUTHOR "chaos.persei, sje, Kildor, Billy_Bons"
+#define __AUTHOR "chaos.persei, sje, Kildor, Billy_Bons"
#define __AUTHORWEB "https://miranda-ng.org/p/Db_autobackups/"
#define __COPYRIGHT "© 2005-18 chaos.persei, sje, Kildor, Billy_Bons, Vasilich, Miranda NG team"