summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/PluginUpdater/src/Common.h1
-rw-r--r--plugins/PluginUpdater/src/Options.cpp23
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp38
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
}