summaryrefslogtreecommitdiff
path: root/plugins/PluginUpdater
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-06-19 20:47:23 +0000
committerRobert Pösel <robyer@seznam.cz>2013-06-19 20:47:23 +0000
commitee88b0130e900c5f9f957b18f5db86800d7707c7 (patch)
treee9cb765df91eb9981822bf35c98f7462b6d9ea0f /plugins/PluginUpdater
parenta33760bd3aea841b60e23909405e78b00b19ae79 (diff)
PluginUpdater: Use persistent http connection. Version bump.
git-svn-id: http://svn.miranda-ng.org/main/trunk@5049 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/PluginUpdater')
-rw-r--r--plugins/PluginUpdater/src/Common.h2
-rw-r--r--plugins/PluginUpdater/src/DlgListNew.cpp4
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp4
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp15
-rw-r--r--plugins/PluginUpdater/src/Version.h2
5 files changed, 20 insertions, 7 deletions
diff --git a/plugins/PluginUpdater/src/Common.h b/plugins/PluginUpdater/src/Common.h
index 7bdcd8e871..5628960b8c 100644
--- a/plugins/PluginUpdater/src/Common.h
+++ b/plugins/PluginUpdater/src/Common.h
@@ -173,7 +173,7 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT &baseUrl, SERVLIST &arHashes);
int CompareHashes(const ServListEntry *p1, const ServListEntry *p2);
TCHAR* GetDefaultUrl();
-BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum);
+BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum, HANDLE &nlc);
void ShowPopup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType);
void __stdcall RestartMe(void*);
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp
index 0561b4cf60..3e37dbecaf 100644
--- a/plugins/PluginUpdater/src/DlgListNew.cpp
+++ b/plugins/PluginUpdater/src/DlgListNew.cpp
@@ -55,6 +55,7 @@ static void ApplyDownloads(void *param)
mir_sntprintf(tszFileTemp, SIZEOF(tszFileTemp), _T("%s\\Temp"), tszRoot);
SafeCreateDirectory(tszFileTemp);
+ HANDLE nlc = NULL;
for (int i=0; i < todo.getCount(); ++i) {
ListView_EnsureVisible(hwndList, i, FALSE);
if ( !todo[i].bEnabled) {
@@ -66,12 +67,13 @@ static void ApplyDownloads(void *param)
ListView_SetItemText(hwndList, i, 2, TranslateT("Downloading..."));
FILEURL *pFileUrl = &todo[i].File;
- if ( !DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath, pFileUrl->CRCsum)){
+ if ( !DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath, pFileUrl->CRCsum, nlc)){
ListView_SetItemText(hwndList, i, 2, TranslateT("Failed!"));
}
else
ListView_SetItemText(hwndList, i, 2, TranslateT("Succeeded."));
}
+ Netlib_CloseHandle(nlc);
if (todo.getCount() > 0) {
ShowPopup(0, LPGENT("Plugin Updater"), TranslateT("Download complete"), 2, 0);
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index e59ca433e8..9c957d0f90 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -62,6 +62,7 @@ static void ApplyUpdates(void *param)
mir_sntprintf(tszFileTemp, SIZEOF(tszFileTemp), _T("%s\\Temp"), tszRoot);
SafeCreateDirectory(tszFileTemp);
+ HANDLE nlc = NULL;
for (int i=0; i < todo.getCount(); ++i) {
ListView_EnsureVisible(hwndList, i, FALSE);
if ( !todo[i].bEnabled) {
@@ -77,11 +78,12 @@ static void ApplyUpdates(void *param)
SetStringText(hwndList, i, TranslateT("Downloading..."));
FILEURL *pFileUrl = &todo[i].File;
- if ( !DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath, pFileUrl->CRCsum))
+ if ( !DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath, pFileUrl->CRCsum, nlc))
SetStringText(hwndList, i, TranslateT("Failed!"));
else
SetStringText(hwndList, i, TranslateT("Succeeded."));
}
+ Netlib_CloseHandle(nlc);
if (todo.getCount() == 0) {
LBL_Exit:
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index fb499aa860..0de79f2b10 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -214,7 +214,12 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
FILEURL pFileUrl;
mir_sntprintf(pFileUrl.tszDownloadURL, SIZEOF(pFileUrl.tszDownloadURL), _T("%s/hashes.zip"), baseUrl);
mir_sntprintf(pFileUrl.tszDiskPath, SIZEOF(pFileUrl.tszDiskPath), _T("%s\\hashes.zip"), tszTempPath);
- if (!DownloadFile(pFileUrl.tszDownloadURL, pFileUrl.tszDiskPath, 0)) {
+
+ HANDLE nlc;
+ BOOL ret = DownloadFile(pFileUrl.tszDownloadURL, pFileUrl.tszDiskPath, 0, nlc);
+ Netlib_CloseHandle(nlc);
+
+ if (!ret) {
ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("An error occured while downloading the update."), 1, 0);
return false;
}
@@ -257,7 +262,7 @@ bool ParseHashes(const TCHAR *ptszUrl, ptrT& baseUrl, SERVLIST& arHashes)
}
-BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum)
+BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum, HANDLE &nlc)
{
DWORD dwBytes;
@@ -268,7 +273,8 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum)
nlhr.cbSize = sizeof(nlhr);
#endif
nlhr.requestType = REQUEST_GET;
- nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
+ nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_PERSISTENT;
+ nlhr.nlc = nlc;
char *szUrl = mir_t2a(tszURL);
nlhr.szUrl = szUrl;
nlhr.headersCount = 4;
@@ -285,6 +291,7 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum)
bool ret = false;
NETLIBHTTPREQUEST *pReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser,(LPARAM)&nlhr);
if (pReply) {
+ nlc = pReply->nlc;
if ((200 == pReply->resultCode) && (pReply->dataLength > 0)) {
HANDLE hFile = CreateFile(tszLocal, GENERIC_READ | GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
@@ -319,6 +326,8 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal, int CRCsum)
}
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pReply);
+ } else {
+ nlc = NULL;
}
mir_free(szUrl);
diff --git a/plugins/PluginUpdater/src/Version.h b/plugins/PluginUpdater/src/Version.h
index 2ad5fb4242..f6ed8685b4 100644
--- a/plugins/PluginUpdater/src/Version.h
+++ b/plugins/PluginUpdater/src/Version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 1
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM