diff options
author | George Hazan <george.hazan@gmail.com> | 2012-08-04 20:56:21 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-08-04 20:56:21 +0000 |
commit | 6a992c3cc581b000faa5b8615b5b84865b4c31c4 (patch) | |
tree | 119696da78005b6c963f9a506f1e90478ca0c08a | |
parent | eb9c3053eb919108153582909ab80e3b42462994 (diff) |
modeless dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@1360 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/PluginUpdater/src/Common.h | 3 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Events.cpp | 4 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Notifications.cpp | 8 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Scanner.cpp | 28 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 2 |
5 files changed, 27 insertions, 18 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index 8717da0b11..7539b14847 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -116,6 +116,7 @@ extern HANDLE CheckThread; extern MYOPTIONS MyOptions;
extern aPopups PopupsList[POPUPS];
extern HANDLE Timer;
+extern HWND hwndDialog;
VOID InitPopupList();
VOID LoadOptions();
@@ -127,7 +128,7 @@ INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam); INT_PTR EmptyFolder(WPARAM wParam,LPARAM lParam);
INT OnPreShutdown(WPARAM wParam, LPARAM lParam);
INT OptInit(WPARAM wParam, LPARAM lParam);
-VOID DoCheck(INT iFlag, INT iFlag2);
+VOID DoCheck(INT iFlag);
BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal);
VOID ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, INT Number, INT ActType);
VOID DlgDownloadProc(FILEURL *pFileUrl, PopupDataText temp);
diff --git a/plugins/PluginUpdater/src/Events.cpp b/plugins/PluginUpdater/src/Events.cpp index f6998d028b..d2055474d5 100644 --- a/plugins/PluginUpdater/src/Events.cpp +++ b/plugins/PluginUpdater/src/Events.cpp @@ -37,7 +37,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) Hotkey_Register(&hkd);
if (AllowUpdateOnStartup())
- DoCheck(UpdateOnStartup, (int)CheckThread);
+ DoCheck(UpdateOnStartup);
Timer = CreateWaitableTimer(NULL, FALSE, NULL);
InitTimer();
@@ -48,7 +48,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam)
{
Silent = false;
- DoCheck(1, (int)CheckThread);
+ DoCheck(1);
return 0;
}
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp index ab59d5739c..2f88205946 100644 --- a/plugins/PluginUpdater/src/Notifications.cpp +++ b/plugins/PluginUpdater/src/Notifications.cpp @@ -19,6 +19,8 @@ Boston, MA 02111-1307, USA. #include "common.h"
+HWND hwndDialog = NULL;
+
void unzip(const TCHAR* ptszZipFile, TCHAR* ptszDestPath, TCHAR* ptszBackPath);
void PopupAction(HWND hWnd, BYTE action)
@@ -301,6 +303,7 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam switch (message) {
case WM_INITDIALOG:
+ hwndDialog = hDlg;
TranslateDialogDefault( hDlg );
SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
@@ -411,6 +414,11 @@ INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam }
}
break;
+
+ case WM_DESTROY:
+ hwndDialog = NULL;
+ delete (vector<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
+ break;
}
return FALSE;
diff --git a/plugins/PluginUpdater/src/Scanner.cpp b/plugins/PluginUpdater/src/Scanner.cpp index 9aea8b20a0..fd6a035174 100644 --- a/plugins/PluginUpdater/src/Scanner.cpp +++ b/plugins/PluginUpdater/src/Scanner.cpp @@ -36,7 +36,7 @@ static bool Exists(LPCTSTR strName) typedef map<string, string> hashMap;
typedef pair<string, string> hashItem;
-static void ScanFolder(const TCHAR* tszFolder, const TCHAR* tszBaseUrl, hashMap& hashes, vector<FILEINFO>& UpdateFiles)
+static void ScanFolder(const TCHAR* tszFolder, const TCHAR* tszBaseUrl, hashMap& hashes, vector<FILEINFO>* UpdateFiles)
{
TCHAR tszMask[MAX_PATH], tszFileBack[MAX_PATH];
mir_sntprintf(tszMask, SIZEOF(tszMask), _T("%s\\*"), tszFolder);
@@ -102,7 +102,7 @@ static void ScanFolder(const TCHAR* tszFolder, const TCHAR* tszBaseUrl, hashMap& mir_sntprintf(FileInfo.File.tszDiskPath, SIZEOF(FileInfo.File.tszDiskPath), _T("%s\\%s.zip"), tszFileBack, ffd.cFileName);
- UpdateFiles.push_back(FileInfo);
+ UpdateFiles->push_back(FileInfo);
} // end compare versions
}
while (FindNextFile(hFind, &ffd) != 0);
@@ -110,13 +110,16 @@ static void ScanFolder(const TCHAR* tszFolder, const TCHAR* tszBaseUrl, hashMap& FindClose(hFind);
}
+static void __stdcall LaunchDialog(void* param)
+{
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)param);
+}
+
static void CheckUpdates(void *)
{
TCHAR tszBuff[2048] = {0}, /*tszFileInfo[30] = {0},*/ tszTmpIni[MAX_PATH] = {0};
char szKey[64] = {0};
- INT upd_ret;
DBVARIANT dbVar = {0};
- vector<FILEINFO> UpdateFiles;
if (!Exists(tszRoot))
CreateDirectoryTreeT(tszRoot);
@@ -168,27 +171,24 @@ static void CheckUpdates(void *) fclose(fp);
DeleteFile(tszTmpIni);
+ vector<FILEINFO>* UpdateFiles = new vector<FILEINFO>;
TCHAR *dirname = Utils_ReplaceVarsT(_T("%miranda_path%"));
ScanFolder(dirname, tszBaseUrl, hashes, UpdateFiles);
mir_free(dirname);
// Show dialog
- if (UpdateFiles.size() > 0)
- upd_ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_UPDATE), GetDesktopWindow(), DlgUpdate, (LPARAM)&UpdateFiles);
- if (upd_ret == IDCANCEL) {
- CheckThread = NULL;
- return;
+ if (UpdateFiles->size() == 0) {
+ if ( !Silent)
+ ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("No updates found."), 2, 0);
}
-
- if (!UpdateFiles.size() && !Silent)
- ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("No updates found."), 2, 0);
+ else CallFunctionAsync(LaunchDialog, UpdateFiles);
CheckThread = NULL;
}
-void DoCheck(int iFlag, int iFlag2)
+void DoCheck(int iFlag)
{
- if (iFlag2)
+ if (CheckThread || hwndDialog)
ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("Update checking already started!"), 2, 0);
else if (iFlag) {
CheckThread = mir_forkthread(CheckUpdates, 0);
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 70da945507..bbce5de63d 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -212,7 +212,7 @@ LONG PeriodToMilliseconds(const INT period, BYTE& periodMeasure) VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwTimerHighValue)
{
- DoCheck(1, (int)CheckThread);
+ DoCheck(1);
}
VOID InitTimer()
|