diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2012-08-23 09:59:01 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2012-08-23 09:59:01 +0000 |
commit | 38fd059aded00e4ed846bf35779f4bbcf7133f0d (patch) | |
tree | 83880b3180d28767450e760ded72153f1aaa99fa /protocols | |
parent | 30d46fcb06781d1277483208488596daab65d09a (diff) |
*fix for logging UTF8 events
*fix for unicode logging
*fix for unicode templates
*removed support for old Miranda
git-svn-id: http://svn.miranda-ng.org/main/trunk@1524 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Weather/weather.h | 18 | ||||
-rw-r--r-- | protocols/Weather/weather_http.cpp | 13 | ||||
-rw-r--r-- | protocols/Weather/weather_opt.cpp | 42 | ||||
-rw-r--r-- | protocols/Weather/weather_update.cpp | 22 | ||||
-rw-r--r-- | protocols/Weather/weather_userinfo.cpp | 4 |
5 files changed, 45 insertions, 54 deletions
diff --git a/protocols/Weather/weather.h b/protocols/Weather/weather.h index eae087fcb1..400d5e6778 100644 --- a/protocols/Weather/weather.h +++ b/protocols/Weather/weather.h @@ -157,16 +157,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // 505 HTTP Version Not Supported
// defaults constants
-#define C_DEFAULT "%n [%t, %c]"
-#define N_DEFAULT "%c\nTemperature: %t\nFeel-Like: %f\nPressure: %p\nWind: %i %w\nHumidity: %m\nDew Point: %e\nVisibility: %v\n\nSun Rise: %r\nSun Set: %y\n\n5 Days Forecast:\n%[Forecast Day 1]\n%[Forecast Day 2]\n%[Forecast Day 3]\n%[Forecast Day 4]\n%[Forecast Day 5]"
-#define B_DEFAULT "Feel-Like: %f\nPressure: %p\nWind: %i %w\nHumidity: %m\nDew Point: %e\nVisibility: %v\n\nSun Rise: %r\nSun Set: %y\n\n5 Days Forecast:\n%[Forecast Day 1]\n%[Forecast Day 2]\n%[Forecast Day 3]\n%[Forecast Day 4]\n%[Forecast Day 5]"
-#define b_DEFAULT "Weather Condition for %n as of %u"
+#define C_DEFAULT TranslateT("%n [%t, %c]")
+#define N_DEFAULT TranslateT("%c\nTemperature: %t\nFeel-Like: %f\nPressure: %p\nWind: %i %w\nHumidity: %m\nDew Point: %e\nVisibility: %v\n\nSun Rise: %r\nSun Set: %y\n\n5 Days Forecast:\n%[Forecast Day 1]\n%[Forecast Day 2]\n%[Forecast Day 3]\n%[Forecast Day 4]\n%[Forecast Day 5]")
+#define B_DEFAULT TranslateT("Feel-Like: %f\nPressure: %p\nWind: %i %w\nHumidity: %m\nDew Point: %e\nVisibility: %v\n\nSun Rise: %r\nSun Set: %y\n\n5 Days Forecast:\n%[Forecast Day 1]\n%[Forecast Day 2]\n%[Forecast Day 3]\n%[Forecast Day 4]\n%[Forecast Day 5]")
+#define b_DEFAULT TranslateT("Weather Condition for %n as of %u")
#define X_DEFAULT N_DEFAULT
-#define H_DEFAULT "%c, %t (feel-like %f) Wind: %i %w Humidity: %m"
-#define E_DEFAULT "%n at %u: %c, %t (feel-like %f) Wind: %i %w Humidity: %m"
-#define P_DEFAULT "%n (%u)"
-#define p_DEFAULT "%c, %t\nToday: High %h, Low %l"
-#define s_DEFAULT "Temperature: %[Temperature]"
+#define H_DEFAULT TranslateT("%c, %t (feel-like %f) Wind: %i %w Humidity: %m")
+#define E_DEFAULT TranslateT("%n at %u: %c, %t (feel-like %f) Wind: %i %w Humidity: %m")
+#define P_DEFAULT TranslateT("%n (%u)")
+#define p_DEFAULT TranslateT("%c, %t\nToday: High %h, Low %l")
+#define s_DEFAULT TranslateT("Temperature: %[Temperature]")
//============ OPTION STRUCT ============
diff --git a/protocols/Weather/weather_http.cpp b/protocols/Weather/weather_http.cpp index 2a3796de66..bfeb6fe727 100644 --- a/protocols/Weather/weather_http.cpp +++ b/protocols/Weather/weather_http.cpp @@ -50,19 +50,16 @@ int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData) {
int result = 0xBADBAD;
char* szRedirUrl = NULL;
- NETLIBHTTPREQUEST nlhr = {0}, *nlhrReply;
+ NETLIBHTTPREQUEST nlhr = {0};
NETLIBHTTPHEADER headers[6];
// initialize the netlib request
nlhr.cbSize = sizeof(nlhr);
nlhr.requestType = REQUEST_GET;
- nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
+ nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT;
nlhr.szUrl = szUrl;
nlhr.nlc = hNetlibHttp;
- if (CallService(MS_SYSTEM_GETVERSION, 0, 0) >= PLUGIN_MAKE_VERSION(0,9,0,5))
- nlhr.flags |= NLHRF_PERSISTENT | NLHRF_REDIRECT;
-
// change the header so the plugin is pretended to be IE 6 + WinXP
nlhr.headersCount = 5;
nlhr.headers = headers;
@@ -83,7 +80,7 @@ int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData) while (result == 0xBADBAD) {
// download the page
- nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,
+ NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,
(WPARAM)hNetlibUser,(LPARAM)&nlhr);
if (nlhrReply) {
@@ -190,9 +187,9 @@ void NetlibInit(void) {
NETLIBUSER nlu = {0};
nlu.cbSize = sizeof(nlu);
- nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION;
+ nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION|NUF_TCHAR;
nlu.szSettingsModule = WEATHERPROTONAME;
- nlu.szDescriptiveName = Translate("Weather HTTP connections");
+ nlu.ptszDescriptiveName = TranslateT("Weather HTTP connections");
hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu);
}
diff --git a/protocols/Weather/weather_opt.cpp b/protocols/Weather/weather_opt.cpp index b6eda4fb94..1f7fe3e3ab 100644 --- a/protocols/Weather/weather_opt.cpp +++ b/protocols/Weather/weather_opt.cpp @@ -32,57 +32,57 @@ int RedrawFrame(WPARAM wParam, LPARAM lParam); // in = string to determine which field to set default "CBNEHXPp"
void SetTextDefault(const char* in)
{
- char str[MAX_TEXT_SIZE];
+ TCHAR str[MAX_TEXT_SIZE];
if (strchr(in, 'C') != NULL)
{
- strcpy(str, C_DEFAULT);
- wSetData(&opt.cText, Translate(str));
+ _tcscpy(str, C_DEFAULT);
+ wSetData(&opt.cText, str);
}
if (strchr(in, 'b') != NULL)
{
- strcpy(str, b_DEFAULT);
- wSetData(&opt.bTitle, Translate(str));
+ _tcscpy(str, b_DEFAULT);
+ wSetData(&opt.bTitle, str);
}
if (strchr(in, 'B') != NULL)
{
- strcpy(str, B_DEFAULT);
- wSetData(&opt.bText, Translate(str));
+ _tcscpy(str, B_DEFAULT);
+ wSetData(&opt.bText, str);
}
if (strchr(in, 'N') != NULL)
{
- strcpy(str, N_DEFAULT);
- wSetData(&opt.nText, Translate(str));
+ _tcscpy(str, N_DEFAULT);
+ wSetData(&opt.nText, str);
}
if (strchr(in, 'E') != NULL)
{
- strcpy(str, E_DEFAULT);
- wSetData(&opt.eText, Translate(str));
+ _tcscpy(str, E_DEFAULT);
+ wSetData(&opt.eText, str);
}
if (strchr(in, 'H') != NULL)
{
- strcpy(str, H_DEFAULT);
- wSetData(&opt.hText, Translate(str));
+ _tcscpy(str, H_DEFAULT);
+ wSetData(&opt.hText, str);
}
if (strchr(in, 'X') != NULL)
{
- strcpy(str, X_DEFAULT);
- wSetData(&opt.xText, Translate(str));
+ _tcscpy(str, X_DEFAULT);
+ wSetData(&opt.xText, str);
}
if (strchr(in, 'P') != NULL)
{
- strcpy(str, P_DEFAULT);
- wSetData(&opt.pTitle, Translate(str));
+ _tcscpy(str, P_DEFAULT);
+ wSetData(&opt.pTitle, str);
}
if (strchr(in, 'p') != NULL)
{
- strcpy(str, p_DEFAULT);
- wSetData(&opt.pText, Translate(str));
+ _tcscpy(str, p_DEFAULT);
+ wSetData(&opt.pText, str);
}
if (strchr(in, 'S') != NULL)
{
- strcpy(str, s_DEFAULT);
- wSetData(&opt.sText, Translate(str));
+ _tcscpy(str, s_DEFAULT);
+ wSetData(&opt.sText, str);
}
}
diff --git a/protocols/Weather/weather_update.cpp b/protocols/Weather/weather_update.cpp index 3e6c2c6120..c4c78edec8 100644 --- a/protocols/Weather/weather_update.cpp +++ b/protocols/Weather/weather_update.cpp @@ -45,10 +45,10 @@ int UpdateWeather(HANDLE hContact) dbv.pszVal = "";
// log to netlib log for debug purpose
- Netlib_Logf(hNetlibUser, "************************************************************************");
+ Netlib_LogfT(hNetlibUser, _T("************************************************************************"));
int dbres = DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv);
- Netlib_Logf(hNetlibUser, "<-- Start update for station -->");
+ Netlib_LogfT(hNetlibUser, _T("<-- Start update for station -->"));
// download the info and parse it
// result are stored in database
@@ -65,8 +65,8 @@ int UpdateWeather(HANDLE hContact) WPShowMessage(str, SM_WARNING);
}
// log to netlib
- Netlib_Logf(hNetlibUser, "Error! Update cannot continue... Start to free memory");
- Netlib_Logf(hNetlibUser, "<-- Error occurs while updating station: %s -->", dbv.ptszVal);
+ Netlib_LogfT(hNetlibUser, _T("Error! Update cannot continue... Start to free memory"));
+ Netlib_LogfT(hNetlibUser, _T("<-- Error occurs while updating station: %s -->"), dbv.ptszVal);
if (!dbres) DBFreeVariant(&dbv);
return 1;
}
@@ -187,7 +187,7 @@ int UpdateWeather(HANDLE hContact) dbei.cbSize = sizeof(dbei);
dbei.szModule = WEATHERPROTONAME;
dbei.timestamp = (DWORD)time(NULL);
- dbei.flags = DBEF_READ;
+ dbei.flags = DBEF_READ|DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.pBlob = (PBYTE)mir_utf8encodeT(str2);
dbei.cbBlob = (DWORD)strlen((char*)dbei.pBlob)+1;
@@ -200,8 +200,8 @@ int UpdateWeather(HANDLE hContact) NotifyEventHooks(hHookWeatherUpdated, (WPARAM)hContact, (LPARAM)Ch);
}
- Netlib_Logf(hNetlibUser, "Update Completed - Start to free memory");
- Netlib_Logf(hNetlibUser, "<-- Update successful for station -->");
+ Netlib_LogfT(hNetlibUser, _T("Update Completed - Start to free memory"));
+ Netlib_LogfT(hNetlibUser, _T("<-- Update successful for station -->"));
// Update frame data
UpdateMwinData(hContact);
@@ -219,9 +219,7 @@ int UpdateWeather(HANDLE hContact) // hContact = current contact
void UpdateListAdd(HANDLE hContact)
{
- UPDATELIST *newItem;
-
- newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST));
+ UPDATELIST *newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST));
newItem->hContact = hContact;
newItem->next = NULL;
@@ -260,11 +258,9 @@ HANDLE UpdateGetFirst() void DestroyUpdateList(void)
{
- UPDATELIST *temp;
-
WaitForSingleObject(hUpdateMutex, INFINITE);
- temp = UpdateListHead;
+ UPDATELIST *temp = UpdateListHead;
// free the list one by one
while (temp != NULL)
diff --git a/protocols/Weather/weather_userinfo.cpp b/protocols/Weather/weather_userinfo.cpp index 84c63d4d4d..0374b801cc 100644 --- a/protocols/Weather/weather_userinfo.cpp +++ b/protocols/Weather/weather_userinfo.cpp @@ -122,9 +122,7 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa switch(LOWORD(wParam)) {
case IDC_MOREDETAIL:
{
- HWND hMoreDataDlg;
-
- hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
+ HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
if (hMoreDataDlg == NULL)
hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL,
DlgProcMoreData, (LPARAM)hContact);
|