From 75a2eab4a30c503df310118d0d75ff503d59e562 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 27 Nov 2012 17:43:42 +0000 Subject: Weather is a virtual protocol now, optionally git-svn-id: http://svn.miranda-ng.org/main/trunk@2522 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Weather/src/stdafx.cpp | 2 +- protocols/Weather/src/version.h | 6 +- protocols/Weather/src/weather.cpp | 54 +++---- protocols/Weather/src/weather.h | 7 +- protocols/Weather/src/weather_addstn.cpp | 53 +++---- protocols/Weather/src/weather_contacts.cpp | 87 +++++------ protocols/Weather/src/weather_conv.cpp | 41 +++--- protocols/Weather/src/weather_data.cpp | 225 +++++++++++++---------------- protocols/Weather/src/weather_http.cpp | 11 +- protocols/Weather/src/weather_icons.cpp | 3 +- protocols/Weather/src/weather_info.cpp | 5 +- protocols/Weather/src/weather_ini.cpp | 115 +++++++-------- protocols/Weather/src/weather_mwin.cpp | 39 ++--- protocols/Weather/src/weather_opt.cpp | 206 +++++++++++++------------- protocols/Weather/src/weather_popup.cpp | 13 +- protocols/Weather/src/weather_svcs.cpp | 187 ++++++++++-------------- protocols/Weather/src/weather_update.cpp | 106 +++++++------- protocols/Weather/src/weather_userinfo.cpp | 11 +- 18 files changed, 558 insertions(+), 613 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/stdafx.cpp b/protocols/Weather/src/stdafx.cpp index 67ade34c29..2d786344e5 100644 --- a/protocols/Weather/src/stdafx.cpp +++ b/protocols/Weather/src/stdafx.cpp @@ -1,5 +1,5 @@ /* -Copyright (C) 2012 Miranda NG team (http://miranda-ng.org) +Copyright (c) 2012 Miranda NG team (http://miranda-ng.org) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/protocols/Weather/src/version.h b/protocols/Weather/src/version.h index 133e5f0818..58a8f34a3c 100644 --- a/protocols/Weather/src/version.h +++ b/protocols/Weather/src/version.h @@ -1,6 +1,6 @@ -#define __FILEVERSION_STRING 0,3,8,19 -#define __VERSION_STRING "0.3.8.19" -#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 3, 8, 19) +#define __FILEVERSION_STRING 0,3,9,1 +#define __VERSION_STRING "0.3.9.1" +#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 3, 9, 1) #define BETA FALSE #define AUTH "NoName, borkra" diff --git a/protocols/Weather/src/weather.cpp b/protocols/Weather/src/weather.cpp index 299f9ecde6..9eb22252b5 100644 --- a/protocols/Weather/src/weather.cpp +++ b/protocols/Weather/src/weather.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -36,8 +37,6 @@ HWND hPopupWindow; HANDLE hHookWeatherUpdated; HANDLE hHookWeatherError; -static HANDLE hHooks[9]; - HANDLE hDataWindowList; HANDLE hWindowList; @@ -113,11 +112,11 @@ void Upgrade(DWORD lastver) { // for version below v0.3.2.3, remove the "TriggerText" setting if (lastver < PLUGIN_MAKE_VERSION(0,3,2,3)) - DBDeleteContactSetting(NULL, WEATHERPROTONAME, "TriggerText"); + db_unset(NULL, WEATHERPROTONAME, "TriggerText"); if (lastver < PLUGIN_MAKE_VERSION(0,3,3,13)) - DBDeleteContactSetting(NULL, "KnownModules", "Weather"); + db_unset(NULL, "KnownModules", "Weather"); - DBWriteContactSettingDword(NULL, WEATHERPROTONAME, "Version", __VERSION_DWORD); + db_set_dw(NULL, WEATHERPROTONAME, "Version", __VERSION_DWORD); } // weather protocol initialization function @@ -137,7 +136,7 @@ int WeatherInit(WPARAM wParam,LPARAM lParam) timerId = SetTimer(NULL, 0, 5000, timerProc2); // first update is 5 sec after load // weather user detail - hHooks[0] = HookEvent(ME_USERINFO_INITIALISE, UserInfoInit); + HookEvent(ME_USERINFO_INITIALISE, UserInfoInit); hDataWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); hWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0); @@ -153,8 +152,8 @@ void UpgradeContact(DWORD lastver, HANDLE hContact) // for version below v0.3.2.3, suppress online notifications for all weather contacts if (lastver < PLUGIN_MAKE_VERSION(0,3,2,3)) { - DBWriteContactSettingDword(hContact, "Ignore", "Mask", 8); - DBWriteContactSettingDword(hContact, "Ignore", "Mask1", 8); + db_set_dw(hContact, "Ignore", "Mask", 8); + db_set_dw(hContact, "Ignore", "Mask1", 8); } } @@ -176,19 +175,12 @@ void InitVar() // unload function extern "C" int __declspec(dllexport) Unload(void) { - unsigned i; - DestroyMwin(); DestroyWindow(hPopupWindow); - for (i = SIZEOF(hHooks); i--; ) - UnhookEvent(hHooks[i]); - DestroyHookableEvent(hHookWeatherUpdated); DestroyHookableEvent(hHookWeatherError); - DestroyServices(); - NetlibHttpDisconnect(); Netlib_CloseHandle(hNetlibUser); @@ -197,7 +189,6 @@ extern "C" int __declspec(dllexport) Unload(void) DestroyWIList(); // unload all ini data from memory CloseHandle(hUpdateMutex); - return 0; } @@ -205,7 +196,6 @@ extern "C" int __declspec(dllexport) Load(void) { DWORD lastver; - mir_getLP(&pluginInfoEx); // initialize global variables @@ -218,7 +208,7 @@ extern "C" int __declspec(dllexport) Load(void) // I only support version check and upgrade for my own version, so check if the author is my name if (strstr(AUTH, "NoName") != NULL) { - lastver = DBGetContactSettingDword(NULL, WEATHERPROTONAME, "Version", PLUGIN_MAKE_VERSION(0,3,1,8)); + lastver = db_get_dw(NULL, WEATHERPROTONAME, "Version", PLUGIN_MAKE_VERSION(0,3,1,8)); if (lastver < __VERSION_DWORD) Upgrade(lastver); } else // if it is not my build, ignore upgrade procedure @@ -238,28 +228,28 @@ extern "C" int __declspec(dllexport) Load(void) hHookWeatherError = CreateHookableEvent(ME_WEATHER_ERROR); // initialize options and network - hHooks[1] = HookEvent(ME_OPT_INITIALISE, OptInit); - hHooks[2] = HookEvent(ME_SYSTEM_MODULESLOADED, WeatherInit); - hHooks[3] = HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted); - hHooks[4] = HookEvent(ME_CLIST_DOUBLECLICKED, BriefInfo); - hHooks[5] = HookEvent(ME_WEATHER_UPDATED, WeatherPopup); - hHooks[6] = HookEvent(ME_WEATHER_ERROR, WeatherError); - hHooks[7] = HookEvent(ME_SYSTEM_PRESHUTDOWN, WeatherShutdown); - hHooks[8] = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, BuildContactMenu); + HookEvent(ME_OPT_INITIALISE, OptInit); + HookEvent(ME_SYSTEM_MODULESLOADED, WeatherInit); + HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted); + HookEvent(ME_CLIST_DOUBLECLICKED, BriefInfo); + HookEvent(ME_WEATHER_UPDATED, WeatherPopup); + HookEvent(ME_WEATHER_ERROR, WeatherError); + HookEvent(ME_SYSTEM_PRESHUTDOWN, WeatherShutdown); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, BuildContactMenu); hUpdateMutex = CreateMutex(NULL, FALSE, NULL); // register weather protocol PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE }; pd.szName = WEATHERPROTONAME; - pd.type = PROTOTYPE_PROTOCOL; - CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd); + pd.type = (opt.NoProtoCondition) ? PROTOTYPE_VIRTUAL : PROTOTYPE_PROTOCOL; + CallService(MS_PROTO_REGISTERMODULE,0, (LPARAM)&pd); // initialize weather protocol services InitServices(); // add our modules to the KnownModules list - DBWriteContactSettingString(NULL, "KnownModules", "Weather Protocol", "Weather,WeatherCondition,Current"); + db_set_s(NULL, "KnownModules", "Weather Protocol", "Weather,WeatherCondition,Current"); // add sound event SkinAddNewSoundExT("weatherupdated", _T(WEATHERPROTONAME), LPGENT("Weather Condition Changed")); @@ -269,7 +259,7 @@ extern "C" int __declspec(dllexport) Load(void) 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); + CW_USEDEFAULT,CW_USEDEFAULT,HWND_DESKTOP,NULL, hInst,NULL); SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc); return 0; diff --git a/protocols/Weather/src/weather.h b/protocols/Weather/src/weather.h index 6541b24f31..072860c914 100644 --- a/protocols/Weather/src/weather.h +++ b/protocols/Weather/src/weather.h @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -440,7 +441,6 @@ 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, TCHAR** szData); @@ -490,7 +490,6 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam // functions in weather_svcs.c void InitServices(void); -void DestroyServices(void); INT_PTR WeatherSetStatus(WPARAM new_status, LPARAM lParam); INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM lParam); diff --git a/protocols/Weather/src/weather_addstn.cpp b/protocols/Weather/src/weather_addstn.cpp index f4f3740023..9a3f1fd19f 100644 --- a/protocols/Weather/src/weather_addstn.cpp +++ b/protocols/Weather/src/weather_addstn.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -43,19 +44,19 @@ INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam) if ( IsMyContact(hContact)) { DBVARIANT dbv; // check ID to see if the contact already exist in the database - if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) { - if (!_tcsicmp(psr->email, dbv.ptszVal)) { + 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 (db_get_b(hContact, "CList", "NotOnList", 1)) { + db_unset(hContact, "CList", "NotOnList"); + db_unset(hContact, "CList", "Hidden"); } - DBFreeVariant(&dbv); + db_free(&dbv); // contact is added, function quitting return (INT_PTR)hContact; } - DBFreeVariant(&dbv); + db_free(&dbv); } } hContact = db_find_next(hContact); @@ -75,31 +76,31 @@ INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam) // set settings by obtaining the default for the service if (psr->lastName[0] != 0) { sData = GetWIData(svc); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "MapURL", sData->DefaultMap); - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "InfoURL", sData->DefaultURL); + db_set_ts(hContact, WEATHERPROTONAME, "MapURL", sData->DefaultMap); + db_set_s(hContact, WEATHERPROTONAME, "InfoURL", sData->DefaultURL); } else { // if no valid service is found, create empty strings for MapURL and InfoURL - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "MapURL", ""); - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "InfoURL", ""); + db_set_s(hContact, WEATHERPROTONAME, "MapURL", ""); + db_set_s(hContact, WEATHERPROTONAME, "InfoURL", ""); } // write the other info and settings to the database - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "ID", psr->email); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "Nick", psr->nick); - DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE); + db_set_ts(hContact, WEATHERPROTONAME, "ID", psr->email); + db_set_ts(hContact, WEATHERPROTONAME, "Nick", psr->nick); + db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE); AvatarDownloaded(hContact); TCHAR str[256]; mir_sntprintf(str, SIZEOF(str), TranslateT("Current weather information for %s."), psr->nick); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "About", str); + db_set_ts(hContact, WEATHERPROTONAME, "About", str); // make the last update tags to something invalid - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastLog", "never"); - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", "None"); - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastTemperature", "None"); + db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never"); + db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None"); + db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None"); // ignore status change - DBWriteContactSettingDword(hContact, "Ignore", "Mask", 8); + db_set_dw(hContact, "Ignore", "Mask", 8); // if no default station is found, set the new contact as default station if (opt.Default[0] == 0) { @@ -107,13 +108,13 @@ INT_PTR WeatherAddToList(WPARAM wParam, LPARAM lParam) GetStationID(hContact, opt.Default, SIZEOF(opt.Default)); opt.DefStn = hContact; - if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) { + if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) { // notification message box wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION); } - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default); + db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); } // display the Edit Settings dialog box EditSettings((WPARAM)hContact, 0); @@ -330,7 +331,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR * GetDataValue(&sData->Single.Name, Name, &szInfo); } // if station name appears first in the downloaded data - else if (!_tcsicmp(sData->Single.First, _T("NAME"))) { + else if ( !_tcsicmp(sData->Single.First, _T("NAME"))) { GetDataValue(&sData->Single.Name, Name, &szInfo); GetDataValue(&sData->Single.ID, str, &szInfo); wsprintf(sID, _T("%s/%s"), svc, str); @@ -421,7 +422,7 @@ int NameSearch(TCHAR *name, const int searchId) // add a new weather station via find/add dialog int WeatherAdd(WPARAM wParam, LPARAM lParam) { - DBWriteContactSettingString(NULL, "FindAdd", "LastSearched", "Weather"); + db_set_s(NULL, "FindAdd", "LastSearched", "Weather"); CallService(MS_FINDADD_FINDADD, 0, 0); return 0; } diff --git a/protocols/Weather/src/weather_contacts.cpp b/protocols/Weather/src/weather_contacts.cpp index 3c2a250ac6..4c049f5d26 100644 --- a/protocols/Weather/src/weather_contacts.cpp +++ b/protocols/Weather/src/weather_contacts.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -45,7 +46,7 @@ INT_PTR ViewLog(WPARAM wParam, LPARAM lParam) 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); + db_free(&dbv); } else // display warning dialog if no path is specified MessageBox(NULL, TranslateT("Weather condition was not logged."), @@ -80,7 +81,7 @@ INT_PTR WeatherMap(WPARAM wParam, LPARAM lParam) 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; } @@ -181,37 +182,37 @@ 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 (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) { + if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) { SetDlgItemText(hwndDlg, IDC_ID, dbv.ptszVal); // check if the station is a default station CheckDlgButton(hwndDlg, IDC_DEFA, _tcscmp(dbv.ptszVal, opt.Default) != 0); - DBFreeVariant(&dbv); + db_free(&dbv); } - if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) { + if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) { SetDlgItemText(hwndDlg, IDC_NAME, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&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); + db_free(&dbv); } // enable/disable the browse button depending on the value of external log checkbox 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)); + CheckDlgButton(hwndDlg, IDC_DPop, db_get_b(hContact, WEATHERPROTONAME, "DPopUp", FALSE)); + CheckDlgButton(hwndDlg, IDC_DAutoUpdate, db_get_b(hContact, WEATHERPROTONAME, "DAutoUpdate", FALSE)); + CheckDlgButton(hwndDlg, IDC_Internal, db_get_b(hContact, WEATHERPROTONAME, "History", 0)); if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "InfoURL", &dbv)) { SetDlgItemText(hwndDlg, IDC_IURL, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "MapURL", &dbv)) { SetDlgItemText(hwndDlg, IDC_MURL, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } // display the dialog box and free memory @@ -247,7 +248,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa // the button for getting station name from the internet // this function uses the ID search for add/find weather station - if (!CheckSearch()) return TRUE; // don't download if update is in progress + 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)); GetSvc(str); @@ -281,7 +282,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa 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; + if ( !(BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) return TRUE; case IDC_BROWSE: // fall through // browse for the external log file @@ -361,38 +362,38 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa // temporary disable the protocol while applying the change // start writing the new settings to database GetDlgItemText(hwndDlg, IDC_ID, str, SIZEOF(str)); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "ID", str); + db_set_ts(hContact, WEATHERPROTONAME, "ID", str); if ((BYTE)IsDlgButtonChecked(hwndDlg, IDC_DEFA)) { // if default station is set _tcscpy(opt.Default, str); opt.DefStn = hContact; - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default); + db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); } GetDlgItemText(hwndDlg, IDC_NAME, city, SIZEOF(city)); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "Nick", city); + db_set_ts(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); + db_set_ts(hContact, WEATHERPROTONAME, "Log", str); } - else DBDeleteContactSetting(hContact, WEATHERPROTONAME, "Log"); + else db_unset(hContact, WEATHERPROTONAME, "Log"); GetDlgItemText(hwndDlg, IDC_IURL, str, SIZEOF(str)); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "InfoURL", str); + db_set_ts(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); + db_set_ts(hContact, WEATHERPROTONAME, "MapURL", str); + db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_OFFLINE); + db_set_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE); AvatarDownloaded(hContact); - 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)); + db_set_ts(hContact, WEATHERPROTONAME, "About", str2); + db_set_b(hContact, WEATHERPROTONAME, "History", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Internal)); + db_set_b(hContact, WEATHERPROTONAME, "Overwrite", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_Overwrite)); + db_set_b(hContact, WEATHERPROTONAME, "File", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)); + db_set_b(hContact, WEATHERPROTONAME, "DPopUp", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DPop)); + db_set_b(hContact, WEATHERPROTONAME, "DAutoUpdate", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DAutoUpdate)); // re-enable the protocol and update the data for the station - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", "None"); + db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None"); UpdateSingleStation((WPARAM)hContact, 0); case IDCANCEL: // fall through @@ -429,7 +430,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa // wParam = deleted contact int ContactDeleted(WPARAM wParam, LPARAM lParam) { - if (!IsMyContact((HANDLE)wParam)) + if ( !IsMyContact((HANDLE)wParam)) return 0; removeWindow((HANDLE)wParam); @@ -438,10 +439,10 @@ int ContactDeleted(WPARAM wParam, LPARAM lParam) DBVARIANT dbv; if ( !DBGetContactSettingTString((HANDLE)wParam, WEATHERPROTONAME, "ID", &dbv)) { if ( _tcscmp(dbv.ptszVal, opt.Default)) { - DBFreeVariant(&dbv); + db_free(&dbv); return 0; } - DBFreeVariant(&dbv); + db_free(&dbv); } // now the default station is deleted, try to get a new one @@ -450,23 +451,23 @@ int ContactDeleted(WPARAM wParam, LPARAM lParam) HANDLE hContact = db_find_first(); while(hContact) { if (IsMyContact(hContact)) { - if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "ID", &dbv)) { + 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)) { + db_free(&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); + db_free(&dbv); MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); } - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default); + db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); return 0; // exit this function quickly } - DBFreeVariant(&dbv); + db_free(&dbv); } } hContact = db_find_next(hContact); @@ -474,7 +475,7 @@ int ContactDeleted(WPARAM wParam, LPARAM lParam) // got here if no more weather station left opt.Default[0] = 0; // no default station opt.DefStn = NULL; - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default); + db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); return 0; } diff --git a/protocols/Weather/src/weather_conv.cpp b/protocols/Weather/src/weather_conv.cpp index ff5e37cb58..780253b8ac 100644 --- a/protocols/Weather/src/weather_conv.cpp +++ b/protocols/Weather/src/weather_conv.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -90,7 +91,7 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) _tcscpy(str, tempchar); return; } - if (!is_number(tempchar)) { + if ( !is_number(tempchar)) { _tcscpy(str, NODATA); return; } @@ -99,8 +100,8 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) temp = _ttof(tempchar); // convert all to F first - if (!_tcsicmp(unit, _T("C"))) temp = (temp*9/5)+32; - else if (!_tcsicmp(unit, _T("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) { @@ -142,17 +143,17 @@ void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str) } // convert all to mb first - if (!_tcsicmp(unit, _T("KPA"))) + if ( !_tcsicmp(unit, _T("KPA"))) tempunit = (double)output * 10; - else if (!_tcsicmp(unit, _T("HPA"))) + else if ( !_tcsicmp(unit, _T("HPA"))) tempunit = (double)output; - else if (!_tcsicmp(unit, _T("MB"))) + else if ( !_tcsicmp(unit, _T("MB"))) tempunit = (double)output; - else if (!_tcsicmp(unit, _T("IN"))) + else if ( !_tcsicmp(unit, _T("IN"))) tempunit = (double)output * 33.86388; - else if (!_tcsicmp(unit, _T("MM"))) + else if ( !_tcsicmp(unit, _T("MM"))) tempunit = (double)output * 1.33322; - else if (!_tcsicmp(unit, _T("TORR"))) + else if ( !_tcsicmp(unit, _T("TORR"))) tempunit = (double)output * 1.33322; // convert to apporiate unit @@ -199,13 +200,13 @@ void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str) return; // convert all to m/s first - if (!_tcsicmp(unit, _T("KM/H"))) + if ( !_tcsicmp(unit, _T("KM/H"))) tempunit /= 3.6; -// else if (!_tcsicmp(unit, _T("M/S")) +// else if ( !_tcsicmp(unit, _T("M/S")) // tempunit = tempunit; - else if (!_tcsicmp(unit, _T("MPH"))) + else if ( !_tcsicmp(unit, _T("MPH"))) tempunit *= 0.44704; - else if (!_tcsicmp(unit, _T("KNOTS"))) + else if ( !_tcsicmp(unit, _T("KNOTS"))) tempunit *= 0.514444; // convert to apporiate unit @@ -248,9 +249,9 @@ void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str) } // convert all to km first - if (!_tcsicmp(unit, _T("KM"))) + if ( !_tcsicmp(unit, _T("KM"))) tempunit = (double)output; - else if (!_tcsicmp(unit, _T("MILES"))) + else if ( !_tcsicmp(unit, _T("MILES"))) tempunit = (double)output * 1.609; // convert to apporiate unit @@ -288,9 +289,9 @@ void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str) } // convert all to m first - if (!_tcsicmp(unit, _T("M"))) + if ( !_tcsicmp(unit, _T("M"))) tempunit = (double)output; - else if (!_tcsicmp(unit, _T("FT"))) + else if ( !_tcsicmp(unit, _T("FT"))) tempunit = (double)output / 3.28; // convert to apporiate unit @@ -556,7 +557,7 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str) if ( !DBGetContactSettingTString(w->hContact, WEATHERCONDITION, name, &dbv)) { if (dbv.ptszVal != TranslateTS(NODATA) && dbv.ptszVal != TranslateT("")) _tcscat(str, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } break; } diff --git a/protocols/Weather/src/weather_data.cpp b/protocols/Weather/src/weather_data.cpp index 3fadde88e7..5def028c3d 100644 --- a/protocols/Weather/src/weather_data.cpp +++ b/protocols/Weather/src/weather_data.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -17,77 +18,69 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* +/* This file contain the source related loading, obtaining, and saving individual weather data for a weather contact. */ #include "weather.h" -// temporary counter and storage for removing weather data -typedef struct -{ - char *value[1024]; - int current; -} WCOUNTER; - //============ LOAD WEATHER INFO FROM A CONTACT ============ - // get station ID from DB // hContact = the current contact handle // return value = the string for station ID + void GetStationID(HANDLE hContact, TCHAR* id, size_t idlen) { // accessing the database - if (DBGetStaticString(hContact, WEATHERPROTONAME, "ID", id, idlen)) + if ( DBGetStaticString(hContact, WEATHERPROTONAME, "ID", id, idlen)) id[0] = 0; } // initialize weather info by loading values from database -// Change = current contact handle +// hContact = current contact handle // return value = the current weather information in WEATHERINFO struct -WEATHERINFO LoadWeatherInfo(HANDLE Change) +WEATHERINFO LoadWeatherInfo(HANDLE hContact) { - WEATHERINFO winfo; - - winfo.hContact = 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)); + WEATHERINFO winfo; + winfo.hContact = hContact; + GetStationID(hContact, winfo.id, SIZEOF(winfo.id)); - if (DBGetStaticString(Change, WEATHERPROTONAME, "Nick", winfo.city, SIZEOF(winfo.city))) + if ( DBGetStaticString(hContact, WEATHERPROTONAME, "Nick", winfo.city, SIZEOF(winfo.city))) _tcscpy(winfo.city, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Update", winfo.update, SIZEOF(winfo.update))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Update", winfo.update, SIZEOF(winfo.update))) _tcscpy(winfo.update, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Condition", winfo.cond, SIZEOF(winfo.cond))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Condition", winfo.cond, SIZEOF(winfo.cond))) _tcscpy(winfo.cond, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Temperature", winfo.temp, SIZEOF(winfo.temp))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Temperature", winfo.temp, SIZEOF(winfo.temp))) _tcscpy(winfo.temp, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "High", winfo.high, SIZEOF(winfo.high))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "High", winfo.high, SIZEOF(winfo.high))) _tcscpy(winfo.high, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Low", winfo.low, SIZEOF(winfo.low))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Low", winfo.low, SIZEOF(winfo.low))) _tcscpy(winfo.low, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Sunset", winfo.sunset, SIZEOF(winfo.sunset))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, SIZEOF(winfo.sunset))) _tcscpy(winfo.sunset, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Sunrise", winfo.sunrise, SIZEOF(winfo.sunrise))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, SIZEOF(winfo.sunrise))) _tcscpy(winfo.sunrise, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Wind Speed", winfo.wind, SIZEOF(winfo.wind))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, SIZEOF(winfo.wind))) _tcscpy(winfo.wind, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Wind Direction", winfo.winddir, SIZEOF(winfo.winddir))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, SIZEOF(winfo.winddir))) _tcscpy(winfo.winddir, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, SIZEOF(winfo.dewpoint))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, SIZEOF(winfo.dewpoint))) _tcscpy(winfo.dewpoint, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Pressure", winfo.pressure, SIZEOF(winfo.pressure))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, SIZEOF(winfo.pressure))) _tcscpy(winfo.pressure, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Visibility", winfo.vis, SIZEOF(winfo.vis))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Visibility", winfo.vis, SIZEOF(winfo.vis))) _tcscpy(winfo.vis, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Humidity", winfo.humid, SIZEOF(winfo.humid))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Humidity", winfo.humid, SIZEOF(winfo.humid))) _tcscpy(winfo.humid, NODATA); - if (DBGetStaticString(Change, WEATHERCONDITION, "Feel", winfo.feel, SIZEOF(winfo.feel))) + if ( DBGetStaticString(hContact, WEATHERCONDITION, "Feel", winfo.feel, SIZEOF(winfo.feel))) _tcscpy(winfo.feel, NODATA); - winfo.status = (WORD)DBGetContactSettingWord(Change, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE); + winfo.status = (WORD)db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE); return winfo; } @@ -95,7 +88,7 @@ WEATHERINFO LoadWeatherInfo(HANDLE Change) // return 0 on success int DBGetData(HANDLE hContact, char *setting, DBVARIANT *dbv) { - if (DBGetContactSettingTString(hContact, WEATHERCONDITION, setting, dbv)) { + if ( DBGetContactSettingTString(hContact, WEATHERCONDITION, setting, dbv)) { size_t len = strlen(setting) + 1; char *set = (char*)alloca(len + 1); *set = '#'; @@ -115,7 +108,7 @@ int DBGetStaticString(HANDLE hContact, const char *szModule, const char *valueNa _tcsncpy( dest, dbv.ptszVal, dest_len ); dest[ dest_len-1 ] = 0; - DBFreeVariant( &dbv ); + db_free( &dbv ); return 0; } @@ -128,56 +121,56 @@ void EraseAllInfo(DWORD lastver) { TCHAR str[255]; int ContactCount = 0; - HANDLE hContact, LastContact = NULL; + HANDLE LastContact = NULL; DBVARIANT dbv; // loop through all contacts - hContact = db_find_first(); - while(hContact) - { + HANDLE hContact = db_find_first(); + 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); - DBWriteContactSettingWord(hContact,WEATHERPROTONAME,"Status",ID_STATUS_OFFLINE); - DBWriteContactSettingWord(hContact,WEATHERPROTONAME,"StatusIcon",ID_STATUS_OFFLINE); - DBDeleteContactSetting(hContact,"CList","MyHandle"); + if (lastver < __VERSION_DWORD) + UpgradeContact(lastver, hContact); + db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE); + db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE); + db_unset(hContact, "CList", "MyHandle"); // clear all data - if (DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) { - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "Nick", TranslateT("")); - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastLog", "never"); - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastCondition", "None"); - DBWriteContactSettingString(hContact, WEATHERPROTONAME, "LastTemperature", "None"); + if ( DBGetContactSettingTString(hContact, WEATHERPROTONAME, "Nick", &dbv)) { + db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("")); + db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never"); + db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None"); + db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None"); } - else DBFreeVariant(&dbv); + else db_free(&dbv); DBDataManage(hContact, WDBM_REMOVE, 0, 0); - DBWriteContactSettingString(hContact, "UserInfo", "MyNotes", ""); + db_set_s(hContact, "UserInfo", "MyNotes", ""); // reset update tag - DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"IsUpdated",FALSE); + db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE); // reset logging settings - if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Log", &dbv)) { - DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"File",(BYTE)(dbv.ptszVal[0] != 0)); - DBFreeVariant(&dbv); + if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME, "Log", &dbv)) { + db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0)); + db_free(&dbv); } - else DBWriteContactSettingByte(hContact,WEATHERPROTONAME,"File",FALSE); + else db_set_b(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)); opt.DefStn = hContact; - if (!DBGetContactSettingTString(hContact,WEATHERPROTONAME,"Nick",&dbv)) { + if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME, "Nick",&dbv)) { wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION); } } // get the handle of the default station if (opt.DefStn == NULL) { - if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME,"ID",&dbv)) { - if ( !_tcscmp(dbv.ptszVal, opt.Default)) opt.DefStn = hContact; - DBFreeVariant(&dbv); + if ( !DBGetContactSettingTString(hContact,WEATHERPROTONAME, "ID",&dbv)) { + if ( !_tcscmp(dbv.ptszVal, opt.Default)) + opt.DefStn = hContact; + db_free(&dbv); } } ContactCount++; // increment counter @@ -185,23 +178,24 @@ void EraseAllInfo(DWORD lastver) } hContact = db_find_next(hContact); } + // 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 ( !DBGetContactSettingTString(LastContact, WEATHERPROTONAME, "ID", &dbv)) { _tcscpy(opt.Default, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } opt.DefStn = LastContact; - if (!DBGetContactSettingTString(LastContact,WEATHERPROTONAME,"Nick",&dbv)) { + if ( !DBGetContactSettingTString(LastContact,WEATHERPROTONAME, "Nick",&dbv)) { wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION); } } // save option in case of default station changed - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default); + db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); } void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data) @@ -211,7 +205,7 @@ void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data) // convert the unit if ( _tcscmp(Data, TranslateT("")) && _tcscmp(Data, NODATA) && _tcscmp(Data, TranslateTS(NODATA))) { // temperature - if (!_tcscmp(UpdateData->Name, _T("Temperature")) || !_tcscmp(UpdateData->Name, _T("High")) || + 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")) || @@ -221,7 +215,7 @@ void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data) _tcscpy(Data, str); } // pressure - else if (!_tcscmp(UpdateData->Name, _T("Pressure")) || !_tcsicmp(UpdateData->Unit, _T("HPA")) || + 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"))) @@ -230,7 +224,7 @@ void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data) _tcscpy(Data, str); } // speed - else if (!_tcscmp(UpdateData->Name, _T("Wind Speed")) || !_tcsicmp(UpdateData->Unit, _T("KM/H")) || + 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"))) { @@ -238,34 +232,34 @@ void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data) _tcscpy(Data, str); } // visibility - else if (!_tcscmp(UpdateData->Name, _T("Visibility")) || !_tcsicmp(UpdateData->Unit, _T("KM")) || + else if ( !_tcscmp(UpdateData->Name, _T("Visibility")) || !_tcsicmp(UpdateData->Unit, _T("KM")) || !_tcsicmp(UpdateData->Unit, _T("MILES"))) { GetDist(Data, UpdateData->Unit, str); _tcscpy(Data, str); } // elevation - else if (!_tcscmp(UpdateData->Name, _T("Elevation")) || !_tcsicmp(UpdateData->Unit, _T("FT")) || + else if ( !_tcscmp(UpdateData->Name, _T("Elevation")) || !_tcsicmp(UpdateData->Unit, _T("FT")) || !_tcsicmp(UpdateData->Unit, _T("M"))) { GetElev(Data, UpdateData->Unit, str); _tcscpy(Data, str); } // converting case for condition to the upper+lower format - else if (!_tcsicmp(UpdateData->Unit, _T("COND"))) + else if ( !_tcsicmp(UpdateData->Unit, _T("COND"))) CaseConv(Data); // degree sign - else if (!_tcsicmp(UpdateData->Unit, _T("DEG"))) + else if ( !_tcsicmp(UpdateData->Unit, _T("DEG"))) { - if (!opt.DoNotAppendUnit) _tcscat(Data, opt.DegreeSign); + if ( !opt.DoNotAppendUnit) _tcscat(Data, opt.DegreeSign); } // percent sign - else if (!_tcsicmp(UpdateData->Unit, _T("%"))) + else if ( !_tcsicmp(UpdateData->Unit, _T("%"))) { - if (!opt.DoNotAppendUnit) _tcscat(Data, _T("%")); + if ( !opt.DoNotAppendUnit) _tcscat(Data, _T("%")); } // truncating strings for day/month to 2 or 3 characters - else if (!_tcsicmp(UpdateData->Unit, _T("DAY")) || !_tcsicmp(UpdateData->Unit, _T("MONTH"))) + else if ( !_tcsicmp(UpdateData->Unit, _T("DAY")) || !_tcsicmp(UpdateData->Unit, _T("MONTH"))) if (opt.dUnit > 1 && _tcslen(Data) > opt.dUnit) Data[opt.dUnit] = '\0'; } @@ -327,7 +321,7 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData) else if (szInfo[startloc] == '>') tag = FALSE; else if (szInfo[startloc] == ';') symb = FALSE; else { - if (!tag && !symb) { + if ( !tag && !symb) { current = szInfo[startloc]; if (current == '\n' || current == '\t' || current == ' ' || current == '\r') current = ' '; @@ -419,71 +413,60 @@ void wfree(WCHAR **Data) } //============ MANAGE THE ITEMS STORED IN DB ============ +// get single setting that is found +// szSetting = the setting name +// lparam = the counter +int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam) +{ + LIST *pList = (LIST*)lparam; + pList->insert( mir_strdup(szSetting)); + return 0; +} -// remove or display the weatehr information for a contact +// remove or display the weather information for a contact // hContact - the contact in which the info is going to be removed + void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam) { - DBCONTACTENUMSETTINGS dbces; - DBVARIANT dbv; - WCOUNTER wc; - wc.current = 0; + LIST arSettings(10); - dbces.lParam = (LPARAM)&wc; + // get all the settings and stored them in a temporary list + DBCONTACTENUMSETTINGS dbces; + dbces.lParam = (LPARAM)&arSettings; dbces.pfnEnumProc = GetWeatherDataFromDB; 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) - wc.current--; + CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact, (LPARAM)&dbces); // begin deleting settings - for (; --wc.current>-1;) { - if (!DBGetContactSettingTString(hContact, WEATHERCONDITION, wc.value[wc.current], &dbv)) { + for (int i=arSettings.getCount()-1; i >= 0; i--) { + char *szSetting = arSettings[i]; + + DBVARIANT dbv; + if ( !DBGetContactSettingTString(hContact, WEATHERCONDITION, szSetting, &dbv)) { switch (Mode) { case WDBM_REMOVE: - DBDeleteContactSetting(hContact, WEATHERCONDITION, wc.value[wc.current]); + db_unset(hContact, WEATHERCONDITION, szSetting); break; case WDBM_DETAILDISPLAY: - { - // skip the "WeatherInfo" variable - if (strcmp(wc.value[wc.current], "WeatherInfo") == 0 || - strcmp(wc.value[wc.current], "Ignore") == 0 || - wc.value[wc.current][0] == '#') - { - wfree(&wc.value[wc.current]); - DBFreeVariant(&dbv); - continue; - } - + // skip the "WeatherInfo" variable + if ( !strcmp(szSetting, "WeatherInfo") || !strcmp(szSetting, "Ignore") || szSetting[0] == '#') + continue; + else { HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST); LV_ITEM lvi = { 0 }; lvi.mask = LVIF_TEXT | LVIF_PARAM; - lvi.iItem = 0; - lvi.iSubItem = 0; - lvi.lParam = (LPARAM)wc.current; - lvi.pszText = TranslateTS( _A2T(wc.value[wc.current] )); + lvi.lParam = i; + lvi.pszText = TranslateTS( _A2T(szSetting )); lvi.iItem = ListView_InsertItem(hList, &lvi); lvi.pszText = dbv.ptszVal; ListView_SetItemText(hList, lvi.iItem, 1, dbv.ptszVal ); break; } } - DBFreeVariant(&dbv); + db_free(&dbv); } - wfree(&wc.value[wc.current]); + mir_free(szSetting); } -} - -// get single setting that is found -// szSetting = the setting name -// lparam = the counter -int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam) -{ - WCOUNTER *wc = (WCOUNTER*)lparam; - wc->value[wc->current] = (char *)mir_alloc(strlen(szSetting) + 1); - strcpy(wc->value[wc->current], szSetting); - wc->current++; - return 0; + arSettings.destroy(); } diff --git a/protocols/Weather/src/weather_http.cpp b/protocols/Weather/src/weather_http.cpp index bfeb6fe727..d9038db9c8 100644 --- a/protocols/Weather/src/weather_http.cpp +++ b/protocols/Weather/src/weather_http.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -81,7 +82,7 @@ int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData) while (result == 0xBADBAD) { // download the page NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, - (WPARAM)hNetlibUser,(LPARAM)&nlhr); + (WPARAM)hNetlibUser, (LPARAM)&nlhr); if (nlhrReply) { // if the recieved code is 200 OK @@ -161,7 +162,7 @@ int InternetDownloadFile (char *szUrl, char* cookie, TCHAR** szData) hNetlibHttp = nlhrReply->nlc; // make a copy of the retrieved data, then free the memory of the http reply - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0, (LPARAM)nlhrReply); } // if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code else @@ -190,7 +191,7 @@ void NetlibInit(void) nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION|NUF_TCHAR; nlu.szSettingsModule = WEATHERPROTONAME; nlu.ptszDescriptiveName = TranslateT("Weather HTTP connections"); - hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu); + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER,0, (LPARAM)&nlu); } void NetlibHttpDisconnect(void) diff --git a/protocols/Weather/src/weather_icons.cpp b/protocols/Weather/src/weather_icons.cpp index 3f52cdc25a..321d758ca2 100644 --- a/protocols/Weather/src/weather_icons.cpp +++ b/protocols/Weather/src/weather_icons.cpp @@ -1,6 +1,7 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/protocols/Weather/src/weather_info.cpp b/protocols/Weather/src/weather_info.cpp index 524860fe3e..f02fc79a28 100644 --- a/protocols/Weather/src/weather_info.cpp +++ b/protocols/Weather/src/weather_info.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/protocols/Weather/src/weather_ini.cpp b/protocols/Weather/src/weather_ini.cpp index 06e83db986..69f9ba40bb 100644 --- a/protocols/Weather/src/weather_ini.cpp +++ b/protocols/Weather/src/weather_ini.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -270,17 +271,17 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data) TrimString(Line); // make sure it is a valid weather protocol ini file - if (!strcmp(Line, "[Weather 0.3.x Update Data]")) + if ( !strcmp(Line, "[Weather 0.3.x Update Data]")) Data->InternalVer = 1; - else if (!strcmp(Line, "[Weather 0.3.x Update Data 1.1]")) + else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.1]")) Data->InternalVer = 2; - else if (!strcmp(Line, "[Weather 0.3.x Update Data 1.1a]")) + else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.1a]")) Data->InternalVer = 3; - else if (!strcmp(Line, "[Weather 0.3.x Update Data 1.2]")) + else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.2]")) Data->InternalVer = 4; - else if (!strcmp(Line, "[Weather 0.3.x Update Data 1.3]")) + else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.3]")) Data->InternalVer = 5; - else if (!strcmp(Line, "[Weather 0.3.x Update Data 1.4]")) + else if ( !strcmp(Line, "[Weather 0.3.x Update Data 1.4]")) Data->InternalVer = 6; else { @@ -395,56 +396,56 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data) Value++; ConvertBackslashes(Value); // store the value for each string - 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); + 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(Group, "DEFAULT")) { - 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(Group, "DEFAULT")) { + 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(Group, "ID SEARCH")) { - if (!_stricmp(ValName, "AVAILABLE")) { - if (!_stricmp(Value, "TRUE")) Data->IDSearch.Available = TRUE; + else if ( !_stricmp(Group, "ID SEARCH")) { + if ( !_stricmp(ValName, "AVAILABLE")) { + if ( !_stricmp(Value, "TRUE")) Data->IDSearch.Available = TRUE; else Data->IDSearch.Available = FALSE; } - else if (!_stricmp(ValName, "SEARCH URL")) wSetData(&Data->IDSearch.SearchURL, Value); - else if (!_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->IDSearch.NotFoundStr, Value); - 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(ValName, "SEARCH URL")) wSetData(&Data->IDSearch.SearchURL, Value); + else if ( !_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->IDSearch.NotFoundStr, Value); + 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")) { - if (!_stricmp(Value, "TRUE")) Data->NameSearch.Single.Available = TRUE; + 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")) { - if (!_stricmp(Value, "TRUE")) Data->NameSearch.Multiple.Available = TRUE; + else if ( !_stricmp(ValName, "MULTIPLE RESULT")) { + if ( !_stricmp(Value, "TRUE")) Data->NameSearch.Multiple.Available = TRUE; else Data->NameSearch.Multiple.Available = FALSE; } - else if (!_stricmp(ValName, "SEARCH URL")) wSetData(&Data->NameSearch.SearchURL, Value); - else if (!_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->NameSearch.NotFoundStr, Value); - else if (!_stricmp(ValName, "SINGLE RESULT STR")) wSetData(&Data->NameSearch.SingleStr, Value); - else if (!_stricmp(ValName, "SINGLE FIRST")) wSetData(&Data->NameSearch.Single.First, Value); - else if (!_stricmp(ValName, "SINGLE NAME START"))wSetData(&Data->NameSearch.Single.Name.Start, Value); - else if (!_stricmp(ValName, "SINGLE NAME END")) wSetData(&Data->NameSearch.Single.Name.End, Value); - else if (!_stricmp(ValName, "SINGLE ID START")) wSetData(&Data->NameSearch.Single.ID.Start, Value); - else if (!_stricmp(ValName, "SINGLE ID END")) wSetData(&Data->NameSearch.Single.ID.End, Value); - else if (!_stricmp(ValName, "MULT FIRST")) wSetData(&Data->NameSearch.Multiple.First, Value); - else if (!_stricmp(ValName, "MULT NAME START")) wSetData(&Data->NameSearch.Multiple.Name.Start, Value); - else if (!_stricmp(ValName, "MULT NAME END")) wSetData(&Data->NameSearch.Multiple.Name.End, Value); - 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(ValName, "SEARCH URL")) wSetData(&Data->NameSearch.SearchURL, Value); + else if ( !_stricmp(ValName, "NOT FOUND STR")) wSetData(&Data->NameSearch.NotFoundStr, Value); + else if ( !_stricmp(ValName, "SINGLE RESULT STR")) wSetData(&Data->NameSearch.SingleStr, Value); + else if ( !_stricmp(ValName, "SINGLE FIRST")) wSetData(&Data->NameSearch.Single.First, Value); + else if ( !_stricmp(ValName, "SINGLE NAME START"))wSetData(&Data->NameSearch.Single.Name.Start, Value); + else if ( !_stricmp(ValName, "SINGLE NAME END")) wSetData(&Data->NameSearch.Single.Name.End, Value); + else if ( !_stricmp(ValName, "SINGLE ID START")) wSetData(&Data->NameSearch.Single.ID.Start, Value); + else if ( !_stricmp(ValName, "SINGLE ID END")) wSetData(&Data->NameSearch.Single.ID.End, Value); + else if ( !_stricmp(ValName, "MULT FIRST")) wSetData(&Data->NameSearch.Multiple.First, Value); + else if ( !_stricmp(ValName, "MULT NAME START")) wSetData(&Data->NameSearch.Multiple.Name.Start, Value); + else if ( !_stricmp(ValName, "MULT NAME END")) wSetData(&Data->NameSearch.Multiple.Name.End, Value); + 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")) { + else if ( !_stricmp(Group, "ICONS")) { for (i=0; i<10; i++) { if ( !_stricmp(ValName, statusStr[i])) { WICondListAdd(Value, &Data->CondList[i]); @@ -453,13 +454,13 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data) } } 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")) { + 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")) { TCHAR *nm = Data->UpdateDataTail->Item.Name; size_t len = _tcslen(nm) + 1; @@ -468,11 +469,11 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data) *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); } diff --git a/protocols/Weather/src/weather_mwin.cpp b/protocols/Weather/src/weather_mwin.cpp index a9561e29c6..8a7798b3b1 100644 --- a/protocols/Weather/src/weather_mwin.cpp +++ b/protocols/Weather/src/weather_mwin.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2006-2009 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2006 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2006-2009 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2006 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -111,7 +112,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break; case WM_COMMAND: //Needed by the contact's context menu - if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)data->hContact)) + if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)data->hContact)) break; return FALSE; @@ -154,9 +155,9 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara int picSize = opt.AvatarSize; HICON hIcon = NULL; - if (!data->haveAvatar) + if ( !data->haveAvatar) { - int statusIcon = DBGetContactSettingWord(data->hContact, WEATHERPROTONAME, "Status", 0); + int statusIcon = db_get_w(data->hContact, WEATHERPROTONAME, "Status", 0); picSize = GetSystemMetrics(SM_CXICON); hIcon = LoadSkinnedProtoIconBig(WEATHERPROTONAME, statusIcon); @@ -167,7 +168,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } } - clr = DBGetContactSettingDword(NULL, WEATHERPROTONAME, "ColorMwinFrame", GetSysColor(COLOR_3DFACE)); + clr = db_get_dw(NULL, WEATHERPROTONAME, "ColorMwinFrame", GetSysColor(COLOR_3DFACE)); { FontIDT fntid = {0}; @@ -185,7 +186,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara HDC hdc = BeginPaint(hwnd, &ps); - if (ServiceExists(MS_SKIN_DRAWGLYPH)) { + if ( ServiceExists(MS_SKIN_DRAWGLYPH)) { SKINDRAWREQUEST rq; memset(&rq, 0, sizeof(rq)); rq.hDC = hdc; @@ -202,7 +203,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara DeleteObject(hBkgBrush); } - if (!data->haveAvatar) + if ( !data->haveAvatar) DrawIconEx(hdc, 1, 1, hIcon, 0, 0, 0, NULL, DI_NORMAL); SetBkMode(hdc, TRANSPARENT); @@ -239,7 +240,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara } EndPaint(hwnd, &ps); Skin_ReleaseIcon(hIcon); - DBFreeVariant(&dbv); + db_free(&dbv); } break; } @@ -257,7 +258,7 @@ static void addWindow(HANDLE hContact) TCHAR winname[512]; mir_sntprintf(winname, SIZEOF(winname), _T("Weather: %s"), dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); HWND hWnd = CreateWindow( _T("WeatherFrame"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 10, 10, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), NULL, hInst, hContact); @@ -273,19 +274,19 @@ static void addWindow(HANDLE hContact) Frame.height = 32; DWORD frameID = CallService(MS_CLIST_FRAMES_ADDFRAME, (WPARAM)&Frame, 0); - DBWriteContactSettingDword(hContact, WEATHERPROTONAME, "mwin", frameID); - DBWriteContactSettingByte(hContact, "CList", "Hidden", TRUE); + db_set_dw(hContact, WEATHERPROTONAME, "mwin", frameID); + db_set_b(hContact, "CList", "Hidden", TRUE); } void removeWindow(HANDLE hContact) { - DWORD frameId = DBGetContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0); + DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0); WindowList_Remove(hMwinWindowList, WindowList_Find(hMwinWindowList, hContact)); CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0); - DBWriteContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0); - DBDeleteContactSetting(hContact, "CList", "Hidden"); + db_set_dw(hContact, WEATHERPROTONAME, "mwin", 0); + db_unset(hContact, "CList", "Hidden"); } void UpdateMwinData(HANDLE hContact) @@ -313,7 +314,7 @@ int BuildContactMenu(WPARAM wparam,LPARAM lparam) mi.cbSize = sizeof(mi); mi.flags = CMIM_FLAGS | - (DBGetContactSettingDword((HANDLE)wparam, WEATHERPROTONAME, "mwin", 0) ? CMIF_CHECKED : 0); + (db_get_dw((HANDLE)wparam, WEATHERPROTONAME, "mwin", 0) ? CMIF_CHECKED : 0); CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMwinMenu, (LPARAM)&mi); return 0; } @@ -330,7 +331,7 @@ void InitMwin(void) { HMODULE hUser = GetModuleHandle(_T("user32.dll")); - if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) return; + if ( !ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) return; f_TrackMouseEvent = (ft_TrackMouseEvent)GetProcAddress(hUser, "TrackMouseEvent"); @@ -392,7 +393,7 @@ void InitMwin(void) // see if the contact is a weather contact if (IsMyContact(hContact)) { - if (DBGetContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0)) + if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0)) addWindow(hContact); } hContact = db_find_next(hContact); @@ -408,7 +409,7 @@ void DestroyMwin(void) // see if the contact is a weather contact if (IsMyContact(hContact)) { - DWORD frameId = DBGetContactSettingDword(hContact, WEATHERPROTONAME, "mwin", 0); + DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0); if (frameId) CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0); } diff --git a/protocols/Weather/src/weather_opt.cpp b/protocols/Weather/src/weather_opt.cpp index 1f7fe3e3ab..f242adb0f1 100644 --- a/protocols/Weather/src/weather_opt.cpp +++ b/protocols/Weather/src/weather_opt.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -107,113 +108,113 @@ void LoadOptions(void) ZeroMemory(&opt, sizeof(opt)); // main options - opt.StartupUpdate = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"StartupUpdate",TRUE); - opt.AutoUpdate = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"AutoUpdate",TRUE); - opt.UpdateTime = (WORD)DBGetContactSettingWord(NULL,WEATHERPROTONAME,"UpdateTime",30); - opt.NewBrowserWin = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"NewWindow",TRUE); - opt.NoProtoCondition = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"NoStatus",0); - opt.UpdateOnlyConditionChanged = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"CondChangeAsUpdate",TRUE); - opt.RemoveOldData = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"RemoveOld",FALSE); - opt.MakeItalic = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"MakeItalic",TRUE); - opt.AvatarSize = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"AvatarSize", 128); + opt.StartupUpdate = db_get_b(NULL, WEATHERPROTONAME, "StartupUpdate",TRUE); + opt.AutoUpdate = db_get_b(NULL, WEATHERPROTONAME, "AutoUpdate",TRUE); + opt.UpdateTime = db_get_w(NULL, WEATHERPROTONAME, "UpdateTime",30); + opt.NewBrowserWin = db_get_b(NULL, WEATHERPROTONAME, "NewWindow",TRUE); + opt.NoProtoCondition = db_get_b(NULL, WEATHERPROTONAME, "NoStatus",0); + opt.UpdateOnlyConditionChanged = db_get_b(NULL, WEATHERPROTONAME, "CondChangeAsUpdate",TRUE); + opt.RemoveOldData = db_get_b(NULL, WEATHERPROTONAME, "RemoveOld",FALSE); + opt.MakeItalic = db_get_b(NULL, WEATHERPROTONAME, "MakeItalic",TRUE); + opt.AvatarSize = db_get_b(NULL, WEATHERPROTONAME, "AvatarSize", 128); // units - opt.tUnit = (WORD)DBGetContactSettingWord(NULL, WEATHERPROTONAME, "tUnit", 1); - opt.wUnit = (WORD)DBGetContactSettingWord(NULL, WEATHERPROTONAME, "wUnit", 2); - opt.vUnit = (WORD)DBGetContactSettingWord(NULL, WEATHERPROTONAME, "vUnit", 1); - 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 (DBGetContactSettingTString(NULL,WEATHERPROTONAME,"DegreeSign",&dbv)) + opt.tUnit = db_get_w(NULL, WEATHERPROTONAME, "tUnit", 1); + opt.wUnit = db_get_w(NULL, WEATHERPROTONAME, "wUnit", 2); + opt.vUnit = db_get_w(NULL, WEATHERPROTONAME, "vUnit", 1); + opt.pUnit = db_get_w(NULL, WEATHERPROTONAME, "pUnit", 4); + opt.dUnit = db_get_w(NULL, WEATHERPROTONAME, "dUnit", 1); + opt.eUnit = db_get_w(NULL, WEATHERPROTONAME, "eUnit", 2); + if (DBGetContactSettingTString(NULL, WEATHERPROTONAME, "DegreeSign",&dbv)) _tcscpy(opt.DegreeSign, _T("")); else { _tcscpy(opt.DegreeSign, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } - opt.DoNotAppendUnit = DBGetContactSettingByte(NULL, WEATHERPROTONAME, "DoNotAppendUnit", 0); - opt.NoFrac = DBGetContactSettingByte(NULL, WEATHERPROTONAME, "NoFractions", 0); + opt.DoNotAppendUnit = db_get_b(NULL, WEATHERPROTONAME, "DoNotAppendUnit", 0); + opt.NoFrac = db_get_b(NULL, WEATHERPROTONAME, "NoFractions", 0); // texts - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"DisplayText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "DisplayText",&dbv)) { wSetData(&opt.cText, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("C"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"BriefTextTitle",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "BriefTextTitle",&dbv)) { wSetData(&opt.bTitle, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("b"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"BriefText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "BriefText",&dbv)) { wSetData(&opt.bText, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("B"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"NoteText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "NoteText",&dbv)) { wSetData(&opt.nText, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("N"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"ExtText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "ExtText",&dbv)) { wSetData(&opt.eText, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("E"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"HistoryText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "HistoryText",&dbv)) { wSetData(&opt.hText, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("H"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"ExtraText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "ExtraText",&dbv)) { wSetData(&opt.xText, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("X"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"StatusText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "StatusText",&dbv)) { wSetData(&opt.sText, TranslateTS(dbv.ptszVal)); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("S"); // advanced - opt.DisCondIcon = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"DisableConditionIcon",FALSE); + opt.DisCondIcon = db_get_b(NULL, WEATHERPROTONAME, "DisableConditionIcon",FALSE); // popup options - opt.UsePopup = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"UsePopUp",TRUE); - opt.UpdatePopup = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"UpdatePopup",TRUE); - opt.AlertPopup = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"AlertPopup",TRUE); - opt.PopupOnChange = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"PopUpOnChange",TRUE); - opt.ShowWarnings = DBGetContactSettingByte(NULL,WEATHERPROTONAME,"ShowWarnings",TRUE); + opt.UsePopup = db_get_b(NULL, WEATHERPROTONAME, "UsePopUp",TRUE); + opt.UpdatePopup = db_get_b(NULL, WEATHERPROTONAME, "UpdatePopup",TRUE); + opt.AlertPopup = db_get_b(NULL, WEATHERPROTONAME, "AlertPopup",TRUE); + opt.PopupOnChange = db_get_b(NULL, WEATHERPROTONAME, "PopUpOnChange",TRUE); + opt.ShowWarnings = db_get_b(NULL, WEATHERPROTONAME, "ShowWarnings",TRUE); // popup colors - opt.BGColour = DBGetContactSettingDword(NULL,WEATHERPROTONAME,"BackgroundColour",GetSysColor(COLOR_BTNFACE)); - opt.TextColour = DBGetContactSettingDword(NULL,WEATHERPROTONAME,"TextColour",GetSysColor(COLOR_WINDOWTEXT)); - opt.UseWinColors = (BOOL)DBGetContactSettingByte(NULL,WEATHERPROTONAME, "UseWinColors", FALSE); + opt.BGColour = db_get_dw(NULL, WEATHERPROTONAME, "BackgroundColour",GetSysColor(COLOR_BTNFACE)); + opt.TextColour = db_get_dw(NULL, WEATHERPROTONAME, "TextColour",GetSysColor(COLOR_WINDOWTEXT)); + opt.UseWinColors = (BOOL)db_get_b(NULL, WEATHERPROTONAME, "UseWinColors", FALSE); // popup actions - opt.LeftClickAction = DBGetContactSettingDword(NULL,WEATHERPROTONAME,"LeftClickAction",IDM_M2); - opt.RightClickAction = DBGetContactSettingDword(NULL,WEATHERPROTONAME,"RightClickAction",IDM_M1); + opt.LeftClickAction = db_get_dw(NULL, WEATHERPROTONAME, "LeftClickAction",IDM_M2); + opt.RightClickAction = db_get_dw(NULL, WEATHERPROTONAME, "RightClickAction",IDM_M1); // popup delay - opt.pDelay = DBGetContactSettingDword(NULL,WEATHERPROTONAME,"PopupDelay",0); + opt.pDelay = db_get_dw(NULL, WEATHERPROTONAME, "PopupDelay",0); // popup texts - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"PopupTitle",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "PopupTitle",&dbv)) { wSetData(&opt.pTitle, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("P"); - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"PopupText",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "PopupText",&dbv)) { wSetData(&opt.pText, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } else SetTextDefault("p"); // misc - if ( !DBGetContactSettingTString(NULL,WEATHERPROTONAME,"Default",&dbv)) { + if ( !DBGetContactSettingTString(NULL, WEATHERPROTONAME, "Default",&dbv)) { _tcscpy(opt.Default, dbv.ptszVal); - DBFreeVariant(&dbv); + db_free(&dbv); } else opt.Default[0] = 0; } @@ -222,56 +223,56 @@ void LoadOptions(void) void SaveOptions(void) { // main options - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "StartupUpdate", (BYTE)opt.StartupUpdate); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)opt.AutoUpdate); - DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "UpdateTime", opt.UpdateTime); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "NewWindow", (BYTE)opt.NewBrowserWin); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "NoStatus", (BYTE)opt.NoProtoCondition); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "CondChangeAsUpdate", (BYTE)opt.UpdateOnlyConditionChanged); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "RemoveOld", (BYTE)opt.RemoveOldData); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "MakeItalic", (BYTE)opt.MakeItalic); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "AvatarSize", (BYTE)opt.AvatarSize); + db_set_b(NULL, WEATHERPROTONAME, "StartupUpdate", (BYTE)opt.StartupUpdate); + db_set_b(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)opt.AutoUpdate); + db_set_w(NULL, WEATHERPROTONAME, "UpdateTime", opt.UpdateTime); + db_set_b(NULL, WEATHERPROTONAME, "NewWindow", (BYTE)opt.NewBrowserWin); + db_set_b(NULL, WEATHERPROTONAME, "NoStatus", (BYTE)opt.NoProtoCondition); + db_set_b(NULL, WEATHERPROTONAME, "CondChangeAsUpdate", (BYTE)opt.UpdateOnlyConditionChanged); + db_set_b(NULL, WEATHERPROTONAME, "RemoveOld", (BYTE)opt.RemoveOldData); + db_set_b(NULL, WEATHERPROTONAME, "MakeItalic", (BYTE)opt.MakeItalic); + db_set_b(NULL, WEATHERPROTONAME, "AvatarSize", (BYTE)opt.AvatarSize); // units - DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "tUnit", opt.tUnit); - DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "wUnit", opt.wUnit); - DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "vUnit", opt.vUnit); - DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "pUnit", opt.pUnit); - DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "dUnit", opt.dUnit); - DBWriteContactSettingWord(NULL, WEATHERPROTONAME, "eUnit", opt.eUnit); - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "DegreeSign", opt.DegreeSign); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "DoNotAppendUnit", (BYTE)opt.DoNotAppendUnit); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "NoFractions", (BYTE)opt.NoFrac); + db_set_w(NULL, WEATHERPROTONAME, "tUnit", opt.tUnit); + db_set_w(NULL, WEATHERPROTONAME, "wUnit", opt.wUnit); + db_set_w(NULL, WEATHERPROTONAME, "vUnit", opt.vUnit); + db_set_w(NULL, WEATHERPROTONAME, "pUnit", opt.pUnit); + db_set_w(NULL, WEATHERPROTONAME, "dUnit", opt.dUnit); + db_set_w(NULL, WEATHERPROTONAME, "eUnit", opt.eUnit); + db_set_ts(NULL, WEATHERPROTONAME, "DegreeSign", opt.DegreeSign); + db_set_b(NULL, WEATHERPROTONAME, "DoNotAppendUnit", (BYTE)opt.DoNotAppendUnit); + db_set_b(NULL, WEATHERPROTONAME, "NoFractions", (BYTE)opt.NoFrac); // texts - 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); + db_set_ts(NULL, WEATHERPROTONAME, "DisplayText", opt.cText); + db_set_ts(NULL, WEATHERPROTONAME, "BriefTextTitle", opt.bTitle); + db_set_ts(NULL, WEATHERPROTONAME, "BriefText", opt.bText); + db_set_ts(NULL, WEATHERPROTONAME, "NoteText", opt.nText); + db_set_ts(NULL, WEATHERPROTONAME, "ExtText", opt.eText); + db_set_ts(NULL, WEATHERPROTONAME, "HistoryText", opt.hText); + db_set_ts(NULL, WEATHERPROTONAME, "ExtraText", opt.xText); + db_set_ts(NULL, WEATHERPROTONAME, "StatusText", opt.sText); // advanced - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "DisableConditionIcon", (BYTE)opt.DisCondIcon); + db_set_b(NULL, WEATHERPROTONAME, "DisableConditionIcon", (BYTE)opt.DisCondIcon); // popup options - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "UsePopUp", (BYTE)opt.UsePopup); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "UpdatePopup", (BYTE)opt.UpdatePopup); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "AlertPopup", (BYTE)opt.AlertPopup); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "PopUpOnChange", (BYTE)opt.PopupOnChange); - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "ShowWarnings", (BYTE)opt.ShowWarnings); + db_set_b(NULL, WEATHERPROTONAME, "UsePopUp", (BYTE)opt.UsePopup); + db_set_b(NULL, WEATHERPROTONAME, "UpdatePopup", (BYTE)opt.UpdatePopup); + db_set_b(NULL, WEATHERPROTONAME, "AlertPopup", (BYTE)opt.AlertPopup); + db_set_b(NULL, WEATHERPROTONAME, "PopUpOnChange", (BYTE)opt.PopupOnChange); + db_set_b(NULL, WEATHERPROTONAME, "ShowWarnings", (BYTE)opt.ShowWarnings); // popup colors - DBWriteContactSettingDword(NULL, WEATHERPROTONAME, "BackgroundColour", opt.BGColour); - DBWriteContactSettingDword(NULL, WEATHERPROTONAME, "TextColour", opt.TextColour); - DBWriteContactSettingByte(NULL,WEATHERPROTONAME, "UseWinColors", (BYTE)opt.UseWinColors); + db_set_dw(NULL, WEATHERPROTONAME, "BackgroundColour", opt.BGColour); + db_set_dw(NULL, WEATHERPROTONAME, "TextColour", opt.TextColour); + db_set_b(NULL, WEATHERPROTONAME, "UseWinColors", (BYTE)opt.UseWinColors); // popup actions - DBWriteContactSettingDword(NULL, WEATHERPROTONAME, "LeftClickAction", opt.LeftClickAction); - DBWriteContactSettingDword(NULL, WEATHERPROTONAME, "RightClickAction", opt.RightClickAction); + db_set_dw(NULL, WEATHERPROTONAME, "LeftClickAction", opt.LeftClickAction); + db_set_dw(NULL, WEATHERPROTONAME, "RightClickAction", opt.RightClickAction); // popup delay - DBWriteContactSettingDword(NULL, WEATHERPROTONAME, "PopupDelay", opt.pDelay); + db_set_dw(NULL, WEATHERPROTONAME, "PopupDelay", opt.pDelay); // popup texts - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "PopupTitle", opt.pTitle); - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "PopupText", opt.pText); + db_set_ts(NULL, WEATHERPROTONAME, "PopupTitle", opt.pTitle); + db_set_ts(NULL, WEATHERPROTONAME, "PopupText", opt.pText); // misc stuff - DBWriteContactSettingTString(NULL, WEATHERPROTONAME, "Default", opt.Default); + db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default); } //============ OPTION INITIALIZATION ============ @@ -300,7 +301,7 @@ int OptInit(WPARAM wParam,LPARAM lParam) { Options_AddPage(wParam, &odp); // if popup service exists, load the weather popup options - if ((ServiceExists(MS_POPUP_ADDPOPUPT))) { + if (( ServiceExists(MS_POPUP_ADDPOPUPT))) { odp.position = 100000000; odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP); odp.ptszGroup = LPGENT("PopUps"); @@ -381,20 +382,19 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam) case WM_COMMAND: if (HIWORD(wparam)==BN_CLICKED && GetFocus()==(HWND)lparam) - if (!opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - if (!((LOWORD(wparam) == IDC_UPDATE || LOWORD(wparam) == IDC_DEGREE) && + if ( !opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + if ( !((LOWORD(wparam) == IDC_UPDATE || LOWORD(wparam) == IDC_DEGREE) && (HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus()))) - if (!opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); + if ( !opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); return 0; case WM_NOTIFY: switch(((LPNMHDR)lparam)->code) { case PSN_APPLY: // change the status for weather protocol - if (IsDlgButtonChecked(hdlg, IDC_PROTOCOND) && opt.DefStn != NULL) - { + if (IsDlgButtonChecked(hdlg, IDC_PROTOCOND) && opt.DefStn != NULL) { old_status = status; - status = DBGetContactSettingWord(opt.DefStn, WEATHERPROTONAME, "StatusIcon", NOSTATUSDATA); + status = db_get_w(opt.DefStn, WEATHERPROTONAME, "StatusIcon", NOSTATUSDATA); ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, status); } diff --git a/protocols/Weather/src/weather_popup.cpp b/protocols/Weather/src/weather_popup.cpp index 134cb973fa..2a3e3580e5 100644 --- a/protocols/Weather/src/weather_popup.cpp +++ b/protocols/Weather/src/weather_popup.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2009 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2009 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -35,7 +36,7 @@ int WeatherPopup(WPARAM wParam, LPARAM lParam) { // determine if the popup should display or not if (opt.UsePopup && opt.UpdatePopup && (!opt.PopupOnChange || (BOOL)lParam) && - !DBGetContactSettingByte((HANDLE)wParam, WEATHERPROTONAME, "DPopUp", 0)) + !db_get_b((HANDLE)wParam, WEATHERPROTONAME, "DPopUp", 0)) { POPUPDATAT ppd = {0}; WEATHERINFO winfo; @@ -72,7 +73,7 @@ int WeatherPopup(WPARAM wParam, LPARAM lParam) int WeatherError(WPARAM wParam, LPARAM lParam) { - if (!opt.UsePopup) + if ( !opt.UsePopup) return 0; TCHAR* tszMsg = ( TCHAR* )wParam; @@ -191,7 +192,7 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam CallService(MS_USERINFO_SHOWDIALOG, wParam, 0); case WM_COMMAND: //Needed by the contact's context menu - if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU),(LPARAM)hPopupContact)) + if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)hPopupContact)) break; return FALSE; @@ -309,7 +310,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) // enable the "apply" button if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); - if (!((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) && + if ( !((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0); //These are simple clicks: we don't save, but we tell the Options Page to enable the "Apply" button. diff --git a/protocols/Weather/src/weather_svcs.cpp b/protocols/Weather/src/weather_svcs.cpp index 1125ba8fb1..66fcdd565a 100644 --- a/protocols/Weather/src/weather_svcs.cpp +++ b/protocols/Weather/src/weather_svcs.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -28,8 +29,6 @@ building/changing the weather menu items. static HGENMENU hEnableDisablePopupMenu; static HGENMENU hEnableDisableMenu; -static HANDLE hService[27]; - //============ MIRANDA PROTOCOL SERVICES ============ // protocol service function for setting weather protocol status @@ -38,14 +37,14 @@ INT_PTR WeatherSetStatus(WPARAM new_status, LPARAM lParam) new_status = new_status != ID_STATUS_OFFLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; // if we don't want to show status for default station - if (opt.NoProtoCondition && status != new_status) - { + if (opt.NoProtoCondition && status != new_status) { old_status = status; status = new_status != ID_STATUS_OFFLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, status); UpdateMenu(new_status != ID_STATUS_OFFLINE); - if (new_status != ID_STATUS_OFFLINE) UpdateAll(FALSE, FALSE); + if (new_status != ID_STATUS_OFFLINE) + UpdateAll(FALSE, FALSE); } return 0; @@ -56,8 +55,7 @@ INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM lParam) { INT_PTR ret = 0; - switch(wParam) - { + switch(wParam) { case PFLAGNUM_1: // support search and visible list ret = PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_EXTSEARCH | PF1_VISLIST | PF1_MODEMSGRECV; @@ -65,18 +63,17 @@ INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM lParam) case PFLAGNUM_2: ret = PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | - PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; + PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; break; case PFLAGNUM_4: ret = PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEADDED | - PF4_FORCEAUTH; + PF4_FORCEAUTH; break; case PFLAGNUM_5: /* this is PFLAGNUM_5 change when alpha SDK is released */ ret = PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | - PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; - // if (!opt.NoProtoCondition) ret |= PF2_ONLINE; + PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; break; case PFLAG_UNIQUEIDTEXT: @@ -142,7 +139,7 @@ INT_PTR WeatherGetAvatarInfo(WPARAM wParam, LPARAM lParam) if (chop) *chop = '\0'; else szSearchPath[0] = 0; - status = (WORD)DBGetContactSettingWord(ai->hContact, WEATHERPROTONAME, "StatusIcon",0); + status = (WORD)db_get_w(ai->hContact, WEATHERPROTONAME, "StatusIcon",0); for (i=0; i<10; i++) if (statusValue[i] == status) break; @@ -186,7 +183,7 @@ static void __cdecl WeatherGetAwayMsgThread(HANDLE hContact) DBVARIANT dbv; if ( !DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv)) { ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal); - DBFreeVariant( &dbv ); + db_free( &dbv ); } else ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0); } @@ -205,98 +202,66 @@ static INT_PTR WeatherGetAwayMsg(WPARAM wParam, LPARAM lParam) // protocol services void InitServices(void) { - hService[0] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETCAPS, WeatherGetCaps); - hService[1] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETNAME, WeatherGetName); - 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_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_GETAVATARINFOT, WeatherGetAvatarInfo); - hService[11] = CreateProtoServiceFunction(WEATHERPROTONAME, PSS_GETAWAYMSG, WeatherGetAwayMsg); - hService[12] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_CREATEADVSEARCHUI, WeatherCreateAdvancedSearchUI); - hService[13] = CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYADVANCED, WeatherAdvancedSearch); - - hService[14] = CreateProtoServiceFunction(WEATHERPROTONAME, MS_WEATHER_GETDISPLAY, GetDisplaySvcFunc); -} - -void DestroyServices(void) -{ - unsigned i; - - for (i = sizeof(hService)/sizeof(HANDLE); i--; ) - { - if (hService[i] != NULL) - DestroyServiceFunction(hService[i]); - } + CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETCAPS, WeatherGetCaps); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETNAME, WeatherGetName); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_LOADICON, WeatherLoadIcon); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_SETSTATUS, WeatherSetStatus); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETSTATUS, WeatherGetStatus); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_BASICSEARCHT, WeatherBasicSearch); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYEMAILT, WeatherBasicSearch); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_ADDTOLIST, WeatherAddToList); + CreateProtoServiceFunction(WEATHERPROTONAME, PSS_GETINFO, WeatherGetInfo); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_GETAVATARINFOT, WeatherGetAvatarInfo); + CreateProtoServiceFunction(WEATHERPROTONAME, PSS_GETAWAYMSG, WeatherGetAwayMsg); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_CREATEADVSEARCHUI, WeatherCreateAdvancedSearchUI); + CreateProtoServiceFunction(WEATHERPROTONAME, PS_SEARCHBYADVANCED, WeatherAdvancedSearch); + + CreateProtoServiceFunction(WEATHERPROTONAME, MS_WEATHER_GETDISPLAY, GetDisplaySvcFunc); } //============ MENU INITIALIZATION ============ void UpdateMenu(BOOL State) { - // We're here to change something, so let's read the actual value. - // TempDisable == FALSE means that right now the popups are enabled - // and if we're here, we want to disable them. - // The icon works this way: - // if the notifications are disabled, the icon hasn't the red circle; - // if the notifications are enabled, the icon has the red circle. - - CLISTMENUITEM mi = {0}; + // update option setting + opt.CAutoUpdate = State; + db_set_b(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)opt.AutoUpdate); - mi.cbSize = sizeof(mi); + CLISTMENUITEM mi = { sizeof(mi) }; - if (State) - { // to enable auto-update - mi.ptszName = LPGENT("Auto Update Enabled"); + if (State) { // to enable auto-update + mi.pszName = LPGEN("Auto Update Enabled"); mi.icolibItem = GetIconHandle("main"); } - else - { // to disable auto-update - mi.ptszName = LPGENT("Auto Update Disabled"); + else { // to disable auto-update + mi.pszName = LPGEN("Auto Update Disabled"); mi.icolibItem = GetIconHandle("disabled"); } - // update option setting - opt.CAutoUpdate = State; - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "AutoUpdate", (BYTE)opt.AutoUpdate); - mi.flags = CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB | CMIF_TCHAR; - // update menu item - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hEnableDisableMenu,(LPARAM)&mi); + mi.flags = CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEnableDisableMenu, (LPARAM)&mi); } void UpdatePopupMenu(BOOL State) { - // We're here to change something, so let's read the actual value. - // TempDisable == FALSE means that right now the popups are enabled - // and if we're here, we want to disable them. - // The icon works this way: - // if the notifications are disabled, the icon hasn't the red circle; - // if the notifications are enabled, the icon has the red circle. - - CLISTMENUITEM mi = {0}; - - mi.cbSize = sizeof(mi); + // update option setting + opt.UsePopup = State; + db_set_b(NULL, WEATHERPROTONAME, "UsePopUp", (BYTE)opt.UsePopup); + CLISTMENUITEM mi = { sizeof(mi) }; if (State) { // to enable popup - mi.ptszName = LPGENT("Disable &weather notification"); + mi.pszName = LPGEN("Disable &weather notification"); mi.icolibItem = GetIconHandle("popup"); } else { // to disable popup - mi.ptszName = LPGENT("Enable &weather notification"); + mi.pszName = LPGEN("Enable &weather notification"); mi.icolibItem = GetIconHandle("nopopup"); } - // update option setting - opt.UsePopup = State; - DBWriteContactSettingByte(NULL, WEATHERPROTONAME, "UsePopUp", (BYTE)opt.UsePopup); - mi.flags = CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB | CMIF_TCHAR; - // update menu item - CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hEnableDisablePopupMenu,(LPARAM)&mi); + mi.flags = CMIM_ICON | CMIM_NAME | CMIF_ICONFROMICOLIB | CMIF_TCHAR; + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEnableDisablePopupMenu, (LPARAM)&mi); } // update the weather auto-update menu item when click on it @@ -317,106 +282,104 @@ INT_PTR MenuitemNotifyCmd(WPARAM wParam,LPARAM lParam) // copied and modified form "modified MSN Protocol" void AddMenuItems(void) { - CLISTMENUITEM mi = {0}; - - mi.cbSize = sizeof(mi); + CLISTMENUITEM mi = { sizeof(mi) }; mi.pszContactOwner = WEATHERPROTONAME; - mi.flags = CMIF_ICONFROMICOLIB|CMIF_TCHAR; + mi.flags = CMIF_ICONFROMICOLIB; // contact menu - hService[15] = CreateServiceFunction(MS_WEATHER_UPDATE, UpdateSingleStation); + CreateServiceFunction(MS_WEATHER_UPDATE, UpdateSingleStation); mi.position = -0x7FFFFFFA; mi.icolibItem = GetIconHandle("update"); - mi.ptszName = LPGENT("Update Weather"); + mi.pszName = LPGEN("Update Weather"); mi.pszService = MS_WEATHER_UPDATE; Menu_AddContactMenuItem(&mi); - hService[16] = CreateServiceFunction(MS_WEATHER_REFRESH, UpdateSingleRemove); + CreateServiceFunction(MS_WEATHER_REFRESH, UpdateSingleRemove); mi.position = -0x7FFFFFF9; mi.icolibItem = GetIconHandle("update2"); - mi.ptszName = LPGENT("Remove Old Data then Update"); + mi.pszName = LPGEN("Remove Old Data then Update"); mi.pszService = MS_WEATHER_REFRESH; Menu_AddContactMenuItem(&mi); - hService[17] = CreateServiceFunction(MS_WEATHER_BRIEF, BriefInfoSvc); + CreateServiceFunction(MS_WEATHER_BRIEF, BriefInfoSvc); mi.position = -0x7FFFFFF8; mi.icolibItem = GetIconHandle("brief"); - mi.ptszName = LPGENT("Brief Information"); + mi.pszName = LPGEN("Brief Information"); mi.pszService = MS_WEATHER_BRIEF; Menu_AddContactMenuItem(&mi); - hService[18] = CreateServiceFunction(MS_WEATHER_COMPLETE, LoadForecast); + CreateServiceFunction(MS_WEATHER_COMPLETE, LoadForecast); mi.position = -0x7FFFFFF7; mi.icolibItem = GetIconHandle("read"); - mi.ptszName = LPGENT("Read Complete Forecast"); + mi.pszName = LPGEN("Read Complete Forecast"); mi.pszService = MS_WEATHER_COMPLETE; Menu_AddContactMenuItem(&mi); - hService[19] = CreateServiceFunction(MS_WEATHER_MAP, WeatherMap); + CreateServiceFunction(MS_WEATHER_MAP, WeatherMap); mi.position = -0x7FFFFFF6; mi.icolibItem = GetIconHandle("map"); - mi.ptszName = LPGENT("Weather Map"); + mi.pszName = LPGEN("Weather Map"); mi.pszService = MS_WEATHER_MAP; Menu_AddContactMenuItem(&mi); - hService[20] = CreateServiceFunction(MS_WEATHER_LOG, ViewLog); + CreateServiceFunction(MS_WEATHER_LOG, ViewLog); mi.position = -0x7FFFFFF5; mi.icolibItem = GetIconHandle("log"); - mi.ptszName = LPGENT("View Log"); + mi.pszName = LPGEN("View Log"); mi.pszService = MS_WEATHER_LOG; Menu_AddContactMenuItem(&mi); - hService[21] = CreateServiceFunction(MS_WEATHER_EDIT, EditSettings); + CreateServiceFunction(MS_WEATHER_EDIT, EditSettings); mi.position = -0x7FFFFFF4; mi.icolibItem = GetIconHandle("edit"); - mi.ptszName = LPGENT("Edit Settings"); + mi.pszName = LPGEN("Edit Settings"); mi.pszService = MS_WEATHER_EDIT; Menu_AddContactMenuItem(&mi); // adding main menu items - mi.ptszPopupName = LPGENT("Weather"); + mi.pszPopupName = LPGEN("Weather"); mi.popupPosition = 500099000; - hService[22] = CreateServiceFunction(MS_WEATHER_ENABLED, EnableDisableCmd); - mi.ptszName = LPGENT("Enable/Disable Weather Update"); + CreateServiceFunction(MS_WEATHER_ENABLED, EnableDisableCmd); + mi.pszName = LPGEN("Enable/Disable Weather Update"); mi.icolibItem = GetIconHandle("main"); mi.position = 10100001; mi.pszService = MS_WEATHER_ENABLED; hEnableDisableMenu = Menu_AddMainMenuItem(&mi); UpdateMenu(opt.AutoUpdate); - hService[23] = CreateServiceFunction(MS_WEATHER_UPDATEALL, UpdateAllInfo); + CreateServiceFunction(MS_WEATHER_UPDATEALL, UpdateAllInfo); mi.position = 20100001; mi.icolibItem = GetIconHandle("update"); - mi.ptszName = LPGENT("Update All Weather"); + mi.pszName = LPGEN("Update All Weather"); mi.pszService = MS_WEATHER_UPDATEALL; Menu_AddMainMenuItem(&mi); - hService[24] = CreateServiceFunction(MS_WEATHER_REFRESHALL, UpdateAllRemove); + CreateServiceFunction(MS_WEATHER_REFRESHALL, UpdateAllRemove); mi.position = 20100002; mi.icolibItem = GetIconHandle("update2"); - mi.ptszName = LPGENT("Remove Old Data then Update All"); + mi.pszName = LPGEN("Remove Old Data then Update All"); mi.pszService = MS_WEATHER_REFRESHALL; Menu_AddMainMenuItem(&mi); // only run if popup service exists - if (ServiceExists(MS_POPUP_ADDPOPUPT)) { - hService[25] = CreateServiceFunction(WEATHERPROTONAME "/PopupMenu", MenuitemNotifyCmd); - mi.ptszName = LPGENT("Weather Notification"); + if ( ServiceExists(MS_POPUP_ADDPOPUPT)) { + CreateServiceFunction(WEATHERPROTONAME "/PopupMenu", MenuitemNotifyCmd); + mi.pszName = LPGEN("Weather Notification"); mi.icolibItem = GetIconHandle("popup"); mi.position = 0; - mi.ptszPopupName = LPGENT("PopUps"); + mi.pszPopupName = LPGEN("PopUps"); mi.pszService = WEATHERPROTONAME "/PopupMenu"; hEnableDisablePopupMenu = Menu_AddMainMenuItem(&mi); UpdatePopupMenu(opt.UsePopup); } - if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - hService[26] = CreateServiceFunction("Weather/mwin_menu", Mwin_MenuClicked); + if ( ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { + CreateServiceFunction("Weather/mwin_menu", Mwin_MenuClicked); mi.position = -0x7FFFFFF0; mi.hIcon = NULL; mi.flags = CMIF_TCHAR; - mi.ptszName = LPGENT("Display in a frame"); + mi.pszName = LPGEN("Display in a frame"); mi.pszService = "Weather/mwin_menu"; hMwinMenu = Menu_AddContactMenuItem(&mi); } diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 48ed3d84c2..d07af7865b 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -67,10 +68,10 @@ int UpdateWeather(HANDLE hContact) // log to netlib Netlib_LogfT(hNetlibUser, _T("Error! Update cannot continue... Start to free memory")); Netlib_LogfT(hNetlibUser, _T("<-- Error occurs while updating station: %s -->"), dbv.ptszVal); - if (!dbres) DBFreeVariant(&dbv); + if ( !dbres) db_free(&dbv); return 1; } - if (!dbres) DBFreeVariant(&dbv); + if ( !dbres) db_free(&dbv); // initialize, load new weather Data WEATHERINFO winfo = LoadWeatherInfo(hContact); @@ -80,74 +81,74 @@ int UpdateWeather(HANDLE hContact) // compare the old condition and determine if the weather had changed if (opt.UpdateOnlyConditionChanged) { // consider condition change - if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastCondition", &dbv)) { + if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastCondition", &dbv)) { if (_tcsicmp(winfo.cond, dbv.ptszVal)) Ch = TRUE; // the weather condition is changed - DBFreeVariant(&dbv); + db_free(&dbv); } else Ch = TRUE; - if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastTemperature", &dbv)) { + if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastTemperature", &dbv)) { if (_tcsicmp(winfo.temp, dbv.ptszVal)) Ch = TRUE; // the temperature is changed - DBFreeVariant(&dbv); + db_free(&dbv); } else Ch = TRUE; } else { // consider update time change - if (!DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastUpdate", &dbv)) { + if ( !DBGetContactSettingTString(hContact, WEATHERPROTONAME, "LastUpdate", &dbv)) { if (_tcsicmp(winfo.update, dbv.ptszVal)) Ch = TRUE; // the update time is changed - DBFreeVariant(&dbv); + db_free(&dbv); } else Ch = TRUE; } // have weather alert issued? dbres = DBGetContactSettingTString(hContact, WEATHERCONDITION, "Alert", &dbv); - if (!dbres && dbv.ptszVal[0] != 0) { - if (opt.AlertPopup && !DBGetContactSettingByte(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) { + if ( !dbres && dbv.ptszVal[0] != 0) { + if (opt.AlertPopup && !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) { // display alert popup wsprintf(str, _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal); WPShowMessage(str, SM_WEATHERALERT); } // alert issued, set display to italic if (opt.MakeItalic) - DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "ApparentMode", ID_STATUS_OFFLINE); + db_set_w(hContact, WEATHERPROTONAME, "ApparentMode", ID_STATUS_OFFLINE); SkinPlaySound("weatheralert"); } // alert dropped, set the display back to normal - else DBDeleteContactSetting(hContact, WEATHERPROTONAME, "ApparentMode"); - if (!dbres) DBFreeVariant(&dbv); + else db_unset(hContact, WEATHERPROTONAME, "ApparentMode"); + if ( !dbres) db_free(&dbv); // backup current condition for checking if the weather is changed or not - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastLog", winfo.update); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastCondition", winfo.cond); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastTemperature", winfo.temp); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "LastUpdate", winfo.update); + db_set_ts(hContact, WEATHERPROTONAME, "LastLog", winfo.update); + db_set_ts(hContact, WEATHERPROTONAME, "LastCondition", winfo.cond); + db_set_ts(hContact, WEATHERPROTONAME, "LastTemperature", winfo.temp); + db_set_ts(hContact, WEATHERPROTONAME, "LastUpdate", winfo.update); // display condition on contact list if (opt.DisCondIcon && winfo.status != ID_STATUS_OFFLINE) - DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "Status", ID_STATUS_ONLINE); + db_set_w(hContact, WEATHERPROTONAME, "Status", ID_STATUS_ONLINE); else - DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "Status", winfo.status); + db_set_w(hContact, WEATHERPROTONAME, "Status", winfo.status); AvatarDownloaded(hContact); GetDisplay(&winfo, opt.cText, str2); - DBWriteContactSettingTString(hContact, "CList", "MyHandle", str2); + db_set_ts(hContact, "CList", "MyHandle", str2); GetDisplay(&winfo, opt.sText, str2); if (str2[0]) - DBWriteContactSettingTString(hContact, "CList", "StatusMsg", str2); + db_set_ts(hContact, "CList", "StatusMsg", str2); else - DBDeleteContactSetting(hContact, "CList", "StatusMsg"); + db_unset(hContact, "CList", "StatusMsg"); ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, NULL, (LPARAM)(str2[0] ? str2 : 0)); // save descriptions in MyNotes GetDisplay(&winfo, opt.nText, str2); - DBWriteContactSettingTString(hContact, "UserInfo", "MyNotes", str2); + db_set_ts(hContact, "UserInfo", "MyNotes", str2); GetDisplay(&winfo, opt.xText, str2); - DBWriteContactSettingTString(hContact, WEATHERCONDITION, "WeatherInfo", str2); + db_set_ts(hContact, WEATHERCONDITION, "WeatherInfo", str2); // set the update tag - DBWriteContactSettingByte(hContact, WEATHERPROTONAME, "IsUpdated", TRUE); + db_set_b(hContact, WEATHERPROTONAME, "IsUpdated", TRUE); // save info for default weather condition if ( !_tcscmp(winfo.id, opt.Default) && !opt.NoProtoCondition) { @@ -164,15 +165,15 @@ int UpdateWeather(HANDLE hContact) // play the sound event SkinPlaySound("weatherupdated"); - if (DBGetContactSettingByte(hContact, WEATHERPROTONAME, "File", 0)) { + if (db_get_b(hContact, WEATHERPROTONAME, "File", 0)) { // external log - if (!DBGetContactSettingTString(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)) + if (db_get_b(hContact,WEATHERPROTONAME, "Overwrite",0)) DeleteFile(dbv.ptszVal); // open the file and set point to the end of file FILE *file = _tfopen( dbv.ptszVal, _T("a")); - DBFreeVariant(&dbv); + db_free(&dbv); if (file != NULL) { // write data to the file and close GetDisplay(&winfo, opt.eText, str2); @@ -180,7 +181,7 @@ int UpdateWeather(HANDLE hContact) fclose(file); } } } - if (DBGetContactSettingByte(hContact, WEATHERPROTONAME, "History", 0)) { + if (db_get_b(hContact, WEATHERPROTONAME, "History", 0)) { DBEVENTINFO dbei = {0}; // internal log using history GetDisplay(&winfo, opt.hText, str2); @@ -289,7 +290,7 @@ void UpdateAll(BOOL AutoUpdate, BOOL RemoveData) { if (IsMyContact(hContact)) { - if (!DBGetContactSettingByte(hContact,WEATHERPROTONAME,"AutoUpdate",FALSE) || !AutoUpdate) + if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate) { if (RemoveData) DBDataManage((HANDLE)hContact, WDBM_REMOVE, 0, 0); UpdateListAdd(hContact); @@ -300,7 +301,7 @@ void UpdateAll(BOOL AutoUpdate, BOOL RemoveData) // if it is not updating, then start the update thread process // if it is updating, the stations just added to the queue will get updated by the already-running process - if (!ThreadRunning) + if ( !ThreadRunning) mir_forkthread(UpdateThreadProc, NULL); } @@ -316,7 +317,7 @@ INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM lParam) // if it is not updating, then start the update thread process // if it is updating, the stations just added to the queue will get // updated by the already-running process - if (!ThreadRunning) + if ( !ThreadRunning) mir_forkthread(UpdateThreadProc, NULL); } @@ -335,7 +336,7 @@ INT_PTR UpdateSingleRemove(WPARAM wParam, LPARAM lParam) // if it is not updating, then start the update thread process // if it is updating, the stations just added to the queue will get updated by the already-running process - if (!ThreadRunning) + if ( !ThreadRunning) mir_forkthread(UpdateThreadProc, NULL); } @@ -368,13 +369,13 @@ void UpdateThreadProc(LPVOID hWnd) // the "Update All" menu item in main menu INT_PTR UpdateAllInfo(WPARAM wParam,LPARAM lParam) { - if (!ThreadRunning) UpdateAll(FALSE, FALSE); + if ( !ThreadRunning) UpdateAll(FALSE, FALSE); return 0; } // the "Update All" menu item in main menu and remove the old data INT_PTR UpdateAllRemove(WPARAM wParam,LPARAM lParam) { - if (!ThreadRunning) UpdateAll(FALSE, TRUE); + if ( !ThreadRunning) UpdateAll(FALSE, TRUE); return 0; } @@ -495,7 +496,7 @@ int GetWeatherData(HANDLE hContact) if ( !DBGetData(hContact, _T2A(str2), &dbv)) { _tcsncat(DataValue, dbv.ptszVal, SIZEOF(DataValue) - _tcslen(DataValue)); DataValue[SIZEOF(DataValue)-1] = 0; - DBFreeVariant(&dbv); + db_free(&dbv); } break; @@ -509,17 +510,17 @@ int GetWeatherData(HANDLE hContact) str = chop + 3; } while (chop[0] && str[0]); - if (!hasvar) ConvertDataValue(&Item->Item, DataValue); + if ( !hasvar) ConvertDataValue(&Item->Item, DataValue); break; } case WID_BREAK: { // for the "Break Data=" operation DBVARIANT dbv; - if (!DBGetData(hContact, _T2A(Item->Item.Start), &dbv)) { + if ( !DBGetData(hContact, _T2A(Item->Item.Start), &dbv)) { _tcsncpy(DataValue, dbv.ptszVal, SIZEOF(DataValue)); DataValue[SIZEOF(DataValue)-1] = 0; - DBFreeVariant(&dbv); + db_free(&dbv); } else { DataValue[0] = 0; @@ -541,7 +542,7 @@ int GetWeatherData(HANDLE hContact) // write the 2 strings created from the break operation if (Item->Item.End[0]) - DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.End), end); + db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.End), end); break; } } @@ -552,17 +553,17 @@ int GetWeatherData(HANDLE hContact) { // temporary workaround for mToolTip to show feel-like temperature if ( !_tcscmp(Item->Item.Name, _T("Feel"))) - DBWriteContactSettingTString(hContact, WEATHERCONDITION, "Heat Index", DataValue); + db_set_ts(hContact, WEATHERCONDITION, "Heat Index", DataValue); GetStationID(hContact, Svc, SIZEOF(Svc)); if ( !_tcscmp(Svc, opt.Default)) - DBWriteContactSettingTString(NULL, DEFCURRENTWEATHER, _T2A(Item->Item.Name), DataValue); + db_set_ts(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 = TranslateTS(DataValue); - DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf); + db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf); CharLowerBuff(DataValue, (DWORD)_tcslen(DataValue)); cond = GetIcon(DataValue, Data); } @@ -572,9 +573,9 @@ int GetWeatherData(HANDLE hContact) cbuf = TranslateTS(buf); if (cbuf[0] == '#') cbuf = TranslateTS(DataValue); - DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf); + db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), cbuf); } - else DBWriteContactSettingTString(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), DataValue); + else db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.Name), DataValue); } Item = Item->Next; } @@ -582,8 +583,8 @@ int GetWeatherData(HANDLE hContact) } // assign condition icon - DBWriteContactSettingWord(hContact, WEATHERPROTONAME, "StatusIcon", cond); - DBWriteContactSettingTString(hContact, WEATHERPROTONAME, "MirVer", Data->DisplayName); + db_set_w(hContact, WEATHERPROTONAME, "StatusIcon", cond); + db_set_ts(hContact, WEATHERPROTONAME, "MirVer", Data->DisplayName); return 0; } @@ -593,7 +594,7 @@ int GetWeatherData(HANDLE hContact) void CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { // only run if it is not current updating and the auto update option is enabled - if (!ThreadRunning && opt.CAutoUpdate && !Miranda_Terminated() && + if ( !ThreadRunning && opt.CAutoUpdate && !Miranda_Terminated() && (!opt.NoProtoCondition || status == ID_STATUS_ONLINE)) UpdateAll(TRUE, FALSE); } @@ -605,8 +606,7 @@ void CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) KillTimer(NULL, timerId); ThreadRunning = FALSE; - if (!Miranda_Terminated()) - { + if ( !Miranda_Terminated()) { if (opt.StartupUpdate && !opt.NoProtoCondition) UpdateAll(FALSE, FALSE); timerId = SetTimer(NULL, 0, ((int)opt.UpdateTime)*60000, (TIMERPROC)timerProc); diff --git a/protocols/Weather/src/weather_userinfo.cpp b/protocols/Weather/src/weather_userinfo.cpp index be964dceea..1d716a58ef 100644 --- a/protocols/Weather/src/weather_userinfo.cpp +++ b/protocols/Weather/src/weather_userinfo.cpp @@ -1,7 +1,8 @@ /* Weather Protocol plugin for Miranda IM -Copyright (C) 2005-2011 Boris Krasnovskiy All Rights Reserved -Copyright (C) 2002-2005 Calvin Che +Copyright (c) 2012 Miranda NG Team +Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved +Copyright (c) 2002-2005 Calvin Che This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -84,7 +85,7 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, (WPARAM)LoadSkinnedProtoIcon(WEATHERPROTONAME, - DBGetContactSettingWord(hContact, WEATHERPROTONAME, "StatusIcon",0)), 0); + db_get_w(hContact, WEATHERPROTONAME, "StatusIcon",0)), 0); { // bold and enlarge the current condition LOGFONT lf; @@ -227,7 +228,7 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l // set icons { - WORD statusIcon = DBGetContactSettingWord(hContact, WEATHERPROTONAME, "StatusIcon", 0); + WORD statusIcon = db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", 0); ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedProtoIconBig(WEATHERPROTONAME, statusIcon))); ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedProtoIcon(WEATHERPROTONAME, statusIcon))); @@ -355,7 +356,7 @@ void LoadBriefInfoText(HWND hwndDlg, HANDLE hContact) // 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)) + if ( !(BOOL)db_get_b(hContact, WEATHERPROTONAME, "IsUpdated", FALSE)) _tcscpy(str, TranslateT("No information available.\r\nPlease update weather condition first.")); else // set the display text and show the message box -- cgit v1.2.3