diff options
author | George Hazan <george.hazan@gmail.com> | 2012-05-30 13:01:44 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-05-30 13:01:44 +0000 |
commit | b947df9fed0907995842d4c7121157508feac65e (patch) | |
tree | c43d627233d6a67ae5f1f35ddb8e03885d27c99c /protocols | |
parent | 657e7fa72958bd46d5319ec839f4270bd065f3f1 (diff) |
Weather Unicode
git-svn-id: http://svn.miranda-ng.org/main/trunk@230 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Weather/weather.cpp | 12 | ||||
-rw-r--r-- | protocols/Weather/weather.h | 217 | ||||
-rw-r--r-- | protocols/Weather/weather_10.vcxproj | 1 | ||||
-rw-r--r-- | protocols/Weather/weather_addstn.cpp | 291 | ||||
-rw-r--r-- | protocols/Weather/weather_contacts.cpp | 373 | ||||
-rw-r--r-- | protocols/Weather/weather_conv.cpp | 594 | ||||
-rw-r--r-- | protocols/Weather/weather_data.cpp | 300 | ||||
-rw-r--r-- | protocols/Weather/weather_http.cpp | 94 | ||||
-rw-r--r-- | protocols/Weather/weather_icons.cpp | 22 | ||||
-rw-r--r-- | protocols/Weather/weather_info.cpp | 166 | ||||
-rw-r--r-- | protocols/Weather/weather_ini.cpp | 225 | ||||
-rw-r--r-- | protocols/Weather/weather_mwin.cpp | 65 | ||||
-rw-r--r-- | protocols/Weather/weather_opt.cpp | 211 | ||||
-rw-r--r-- | protocols/Weather/weather_popup.cpp | 55 | ||||
-rw-r--r-- | protocols/Weather/weather_svcs.cpp | 32 | ||||
-rw-r--r-- | protocols/Weather/weather_update.cpp | 296 | ||||
-rw-r--r-- | protocols/Weather/weather_userinfo.cpp | 84 |
17 files changed, 1359 insertions, 1679 deletions
diff --git a/protocols/Weather/weather.cpp b/protocols/Weather/weather.cpp index ebb5e24fb5..b716aefa63 100644 --- a/protocols/Weather/weather.cpp +++ b/protocols/Weather/weather.cpp @@ -60,7 +60,6 @@ BOOL ModuleLoaded; struct MM_INTERFACE mmi;
struct UTF8_INTERFACE utfi;
-
PLUGINLINK *pluginLink;
// plugin info
@@ -87,7 +86,7 @@ static const PLUGININFOEX pluginInfoEx = extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
if (mirandaVersion < PLUGIN_MAKE_VERSION(0,8,0,0)) {
- MessageBox(NULL, "Weather Protocol requires Miranda 0.8.0.0 or later to run.", "Weather Protocol", MB_OK|MB_ICONERROR|MB_APPLMODAL);
+ MessageBoxA(NULL, "Weather Protocol requires Miranda 0.8.0.0 or later to run.", "Weather Protocol", MB_OK|MB_ICONERROR|MB_APPLMODAL);
return NULL;
}
// if Miranda version is higher than 0.7.0
@@ -206,7 +205,7 @@ extern "C" int __declspec(dllexport) Unload(void) DestroyMwin();
DestroyWindow(hPopupWindow);
- for (i = sizeof(hHooks)/sizeof(HANDLE); i--; )
+ for (i = SIZEOF(hHooks); i--; )
UnhookEvent(hHooks[i]);
DestroyHookableEvent(hHookWeatherUpdated);
@@ -229,7 +228,6 @@ extern "C" int __declspec(dllexport) Unload(void) extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
PROTOCOLDESCRIPTOR pd = {0};
- char SvcFunc[100];
DWORD lastver;
pluginLink = link;
@@ -297,9 +295,9 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) SkinAddNewSound("weatheralert", Translate("Weather Alert Issued"), "");
// window needed for popup commands
- strcpy(SvcFunc, WEATHERPROTONAME);
- strcat(SvcFunc, "_PopupWindow");
- hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW,"static",SvcFunc,0,CW_USEDEFAULT,CW_USEDEFAULT,
+ TCHAR SvcFunc[100];
+ mir_sntprintf( SvcFunc, SIZEOF(SvcFunc), _T("%s__PopupWindow"), _T(WEATHERPROTONAME));
+ hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW,_T("static"),SvcFunc,0,CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,HWND_DESKTOP,NULL,hInst,NULL);
SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc);
diff --git a/protocols/Weather/weather.h b/protocols/Weather/weather.h index 46c5ec6bae..047f408dd5 100644 --- a/protocols/Weather/weather.h +++ b/protocols/Weather/weather.h @@ -85,7 +85,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define LIST_COLUMN 150
// others
-#define NODATA Translate("N/A")
+#define NODATA TranslateT("N/A")
#define UM_SETCONTACT 40000
// weather update error codes
@@ -100,15 +100,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define UNKNOWN_ERROR 99
// weather update error text
-#define E10 Translate("Invalid ID format, missing \"/\" (10)")
-#define E11 Translate("Invalid service (11)")
-#define E12 Translate("Invalid station (12)")
-#define E20 Translate("Weather service ini for this station is not found (20)")
-#define E30 Translate("Netlib error - check your internet connection (30)")
-#define E40 Translate("Empty data is retrieved (40)")
-#define E42 Translate("Document not found (42)")
-#define E43 Translate("Document too short to contain any weather data (43)")
-#define E99 Translate("Unknown error (99)")
+#define E10 TranslateT("Invalid ID format, missing \"/\" (10)")
+#define E11 TranslateT("Invalid service (11)")
+#define E12 TranslateT("Invalid station (12)")
+#define E20 TranslateT("Weather service ini for this station is not found (20)")
+#define E30 TranslateT("Netlib error - check your internet connection (30)")
+#define E40 TranslateT("Empty data is retrieved (40)")
+#define E42 TranslateT("Document not found (42)")
+#define E43 TranslateT("Document too short to contain any weather data (43)")
+#define E99 TranslateT("Unknown error (99)")
// HTTP error... not all translated
// 100 Continue
@@ -117,28 +117,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // 201 Created
// 202 Accepted
// 203 Non-Authoritative Information
-#define E204 Translate("HTTP Error: No content (204)")
+#define E204 TranslateT("HTTP Error: No content (204)")
// 205 Reset Content
// 206 Partial Content
// 300 Multiple Choices
-#define E301 Translate("HTTP Error: Data moved (301)")
+#define E301 TranslateT("HTTP Error: Data moved (301)")
// 302 Found
// 303 See Other
// 304 Not Modified
-#define E305 Translate("HTTP Error: Use proxy (305)")
+#define E305 TranslateT("HTTP Error: Use proxy (305)")
// 306 (Unused)
-#define E307 Translate("HTTP Error: Temporary redirect (307)")
-#define E400 Translate("HTTP Error: Bad request (400)")
-#define E401 Translate("HTTP Error: Unauthorized (401)")
-#define E402 Translate("HTTP Error: Payment required (402)")
-#define E403 Translate("HTTP Error: Forbidden (403)")
-#define E404 Translate("HTTP Error: Not found (404)")
-#define E405 Translate("HTTP Error: Method not allowed (405)")
+#define E307 TranslateT("HTTP Error: Temporary redirect (307)")
+#define E400 TranslateT("HTTP Error: Bad request (400)")
+#define E401 TranslateT("HTTP Error: Unauthorized (401)")
+#define E402 TranslateT("HTTP Error: Payment required (402)")
+#define E403 TranslateT("HTTP Error: Forbidden (403)")
+#define E404 TranslateT("HTTP Error: Not found (404)")
+#define E405 TranslateT("HTTP Error: Method not allowed (405)")
// 406 Not Acceptable
-#define E407 Translate("HTTP Error: Proxy authentication required (407)")
+#define E407 TranslateT("HTTP Error: Proxy authentication required (407)")
// 408 Request Timeout
// 409 Conflict
-#define E410 Translate("HTTP Error: Gone (410)")
+#define E410 TranslateT("HTTP Error: Gone (410)")
// 411 Length Required
// 412 Precondition Failed
// 413 Request Entity Too Large
@@ -146,11 +146,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. // 415 Unsupported Media Type
// 416 Requested Range Not Satisfiable
// 417 Expectation Failed
-#define E500 Translate("HTTP Error: Internal server error (500)")
+#define E500 TranslateT("HTTP Error: Internal server error (500)")
// 501 Not Implemented
-#define E502 Translate("HTTP Error: Bad gateway (502)")
-#define E503 Translate("HTTP Error: Service unavailable (503)")
-#define E504 Translate("HTTP Error: Gateway timeout (504)")
+#define E502 TranslateT("HTTP Error: Bad gateway (502)")
+#define E503 TranslateT("HTTP Error: Service unavailable (503)")
+#define E504 TranslateT("HTTP Error: Gateway timeout (504)")
// 505 HTTP Version Not Supported
// defaults constants
@@ -188,18 +188,18 @@ typedef struct { WORD pUnit;
WORD dUnit;
WORD eUnit;
- char DegreeSign[4];
+ TCHAR DegreeSign[4];
BOOL DoNotAppendUnit;
BOOL NoFrac;
// texts
- char *cText;
- char *bTitle;
- char *bText;
- char *nText;
- char *eText;
- char *hText;
- char *xText;
- char *sText;
+ TCHAR *cText;
+ TCHAR *bTitle;
+ TCHAR *bText;
+ TCHAR *nText;
+ TCHAR *eText;
+ TCHAR *hText;
+ TCHAR *xText;
+ TCHAR *sText;
// advanced
BOOL DisCondIcon;
// popup options
@@ -218,10 +218,10 @@ typedef struct { // popup delay
DWORD pDelay;
// popup texts
- char *pTitle;
- char *pText;
+ TCHAR *pTitle;
+ TCHAR *pText;
// other misc stuff
- char Default[64];
+ TCHAR Default[64];
HANDLE DefStn;
} MYOPTIONS;
@@ -248,12 +248,12 @@ void DestroyUpdateList(void); #define WID_BREAK 2
typedef struct {
- char *Name;
- char *Start;
- char *End;
- char *Unit;
- char *Url;
- char *Break;
+ TCHAR *Name;
+ TCHAR *Start;
+ TCHAR *End;
+ TCHAR *Unit;
+ char *Url;
+ TCHAR *Break;
int Type;
} WIDATAITEM;
@@ -267,27 +267,27 @@ typedef struct WITEMLIST WIDATAITEMLIST; typedef struct {
BOOL Available;
char *SearchURL;
- char *NotFoundStr;
+ TCHAR *NotFoundStr;
WIDATAITEM Name;
} WIIDSEARCH;
typedef struct {
BOOL Available;
- char *First;
+ TCHAR *First;
WIDATAITEM Name;
WIDATAITEM ID;
} WINAMESEARCHTYPE;
typedef struct {
char *SearchURL;
- char *NotFoundStr;
- char *SingleStr;
+ TCHAR *NotFoundStr;
+ TCHAR *SingleStr;
WINAMESEARCHTYPE Single;
WINAMESEARCHTYPE Multiple;
} WINAMESEARCH;
struct STRLIST {
- char *Item;
+ TCHAR *Item;
struct STRLIST *Next;
};
@@ -299,24 +299,26 @@ typedef struct { } WICONDLIST;
typedef struct {
- char *FileName;
- char *ShortFileName;
+ TCHAR *FileName;
+ TCHAR *ShortFileName;
BOOL Enabled;
-// header
- char *DisplayName;
- char *InternalName;
- char *Description;
- char *Author;
- char *Version;
+
+ // header
+ TCHAR *DisplayName;
+ TCHAR *InternalName;
+ TCHAR *Description;
+ TCHAR *Author;
+ TCHAR *Version;
int InternalVer;
size_t MemUsed;
-// default
- char *DefaultURL;
- char *DefaultMap;
- char *UpdateURL;
- char *UpdateURL2;
- char *UpdateURL3;
- char *UpdateURL4;
+
+ // default
+ char *DefaultURL;
+ TCHAR *DefaultMap;
+ char *UpdateURL;
+ char *UpdateURL2;
+ char *UpdateURL3;
+ char *UpdateURL4;
char *Cookie;
// items
int UpdateDataCount;
@@ -371,8 +373,8 @@ void UpgradeContact(DWORD lastver, HANDLE hContact); INT_PTR WeatherAddToList(WPARAM wParam,LPARAM lParam);
BOOL CheckSearch();
-int IDSearch(char *id, const int searchId);
-int NameSearch(char *name, const int searchId);
+int IDSearch(TCHAR *id, const int searchId);
+int NameSearch(TCHAR *name, const int searchId);
INT_PTR WeatherBasicSearch(WPARAM wParam,LPARAM lParam);
INT_PTR WeatherCreateAdvancedSearchUI(WPARAM wParam, LPARAM lParam);
@@ -398,60 +400,58 @@ BOOL is_number(char *s); extern unsigned lpcp;
void InitUniConv(void);
LPWSTR ConvToUnicode(LPCSTR str2);
-UINT GetDlgItemTextWth(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount);
-BOOL SetDlgItemTextWth(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
-BOOL SetWindowTextWth(HWND hWnd, LPCSTR lpString);
-void ListView_SetItemTextWth(HWND hwndLV, int i, int iSubItem_, LPSTR pszText_);
-int ListView_InsertItemWth(HWND hwnd, LV_ITEM *pitem);
-int ListView_InsertColumnWth(HWND hwnd, int iCol, LV_COLUMN *pitem);
-
-void GetTemp(char *tempchar, char *unit, char *str);
-void GetSpeed(char *tempchar, char *unit, char *str);
-void GetPressure(char *tempchar, char *unit, char *str);
-void GetDist(char *tempchar, char *unit, char *str);
-void GetElev(char *tempchar, char *unit, char *str);
-
-WORD GetIcon(const char* cond, WIDATA *Data);
-void CaseConv(char *str);
+
+void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str);
+
+WORD GetIcon(const TCHAR* cond, WIDATA *Data);
+void CaseConv(TCHAR *str);
void TrimString(char *str);
+void TrimString(WCHAR *str);
void ConvertBackslashes(char *str);
char *GetSearchStr(char *dis);
-char *GetDisplay(WEATHERINFO *w, const char *dis, char* str);
+TCHAR *GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str);
INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam);
-void GetSvc(char *pszID);
-void GetID(char *pszID);
+void GetSvc(TCHAR *pszID);
+void GetID(TCHAR *pszID);
-char *GetError(int code);
+TCHAR *GetError(int code);
// functions in weather_data.c
-void GetStationID(HANDLE hContact, char* id, size_t idlen);
+void GetStationID(HANDLE hContact, TCHAR* id, size_t idlen);
WEATHERINFO LoadWeatherInfo(HANDLE Change);
int DBGetData(HANDLE hContact, char *setting, DBVARIANT *dbv);
-int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueName, char *dest, size_t dest_len);
+int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueName, TCHAR *dest, size_t dest_len);
void EraseAllInfo(DWORD lastver);
-void LoadStationData(char *pszFile, char *pszShortFile, WIDATA *Data);
-void GetDataValue(WIDATAITEM *UpdateData, char *Data, char** szInfo);
-void ConvertDataValue(WIDATAITEM *UpdateData, char *Data);
+void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data);
+void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szInfo);
+void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data);
void wSetData(char **Data, const char *Value);
+void wSetData(WCHAR **Data, const char *Value);
+void wSetData(WCHAR **Data, const WCHAR *Value);
void wfree(char **Data);
+void wfree(WCHAR **Data);
void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam);
int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam);
// functions in weather_http.c
-int InternetDownloadFile (char *szUrl, char *cookie, char** szData);
+int InternetDownloadFile (char *szUrl, char *cookie, TCHAR** szData);
void NetlibInit();
void NetlibHttpDisconnect(void);
// functions in weather_ini.c
void WIListAdd(WIDATA Data);
-WIDATA* GetWIData(char *pszServ);
+WIDATA* GetWIData(TCHAR *pszServ);
-BOOL IsContainedInCondList(const char *pszStr, WICONDLIST *List);
+BOOL IsContainedInCondList(const TCHAR *pszStr, WICONDLIST *List);
void DestroyWIList();
BOOL LoadWIData(BOOL dial);
@@ -460,7 +460,7 @@ void FreeWIData(WIDATA *Data); INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
// functions in weather_info.c
-void GetINIInfo(char *pszSvc);
+void GetINIInfo(TCHAR *pszSvc);
void MoreVarList();
@@ -483,7 +483,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar // functions in weather_popup.c
int WeatherPopup(WPARAM wParam, LPARAM lParam);
int WeatherError(WPARAM wParam, LPARAM lParam);
-int WPShowMessage(char* lpzText, WORD kind);
+int WPShowMessage(TCHAR* lpzText, WORD kind);
LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@@ -546,3 +546,30 @@ void InitIcons(void); HICON LoadIconEx(const char* name, BOOL big);
HANDLE GetIconHandle(const char* name);
void ReleaseIconEx(HICON hIcon);
+
+class _A2T
+{
+ TCHAR* buf;
+
+public:
+ _A2T( const char* s ) : buf( mir_a2t( s )) {}
+ _A2T( const char* s, int cp ) : buf( mir_a2t_cp( s, cp )) {}
+ ~_A2T() { mir_free(buf); }
+
+ __forceinline operator TCHAR*() const
+ { return buf;
+ }
+};
+
+class _T2A
+{
+ char* buf;
+
+public:
+ _T2A( const TCHAR* s ) : buf( mir_t2a( s )) {}
+ ~_T2A() { mir_free(buf); }
+
+ __forceinline operator char*() const
+ { return buf;
+ }
+};
diff --git a/protocols/Weather/weather_10.vcxproj b/protocols/Weather/weather_10.vcxproj index 6d9df9bee7..530054497f 100644 --- a/protocols/Weather/weather_10.vcxproj +++ b/protocols/Weather/weather_10.vcxproj @@ -26,6 +26,7 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
diff --git a/protocols/Weather/weather_addstn.cpp b/protocols/Weather/weather_addstn.cpp index 24b965ce19..86c58d5a9b 100644 --- a/protocols/Weather/weather_addstn.cpp +++ b/protocols/Weather/weather_addstn.cpp @@ -8,7 +8,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2
of the License.
-This program is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@@ -24,39 +24,32 @@ to the contact list. Contain code for both name and ID search. #include "weather.h"
// variables used for weather_addstn.c
-static int searchId=-1;
-static char sID[32];
-static char name1[256];
+static int searchId = -1;
+static TCHAR name1[256];
-//============ ADDING NEW STATION ============
+// ============ ADDING NEW STATION ============
// protocol service function for adding a new contact onto contact list
// lParam = PROTOSEARCHRESULT
-INT_PTR WeatherAddToList(WPARAM wParam,LPARAM lParam)
+INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam)
{
- PROTOSEARCHRESULT *psr=(PROTOSEARCHRESULT*)lParam;
- char str[256], svc[256];
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam;
WIDATA *sData;
// search for existing contact
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
- while(hContact != NULL)
- {
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while (hContact != NULL) {
// check if it is a weather contact
- if(IsMyContact(hContact))
- {
+ if ( IsMyContact(hContact)) {
DBVARIANT dbv;
// check ID to see if the contact already exist in the database
- if(!DBGetContactSettingString(hContact,WEATHERPROTONAME,"ID",&dbv))
- {
- if(!_stricmp(psr->email,dbv.pszVal))
- {
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ if (!_tcsicmp(psr->email, dbv.ptszVal)) {
// remove the flag for not on list and hidden, thus make the contact visible
// and add them on the list
- if (DBGetContactSettingByte(hContact,"CList","NotOnList",1))
- {
- DBDeleteContactSetting(hContact,"CList","NotOnList");
- DBDeleteContactSetting(hContact,"CList","Hidden");
+ if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 1)) {
+ DBDeleteContactSetting(hContact, "CList", "NotOnList");
+ DBDeleteContactSetting(hContact, "CList", "Hidden");
}
DBFreeVariant(&dbv);
// contact is added, function quitting
@@ -65,7 +58,7 @@ INT_PTR WeatherAddToList(WPARAM wParam,LPARAM lParam) DBFreeVariant(&dbv);
}
}
- hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
// if contact with the same ID was not found, add it
@@ -73,29 +66,33 @@ INT_PTR WeatherAddToList(WPARAM wParam,LPARAM lParam) hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)WEATHERPROTONAME);
// suppress online notification for the new contact
- CallService(MS_IGNORE_IGNORE,(WPARAM)hContact, IGNOREEVENT_USERONLINE);
+ CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
+
// set contact info and settings
- strncpy(svc, psr->email, sizeof(svc)); svc[sizeof(svc)-1] = 0;
+ TCHAR svc[256];
+ _tcsncpy(svc, psr->email, SIZEOF(svc)); svc[SIZEOF(svc)-1] = 0;
GetSvc(svc);
// set settings by obtaining the default for the service
- if (psr->lastName[0] != 0)
- {
+ if (psr->lastName[0] != 0) {
sData = GetWIData(svc);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "MapURL", sData->DefaultMap);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "MapURL", sData->DefaultMap);
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "InfoURL", sData->DefaultURL);
}
- else // if no valid service is found, create empty strings for MapURL and InfoURL
- {
+ else { // if no valid service is found, create empty strings for MapURL and InfoURL
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "MapURL", "");
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "InfoURL", "");
}
// write the other info and settings to the database
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "ID", psr->email);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "Nick", psr->nick);
- wsprintf(str, Translate("Current weather information for %s."), psr->nick);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "ID", psr->email);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "Nick", psr->nick);
DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE);
+
AvatarDownloaded(hContact);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "About", str);
+
+ TCHAR str[256];
+ mir_sntprintf(str, SIZEOF(str), TranslateT("Current weather information for %s."), psr->nick);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "About", str);
+
// make the last update tags to something invalid
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastLog", "never");
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", "None");
@@ -105,75 +102,77 @@ INT_PTR WeatherAddToList(WPARAM wParam,LPARAM lParam) DBWriteContactSettingDword(hContact, "Ignore", "Mask", 8);
// if no default station is found, set the new contact as default station
- if (opt.Default[0] == 0)
- {
+ if (opt.Default[0] == 0) {
DBVARIANT dbv;
- GetStationID(hContact, opt.Default, sizeof(opt.Default));
+ GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
opt.DefStn = hContact;
- if (!DBGetContactSettingString(hContact,WEATHERPROTONAME,"Nick",&dbv))
- {
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
// notification message box
- wsprintf(str, Translate("%s is now the default weather station"), dbv.pszVal);
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
DBFreeVariant(&dbv);
- MessageBox(NULL, str, Translate("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default);
}
// display the Edit Settings dialog box
EditSettings((WPARAM)hContact, 0);
return (INT_PTR)hContact;
}
-//============ WARNING DIALOG ============
+// ============ WARNING DIALOG ============
// show a message box and cancel search if update is in process
BOOL CheckSearch() {
if (UpdateListHead != NULL) {
- MessageBox(NULL, Translate("Please try again after weather update is completed."), Translate("Weather Protocol"), MB_OK|MB_ICONERROR);
+ MessageBox(NULL, TranslateT("Please try again after weather update is completed."), TranslateT("Weather Protocol"), MB_OK|MB_ICONERROR);
return FALSE;
}
return TRUE;
}
-//============ BASIC ID SEARCH ============
+// ============ BASIC ID SEARCH ============
+
+static TCHAR sID[32];
// A timer process for the ID search (threaded)
static void __cdecl BasicSearchTimerProc(LPVOID hWnd)
{
int result;
// search only when it's not current updating weather.
- if (CheckSearch()) result = IDSearch(sID, searchId);
+ if (CheckSearch())
+ result = IDSearch(sID, searchId);
+
// broadcast the search result
- ProtoBroadcastAck(WEATHERPROTONAME,NULL,ACKTYPE_SEARCH,ACKRESULT_SUCCESS,(HANDLE)searchId,0);
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)searchId, 0);
// exit the search
- searchId=-1;
+ searchId = -1;
}
// the service function for ID search
// lParam = ID search string
-INT_PTR WeatherBasicSearch(WPARAM wParam,LPARAM lParam)
+INT_PTR WeatherBasicSearch(WPARAM wParam, LPARAM lParam)
{
- if(searchId != -1) return 0; //only one search at a time
- strncpy(sID, (char*)lParam, sizeof(sID));
- sID[sizeof(sID)-1] = 0;
- searchId=1;
+ if (searchId != -1) return 0; //only one search at a time
+ _tcsncpy(sID, ( TCHAR* )lParam, SIZEOF(sID));
+ sID[SIZEOF(sID)-1] = 0;
+ searchId = 1;
// create a thread for the ID search
mir_forkthread(BasicSearchTimerProc, NULL);
return searchId;
}
-//============ NAME SEARCH ============
+// ============ NAME SEARCH ============
// name search timer process (threaded)
static void __cdecl NameSearchTimerProc(LPVOID hWnd)
{
// search only when it's not current updating weather.
if (CheckSearch())
- {
- if (name1[0] != 0) NameSearch(name1, searchId); // search nickname field
- }
+ if (name1[0] != 0)
+ NameSearch(name1, searchId); // search nickname field
+
// broadcast the result
ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)searchId, 0);
@@ -183,8 +182,7 @@ static void __cdecl NameSearchTimerProc(LPVOID hWnd) static INT_PTR CALLBACK WeatherSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SetFocus(GetDlgItem(hwndDlg, IDC_SEARCHCITY));
@@ -200,7 +198,6 @@ static INT_PTR CALLBACK WeatherSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPA INT_PTR WeatherCreateAdvancedSearchUI(WPARAM wParam, LPARAM lParam)
{
HWND parent = (HWND)lParam;
-
if (parent)
return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SEARCHCITY), parent, WeatherSearchAdvancedDlgProc, 0);
@@ -211,8 +208,8 @@ INT_PTR WeatherCreateAdvancedSearchUI(WPARAM wParam, LPARAM lParam) INT_PTR WeatherAdvancedSearch(WPARAM wParam, LPARAM lParam)
{
if (searchId != -1) return 0; //only one search at a time
- searchId = 1;
+ searchId = 1;
GetDlgItemText((HWND)lParam, IDC_SEARCHCITY, name1, 256);
// search for the weather station using a thread
@@ -220,30 +217,28 @@ INT_PTR WeatherAdvancedSearch(WPARAM wParam, LPARAM lParam) return searchId;
}
-//============ SEARCH FOR A WEATHER STATION USING ID ============
+// ============ SEARCH FOR A WEATHER STATION USING ID ============
// Seaching station ID from a single weather service (Threaded)
// sID = search string for the station ID
// searchId = -1
// sData = the ID search data for that particular weather service
// svcname = the name of the weather service that is currently searching (ie. Yahoo Weather)
-int IDSearchProc(char *sID, const int searchId, WIIDSEARCH *sData, char *svc, char *svcname)
+int IDSearchProc(TCHAR *sID, const int searchId, WIIDSEARCH *sData, TCHAR *svc, TCHAR *svcname)
{
- PROTOSEARCHRESULT psr = {0};
- char str[MAX_DATA_LEN] = "", newID[MAX_DATA_LEN];
+ TCHAR str[MAX_DATA_LEN], newID[MAX_DATA_LEN];
- if (sData->Available)
- {
- char loc[255], *szData = NULL;
+ if (sData->Available) {
+ char loc[255];
+ TCHAR *szData = NULL;
// load the page
- mir_snprintf(loc, sizeof(loc), sData->SearchURL , sID);
- if (InternetDownloadFile(loc, NULL, &szData) == 0)
- {
- char* szInfo = szData;
+ mir_snprintf(loc, SIZEOF(loc), sData->SearchURL, sID);
+ if (InternetDownloadFile(loc, NULL, &szData) == 0) {
+ TCHAR* szInfo = szData;
// not found
- if (strstr(szInfo, sData->NotFoundStr) == NULL)
+ if ( _tcsstr(szInfo, sData->NotFoundStr) == NULL)
GetDataValue(&sData->Name, str, &szInfo);
}
mir_free(szData);
@@ -252,15 +247,16 @@ int IDSearchProc(char *sID, const int searchId, WIIDSEARCH *sData, char *svc, ch }
// give no station name but only ID if the search is unavailable
- else strcpy(str, Translate("<Enter station name here>"));
- mir_snprintf(newID, sizeof(newID), "%s/%s", svc, sID);
+ else _tcscpy(str, TranslateT("<Enter station name here>"));
+ mir_sntprintf(newID, SIZEOF(newID), _T("%s/%s"), svc, sID);
// set the search result and broadcast it
- psr.cbSize=sizeof(psr);
- psr.nick=str;
- psr.firstName=" ";
- psr.lastName=svcname;
- psr.email=newID;
+ PROTOSEARCHRESULT psr = {0};
+ psr.cbSize = sizeof(psr);
+ psr.nick = str;
+ psr.firstName = _T(" ");
+ psr.lastName = svcname;
+ psr.email = newID;
ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
return 0;
@@ -270,139 +266,131 @@ int IDSearchProc(char *sID, const int searchId, WIIDSEARCH *sData, char *svc, ch // sID: the ID to search for
// searchId: don't change
// return 0 if no error
-int IDSearch(char *sID, const int searchId)
+int IDSearch(TCHAR *sID, const int searchId)
{
// for a normal ID search (ID != #)
- if (strcmp(sID, "#"))
- {
+ if ( _tcscmp(sID, _T("#"))) {
WIDATALIST *Item = WIHead;
// search every weather service using the search station ID
- while (Item != NULL)
- {
+ while (Item != NULL) {
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
- {
- PROTOSEARCHRESULT psr = {0};
+ else {
// return an empty contact on "#"
- psr.cbSize=sizeof(psr);
- psr.nick=Translate("<Enter station name here>"); // to be entered
- psr.firstName=" ";
- psr.lastName="";
- psr.email=Translate("<Enter station ID here>"); // to be entered
- ProtoBroadcastAck(WEATHERPROTONAME,NULL,ACKTYPE_SEARCH,ACKRESULT_DATA,(HANDLE)searchId,(LPARAM)&psr);
+ PROTOSEARCHRESULT psr = {0};
+ psr.cbSize = sizeof(psr);
+ psr.nick = TranslateT("<Enter station name here>"); // to be entered
+ psr.firstName = _T(" ");
+ psr.lastName = _T("");
+ psr.email = TranslateT("<Enter station ID here>"); // to be entered
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
}
return 0;
}
-//============ SEARCH FOR A WEATHER STATION BY NAME ============
+// ============ SEARCH FOR A WEATHER STATION BY NAME ============
// Seaching station name from a single weather service (Threaded)
// name = the name of the weather station to be searched
// searchId = -1
// sData = the name search data for that particular weather service
// svcname = the name of the weather service that is currently searching (ie. Yahoo Weather)
-int NameSearchProc(char *name, const int searchId, WINAMESEARCH *sData, char *svc, char *svcname)
+int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *svc, TCHAR *svcname)
{
- PROTOSEARCHRESULT psr;
- char *search, str[MAX_DATA_LEN], loc[256], sID[MAX_DATA_LEN], Name[MAX_DATA_LEN], *szData = NULL;
+ char loc[256];
+ TCHAR Name[MAX_DATA_LEN], str[MAX_DATA_LEN], sID[MAX_DATA_LEN], *szData = NULL, *search;
// replace spaces with %20
- char *pstr = (char*)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM) name);
- wsprintf(loc, sData->SearchURL, pstr);
+ char *pstr = (char*)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)(char*)_T2A(name));
+ wsprintfA(loc, sData->SearchURL, pstr);
HeapFree(GetProcessHeap(), 0, pstr);
- if (InternetDownloadFile(loc, NULL, &szData) == 0)
- {
- char* szInfo = szData;
- search = strstr(szInfo, sData->NotFoundStr); // determine if data is available
- if (search == NULL) // if data is found
- {
+ if (InternetDownloadFile(loc, NULL, &szData) == 0) {
+ TCHAR* szInfo = szData;
+ search = _tcsstr(szInfo, sData->NotFoundStr); // determine if data is available
+ if (search == NULL) { // if data is found
// test if it is single result
if (sData->Single.Available && sData->Multiple.Available)
- search = strstr(szInfo, sData->SingleStr);
+ search = _tcsstr(szInfo, sData->SingleStr);
// for single result
- if (sData->Single.Available && (search != NULL || !sData->Multiple.Available)) // single result
- {
+ if (sData->Single.Available && (search != NULL || !sData->Multiple.Available)) { // single result
// if station ID appears first in the downloaded data
- if (!_stricmp(sData->Single.First, "ID"))
- {
+ if ( !_tcsicmp(sData->Single.First, _T("ID"))) {
GetDataValue(&sData->Single.ID, str, &szInfo);
- wsprintf(sID, "%s/%s", svc, str);
+ wsprintf(sID, _T("%s/%s"), svc, str);
GetDataValue(&sData->Single.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
- else if (!_stricmp(sData->Single.First, "NAME"))
- {
+ else if (!_tcsicmp(sData->Single.First, _T("NAME"))) {
GetDataValue(&sData->Single.Name, Name, &szInfo);
GetDataValue(&sData->Single.ID, str, &szInfo);
- wsprintf(sID, "%s/%s", svc, str);
+ wsprintf(sID, _T("%s/%s"), svc, str);
}
// if no station ID is obtained, quit the search
- if (str[0] == 0)
- {
+ if (str[0] == 0) {
mir_free(szData);
return 1;
}
+
// if can't get the name, use the search string as name
- if (Name[0] == 0) strcpy(Name, name);
+ if (Name[0] == 0)
+ _tcscpy(Name, name);
// set the data and broadcast it
- memset(&psr,0,sizeof(psr));
- psr.cbSize=sizeof(psr);
- psr.nick=Name;
- psr.firstName=" ";
- psr.lastName=svcname;
- psr.email=sID;
- psr.id=sID;
- ProtoBroadcastAck(WEATHERPROTONAME,NULL,ACKTYPE_SEARCH,ACKRESULT_DATA,(HANDLE)searchId,(LPARAM)&psr);
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.nick = Name;
+ psr.firstName = _T(" ");
+ psr.lastName = svcname;
+ psr.email = sID;
+ psr.id = sID;
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
mir_free(szData);
return 0;
}
// for multiple result
- else if (sData->Multiple.Available) // multiple results
- {
+ else if (sData->Multiple.Available) { // multiple results
// search for the next occurrence of the string
- for (;;)
- {
+ for (;;) {
// if station ID appears first in the downloaded data
- if (!_stricmp(sData->Multiple.First, "ID")) {
+ if ( !_tcsicmp(sData->Multiple.First, _T("ID"))) {
GetDataValue(&sData->Multiple.ID, str, &szInfo);
- wsprintf(sID, "%s/%s", svc, str);
+ wsprintf(sID, _T("%s/%s"), svc, str);
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
- else if (!_stricmp(sData->Multiple.First, "NAME")) {
+ else if ( !_tcsicmp(sData->Multiple.First, _T("NAME"))) {
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
GetDataValue(&sData->Multiple.ID, str, &szInfo);
- wsprintf(sID, "%s/%s", svc, str);
+ wsprintf(sID, _T("%s/%s"), svc, str);
}
// if no station ID is obtained, search completed and quit the search
if (str[0] == 0) break;
// if can't get the name, use the search string as name
- if (Name[0] == 0) strcpy(Name, name);
-
- memset(&psr,0,sizeof(psr));
- psr.cbSize=sizeof(psr);
- psr.nick=Name;
- psr.firstName="";
- psr.lastName=svcname;
- psr.email=sID;
- psr.id=sID;
- ProtoBroadcastAck(WEATHERPROTONAME,NULL,ACKTYPE_SEARCH,ACKRESULT_DATA,
- (HANDLE)searchId,(LPARAM)&psr);
- }
- }
- }
+ if (Name[0] == 0)
+ _tcscpy(Name, name);
+
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+ psr.nick = Name;
+ psr.firstName = _T("");
+ psr.lastName = svcname;
+ psr.email = sID;
+ psr.id = sID;
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
+ } } }
+
mir_free(szData);
return 0;
}
+
mir_free(szData);
return 1;
}
@@ -411,23 +399,22 @@ int NameSearchProc(char *name, const int searchId, WINAMESEARCH *sData, char *sv // name: the station name to search for
// searchId: don't change
// return 0 if no error
-int NameSearch(char *name, const int searchId)
+int NameSearch(TCHAR *name, const int searchId)
{
WIDATALIST *Item = WIHead;
// search every weather service using the search station name
- while (Item != NULL)
- {
+ while (Item != NULL) {
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();
+ NetlibHttpDisconnect();
return 0;
}
-//====================== MENU ITEM FUNCTION ============
+// ======================MENU ITEM FUNCTION ============
// add a new weather station via find/add dialog
int WeatherAdd(WPARAM wParam, LPARAM lParam)
diff --git a/protocols/Weather/weather_contacts.cpp b/protocols/Weather/weather_contacts.cpp index 94aae312fd..45c322d640 100644 --- a/protocols/Weather/weather_contacts.cpp +++ b/protocols/Weather/weather_contacts.cpp @@ -8,7 +8,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2
of the License.
-This program is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@@ -17,23 +17,34 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* This file contain the source that is related to weather contacts,
+/* This file contain the source that is related to weather contacts,
include the links, edit settings, and loading weather information for
the contact.
*/
#include "weather.h"
-//============ BASIC CONTACTS FUNCTIONS AND LINKS ============
+static void OpenUrl( TCHAR* format, TCHAR* id )
+{
+ TCHAR loc[512];
+
+ GetID( id );
+ mir_sntprintf( loc, SIZEOF(loc), format, id );
+
+ char* szUrl = mir_t2a( loc );
+ CallService(MS_UTILS_OPENURL, opt.NewBrowserWin, (LPARAM)szUrl );
+ mir_free( szUrl );
+}
+
+// == == == == == == BASIC CONTACTS FUNCTIONS AND LINKS == == == == == ==
// view weather log for the contact
// wParam = current contact
-INT_PTR ViewLog(WPARAM wParam,LPARAM lParam)
+INT_PTR ViewLog(WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
// see if the log path is set
- if (!DBGetContactSettingTString((HANDLE)wParam,WEATHERPROTONAME,"Log",&dbv))
- {
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString((HANDLE)wParam, WEATHERPROTONAME, "Log", &dbv)) {
if (dbv.pszVal[0] != 0)
ShellExecute((HWND)lParam, _T("open"), dbv.ptszVal, _T(""), _T(""), SW_SHOW);
DBFreeVariant(&dbv);
@@ -46,79 +57,61 @@ INT_PTR ViewLog(WPARAM wParam,LPARAM lParam) // read complete forecast
// wParam = current contact
-INT_PTR LoadForecast(WPARAM wParam,LPARAM lParam)
+INT_PTR LoadForecast(WPARAM wParam, LPARAM lParam)
{
- char id[256], loc[256], loc2[256];
-
- // get station ID
- GetStationID((HANDLE)wParam, id, sizeof(id));
-
- if (id[0] != 0)
- {
- GetID(id);
-
+ TCHAR id[256], loc2[256];
+ GetStationID((HANDLE)wParam, id, SIZEOF(id));
+ if (id[0] != 0) {
// check if the complte forecast URL is set. If it is not, display warning and quit
- if (DBGetStaticString((HANDLE)wParam, WEATHERPROTONAME, "InfoURL", loc2, sizeof(loc2)) || loc2[0] == 0)
- {
+ if ( DBGetStaticString((HANDLE)wParam, WEATHERPROTONAME, "InfoURL", loc2, SIZEOF(loc2)) || loc2[0] == 0) {
MessageBox(NULL, TranslateT("The URL for complete forcast have not been set. You can set it from the Edit Settings dialog."),
TranslateT("Weather Protocol"), MB_ICONINFORMATION);
return 1;
}
// set the url and open the webpage
- mir_snprintf(loc, sizeof(loc), loc2, id);
- CallService(MS_UTILS_OPENURL, opt.NewBrowserWin, (WPARAM)loc);
+ OpenUrl(loc2, id );
}
return 0;
}
// load weather map
// wParam = current contact
-INT_PTR WeatherMap(WPARAM wParam,LPARAM lParam)
+INT_PTR WeatherMap(WPARAM wParam, LPARAM lParam)
{
- char id[256], loc[256], loc2[256];
-
- GetStationID((HANDLE)wParam, id, sizeof(id));
-
- if (id[0] != 0)
- {
- GetID(id);
-
+ TCHAR id[256], loc2[256];
+ GetStationID((HANDLE)wParam, id, SIZEOF(id));
+ if (id[0] != 0) {
// check if the weather map URL is set. If it is not, display warning and quit
- if (DBGetStaticString((HANDLE)wParam, WEATHERPROTONAME, "MapURL", loc2, sizeof(loc2)) || loc2[0] == 0)
- {
+ if (DBGetStaticString((HANDLE)wParam, WEATHERPROTONAME, "MapURL", loc2, SIZEOF(loc2)) || loc2[0] == 0) {
MessageBox(NULL, TranslateT("The URL for weather map have not been set. You can set it from the Edit Settings dialog."), TranslateT("Weather Protocol"), MB_ICONINFORMATION);
return 1;
}
+
// set the url and open the webpage
- mir_snprintf(loc, sizeof(loc), loc2, id);
- CallService(MS_UTILS_OPENURL, opt.NewBrowserWin, (WPARAM)loc);
+ OpenUrl(loc2, id);
}
return 0;
}
-//============ EDIT SETTINGS ============
+// == == == == == == EDIT SETTINGS == == == == == ==
// show edit settings dialog
// wParam = current contact
-INT_PTR EditSettings(WPARAM wParam,LPARAM lParam)
+INT_PTR EditSettings(WPARAM wParam, LPARAM lParam)
{
HWND hEditDlg = WindowList_Find(hWindowList, (HANDLE)wParam);
// search the dialog list to prevent multiple instance of dialog for the same contact
- if (hEditDlg != NULL)
- {
+ if (hEditDlg != NULL) {
// if the dialog box already opened, bring it to the front
SetForegroundWindow(hEditDlg);
SetFocus(hEditDlg);
}
- else
- {
- if(IsMyContact((HANDLE)wParam))
- {
- // if the dialog box is not opened, open a new one
+ else {
+ // if the dialog box is not opened, open a new one
+ if (IsMyContact((HANDLE)wParam))
CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT), NULL, DlgProcChange, (LPARAM)wParam);
- }
}
return 0;
@@ -138,14 +131,14 @@ typedef struct INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
- char str[256], str2[256], city[256], filter[256], *pfilter, loc[512], *chop;
+ TCHAR str[256], str2[256], city[256], filter[256], *pfilter, *chop;
+ char loc[512];
OPENFILENAME ofn; // common dialog box structure
HANDLE hContact;
WIDATA *sData;
CntSetWndDataType *wndData = NULL;
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -168,21 +161,21 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SendDlgItemMessage(hwndDlg, IDC_RESET2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
// make all buttons flat
- SendDlgItemMessage(hwndDlg,IDC_GETNAME, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg,IDC_SVCINFO, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg,IDC_BROWSE, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg,IDC_VIEW1, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg,IDC_RESET1, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg,IDC_VIEW2, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg,IDC_RESET2, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONSETASFLATBTN, 0, 0);
// set tooltip for the buttons
- SendDlgItemMessage(hwndDlg,IDC_GETNAME, BUTTONADDTOOLTIP, (WPARAM)"Get city name from ID", 0);
- SendDlgItemMessage(hwndDlg,IDC_SVCINFO, BUTTONADDTOOLTIP, (WPARAM)"Weather INI information", 0);
- SendDlgItemMessage(hwndDlg,IDC_BROWSE, BUTTONADDTOOLTIP, (WPARAM)"Browse", 0);
- SendDlgItemMessage(hwndDlg,IDC_VIEW1, BUTTONADDTOOLTIP, (WPARAM)"View webpage", 0);
- SendDlgItemMessage(hwndDlg,IDC_RESET1, BUTTONADDTOOLTIP, (WPARAM)"Reset to default", 0);
- SendDlgItemMessage(hwndDlg,IDC_VIEW2, BUTTONADDTOOLTIP, (WPARAM)"View webpage", 0);
+ SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONADDTOOLTIP, (WPARAM)"Get city name from ID", 0);
+ SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONADDTOOLTIP, (WPARAM)"Weather INI information", 0);
+ SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONADDTOOLTIP, (WPARAM)"Browse", 0);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONADDTOOLTIP, (WPARAM)"View webpage", 0);
+ SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONADDTOOLTIP, (WPARAM)"Reset to default", 0);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONADDTOOLTIP, (WPARAM)"View webpage", 0);
SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONADDTOOLTIP, (WPARAM)"Reset to default", 0);
// save the handle for the contact
@@ -190,73 +183,67 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa // start to get the settings
// if the setting not exist, leave the dialog box blank
- if(!DBGetContactSettingString(hContact,WEATHERPROTONAME,"ID",&dbv))
- {
- SetDlgItemTextA(hwndDlg,IDC_ID,dbv.pszVal);
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_ID, dbv.ptszVal);
// check if the station is a default station
- if (!strcmp(dbv.pszVal, opt.Default))
- CheckDlgButton(hwndDlg, IDC_DEFA, TRUE);
- else CheckDlgButton(hwndDlg, IDC_DEFA, FALSE);
+ CheckDlgButton(hwndDlg, IDC_DEFA, _tcscmp(dbv.ptszVal, opt.Default) != 0);
DBFreeVariant(&dbv);
}
- if(!DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Nick",&dbv))
- {
- SetDlgItemText(hwndDlg,IDC_NAME,dbv.ptszVal);
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_NAME, dbv.ptszVal);
DBFreeVariant(&dbv);
}
- if(!DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Log",&dbv))
- {
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Log", &dbv)) {
SetDlgItemText(hwndDlg, IDC_LOG, dbv.ptszVal);
// if the log path is not empty, check the checkbox for external log
if (dbv.ptszVal[0]) CheckDlgButton(hwndDlg, IDC_External, TRUE);
DBFreeVariant(&dbv);
}
// enable/disable the browse button depending on the value of external log checkbox
- EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),(BYTE)IsDlgButtonChecked(hwndDlg,IDC_External));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External));
// other checkbox options
- CheckDlgButton(hwndDlg, IDC_DPop, DBGetContactSettingByte(hContact,WEATHERPROTONAME,"DPopUp",FALSE));
- CheckDlgButton(hwndDlg, IDC_DAutoUpdate, DBGetContactSettingByte(hContact,WEATHERPROTONAME,
- "DAutoUpdate",FALSE));
- CheckDlgButton(hwndDlg, IDC_Internal, DBGetContactSettingByte(hContact,WEATHERPROTONAME,"History",0));
- if (!DBGetContactSettingString(hContact,WEATHERPROTONAME,"InfoURL",&dbv))
- {
- SetDlgItemText(hwndDlg,IDC_IURL,dbv.pszVal);
+ CheckDlgButton(hwndDlg, IDC_DPop, DBGetContactSettingByte(hContact, WEATHERPROTONAME, "DPopUp", FALSE));
+ CheckDlgButton(hwndDlg, IDC_DAutoUpdate, DBGetContactSettingByte(hContact, WEATHERPROTONAME, "DAutoUpdate", FALSE));
+ CheckDlgButton(hwndDlg, IDC_Internal, DBGetContactSettingByte(hContact, WEATHERPROTONAME, "History", 0));
+
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "InfoURL", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_IURL, dbv.ptszVal);
DBFreeVariant(&dbv);
}
- if (!DBGetContactSettingString(hContact,WEATHERPROTONAME,"MapURL",&dbv))
- {
- SetDlgItemText(hwndDlg,IDC_MURL,dbv.pszVal);
+ if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "MapURL", &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_MURL, dbv.ptszVal);
DBFreeVariant(&dbv);
}
// display the dialog box and free memory
- Utils_RestoreWindowPositionNoMove(hwndDlg,NULL,WEATHERPROTONAME,"EditSetting_");
- ShowWindow(hwndDlg,SW_SHOW);
+ Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, WEATHERPROTONAME, "EditSetting_");
+ ShowWindow(hwndDlg, SW_SHOW);
break;
case WM_COMMAND:
wndData = (CntSetWndDataType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
hContact = wndData ? wndData->hContact : NULL;
- switch(LOWORD(wParam))
- {
+ switch(LOWORD(wParam)) {
case IDC_ID:
// check if there are 2 parts in the ID (svc/id) seperated by "/"
// if not, don't let user change the setting
- GetDlgItemText(hwndDlg,IDC_ID,str,sizeof(str));
- chop = strstr(str, "/");
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ chop = _tcsstr(str, _T("/"));
if (chop == NULL)
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHANGE),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE);
else
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHANGE),TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), TRUE);
break;
+
case IDC_NAME:
// check if station name is entered
// if not, don't let user change the setting
- GetDlgItemText(hwndDlg,IDC_NAME,str,sizeof(str));
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHANGE),str[0] != 0);
+ GetDlgItemText(hwndDlg, IDC_NAME, str, SIZEOF(str));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), str[0] != 0);
break;
+
case IDC_GETNAME:
{
// the button for getting station name from the internet
@@ -265,23 +252,21 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa if (!CheckSearch()) return TRUE; // don't download if update is in progress
// get the weather update data using the string in the ID field
- GetDlgItemText(hwndDlg,IDC_ID,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
GetSvc(str);
sData = GetWIData(str);
- GetDlgItemText(hwndDlg,IDC_ID,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
GetID(str);
// if ID search is available, do it
- if (sData->IDSearch.Available)
- {
- char *szData = NULL;
+ if (sData->IDSearch.Available) {
+ TCHAR *szData = NULL;
// load the page
- wsprintf(loc, sData->IDSearch.SearchURL, str);
+ wsprintfA(loc, sData->IDSearch.SearchURL, str);
str[0] = 0;
- if (InternetDownloadFile(loc, NULL, &szData) == 0)
- {
- char *szInfo = szData;
- char* search = strstr(szInfo, sData->IDSearch.NotFoundStr);
+ if (InternetDownloadFile(loc, NULL, &szData) == 0) {
+ TCHAR *szInfo = szData;
+ TCHAR* search = _tcsstr(szInfo, sData->IDSearch.NotFoundStr);
// if the page is found (ie. valid ID), get the name of the city
if (search == NULL)
@@ -293,35 +278,35 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa NetlibHttpDisconnect();
}
// give no station name but only ID if the search is unavailable
- if (str[0] != 0) SetDlgItemText(hwndDlg,IDC_NAME,str);
+ if (str[0] != 0) SetDlgItemText(hwndDlg, IDC_NAME, str);
break;
}
case IDC_External:
// enable/disable the borwse button depending if the external log is enabled
- EnableWindow(GetDlgItem(hwndDlg,IDC_BROWSE),(BYTE)IsDlgButtonChecked(hwndDlg,IDC_External));
- if (!(BYTE)IsDlgButtonChecked(hwndDlg,IDC_External)) return TRUE;
+ EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External));
+ if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) return TRUE;
case IDC_BROWSE: // fall through
// browse for the external log file
- GetDlgItemText(hwndDlg,IDC_LOG,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str));
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwndDlg;
ofn.lpstrFile = str;
- ofn.nMaxFile = sizeof(str);
+ ofn.nMaxFile = SIZEOF(str);
// set filters
- strcpy(filter,Translate("Text Files"));
- strcat(filter," (*.txt)");
- pfilter=filter+strlen(filter)+1;
- strcpy(pfilter,"*.txt");
- pfilter=pfilter+strlen(pfilter)+1;
- strcpy(pfilter,Translate("All Files"));
- strcat(pfilter," (*.*)");
- pfilter=pfilter+strlen(pfilter)+1;
- strcpy(pfilter,"*.*");
- pfilter=pfilter+strlen(pfilter)+1;
- *pfilter='\0';
+ _tcscpy(filter, TranslateT("Text Files"));
+ _tcscat(filter, _T(" (*.txt)"));
+ pfilter = filter + _tcslen(filter)+1;
+ _tcscpy(pfilter, _T("*.txt"));
+ pfilter = pfilter + _tcslen(pfilter)+1;
+ _tcscpy(pfilter, TranslateT("All Files"));
+ _tcscat(pfilter, _T(" (*.*)"));
+ pfilter = pfilter + _tcslen(pfilter)+1;
+ _tcscpy(pfilter, _T("*.*"));
+ pfilter = pfilter + _tcslen(pfilter)+1;
+ *pfilter = '\0';
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
@@ -330,51 +315,47 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa ofn.Flags = OFN_PATHMUSTEXIST;
// Display a Open dialog box and put the file name on the dialog
- if(GetOpenFileName(&ofn))
- SetDlgItemText(hwndDlg,IDC_LOG,ofn.lpstrFile);
+ if (GetOpenFileName(&ofn))
+ SetDlgItemText(hwndDlg, IDC_LOG, ofn.lpstrFile);
// if there is no log file specified, disable external logging
- EnableWindow(GetDlgItem(hwndDlg,IDC_CHANGE),ofn.lpstrFile[0] != 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), ofn.lpstrFile[0] != 0);
break;
case IDC_VIEW1:
// view the page for more info
- GetDlgItemText(hwndDlg,IDC_IURL,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_IURL, str, SIZEOF(str));
if (str[0] == 0) return TRUE;
- GetDlgItemText(hwndDlg,IDC_ID,str2,sizeof(str2));
- GetID(str2);
- wsprintf(loc, str, str2);
- CallService(MS_UTILS_OPENURL, opt.NewBrowserWin, (WPARAM)loc);
+ GetDlgItemText(hwndDlg, IDC_ID, str2, SIZEOF(str2));
+ OpenUrl(str, str2);
break;
case IDC_VIEW2:
// view the page for weather map
- GetDlgItemText(hwndDlg,IDC_MURL,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_MURL, str, SIZEOF(str));
if (str[0] == 0) return TRUE;
- GetDlgItemText(hwndDlg,IDC_ID,str2,sizeof(str2));
- GetID(str2);
- wsprintf(loc, str, str2);
- CallService(MS_UTILS_OPENURL, opt.NewBrowserWin, (WPARAM)loc);
+ GetDlgItemText(hwndDlg, IDC_ID, str2, SIZEOF(str2));
+ OpenUrl(str, str2);
break;
case IDC_RESET1:
// reset the more info url to service default
- GetDlgItemText(hwndDlg,IDC_ID,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
GetSvc(str);
sData = GetWIData(str);
- SetDlgItemText(hwndDlg,IDC_IURL,sData->DefaultURL);
+ SetDlgItemTextA(hwndDlg, IDC_IURL, sData->DefaultURL);
break;
case IDC_RESET2:
// reset the weathe map url to service default
- GetDlgItemText(hwndDlg,IDC_ID,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
GetSvc(str);
sData = GetWIData(str);
- SetDlgItemText(hwndDlg,IDC_MURL,sData->DefaultMap);
+ SetDlgItemText(hwndDlg, IDC_MURL, sData->DefaultMap);
break;
case IDC_SVCINFO:
// display the information of the ini file used by the weather station
- GetDlgItemText(hwndDlg,IDC_ID,str,sizeof(str));
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
GetSvc(str);
GetINIInfo(str);
break;
@@ -382,36 +363,36 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa case IDC_CHANGE:
// temporary disable the protocol while applying the change
// start writing the new settings to database
- GetDlgItemText(hwndDlg,IDC_ID,str,sizeof(str));
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "ID", str);
- if ((BYTE)IsDlgButtonChecked(hwndDlg,IDC_DEFA)) { // if default station is set
- strcpy(opt.Default, str);
+ GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "ID", str);
+ if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFA)) { // if default station is set
+ _tcscpy(opt.Default, str);
opt.DefStn = hContact;
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default);
}
- GetDlgItemText(hwndDlg,IDC_NAME,city,sizeof(city));
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "Nick", city);
- wsprintf(str2, Translate("Current weather information for %s."), city);
- if ((BYTE)IsDlgButtonChecked(hwndDlg,IDC_External))
- {
- GetDlgItemText(hwndDlg,IDC_LOG,str,sizeof(str));
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "Log", str);
+ GetDlgItemText(hwndDlg, IDC_NAME, city, SIZEOF(city));
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "Nick", city);
+ wsprintf(str2, TranslateT("Current weather information for %s."), city);
+ if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) {
+ GetDlgItemText(hwndDlg, IDC_LOG, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "Log", str);
}
- else
- DBDeleteContactSetting(hContact, WEATHERPROTONAME, "Log");
- GetDlgItemTextA(hwndDlg,IDC_IURL,str,sizeof(str));
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "InfoURL", str);
- GetDlgItemTextA(hwndDlg,IDC_MURL,str,sizeof(str));
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "MapURL", str);
+ else DBDeleteContactSetting(hContact, WEATHERPROTONAME, "Log");
+
+ GetDlgItemText(hwndDlg, IDC_IURL, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "InfoURL", str);
+
+ GetDlgItemText(hwndDlg, IDC_MURL, str, SIZEOF(str));
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "MapURL", str);
DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE);
DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE);
AvatarDownloaded(hContact);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "About", str2);
- DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"History",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_Internal));
- DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"Overwrite",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_Overwrite));
- DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"File",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_External));
- DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"DPopUp",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_DPop));
- DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"DAutoUpdate",(BYTE)IsDlgButtonChecked(hwndDlg,IDC_DAutoUpdate));
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "About", str2);
+ DBWriteContactSettingByte(hContact, WEATHERPROTONAME, "History", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Internal));
+ DBWriteContactSettingByte(hContact, WEATHERPROTONAME, "Overwrite", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Overwrite));
+ DBWriteContactSettingByte(hContact, WEATHERPROTONAME, "File", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External));
+ DBWriteContactSettingByte(hContact, WEATHERPROTONAME, "DPopUp", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DPop));
+ DBWriteContactSettingByte(hContact, WEATHERPROTONAME, "DAutoUpdate", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DAutoUpdate));
// re-enable the protocol and update the data for the station
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", "None");
@@ -439,29 +420,27 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
WindowList_Remove(hWindowList, hwndDlg);
- Utils_SaveWindowPosition(hwndDlg,NULL,WEATHERPROTONAME,"EditSetting_");
+ Utils_SaveWindowPosition(hwndDlg, NULL, WEATHERPROTONAME, "EditSetting_");
break;
}
return FALSE;
}
-//============ CONTACT DELETION ============
+// == == == == == == CONTACT DELETION == == == == == ==
// when a contact is deleted, make sure some other contact take over the default station
// wParam = deleted contact
-int ContactDeleted(WPARAM wParam,LPARAM lParam)
+int ContactDeleted(WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
-
- if(!IsMyContact((HANDLE)wParam)) return 0;
+ if (!IsMyContact((HANDLE)wParam))
+ return 0;
removeWindow((HANDLE)wParam);
// exit this function if it is not default station
- if (!DBGetContactSettingString((HANDLE)wParam, WEATHERPROTONAME, "ID", &dbv))
- {
- if (strcmp(dbv.pszVal, opt.Default))
- {
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingTString((HANDLE)wParam, WEATHERPROTONAME, "ID", &dbv)) {
+ if ( _tcscmp(dbv.ptszVal, opt.Default)) {
DBFreeVariant(&dbv);
return 0;
}
@@ -469,42 +448,36 @@ int ContactDeleted(WPARAM wParam,LPARAM lParam) }
// now the default station is deleted, try to get a new one
- {
- // start looking for other weather stations
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- while(hContact)
- {
- if(IsMyContact(hContact))
- {
- if (!DBGetContactSettingString(hContact, WEATHERPROTONAME, "ID", &dbv))
- {
- // if the station is not a default station, set it as the new default station
- // this is the first weather station encountered from the search
- if (strcmp(opt.Default, dbv.pszVal))
- {
- strcpy(opt.Default, dbv.pszVal);
- opt.DefStn = hContact;
+
+ // start looking for other weather stations
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ while(hContact) {
+ if (IsMyContact(hContact)) {
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ // if the station is not a default station, set it as the new default station
+ // this is the first weather station encountered from the search
+ if ( _tcscmp(opt.Default, dbv.ptszVal)) {
+ _tcscpy(opt.Default, dbv.ptszVal);
+ opt.DefStn = hContact;
+ DBFreeVariant(&dbv);
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ TCHAR str[255];
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
DBFreeVariant(&dbv);
- if (!DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Nick",&dbv))
- {
- TCHAR str[255];
- mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
- DBFreeVariant(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
- }
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "Default", opt.Default);
- return 0; // exit this function quickly
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
}
- DBFreeVariant(&dbv);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ return 0; // exit this function quickly
}
+ DBFreeVariant(&dbv);
}
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
- // got here if no more weather station left
- opt.Default[0] = 0; // no default station
- opt.DefStn = NULL;
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
+ // got here if no more weather station left
+ opt.Default[0] = 0; // no default station
+ opt.DefStn = NULL;
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default);
return 0;
}
diff --git a/protocols/Weather/weather_conv.cpp b/protocols/Weather/weather_conv.cpp index 7679a6c440..1cf003e8e2 100644 --- a/protocols/Weather/weather_conv.cpp +++ b/protocols/Weather/weather_conv.cpp @@ -29,7 +29,7 @@ string conversions, display text parsing, etc // see if a string is a number
// s = the string to be determined
// return value = true if the string is a number, false if it isn't
-BOOL is_number(char *s)
+BOOL is_number(TCHAR *s)
{
BOOL tag = FALSE;
// looking character by character
@@ -47,7 +47,7 @@ BOOL is_number(char *s) return FALSE;
}
-static void numToStr(double num, char* str)
+static void numToStr(double num, TCHAR* str)
{
int i = (int)(num * (opt.NoFrac ? 10 : 100));
int u = abs(i);
@@ -55,21 +55,18 @@ static void numToStr(double num, char* str) int r = u % 10;
int w = u / 10 + (r >= 5);
- if (opt.NoFrac)
- {
+ if (opt.NoFrac)
r = 0;
- }
- else
- {
+ else {
r = w % 10;
w /= 10;
}
if (i < 0 && (w || r)) *(str++) = '-';
if (r)
- sprintf(str, "%i.%i", w, r);
+ wsprintf(str, _T("%i.%i"), w, r);
else
- sprintf(str, "%i", w);
+ wsprintf(str, _T("%i"), w);
}
//============ UNIT CONVERSIONS ============
@@ -78,53 +75,50 @@ static void numToStr(double num, char* str) // tempchar = the string containing the temperature value
// unit = the unit for temperature
// return value = the converted temperature with degree sign and unit; if fails, return N/A
-void GetTemp(char *tempchar, char *unit, char* str)
+void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
{
// unit can be C, F
double temp;
- char tstr[20];
+ TCHAR tstr[20];
TrimString(tempchar);
if (tempchar[0] == '-' && tempchar[1] == ' ')
- memmove(&tempchar[1], &tempchar[2], strlen(&tempchar[2])+1);
+ memmove(&tempchar[1], &tempchar[2], sizeof(TCHAR)*(_tcslen(&tempchar[2])+1));
// quit if the value obtained is N/A or not a number
- if (!strcmp(tempchar, NODATA) || !strcmp(tempchar, "N/A"))
- {
- strcpy(str, tempchar);
+ if ( !_tcscmp(tempchar, NODATA) || !_tcscmp(tempchar, _T("N/A"))) {
+ _tcscpy(str, tempchar);
return;
}
- if (!is_number(tempchar))
- {
- strcpy(str, NODATA);
+ if (!is_number(tempchar)) {
+ _tcscpy(str, NODATA);
return;
}
// convert the string to an integer
- temp = atof(tempchar);
+ temp = _ttof(tempchar);
// convert all to F first
- if (!_stricmp(unit, "C")) temp = (temp*9/5)+32;
- else if (!_stricmp(unit, "K")) temp = ((temp-273.15)*9/5)+32;
+ if (!_tcsicmp(unit, _T("C"))) temp = (temp*9/5)+32;
+ else if (!_tcsicmp(unit, _T("K"))) temp = ((temp-273.15)*9/5)+32;
// convert to apporiate unit
- switch (opt.tUnit)
- {
+ switch (opt.tUnit) {
case 1:
// rounding
numToStr((temp-32)/9*5, tstr);
if (opt.DoNotAppendUnit)
- sprintf(str, "%s", tstr);
+ wsprintf(str, _T("%s"), tstr);
else
- sprintf(str, "%s%sC", tstr, opt.DegreeSign);
+ wsprintf(str, _T("%s%sC"), tstr, opt.DegreeSign);
break;
case 2:
numToStr(temp, tstr);
if (opt.DoNotAppendUnit)
- sprintf(str, "%s", tstr);
+ wsprintf(str, _T("%s"), tstr);
else
- sprintf(str, "%s%sF", tstr, opt.DegreeSign);
+ wsprintf(str, _T("%s%sF"), tstr, opt.DegreeSign);
break;
}
}
@@ -133,7 +127,7 @@ void GetTemp(char *tempchar, char *unit, char* str) // tempchar = the string containing the pressure value
// unit = the unit for pressure
// return value = the converted pressure with unit; if fail, return the original string
-void GetPressure(char *tempchar, char *unit, char* str)
+void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
{
// unit can be kPa, hPa, mb, in, mm, torr
double tempunit = 0, output;
@@ -141,48 +135,46 @@ void GetPressure(char *tempchar, char *unit, char* str) // convert the string to a floating point number (always positive)
// if it end up with 0, then it's not a number, return the original string and quit
- output = atof(tempchar);
- if (output == 0)
- {
- strcpy(str, tempchar);
+ output = _ttof(tempchar);
+ if (output == 0) {
+ _tcscpy(str, tempchar);
return;
}
// convert all to mb first
- if (!_stricmp(unit, "KPA"))
+ if (!_tcsicmp(unit, _T("KPA")))
tempunit = (double)output * 10;
- else if (!_stricmp(unit, "HPA"))
+ else if (!_tcsicmp(unit, _T("HPA")))
tempunit = (double)output;
- else if (!_stricmp(unit, "MB"))
+ else if (!_tcsicmp(unit, _T("MB")))
tempunit = (double)output;
- else if (!_stricmp(unit, "IN"))
+ else if (!_tcsicmp(unit, _T("IN")))
tempunit = (double)output * 33.86388;
- else if (!_stricmp(unit, "MM"))
+ else if (!_tcsicmp(unit, _T("MM")))
tempunit = (double)output * 1.33322;
- else if (!_stricmp(unit, "TORR"))
+ else if (!_tcsicmp(unit, _T("TORR")))
tempunit = (double)output * 1.33322;
// convert to apporiate unit
- switch (opt.pUnit)
- {
+ switch (opt.pUnit) {
case 1:
intunit = (int)(tempunit + 0.5);
- wsprintf(str, "%i.%i %s", intunit/10, intunit%10, opt.DoNotAppendUnit ? "" : Translate("kPa"));
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
break;
case 2:
intunit = (int)(tempunit + 0.5);
- wsprintf(str, "%i %s", intunit, opt.DoNotAppendUnit ? "" : Translate("mb"));
+ wsprintf(str, _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
break;
case 3:
intunit = (int)((tempunit*10 / 33.86388) + 0.5);
- wsprintf(str, "%i.%i %s", intunit/10, intunit%10, opt.DoNotAppendUnit ? "" : Translate("in"));
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
break;
case 4:
intunit = (int)((tempunit*10 / 1.33322) + 0.5);
- wsprintf(str, "%i.%i %s", intunit/10, intunit%10, opt.DoNotAppendUnit ? "" : Translate("mm"));
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
break;
default:
- strcpy(str, tempchar);
+ _tcscpy(str, tempchar);
break;
}
@@ -191,48 +183,48 @@ void GetPressure(char *tempchar, char *unit, char* str) // speed conversion
// tempchar = the string containing the speed value
// unit = the unit for speed
-// return value = the converted speed with unit; if fail, return ""
-void GetSpeed(char *tempchar, char *unit, char *str)
+// return value = the converted speed with unit; if fail, return _T(""
+void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
{
// unit can be km/h, mph, m/s, knots
double tempunit;
- char tstr[20];
+ TCHAR tstr[20];
str[0] = 0;
// convert the string into an integer (always positive)
- // if the result is 0, then the string is not a number, return ""
- tempunit = atof(tempchar);
- if (tempunit == 0 && tempchar[0] != '0') return;
+ // if the result is 0, then the string is not a number, return _T(""
+ tempunit = _ttof(tempchar);
+ if (tempunit == 0 && tempchar[0] != '0')
+ return;
// convert all to m/s first
- if (!_stricmp(unit, "KM/H"))
+ if (!_tcsicmp(unit, _T("KM/H")))
tempunit /= 3.6;
-// else if (!_stricmp(unit, "M/S"))
+// else if (!_tcsicmp(unit, _T("M/S"))
// tempunit = tempunit;
- else if (!_stricmp(unit, "MPH"))
+ else if (!_tcsicmp(unit, _T("MPH")))
tempunit *= 0.44704;
- else if (!_stricmp(unit, "KNOTS"))
+ else if (!_tcsicmp(unit, _T("KNOTS")))
tempunit *= 0.514444;
// convert to apporiate unit
- switch (opt.wUnit)
- {
+ switch (opt.wUnit) {
case 1:
numToStr(tempunit * 3.6, tstr);
- sprintf(str, "%s %s", tstr, opt.DoNotAppendUnit ? "" : Translate("km/h"));
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
break;
case 2:
numToStr(tempunit, tstr);
- sprintf(str, "%s %s", tstr, opt.DoNotAppendUnit ? "" : Translate("m/s"));
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
break;
case 3:
numToStr(tempunit / 0.44704, tstr);
- sprintf(str, "%s %s", tstr, opt.DoNotAppendUnit ? "" : Translate("mph"));
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
break;
case 4:
numToStr(tempunit / 0.514444, tstr);
- sprintf(str, "%s %s", tstr, opt.DoNotAppendUnit ? "" : Translate("knots"));
+ wsprintf(str, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
break;
}
}
@@ -241,7 +233,7 @@ void GetSpeed(char *tempchar, char *unit, char *str) // tempchar = the string containing the distance value
// unit = the unit for distance
// return value = the converted distance with unit; if fail, return original string
-void GetDist(char *tempchar, char *unit, char *str)
+void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
{
// unit can be km, miles
double tempunit = 0, output;
@@ -249,32 +241,30 @@ void GetDist(char *tempchar, char *unit, char *str) // convert the string to a floating point number (always positive)
// if it end up with 0, then it's not a number, return the original string and quit
- output = atof(tempchar);
- if (output == 0)
- {
- strcpy(str, tempchar);
+ output = _ttof(tempchar);
+ if (output == 0) {
+ _tcscpy(str, tempchar);
return;
}
// convert all to km first
- if (!_stricmp(unit, "KM"))
+ if (!_tcsicmp(unit, _T("KM")))
tempunit = (double)output;
- else if (!_stricmp(unit, "MILES"))
+ else if (!_tcsicmp(unit, _T("MILES")))
tempunit = (double)output * 1.609;
// convert to apporiate unit
- switch (opt.vUnit)
- {
+ switch (opt.vUnit) {
case 1:
intunit = (int)((tempunit*10) + 0.5);
- wsprintf(str, "%i.%i %s", intunit/10, intunit%10, opt.DoNotAppendUnit ? "" : Translate("km"));
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
break;
case 2:
intunit = (int)((tempunit*10 / 1.609) + 0.5);
- wsprintf(str, "%i.%i %s", intunit/10, intunit%10, opt.DoNotAppendUnit ? "" : Translate("miles"));
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
break;
default:
- strcpy(str, tempchar);
+ _tcscpy(str, tempchar);
break;
}
}
@@ -283,7 +273,7 @@ void GetDist(char *tempchar, char *unit, char *str) // tempchar = the string containing the elevation value
// unit = the unit for elevation
// return value = the converted elevation with unit; if fail, return original string
-void GetElev(char *tempchar, char *unit, char *str)
+void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
{
// unit can be ft, m
double tempunit = 0, output;
@@ -291,32 +281,31 @@ void GetElev(char *tempchar, char *unit, char *str) // convert the string to a floating point number (always positive)
// if it end up with 0, then it's not a number, return the original string and quit
- output = atof(tempchar);
- if (output == 0)
- {
- strcpy(str, tempchar);
+ output = _ttof(tempchar);
+ if (output == 0) {
+ _tcscpy(str, tempchar);
return;
}
// convert all to m first
- if (!_stricmp(unit, "M"))
+ if (!_tcsicmp(unit, _T("M")))
tempunit = (double)output;
- else if (!_stricmp(unit, "FT"))
+ else if (!_tcsicmp(unit, _T("FT")))
tempunit = (double)output / 3.28;
// convert to apporiate unit
switch (opt.eUnit) {
- case 1:
- intunit = (int)((tempunit*10 * 3.28) + 0.5);
- wsprintf(str, "%i.%i %s", intunit/10, intunit%10, opt.DoNotAppendUnit ? "" : Translate("ft"));
- break;
- case 2:
- intunit = (int)((tempunit*10) + 0.5);
- wsprintf(str, "%i.%i %s", intunit/10, intunit%10, opt.DoNotAppendUnit ? "" : Translate("m"));
- break;
- default:
- strcpy(str, tempchar);
- break;
+ case 1:
+ intunit = (int)((tempunit*10 * 3.28) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
+ break;
+ case 2:
+ intunit = (int)((tempunit*10) + 0.5);
+ wsprintf(str, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
+ break;
+ default:
+ _tcscpy(str, tempchar);
+ break;
}
}
@@ -326,123 +315,93 @@ void GetElev(char *tempchar, char *unit, char *str) // the description may be different between different sources
// cond = the string for weather condition
// return value = status for the icon (ONLINE, OFFLINE, etc)
-WORD GetIcon(const char* cond, WIDATA *Data)
+
+static const TCHAR *statusStr[10] = { _T("Lightning"), _T("Fog"), _T("Snow Shower"), _T("Snow"), _T("Rain Shower"), _T("Rain"), _T("Partly Cloudy"), _T("Cloudy"), _T("Sunny"), _T("N/A") };
+static const WORD statusValue[10] = { LIGHT, FOG, SSHOWER, SNOW, RSHOWER, RAIN, PCLOUDY, CLOUDY, SUNNY, NA };
+
+WORD GetIcon(const TCHAR* cond, WIDATA *Data)
{
int i;
- static const
- char *statusStr[10] =
- {
- "Lightning",
- "Fog",
- "Snow Shower",
- "Snow",
- "Rain Shower",
- "Rain",
- "Partly Cloudy",
- "Cloudy",
- "Sunny",
- "N/A"
- };
-
- static const
- WORD statusValue[10] =
- {
- LIGHT,
- FOG,
- SSHOWER,
- SNOW,
- RSHOWER,
- RAIN,
- PCLOUDY,
- CLOUDY,
- SUNNY,
- NA
- };
-
// set the icon using ini
- for (i=0; i<10; i++) {
- if (IsContainedInCondList(cond, &Data->CondList[i]))
+ for (i=0; i<10; i++)
+ if ( IsContainedInCondList(cond, &Data->CondList[i]))
return statusValue[i];
- }
// internal detection
if (
- strstr(cond, "mainy sunny") != NULL ||
- strstr(cond, "mainy clear") != NULL ||
- strstr(cond, "partly cloudy") != NULL ||
- strstr(cond, "mostly") != NULL ||
- strstr(cond, "clouds") != NULL) {
+ _tcsstr(cond, _T("mainy sunny")) != NULL ||
+ _tcsstr(cond, _T("mainy clear")) != NULL ||
+ _tcsstr(cond, _T("partly cloudy")) != NULL ||
+ _tcsstr(cond, _T("mostly")) != NULL ||
+ _tcsstr(cond, _T("clouds")) != NULL) {
return PCLOUDY;
}
else if (
- strstr(cond, "sunny") != NULL ||
- strstr(cond, "clear") != NULL ||
- strstr(cond, "fair") != NULL) {
+ _tcsstr(cond, _T("sunny")) != NULL ||
+ _tcsstr(cond, _T("clear")) != NULL ||
+ _tcsstr(cond, _T("fair")) != NULL) {
return SUNNY;
}
else if (
- strstr(cond, "thunder") != NULL ||
- strstr(cond, "t-storm") != NULL) {
+ _tcsstr(cond, _T("thunder")) != NULL ||
+ _tcsstr(cond, _T("t-storm")) != NULL) {
return LIGHT;
}
else if (
- strstr(cond, "cloud") != NULL ||
- strstr(cond, "overcast") != NULL) {
+ _tcsstr(cond, _T("cloud")) != NULL ||
+ _tcsstr(cond, _T("overcast")) != NULL) {
return CLOUDY;
}
else if (
- strstr(cond, "fog") != NULL ||
- strstr(cond, "mist") != NULL ||
- strstr(cond, "smoke") != NULL ||
- strstr(cond, "sand") != NULL ||
- strstr(cond, "dust") != NULL ||
- strstr(cond, "haze") != NULL) {
+ _tcsstr(cond, _T("fog")) != NULL ||
+ _tcsstr(cond, _T("mist")) != NULL ||
+ _tcsstr(cond, _T("smoke")) != NULL ||
+ _tcsstr(cond, _T("sand")) != NULL ||
+ _tcsstr(cond, _T("dust")) != NULL ||
+ _tcsstr(cond, _T("haze")) != NULL) {
return FOG;
}
else if (
- (strstr(cond, "shower") != NULL && strstr(cond, "snow") != NULL) ||
- strstr(cond, "flurries") != NULL) {
+ (_tcsstr(cond, _T("shower")) != NULL && _tcsstr(cond, _T("snow")) != NULL) ||
+ _tcsstr(cond, _T("flurries")) != NULL) {
return SSHOWER;
}
else if (
- strstr(cond, "rain shower") != NULL ||
- strstr(cond, "shower") != NULL)
+ _tcsstr(cond, _T("rain shower")) != NULL ||
+ _tcsstr(cond, _T("shower")) != NULL)
{
return RSHOWER;
}
else if (
- strstr(cond, "snow") != NULL ||
- strstr(cond, "ice") != NULL ||
- strstr(cond, "freezing") != NULL ||
- strstr(cond, "wintry") != NULL) {
+ _tcsstr(cond, _T("snow")) != NULL ||
+ _tcsstr(cond, _T("ice")) != NULL ||
+ _tcsstr(cond, _T("freezing")) != NULL ||
+ _tcsstr(cond, _T("wintry")) != NULL) {
return SNOW;
}
else if (
- strstr(cond, "drizzle") != NULL ||
- strstr(cond, "rain") != NULL)
+ _tcsstr(cond, _T("drizzle")) != NULL ||
+ _tcsstr(cond, _T("rain")) != NULL)
{
return RAIN;
}
// set the icon using langpack
- for (i=0; i<9; i++)
- {
- char LangPackStr[64];
- char LangPackStr1[128];
+ for (i=0; i < 9; i++) {
+ TCHAR LangPackStr[64], LangPackStr1[128];
int j = 0;
- do
- {
+ do {
j++;
- // using the format "# Weather <condition name> <counter> #"
- mir_snprintf(LangPackStr, sizeof(LangPackStr), "# Weather %s %i #", statusStr[i], j);
- mir_snprintf(LangPackStr1, sizeof(LangPackStr1), "%s", Translate(LangPackStr));
- CharLowerBuff(LangPackStr1, (DWORD)strlen(LangPackStr1));
- if (strstr(cond, LangPackStr1) != NULL)
+ // using the format _T("# Weather <condition name> <counter> #"
+ mir_sntprintf(LangPackStr, SIZEOF(LangPackStr), _T("# Weather %s %i #"), statusStr[i], j);
+ mir_sntprintf(LangPackStr1, SIZEOF(LangPackStr1), _T("%s"), TranslateTS(LangPackStr));
+ CharLowerBuff(LangPackStr1, _tcslen(LangPackStr1));
+ if (_tcsstr(cond, LangPackStr1) != NULL)
return statusValue[i];
// loop until the translation string exists (ie, the translated string is differ from original)
}
- while (strcmp(Translate(LangPackStr), LangPackStr));
+ while ( _tcscmp(TranslateTS(LangPackStr), LangPackStr));
}
return NA;
@@ -451,59 +410,62 @@ WORD GetIcon(const char* cond, WIDATA *Data) //============ STRING CONVERSIONS ============
// this function convert the string to the format with 1 upper case followed by lower case char
-void CaseConv(char *str)
+void CaseConv(TCHAR *str)
{
- char *pstr;
+ TCHAR *pstr;
BOOL nextUp = TRUE;
- CharLowerBuff(str, (DWORD)strlen(str));
- for(pstr=str; *pstr; pstr++)
- {
+ CharLowerBuff(str, _tcslen(str));
+ for(pstr = str; *pstr; pstr++) {
if (*pstr==' ' || *pstr=='-')
nextUp = TRUE;
- else
- {
- unsigned ch = *(unsigned char*)pstr;
- if (nextUp) *pstr = (char)(unsigned)CharUpper((LPSTR)ch);
+ else {
+ TCHAR ch = *(TCHAR*)pstr;
+ if (nextUp)
+ *pstr = ( TCHAR )CharUpper((LPTSTR)ch);
nextUp = FALSE;
- }
- }
-}
+} } }
// the next 2 functions are copied from miranda source
// str = the string to modify
+
void TrimString(char *str)
{
size_t len, start;
len = strlen(str);
while(len && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
- for(start=0; (unsigned char)str[start]<=' ' && str[start]; start++);
+ for(start=0; (unsigned char)str[start] <= ' ' && str[start]; start++);
memmove(str, str+start, len-start+1);
}
+void TrimString(WCHAR *str)
+{
+ size_t len, start;
+
+ len = wcslen(str);
+ while(len && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
+ for(start=0; (unsigned char)str[start] <= ' ' && str[start]; start++);
+ memmove(str, str+start, (len-start+1)*sizeof(WCHAR));
+}
+
// convert \t to tab and \n to linefeed
void ConvertBackslashes(char *str)
{
char *pstr;
- for(pstr=str;*pstr;pstr=CharNext(pstr))
- {
- if(*pstr=='\\')
- {
- switch(pstr[1])
- {
- case 'n': *pstr='\n'; break;
- case 't': *pstr='\t'; break;
- default: *pstr=pstr[1]; break;
+ for( pstr=str; *pstr; pstr = CharNextA(pstr)) {
+ if (*pstr=='\\') {
+ switch(pstr[1]) {
+ case 'n': *pstr='\n'; break;
+ case 't': *pstr='\t'; break;
+ default: *pstr=pstr[1]; break;
}
- memmove(pstr+1,pstr+2,strlen(pstr+2)+1);
- }
- }
-}
+ memmove(pstr+1, pstr+2, strlen(pstr+2)+1);
+} } }
-// replace spaces with "%20"
+// replace spaces with _T("%20"
// dis = original string
-// return value = the modified string with space -> "%20"
+// return value = the modified string with space -> _T("%20"
char *GetSearchStr(char *dis)
{
char *pstr = dis;
@@ -513,7 +475,7 @@ char *GetSearchStr(char *dis) if (*pstr == ' ')
{
memmove(pstr+3, pstr+1, len);
- memcpy(pstr, "%20", 3);
+ memcpy(pstr, _T("%20"), 3);
pstr += 2;
}
pstr++;
@@ -528,9 +490,10 @@ char *GetSearchStr(char *dis) // w = WEATHERINFO data to be parsed
// dis = the string to parse
// return value = the parsed string
-char* GetDisplay(WEATHERINFO *w, const char *dis, char* str)
+TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str)
{
- char lpzDate[32], chr, name[256], temp[2];
+ TCHAR lpzDate[32], chr;
+ char name[256], temp[2];
DBVARIANT dbv;
size_t i;
@@ -538,21 +501,19 @@ char* GetDisplay(WEATHERINFO *w, const char *dis, char* str) str[0] = 0;
// looking character by character
- for (i=0; i<strlen(dis); i++)
- {
+ for (i=0; i < _tcslen(dis); i++) {
// for the escape characters
- if (dis[i] == '\\')
- {
+ if (dis[i] == '\\') {
i++;
chr = dis[i];
- switch (chr)
- {
- case '%': strcat(str, "%"); break;
- case 't': strcat(str, "\t"); break;
- case 'n': strcat(str, "\r\n"); break;
- case '\\': strcat(str, "\\"); break;
- }
+ switch (chr) {
+ case '%': _tcscat(str, _T("%")); break;
+ case 't': _tcscat(str, _T("\t")); break;
+ case 'n': _tcscat(str, _T("\r\n")); break;
+ case '\\': _tcscat(str, _T("\\")); break;
+ }
}
+
// for the % varaibles
else if (dis[i] == '%')
{
@@ -561,62 +522,60 @@ char* GetDisplay(WEATHERINFO *w, const char *dis, char* str) // turn capitalized characters to small case
if (chr < 'a' && chr != '[' && chr != '%') chr = (char)((int)chr + 32);
switch (chr) {
- case 'c': strcat(str, w->cond); break;
+ case 'c': _tcscat(str, w->cond); break;
case 'd': // get the current date
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, lpzDate, sizeof(lpzDate));
- strcat(str, lpzDate); break;
- case 'e': strcat(str, w->dewpoint); break;
- case 'f': strcat(str, w->feel); break;
- case 'h': strcat(str, w->high); break;
- case 'i': strcat(str, w->winddir); break;
- case 'l': strcat(str, w->low); break;
- case 'm': strcat(str, w->humid); break;
- case 'n': strcat(str, w->city); break;
- case 'p': strcat(str, w->pressure); break;
- case 'r': strcat(str, w->sunrise); break;
- case 's': strcat(str, w->id); break;
- case 't': strcat(str, w->temp); break;
+ GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, lpzDate, SIZEOF(lpzDate));
+ _tcscat(str, lpzDate); break;
+ case 'e': _tcscat(str, w->dewpoint); break;
+ case 'f': _tcscat(str, w->feel); break;
+ case 'h': _tcscat(str, w->high); break;
+ case 'i': _tcscat(str, w->winddir); break;
+ case 'l': _tcscat(str, w->low); break;
+ case 'm': _tcscat(str, w->humid); break;
+ case 'n': _tcscat(str, w->city); break;
+ case 'p': _tcscat(str, w->pressure); break;
+ case 'r': _tcscat(str, w->sunrise); break;
+ case 's': _tcscat(str, w->id); break;
+ case 't': _tcscat(str, w->temp); break;
case 'u':
- if (strcmp(w->update, NODATA)) strcat(str, w->update);
- else strcat(str, Translate("<unknown time>"));
+ if (_tcscmp(w->update, NODATA)) _tcscat(str, w->update);
+ else _tcscat(str, TranslateT("<unknown time>"));
break;
- case 'v': strcat(str, w->vis); break;
- case 'w': strcat(str, w->wind); break;
- case 'y': strcat(str, w->sunset); break;
- case '%': strcat(str, "%"); break;
+ case 'v': _tcscat(str, w->vis); break;
+ case 'w': _tcscat(str, w->wind); break;
+ case 'y': _tcscat(str, w->sunset); break;
+ case '%': _tcscat(str, _T("%")); break;
case '[': // custom variables
i++;
name[0] = 0;
// read the entire variable name
- while (dis[i] != ']' && i < strlen(dis)) {
- wsprintf(temp, "%c", dis[i++]);
+ while (dis[i] != ']' && i < _tcslen(dis)) {
+ wsprintfA(temp, "%c", dis[i++]);
strcat(name, temp);
}
// access the database to get its value
- if (!DBGetContactSettingString(w->hContact, WEATHERCONDITION, name, &dbv))
- {
- if (dbv.pszVal != Translate(NODATA) && dbv.pszVal != Translate("<Error>"))
- strcat(str, dbv.pszVal);
+ if ( !DBGetContactSettingTString(w->hContact, WEATHERCONDITION, name, &dbv)) {
+ if (dbv.ptszVal != TranslateTS(NODATA) && dbv.ptszVal != TranslateT("<Error>"))
+ _tcscat(str, dbv.ptszVal);
DBFreeVariant(&dbv);
}
break;
}
}
// if the character is not a variable, write the original character to the new string
- else
- {
- wsprintf(temp, "%c", dis[i]);
- strcat(str, temp);
- }
- }
+ else {
+ wsprintf( lpzDate, _T("%c"), dis[i]);
+ _tcscat(str, lpzDate);
+ } }
+
return str;
}
-char svcReturnText[MAX_TEXT_SIZE];
+TCHAR svcReturnText[MAX_TEXT_SIZE];
INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam)
{
WEATHERINFO winfo = LoadWeatherInfo((HANDLE)wParam);
- return (INT_PTR)GetDisplay(&winfo, (char *)lParam, svcReturnText);
+ return (INT_PTR)GetDisplay(&winfo, (TCHAR*)lParam, svcReturnText);
}
//============ ID MANAGEMENT ============
@@ -624,11 +583,9 @@ INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam) // get service data module internal name
// mod/id <- the mod part
// pszID = original 2-part id, return the service internal name
-void GetSvc(char *pszID)
+void GetSvc(TCHAR *pszID)
{
- char *chop;
-
- chop = strstr(pszID, "/");
+ TCHAR *chop = _tcsstr(pszID, _T("/"));
if (chop != NULL) *chop = '\0';
else pszID[0] = 0;
}
@@ -636,12 +593,10 @@ void GetSvc(char *pszID) // get the id use for update without the service internal name
// mod/id <- the id part
// pszID = original 2-part id, return the single part id
-void GetID(char *pszID)
+void GetID(TCHAR *pszID)
{
- char *chop;
-
- chop = strstr(pszID, "/");
- if (chop != NULL) strcpy(pszID, chop+1);
+ TCHAR *chop = _tcsstr(pszID, _T("/"));
+ if (chop != NULL) _tcscpy(pszID, chop+1);
else pszID[0] = 0;
}
@@ -651,11 +606,10 @@ void GetID(char *pszID) // code = the error code obtained when updating weather
// str = the string for the error
-char *GetError(int code)
+TCHAR *GetError(int code)
{
- char *str, str2[100];
- switch (code)
- {
+ TCHAR *str, str2[100];
+ switch (code) {
case 10: str = E10; break;
case 11: str = E11; break;
case 12: str = E12; break;
@@ -682,7 +636,7 @@ char *GetError(int code) case 503: str = E503; break;
case 504: str = E504; break;
default:
- mir_snprintf(str2, sizeof(str2), Translate("HTTP Error %i"), code);
+ mir_sntprintf(str2, SIZEOF(str2), TranslateT("HTTP Error %i"), code);
str = str2;
break;
}
@@ -697,142 +651,12 @@ LPWSTR ConvToUnicode(LPCSTR str2) return res;
}
-typedef BOOL (WINAPI *ft_SetDlgItemTextW) (
- HWND hDlg,
- int nIDDlgItem,
- LPCWSTR lpString
- );
-
-typedef BOOL (WINAPI *ft_SetWindowTextW) (
- HWND hWnd,
- LPCWSTR lpString
- );
-
-typedef UINT (WINAPI *ft_GetDlgItemTextW) (
- HWND hDlg,
- int nIDDlgItem,
- LPWSTR lpString,
- int nMaxCount
- );
-
-static ft_GetDlgItemTextW f_GetDlgItemTextW = NULL;
-static ft_SetDlgItemTextW f_SetDlgItemTextW = NULL;
-static ft_SetWindowTextW f_SetWindowTextW = NULL;
-
unsigned lpcp;
void InitUniConv(void)
{
- HMODULE hUser = GetModuleHandle("user32.dll");
- f_GetDlgItemTextW = (ft_GetDlgItemTextW)GetProcAddress(hUser, "GetDlgItemTextW");
- f_SetDlgItemTextW = (ft_SetDlgItemTextW)GetProcAddress(hUser, "SetDlgItemTextW");
- f_SetWindowTextW = (ft_SetWindowTextW) GetProcAddress(hUser, "SetWindowTextW");
-
lpcp = (unsigned)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
if (lpcp == CALLSERVICE_NOTFOUND || lpcp == GetUserDefaultLangID())
lpcp = CP_ACP;
}
-UINT GetDlgItemTextWth(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount)
-{
- UINT res;
-
- if (lpcp != CP_ACP && f_GetDlgItemTextW != NULL)
- {
- LPWSTR m_psz = ( LPWSTR )mir_alloc(sizeof(WCHAR) * nMaxCount);
- res = f_GetDlgItemTextW(hDlg, nIDDlgItem, m_psz, nMaxCount);
- WideCharToMultiByte( lpcp, 0, m_psz, -1, lpString, nMaxCount, NULL, NULL );
- mir_free(m_psz);
- }
- else
- res = GetDlgItemText(hDlg, nIDDlgItem, lpString, nMaxCount);
-
- return res;
-}
-
-BOOL SetDlgItemTextWth(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
-{
- BOOL res;
-
- if (lpcp != CP_ACP && f_SetDlgItemTextW != NULL)
- {
- LPWSTR m_psz = ConvToUnicode(lpString);
- res = f_SetDlgItemTextW(hDlg, nIDDlgItem, m_psz);
- mir_free(m_psz);
- }
- else
- res = SetDlgItemText(hDlg, nIDDlgItem, lpString);
-
- return res;
-}
-
-BOOL SetWindowTextWth(HWND hWnd, LPCSTR lpString)
-{
- BOOL res;
-
- if (lpcp != CP_ACP && f_SetWindowTextW != NULL)
- {
- LPWSTR m_psz = ConvToUnicode(lpString);
- res = f_SetWindowTextW(hWnd, m_psz);
- mir_free(m_psz);
- }
- else
- res = SetWindowText(hWnd, lpString);
-
- return res;
-}
-
-void ListView_SetItemTextWth(HWND hwndLV, int i, int iSubItem_, LPSTR pszText_)
-{
- LV_ITEM _ms_lvi;
- _ms_lvi.iSubItem = iSubItem_;
-
- if (lpcp != CP_ACP)
- {
- LPWSTR m_psz = ConvToUnicode(pszText_);
- _ms_lvi.pszText = (LPSTR)m_psz;
- SendMessage(hwndLV, LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)&_ms_lvi);
- mir_free(m_psz);
- }
- else
- {
- _ms_lvi.pszText = pszText_;
- SendMessage(hwndLV, LVM_SETITEMTEXTA, (WPARAM)(i), (LPARAM)&_ms_lvi);
- }
-}
-
-int ListView_InsertItemWth(HWND hwnd, LV_ITEM *pitem)
-{
- int res;
- if (lpcp != CP_ACP)
- {
- LPSTR otxt = pitem->pszText;
- LPWSTR m_psz = ConvToUnicode(otxt);
- pitem->pszText = (LPSTR)m_psz;
- res = SendMessage(hwnd, LVM_INSERTITEMW, 0, (LPARAM)pitem);
- mir_free(m_psz);
- pitem->pszText = otxt;
- }
- else
- res = SendMessage(hwnd, LVM_INSERTITEMA, 0, (LPARAM)pitem);
-
- return res;
-}
-
-int ListView_InsertColumnWth(HWND hwnd, int iCol, LV_COLUMN *pitem)
-{
- int res;
- if (lpcp != CP_ACP)
- {
- LPSTR otxt = pitem->pszText;
- LPWSTR m_psz = ConvToUnicode(otxt);
- pitem->pszText = (LPSTR)m_psz;
- res = SendMessage(hwnd, LVM_INSERTCOLUMNW, iCol, (LPARAM)pitem);
- mir_free(m_psz);
- pitem->pszText = otxt;
- }
- else
- res = SendMessage(hwnd, LVM_INSERTCOLUMNA, iCol, (LPARAM)pitem);
-
- return res;
-}
diff --git a/protocols/Weather/weather_data.cpp b/protocols/Weather/weather_data.cpp index 86f051199f..85c87bb972 100644 --- a/protocols/Weather/weather_data.cpp +++ b/protocols/Weather/weather_data.cpp @@ -36,7 +36,7 @@ typedef struct // get station ID from DB
// hContact = the current contact handle
// return value = the string for station ID
-void GetStationID(HANDLE hContact, char* id, size_t idlen)
+void GetStationID(HANDLE hContact, TCHAR* id, size_t idlen)
{
// accessing the database
if (DBGetStaticString(hContact, WEATHERPROTONAME, "ID", id, idlen))
@@ -54,38 +54,38 @@ WEATHERINFO LoadWeatherInfo(HANDLE Change) // obtaining values from the DB
// assuming station ID must exist at all time, but others does not have to
// if the string is not found in database, a value of "N/A" is stored in the field
- GetStationID(Change, winfo.id, sizeof(winfo.id));
-
- if (DBGetStaticString(Change, WEATHERPROTONAME, "Nick", winfo.city, sizeof(winfo.city)))
- strcpy(winfo.city, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Update", winfo.update, sizeof(winfo.update)))
- strcpy(winfo.update, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Condition", winfo.cond, sizeof(winfo.cond)))
- strcpy(winfo.cond, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Temperature", winfo.temp, sizeof(winfo.temp)))
- strcpy(winfo.temp, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "High", winfo.high, sizeof(winfo.high)))
- strcpy(winfo.high, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Low", winfo.low, sizeof(winfo.low)))
- strcpy(winfo.low, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Sunset", winfo.sunset, sizeof(winfo.sunset)))
- strcpy(winfo.sunset, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Sunrise", winfo.sunrise, sizeof(winfo.sunrise)))
- strcpy(winfo.sunrise, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Wind Speed", winfo.wind, sizeof(winfo.wind)))
- strcpy(winfo.wind, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Wind Direction", winfo.winddir, sizeof(winfo.winddir)))
- strcpy(winfo.winddir, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, sizeof(winfo.dewpoint)))
- strcpy(winfo.dewpoint, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Pressure", winfo.pressure, sizeof(winfo.pressure)))
- strcpy(winfo.pressure, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Visibility", winfo.vis, sizeof(winfo.vis)))
- strcpy(winfo.vis, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Humidity", winfo.humid, sizeof(winfo.humid)))
- strcpy(winfo.humid, NODATA);
- if (DBGetStaticString(Change, WEATHERCONDITION, "Feel", winfo.feel, sizeof(winfo.feel)))
- strcpy(winfo.feel, NODATA);
+ GetStationID(Change, winfo.id, SIZEOF(winfo.id));
+
+ if (DBGetStaticString(Change, WEATHERPROTONAME, "Nick", winfo.city, SIZEOF(winfo.city)))
+ _tcscpy(winfo.city, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Update", winfo.update, SIZEOF(winfo.update)))
+ _tcscpy(winfo.update, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Condition", winfo.cond, SIZEOF(winfo.cond)))
+ _tcscpy(winfo.cond, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Temperature", winfo.temp, SIZEOF(winfo.temp)))
+ _tcscpy(winfo.temp, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "High", winfo.high, SIZEOF(winfo.high)))
+ _tcscpy(winfo.high, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Low", winfo.low, SIZEOF(winfo.low)))
+ _tcscpy(winfo.low, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Sunset", winfo.sunset, SIZEOF(winfo.sunset)))
+ _tcscpy(winfo.sunset, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Sunrise", winfo.sunrise, SIZEOF(winfo.sunrise)))
+ _tcscpy(winfo.sunrise, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Wind Speed", winfo.wind, SIZEOF(winfo.wind)))
+ _tcscpy(winfo.wind, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Wind Direction", winfo.winddir, SIZEOF(winfo.winddir)))
+ _tcscpy(winfo.winddir, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, SIZEOF(winfo.dewpoint)))
+ _tcscpy(winfo.dewpoint, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Pressure", winfo.pressure, SIZEOF(winfo.pressure)))
+ _tcscpy(winfo.pressure, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Visibility", winfo.vis, SIZEOF(winfo.vis)))
+ _tcscpy(winfo.vis, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Humidity", winfo.humid, SIZEOF(winfo.humid)))
+ _tcscpy(winfo.humid, NODATA);
+ if (DBGetStaticString(Change, WEATHERCONDITION, "Feel", winfo.feel, SIZEOF(winfo.feel)))
+ _tcscpy(winfo.feel, NODATA);
winfo.status = (WORD)DBGetContactSettingWord(Change, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE);
return winfo;
@@ -95,36 +95,28 @@ WEATHERINFO LoadWeatherInfo(HANDLE Change) // return 0 on success
int DBGetData(HANDLE hContact, char *setting, DBVARIANT *dbv)
{
- if (DBGetContactSettingString(hContact, WEATHERCONDITION, setting, dbv))
- {
+ if (DBGetContactSettingTString(hContact, WEATHERCONDITION, setting, dbv)) {
size_t len = strlen(setting) + 1;
char *set = (char*)alloca(len + 1);
*set = '#';
memcpy(set + 1, setting, len);
- if (DBGetContactSettingString(hContact, WEATHERCONDITION, set, dbv))
+ if ( DBGetContactSettingTString(hContact, WEATHERCONDITION, set, dbv))
return 1;
}
return 0;
}
-int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueName, char *dest, size_t dest_len)
+int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueName, TCHAR *dest, size_t dest_len)
{
DBVARIANT dbv;
- DBCONTACTGETSETTING sVal;
-
- dbv.pszVal = dest;
- dbv.cchVal = (WORD)dest_len;
- dbv.type = DBVT_ASCIIZ;
-
- sVal.pValue = &dbv;
- sVal.szModule = szModule;
- sVal.szSetting = valueName;
-
- if ( CallService( MS_DB_CONTACT_GETSETTINGSTATIC, ( WPARAM )hContact, ( LPARAM )&sVal ) != 0 )
+ if ( DBGetContactSettingTString( hContact, szModule, valueName, &dbv ))
return 1;
- return ( dbv.type != DBVT_ASCIIZ );
+ _tcsncpy( dest, dbv.ptszVal, dest_len );
+ dest[ dest_len-1 ] = 0;
+ DBFreeVariant( &dbv );
+ return 0;
}
@@ -134,7 +126,7 @@ int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueNa // lastver = the last used version number in dword (using PLUGIN_MAKE_VERSION)
void EraseAllInfo(DWORD lastver)
{
- char str[255];
+ TCHAR str[255];
int ContactCount = 0;
HANDLE hContact, LastContact = NULL;
DBVARIANT dbv;
@@ -143,7 +135,7 @@ void EraseAllInfo(DWORD lastver) while(hContact)
{
// see if the contact is a weather contact
- if(IsMyContact(hContact))
+ if (IsMyContact(hContact))
{
// check for upgrade
if (lastver < __VERSION_DWORD) UpgradeContact(lastver, hContact);
@@ -151,61 +143,40 @@ void EraseAllInfo(DWORD lastver) DBWriteContactSettingWord(hContact,WEATHERPROTONAME,"StatusIcon",ID_STATUS_OFFLINE);
DBDeleteContactSetting(hContact,"CList","MyHandle");
// clear all data
- if (DBGetContactSettingString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "Nick", Translate("<Enter city name here>"));
+ if (DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>"));
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastLog", "never");
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", "None");
DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastTemperature", "None");
}
- else
- DBFreeVariant(&dbv);
-/*
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Update", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Condition", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Temperature", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"High", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Low", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Humidity", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Wind Speed", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Wind Direction", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Pressure", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Visibility", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Dewpoint", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Feel", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Heat Index", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Sunrise", NODATA);
- DBWriteContactSettingString(hContact,WEATHERCONDITION,"Sunset", NODATA);
-*/
+ else DBFreeVariant(&dbv);
+
DBDataManage(hContact, WDBM_REMOVE, 0, 0);
DBWriteContactSettingString(hContact, "UserInfo", "MyNotes", "");
// reset update tag
DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"IsUpdated",FALSE);
// reset logging settings
- if (!DBGetContactSettingString(hContact,WEATHERPROTONAME,"Log",&dbv))
- {
- DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"File",(BYTE)(dbv.pszVal[0] != 0));
+ if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Log", &dbv)) {
+ DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"File",(BYTE)(dbv.ptszVal[0] != 0));
DBFreeVariant(&dbv);
}
- else
- DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"File",FALSE);
+ else DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"File",FALSE);
+
// if no default station find, assign a new one
- if (opt.Default[0] == 0)
- {
- GetStationID(hContact, opt.Default, sizeof(opt.Default));
+ if (opt.Default[0] == 0) {
+ GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
opt.DefStn = hContact;
- if (!DBGetContactSettingString(hContact,WEATHERPROTONAME,"Nick",&dbv))
- {
- wsprintf(str, Translate("%s is now the default weather station"), dbv.pszVal);
+ if (!DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Nick",&dbv)) {
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
DBFreeVariant(&dbv);
- MessageBox(NULL, str, Translate("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
}
// get the handle of the default station
if (opt.DefStn == NULL) {
- if (!DBGetContactSettingString(hContact,WEATHERPROTONAME,"ID",&dbv))
- {
- if (!strcmp(dbv.pszVal, opt.Default)) opt.DefStn = hContact;
+ if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME,"ID",&dbv)) {
+ if ( !_tcscmp(dbv.ptszVal, opt.Default)) opt.DefStn = hContact;
DBFreeVariant(&dbv);
}
}
@@ -217,89 +188,86 @@ void EraseAllInfo(DWORD lastver) // if weather contact exists, set the status to online so it is ready for update
// if (ContactCount != 0) status = ONLINE;
// in case where the default station is missing
- if (opt.DefStn == NULL && ContactCount != 0)
- {
- if (!DBGetContactSettingString(LastContact,WEATHERPROTONAME,"ID",&dbv))
- {
- strcpy(opt.Default, dbv.pszVal);
+ if (opt.DefStn == NULL && ContactCount != 0) {
+ if ( !DBGetContactSettingTString(LastContact, WEATHERPROTONAME, "ID", &dbv)) {
+ _tcscpy(opt.Default, dbv.ptszVal);
DBFreeVariant(&dbv);
}
opt.DefStn = LastContact;
- if (!DBGetContactSettingString(LastContact,WEATHERPROTONAME,"Nick",&dbv))
- {
- wsprintf(str, Translate("%s is now the default weather station"), dbv.pszVal);
+ if (!DBGetContactSettingTString(LastContact,WEATHERPROTONAME,"Nick",&dbv)) {
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
DBFreeVariant(&dbv);
- MessageBox(NULL, str, Translate("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
}
// save option in case of default station changed
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default);
}
-void ConvertDataValue(WIDATAITEM *UpdateData, char *Data)
+void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data)
{
- char str[MAX_DATA_LEN];
+ TCHAR str[MAX_DATA_LEN];
// convert the unit
- if (strcmp(Data, Translate("<Error>")) && strcmp(Data, NODATA) && strcmp(Data, Translate(NODATA)))
- {
+ if ( _tcscmp(Data, TranslateT("<Error>")) && _tcscmp(Data, NODATA) && _tcscmp(Data, TranslateTS(NODATA))) {
// temperature
- if (!strcmp(UpdateData->Name, "Temperature") || !strcmp(UpdateData->Name, "High") ||
- !strcmp(UpdateData->Name, "Low") || !strcmp(UpdateData->Name, "Feel") ||
- !strcmp(UpdateData->Name, "Dewpoint") ||
- !_stricmp(UpdateData->Unit, "C") || !_stricmp(UpdateData->Unit, "F") ||
- !_stricmp(UpdateData->Unit, "K"))
+ if (!_tcscmp(UpdateData->Name, _T("Temperature")) || !_tcscmp(UpdateData->Name, _T("High")) ||
+ !_tcscmp(UpdateData->Name, _T("Low")) || !_tcscmp(UpdateData->Name, _T("Feel")) ||
+ !_tcscmp(UpdateData->Name, _T("Dewpoint")) ||
+ !_tcsicmp(UpdateData->Unit, _T("C")) || !_tcsicmp(UpdateData->Unit, _T("F")) ||
+ !_tcsicmp(UpdateData->Unit, _T("K")))
{
GetTemp(Data, UpdateData->Unit, str);
- strcpy(Data, str);
+ _tcscpy(Data, str);
}
// pressure
- else if (!strcmp(UpdateData->Name, "Pressure") || !_stricmp(UpdateData->Unit, "HPA") ||
- !_stricmp(UpdateData->Unit, "KPA") || !_stricmp(UpdateData->Unit, "MB") ||
- !_stricmp(UpdateData->Unit, "TORR") || !_stricmp(UpdateData->Unit, "IN") ||
- !_stricmp(UpdateData->Unit, "MM"))
+ else if (!_tcscmp(UpdateData->Name, _T("Pressure")) || !_tcsicmp(UpdateData->Unit, _T("HPA")) ||
+ !_tcsicmp(UpdateData->Unit, _T("KPA")) || !_tcsicmp(UpdateData->Unit, _T("MB")) ||
+ !_tcsicmp(UpdateData->Unit, _T("TORR")) || !_tcsicmp(UpdateData->Unit, _T("IN")) ||
+ !_tcsicmp(UpdateData->Unit, _T("MM")))
{
GetPressure(Data, UpdateData->Unit, str);
- strcpy(Data, str);
+ _tcscpy(Data, str);
}
// speed
- else if (!strcmp(UpdateData->Name, "Wind Speed") || !_stricmp(UpdateData->Unit, "KM/H") ||
- !_stricmp(UpdateData->Unit, "M/S") || !_stricmp(UpdateData->Unit, "MPH") ||
- !_stricmp(UpdateData->Unit, "KNOTS"))
+ else if (!_tcscmp(UpdateData->Name, _T("Wind Speed")) || !_tcsicmp(UpdateData->Unit, _T("KM/H")) ||
+ !_tcsicmp(UpdateData->Unit, _T("M/S")) || !_tcsicmp(UpdateData->Unit, _T("MPH")) ||
+ !_tcsicmp(UpdateData->Unit, _T("KNOTS")))
{
GetSpeed(Data, UpdateData->Unit, str);
- strcpy(Data, str);
+ _tcscpy(Data, str);
}
// visibility
- else if (!strcmp(UpdateData->Name, "Visibility") || !_stricmp(UpdateData->Unit, "KM") ||
- !_stricmp(UpdateData->Unit, "MILES"))
+ else if (!_tcscmp(UpdateData->Name, _T("Visibility")) || !_tcsicmp(UpdateData->Unit, _T("KM")) ||
+ !_tcsicmp(UpdateData->Unit, _T("MILES")))
{
GetDist(Data, UpdateData->Unit, str);
- strcpy(Data, str);
+ _tcscpy(Data, str);
}
// elevation
- else if (!strcmp(UpdateData->Name, "Elevation") || !_stricmp(UpdateData->Unit, "FT") ||
- !_stricmp(UpdateData->Unit, "M"))
+ else if (!_tcscmp(UpdateData->Name, _T("Elevation")) || !_tcsicmp(UpdateData->Unit, _T("FT")) ||
+ !_tcsicmp(UpdateData->Unit, _T("M")))
{
GetElev(Data, UpdateData->Unit, str);
- strcpy(Data, str);
+ _tcscpy(Data, str);
}
// converting case for condition to the upper+lower format
- else if (!_stricmp(UpdateData->Unit, "COND"))
+ else if (!_tcsicmp(UpdateData->Unit, _T("COND")))
CaseConv(Data);
// degree sign
- else if (!_stricmp(UpdateData->Unit, "DEG"))
+ else if (!_tcsicmp(UpdateData->Unit, _T("DEG")))
{
- if (!opt.DoNotAppendUnit) strcat(Data, opt.DegreeSign);
+ if (!opt.DoNotAppendUnit) _tcscat(Data, opt.DegreeSign);
}
// percent sign
- else if (!_stricmp(UpdateData->Unit, "%"))
+ else if (!_tcsicmp(UpdateData->Unit, _T("%")))
{
- if (!opt.DoNotAppendUnit) strcat(Data, "%");
+ if (!opt.DoNotAppendUnit) _tcscat(Data, _T("%"));
}
// truncating strings for day/month to 2 or 3 characters
- else if (!_stricmp(UpdateData->Unit, "DAY") || !_stricmp(UpdateData->Unit, "MONTH"))
- if (opt.dUnit > 1 && strlen(Data) > opt.dUnit) Data[opt.dUnit] = '\0';
+ else if (!_tcsicmp(UpdateData->Unit, _T("DAY")) || !_tcsicmp(UpdateData->Unit, _T("MONTH")))
+ if (opt.dUnit > 1 && _tcslen(Data) > opt.dUnit)
+ Data[opt.dUnit] = '\0';
}
}
@@ -309,12 +277,13 @@ void ConvertDataValue(WIDATAITEM *UpdateData, char *Data) // UpdateData = the WIDATAITEM struct containing start, end, unit
// Data = the string containing weather data obtained from UpdateData
// global var. used: szInfo = the downloaded string
-void GetDataValue(WIDATAITEM *UpdateData, char *Data, char** szData)
+
+void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
{
- char last = 0, current, *start, *end;
+ TCHAR last = 0, current, *start, *end;
unsigned startloc = 0, endloc = 0, respos = 0;
BOOL tag = FALSE, symb = FALSE;
- char *szInfo = *szData;
+ TCHAR *szInfo = *szData;
Data[0] = 0;
// parse the data if available
@@ -322,22 +291,24 @@ void GetDataValue(WIDATAITEM *UpdateData, char *Data, char** szData) start = szInfo;
// the start string must be found
if (UpdateData->Start[0] != 0) {
- start = strstr(szInfo, UpdateData->Start);
+ start = _tcsstr(szInfo, UpdateData->Start);
if (start != NULL) {
// set the starting location for getting data
- start += strlen(UpdateData->Start);
+ start += _tcslen(UpdateData->Start);
szInfo = start;
}
}
// the end string must be found too
if (UpdateData->End[0] != 0)
- end = strstr(szInfo, UpdateData->End);
- else end = strstr(szInfo, " ");
+ end = _tcsstr(szInfo, UpdateData->End);
+ else
+ end = _tcsstr(szInfo, _T(" "));
+
if (end != NULL) {
// set the ending location
startloc = 0;
endloc = end - szInfo;
- end += strlen(UpdateData->End);
+ end += _tcslen(UpdateData->End);
last = '\n';
}
// ignore if not both of the string found - this prevent crashes
@@ -370,11 +341,11 @@ void GetDataValue(WIDATAITEM *UpdateData, char *Data, char** szData) ++startloc;
// prevent crashes if the string go over maximun length -> generate an error
if (respos >= MAX_DATA_LEN) {
- if (opt.ShowWarnings && UpdateData->Name[0] != 0 && strcmp(UpdateData->Name, "Ignore")) {
- mir_snprintf(Data, MAX_DATA_LEN, Translate("Error when obtaining data: %s"), UpdateData->Name);
+ if (opt.ShowWarnings && UpdateData->Name[0] != 0 && _tcscmp(UpdateData->Name, _T("Ignore"))) {
+ mir_sntprintf(Data, MAX_DATA_LEN, TranslateT("Error when obtaining data: %s"), UpdateData->Name);
WPShowMessage(Data, SM_WARNING);
}
- strncpy(Data, Translate("<Error>"), MAX_DATA_LEN);
+ _tcsncpy(Data, TranslateT("<Error>"), MAX_DATA_LEN);
last = ' ';
respos = MAX_DATA_LEN - 1;
break;
@@ -388,9 +359,6 @@ void GetDataValue(WIDATAITEM *UpdateData, char *Data, char** szData) // null terminate the string
Data[respos] = 0;
- // write raw data for debug
- Netlib_Logf(hNetlibUser, "%s: %s", UpdateData->Name, Data);
-
// convert the unit
ConvertDataValue(UpdateData, Data);
@@ -417,6 +385,24 @@ void wSetData(char **Data, const char *Value) *Data = "";
}
+void wSetData(WCHAR **Data, const char *Value)
+{
+ if (Value[0] != 0)
+ *Data = mir_a2u( Value );
+ else
+ *Data = L"";
+}
+
+void wSetData(WCHAR **Data, const WCHAR *Value)
+{
+ if (Value[0] != 0) {
+ WCHAR *newData = (WCHAR*)mir_alloc( sizeof(WCHAR)*(wcslen(Value)+3));
+ wcscpy(newData, Value);
+ *Data = newData;
+ }
+ else *Data = L"";
+}
+
// A safer free function that free memory for a string
// Data = the string occuping the data to be freed
void wfree(char **Data)
@@ -425,6 +411,13 @@ void wfree(char **Data) *Data = NULL;
}
+void wfree(WCHAR **Data)
+{
+ if (*Data && wcslen(*Data) > 0)
+ mir_free(*Data);
+ *Data = NULL;
+}
+
//============ MANAGE THE ITEMS STORED IN DB ============
// remove or display the weatehr information for a contact
@@ -441,16 +434,13 @@ void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam) dbces.szModule=WEATHERCONDITION;
// get all the settings and stored them in a temporary list
- if(CallService(MS_DB_CONTACT_ENUMSETTINGS,(WPARAM)hContact,(LPARAM)&dbces)==-1)
+ if (CallService(MS_DB_CONTACT_ENUMSETTINGS,(WPARAM)hContact,(LPARAM)&dbces)==-1)
wc.current--;
// begin deleting settings
- for (; --wc.current>-1;)
- {
- if (!DBGetContactSettingString(hContact, WEATHERCONDITION, wc.value[wc.current], &dbv))
- {
- switch (Mode)
- {
+ for (; --wc.current>-1;) {
+ if (!DBGetContactSettingTString(hContact, WEATHERCONDITION, wc.value[wc.current], &dbv)) {
+ switch (Mode) {
case WDBM_REMOVE:
DBDeleteContactSetting(hContact, WEATHERCONDITION, wc.value[wc.current]);
break;
@@ -472,12 +462,12 @@ void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam) lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.iItem = 0;
- lvi.iSubItem = 0;
+ lvi.iSubItem = 1;
lvi.lParam = (LPARAM)wc.current;
- lvi.pszText = (LPSTR)Translate(wc.value[wc.current]);
- lvi.iItem = ListView_InsertItemWth(hList, &lvi);
- lvi.pszText = dbv.pszVal;
- ListView_SetItemTextWth(hList, lvi.iItem, 1, lvi.pszText);
+ lvi.pszText = TranslateTS( _A2T(wc.value[wc.current] ));
+ lvi.iItem = ListView_InsertItem(hList, &lvi);
+ lvi.pszText = dbv.ptszVal;
+ ListView_SetItemText(hList, lvi.iItem, 1, dbv.ptszVal );
break;
}
}
diff --git a/protocols/Weather/weather_http.cpp b/protocols/Weather/weather_http.cpp index eb69dd4ca7..69a54de31a 100644 --- a/protocols/Weather/weather_http.cpp +++ b/protocols/Weather/weather_http.cpp @@ -46,7 +46,7 @@ int findHeader(NETLIBHTTPREQUEST *nlhrReply, char *hdr) // szUrl = URL of the webpage to be retrieved
// return value = 0 for success, 1 or HTTP error code for failure
// global var used: szData, szInfo = containing the retrieved data
-int InternetDownloadFile (char *szUrl, char* cookie, char** szData)
+int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData)
{
int result = 0xBADBAD;
char* szRedirUrl = NULL;
@@ -81,68 +81,51 @@ int InternetDownloadFile (char *szUrl, char* cookie, char** szData) if (cookie == NULL || cookie[0] == 0) --nlhr.headersCount;
- while (result == 0xBADBAD)
- {
+ while (result == 0xBADBAD) {
// download the page
nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,
(WPARAM)hNetlibUser,(LPARAM)&nlhr);
- if (nlhrReply)
- {
+ if (nlhrReply) {
// if the recieved code is 200 OK
- if(nlhrReply->resultCode == 200)
- {
- if (nlhrReply->dataLength)
- {
- char* end;
- int i;
-
+ if (nlhrReply->resultCode == 200) {
+ if (nlhrReply->dataLength) {
result = 0;
-
-// i = findHeader(nlhrReply, "Date-Modified");
+ bool bIsUtf = false;
// allocate memory and save the retrieved data
- *szData = (char *)mir_alloc(nlhrReply->dataLength + 2);
+ int i = findHeader(nlhrReply, "Content-Type");
+ if (i != -1 && strstr(_strlwr((char*)nlhrReply->headers[i].szValue), "utf-8"))
+ bIsUtf = true;
+ else {
+ char* end = nlhrReply->pData;
+ for (;;) {
+ char* beg = strstr(end, "<meta");
+ if (beg == NULL) break;
+ else {
+ char* method, tmp;
+ end = strchr(beg, '>');
+ tmp = *end; *end = 0;
+
+ method = strstr(beg, "http-equiv=\"");
+ if (method && _strnicmp(method+12, "Content-Type", 12) == 0 && strstr(method, "utf-8")) {
+ bIsUtf = true;
+ break;
+ }
+ else *end = tmp;
+ } } }
+
+ if ( bIsUtf )
+ *szData = mir_utf8decodeT( nlhrReply->pData );
+ else
+ *szData = mir_a2t( nlhrReply->pData );
- memcpy(*szData, nlhrReply->pData, nlhrReply->dataLength);
- (*szData)[nlhrReply->dataLength] = 0;
-
- i = findHeader(nlhrReply, "Content-Type");
- if (i != -1)
- {
- if (strstr(_strlwr((char*)nlhrReply->headers[i].szValue), "utf-8"))
- mir_utf8decode(*szData, NULL);
- }
-
- end = *szData;
- for (;;)
- {
- char* beg = strstr(end, "<meta");
- if (beg == NULL) break;
- else
- {
- char* method, tmp;
- end = strchr(beg, '>');
- tmp = *end; *end = 0;
-
- method = strstr(beg, "http-equiv=\"");
- if (method && _strnicmp(method+12, "Content-Type", 12) == 0 && strstr(method, "utf-8"))
- {
- *end = tmp;
- mir_utf8decode(*szData, NULL);
- break;
- }
- else
- *end = tmp;
- }
- }
}
- else
- result = DATA_EMPTY;
+ else result = DATA_EMPTY;
}
// if the recieved code is 302 Moved, Found, etc
// workaround for url forwarding
- else if(nlhrReply->resultCode == 302 || nlhrReply->resultCode == 301 || nlhrReply->resultCode == 303 ) // page moved
+ else if (nlhrReply->resultCode == 302 || nlhrReply->resultCode == 301 || nlhrReply->resultCode == 303 ) // page moved
{
// get the url for the new location and save it to szInfo
// look for the reply header "Location"
@@ -172,11 +155,10 @@ int InternetDownloadFile (char *szUrl, char* cookie, char** szData) }
}
// return error code if the recieved code is neither 200 OK nor 302 Moved
- else
- {
- *szData = (char *)mir_alloc(512);
+ else {
+ *szData = ( TCHAR* )mir_alloc(512);
// store the error code in szData
- wsprintf(*szData, "Error occured! HTTP Error: %i\n", nlhrReply->resultCode);
+ wsprintf(*szData, _T("Error occured! HTTP Error: %i\n"), nlhrReply->resultCode);
result = (int)nlhrReply->resultCode;
}
@@ -187,9 +169,9 @@ int InternetDownloadFile (char *szUrl, char* cookie, char** szData) // if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code
else
{
- *szData = (char *)mir_alloc(512);
+ *szData = ( TCHAR* )mir_alloc(512);
// store the error code in szData
- strcpy(*szData, "NetLib error occurred!!");
+ _tcscpy(*szData, _T("NetLib error occurred!!"));
result = NETLIB_ERROR;
hNetlibHttp = NULL;
}
diff --git a/protocols/Weather/weather_icons.cpp b/protocols/Weather/weather_icons.cpp index e1b95c4405..ada253bb07 100644 --- a/protocols/Weather/weather_icons.cpp +++ b/protocols/Weather/weather_icons.cpp @@ -45,33 +45,29 @@ static iconList[] = void InitIcons(void)
{
- char szFile[MAX_PATH];
char szSettingName[100];
- SKINICONDESC sid = {0};
- unsigned i;
-
+ TCHAR szFile[MAX_PATH];
GetModuleFileName(hInst, szFile, MAX_PATH);
- sid.cbSize = sizeof(SKINICONDESC);
- sid.pszDefaultFile = szFile;
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.ptszDefaultFile = szFile;
sid.pszName = szSettingName;
sid.pszSection = WEATHERPROTONAME;
+ sid.flags = SIDF_PATH_TCHAR;
- for (i = 0; i < SIZEOF(iconList); i++)
- {
- mir_snprintf(szSettingName, sizeof( szSettingName ), "%s_%s", WEATHERPROTONAME, iconList[i].szName);
+ for (int i = 0; i < SIZEOF(iconList); i++) {
+ mir_snprintf(szSettingName, SIZEOF( szSettingName ), "%s_%s", WEATHERPROTONAME, iconList[i].szName);
sid.pszDescription = iconList[i].szDescr;
sid.iDefaultIndex = -iconList[i].defIconID;
iconList[i].hIconLibItem = ( HANDLE )CallService(MS_SKIN2_ADDICON, 0, (LPARAM)&sid);
- }
-}
-
+} }
HICON LoadIconEx(const char* name, BOOL big)
{
char szSettingName[100];
- mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", WEATHERPROTONAME, name);
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", WEATHERPROTONAME, name);
return (HICON)CallService(MS_SKIN2_GETICON, big, (LPARAM)szSettingName);
}
diff --git a/protocols/Weather/weather_info.cpp b/protocols/Weather/weather_info.cpp index b5997feb6c..524860fe3e 100644 --- a/protocols/Weather/weather_info.cpp +++ b/protocols/Weather/weather_info.cpp @@ -31,9 +31,9 @@ regrading the loading of ini contents // List INI Information for all loaded INI files
void INIInfo(HWND hwndDlg)
{
- char str[16];
+ TCHAR str[16];
size_t memused = 0;
- LVITEM lvi = {0};
+ LVITEM lvi = {0};
WIDATALIST *Item = WIHead;
HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
@@ -57,17 +57,17 @@ void INIInfo(HWND hwndDlg) lvi.iSubItem = 3;
switch (Item->Data.InternalVer)
{
- case 1: lvi.pszText = "1.0"; break;
- case 2: lvi.pszText = "1.1"; break;
- case 3: lvi.pszText = "1.1a"; break;
- case 4: lvi.pszText = "1.2"; break;
- case 5: lvi.pszText = "1.3"; break;
- case 6: lvi.pszText = "1.4"; break;
- default: lvi.pszText = ""; break;
+ case 1: lvi.pszText = _T("1.0"); break;
+ case 2: lvi.pszText = _T("1.1"); break;
+ case 3: lvi.pszText = _T("1.1a"); break;
+ case 4: lvi.pszText = _T("1.2"); break;
+ case 5: lvi.pszText = _T("1.3"); break;
+ case 6: lvi.pszText = _T("1.4"); break;
+ default: lvi.pszText = _T(""); break;
}
ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 4;
- lvi.pszText = _ltoa(Item->Data.UpdateDataCount, str, 10);
+ lvi.pszText = _ltot(Item->Data.UpdateDataCount, str, 10);
ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 5;
lvi.pszText = Item->Data.DisplayName;
@@ -81,24 +81,24 @@ void INIInfo(HWND hwndDlg) Item = Item->next;
++lvi.iItem;
}
- SetDlgItemText(hwndDlg, IDC_INICOUNT, _itoa(lvi.iItem, str, 10));
- SetDlgItemText(hwndDlg, IDC_MEMUSED, _ltoa((long)memused, str, 10));
+ SetDlgItemText(hwndDlg, IDC_INICOUNT, _itot(lvi.iItem, str, 10));
+ SetDlgItemText(hwndDlg, IDC_MEMUSED, _ltot((long)memused, str, 10));
}
static const struct tag_Columns
{
- const char *name;
+ const TCHAR *name;
unsigned size;
}
columns[] =
{
- { "Name" , 70 },
- { "Author" , 100 },
- { "File Version" , 70 },
- { "INI Version" , 70 },
- { "Items" , 40 },
- { "Display Name" , 200 },
- { "File Name" , 150 },
+ { _T("Name"), 70 },
+ { _T("Author"), 100 },
+ { _T("File Version"), 70 },
+ { _T("INI Version"), 70 },
+ { _T("Items"), 40 },
+ { _T("Display Name"), 200 },
+ { _T("File Name"), 150 },
};
@@ -109,19 +109,16 @@ INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- unsigned i;
-
HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
LVCOLUMN lvc = {0};
lvc.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_LEFT;
- for (i=0; i<7; ++i)
- {
+ for ( int i=0; i<7; ++i) {
lvc.iSubItem = i;
- lvc.pszText = Translate(columns[i].name);
+ lvc.pszText = TranslateTS(columns[i].name);
lvc.cx = columns[i].size;
- ListView_InsertColumnWth(hIniList, i, &lvc);
+ ListView_InsertColumn(hIniList, i, &lvc);
}
INIInfo(hwndDlg);
}
@@ -147,64 +144,64 @@ INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP // get the info of individual ini file
// pszSvc = the internal name of the service to get the data
-void GetINIInfo(char *pszSvc) {
- char str2[2048];
+void GetINIInfo(TCHAR *pszSvc)
+{
+ TCHAR str2[2048];
WIDATA *sData = GetWIData(pszSvc);
// if the service does not exist among the loaded INI's
if (sData == NULL)
{
- wsprintf(str2, Translate("The corresponding INI file for \"%s\" is not found."), pszSvc);
- MessageBox(NULL, str2, Translate("Weather INI information"), MB_OK|MB_ICONINFORMATION);
+ wsprintf(str2, TranslateT("The corresponding INI file for \"%s\" is not found."), pszSvc);
+ MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK|MB_ICONINFORMATION);
}
// if exist, get the information
else
{
- wsprintf(str2, Translate("Weather INI information for \"%s\":"), pszSvc);
- strcat(str2, "\n\n");
- strcat(str2, Translate("Name:"));
- strcat(str2, "\t\t");
- strcat(str2, sData->DisplayName);
- strcat(str2, "\n");
- strcat(str2, Translate("Internal Name:"));
- strcat(str2, "\t");
- strcat(str2, sData->InternalName);
- strcat(str2, "\n");
- strcat(str2, Translate("Author:"));
- strcat(str2, "\t\t");
- strcat(str2, sData->Author);
- strcat(str2, "\n");
- strcat(str2, Translate("Version:"));
- strcat(str2, "\t\t");
- strcat(str2, sData->Version);
- strcat(str2, "\n");
- strcat(str2, Translate("INI Version:"));
- strcat(str2, "\t");
- switch (sData->InternalVer)
- {
- case 1: strcat(str2, "1.0"); break;
- case 2: strcat(str2, "1.1"); break;
- case 3: strcat(str2, "1.1a"); break;
- case 4: strcat(str2, "1.2"); break;
- case 5: strcat(str2, "1.3"); break;
- case 6: strcat(str2, "1.4"); break;
+ wsprintf(str2, TranslateT("Weather INI information for \"%s\":"), pszSvc);
+ _tcscat(str2,_T("\n\n"));
+ _tcscat(str2, TranslateT("Name:"));
+ _tcscat(str2,_T("\t\t"));
+ _tcscat(str2, sData->DisplayName);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("Internal Name:"));
+ _tcscat(str2,_T("\t"));
+ _tcscat(str2, sData->InternalName);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("Author:"));
+ _tcscat(str2,_T("\t\t"));
+ _tcscat(str2, sData->Author);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("Version:"));
+ _tcscat(str2,_T("\t\t"));
+ _tcscat(str2, sData->Version);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("INI Version:"));
+ _tcscat(str2,_T("\t"));
+ switch (sData->InternalVer) {
+ case 1: _tcscat(str2,_T("1.0")); break;
+ case 2: _tcscat(str2,_T("1.1")); break;
+ case 3: _tcscat(str2,_T("1.1a")); break;
+ case 4: _tcscat(str2,_T("1.2")); break;
+ case 5: _tcscat(str2,_T("1.3")); break;
+ case 6: _tcscat(str2,_T("1.4")); break;
}
- strcat(str2, "\n");
- strcat(str2, Translate("File Name:"));
- strcat(str2, "\t");
- strcat(str2, sData->ShortFileName);
- strcat(str2, "\n");
- strcat(str2, Translate("Item Count:"));
- wsprintf(str2, "%s\t%i\n", str2, sData->UpdateDataCount);
- strcat(str2, Translate("Memory Used:"));
- wsprintf(str2, "%s\t%i ", str2, sData->MemUsed);
- strcat(str2, Translate("bytes"));
- strcat(str2, "\n\n");
- strcat(str2, Translate("Description:"));
- strcat(str2, "\n");
- strcat(str2, sData->Description);
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, TranslateT("File Name:"));
+ _tcscat(str2,_T("\t"));
+ _tcscat(str2, sData->ShortFileName);
+ _tcscat(str2, _T("\n"));
+ _tcscat(str2, TranslateT("Item Count:"));
+ wsprintf(str2, _T("%s\t%i\n"), str2, sData->UpdateDataCount);
+ _tcscat(str2, TranslateT("Memory Used:"));
+ wsprintf(str2, _T("%s\t%i "), str2, sData->MemUsed);
+ _tcscat(str2, TranslateT("bytes"));
+ _tcscat(str2,_T("\n\n"));
+ _tcscat(str2, TranslateT("Description:"));
+ _tcscat(str2,_T("\n"));
+ _tcscat(str2, sData->Description);
// display the message box and quit
- MessageBox(NULL, str2, Translate("Weather INI information"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK|MB_ICONINFORMATION);
}
}
@@ -214,12 +211,12 @@ void GetINIInfo(char *pszSvc) { // can be found when click on "More" in text option dialog
void MoreVarList(void)
{
- char str[10240], tempstr[1024], *find;
+ TCHAR str[10240], tempstr[1024];
WIDATALIST *Item = WIHead;
// heading
- strcpy(str, Translate("Here is a list of custom variables that are currently available"));
- strcat(str, "\n\n");
+ _tcscpy(str, TranslateT("Here is a list of custom variables that are currently available"));
+ _tcscat(str, _T("\n\n"));
// loop through all weather services to find custom variables
while (Item != NULL)
{
@@ -230,13 +227,13 @@ void MoreVarList(void) {
// the custom variable is defined as "%[<variable name>]"
// ignore the "hi" item and hidden items
- if (strcmp(WItem->Item.Name, "Ignore") && WItem->Item.Name[0] != '#') {
- wsprintf(tempstr, "%c[%s]", '%', WItem->Item.Name);
- find = strstr(str, tempstr);
+ if ( _tcscmp(WItem->Item.Name, _T("Ignore")) && WItem->Item.Name[0] != '#') {
+ wsprintf(tempstr, _T("%c[%s]"), '%', WItem->Item.Name);
+ TCHAR* find = _tcsstr(str, tempstr);
// if the custom variable does not exist in the list, add it to the list
if (find == NULL) {
- strcat(str, tempstr);
- strcat(str, ", ");
+ _tcscat(str, tempstr);
+ _tcscat(str, _T(", "));
}
}
WItem = WItem->Next;
@@ -244,10 +241,11 @@ void MoreVarList(void) Item = Item->next;
}
// remove the last comma in the list
- find = strrchr(str, ',');
- if (find != NULL) *find = '\0';
+ TCHAR* find = _tcsrchr(str, ',');
+ if (find != NULL)
+ *find = '\0';
// display the list in a message box
- MessageBox(NULL, str, Translate("More Variables"), MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
+ MessageBox(NULL, str, TranslateT("More Variables"), MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
}
diff --git a/protocols/Weather/weather_ini.cpp b/protocols/Weather/weather_ini.cpp index 363f2d364f..b3c0be722c 100644 --- a/protocols/Weather/weather_ini.cpp +++ b/protocols/Weather/weather_ini.cpp @@ -49,15 +49,15 @@ void WIListAdd(WIDATA Data) // get the service data (from loaded ini file) by internal name
// pszServ = internal name for the service
// return value = the matching WIDATA struct for pszServ, NULL if no match found
-WIDATA* GetWIData(char *pszServ)
+WIDATA* GetWIData(TCHAR *pszServ)
{
WIDATALIST *Item = WIHead;
// loop through the list to find matching internal name
- while (Item != NULL)
- {
+ while (Item != NULL) {
// if internal name found, return the data
- if (strcmp(Item->Data.InternalName, pszServ) == 0) return &Item->Data;
+ if ( _tcscmp(Item->Data.InternalName, pszServ) == 0)
+ return &Item->Data;
Item = Item->next;
}
// return NULL when no match found
@@ -98,16 +98,16 @@ void WIItemListAdd(WIDATAITEM *DataItem, WIDATA *Data) // reset the data item by using empty string
// Item = the item to set
// name = the string to store in the "name" field
-void ResetDataItem(WIDATAITEM *Item, const char *name)
+void ResetDataItem(WIDATAITEM *Item, const TCHAR *name)
{
- char str[] = "ID Search - Station Name";
- Item->Name = ( char* )mir_alloc(sizeof(str));
- strcpy(Item->Name, str);
- Item->Start = "";
- Item->End = "";
- Item->Unit = "";
+ TCHAR str[] = _T("ID Search - Station Name");
+ Item->Name = ( TCHAR* )mir_alloc( sizeof(str));
+ _tcscpy(Item->Name, str);
+ Item->Start = _T("");
+ Item->End = _T("");
+ Item->Unit = _T("");
Item->Url = "";
- Item->Break = "";
+ Item->Break = _T("");
Item->Type = 0;
}
@@ -135,11 +135,9 @@ void WICondListInit(WICONDLIST *List) // add a new update item into the current list
void WICondListAdd(char *str, WICONDLIST *List)
{
- WICONDITEM *newItem;
-
- newItem = (WICONDITEM*)mir_alloc(sizeof(WICONDITEM));
- CharLowerBuff(str, (DWORD)strlen(str));
+ WICONDITEM *newItem = (WICONDITEM*)mir_alloc(sizeof(WICONDITEM));
wSetData(&newItem->Item, str);
+ CharLowerBuff(newItem->Item, _tcslen( newItem->Item ));
newItem->Next = NULL;
if (List->Tail == NULL) List->Head = newItem;
else List->Tail->Next = newItem;
@@ -147,15 +145,15 @@ void WICondListAdd(char *str, WICONDLIST *List) }
// check if the condition string matched for the assignment
-BOOL IsContainedInCondList(const char *pszStr, WICONDLIST *List)
+BOOL IsContainedInCondList(const TCHAR *pszStr, WICONDLIST *List)
{
WICONDITEM *Item = List->Head;
// loop through the list to find matching internal name
- while (Item != NULL)
- {
+ while (Item != NULL) {
// if internal name found, return true indicating that the data is found
- if (strstr(pszStr, Item->Item)) return TRUE;
+ if ( _tcsstr(pszStr, Item->Item))
+ return TRUE;
Item = Item->Next;
}
// return false when no match found
@@ -188,7 +186,7 @@ void DestroyCondList(WICONDLIST *List) BOOL LoadWIData(BOOL dial)
{
HANDLE hFind;
- char szSearchPath[MAX_PATH], FileName[MAX_PATH], *chop;
+ TCHAR szSearchPath[MAX_PATH], FileName[MAX_PATH], *chop;
WIN32_FIND_DATA fd;
WIDATA Data;
@@ -197,41 +195,38 @@ BOOL LoadWIData(BOOL dial) WIHead = WITail;
// find all *.ini file in the plugin\weather directory
- GetModuleFileName(GetModuleHandle(NULL), szSearchPath, sizeof(szSearchPath));
- chop = strrchr(szSearchPath, '\\');
+ GetModuleFileName(GetModuleHandle(NULL), szSearchPath, SIZEOF(szSearchPath));
+ chop = _tcsrchr(szSearchPath, '\\');
*chop = '\0';
- strcat(szSearchPath,"\\Plugins\\Weather\\*.ini");
- strcpy(FileName, szSearchPath);
+ _tcscat(szSearchPath, _T("\\Plugins\\Weather\\*.ini"));
+ _tcscpy(FileName, szSearchPath);
hFind = FindFirstFile(szSearchPath, &fd);
// load the content of the ini file into memory
- if (hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- chop = strrchr(FileName, '\\');
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ chop = _tcsrchr(FileName, '\\');
chop[1] = '\0';
- strcat(FileName, fd.cFileName);
- if (_stricmp(fd.cFileName, "SAMPLE_INI.INI"))
- {
+ _tcscat(FileName, fd.cFileName);
+ if ( _tcsicmp(fd.cFileName, _T("SAMPLE_INI.INI"))) {
LoadStationData(FileName, fd.cFileName, &Data);
if (Data.Enabled) WIListAdd(Data);
}
// look through the entire "plugins\weather" directory
}
- while(FindNextFile(hFind, &fd));
+ while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
- if (WIHead == NULL)
- {
+
+ if (WIHead == NULL) {
// no ini found, display an error message box.
if (dial)
hWndSetup = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETUP), NULL, DlgProcSetup);
else
MessageBox(NULL,
- Translate("No update data file is found. Please check your Plugins\\Weather directory."),
- Translate("Weather Protocol"), MB_OK | MB_ICONERROR);
+ TranslateT("No update data file is found. Please check your Plugins\\Weather directory."),
+ TranslateT("Weather Protocol"), MB_OK | MB_ICONERROR);
return FALSE;
}
return TRUE;
@@ -241,12 +236,12 @@ BOOL LoadWIData(BOOL dial) // pszFile = the file name + path for the ini file to be loaded
// pszShortFile = the file name of the ini file, but not including the path
// Data = the struct to load the ini content to, and return to previous function
-void LoadStationData(char *pszFile, char *pszShortFile, WIDATA *Data)
+void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
{
WIDATAITEM DataItem;
FILE *pfile;
int i;
- char Line[4096], *Group, *Temp;
+ char *Group, *Temp;
char *ValName, *Value;
static const char *statusStr[10] =
@@ -268,11 +263,12 @@ void LoadStationData(char *pszFile, char *pszShortFile, WIDATA *Data) Data->Enabled = FALSE;
// open the ini file
- pfile = _fsopen(pszFile, "rt", _SH_DENYWR);
- if (pfile != NULL)
- {
- fgets(Line, sizeof(Line), pfile);
+ pfile = _tfsopen(pszFile, _T("rt"), _SH_DENYWR);
+ if (pfile != NULL) {
+ char Line[4096];
+ fgets(Line, SIZEOF(Line), pfile);
TrimString(Line);
+
// make sure it is a valid weather protocol ini file
if (!strcmp(Line, "[Weather 0.3.x Update Data]"))
Data->InternalVer = 1;
@@ -288,78 +284,80 @@ void LoadStationData(char *pszFile, char *pszShortFile, WIDATA *Data) Data->InternalVer = 6;
else
{
- wsprintf(Line, Translate("Invalid ini format for: %s"), pszFile);
- MessageBox(NULL, Line, Translate("Weather Protocol"), MB_OK|MB_ICONERROR);
+ wsprintfA(Line, Translate("Invalid ini format for: %s"), pszFile);
+ MessageBoxA(NULL, Line, Translate("Weather Protocol"), MB_OK|MB_ICONERROR);
fclose(pfile);
return;
}
// initialize all data fields
Group = "";
- Data->DisplayName = "";
- Data->InternalName = "";
- Data->Description = "";
- Data->Author = "";
- Data->Version = "";
+
+ Data->DisplayName = _T("");
+ Data->InternalName = _T("");
+ Data->Description = _T("");
+ Data->Author = _T("");
+ Data->Version = _T("");
Data->DefaultURL = "";
- Data->DefaultMap = "";
+ Data->DefaultMap = _T("");
Data->UpdateURL = "";
Data->UpdateURL2 = "";
Data->UpdateURL3 = "";
Data->UpdateURL4 = "";
Data->Cookie = "";
Data->IDSearch.SearchURL = "";
- Data->IDSearch.NotFoundStr = "";
+ Data->IDSearch.NotFoundStr = _T("");
Data->NameSearch.SearchURL = "";
- Data->NameSearch.NotFoundStr = "";
- Data->NameSearch.SingleStr = "";
- Data->NameSearch.Single.First = "";
- Data->NameSearch.Multiple.First = "";
+ Data->NameSearch.NotFoundStr = _T("");
+ Data->NameSearch.SingleStr = _T("");
+ Data->NameSearch.Single.First = _T("");
+ Data->NameSearch.Multiple.First = _T("");
Data->IDSearch.Available = FALSE;
Data->NameSearch.Single.Available = FALSE;
Data->NameSearch.Multiple.Available = FALSE;
wSetData(&Data->FileName, pszFile);
wSetData(&Data->ShortFileName, pszShortFile);
- ResetDataItem(&Data->IDSearch.Name, "ID Search - Station Name");
- ResetDataItem(&Data->NameSearch.Single.Name, "Name Search Single Result - Station Name");
- ResetDataItem(&Data->NameSearch.Single.ID, "Name Search Single Result - Station ID");
- ResetDataItem(&Data->NameSearch.Multiple.Name, "Name Search Multiple Result - Station Name");
- ResetDataItem(&Data->NameSearch.Multiple.ID, "Name Search Multiple Result - Station ID");
+ ResetDataItem(&Data->IDSearch.Name, _T("ID Search - Station Name"));
+ ResetDataItem(&Data->NameSearch.Single.Name, _T("Name Search Single Result - Station Name"));
+ ResetDataItem(&Data->NameSearch.Single.ID, _T("Name Search Single Result - Station ID"));
+ ResetDataItem(&Data->NameSearch.Multiple.Name, _T("Name Search Multiple Result - Station Name"));
+ ResetDataItem(&Data->NameSearch.Multiple.ID, _T("Name Search Multiple Result - Station ID"));
- DataItem.Name = "";
- DataItem.Start = "";
- DataItem.End = "";
- DataItem.Unit = "";
+ DataItem.Name = _T("");
+ DataItem.Start = _T("");
+ DataItem.End = _T("");
+ DataItem.Unit = _T("");
DataItem.Url = "";
- DataItem.Break = "";
+ DataItem.Break = _T("");
DataItem.Type = 0;
Temp = "";
// initialize the linked list for update items
Data->UpdateDataCount = 0;
- Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + strlen(pszShortFile) + strlen(pszFile) + 20;
+ Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + (_tcslen(pszShortFile) + _tcslen(pszFile) + 20)*sizeof( TCHAR );
Data->UpdateData = NULL;
Data->UpdateDataTail = NULL;
// initialize the icon assignment list
- for (i=0; i<10; i++) WICondListInit(&Data->CondList[i]);
+ for (i=0; i<10; i++)
+ WICondListInit( &Data->CondList[i] );
- while (!feof(pfile))
- {
+ while (!feof(pfile)) {
// determine current tag
- if (fgets(Line, sizeof(Line), pfile) == NULL) break;
+ if (fgets(Line, SIZEOF(Line), pfile) == NULL)
+ break;
TrimString(Line);
// if the line is a group header/footer
- if (Line[0] == '[')
- {
+ if (Line[0] == '[') {
char *chop = strchr(Line+1,']');
- if (chop == NULL) continue;
- if (Line[1] != '/') // if it is not a footer (for old ini)
- {
+ if (chop == NULL)
+ continue;
+
+ if (Line[1] != '/') { // if it is not a footer (for old ini)
// save the group name
Temp = (char *)mir_alloc(strlen(Line)+10);
strncpy(Temp, Line+1, chop-Line-1);
@@ -397,27 +395,24 @@ void LoadStationData(char *pszFile, char *pszShortFile, WIDATA *Data) Value++;
ConvertBackslashes(Value);
// store the value for each string
- if (!_stricmp(Group, "HEADER"))
- {
- if (!_stricmp(ValName, "NAME")) wSetData(&Data->DisplayName, Value);
+ if (!_stricmp(Group, "HEADER")) {
+ if (!_stricmp(ValName, "NAME")) wSetData(&Data->DisplayName, Value);
else if (!_stricmp(ValName, "INTERNAL NAME")) wSetData(&Data->InternalName, Value);
else if (!_stricmp(ValName, "DESCRIPTION")) wSetData(&Data->Description, Value);
else if (!_stricmp(ValName, "AUTHOR")) wSetData(&Data->Author, Value);
- else if (!_stricmp(ValName, "VERSION")) wSetData(&Data->Version, Value);
+ else if (!_stricmp(ValName, "VERSION")) wSetData(&Data->Version, Value);
}
else if (!_stricmp(Group, "DEFAULT")) {
- if (!_stricmp(ValName, "DEFAULT URL")) wSetData(&Data->DefaultURL, Value);
+ if (!_stricmp(ValName, "DEFAULT URL")) wSetData(&Data->DefaultURL, Value);
else if (!_stricmp(ValName, "DEFAULT MAP")) wSetData(&Data->DefaultMap, Value);
else if (!_stricmp(ValName, "UPDATE URL")) wSetData(&Data->UpdateURL, Value);
else if (!_stricmp(ValName, "UPDATE URL2")) wSetData(&Data->UpdateURL2, Value);
else if (!_stricmp(ValName, "UPDATE URL3")) wSetData(&Data->UpdateURL3, Value);
else if (!_stricmp(ValName, "UPDATE URL4")) wSetData(&Data->UpdateURL4, Value);
- else if (!_stricmp(ValName, "COOKIE")) wSetData(&Data->Cookie, Value);
+ else if (!_stricmp(ValName, "COOKIE")) wSetData(&Data->Cookie, Value);
}
- else if (!_stricmp(Group, "ID SEARCH"))
- {
- if (!_stricmp(ValName, "AVAILABLE"))
- {
+ else if (!_stricmp(Group, "ID SEARCH")) {
+ if (!_stricmp(ValName, "AVAILABLE")) {
if (!_stricmp(Value, "TRUE")) Data->IDSearch.Available = TRUE;
else Data->IDSearch.Available = FALSE;
}
@@ -426,15 +421,12 @@ void LoadStationData(char *pszFile, char *pszShortFile, WIDATA *Data) else if (!_stricmp(ValName, "NAME START")) wSetData(&Data->IDSearch.Name.Start, Value);
else if (!_stricmp(ValName, "NAME END")) wSetData(&Data->IDSearch.Name.End, Value);
}
- else if (!_stricmp(Group, "NAME SEARCH"))
- {
- if (!_stricmp(ValName, "SINGLE RESULT"))
- {
+ else if (!_stricmp(Group, "NAME SEARCH")) {
+ if (!_stricmp(ValName, "SINGLE RESULT")) {
if (!_stricmp(Value, "TRUE")) Data->NameSearch.Single.Available = TRUE;
else Data->NameSearch.Single.Available = FALSE;
}
- else if (!_stricmp(ValName, "MULTIPLE RESULT"))
- {
+ else if (!_stricmp(ValName, "MULTIPLE RESULT")) {
if (!_stricmp(Value, "TRUE")) Data->NameSearch.Multiple.Available = TRUE;
else Data->NameSearch.Multiple.Available = FALSE;
}
@@ -452,43 +444,35 @@ void LoadStationData(char *pszFile, char *pszShortFile, WIDATA *Data) else if (!_stricmp(ValName, "MULT ID START")) wSetData(&Data->NameSearch.Multiple.ID.Start, Value);
else if (!_stricmp(ValName, "MULT ID END")) wSetData(&Data->NameSearch.Multiple.ID.End, Value);
}
- else if (!_stricmp(Group, "ICONS"))
- {
- for (i=0; i<10; i++)
- {
- if (!_stricmp(ValName, statusStr[i]))
- {
+ else if (!_stricmp(Group, "ICONS")) {
+ for (i=0; i<10; i++) {
+ if ( !_stricmp(ValName, statusStr[i])) {
WICondListAdd(Value, &Data->CondList[i]);
break;
}
}
}
- else if (Data->UpdateDataCount != 0)
- {
+ else if (Data->UpdateDataCount != 0) {
if (!_stricmp(ValName, "START")) wSetData(&Data->UpdateDataTail->Item.Start, Value);
else if (!_stricmp(ValName, "SOURCE")) wSetData(&Data->UpdateDataTail->Item.Start, Value);
else if (!_stricmp(ValName, "END")) wSetData(&Data->UpdateDataTail->Item.End, Value);
else if (!_stricmp(ValName, "UNIT")) wSetData(&Data->UpdateDataTail->Item.Unit, Value);
else if (!_stricmp(ValName, "URL")) wSetData(&Data->UpdateDataTail->Item.Url, Value);
- else if (!_stricmp(ValName, "HIDDEN"))
- {
- if (!_stricmp(Value, "TRUE"))
- {
- char *nm = Data->UpdateDataTail->Item.Name;
- size_t len = strlen(nm) + 1;
+ else if (!_stricmp(ValName, "HIDDEN")) {
+ if (!_stricmp(Value, "TRUE")) {
+ TCHAR *nm = Data->UpdateDataTail->Item.Name;
+ size_t len = _tcslen(nm) + 1;
- Data->UpdateDataTail->Item.Name = nm = ( char* )mir_realloc(nm, len + 3);
- memmove(nm + 1, nm, len);
+ Data->UpdateDataTail->Item.Name = nm = ( TCHAR* )mir_realloc(nm, sizeof(TCHAR)*(len + 3));
+ memmove(nm + 1, nm, len*sizeof( TCHAR ));
*nm = '#';
}
}
- else if (!_stricmp(ValName, "SET DATA"))
- {
+ else if (!_stricmp(ValName, "SET DATA")) {
Data->UpdateDataTail->Item.Type = WID_SET;
wSetData(&Data->UpdateDataTail->Item.End, Value);
}
- else if (!_stricmp(ValName, "BREAK DATA"))
- {
+ else if (!_stricmp(ValName, "BREAK DATA")) {
Data->UpdateDataTail->Item.Type = WID_BREAK;
wSetData(&Data->UpdateDataTail->Item.Break, Value);
}
@@ -588,20 +572,21 @@ INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar case IDC_STEP2:
{
- char szPath[1024], *chop;
+ TCHAR szPath[1024], *chop;
GetModuleFileName(GetModuleHandle(NULL), szPath, sizeof(szPath));
- chop = strrchr(szPath, '\\');
+ chop = _tcsrchr(szPath, '\\');
*chop = '\0';
- strcat(szPath,"\\Plugins\\weather\\");
- _mkdir(szPath);
- ShellExecute((HWND)lParam, "open", szPath, "", "", SW_SHOW);
+ _tcscat(szPath, _T("\\Plugins\\weather\\"));
+ _tmkdir(szPath);
+ ShellExecute((HWND)lParam, _T("open"), szPath, _T(""), _T(""), SW_SHOW);
break;
}
case IDC_STEP3:
if (LoadWIData(FALSE))
- MessageBox(NULL, Translate("All update data has been reloaded."),
- Translate("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL,
+ TranslateT("All update data has been reloaded."),
+ TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
break;
case IDC_STEP4:
diff --git a/protocols/Weather/weather_mwin.cpp b/protocols/Weather/weather_mwin.cpp index 8f40fde594..4c43cc2afe 100644 --- a/protocols/Weather/weather_mwin.cpp +++ b/protocols/Weather/weather_mwin.cpp @@ -161,7 +161,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara {
RECT r, rc;
- if(GetUpdateRect(hwnd, &r, FALSE))
+ if (GetUpdateRect(hwnd, &r, FALSE))
{
DBVARIANT dbv = {0};
PAINTSTRUCT ps;
@@ -197,14 +197,13 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara fntc1 = CallService(MS_FONT_GET, (WPARAM)&fntid, (LPARAM)&lfnt1);
}
- DBGetContactSettingString(data->hContact, WEATHERCONDITION, "WeatherInfo", &dbv);
+ DBGetContactSettingTString(data->hContact, WEATHERCONDITION, "WeatherInfo", &dbv);
GetClientRect(hwnd, &rc);
hdc = BeginPaint(hwnd, &ps);
- if (ServiceExists(MS_SKIN_DRAWGLYPH))
- {
+ if (ServiceExists(MS_SKIN_DRAWGLYPH)) {
SKINDRAWREQUEST rq;
memset(&rq, 0, sizeof(rq));
rq.hDC = hdc;
@@ -215,8 +214,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara CallService(MS_SKIN_DRAWGLYPH, (WPARAM)&rq, 0);
}
- if (clr != 0xFFFFFFFF)
- {
+ if (clr != 0xFFFFFFFF) {
HBRUSH hBkgBrush = CreateSolidBrush(clr);
FillRect(hdc, &rc, hBkgBrush);
DeleteObject(hBkgBrush);
@@ -227,26 +225,24 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SetBkMode(hdc, TRANSPARENT);
- {
- HFONT hfnt = CreateFontIndirect(&lfnt1);
- HFONT hfntold = ( HFONT )SelectObject(hdc, hfnt);
- SIZE fontSize;
+ HFONT hfnt = CreateFontIndirect(&lfnt1);
+ HFONT hfntold = ( HFONT )SelectObject(hdc, hfnt);
+ SIZE fontSize;
- char *nick = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)data->hContact, 0);
+ TCHAR *nick = ( TCHAR* )CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)data->hContact, GCDNF_TCHAR);
- GetTextExtentPoint32(hdc, _T("|"), 1, &fontSize);
+ GetTextExtentPoint32(hdc, _T("|"), 1, &fontSize);
- rc.top += 1;
- rc.left += picSize + fontSize.cx;
+ rc.top += 1;
+ rc.left += picSize + fontSize.cx;
- SetTextColor(hdc, fntc1);
- DrawText(hdc, nick, -1, &rc, DT_LEFT | DT_EXPANDTABS);
+ SetTextColor(hdc, fntc1);
+ DrawText(hdc, nick, -1, &rc, DT_LEFT | DT_EXPANDTABS);
- rc.top += fontSize.cy;
+ rc.top += fontSize.cy;
- SelectObject(hdc, hfntold);
- DeleteObject(hfnt);
- }
+ SelectObject(hdc, hfntold);
+ DeleteObject(hfnt);
if (dbv.pszVal)
{
@@ -254,7 +250,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara HFONT hfntold = ( HFONT )SelectObject(hdc, hfnt);
SetTextColor(hdc, fntc);
- DrawText(hdc, dbv.pszVal, -1, &rc, DT_LEFT | DT_EXPANDTABS);
+ DrawText(hdc, dbv.ptszVal, -1, &rc, DT_LEFT | DT_EXPANDTABS);
SelectObject(hdc, hfntold);
DeleteObject(hfnt);
@@ -274,29 +270,28 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara static void addWindow(HANDLE hContact)
{
- CLISTFrame Frame = {0};
- HWND hWnd;
- DBVARIANT dbv;
- char winname[512];
DWORD frameID;
+ DBVARIANT dbv;
DBGetContactSettingString(hContact, WEATHERPROTONAME, "Nick", &dbv);
- mir_snprintf(winname, sizeof(winname), "Weather: %s", dbv.pszVal);
+
+ char winname[512];
+ mir_snprintf(winname, SIZEOF(winname), "Weather: %s", dbv.pszVal);
DBFreeVariant(&dbv);
- hWnd = CreateWindow("WeatherFrame", "", WS_CHILD | WS_VISIBLE,
+ HWND hWnd = CreateWindow( _T("WeatherFrame"), _T(""), WS_CHILD | WS_VISIBLE,
0, 0, 10, 10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, hContact);
+ WindowList_Add(hMwinWindowList, hWnd, hContact);
+ CLISTFrame Frame = {0};
Frame.name = winname;
Frame.cbSize = sizeof(Frame);
Frame.hWnd = hWnd;
Frame.align = alBottom;
Frame.Flags = F_VISIBLE|F_NOBORDER;
Frame.height = 32;
-
- WindowList_Add(hMwinWindowList, hWnd, hContact);
-
frameID = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0);
+
DBWriteContactSettingDword(hContact, WEATHERPROTONAME, "mwin", frameID);
DBWriteContactSettingByte(hContact, "CList", "Hidden", TRUE);
}
@@ -353,7 +348,7 @@ int RedrawFrame(WPARAM wParam, LPARAM lParam) void InitMwin(void)
{
HANDLE hContact;
- HMODULE hUser = GetModuleHandle("user32.dll");
+ HMODULE hUser = GetModuleHandleA("user32.dll");
if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) return;
@@ -373,7 +368,7 @@ void InitMwin(void) wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = 0; //(HBRUSH)(COLOR_3DFACE+1);
wndclass.lpszMenuName = NULL;
- wndclass.lpszClassName = "WeatherFrame";
+ wndclass.lpszClassName = _T("WeatherFrame");
RegisterClass(&wndclass);
}
@@ -420,7 +415,7 @@ void InitMwin(void) while(hContact)
{
// see if the contact is a weather contact
- if(IsMyContact(hContact))
+ if (IsMyContact(hContact))
{
if (DBGetContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0))
addWindow(hContact);
@@ -436,7 +431,7 @@ void DestroyMwin(void) while(hContact)
{
// see if the contact is a weather contact
- if(IsMyContact(hContact))
+ if (IsMyContact(hContact))
{
DWORD frameId = DBGetContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0);
if (frameId)
@@ -444,6 +439,6 @@ void DestroyMwin(void) }
hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
- UnregisterClass("WeatherFrame", hInst);
+ UnregisterClass( _T("WeatherFrame"), hInst);
UnhookEvent(hFontHook);
}
diff --git a/protocols/Weather/weather_opt.cpp b/protocols/Weather/weather_opt.cpp index 59419edf1b..68512e09c8 100644 --- a/protocols/Weather/weather_opt.cpp +++ b/protocols/Weather/weather_opt.cpp @@ -123,72 +123,62 @@ void LoadOptions(void) opt.pUnit = (WORD)DBGetContactSettingWord(NULL, WEATHERPROTONAME, "pUnit", 4);
opt.dUnit = (WORD)DBGetContactSettingWord(NULL, WEATHERPROTONAME, "dUnit", 1);
opt.eUnit = (WORD)DBGetContactSettingWord(NULL, WEATHERPROTONAME, "eUnit", 2);
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"DegreeSign",&dbv))
- strcpy(opt.DegreeSign, "");
- else
- {
- strcpy(opt.DegreeSign, dbv.pszVal);
+ if (DBGetContactSettingTString(NULL,WEATHERPROTONAME,"DegreeSign",&dbv))
+ _tcscpy(opt.DegreeSign, _T(""));
+ else {
+ _tcscpy(opt.DegreeSign, dbv.ptszVal);
DBFreeVariant(&dbv);
}
opt.DoNotAppendUnit = DBGetContactSettingByte(NULL, WEATHERPROTONAME, "DoNotAppendUnit", 0);
opt.NoFrac = DBGetContactSettingByte(NULL, WEATHERPROTONAME, "NoFractions", 0);
// texts
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"DisplayText",&dbv))
- SetTextDefault("C");
- else
- {
- wSetData(&opt.cText, Translate(dbv.pszVal));
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"DisplayText",&dbv)) {
+ wSetData(&opt.cText, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"BriefTextTitle",&dbv))
- SetTextDefault("b");
- else
- {
- wSetData(&opt.bTitle, Translate(dbv.pszVal));
+ else SetTextDefault("C");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"BriefTextTitle",&dbv)) {
+ wSetData(&opt.bTitle, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"BriefText",&dbv))
- SetTextDefault("B");
- else
- {
- wSetData(&opt.bText, Translate(dbv.pszVal));
+ else SetTextDefault("b");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"BriefText",&dbv)) {
+ wSetData(&opt.bText, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"NoteText",&dbv))
- SetTextDefault("N");
- else
- {
- wSetData(&opt.nText, Translate(dbv.pszVal));
+ else SetTextDefault("B");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"NoteText",&dbv)) {
+ wSetData(&opt.nText, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"ExtText",&dbv))
- SetTextDefault("E");
- else
- {
- wSetData(&opt.eText, Translate(dbv.pszVal));
+ else SetTextDefault("N");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"ExtText",&dbv)) {
+ wSetData(&opt.eText, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"HistoryText",&dbv))
- SetTextDefault("H");
- else
- {
- wSetData(&opt.hText, Translate(dbv.pszVal));
+ else SetTextDefault("E");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"HistoryText",&dbv)) {
+ wSetData(&opt.hText, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"ExtraText",&dbv))
- SetTextDefault("X");
- else
- {
- wSetData(&opt.xText, Translate(dbv.pszVal));
+ else SetTextDefault("H");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"ExtraText",&dbv)) {
+ wSetData(&opt.xText, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"StatusText",&dbv))
- SetTextDefault("S");
- else
- {
- wSetData(&opt.sText, Translate(dbv.pszVal));
+ else SetTextDefault("X");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"StatusText",&dbv)) {
+ wSetData(&opt.sText, TranslateTS(dbv.ptszVal));
DBFreeVariant(&dbv);
}
+ else SetTextDefault("S");
// advanced
opt.DisCondIcon = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"DisableConditionIcon",FALSE);
@@ -208,28 +198,24 @@ void LoadOptions(void) // popup delay
opt.pDelay = DBGetContactSettingDword(NULL,WEATHERPROTONAME,"PopupDelay",0);
// popup texts
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"PopupTitle",&dbv))
- SetTextDefault("P");
- else
- {
- wSetData(&opt.pTitle, dbv.pszVal);
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"PopupTitle",&dbv)) {
+ wSetData(&opt.pTitle, dbv.ptszVal);
DBFreeVariant(&dbv);
}
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"PopupText",&dbv))
- SetTextDefault("p");
- else
- {
- wSetData(&opt.pText, dbv.pszVal);
+ else SetTextDefault("P");
+
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"PopupText",&dbv)) {
+ wSetData(&opt.pText, dbv.ptszVal);
DBFreeVariant(&dbv);
}
+ else SetTextDefault("p");
+
// misc
- if (DBGetContactSettingString(NULL,WEATHERPROTONAME,"Default",&dbv))
- opt.Default[0] = 0;
- else
- {
- strcpy(opt.Default, dbv.pszVal);
+ if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"Default",&dbv)) {
+ _tcscpy(opt.Default, dbv.ptszVal);
DBFreeVariant(&dbv);
}
+ else opt.Default[0] = 0;
}
// save the options to database
@@ -252,18 +238,18 @@ void SaveOptions(void) DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "pUnit", opt.pUnit);
DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "dUnit", opt.dUnit);
DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "eUnit", opt.eUnit);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "DegreeSign", opt.DegreeSign);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "DegreeSign", opt.DegreeSign);
DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "DoNotAppendUnit", (BYTE)opt.DoNotAppendUnit);
DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "NoFractions", (BYTE)opt.NoFrac);
// texts
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "DisplayText", opt.cText);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "BriefTextTitle", opt.bTitle);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "BriefText", opt.bText);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "NoteText", opt.nText);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "ExtText", opt.eText);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "HistoryText", opt.hText);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "ExtraText", opt.xText);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "StatusText", opt.sText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "DisplayText", opt.cText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "BriefTextTitle", opt.bTitle);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "BriefText", opt.bText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "NoteText", opt.nText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "ExtText", opt.eText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "HistoryText", opt.hText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "ExtraText", opt.xText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "StatusText", opt.sText);
// advanced
DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "DisableConditionIcon", (BYTE)opt.DisCondIcon);
// popup options
@@ -282,10 +268,10 @@ void SaveOptions(void) // popup delay
DBWriteContactSettingDword(NULL, WEATHERPROTONAME, "PopupDelay", opt.pDelay);
// popup texts
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "PopupTitle", opt.pTitle);
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "PopupText", opt.pText);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "PopupTitle", opt.pTitle);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "PopupText", opt.pText);
// misc stuff
- DBWriteContactSettingString(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default);
}
//============ OPTION INITIALIZATION ============
@@ -299,7 +285,7 @@ int OptInit(WPARAM wParam,LPARAM lParam) { // plugin options
odp.position = 95600;
- odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.pfnDlgProc = OptionsProc;
odp.pszGroup = LPGEN("Network");
odp.pszTitle = WEATHERPROTOTEXT;
@@ -308,7 +294,7 @@ int OptInit(WPARAM wParam,LPARAM lParam) { CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
// text options
- odp.pszTemplate = MAKEINTRESOURCE(IDD_TEXTOPT);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_TEXTOPT);
odp.pfnDlgProc = DlgProcText;
odp.pszTab = LPGEN("Display");
CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
@@ -317,7 +303,7 @@ int OptInit(WPARAM wParam,LPARAM lParam) { if ((ServiceExists(MS_POPUP_ADDPOPUP)))
{
odp.position = 100000000;
- odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUP);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP);
odp.pszGroup = LPGEN("PopUps");
odp.groupPosition = 910000000;
odp.pszTab = NULL;
@@ -333,17 +319,16 @@ int OptInit(WPARAM wParam,LPARAM lParam) { // weather options
INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
- char str[512];
+ TCHAR str[512];
- switch(msg)
- {
+ switch(msg) {
case WM_INITDIALOG:
opt_startup = TRUE;
TranslateDialogDefault(hdlg);
// load settings
- _ltoa(opt.UpdateTime, str, 10);
- SetDlgItemTextWth(hdlg, IDC_UPDATETIME, str);
- SetDlgItemTextWth(hdlg, IDC_DEGREE, opt.DegreeSign);
+ _ltot(opt.UpdateTime, str, 10);
+ SetDlgItemText(hdlg, IDC_UPDATETIME, str);
+ SetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign);
SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETRANGE32, 0, 999);
SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETPOS, 0, opt.AvatarSize);
@@ -404,8 +389,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) return 0;
case WM_NOTIFY:
- switch(((LPNMHDR)lparam)->code)
- {
+ switch(((LPNMHDR)lparam)->code) {
case PSN_APPLY:
// change the status for weather protocol
if (IsDlgButtonChecked(hdlg, IDC_PROTOCOND) && opt.DefStn != NULL)
@@ -417,7 +401,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) // get update time and remove the old timer
GetDlgItemText(hdlg, IDC_UPDATETIME, str, sizeof(str));
- opt.UpdateTime = (WORD)atoi(str);
+ opt.UpdateTime = (WORD)_ttoi(str);
if (opt.UpdateTime < 1) opt.UpdateTime = 1;
KillTimer(NULL, timerId);
timerId = SetTimer(NULL, 0, opt.UpdateTime*60000, (TIMERPROC)timerProc);
@@ -473,14 +457,14 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) void LoadTextSettings(HWND hdlg)
{
// load text option settings from memory
- SetDlgItemTextWth(hdlg, IDC_CTEXT, opt.cText);
- SetDlgItemTextWth(hdlg, IDC_BTITLE, opt.bTitle);
- SetDlgItemTextWth(hdlg, IDC_BTEXT, opt.bText);
- SetDlgItemTextWth(hdlg, IDC_ETEXT, opt.eText);
- SetDlgItemTextWth(hdlg, IDC_NTEXT, opt.nText);
- SetDlgItemTextWth(hdlg, IDC_HTEXT, opt.hText);
- SetDlgItemTextWth(hdlg, IDC_XTEXT, opt.xText);
- SetDlgItemTextWth(hdlg, IDC_BTITLE2, opt.sText);
+ SetDlgItemText(hdlg, IDC_CTEXT, opt.cText);
+ SetDlgItemText(hdlg, IDC_BTITLE, opt.bTitle);
+ SetDlgItemText(hdlg, IDC_BTEXT, opt.bText);
+ SetDlgItemText(hdlg, IDC_ETEXT, opt.eText);
+ SetDlgItemText(hdlg, IDC_NTEXT, opt.nText);
+ SetDlgItemText(hdlg, IDC_HTEXT, opt.hText);
+ SetDlgItemText(hdlg, IDC_XTEXT, opt.xText);
+ SetDlgItemText(hdlg, IDC_BTITLE2, opt.sText);
}
// free the display text settings from memory
@@ -497,12 +481,17 @@ void FreeTextVar(void) }
// text option dialog
+
+static const char *varname[8] = {"C", "b", "B", "N", "X", "E", "H", "S"};
+static const int cname[8] = {IDC_CTEXT, IDC_BTITLE, IDC_BTEXT, IDC_NTEXT, IDC_XTEXT, IDC_ETEXT, IDC_HTEXT, IDC_BTITLE2 };
+static TCHAR* const *var[8] = {&opt.cText, &opt.bTitle, &opt.bText, &opt.nText, &opt.xText, &opt.eText, &opt.hText, &opt.sText };
+
INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
RECT rc, pos;
HWND button;
HMENU hMenu, hMenu1;
- char str[4096];
+ TCHAR str[4096];
switch (msg)
{
case WM_INITDIALOG:
@@ -512,8 +501,8 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) SetWindowPos(hdlg, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
TranslateDialogDefault(hdlg);
// generate the display text for variable list
- strcpy(str, Translate("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
- SetDlgItemTextWth(hdlg, IDC_VARLIST, str);
+ _tcscpy(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
+ SetDlgItemText(hdlg, IDC_VARLIST, str);
// make the more variable and other buttons flat
SendMessage(GetDlgItem(hdlg,IDC_MORE), BUTTONSETASFLATBTN, 0, 0);
@@ -560,11 +549,6 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) case IDC_TM7:
case IDC_TM8:
{
- static const char *varname[8] = {"C", "b", "B", "N", "X", "E", "H", "S"};
- static const int cname[8] = {IDC_CTEXT, IDC_BTITLE, IDC_BTEXT, IDC_NTEXT, IDC_XTEXT,
- IDC_ETEXT, IDC_HTEXT, IDC_BTITLE2 };
- static char* const *var[8] = {&opt.cText, &opt.bTitle, &opt.bText, &opt.nText,
- &opt.xText, &opt.eText, &opt.hText, &opt.sText };
WEATHERINFO winfo;
// display the menu
@@ -573,23 +557,22 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMMENU));
hMenu1 = GetSubMenu(hMenu, 0);
CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM)hMenu1, 0);
- switch(TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL))
- {
+ switch(TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) {
case ID_MPREVIEW:
// show the preview in a message box, using the weather data from the default station
winfo = LoadWeatherInfo(opt.DefStn);
GetDisplay(&winfo, *var[LOWORD(wParam)-IDC_TM1], str);
- MessageBox(NULL, str, Translate("Weather Protocol Text Preview"), MB_OK|MB_TOPMOST);
+ MessageBox(NULL, str, TranslateT("Weather Protocol Text Preview"), MB_OK|MB_TOPMOST);
break;
case ID_MRESET:
{
unsigned varo = LOWORD(wParam) - IDC_TM1;
// remove the old setting from db and free memory
- char* vartmp = *var[varo];
+ TCHAR* vartmp = *var[varo];
wfree(&vartmp);
SetTextDefault(varname[varo]);
- SetDlgItemTextWth(hdlg, cname[varo], *var[varo]);
+ SetDlgItemText(hdlg, cname[varo], *var[varo]);
}
break;
}
@@ -628,25 +611,25 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) case PSN_APPLY:
{
// save the option
- char textstr[MAX_TEXT_SIZE];
+ TCHAR textstr[MAX_TEXT_SIZE];
// free memory for old settings
FreeTextVar();
// save new settings to memory
- GetDlgItemTextWth(hdlg, IDC_CTEXT, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_CTEXT, textstr, MAX_TEXT_SIZE);
wSetData(&opt.cText, textstr);
- GetDlgItemTextWth(hdlg, IDC_BTEXT, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_BTEXT, textstr, MAX_TEXT_SIZE);
wSetData(&opt.bText, textstr);
- GetDlgItemTextWth(hdlg, IDC_BTITLE, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_BTITLE, textstr, MAX_TEXT_SIZE);
wSetData(&opt.bTitle, textstr);
- GetDlgItemTextWth(hdlg, IDC_ETEXT, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_ETEXT, textstr, MAX_TEXT_SIZE);
wSetData(&opt.eText, textstr);
- GetDlgItemTextWth(hdlg, IDC_NTEXT, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_NTEXT, textstr, MAX_TEXT_SIZE);
wSetData(&opt.nText, textstr);
- GetDlgItemTextWth(hdlg, IDC_HTEXT, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_HTEXT, textstr, MAX_TEXT_SIZE);
wSetData(&opt.hText, textstr);
- GetDlgItemTextWth(hdlg, IDC_XTEXT, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_XTEXT, textstr, MAX_TEXT_SIZE);
wSetData(&opt.xText, textstr);
- GetDlgItemTextWth(hdlg, IDC_BTITLE2, textstr, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_BTITLE2, textstr, MAX_TEXT_SIZE);
wSetData(&opt.sText, textstr);
SaveOptions();
UpdateAllInfo(0, 0);
diff --git a/protocols/Weather/weather_popup.cpp b/protocols/Weather/weather_popup.cpp index 270f989c73..9945b5fe8d 100644 --- a/protocols/Weather/weather_popup.cpp +++ b/protocols/Weather/weather_popup.cpp @@ -37,7 +37,7 @@ int WeatherPopup(WPARAM wParam, LPARAM lParam) if (opt.UsePopup && opt.UpdatePopup && (!opt.PopupOnChange || (BOOL)lParam) &&
!DBGetContactSettingByte((HANDLE)wParam, WEATHERPROTONAME, "DPopUp", 0))
{
- POPUPDATAEX ppd = {0};
+ POPUPDATAT ppd = {0};
WEATHERINFO winfo;
// setup the popup
@@ -45,8 +45,8 @@ int WeatherPopup(WPARAM wParam, LPARAM lParam) // if ((HANDLE)wParam != NULL) { // for actual contact
winfo = LoadWeatherInfo((HANDLE)wParam);
ppd.PluginData = ppd.lchIcon = LoadSkinnedProtoIcon(WEATHERPROTONAME, winfo.status);
- GetDisplay(&winfo, opt.pTitle, ppd.lpzContactName);
- GetDisplay(&winfo, opt.pText, ppd.lpzText);
+ GetDisplay(&winfo, opt.pTitle, ppd.lptzContactName);
+ GetDisplay(&winfo, opt.pText, ppd.lptzText);
ppd.PluginWindowProc = (WNDPROC)PopupDlgProc;
// }
// else { // for preview
@@ -123,7 +123,8 @@ int WeatherError(WPARAM wParam, LPARAM lParam) // (threaded)
// lpzText = error text
// kind = display type (see m_popup.h)
-int WPShowMessage(char* lpzText, WORD kind) {
+int WPShowMessage(TCHAR* lpzText, WORD kind)
+{
NotifyEventHooks(hHookWeatherError, (WPARAM)lpzText, (LPARAM)kind);
return 0;
}
@@ -221,9 +222,9 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam // but does not write to the database
void ReadPopupOpt(HWND hdlg)
{
- char text[MAX_TEXT_SIZE];
+ TCHAR text[MAX_TEXT_SIZE];
int num;
- char str[512];
+ TCHAR str[512];
// popup colour
opt.TextColour = SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_GETCOLOUR,0,0);
@@ -231,7 +232,7 @@ void ReadPopupOpt(HWND hdlg) // get delay time
GetDlgItemText(hdlg, IDC_DELAY, str, sizeof(str));
- num = atoi(str);
+ num = _ttoi(str);
opt.pDelay = num;
// other options
@@ -245,9 +246,9 @@ void ReadPopupOpt(HWND hdlg) // popup texts
wfree(&opt.pText);
wfree(&opt.pTitle);
- GetDlgItemTextWth(hdlg, IDC_PText, text, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_PText, text, MAX_TEXT_SIZE);
wSetData(&opt.pText, text);
- GetDlgItemTextWth(hdlg, IDC_PTitle, text, MAX_TEXT_SIZE);
+ GetDlgItemText(hdlg, IDC_PTitle, text, MAX_TEXT_SIZE);
wSetData(&opt.pTitle, text);
}
@@ -255,7 +256,7 @@ void ReadPopupOpt(HWND hdlg) INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int ID;
- char str[512];
+ TCHAR str[512];
HMENU hMenu, hMenu1;
RECT pos;
HWND button;
@@ -271,9 +272,9 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
- SetDlgItemTextWth(hdlg, IDC_LeftClick, Translate(str));
+ SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
- SetDlgItemTextWth(hdlg, IDC_RightClick, Translate(str));
+ SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
DestroyMenu(hMenu);
// other options
@@ -282,11 +283,11 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup);
CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange);
CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings);
- SetDlgItemTextWth(hdlg,IDC_PText, opt.pText);
- SetDlgItemTextWth(hdlg,IDC_PTitle, opt.pTitle);
+ SetDlgItemText(hdlg,IDC_PText, opt.pText);
+ SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
// setting popup delay option
- _ltoa(opt.pDelay, str, 10);
- SetDlgItemTextWth(hdlg,IDC_DELAY, str);
+ _ltot(opt.pDelay, str, 10);
+ SetDlgItemText(hdlg,IDC_DELAY, str);
if (opt.pDelay == -1)
CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
else if (opt.pDelay == 0)
@@ -355,7 +356,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
- SetDlgItemTextWth(hdlg, IDC_RightClick, Translate(str));
+ SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
DestroyMenu(hMenu);
break;
@@ -375,19 +376,19 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
- SetDlgItemTextWth(hdlg, IDC_LeftClick, Translate(str));
+ SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
DestroyMenu(hMenu);
break;
case IDC_PD1:
// Popup delay setting from PopUp plugin
- SetDlgItemText(hdlg, IDC_DELAY, "0");
+ SetDlgItemText(hdlg, IDC_DELAY, _T("0"));
CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
break;
case IDC_PD2:
// Popup delay = permanent
- SetDlgItemText(hdlg, IDC_DELAY, "-1");
+ SetDlgItemText(hdlg, IDC_DELAY, _T("-1"));
CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
break;
@@ -399,19 +400,19 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) case IDC_PDEF:
// set the default value for popup texts
SetTextDefault("Pp");
- SetDlgItemTextWth(hdlg,IDC_PText, opt.pText);
- SetDlgItemTextWth(hdlg,IDC_PTitle, opt.pTitle);
+ SetDlgItemText(hdlg,IDC_PText, opt.pText);
+ SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
wfree(&opt.pText);
wfree(&opt.pTitle);
break;
case IDC_VAR3:
// display variable list
- strcpy(str, " \n"); // to make the message box wider
- strcat(str, Translate("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temperature\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
- strcat(str, "\n");
- strcat(str, Translate("%[..]\tcustom variables"));
- MessageBox(NULL, str, Translate("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
+ _tcscpy(str, _T(" \n")); // to make the message box wider
+ _tcscat(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temperature\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
+ _tcscat(str, _T("\n"));
+ _tcscat(str, TranslateT("%[..]\tcustom variables"));
+ MessageBox(NULL, str, TranslateT("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
break;
case IDC_PREVIEW:
diff --git a/protocols/Weather/weather_svcs.cpp b/protocols/Weather/weather_svcs.cpp index 89c58c2d6e..9e95f307f6 100644 --- a/protocols/Weather/weather_svcs.cpp +++ b/protocols/Weather/weather_svcs.cpp @@ -153,13 +153,14 @@ INT_PTR WeatherGetAvatarInfo(WPARAM wParam, LPARAM lParam) SUNNY,
NA
};
- char szSearchPath[MAX_PATH], *chop;
+
+ TCHAR szSearchPath[MAX_PATH], *chop;
WORD status;
unsigned i;
- PROTO_AVATAR_INFORMATION* ai = ( PROTO_AVATAR_INFORMATION* )lParam;
+ PROTO_AVATAR_INFORMATIONT* ai = ( PROTO_AVATAR_INFORMATIONT* )lParam;
GetModuleFileName(GetModuleHandle(NULL), szSearchPath, sizeof(szSearchPath));
- chop = strrchr(szSearchPath, '\\');
+ chop = _tcsrchr(szSearchPath, '\\');
if (chop) *chop = '\0';
else szSearchPath[0] = 0;
@@ -173,12 +174,12 @@ INT_PTR WeatherGetAvatarInfo(WPARAM wParam, LPARAM lParam) if (i >= 10) return GAIR_NOAVATAR;
ai->format = PA_FORMAT_PNG;
- wsprintf(ai->filename, "%s\\Plugins\\Weather\\%s.png", szSearchPath, statusStr[i]);
- if (_access(ai->filename, 4) == 0) return GAIR_SUCCESS;
+ wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.png"), szSearchPath, statusStr[i]);
+ if (_taccess(ai->filename, 4) == 0) return GAIR_SUCCESS;
ai->format = PA_FORMAT_GIF;
- wsprintf(ai->filename, "%s\\Plugins\\Weather\\%s.gif", szSearchPath, statusStr[i]);
- if (_access(ai->filename, 4) == 0) return GAIR_SUCCESS;
+ wsprintf(ai->filename, _T("%s\\Plugins\\Weather\\%s.gif"), szSearchPath, statusStr[i]);
+ if (_taccess(ai->filename, 4) == 0) return GAIR_SUCCESS;
ai->format = PA_FORMAT_UNKNOWN;
ai->filename[0] = 0;
@@ -189,7 +190,7 @@ INT_PTR WeatherGetAvatarInfo(WPARAM wParam, LPARAM lParam) void AvatarDownloaded(HANDLE hContact)
{
int haveAvatar;
- PROTO_AVATAR_INFORMATION AI = {0};
+ PROTO_AVATAR_INFORMATIONT AI = {0};
AI.cbSize = sizeof(AI);
AI.hContact = hContact;
@@ -208,14 +209,11 @@ static void __cdecl WeatherGetAwayMsgThread(HANDLE hContact) {
DBVARIANT dbv;
Sleep(100);
- if (!DBGetContactSettingString(hContact, "CList", "StatusMsg", &dbv))
- {
- ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS,
- (HANDLE)1, (LPARAM)dbv.pszVal);
+ if ( !DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv)) {
+ ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
DBFreeVariant( &dbv );
}
- else
- ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+ else ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
static INT_PTR WeatherGetAwayMsg(WPARAM wParam, LPARAM lParam)
@@ -237,11 +235,11 @@ void InitServices(void) hService[3] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_LOADICON, WeatherLoadIcon);
hService[4] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_SETSTATUS, WeatherSetStatus);
hService[5] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETSTATUS, WeatherGetStatus);
- hService[6] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_BASICSEARCH, WeatherBasicSearch);
- hService[7] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYEMAIL, WeatherBasicSearch);
+ hService[6] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_BASICSEARCHT, WeatherBasicSearch);
+ hService[7] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYEMAILT, WeatherBasicSearch);
hService[8] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_ADDTOLIST, WeatherAddToList);
hService[9] = CreateProtoServiceFunction(WEATHERPROTONAME, PSS_GETINFO, WeatherGetInfo);
- hService[10] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETAVATARINFO, WeatherGetAvatarInfo);
+ hService[10] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETAVATARINFOT, WeatherGetAvatarInfo);
hService[11] = CreateProtoServiceFunction(WEATHERPROTONAME, PSS_GETAWAYMSG, WeatherGetAwayMsg);
hService[12] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_CREATEADVSEARCHUI, WeatherCreateAdvancedSearchUI);
hService[13] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYADVANCED, WeatherAdvancedSearch);
diff --git a/protocols/Weather/weather_update.cpp b/protocols/Weather/weather_update.cpp index 9b81b023f5..0cf6d890fd 100644 --- a/protocols/Weather/weather_update.cpp +++ b/protocols/Weather/weather_update.cpp @@ -36,7 +36,7 @@ extern HANDLE hUpdateMutex; // hContact = current contact
int UpdateWeather(HANDLE hContact)
{
- char str[256], str2[MAX_TEXT_SIZE], logstr[256];
+ TCHAR str[256], str2[MAX_TEXT_SIZE];
int code;
FILE *file;
DBVARIANT dbv;
@@ -51,10 +51,9 @@ int UpdateWeather(HANDLE hContact) // log to netlib log for debug purpose
Netlib_Logf(hNetlibUser, "************************************************************************");
- dbres = DBGetContactSettingString(hContact, WEATHERPROTONAME, "Nick", &dbv);
+ dbres = DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv);
- Netlib_Logf(hNetlibUser, "<-- Start update for station: %s -->", dbv.pszVal);
- mir_snprintf(logstr, sizeof(logstr), "<-- Update successful for station: %s -->", dbv.pszVal);
+ Netlib_Logf(hNetlibUser, "<-- Start update for station -->");
// download the info and parse it
// result are stored in database
@@ -64,15 +63,15 @@ int UpdateWeather(HANDLE hContact) // error occurs if the return value is not equals to 0
if (opt.ShowWarnings)
{ // show warnings by popup
- mir_snprintf(str, sizeof(str)-105,
- Translate("Unable to retrieve weather information for %s"), dbv.pszVal);
- strcat(str, "\n");
- strcat(str, GetError(code));
+ mir_sntprintf(str, SIZEOF(str)-105,
+ TranslateT("Unable to retrieve weather information for %s"), dbv.ptszVal);
+ _tcscat(str, _T("\n"));
+ _tcscat(str, GetError(code));
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.pszVal);
+ Netlib_Logf(hNetlibUser, "<-- Error occurs while updating station: %s -->", dbv.ptszVal);
if (!dbres) DBFreeVariant(&dbv);
return 1;
}
@@ -82,42 +81,35 @@ int UpdateWeather(HANDLE hContact) winfo = LoadWeatherInfo(hContact);
// translate weather condition
- strcpy(winfo.cond, Translate(winfo.cond));
+ _tcscpy(winfo.cond, TranslateTS(winfo.cond));
// compare the old condition and determine if the weather had changed
- if (opt.UpdateOnlyConditionChanged) // consider condition change
- {
- if (!DBGetContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", &dbv))
- {
- if (_stricmp(winfo.cond, dbv.pszVal)) Ch = TRUE; // the weather condition is changed
+ if (opt.UpdateOnlyConditionChanged) { // consider condition change
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastCondition", &dbv)) {
+ if (_tcsicmp(winfo.cond, dbv.ptszVal)) Ch = TRUE; // the weather condition is changed
DBFreeVariant(&dbv);
}
else Ch = TRUE;
- if (!DBGetContactSettingString(hContact, WEATHERPROTONAME, "LastTemperature", &dbv))
- {
- if (_stricmp(winfo.temp, dbv.pszVal)) Ch = TRUE; // the temperature is changed
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastTemperature", &dbv)) {
+ if (_tcsicmp(winfo.temp, dbv.ptszVal)) Ch = TRUE; // the temperature is changed
DBFreeVariant(&dbv);
}
else Ch = TRUE;
}
- else // consider update time change
- {
- if (!DBGetContactSettingString(hContact, WEATHERPROTONAME, "LastUpdate", &dbv))
- {
- if (_stricmp(winfo.update, dbv.pszVal)) Ch = TRUE; // the update time is changed
+ else { // consider update time change
+ if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastUpdate", &dbv)) {
+ if (_tcsicmp(winfo.update, dbv.ptszVal)) Ch = TRUE; // the update time is changed
DBFreeVariant(&dbv);
}
else Ch = TRUE;
}
// have weather alert issued?
- dbres = DBGetContactSettingString(hContact, WEATHERCONDITION, "Alert", &dbv);
- if (!dbres && dbv.pszVal[0] != 0)
- {
- if (opt.AlertPopup && !DBGetContactSettingByte(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch)
- {
+ dbres = DBGetContactSettingTString(hContact, WEATHERCONDITION, "Alert", &dbv);
+ if (!dbres && dbv.ptszVal[0] != 0) {
+ if (opt.AlertPopup && !DBGetContactSettingByte(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) {
// display alert popup
- wsprintf(str, "Alert for %s%c%s", winfo.city, 255, dbv.pszVal);
+ wsprintf(str, _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal);
WPShowMessage(str, SM_WEATHERALERT);
}
// alert issued, set display to italic
@@ -130,10 +122,10 @@ int UpdateWeather(HANDLE hContact) if (!dbres) DBFreeVariant(&dbv);
// backup current condition for checking if the weather is changed or not
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastLog", winfo.update);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", winfo.cond);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastTemperature", winfo.temp);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastUpdate", winfo.update);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastLog", winfo.update);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastCondition", winfo.cond);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastTemperature", winfo.temp);
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastUpdate", winfo.update);
// display condition on contact list
if (opt.DisCondIcon && winfo.status != ID_STATUS_OFFLINE)
@@ -143,27 +135,11 @@ int UpdateWeather(HANDLE hContact) AvatarDownloaded(hContact);
GetDisplay(&winfo, opt.cText, str2);
- if (lpcp != CP_ACP)
- {
- LPWSTR m_psz = ConvToUnicode(str2);
- DBWriteContactSettingWString(hContact, "CList", "MyHandle", m_psz);
- mir_free(m_psz);
- }
- else
- DBWriteContactSettingString(hContact, "CList", "MyHandle", str2);
+ DBWriteContactSettingTString(hContact, "CList", "MyHandle", str2);
GetDisplay(&winfo, opt.sText, str2);
if (str2[0])
- {
- if (lpcp != CP_ACP)
- {
- wchar_t* m_psz = ConvToUnicode(str2);
- DBWriteContactSettingWString(hContact, "CList", "StatusMsg", m_psz);
- mir_free(m_psz);
- }
- else
- DBWriteContactSettingString(hContact, "CList", "StatusMsg", str2);
- }
+ DBWriteContactSettingTString(hContact, "CList", "StatusMsg", str2);
else
DBDeleteContactSetting(hContact, "CList", "StatusMsg");
@@ -171,15 +147,15 @@ int UpdateWeather(HANDLE hContact) // save descriptions in MyNotes
GetDisplay(&winfo, opt.nText, str2);
- DBWriteContactSettingString(hContact, "UserInfo", "MyNotes", str2);
+ DBWriteContactSettingTString(hContact, "UserInfo", "MyNotes", str2);
GetDisplay(&winfo, opt.xText, str2);
- DBWriteContactSettingString(hContact, WEATHERCONDITION, "WeatherInfo", str2);
+ DBWriteContactSettingTString(hContact, WEATHERCONDITION, "WeatherInfo", str2);
// set the update tag
DBWriteContactSettingByte(hContact, WEATHERPROTONAME, "IsUpdated", TRUE);
// save info for default weather condition
- if (!strcmp(winfo.id, opt.Default) && !opt.NoProtoCondition) {
+ if ( !_tcscmp(winfo.id, opt.Default) && !opt.NoProtoCondition) {
// save current condition for default station to be displayed after the update
old_status = status;
status = winfo.status;
@@ -189,34 +165,27 @@ int UpdateWeather(HANDLE hContact) }
// logging
- if (Ch)
- {
+ if (Ch) {
// play the sound event
SkinPlaySound("weatherupdated");
- if (DBGetContactSettingByte(hContact, WEATHERPROTONAME, "File", 0))
- {
+ if (DBGetContactSettingByte(hContact, WEATHERPROTONAME, "File", 0)) {
// external log
- if (!DBGetContactSettingString(hContact,WEATHERPROTONAME,"Log",&dbv))
- {
+ if (!DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Log",&dbv)) {
// for the option for overwriting the file, delete old file first
if (DBGetContactSettingByte(hContact,WEATHERPROTONAME,"Overwrite",0))
- DeleteFile(dbv.pszVal);
+ DeleteFile(dbv.ptszVal);
// open the file and set point to the end of file
file = fopen( dbv.pszVal, "a");
DBFreeVariant(&dbv);
- if (file != NULL)
- {
+ if (file != NULL) {
// write data to the file and close
GetDisplay(&winfo, opt.eText, str2);
- fputs(str2, file);
+ fputws(str2, file);
fclose(file);
- }
- }
- }
+ } } }
- if (DBGetContactSettingByte(hContact, WEATHERPROTONAME, "History", 0))
- {
+ if (DBGetContactSettingByte(hContact, WEATHERPROTONAME, "History", 0)) {
DBEVENTINFO dbei = {0};
// internal log using history
GetDisplay(&winfo, opt.hText, str2);
@@ -225,8 +194,8 @@ int UpdateWeather(HANDLE hContact) dbei.timestamp = (DWORD)time(NULL);
dbei.flags = DBEF_READ;
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = (DWORD)strlen(str2)+1;
- dbei.pBlob = (PBYTE)str2;
+ dbei.pBlob = (PBYTE)mir_utf8encodeT(str2);
+ dbei.cbBlob = (DWORD)strlen((char*)dbei.pBlob)+1;
// add the history event
CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
@@ -237,9 +206,7 @@ int UpdateWeather(HANDLE hContact) }
Netlib_Logf(hNetlibUser, "Update Completed - Start to free memory");
-
- // free memory
- Netlib_Logf(hNetlibUser, logstr);
+ Netlib_Logf(hNetlibUser, "<-- Update successful for station -->");
// Update frame data
UpdateMwinData(hContact);
@@ -329,7 +296,7 @@ void UpdateAll(BOOL AutoUpdate, BOOL RemoveData) HANDLE hContact= (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while (hContact != NULL)
{
- if(IsMyContact(hContact))
+ if (IsMyContact(hContact))
{
if (!DBGetContactSettingByte(hContact,WEATHERPROTONAME,"AutoUpdate",FALSE) || !AutoUpdate)
{
@@ -350,7 +317,7 @@ void UpdateAll(BOOL AutoUpdate, BOOL RemoveData) // wParam = handle for the weather station that is going to be updated
INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM lParam)
{
- if(IsMyContact((HANDLE)wParam))
+ if (IsMyContact((HANDLE)wParam))
{
// add the station to the end of the update queue
UpdateListAdd((HANDLE)wParam);
@@ -369,7 +336,7 @@ INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM lParam) // wParam = handle for the weather station that is going to be updated
INT_PTR UpdateSingleRemove(WPARAM wParam, LPARAM lParam)
{
- if(IsMyContact((HANDLE)wParam))
+ if (IsMyContact((HANDLE)wParam))
{
// add the station to the end of the update queue, and also remove old data
DBDataManage((HANDLE)wParam, WDBM_REMOVE, 0, 0);
@@ -426,21 +393,19 @@ INT_PTR UpdateAllRemove(WPARAM wParam,LPARAM lParam) { // hContact = the contact to get the data
int GetWeatherData(HANDLE hContact)
{
- char *loc, id[256], Svc[256], DataValue[MAX_DATA_LEN], *szData = NULL, *szInfo;
- int retval, i;
- WIDATAITEMLIST* Item;
- WIDATA *Data;
- WORD cond = NA;
-
// get eacnh part of the id's
- GetStationID(hContact, id, sizeof(id));
+ TCHAR id[256];
+ GetStationID(hContact, id, SIZEOF(id));
// test ID format
- loc = strchr(id, '/');
- if (loc == NULL) return INVALID_ID_FORMAT;
+ TCHAR* szInfo = _tcschr(id, '/');
+ if (szInfo == NULL)
+ return INVALID_ID_FORMAT;
GetID(id);
- GetStationID(hContact, Svc, sizeof(Svc));
+
+ TCHAR Svc[256];
+ GetStationID(hContact, Svc, SIZEOF(Svc));
GetSvc(Svc);
// check for invalid station
@@ -448,83 +413,74 @@ int GetWeatherData(HANDLE hContact) if (Svc[0] == 0) return INVALID_SVC;
// get the update strings (loaded to memory from ini files)
- Data = GetWIData(Svc);
- if (Data == NULL) return SVC_NOT_FOUND; // the ini for the station cannot be found
+ WIDATA *Data = GetWIData(Svc);
+ if (Data == NULL)
+ return SVC_NOT_FOUND; // the ini for the station cannot be found
- for (i=0; i<4; ++i)
- {
+ WIDATAITEMLIST* Item;
+ WORD cond = NA;
+ char loc[256];
+ char* szId = mir_t2a( id );
+ for ( int i=0; i<4; ++i) {
// generate update URL
- switch(i)
- {
+ switch(i) {
case 0:
- loc = (char*)mir_alloc(strlen(Data->UpdateURL)+128);
- wsprintf(loc, Data->UpdateURL, id);
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL, szId);
break;
case 1:
- loc = (char*)mir_alloc(strlen(Data->UpdateURL2)+128);
- wsprintf(loc, Data->UpdateURL2, id);
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL2, szId);
break;
case 2:
- loc = (char*)mir_alloc(strlen(Data->UpdateURL3)+128);
- wsprintf(loc, Data->UpdateURL3, id);
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL3, szId);
break;
case 3:
- loc = (char*)mir_alloc(strlen(Data->UpdateURL4)+128);
- wsprintf(loc, Data->UpdateURL4, id);
+ _snprintf(loc, SIZEOF(loc), Data->UpdateURL4, szId);
break;
}
- if (loc[0] == 0)
- {
- mir_free(loc);
+ if ( loc[0] == 0 )
continue;
- }
// download the html file from the internet
- retval = InternetDownloadFile(loc, Data->Cookie, &szData);
- mir_free(loc);
-
- if (retval != 0)
- {
+ TCHAR* szData = NULL;
+ int retval = InternetDownloadFile(loc, Data->Cookie, &szData);
+ if (retval != 0) {
mir_free(szData);
return retval;
}
- else if (strstr(szData, "Document Not Found") != NULL) {
+ if ( _tcsstr(szData, _T("Document Not Found")) != NULL) {
mir_free(szData);
return DOC_NOT_FOUND;
}
szInfo = szData;
-
Item = Data->UpdateData;
// begin parsing item by item
- while (Item != NULL)
- {
- if (Item->Item.Url[0] != 0 && Item->Item.Url[0] != (i + '1'))
- {
+ while (Item != NULL) {
+ if (Item->Item.Url[0] != 0 && Item->Item.Url[0] != (i + '1')) {
Item = Item->Next;
continue;
}
- switch (Item->Item.Type)
- {
+ TCHAR DataValue[MAX_DATA_LEN];
+ switch (Item->Item.Type) {
case WID_NORMAL:
// if it is a normal item with start= and end=, then parse through the downloaded string
// to get a data value.
GetDataValue(&Item->Item, DataValue, &szInfo);
- if (strcmp(Item->Item.Name, "Condition") && _stricmp(Item->Item.Unit, "Cond"))
- strcpy(DataValue, Translate(DataValue));
+ if ( _tcscmp(Item->Item.Name, _T("Condition")) && _tcsicmp(Item->Item.Unit, _T("Cond")))
+ _tcscpy(DataValue, TranslateTS(DataValue));
break;
case WID_SET:
{
// for the "Set Data=" operation
DBVARIANT dbv;
- char *chop, *str, str2[MAX_DATA_LEN];
+ TCHAR *chop, *str, str2[MAX_DATA_LEN];
BOOL hasvar = FALSE;
size_t stl;
@@ -533,29 +489,28 @@ int GetWeatherData(HANDLE hContact) DataValue[0] = 0;
// go through each part of the operation string seperated by the & operator
do {
- chop = strstr(str, " & ");
// the end of the string, last item
- if (chop == NULL) chop = strchr(str, '\0');
+ chop = _tcsstr(str, _T(" & "));
+ if (chop == NULL)
+ chop = _tcschr(str, '\0');
stl = min(sizeof(str2)-1, (unsigned)(chop-str-2));
- strncpy(str2, str+1, stl);
+ _tcsncpy(str2, str+1, stl);
str2[stl] = 0;
- switch(str[0])
- {
+ switch(str[0]) {
case '[': // variable, add the value to the result string
hasvar = TRUE;
- if (!DBGetData(hContact, str2, &dbv))
- {
- strncat(DataValue, dbv.pszVal, sizeof(DataValue)-strlen(DataValue));
- DataValue[sizeof(DataValue)-1]=0;
+ if ( !DBGetData(hContact, _T2A(str2), &dbv)) {
+ _tcsncat(DataValue, dbv.ptszVal, SIZEOF(DataValue) - _tcslen(DataValue));
+ DataValue[SIZEOF(DataValue)-1]=0;
DBFreeVariant(&dbv);
}
break;
case'\"': // constant, add it to the result string
- strncat(DataValue, Translate(str2), sizeof(DataValue)-strlen(DataValue));
- DataValue[sizeof(DataValue)-1]=0;
+ _tcsncat(DataValue, TranslateTS(str2), SIZEOF(DataValue) - _tcslen(DataValue));
+ DataValue[SIZEOF(DataValue)-1]=0;
break;
}
@@ -569,74 +524,66 @@ int GetWeatherData(HANDLE hContact) case WID_BREAK:
{
// for the "Break Data=" operation
- char *end;
DBVARIANT dbv;
- if (!DBGetData(hContact, Item->Item.Start, &dbv))
- {
- strncpy(DataValue, dbv.pszVal, sizeof(DataValue));
- DataValue[sizeof(DataValue)-1] = 0;
+ if (!DBGetData(hContact, _T2A(Item->Item.Start), &dbv)) {
+ _tcsncpy(DataValue, dbv.ptszVal, SIZEOF(DataValue));
+ DataValue[SIZEOF(DataValue)-1] = 0;
DBFreeVariant(&dbv);
}
- else
- {
+ else {
DataValue[0] = 0;
break; // do not continue if the source is invalid
}
// generate the strings
- end = strstr(DataValue, Item->Item.Break);
- if (end == NULL)
- {
+ TCHAR* end = _tcsstr(DataValue, Item->Item.Break);
+ if (end == NULL) {
DataValue[0] = 0;
break; // exit if break string is not found
}
*end = '\0';
- end+=strlen(Item->Item.Break);
- while (end[0] == ' ') end++; // remove extra space
+ end += _tcslen(Item->Item.Break);
+ while (end[0] == ' ')
+ end++; // remove extra space
ConvertDataValue(&Item->Item, DataValue);
// write the 2 strings created from the break operation
-// DBWriteContactSettingString(hContact, WEATHERCONDITION, Item->Item.Name, DataValue);
if (Item->Item.End[0])
- DBWriteContactSettingString(hContact, WEATHERCONDITION, Item->Item.End, end);
+ DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.End), end);
break;
- }
- }
+ } }
// don't store data if it is not available
- if ((DataValue[0] != 0 && strcmp(DataValue, NODATA) &&
- strcmp(DataValue, Translate(NODATA)) && strcmp(Item->Item.Name, "Ignore")) ||
- (!strcmp(Item->Item.Name, "Alert") && i == 0))
+ if ((DataValue[0] != 0 && _tcscmp(DataValue, NODATA) &&
+ _tcscmp(DataValue, TranslateTS(NODATA)) && _tcscmp(Item->Item.Name, _T("Ignore"))) ||
+ ( !_tcscmp(Item->Item.Name, _T("Alert")) && i == 0))
{
// temporary workaround for mToolTip to show feel-like temperature
- if (!strcmp(Item->Item.Name, "Feel"))
- DBWriteContactSettingString(hContact, WEATHERCONDITION, "Heat Index", DataValue);
- GetStationID(hContact, Svc, sizeof(Svc));
- if (strcmp(Svc, opt.Default) == 0)
- DBWriteContactSettingString(NULL, DEFCURRENTWEATHER, Item->Item.Name, DataValue);
- if (strcmp(Item->Item.Name, "Condition") == 0)
- {
- char buf[128], *cbuf;
- mir_snprintf(buf, sizeof(buf), "#%s Weather", DataValue);
- cbuf = Translate(buf);
+ if ( !_tcscmp(Item->Item.Name, _T("Feel")))
+ DBWriteContactSettingTString(hContact, WEATHERCONDITION, "Heat Index", DataValue);
+ GetStationID(hContact, Svc, SIZEOF(Svc));
+ if ( !_tcscmp(Svc, opt.Default))
+ DBWriteContactSettingTString(NULL, DEFCURRENTWEATHER, _T2A(Item->Item.Name), DataValue);
+ if ( !_tcscmp(Item->Item.Name, _T("Condition"))) {
+ TCHAR buf[128], *cbuf;
+ mir_sntprintf(buf, SIZEOF(buf), _T("#%s Weather"), DataValue);
+ cbuf = TranslateTS(buf);
if (cbuf[0] == '#')
- cbuf = Translate(DataValue);
- DBWriteContactSettingString(hContact, WEATHERCONDITION, Item->Item.Name, cbuf);
- CharLowerBuff(DataValue, (int)strlen(DataValue));
+ cbuf = TranslateTS(DataValue);
+ DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf);
+ CharLowerBuff(DataValue, _tcslen(DataValue));
cond = GetIcon(DataValue, Data);
}
- else if (_stricmp(Item->Item.Unit, "Cond") == 0)
- {
- char buf[128], *cbuf;
- mir_snprintf(buf, sizeof(buf), "#%s Weather", DataValue);
- cbuf = Translate(buf);
+ else if ( _tcsicmp(Item->Item.Unit, _T("Cond")) == 0) {
+ TCHAR buf[128], *cbuf;
+ mir_sntprintf(buf, SIZEOF(buf), _T("#%s Weather"), DataValue);
+ cbuf = TranslateTS(buf);
if (cbuf[0] == '#')
- cbuf = Translate(DataValue);
- DBWriteContactSettingString(hContact, WEATHERCONDITION, Item->Item.Name, cbuf);
+ cbuf = TranslateTS(DataValue);
+ DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf);
}
- else
- DBWriteContactSettingString(hContact, WEATHERCONDITION, Item->Item.Name, DataValue);
+ else DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), DataValue);
}
Item = Item->Next;
}
@@ -645,8 +592,7 @@ int GetWeatherData(HANDLE hContact) // assign condition icon
DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "StatusIcon", cond);
- DBWriteContactSettingString(hContact, WEATHERPROTONAME, "MirVer", Data->DisplayName);
-
+ DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "MirVer", Data->DisplayName);
return 0;
}
diff --git a/protocols/Weather/weather_userinfo.cpp b/protocols/Weather/weather_userinfo.cpp index f608978c12..ba9ee83570 100644 --- a/protocols/Weather/weather_userinfo.cpp +++ b/protocols/Weather/weather_userinfo.cpp @@ -35,7 +35,6 @@ extern INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LP int UserInfoInit(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = {0};
-
odp.cbSize = sizeof(odp);
odp.hInstance = hInst;
odp.position = 100000000;
@@ -50,10 +49,10 @@ int UserInfoInit(WPARAM wParam, LPARAM lParam) else
{
// check if it is a weather contact
- if(IsMyContact((HANDLE)lParam))
+ if (IsMyContact((HANDLE)lParam))
{
// register the contact info page
- odp.pszTemplate = MAKEINTRESOURCE(IDD_USERINFO);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
odp.pfnDlgProc = DlgProcUIPage;
odp.flags = ODPF_BOLDGROUPS;
CallService(MS_USERINFO_ADDPAGE, wParam, (LPARAM)&odp);
@@ -68,12 +67,11 @@ int UserInfoInit(WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
WEATHERINFO w;
- char str[MAX_TEXT_SIZE];
+ TCHAR str[MAX_TEXT_SIZE];
HANDLE hContact;
hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SendMessage(GetDlgItem(hwndDlg,IDC_MOREDETAIL), BUTTONSETASFLATBTN, 0, 0);
@@ -82,7 +80,7 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact);
// load weather info for the contact
w = LoadWeatherInfo((HANDLE)lParam);
- SetDlgItemTextWth(hwndDlg, IDC_INFO1, GetDisplay(&w, Translate("Current condition for %n"), str));
+ SetDlgItemText(hwndDlg, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"), str));
SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON,
(WPARAM)LoadSkinnedProtoIcon(WEATHERPROTONAME,
@@ -98,21 +96,21 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
}
// set the text for displaying other current weather conditions data
- GetDisplay(&w, "%c %t", str);
- SetDlgItemTextWth(hwndDlg, IDC_INFO2, str);
- SetDlgItemTextWth(hwndDlg, IDC_INFO3, w.feel);
- SetDlgItemTextWth(hwndDlg, IDC_INFO4, w.pressure);
- GetDisplay(&w, "%i %w", str);
- SetDlgItemTextWth(hwndDlg, IDC_INFO5, str);
- SetDlgItemTextWth(hwndDlg, IDC_INFO6, w.dewpoint);
- SetDlgItemTextWth(hwndDlg, IDC_INFO7, w.sunrise);
- SetDlgItemTextWth(hwndDlg, IDC_INFO8, w.sunset);
- SetDlgItemTextWth(hwndDlg, IDC_INFO9, w.high);
- SetDlgItemTextWth(hwndDlg, IDC_INFO10, w.low);
- GetDisplay(&w, Translate("Last update on: %u"), str);
- SetDlgItemTextWth(hwndDlg, IDC_INFO11, str);
- SetDlgItemTextWth(hwndDlg, IDC_INFO12, w.humid);
- SetDlgItemTextWth(hwndDlg, IDC_INFO13, w.vis);
+ GetDisplay(&w, _T("%c %t"), str);
+ SetDlgItemText(hwndDlg, IDC_INFO2, str);
+ SetDlgItemText(hwndDlg, IDC_INFO3, w.feel);
+ SetDlgItemText(hwndDlg, IDC_INFO4, w.pressure);
+ GetDisplay(&w, _T("%i %w"), str);
+ SetDlgItemText(hwndDlg, IDC_INFO5, str);
+ SetDlgItemText(hwndDlg, IDC_INFO6, w.dewpoint);
+ SetDlgItemText(hwndDlg, IDC_INFO7, w.sunrise);
+ SetDlgItemText(hwndDlg, IDC_INFO8, w.sunset);
+ SetDlgItemText(hwndDlg, IDC_INFO9, w.high);
+ SetDlgItemText(hwndDlg, IDC_INFO10, w.low);
+ GetDisplay(&w, TranslateT("Last update on: %u"), str);
+ SetDlgItemText(hwndDlg, IDC_INFO11, str);
+ SetDlgItemText(hwndDlg, IDC_INFO12, w.humid);
+ SetDlgItemText(hwndDlg, IDC_INFO13, w.vis);
break;
case WM_DESTROY:
@@ -206,12 +204,12 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l // inserting columns
lvc.cx = LIST_COLUMN;
- lvc.pszText = Translate("Variable");
- ListView_InsertColumnWth(hList, 0, &lvc);
+ lvc.pszText = TranslateT("Variable");
+ ListView_InsertColumn(hList, 0, &lvc);
lvc.cx = aRect.right - LIST_COLUMN - GetSystemMetrics(SM_CXVSCROLL) - 3;
- lvc.pszText = Translate("Information");
- ListView_InsertColumnWth(hList, 1, &lvc);
+ lvc.pszText = TranslateT("Information");
+ ListView_InsertColumn(hList, 1, &lvc);
// inserting data
SendMessage(hwndDlg, WM_UPDATEDATA, 0, 0);
@@ -285,14 +283,14 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l // update current data
// set the text to "updating"
- SetDlgItemTextWth(hwndDlg, IDC_MTEXT, Translate("Retrieving new data, please wait..."));
+ SetDlgItemText(hwndDlg, IDC_MTEXT, TranslateT("Retrieving new data, please wait..."));
ListView_DeleteAllItems(hList);
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.lParam = 1;
- lvi.pszText = (LPSTR)"";
- lvi.iItem = ListView_InsertItemWth(hList, &lvi);
- lvi.pszText = Translate("Retrieving new data, please wait...");
- ListView_SetItemTextWth(hList, lvi.iItem, 1, lvi.pszText);
+ lvi.pszText = (LPTSTR)_T("");
+ lvi.iItem = ListView_InsertItem(hList, &lvi);
+ lvi.pszText = TranslateT("Retrieving new data, please wait...");
+ ListView_SetItemText(hList, lvi.iItem, 1, lvi.pszText);
UpdateSingleStation((WPARAM)hContact, 0);
break;
}
@@ -303,9 +301,9 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_MTOGGLE:
if (IsWindowVisible(GetDlgItem(hwndDlg,IDC_DATALIST)))
- SetDlgItemTextWth(hwndDlg, IDC_MTOGGLE, Translate("More Info"));
+ SetDlgItemText(hwndDlg, IDC_MTOGGLE, TranslateT("More Info"));
else
- SetDlgItemTextWth(hwndDlg, IDC_MTOGGLE, Translate("Brief Info"));
+ SetDlgItemText(hwndDlg, IDC_MTOGGLE, TranslateT("Brief Info"));
ShowWindow(GetDlgItem(hwndDlg,IDC_DATALIST), (int)!IsWindowVisible(
GetDlgItem(hwndDlg,IDC_DATALIST)));
ShowWindow(GetDlgItem(hwndDlg,IDC_MTEXT), (int)!IsWindowVisible(GetDlgItem(hwndDlg,IDC_MTEXT)));
@@ -324,7 +322,7 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l {
case WM_LBUTTONUP:
tr.chrg = enlink->chrg;
- tr.lpstrText = ( LPSTR )mir_alloc(tr.chrg.cpMax - tr.chrg.cpMin + 8);
+ tr.lpstrText = ( LPTSTR )mir_alloc( sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 8));
SendMessage(pNmhdr->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
CallService(MS_UTILS_OPENURL, 1, (LPARAM) tr.lpstrText);
mir_free(tr.lpstrText);
@@ -355,15 +353,13 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l void LoadBriefInfoText(HWND hwndDlg, HANDLE hContact)
{
WEATHERINFO winfo;
- char str[4096], str2[4096];
+ TCHAR str[4096], str2[4096];
// load weather information from the contact into the WEATHERINFO struct
winfo = LoadWeatherInfo(hContact);
// check if data exist. If not, display error message box
if (!(BOOL)DBGetContactSettingByte(hContact, WEATHERPROTONAME, "IsUpdated", FALSE))
- {
- strcpy(str, Translate("No information available.\r\nPlease update weather condition first."));
- }
+ _tcscpy(str, TranslateT("No information available.\r\nPlease update weather condition first."));
else
// set the display text and show the message box
GetDisplay(&winfo, opt.bText, str);
@@ -380,10 +376,10 @@ void LoadBriefInfoText(HWND hwndDlg, HANDLE hContact) SetDlgItemText(hwndDlg, IDC_MTEXT, str);
GetDisplay(&winfo, opt.bTitle, str);
- SetWindowTextWth(hwndDlg, str);
- GetDisplay(&winfo, "%c, %t", str);
- mir_snprintf(str2, SIZEOF(str2), "%s\n%s", winfo.city, str);
- SetDlgItemTextWth(hwndDlg, IDC_HEADERBAR, str2);
+ SetWindowText(hwndDlg, str);
+ GetDisplay(&winfo, _T("%c, %t"), str);
+ mir_sntprintf(str2, SIZEOF(str2), _T("%s\n%s"), winfo.city, str);
+ SetDlgItemText(hwndDlg, IDC_HEADERBAR, str2);
}
// show brief information dialog
@@ -391,7 +387,7 @@ void LoadBriefInfoText(HWND hwndDlg, HANDLE hContact) int BriefInfo(WPARAM wParam, LPARAM lParam)
{
// make sure that the contact is actually a weather one
- if(IsMyContact((HANDLE)wParam))
+ if (IsMyContact((HANDLE)wParam))
{
HWND hMoreDataDlg = WindowList_Find(hDataWindowList,(HANDLE)wParam);
if (hMoreDataDlg != NULL)
@@ -406,7 +402,7 @@ int BriefInfo(WPARAM wParam, LPARAM lParam) }
ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 0);
ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 1);
- SetDlgItemTextWth(hMoreDataDlg, IDC_MTOGGLE, Translate("More Info"));
+ SetDlgItemText(hMoreDataDlg, IDC_MTOGGLE, TranslateT("More Info"));
return 1;
}
return 0;
|