From a726af53f03ff37df6c57afd6ab947ace70dea47 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Tue, 25 Dec 2012 19:44:14 +0000 Subject: minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@2845 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Db_autobackups/src/backup.cpp | 22 ++++++------ plugins/Db_autobackups/src/main.cpp | 29 +++++++--------- plugins/Db_autobackups/src/options.cpp | 61 ++++++++++++++++++---------------- 3 files changed, 55 insertions(+), 57 deletions(-) (limited to 'plugins') diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index 40373ed461..155480ed58 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -28,7 +28,6 @@ INT_PTR CALLBACK DlgProcProgress(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l INT_PTR DBSaveAs(WPARAM wParam, LPARAM lParam) { - HWND progress_dialog = 0; TCHAR fname_buff[MAX_PATH], szFilter[128]; OPENFILENAME ofn = {0}; CallService(MS_DB_GETPROFILENAMET,MAX_PATH,(LPARAM)fname_buff); @@ -62,7 +61,7 @@ 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 backupfilename1[MAX_PATH] = {0}, backupfolderTmp[MAX_PATH] = {0}; unsigned int i = 0; HWND prog = GetDlgItem(progress_dialog, IDC_PROGRESS); MSG msg; @@ -125,11 +124,8 @@ void BackupThread(void* backup_filename) int Backup(TCHAR* backup_filename) { TCHAR source_file[MAX_PATH] = {0}, dest_file[MAX_PATH] = {0}; - TCHAR* backupfolder,* pathtmp,* puText; HWND progress_dialog; DWORD start_time = GetTickCount(); - int i; - size_t dest_file_len; CallService(MS_DB_GETPROFILENAMET, MAX_PATH, (LPARAM)dbname); @@ -141,7 +137,7 @@ int Backup(TCHAR* backup_filename) TCHAR buffer[MAX_COMPUTERNAME_LENGTH+1]; DWORD size = sizeof(buffer); - backupfolder = Utils_ReplaceVarsT(options.folder); + TCHAR *backupfolder = Utils_ReplaceVarsT(options.folder); // ensure the backup folder exists (either create it or return non-zero signifying error) err = CreateDirectoryTree(backupfolder); if(err != ERROR_ALREADY_EXISTS && err != 0) { @@ -171,7 +167,7 @@ int Backup(TCHAR* backup_filename) UpdateWindow(progress_dialog); mir_sntprintf(source_file, MAX_PATH, _T("%s\\%s"), profilePath, dbname); - pathtmp = Utils_ReplaceVarsT(source_file); + TCHAR *pathtmp = Utils_ReplaceVarsT(source_file); if (CopyFile(pathtmp, dest_file, 0)) { SendMessage(progress_dialog, PBM_SETPOS, (WPARAM)(int)(100), 0); @@ -179,9 +175,11 @@ int Backup(TCHAR* backup_filename) DBWriteContactSettingDword(0, "AutoBackups", "LastBackupTimestamp", (DWORD)time(0)); if (!options.disable_popups) { - dest_file_len = lstrlen(dest_file); + size_t dest_file_len = lstrlen(dest_file); + TCHAR *puText; if(dest_file_len > 50) { + int i; puText = (TCHAR*)mir_alloc(sizeof(TCHAR) * (dest_file_len + 2)); for(i = (int)dest_file_len - 1; dest_file[i] != _T('\\'); i--); @@ -204,8 +202,10 @@ int Backup(TCHAR* backup_filename) return 0; } -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); +VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + time_t t = time(NULL); + time_t 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 )))) mir_forkthread(BackupThread, NULL); } @@ -215,7 +215,7 @@ int SetBackupTimer(void) if(options.backup_types & BT_PERIODIC) { if(timer_id == 0) - timer_id = SetTimer(0, 0, 1000 * 60, TimerProc); + timer_id = SetTimer(0, timer_id, 1000 * 60, TimerProc); } else if(timer_id != 0) { diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index e494f0a5d9..aba289b59d 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -4,8 +4,8 @@ HINSTANCE hInst; +TCHAR *profilePath; int hLangpack; -TCHAR* profilePath; HANDLE hFolder; HANDLE hHooks[4]; @@ -20,10 +20,7 @@ PLUGININFOEX pluginInfo={ "chaos.persei@gmail.com", __COPYRIGHTS, "http://miranda-ng.org/", - UNICODE_AWARE, //doesn't replace anything built-in - // Generate your own unique id for your plugin. - // Do not use this UUID! - // Use uuidgen.exe to generate the uuuid + UNICODE_AWARE, // {81C220A6-0226-4ad6-BFCA-217B17A16053} { 0x81c220a6, 0x226, 0x4ad6, { 0xbf, 0xca, 0x21, 0x7b, 0x17, 0xa1, 0x60, 0x53 } } }; @@ -107,7 +104,8 @@ static int ModulesLoad(WPARAM wParam, LPARAM lParam) // can't do this on unload, since other plugins will be have already been unloaded, but their hooks // for setting changed event not cleared. the backup on exit function will write to the db, calling those hooks. -int PreShutdown(WPARAM wParam, LPARAM lParam) { +int PreShutdown(WPARAM wParam, LPARAM lParam) +{ if(options.backup_types & BT_EXIT) { options.disable_popups = 1; // Don't try to show popups on exit @@ -131,7 +129,7 @@ void SysInit() BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) { - hInst=hinstDLL; + hInst = hinstDLL; return TRUE; } @@ -149,16 +147,14 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void) { - int i; - OleUninitialize(); - for (i=0; i= 2 && tmp[1] == ':') _tcsncpy(options.folder, dbv.ptszVal, MAX_PATH-1); @@ -35,10 +33,9 @@ int LoadOptions(void) { return 0; } -int SaveOptions(void) { +int SaveOptions(void) +{ TCHAR prof_dir[MAX_PATH]; - TCHAR* buf,* tmp; - size_t prof_len, opt_len; DBWriteContactSettingByte(0, "AutoBackups", "BackupType", (BYTE)options.backup_types); if (options.period < 1) options.period = 1; @@ -46,18 +43,18 @@ int SaveOptions(void) { DBWriteContactSettingByte(0, "AutoBackups", "PeriodType", (BYTE)options.period_type); mir_sntprintf(prof_dir, MAX_PATH, _T("%s\\"), profilePath); - prof_len = _tcslen(prof_dir); - opt_len = _tcslen(options.folder); + size_t prof_len = _tcslen(prof_dir); + size_t opt_len = _tcslen(options.folder); if(opt_len > prof_len && _tcsncmp(options.folder, prof_dir, prof_len) == 0) { DBWriteContactSettingTString(0, "AutoBackups", "Folder", (options.folder + prof_len)); } else DBWriteContactSettingTString(0, "AutoBackups", "Folder", options.folder); - tmp = Utils_ReplaceVarsT(options.folder); + TCHAR *tmp = Utils_ReplaceVarsT(options.folder); if(_tcslen(tmp) < 2 || tmp[1] != ':') { - buf = mir_tstrdup(options.folder); + TCHAR *buf = mir_tstrdup(options.folder); mir_sntprintf(options.folder, MAX_PATH, _T("%s\\%s"), profilePath, buf); mir_free(buf); } @@ -72,7 +69,8 @@ int SaveOptions(void) { Options new_options; -int SetDlgState(HWND hwndDlg) { +int SetDlgState(HWND hwndDlg) +{ TCHAR buff[10]; if(new_options.backup_types == BT_DISABLED) { @@ -123,13 +121,12 @@ int SetDlgState(HWND hwndDlg) { return 0; } -int CALLBACK BrowseProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData ) +int CALLBACK BrowseProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData) { - TCHAR* folder; switch(uMsg) { case BFFM_INITIALIZED: - folder = Utils_ReplaceVarsT(options.folder); + TCHAR *folder = Utils_ReplaceVarsT(options.folder); SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)folder); mir_free(folder); break; @@ -139,17 +136,12 @@ int CALLBACK BrowseProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData ) INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - TCHAR buff[10]; - TCHAR folder_buff[MAX_PATH] = {0}, backupfolder[MAX_PATH] = {0}; - TCHAR tszTooltipText[1024]; - TCHAR* tmp; - BROWSEINFO bi; - LPCITEMIDLIST pidl; - OPENOPTIONSDIALOG ood = {0}; - - switch ( msg ) { + TCHAR folder_buff[MAX_PATH] = {0}; + HWND hPathTip = NULL; + + switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault( hwndDlg ); + TranslateDialogDefault(hwndDlg); memcpy(&new_options, &options, sizeof(Options)); if (ServiceExists(MS_FOLDERS_GET_PATH)) @@ -160,6 +152,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP } else { + TCHAR tszTooltipText[1024]; mir_sntprintf(tszTooltipText, SIZEOF(tszTooltipText), _T("%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"), _T("%miranda_path%"), TranslateT("path to root miranda folder"), _T("%miranda_profile%"), TranslateT("path to current miranda profile"), @@ -234,6 +227,10 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case IDC_BUT_BROWSE: + { + BROWSEINFO bi; + LPCITEMIDLIST pidl; + bi.hwndOwner = hwndDlg; bi.pidlRoot = 0; bi.pszDisplayName = folder_buff; @@ -253,8 +250,9 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP CoTaskMemFree((void *)pidl); } break; + } case IDC_BUT_NOW: - Backup(NULL); + mir_forkthread(BackupThread, NULL); break; case IDC_CHK_NOPROG: new_options.disable_progress = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOPROG); @@ -265,12 +263,15 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; case IDC_LNK_FOLDERS: + { + OPENOPTIONSDIALOG ood = {0}; ood.cbSize = sizeof(ood); ood.pszGroup = "Customize"; ood.pszPage = "Folders"; Options_Open(&ood); break; } + } } break; @@ -282,6 +283,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_NOTIFY: if (((LPNMHDR)lParam)->code == PSN_APPLY ) { + TCHAR buff[10]; GetDlgItemText(hwndDlg, IDC_ED_PERIOD, buff, sizeof(buff)); new_options.period = _ttoi(buff); GetDlgItemText(hwndDlg, IDC_ED_NUMBACKUPS, buff, sizeof(buff)); @@ -295,9 +297,10 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP GetDlgItemText(hwndDlg, IDC_ED_FOLDER, folder_buff, MAX_PATH); { + TCHAR backupfolder[MAX_PATH] = {0}; BOOL folder_ok = TRUE; int err = 0; - tmp = Utils_ReplaceVarsT(folder_buff); + TCHAR *tmp = Utils_ReplaceVarsT(folder_buff); if(_tcslen(tmp) >= 2 && tmp[1] == ':') _tcsncpy(backupfolder, tmp, MAX_PATH-1); -- cgit v1.2.3