summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Db_autobackups/src/backup.cpp20
-rw-r--r--plugins/Db_autobackups/src/headers.h1
-rw-r--r--plugins/Db_autobackups/src/main.cpp12
3 files changed, 18 insertions, 15 deletions
diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp
index a6b78dace2..40373ed461 100644
--- a/plugins/Db_autobackups/src/backup.cpp
+++ b/plugins/Db_autobackups/src/backup.cpp
@@ -30,11 +30,10 @@ INT_PTR DBSaveAs(WPARAM wParam, LPARAM lParam)
{
HWND progress_dialog = 0;
TCHAR fname_buff[MAX_PATH], szFilter[128];
- int i;
OPENFILENAME ofn = {0};
CallService(MS_DB_GETPROFILENAMET,MAX_PATH,(LPARAM)fname_buff);
- i = mir_sntprintf(szFilter, 64, _T("%s (*.dat)"), TranslateT("Miranda Databases")) + 1;
+ int i = mir_sntprintf(szFilter, 64, _T("%s (*.dat)"), TranslateT("Miranda Databases")) + 1;
_tcscpy(szFilter + i, _T("*.dat"));
i += 6;
i += mir_sntprintf(szFilter + i, 48, _T("%s (*.*)"), TranslateT("All Files")) + 1;
@@ -50,7 +49,7 @@ INT_PTR DBSaveAs(WPARAM wParam, LPARAM lParam)
ofn.lpstrDefExt = _T("dat");
if (GetSaveFileName(&ofn))
- Backup(fname_buff);
+ mir_forkthread(BackupThread, (void*)fname_buff);
return 0;
}
@@ -64,18 +63,16 @@ struct FileNameFound_Tag
int RotateBackups(HWND progress_dialog, DWORD start_time)
{
TCHAR backupfilename1[MAX_PATH] = {0}, backupfilename2[MAX_PATH] = {0}, backupfolderTmp[MAX_PATH] = {0};
- TCHAR* backupfolder;
unsigned int i = 0;
HWND prog = GetDlgItem(progress_dialog, IDC_PROGRESS);
MSG msg;
WIN32_FIND_DATA FindFileData;
- HANDLE hFind;
- backupfolder = Utils_ReplaceVarsT(options.folder);
+ TCHAR *backupfolder = Utils_ReplaceVarsT(options.folder);
mir_sntprintf(backupfolderTmp, SIZEOF(backupfolderTmp), _T("%s\\*"), backupfolder);
- hFind = FindFirstFile(backupfolderTmp, &FindFileData);
+ HANDLE hFind = FindFirstFile(backupfolderTmp, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
return 0;
_tcscpy(FileNameFound.Name, _T(""));
@@ -120,6 +117,11 @@ int RotateBackups(HWND progress_dialog, DWORD start_time)
return 0;
}
+void BackupThread(void* backup_filename)
+{
+ Backup((TCHAR*)backup_filename);
+}
+
int Backup(TCHAR* backup_filename)
{
TCHAR source_file[MAX_PATH] = {0}, dest_file[MAX_PATH] = {0};
@@ -205,7 +207,7 @@ int Backup(TCHAR* backup_filename)
VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
time_t t = time(0), diff = t - (time_t)DBGetContactSettingDword(0, "AutoBackups", "LastBackupTimestamp", (DWORD)t);
if(diff > (time_t)(options.period * (options.period_type == PT_MINUTES ? 60 : (options.period_type == PT_HOURS ? 60 * 60 : 60 * 60 * 24 ))))
- Backup(NULL);
+ mir_forkthread(BackupThread, NULL);
}
int SetBackupTimer(void)
@@ -225,6 +227,6 @@ int SetBackupTimer(void)
INT_PTR ABService(WPARAM wParam, LPARAM lParam)
{
- Backup((TCHAR*)wParam);
+ mir_forkthread(BackupThread, (void*)wParam);
return 0;
}
diff --git a/plugins/Db_autobackups/src/headers.h b/plugins/Db_autobackups/src/headers.h
index eab2ffc667..966bdcde73 100644
--- a/plugins/Db_autobackups/src/headers.h
+++ b/plugins/Db_autobackups/src/headers.h
@@ -43,6 +43,7 @@ int SetBackupTimer(void);
int OptionsInit(WPARAM wParam, LPARAM lParam);
int LoadOptions(void);
HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle);
+void BackupThread(void* backup_filename);
extern HINSTANCE hInst;
extern TCHAR* profilePath;
diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp
index 055fc80df2..e494f0a5d9 100644
--- a/plugins/Db_autobackups/src/main.cpp
+++ b/plugins/Db_autobackups/src/main.cpp
@@ -35,9 +35,9 @@ static IconItem iconList[] = {
INT_PTR BackupServiceTrgr(WPARAM wParam, LPARAM lParam)
{
- if(wParam & ACT_PERFORM) {
- return Backup(NULL);
- }
+ if(wParam & ACT_PERFORM)
+ mir_forkthread(BackupThread, NULL);
+
return 0;
}
@@ -101,7 +101,7 @@ static int ModulesLoad(WPARAM wParam, LPARAM lParam)
hHooks[1] = HookEvent(ME_OPT_INITIALISE, OptionsInit);
if(options.backup_types & BT_START)
- Backup(NULL);
+ mir_forkthread(BackupThread, NULL);
return 0;
}
@@ -111,14 +111,14 @@ int PreShutdown(WPARAM wParam, LPARAM lParam) {
if(options.backup_types & BT_EXIT)
{
options.disable_popups = 1; // Don't try to show popups on exit
- Backup(NULL);
+ mir_forkthread(BackupThread, NULL);
}
return 0;
}
void SysInit()
{
- mir_getLP( &pluginInfo );
+ mir_getLP(&pluginInfo);
OleInitialize(0);
hServices[0] = CreateServiceFunction(MS_AB_BACKUP, ABService);