summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-06-12 18:22:25 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-06-12 18:22:25 +0000
commit21ecc48547be0920eed6ce45d5948c3b7d0d7581 (patch)
tree4d759e1fb665f720df1de93f007358635b8e870c /plugins
parentb1a0d9c8ddd50cb9c3abe6aa4c0a3be2f5469063 (diff)
PluginUpdater:
- minor cleanup - compilation fix for IM Updater git-svn-id: http://svn.miranda-ng.org/main/trunk@14134 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/PluginUpdater/src/Common.h4
-rw-r--r--plugins/PluginUpdater/src/Compat/compat.h28
-rw-r--r--plugins/PluginUpdater/src/Options.cpp61
-rw-r--r--plugins/PluginUpdater/src/PluginUpdater.cpp2
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp67
5 files changed, 95 insertions, 67 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h
index dd5291294f..7834bdcb3b 100644
--- a/plugins/PluginUpdater/src/Common.h
+++ b/plugins/PluginUpdater/src/Common.h
@@ -87,7 +87,7 @@ typedef OBJLIST<FILEINFO> FILELIST;
extern struct PlugOptions
{
BYTE bUpdateOnStartup, bUpdateOnPeriod, bOnlyOnceADay, bForceRedownload, bSilentMode;
- BOOL bSilent, bDlgDld;
+ BOOL bSilent;
BYTE bPeriodMeasure;
int Period;
@@ -134,6 +134,7 @@ using namespace std;
extern HINSTANCE hInst;
+extern DWORD g_mirandaVersion;
extern TCHAR tszRoot[MAX_PATH], tszTempPath[MAX_PATH];
extern aPopups PopupsList[POPUPS];
extern HANDLE hPipe, hNetlibUser;
@@ -204,7 +205,6 @@ 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/Compat/compat.h b/plugins/PluginUpdater/src/Compat/compat.h
index fe68dfdcf0..fe05af3f60 100644
--- a/plugins/PluginUpdater/src/Compat/compat.h
+++ b/plugins/PluginUpdater/src/Compat/compat.h
@@ -148,3 +148,31 @@ __forceinline INT_PTR CreateDirectoryTreeT(const TCHAR *ptszPath)
#define _qtoupper(_c) (((_c) >= 'a' && (_c) <= 'z')?((_c)-('a'+'A')):(_c))
+
+template <size_t _Size>
+inline int mir_snprintf(char(&buffer)[_Size], const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ return mir_vsnprintf(buffer, _Size, fmt, args);
+}
+
+template <size_t _Size>
+inline int mir_snwprintf(wchar_t(&buffer)[_Size], const wchar_t* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ return mir_vsnwprintf(buffer, _Size, fmt, args);
+}
+
+template <size_t _Size>
+inline int mir_vsnprintf(char(&buffer)[_Size], const char* fmt, va_list va)
+{
+ return mir_vsnprintf(buffer, _Size, fmt, va);
+}
+
+template <size_t _Size>
+inline int mir_vsnwprintf(wchar_t(&buffer)[_Size], const wchar_t* fmt, va_list va)
+{
+ return mir_vsnwprintf(buffer, _Size, fmt, va);
+}
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp
index 4721a71e40..e8ae139ce7 100644
--- a/plugins/PluginUpdater/src/Options.cpp
+++ b/plugins/PluginUpdater/src/Options.cpp
@@ -19,6 +19,67 @@ Boston, MA 02111-1307, USA.
#include "common.h"
+PlugOptions opts;
+POPUP_OPTIONS PopupOptions = {0};
+
+void LoadOptions()
+{
+ PopupOptions.DefColors = db_get_b(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
+ PopupOptions.LeftClickAction= db_get_b(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
+ PopupOptions.RightClickAction = db_get_b(NULL, MODNAME, "RightClickAction", DEFAULT_POPUP_RCLICK);
+ PopupOptions.Timeout = db_get_dw(NULL, MODNAME, "Timeout", DEFAULT_TIMEOUT_VALUE);
+
+ opts.bUpdateOnStartup = db_get_b(NULL, MODNAME, "UpdateOnStartup", DEFAULT_UPDATEONSTARTUP);
+ opts.bOnlyOnceADay = db_get_b(NULL, MODNAME, "OnlyOnceADay", DEFAULT_ONLYONCEADAY);
+ opts.bUpdateOnPeriod = db_get_b(NULL, MODNAME, "UpdateOnPeriod", DEFAULT_UPDATEONPERIOD);
+ opts.Period = db_get_dw(NULL, MODNAME, "Period", DEFAULT_PERIOD);
+ opts.bPeriodMeasure = db_get_b(NULL, MODNAME, "PeriodMeasure", DEFAULT_PERIODMEASURE);
+ opts.bForceRedownload = db_get_b(NULL, MODNAME, DB_SETTING_REDOWNLOAD, 0);
+ opts.bSilentMode = db_get_b(NULL, MODNAME, "SilentMode", 0);
+}
+
+int GetUpdateMode()
+{
+ int UpdateMode = db_get_b(NULL, MODNAME, DB_SETTING_UPDATE_MODE, -1);
+
+ // Check if there is url for custom mode
+ if (UpdateMode == UPDATE_MODE_CUSTOM) {
+ ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL));
+ if (url == NULL || !_tcslen(url)) {
+ // No url for custom mode, reset that setting so it will be determined automatically
+ db_unset(NULL, MODNAME, DB_SETTING_UPDATE_MODE);
+ UpdateMode = -1;
+ }
+ }
+
+ if (UpdateMode < 0 || UpdateMode > UPDATE_MODE_MAX_VALUE) {
+ // Missing or unknown mode, determine correct from version of running core
+ char coreVersion[512];
+ CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)SIZEOF(coreVersion), (LPARAM)coreVersion);
+ UpdateMode = (strstr(coreVersion, "alpha") == NULL) ? UPDATE_MODE_STABLE : UPDATE_MODE_TRUNK;
+ }
+
+ return UpdateMode;
+}
+
+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));
+ default:
+ return db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL);
+ }
+#endif
+}
+
INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp
index 900c9bd34e..86e476bd05 100644
--- a/plugins/PluginUpdater/src/PluginUpdater.cpp
+++ b/plugins/PluginUpdater/src/PluginUpdater.cpp
@@ -19,8 +19,6 @@ Boston, MA 02111-1307, USA.
#include "common.h"
-PlugOptions opts;
-
HINSTANCE hInst = NULL;
TCHAR tszRoot[MAX_PATH] = {0}, tszTempPath[MAX_PATH];
int hLangpack;
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index ac05ae7844..d5f03c8076 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -20,8 +20,6 @@ Boston, MA 02111-1307, USA.
#include "Common.h"
HANDLE hNetlibUser = NULL, hPipe = NULL;
-POPUP_OPTIONS PopupOptions = {0};
-extern DWORD g_mirandaVersion;
/////////////////////////////////////////////////////////////////////////////////////
#if MIRANDA_VER >= 0x0A00
@@ -54,22 +52,6 @@ void UnloadNetlib()
hNetlibUser = NULL;
}
-void LoadOptions()
-{
- PopupOptions.DefColors = db_get_b(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
- PopupOptions.LeftClickAction= db_get_b(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
- PopupOptions.RightClickAction = db_get_b(NULL, MODNAME, "RightClickAction", DEFAULT_POPUP_RCLICK);
- PopupOptions.Timeout = db_get_dw(NULL, MODNAME, "Timeout", DEFAULT_TIMEOUT_VALUE);
-
- opts.bUpdateOnStartup = db_get_b(NULL, MODNAME, "UpdateOnStartup", DEFAULT_UPDATEONSTARTUP);
- opts.bOnlyOnceADay = db_get_b(NULL, MODNAME, "OnlyOnceADay", DEFAULT_ONLYONCEADAY);
- opts.bUpdateOnPeriod = db_get_b(NULL, MODNAME, "UpdateOnPeriod", DEFAULT_UPDATEONPERIOD);
- opts.Period = db_get_dw(NULL, MODNAME, "Period", DEFAULT_PERIOD);
- opts.bPeriodMeasure = db_get_b(NULL, MODNAME, "PeriodMeasure", DEFAULT_PERIODMEASURE);
- opts.bForceRedownload = db_get_b(NULL, MODNAME, DB_SETTING_REDOWNLOAD, 0);
- opts.bSilentMode = db_get_b(NULL, MODNAME, "SilentMode", 0);
-}
-
ULONG crc32_table[256];
ULONG ulPolynomial = 0x04c11db7;
@@ -123,48 +105,6 @@ int Get_CRC(unsigned char* buffer, ULONG bufsize)
return crc^0xffffffff;
}
-int GetUpdateMode()
-{
- int UpdateMode = db_get_b(NULL, MODNAME, DB_SETTING_UPDATE_MODE, -1);
-
- // Check if there is url for custom mode
- if (UpdateMode == UPDATE_MODE_CUSTOM) {
- ptrT url(db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL));
- if (url == NULL || !_tcslen(url)) {
- // No url for custom mode, reset that setting so it will be determined automatically
- db_unset(NULL, MODNAME, DB_SETTING_UPDATE_MODE);
- UpdateMode = -1;
- }
- }
-
- if (UpdateMode < 0 || UpdateMode > UPDATE_MODE_MAX_VALUE) {
- // Missing or unknown mode, determine correct from version of running core
- char coreVersion[512];
- CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)SIZEOF(coreVersion), (LPARAM)coreVersion);
- UpdateMode = (strstr(coreVersion, "alpha") == NULL) ? UPDATE_MODE_STABLE : UPDATE_MODE_TRUNK;
- }
-
- return UpdateMode;
-}
-
-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));
- default:
- return db_get_tsa(NULL, MODNAME, DB_SETTING_UPDATE_URL);
- }
-#endif
-}
-
int CompareHashes(const ServListEntry *p1, const ServListEntry *p2)
{
return _tcsicmp(p1->m_name, p2->m_name);
@@ -270,13 +210,14 @@ bool DownloadFile(FILEURL *pFileURL, HANDLE &nlc)
NETLIBHTTPREQUEST nlhr = {0};
#if MIRANDA_VER < 0x0A00
nlhr.cbSize = NETLIBHTTPREQUEST_V1_SIZE;
+ nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
+ if (g_mirandaVersion >= PLUGIN_MAKE_VERSION(0, 9, 0, 0))
+ nlhr.flags |= NLHRF_PERSISTENT;
#else
nlhr.cbSize = sizeof(nlhr);
+ nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_PERSISTENT;
#endif
nlhr.requestType = REQUEST_GET;
- nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
- if (g_mirandaVersion >= PLUGIN_MAKE_VERSION(0, 9, 0, 0))
- nlhr.flags |= NLHRF_PERSISTENT;
nlhr.nlc = nlc;
char *szUrl = mir_t2a(pFileURL->tszDownloadURL);
nlhr.szUrl = szUrl;