diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-09-07 12:36:33 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-09-07 12:36:33 +0000 |
commit | d267c7e3f3462693a6264029308e239de115eda5 (patch) | |
tree | 0a7978b5492a4bdba2ddac775a5b399ac03cfd1f /plugins/PluginUpdater | |
parent | 3306ec22ce0c8c8c973371910028f1456424aec0 (diff) |
PluginUpdater: Final fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@10392 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r-- | plugins/PluginUpdater/src/Common.h | 1 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Options.cpp | 23 | ||||
-rw-r--r-- | plugins/PluginUpdater/src/Utils.cpp | 38 |
3 files changed, 28 insertions, 34 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h index 3c7bd6d7c4..0daf395231 100644 --- a/plugins/PluginUpdater/src/Common.h +++ b/plugins/PluginUpdater/src/Common.h @@ -207,6 +207,7 @@ void BackupFile(TCHAR *ptszSrcFileName, TCHAR *ptszBackFileName); bool ParseHashes(const TCHAR *ptszUrl, ptrT &baseUrl, SERVLIST &arHashes);
int CompareHashes(const ServListEntry *p1, const ServListEntry *p2);
+int GetUpdateMode();
TCHAR* GetDefaultUrl();
bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc);
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp index aa59496ac0..cd199df741 100644 --- a/plugins/PluginUpdater/src/Options.cpp +++ b/plugins/PluginUpdater/src/Options.cpp @@ -45,7 +45,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), 1, TranslateT("days"));
ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PERIODMEASURE), opts.bPeriodMeasure);
- BYTE UpdateMode = db_get_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_STABLE);
+ int UpdateMode = GetUpdateMode();
if (UpdateMode == UPDATE_MODE_STABLE) {
SetDlgItemText(hwndDlg, IDC_CUSTOMURL, _T(DEFAULT_UPDATE_URL));
CheckDlgButton(hwndDlg, IDC_STABLE, TRUE);
@@ -61,13 +61,9 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA else {
CheckDlgButton(hwndDlg, IDC_CUSTOM, TRUE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
- DBVARIANT dbv;
- if (!db_get_s(NULL, MODNAME, "UpdateURL", &dbv)) {
- SetDlgItemTextA(hwndDlg, IDC_CUSTOMURL, dbv.pszVal);
- db_free(&dbv);
- }
- else
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, ptrT(GetDefaultUrl()));
+
+ ptrT url(db_get_tsa(NULL, MODNAME, "UpdateURL"));
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, (url == NULL) ? ptrT(GetDefaultUrl()) : url);
}
}
return TRUE;
@@ -110,13 +106,8 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case IDC_CUSTOM:
EnableWindow(GetDlgItem(hwndDlg, IDC_CUSTOMURL), TRUE);
{
- DBVARIANT dbv;
- if (!db_get_ts(NULL, MODNAME, "UpdateURL", &dbv)) {
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, dbv.ptszVal);
- db_free(&dbv);
- }
- else
- SetDlgItemText(hwndDlg, IDC_CUSTOMURL, ptrT(GetDefaultUrl()));
+ ptrT url(db_get_tsa(NULL, MODNAME, "UpdateURL"));
+ SetDlgItemText(hwndDlg, IDC_CUSTOMURL, (url == NULL) ? ptrT(GetDefaultUrl()) : url);
}
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -181,7 +172,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK))
db_set_b(NULL, MODNAME, "UpdateMode", UPDATE_MODE_TRUNK);
else if ( IsDlgButtonChecked(hwndDlg, IDC_TRUNK_SYMBOLS)) {
- BYTE oldMode = db_get_b(NULL, MODNAME, "UpdateMode",0);
+ int oldMode = GetUpdateMode();
if(oldMode != UPDATE_MODE_TRUNK_SYMBOLS) {
opts.bForceRedownload = true;
db_set_b(NULL, MODNAME, "ForceRedownload", 1);
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 2ee3402a76..24832935cc 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -142,19 +142,14 @@ int Get_CRC(unsigned char* buffer, ULONG bufsize) return crc^0xffffffff;
}
-TCHAR* GetDefaultUrl()
+int GetUpdateMode()
{
-#if MIRANDA_VER < 0x0A00
- return mir_tstrdup(_T("http://miranda-ng.org/distr/deprecated/0.94.9/x%platform%"));
-#else
int UpdateMode = db_get_b(NULL, MODNAME, "UpdateMode", -1);
- TCHAR *url = NULL;
-
// Check if there is url for custom mode
if (UpdateMode == UPDATE_MODE_CUSTOM) {
- url = db_get_tsa(NULL, MODNAME, "UpdateUrl");
- if (url == NULL) {
+ ptrT url( db_get_tsa(NULL, MODNAME, "UpdateUrl"));
+ if (url == NULL || !_tcslen(url)) {
// No url for custom mode, reset that setting so it will be determined automatically
db_unset(NULL, MODNAME, "UpdateMode");
UpdateMode = -1;
@@ -168,17 +163,24 @@ TCHAR* GetDefaultUrl() UpdateMode = (strstr(coreVersion, "alpha") == NULL) ? UPDATE_MODE_STABLE : UPDATE_MODE_TRUNK;
}
- if (UpdateMode == UPDATE_MODE_STABLE) {
- url = mir_tstrdup(_T(DEFAULT_UPDATE_URL));
- } else if (UpdateMode == UPDATE_MODE_TRUNK) {
- url = mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK));
- } else if (UpdateMode == UPDATE_MODE_TRUNK_SYMBOLS) {
- url = mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS));
- } else if (UpdateMode == UPDATE_MODE_CUSTOM) {
- // url was loaded in the beginning, no need to load it again
- }
+ return UpdateMode;
+}
- return url;
+TCHAR* GetDefaultUrl()
+{
+#if MIRANDA_VER < 0x0A00
+ return mir_tstrdup(_T("http://miranda-ng.org/distr/deprecated/0.94.9/x%platform%"));
+#else
+ switch (GetUpdateMode()) {
+ case UPDATE_MODE_STABLE:
+ return mir_tstrdup(_T(DEFAULT_UPDATE_URL));
+ case UPDATE_MODE_TRUNK:
+ return mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK));
+ case UPDATE_MODE_TRUNK_SYMBOLS:
+ return mir_tstrdup(_T(DEFAULT_UPDATE_URL_TRUNK_SYMBOLS));
+ case UPDATE_MODE_CUSTOM:
+ return db_get_tsa(NULL, MODNAME, "UpdateUrl");
+ }
#endif
}
|