diff options
author | George Hazan <ghazan@miranda.im> | 2018-07-18 13:21:23 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-07-18 13:21:23 +0300 |
commit | e94f080dd0e19266003da01583222784c9169fc2 (patch) | |
tree | fd150c01741ebddf719bdef95fd3a622837f902c /plugins | |
parent | adf1f2e587159bb99d820faa983ef3e357d41f40 (diff) |
Weather:
- persistent connection removed due to memory corruption problems;
- warning fixed;
- version bump
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Weather/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/Weather/src/version.h | 2 | ||||
-rw-r--r-- | plugins/Weather/src/weather.cpp | 3 | ||||
-rw-r--r-- | plugins/Weather/src/weather_addstn.cpp | 5 | ||||
-rw-r--r-- | plugins/Weather/src/weather_contacts.cpp | 3 | ||||
-rw-r--r-- | plugins/Weather/src/weather_conv.cpp | 14 | ||||
-rw-r--r-- | plugins/Weather/src/weather_http.cpp | 14 | ||||
-rw-r--r-- | plugins/Weather/src/weather_update.cpp | 2 | ||||
-rw-r--r-- | plugins/Weather/src/weather_userinfo.cpp | 2 |
9 files changed, 10 insertions, 37 deletions
diff --git a/plugins/Weather/src/stdafx.h b/plugins/Weather/src/stdafx.h index a33b89e6d3..74cecbed62 100644 --- a/plugins/Weather/src/stdafx.h +++ b/plugins/Weather/src/stdafx.h @@ -359,7 +359,6 @@ extern unsigned status, old_status; extern MWindowList hDataWindowList, hWindowList;
extern HNETLIBUSER hNetlibUser;
-extern HNETLIBCONN hNetlibHttp;
extern HANDLE hHookWeatherUpdated, hHookWeatherError, hTBButton, hUpdateMutex;
extern UINT_PTR timerId;
@@ -435,7 +434,6 @@ void DBDataManage(MCONTACT hContact, WORD Mode, WPARAM wParam, LPARAM lParam); // functions in weather_http.c
int InternetDownloadFile (char *szUrl, char *cookie, char *userAgent, wchar_t** szData);
void NetlibInit();
-void NetlibHttpDisconnect(void);
// functions in weather_ini.c
WIDATA* GetWIData(wchar_t *pszServ);
diff --git a/plugins/Weather/src/version.h b/plugins/Weather/src/version.h index 6c6e8e3b7d..6985233d72 100644 --- a/plugins/Weather/src/version.h +++ b/plugins/Weather/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
diff --git a/plugins/Weather/src/weather.cpp b/plugins/Weather/src/weather.cpp index 2471557fcb..5ecdb7f4a5 100644 --- a/plugins/Weather/src/weather.cpp +++ b/plugins/Weather/src/weather.cpp @@ -95,8 +95,6 @@ int WeatherShutdown(WPARAM, LPARAM) SaveOptions(); // save options once more
status = ID_STATUS_OFFLINE; // set status to offline
- Netlib_Shutdown(hNetlibHttp);
-
WindowList_Broadcast(hWindowList, WM_CLOSE, 0, 0);
WindowList_Broadcast(hDataWindowList, WM_CLOSE, 0, 0);
SendMessage(hWndSetup, WM_CLOSE, 0, 0);
@@ -219,7 +217,6 @@ int CMPlugin::Unload() DestroyHookableEvent(hHookWeatherUpdated);
DestroyHookableEvent(hHookWeatherError);
- NetlibHttpDisconnect();
Netlib_CloseHandle(hNetlibUser);
DestroyUpdateList();
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index e683f561ac..fdc28202b9 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -280,7 +280,6 @@ int IDSearch(wchar_t *sID, const int searchId) IDSearchProc(sID, searchId, &Item->Data.IDSearch, Item->Data.InternalName, Item->Data.DisplayName);
Item = Item->next;
}
- NetlibHttpDisconnect();
}
// if the station ID is #, return a dummy result and quit the funciton
else {
@@ -411,16 +410,14 @@ int NameSearchProc(wchar_t *name, const int searchId, WINAMESEARCH *sData, wchar // return 0 if no error
int NameSearch(wchar_t *name, const int searchId)
{
- WIDATALIST *Item = WIHead;
-
// search every weather service using the search station name
+ WIDATALIST *Item = WIHead;
while (Item != nullptr) {
if (Item->Data.NameSearch.Single.Available || Item->Data.NameSearch.Multiple.Available)
NameSearchProc(name, searchId, &Item->Data.NameSearch, Item->Data.InternalName, Item->Data.DisplayName);
Item = Item->next;
}
- NetlibHttpDisconnect();
return 0;
}
diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp index c770ebd5d0..5fdb1d097d 100644 --- a/plugins/Weather/src/weather_contacts.cpp +++ b/plugins/Weather/src/weather_contacts.cpp @@ -247,9 +247,8 @@ static INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPA }
// free memory
mir_free(pData);
-
- NetlibHttpDisconnect();
}
+
// give no station name but only ID if the search is unavailable
if (str[0] != 0)
SetDlgItemText(hwndDlg, IDC_NAME, str);
diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp index 88822b98bc..c58751a072 100644 --- a/plugins/Weather/src/weather_conv.cpp +++ b/plugins/Weather/src/weather_conv.cpp @@ -407,17 +407,15 @@ WORD GetIcon(const wchar_t* cond, WIDATA *Data) // this function convert the string to the format with 1 upper case followed by lower case char
void CaseConv(wchar_t *str)
{
- BOOL nextUp = TRUE;
+ bool nextUp = true;
- CharLowerBuff(str, (DWORD)mir_wstrlen(str));
+ CharLowerBuffW(str, (DWORD)mir_wstrlen(str));
for (wchar_t *pstr = str; *pstr; pstr++) {
if (*pstr == ' ' || *pstr == '-')
- nextUp = TRUE;
- else {
- wchar_t ch = *pstr;
- if (nextUp)
- *pstr = (wchar_t)CharUpper((LPTSTR)ch);
- nextUp = FALSE;
+ nextUp = true;
+ else if (nextUp) {
+ CharUpperBuffW(pstr, 1);
+ nextUp = false;
}
}
}
diff --git a/plugins/Weather/src/weather_http.cpp b/plugins/Weather/src/weather_http.cpp index 63ea78b03a..10bcf63690 100644 --- a/plugins/Weather/src/weather_http.cpp +++ b/plugins/Weather/src/weather_http.cpp @@ -26,7 +26,6 @@ from the web using netlib #include "stdafx.h"
HNETLIBUSER hNetlibUser;
-HNETLIBCONN hNetlibHttp;
static int findHeader(const NETLIBHTTPREQUEST *nlhrReply, const char *hdr)
{
@@ -67,7 +66,6 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s nlhr.requestType = REQUEST_GET;
nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT;
nlhr.szUrl = szUrl;
- nlhr.nlc = hNetlibHttp;
nlhr.headers = headers;
nlhr.headersCount = _countof(headers);
@@ -81,7 +79,6 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s *szData = (wchar_t*)mir_alloc(512);
// store the error code in szData
mir_wstrcpy(*szData, L"NetLib error occurred!!");
- hNetlibHttp = nullptr;
return NLHRF_REDIRECT;
}
@@ -142,7 +139,6 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s result = nlhrReply->resultCode;
}
- hNetlibHttp = nlhrReply->nlc;
// make a copy of the retrieved data, then free the memory of the http reply
Netlib_FreeHttpRequest(nlhrReply);
return result;
@@ -159,13 +155,3 @@ void NetlibInit(void) nlu.szDescriptiveName.w = TranslateT("Weather HTTP connections");
hNetlibUser = Netlib_RegisterUser(&nlu);
}
-
-void NetlibHttpDisconnect(void)
-{
- if (hNetlibHttp) {
- HANDLE hConn = hNetlibHttp;
- hNetlibHttp = nullptr;
- Netlib_CloseHandle(hConn);
- }
-}
-
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index d5540d041c..3b616388f2 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -293,8 +293,6 @@ static void UpdateThreadProc(void *) while (UpdateListHead != nullptr && !Miranda_IsTerminated())
UpdateWeather(UpdateGetFirst());
- NetlibHttpDisconnect();
-
// exit the update thread
ThreadRunning = FALSE;
}
diff --git a/plugins/Weather/src/weather_userinfo.cpp b/plugins/Weather/src/weather_userinfo.cpp index b535e6cfa8..90d3b8d4ae 100644 --- a/plugins/Weather/src/weather_userinfo.cpp +++ b/plugins/Weather/src/weather_userinfo.cpp @@ -210,7 +210,7 @@ static INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, L case WM_LBUTTONUP:
TEXTRANGE tr;
tr.chrg = enlink->chrg;
- tr.lpstrText = (LPTSTR)mir_alloc(sizeof(wchar_t)*(tr.chrg.cpMax - tr.chrg.cpMin + 8));
+ tr.lpstrText = (wchar_t*)mir_alloc(sizeof(wchar_t)*(tr.chrg.cpMax - tr.chrg.cpMin + 8));
SendMessage(pNmhdr->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
Utils_OpenUrlW(tr.lpstrText);
mir_free(tr.lpstrText);
|