summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Weather/src/weather.cpp16
-rw-r--r--plugins/Weather/src/weather_addstn.cpp61
-rw-r--r--plugins/Weather/src/weather_contacts.cpp186
-rw-r--r--plugins/Weather/src/weather_conv.cpp210
-rw-r--r--plugins/Weather/src/weather_data.cpp123
-rw-r--r--plugins/Weather/src/weather_http.cpp33
-rw-r--r--plugins/Weather/src/weather_icons.cpp2
-rw-r--r--plugins/Weather/src/weather_info.cpp100
-rw-r--r--plugins/Weather/src/weather_ini.cpp230
-rw-r--r--plugins/Weather/src/weather_opt.cpp54
-rw-r--r--plugins/Weather/src/weather_popup.cpp120
-rw-r--r--plugins/Weather/src/weather_update.cpp102
-rw-r--r--plugins/Weather/src/weather_userinfo.cpp56
13 files changed, 631 insertions, 662 deletions
diff --git a/plugins/Weather/src/weather.cpp b/plugins/Weather/src/weather.cpp
index 749ed697cf..fdd4596d19 100644
--- a/plugins/Weather/src/weather.cpp
+++ b/plugins/Weather/src/weather.cpp
@@ -74,18 +74,18 @@ static const PLUGININFOEX pluginInfoEx =
{0x6b612a34, 0xdcf2, 0x4e32, {0x85, 0xcf, 0xb6, 0xfd, 0x0, 0x6b, 0x74, 0x5e}}
};
-extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
}
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
{
hInst = hinstDLL;
return TRUE;
}
-int WeatherShutdown(WPARAM, LPARAM)
+int WeatherShutdown(WPARAM, LPARAM)
{
KillTimer(NULL, timerId); // kill update timer
@@ -117,7 +117,7 @@ int OnToolbarLoaded(WPARAM, LPARAM)
// weather protocol initialization function
// run after the event ME_SYSTEM_MODULESLOADED occurs
-int WeatherInit(WPARAM, LPARAM)
+int WeatherInit(WPARAM, LPARAM)
{
// initialize netlib
NetlibInit();
@@ -139,7 +139,7 @@ int WeatherInit(WPARAM, LPARAM)
//============ MISC FUNCTIONS ============
// initialize the global variables at startup
-void InitVar()
+void InitVar()
{
// setup the linklist for weather update list
UpdateListTail = NULL;
@@ -152,7 +152,7 @@ void InitVar()
}
// unload function
-extern "C" int __declspec(dllexport) Unload(void)
+extern "C" int __declspec(dllexport) Unload(void)
{
DestroyMwin();
DestroyWindow(hPopupWindow);
@@ -174,7 +174,7 @@ extern "C" int __declspec(dllexport) Unload(void)
return 0;
}
-extern "C" int __declspec(dllexport) Load(void)
+extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfoEx);
mir_getCLI();
@@ -235,5 +235,5 @@ extern "C" int __declspec(dllexport) Load(void)
hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, _T("static"), SvcFunc, 0, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hInst, NULL);
SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc);
- return 0;
+ return 0;
}
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp
index e8e8dc25c3..bda1bd95b7 100644
--- a/plugins/Weather/src/weather_addstn.cpp
+++ b/plugins/Weather/src/weather_addstn.cpp
@@ -9,7 +9,7 @@ modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.
-This program is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@@ -32,20 +32,20 @@ static TCHAR name1[256];
// protocol service function for adding a new contact onto contact list
// lParam = PROTOSEARCHRESULT
-INT_PTR WeatherAddToList(WPARAM, LPARAM lParam)
+INT_PTR WeatherAddToList(WPARAM, LPARAM lParam)
{
PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT*)lParam;
- if(!psr || !psr->email.t)
+ if (!psr || !psr->email.t)
return 0;
// search for existing contact
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
// check if it is a weather contact
- if ( IsMyContact(hContact)) {
+ if (IsMyContact(hContact)) {
DBVARIANT dbv;
// check ID to see if the contact already exist in the database
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
- if ( !mir_tstrcmpi(psr->email.t, dbv.ptszVal)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ if (!mir_tstrcmpi(psr->email.t, dbv.ptszVal)) {
// remove the flag for not on list and hidden, thus make the contact visible
// and add them on the list
if (db_get_b(hContact, "CList", "NotOnList", 1)) {
@@ -70,7 +70,7 @@ INT_PTR WeatherAddToList(WPARAM, LPARAM lParam)
// set contact info and settings
TCHAR svc[256];
- _tcsncpy(svc, psr->email.t, _countof(svc)); svc[_countof(svc)-1] = 0;
+ _tcsncpy(svc, psr->email.t, _countof(svc)); svc[_countof(svc) - 1] = 0;
GetSvc(svc);
// set settings by obtaining the default for the service
if (psr->lastName.t[0] != 0) {
@@ -107,11 +107,11 @@ INT_PTR WeatherAddToList(WPARAM, LPARAM lParam)
GetStationID(hContact, opt.Default, _countof(opt.Default));
opt.DefStn = hContact;
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
// notification message box
mir_sntprintf(str, _countof(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
}
db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
}
@@ -123,9 +123,10 @@ INT_PTR WeatherAddToList(WPARAM, LPARAM lParam)
// ============ WARNING DIALOG ============
// show a message box and cancel search if update is in process
-BOOL CheckSearch() {
+BOOL CheckSearch()
+{
if (UpdateListHead != NULL) {
- MessageBox(NULL, TranslateT("Please try again after weather update is completed."), TranslateT("Weather Protocol"), MB_OK|MB_ICONERROR);
+ MessageBox(NULL, TranslateT("Please try again after weather update is completed."), TranslateT("Weather Protocol"), MB_OK | MB_ICONERROR);
return FALSE;
}
return TRUE;
@@ -136,11 +137,11 @@ BOOL CheckSearch() {
static TCHAR sttSID[32];
// A timer process for the ID search (threaded)
-static void __cdecl BasicSearchTimerProc(LPVOID)
+static void __cdecl BasicSearchTimerProc(LPVOID)
{
int result;
// search only when it's not current updating weather.
- if (CheckSearch())
+ if (CheckSearch())
result = IDSearch(sttSID, sttSearchId);
// broadcast the search result
@@ -152,11 +153,11 @@ static void __cdecl BasicSearchTimerProc(LPVOID)
// the service function for ID search
// lParam = ID search string
-INT_PTR WeatherBasicSearch(WPARAM, LPARAM lParam)
+INT_PTR WeatherBasicSearch(WPARAM, LPARAM lParam)
{
if (sttSearchId != -1) return 0; //only one search at a time
- _tcsncpy(sttSID, ( TCHAR* )lParam, _countof(sttSID));
- sttSID[_countof(sttSID)-1] = 0;
+ _tcsncpy(sttSID, (TCHAR*)lParam, _countof(sttSID));
+ sttSID[_countof(sttSID) - 1] = 0;
sttSearchId = 1;
// create a thread for the ID search
mir_forkthread(BasicSearchTimerProc, NULL);
@@ -166,7 +167,7 @@ INT_PTR WeatherBasicSearch(WPARAM, LPARAM lParam)
// ============ NAME SEARCH ============
// name search timer process (threaded)
-static void __cdecl NameSearchTimerProc(LPVOID)
+static void __cdecl NameSearchTimerProc(LPVOID)
{
// search only when it's not current updating weather.
if (CheckSearch())
@@ -224,7 +225,7 @@ INT_PTR WeatherAdvancedSearch(WPARAM, LPARAM lParam)
// searchId = -1
// sData = the ID search data for that particular weather service
// svcname = the name of the weather service that is currently searching (ie. Yahoo Weather)
-int IDSearchProc(TCHAR *sID, const int searchId, WIIDSEARCH *sData, TCHAR *svc, TCHAR *svcname)
+int IDSearchProc(TCHAR *sID, const int searchId, WIIDSEARCH *sData, TCHAR *svc, TCHAR *svcname)
{
TCHAR str[MAX_DATA_LEN], newID[MAX_DATA_LEN];
@@ -239,7 +240,7 @@ int IDSearchProc(TCHAR *sID, const int searchId, WIIDSEARCH *sData, TCHAR *svc,
TCHAR* szInfo = szData;
// not found
- if ( _tcsstr(szInfo, sData->NotFoundStr) == NULL)
+ if (_tcsstr(szInfo, sData->NotFoundStr) == NULL)
GetDataValue(&sData->Name, str, &szInfo);
}
@@ -268,10 +269,10 @@ int IDSearchProc(TCHAR *sID, const int searchId, WIIDSEARCH *sData, TCHAR *svc,
// sID: the ID to search for
// searchId: don't change
// return 0 if no error
-int IDSearch(TCHAR *sID, const int searchId)
+int IDSearch(TCHAR *sID, const int searchId)
{
// for a normal ID search (ID != #)
- if ( mir_tstrcmp(sID, _T("#"))) {
+ if (mir_tstrcmp(sID, _T("#"))) {
WIDATALIST *Item = WIHead;
// search every weather service using the search station ID
@@ -310,7 +311,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
// replace spaces with %20
char loc[256];
T2Utf szSearchName(name);
- mir_snprintf(loc, _countof(loc), sData->SearchURL, ptrA( mir_urlEncode(szSearchName)));
+ mir_snprintf(loc, _countof(loc), sData->SearchURL, ptrA(mir_urlEncode(szSearchName)));
if (InternetDownloadFile(loc, NULL, NULL, &szData) == 0) {
TCHAR* szInfo = szData;
search = _tcsstr(szInfo, sData->NotFoundStr); // determine if data is available
@@ -321,13 +322,13 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
// for single result
if (sData->Single.Available && (search != NULL || !sData->Multiple.Available)) { // single result
// if station ID appears first in the downloaded data
- if ( !mir_tstrcmpi(sData->Single.First, _T("ID"))) {
+ if (!mir_tstrcmpi(sData->Single.First, _T("ID"))) {
GetDataValue(&sData->Single.ID, str, &szInfo);
mir_sntprintf(sID, _countof(sID), _T("%s/%s"), svc, str);
GetDataValue(&sData->Single.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
- else if ( !mir_tstrcmpi(sData->Single.First, _T("NAME"))) {
+ else if (!mir_tstrcmpi(sData->Single.First, _T("NAME"))) {
GetDataValue(&sData->Single.Name, Name, &szInfo);
GetDataValue(&sData->Single.ID, str, &szInfo);
mir_sntprintf(sID, _countof(sID), _T("%s/%s"), svc, str);
@@ -340,7 +341,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
mir_free(szData);
return 1;
}
-
+
// if can't get the name, use the search string as name
if (Name[0] == 0)
_tcsncpy(Name, name, _countof(Name));
@@ -362,13 +363,13 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
// search for the next occurrence of the string
while (true) {
// if station ID appears first in the downloaded data
- if ( !mir_tstrcmpi(sData->Multiple.First, _T("ID"))) {
+ if (!mir_tstrcmpi(sData->Multiple.First, _T("ID"))) {
GetDataValue(&sData->Multiple.ID, str, &szInfo);
mir_sntprintf(sID, _countof(sID), _T("%s/%s"), svc, str);
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
}
// if station name appears first in the downloaded data
- else if ( !mir_tstrcmpi(sData->Multiple.First, _T("NAME"))) {
+ else if (!mir_tstrcmpi(sData->Multiple.First, _T("NAME"))) {
GetDataValue(&sData->Multiple.Name, Name, &szInfo);
GetDataValue(&sData->Multiple.ID, str, &szInfo);
mir_sntprintf(sID, _countof(sID), _T("%s/%s"), svc, str);
@@ -381,7 +382,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
break;
// if can't get the name, use the search string as name
- if (Name[0] == 0)
+ if (Name[0] == 0)
_tcsncpy(Name, name, _countof(Name));
PROTOSEARCHRESULT psr = { sizeof(psr) };
@@ -401,7 +402,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
}
mir_free(szData);
- return 1;
+ return 1;
}
// name search (Threaded)
@@ -426,7 +427,7 @@ int NameSearch(TCHAR *name, const int searchId)
// ======================MENU ITEM FUNCTION ============
// add a new weather station via find/add dialog
-int WeatherAdd(WPARAM, LPARAM)
+int WeatherAdd(WPARAM, LPARAM)
{
db_set_s(NULL, "FindAdd", "LastSearched", "Weather");
CallService(MS_FINDADD_FINDADD, 0, 0);
diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp
index 16dcf7d3ce..3ce506d66a 100644
--- a/plugins/Weather/src/weather_contacts.cpp
+++ b/plugins/Weather/src/weather_contacts.cpp
@@ -1,4 +1,4 @@
- /*
+/*
Weather Protocol plugin for Miranda IM
Copyright (c) 2012 Miranda NG Team
Copyright (c) 2005-2011 Boris Krasnovskiy All Rights Reserved
@@ -9,7 +9,7 @@ modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.
-This program is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* This file contain the source that is related to weather contacts,
+/* This file contain the source that is related to weather contacts,
include the links, edit settings, and loading weather information for
the contact.
*/
@@ -37,7 +37,7 @@ static void OpenUrl(TCHAR* format, TCHAR* id)
// view weather log for the contact
// wParam = current contact
-INT_PTR ViewLog(WPARAM wParam, LPARAM lParam)
+INT_PTR ViewLog(WPARAM wParam, LPARAM lParam)
{
// see if the log path is set
DBVARIANT dbv;
@@ -47,8 +47,8 @@ INT_PTR ViewLog(WPARAM wParam, LPARAM lParam)
db_free(&dbv);
}
else // display warning dialog if no path is specified
- MessageBox(NULL, TranslateT("Weather condition was not logged."),
- TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
+ MessageBox(NULL, TranslateT("Weather condition was not logged."),
+ TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
return 0;
}
@@ -66,14 +66,14 @@ INT_PTR LoadForecast(WPARAM wParam, LPARAM)
return 1;
}
// set the url and open the webpage
- OpenUrl(loc2, id );
+ OpenUrl(loc2, id);
}
return 0;
}
// load weather map
// wParam = current contact
-INT_PTR WeatherMap(WPARAM wParam, LPARAM)
+INT_PTR WeatherMap(WPARAM wParam, LPARAM)
{
TCHAR id[256], loc2[256];
GetStationID(wParam, id, _countof(id));
@@ -125,7 +125,7 @@ typedef struct
// edit weather settings
// lParam = current contact
-INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
DBVARIANT dbv;
TCHAR str[256], str2[256], city[256], filter[256], *pfilter, *chop;
@@ -139,7 +139,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- wndData = ( CntSetWndDataType* )mir_alloc(sizeof(CntSetWndDataType));
+ wndData = (CntSetWndDataType*)mir_alloc(sizeof(CntSetWndDataType));
wndData->hContact = hContact = lParam;
wndData->hRename = Skin_LoadIcon(SKINICON_OTHER_RENAME);
wndData->hUserDetail = Skin_LoadIcon(SKINICON_OTHER_USERDETAILS);
@@ -151,11 +151,11 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// set button images
SendDlgItemMessage(hwndDlg, IDC_GETNAME, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hUserDetail);
- SendDlgItemMessage(hwndDlg, IDC_BROWSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hFile);
- SendDlgItemMessage(hwndDlg, IDC_VIEW1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll);
- SendDlgItemMessage(hwndDlg, IDC_RESET1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
- SendDlgItemMessage(hwndDlg, IDC_VIEW2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll);
- SendDlgItemMessage(hwndDlg, IDC_RESET2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
+ SendDlgItemMessage(hwndDlg, IDC_BROWSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hFile);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll);
+ SendDlgItemMessage(hwndDlg, IDC_RESET1, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hSrchAll);
+ SendDlgItemMessage(hwndDlg, IDC_RESET2, BM_SETIMAGE, IMAGE_ICON, (LPARAM)wndData->hRename);
// make all buttons flat
SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONSETASFLATBTN, TRUE, 0);
@@ -167,30 +167,30 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONSETASFLATBTN, TRUE, 0);
// set tooltip for the buttons
- SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Get city name from ID"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Weather INI information"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Browse"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONADDTOOLTIP, (WPARAM) LPGENT("View webpage"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Reset to default"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONADDTOOLTIP, (WPARAM) LPGENT("View webpage"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONADDTOOLTIP, (WPARAM) LPGENT("Reset to default"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_GETNAME, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Get city name from ID"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_SVCINFO, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Weather INI information"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BROWSE, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Browse"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW1, BUTTONADDTOOLTIP, (WPARAM)LPGENT("View webpage"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_RESET1, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Reset to default"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_VIEW2, BUTTONADDTOOLTIP, (WPARAM)LPGENT("View webpage"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_RESET2, BUTTONADDTOOLTIP, (WPARAM)LPGENT("Reset to default"), BATF_TCHAR);
// save the handle for the contact
WindowList_Add(hWindowList, hwndDlg, hContact);
// start to get the settings
// if the setting not exist, leave the dialog box blank
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
SetDlgItemText(hwndDlg, IDC_ID, dbv.ptszVal);
// check if the station is a default station
CheckDlgButton(hwndDlg, IDC_DEFA, mir_tstrcmp(dbv.ptszVal, opt.Default) != 0 ? BST_CHECKED : BST_UNCHECKED);
db_free(&dbv);
}
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
SetDlgItemText(hwndDlg, IDC_NAME, dbv.ptszVal);
db_free(&dbv);
}
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "Log", &dbv)) {
+ if (!db_get_ts(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, BST_CHECKED);
@@ -204,11 +204,11 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
CheckDlgButton(hwndDlg, IDC_DAutoUpdate, db_get_b(hContact, WEATHERPROTONAME, "DAutoUpdate", FALSE) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_Internal, db_get_b(hContact, WEATHERPROTONAME, "History", 0) ? BST_CHECKED : BST_UNCHECKED);
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "InfoURL", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "InfoURL", &dbv)) {
SetDlgItemText(hwndDlg, IDC_IURL, dbv.ptszVal);
db_free(&dbv);
}
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "MapURL", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "MapURL", &dbv)) {
SetDlgItemText(hwndDlg, IDC_MURL, dbv.ptszVal);
db_free(&dbv);
}
@@ -222,7 +222,7 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
wndData = (CntSetWndDataType*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
hContact = wndData ? wndData->hContact : NULL;
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_ID:
// check if there are 2 parts in the ID (svc/id) seperated by "/"
// if not, don't let user change the setting
@@ -241,46 +241,47 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), str[0] != 0);
break;
- case IDC_GETNAME:
- {
- // the button for getting station name from the internet
- // this function uses the ID search for add/find weather station
+ case IDC_GETNAME:
+ // 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, _countof(str));
- GetSvc(str);
- WIDATA *sData = GetWIData(str);
- GetDlgItemText(hwndDlg, IDC_ID, str, _countof(str));
- GetID(str);
- // if ID search is available, do it
- if (sData->IDSearch.Available) {
- TCHAR *szData = NULL;
-
- // load the page
- mir_snprintf(loc, _countof(loc), sData->IDSearch.SearchURL, str);
- str[0] = 0;
- if (InternetDownloadFile(loc, NULL, sData->UserAgent, &szData) == 0) {
- TCHAR *szInfo = szData;
- TCHAR* search = _tcsstr(szInfo, sData->IDSearch.NotFoundStr);
-
- // if the page is found (ie. valid ID), get the name of the city
- if (search == NULL)
- GetDataValue(&sData->IDSearch.Name, str, &szInfo);
- }
- // free memory
- mir_free(szData);
-
- NetlibHttpDisconnect();
+ GetDlgItemText(hwndDlg, IDC_ID, str, _countof(str));
+ GetSvc(str);
+ sData = GetWIData(str);
+ GetDlgItemText(hwndDlg, IDC_ID, str, _countof(str));
+ GetID(str);
+ // if ID search is available, do it
+ if (sData->IDSearch.Available) {
+ // load the page
+ mir_snprintf(loc, _countof(loc), sData->IDSearch.SearchURL, str);
+ str[0] = 0;
+ TCHAR *pData = NULL;
+ if (InternetDownloadFile(loc, NULL, sData->UserAgent, &pData) == 0) {
+ TCHAR *szInfo = pData;
+ TCHAR* search = _tcsstr(szInfo, sData->IDSearch.NotFoundStr);
+
+ // if the page is found (ie. valid ID), get the name of the city
+ if (search == NULL)
+ GetDataValue(&sData->IDSearch.Name, str, &szInfo);
}
- // give no station name but only ID if the search is unavailable
- if (str[0] != 0) SetDlgItemText(hwndDlg, IDC_NAME, str);
- break;
+ // free memory
+ mir_free(pData);
+
+ NetlibHttpDisconnect();
}
+ // give no station name but only ID if the search is unavailable
+ if (str[0] != 0)
+ SetDlgItemText(hwndDlg, IDC_NAME, str);
+ break;
+
case IDC_External:
// enable/disable the borwse button depending if the external log is enabled
EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (BYTE)IsDlgButtonChecked(hwndDlg, IDC_External));
- if ( !(BYTE)IsDlgButtonChecked(hwndDlg, IDC_External)) return TRUE;
+ if (!(BYTE)IsDlgButtonChecked(hwndDlg, IDC_External))
+ return TRUE;
case IDC_BROWSE: // fall through
// browse for the external log file
@@ -294,14 +295,14 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// set filters
_tcsncpy(filter, TranslateT("Text Files"), _countof(filter) - 1);
mir_tstrncat(filter, _T(" (*.txt)"), _countof(filter) - mir_tstrlen(filter));
- pfilter = filter + mir_tstrlen(filter)+1;
+ pfilter = filter + mir_tstrlen(filter) + 1;
_tcsncpy(pfilter, _T("*.txt"), _countof(filter) - 1);
- pfilter = pfilter + mir_tstrlen(pfilter)+1;
+ pfilter = pfilter + mir_tstrlen(pfilter) + 1;
_tcsncpy(pfilter, TranslateT("All Files"), _countof(filter) - 1);
mir_tstrncat(pfilter, _T(" (*.*)"), _countof(filter) - mir_tstrlen(filter));
- pfilter = pfilter + mir_tstrlen(pfilter)+1;
+ pfilter = pfilter + mir_tstrlen(pfilter) + 1;
_tcsncpy(pfilter, _T("*.*"), _countof(filter) - 1);
- pfilter = pfilter + mir_tstrlen(pfilter)+1;
+ pfilter = pfilter + mir_tstrlen(pfilter) + 1;
*pfilter = '\0';
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
@@ -320,7 +321,8 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case IDC_VIEW1:
// view the page for more info
GetDlgItemText(hwndDlg, IDC_IURL, str, _countof(str));
- if (str[0] == 0) return TRUE;
+ if (str[0] == 0)
+ return TRUE;
GetDlgItemText(hwndDlg, IDC_ID, str2, _countof(str2));
OpenUrl(str, str2);
break;
@@ -328,7 +330,8 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case IDC_VIEW2:
// view the page for weather map
GetDlgItemText(hwndDlg, IDC_MURL, str, _countof(str));
- if (str[0] == 0) return TRUE;
+ if (str[0] == 0)
+ return TRUE;
GetDlgItemText(hwndDlg, IDC_ID, str2, _countof(str2));
OpenUrl(str, str2);
break;
@@ -426,46 +429,43 @@ INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
// when a contact is deleted, make sure some other contact take over the default station
// wParam = deleted contact
-int ContactDeleted(WPARAM wParam, LPARAM)
+int ContactDeleted(WPARAM wParam, LPARAM)
{
if (!IsMyContact(wParam))
- return 0;
+ return 0;
removeWindow(wParam);
// exit this function if it is not default station
- DBVARIANT dbv;
- if (!db_get_ts(wParam, WEATHERPROTONAME, "ID", &dbv)) {
- if ( mir_tstrcmp(dbv.ptszVal, opt.Default)) {
- db_free(&dbv);
+ ptrT tszID(db_get_tsa(wParam, WEATHERPROTONAME, "ID"));
+ if (tszID != NULL)
+ if (mir_tstrcmp(tszID, opt.Default))
return 0;
- }
- db_free(&dbv);
- }
// now the default station is deleted, try to get a new one
// start looking for other weather stations
for (MCONTACT hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) {
- if ( !db_get_ts(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 ( mir_tstrcmp(opt.Default, dbv.ptszVal)) {
- _tcsncpy(opt.Default, dbv.ptszVal, _countof(opt.Default) - 1);
- opt.DefStn = hContact;
- db_free(&dbv);
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
- TCHAR str[255];
- mir_sntprintf(str, _countof(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
- db_free(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
- }
- db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
- return 0; // exit this function quickly
+ tszID = db_get_tsa(hContact, WEATHERPROTONAME, "ID");
+ if (tszID == NULL)
+ continue;
+
+ // 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 (mir_tstrcmp(opt.Default, tszID)) {
+ _tcsncpy_s(opt.Default, tszID, _TRUNCATE);
+ opt.DefStn = hContact;
+ ptrT tszNick(db_get_tsa(hContact, WEATHERPROTONAME, "Nick"));
+ if (tszNick != NULL) {
+ TCHAR str[255];
+ mir_sntprintf(str, _countof(str), TranslateT("%s is now the default weather station"), (TCHAR*)tszNick);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
}
- db_free(&dbv);
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ return 0; // exit this function quickly
}
}
+
// got here if no more weather station left
opt.Default[0] = 0; // no default station
opt.DefStn = NULL;
@@ -475,6 +475,6 @@ int ContactDeleted(WPARAM wParam, LPARAM)
BOOL IsMyContact(MCONTACT hContact)
{
- const char* szProto = GetContactProto(hContact);
+ const char *szProto = GetContactProto(hContact);
return szProto != NULL && mir_strcmp(WEATHERPROTONAME, szProto) == 0;
}
diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp
index 5d546609aa..b77cb46500 100644
--- a/plugins/Weather/src/weather_conv.cpp
+++ b/plugins/Weather/src/weather_conv.cpp
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
-This file contain the source related unit conversion, icon assignment,
+This file contain the source related unit conversion, icon assignment,
string conversions, display text parsing, etc
*/
@@ -30,14 +30,13 @@ string conversions, display text parsing, etc
// see if a string is a number
// s = the string to be determined
// return value = true if the string is a number, false if it isn't
-BOOL is_number(TCHAR *s)
+BOOL is_number(TCHAR *s)
{
BOOL tag = FALSE;
// looking character by character
// for a number: numerous spaces in front, then optional +/-, then the number
// don't care anything that comes after it
- while(*s != '\0')
- {
+ while (*s != '\0') {
if (*s >= '0' && *s <= '9') return TRUE;
else if (*s == ' ');
else if (*s != '+' && *s != '-') return FALSE;
@@ -76,7 +75,7 @@ static void numToStr(double num, TCHAR *str, size_t strSize)
// tempchar = the string containing the temperature value
// unit = the unit for temperature
// return value = the converted temperature with degree sign and unit; if fails, return N/A
-void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
+void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
{
// unit can be C, F
double temp;
@@ -84,14 +83,14 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
TrimString(tempchar);
if (tempchar[0] == '-' && tempchar[1] == ' ')
- memmove(&tempchar[1], &tempchar[2], sizeof(TCHAR)*(mir_tstrlen(&tempchar[2])+1));
+ memmove(&tempchar[1], &tempchar[2], sizeof(TCHAR)*(mir_tstrlen(&tempchar[2]) + 1));
// quit if the value obtained is N/A or not a number
- if ( !mir_tstrcmp(tempchar, NODATA) || !mir_tstrcmp(tempchar, _T("N/A"))) {
+ if (!mir_tstrcmp(tempchar, NODATA) || !mir_tstrcmp(tempchar, _T("N/A"))) {
mir_tstrcpy(str, tempchar);
return;
}
- if ( !is_number(tempchar)) {
+ if (!is_number(tempchar)) {
mir_tstrcpy(str, NODATA);
return;
}
@@ -100,14 +99,14 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
temp = _ttof(tempchar);
// convert all to F first
- if ( !mir_tstrcmpi(unit, _T("C"))) temp = (temp*9/5)+32;
- else if ( !mir_tstrcmpi(unit, _T("K"))) temp = ((temp-273.15)*9/5)+32;
+ if (!mir_tstrcmpi(unit, _T("C"))) temp = (temp * 9 / 5) + 32;
+ else if (!mir_tstrcmpi(unit, _T("K"))) temp = ((temp - 273.15) * 9 / 5) + 32;
// convert to apporiate unit
switch (opt.tUnit) {
case 1:
// rounding
- numToStr((temp-32)/9*5, tstr, _countof(tstr));
+ numToStr((temp - 32) / 9 * 5, tstr, _countof(tstr));
if (opt.DoNotAppendUnit)
_tcsncpy_s(str, MAX_DATA_LEN, tstr, _TRUNCATE);
else
@@ -128,7 +127,7 @@ void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
// tempchar = the string containing the pressure value
// unit = the unit for pressure
// return value = the converted pressure with unit; if fail, return the original string
-void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
+void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
{
// unit can be kPa, hPa, mb, in, mm, torr
double tempunit = 0, output;
@@ -138,44 +137,44 @@ void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
// if it end up with 0, then it's not a number, return the original string and quit
output = _ttof(tempchar);
if (output == 0) {
- mir_tstrcpy(str, tempchar);
+ mir_tstrcpy(str, tempchar);
return;
}
// convert all to mb first
- if ( !mir_tstrcmpi(unit, _T("KPA")))
+ if (!mir_tstrcmpi(unit, _T("KPA")))
tempunit = (double)output * 10;
- else if ( !mir_tstrcmpi(unit, _T("HPA")))
+ else if (!mir_tstrcmpi(unit, _T("HPA")))
tempunit = (double)output;
- else if ( !mir_tstrcmpi(unit, _T("MB")))
+ else if (!mir_tstrcmpi(unit, _T("MB")))
tempunit = (double)output;
- else if ( !mir_tstrcmpi(unit, _T("IN")))
+ else if (!mir_tstrcmpi(unit, _T("IN")))
tempunit = (double)output * 33.86388;
- else if ( !mir_tstrcmpi(unit, _T("MM")))
+ else if (!mir_tstrcmpi(unit, _T("MM")))
tempunit = (double)output * 1.33322;
- else if ( !mir_tstrcmpi(unit, _T("TORR")))
+ else if (!mir_tstrcmpi(unit, _T("TORR")))
tempunit = (double)output * 1.33322;
// convert to apporiate unit
switch (opt.pUnit) {
case 1:
intunit = (int)(tempunit + 0.5);
- mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
+ mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit / 10, intunit % 10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
break;
case 2:
intunit = (int)(tempunit + 0.5);
mir_sntprintf(str, MAX_DATA_LEN, _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
break;
case 3:
- intunit = (int)((tempunit*10 / 33.86388) + 0.5);
- mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
+ intunit = (int)((tempunit * 10 / 33.86388) + 0.5);
+ mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit / 10, intunit % 10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
break;
case 4:
- intunit = (int)((tempunit*10 / 1.33322) + 0.5);
- mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
+ intunit = (int)((tempunit * 10 / 1.33322) + 0.5);
+ mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit / 10, intunit % 10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
break;
default:
- mir_tstrcpy(str, tempchar);
+ mir_tstrcpy(str, tempchar);
break;
}
@@ -185,7 +184,7 @@ void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str)
// tempchar = the string containing the speed value
// unit = the unit for speed
// return value = the converted speed with unit; if fail, return _T(""
-void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
+void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
{
// unit can be km/h, mph, m/s, knots
double tempunit;
@@ -200,13 +199,13 @@ void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
return;
// convert all to m/s first
- if ( !mir_tstrcmpi(unit, _T("KM/H")))
+ if (!mir_tstrcmpi(unit, _T("KM/H")))
tempunit /= 3.6;
-// else if ( !mir_tstrcmpi(unit, _T("M/S"))
-// tempunit = tempunit;
- else if ( !mir_tstrcmpi(unit, _T("MPH")))
+ // else if ( !mir_tstrcmpi(unit, _T("M/S"))
+ // tempunit = tempunit;
+ else if (!mir_tstrcmpi(unit, _T("MPH")))
tempunit *= 0.44704;
- else if ( !mir_tstrcmpi(unit, _T("KNOTS")))
+ else if (!mir_tstrcmpi(unit, _T("KNOTS")))
tempunit *= 0.514444;
// convert to apporiate unit
@@ -234,7 +233,7 @@ void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
// tempchar = the string containing the distance value
// unit = the unit for distance
// return value = the converted distance with unit; if fail, return original string
-void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
+void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
{
// unit can be km, miles
double tempunit = 0, output;
@@ -249,20 +248,20 @@ void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
}
// convert all to km first
- if ( !mir_tstrcmpi(unit, _T("KM")))
+ if (!mir_tstrcmpi(unit, _T("KM")))
tempunit = (double)output;
- else if ( !mir_tstrcmpi(unit, _T("MILES")))
+ else if (!mir_tstrcmpi(unit, _T("MILES")))
tempunit = (double)output * 1.609;
// convert to apporiate unit
switch (opt.vUnit) {
case 1:
- intunit = (int)((tempunit*10) + 0.5);
- mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
+ intunit = (int)((tempunit * 10) + 0.5);
+ mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit / 10, intunit % 10, opt.DoNotAppendUnit ? _T("") : TranslateT("km"));
break;
case 2:
- intunit = (int)((tempunit*10 / 1.609) + 0.5);
- mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
+ intunit = (int)((tempunit * 10 / 1.609) + 0.5);
+ mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit / 10, intunit % 10, opt.DoNotAppendUnit ? _T("") : TranslateT("miles"));
break;
default:
mir_tstrcpy(str, tempchar);
@@ -274,7 +273,7 @@ void GetDist(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
// tempchar = the string containing the elevation value
// unit = the unit for elevation
// return value = the converted elevation with unit; if fail, return original string
-void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
+void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
{
// unit can be ft, m
double tempunit = 0, output;
@@ -289,20 +288,20 @@ void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
}
// convert all to m first
- if ( !mir_tstrcmpi(unit, _T("M")))
+ if (!mir_tstrcmpi(unit, _T("M")))
tempunit = (double)output;
- else if ( !mir_tstrcmpi(unit, _T("FT")))
+ else if (!mir_tstrcmpi(unit, _T("FT")))
tempunit = (double)output / 3.28;
// convert to apporiate unit
switch (opt.eUnit) {
case 1:
- intunit = (int)((tempunit*10 * 3.28) + 0.5);
- mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
+ intunit = (int)((tempunit * 10 * 3.28) + 0.5);
+ mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit / 10, intunit % 10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
break;
case 2:
- intunit = (int)((tempunit*10) + 0.5);
- mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
+ intunit = (int)((tempunit * 10) + 0.5);
+ mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit / 10, intunit % 10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
break;
default:
mir_tstrcpy(str, tempchar);
@@ -320,11 +319,11 @@ void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str)
static const TCHAR *statusStr[10] = { _T("Lightning"), _T("Fog"), _T("Snow Shower"), _T("Snow"), _T("Rain Shower"), _T("Rain"), _T("Partly Cloudy"), _T("Cloudy"), _T("Sunny"), _T("N/A") };
static const WORD statusValue[10] = { LIGHT, FOG, SSHOWER, SNOW, RSHOWER, RAIN, PCLOUDY, CLOUDY, SUNNY, NA };
-WORD GetIcon(const TCHAR* cond, WIDATA *Data)
+WORD GetIcon(const TCHAR* cond, WIDATA *Data)
{
// set the icon using ini
- for (int i=0; i<10; i++)
- if ( IsContainedInCondList(cond, &Data->CondList[i]))
+ for (int i = 0; i < 10; i++)
+ if (IsContainedInCondList(cond, &Data->CondList[i]))
return statusValue[i];
// internal detection
@@ -334,23 +333,23 @@ WORD GetIcon(const TCHAR* cond, WIDATA *Data)
_tcsstr(cond, _T("partly cloudy")) != NULL ||
_tcsstr(cond, _T("mostly")) != NULL ||
_tcsstr(cond, _T("clouds")) != NULL) {
- return PCLOUDY;
+ return PCLOUDY;
}
else if (
_tcsstr(cond, _T("sunny")) != NULL ||
_tcsstr(cond, _T("clear")) != NULL ||
_tcsstr(cond, _T("fair")) != NULL) {
- return SUNNY;
+ return SUNNY;
}
else if (
- _tcsstr(cond, _T("thunder")) != NULL ||
+ _tcsstr(cond, _T("thunder")) != NULL ||
_tcsstr(cond, _T("t-storm")) != NULL) {
- return LIGHT;
+ return LIGHT;
}
else if (
_tcsstr(cond, _T("cloud")) != NULL ||
_tcsstr(cond, _T("overcast")) != NULL) {
- return CLOUDY;
+ return CLOUDY;
}
else if (
_tcsstr(cond, _T("fog")) != NULL ||
@@ -359,17 +358,16 @@ WORD GetIcon(const TCHAR* cond, WIDATA *Data)
_tcsstr(cond, _T("sand")) != NULL ||
_tcsstr(cond, _T("dust")) != NULL ||
_tcsstr(cond, _T("haze")) != NULL) {
- return FOG;
+ return FOG;
}
else if (
(_tcsstr(cond, _T("shower")) != NULL && _tcsstr(cond, _T("snow")) != NULL) ||
_tcsstr(cond, _T("flurries")) != NULL) {
- return SSHOWER;
+ return SSHOWER;
}
else if (
_tcsstr(cond, _T("rain shower")) != NULL ||
- _tcsstr(cond, _T("shower")) != NULL)
- {
+ _tcsstr(cond, _T("shower")) != NULL) {
return RSHOWER;
}
else if (
@@ -377,17 +375,16 @@ WORD GetIcon(const TCHAR* cond, WIDATA *Data)
_tcsstr(cond, _T("ice")) != NULL ||
_tcsstr(cond, _T("freezing")) != NULL ||
_tcsstr(cond, _T("wintry")) != NULL) {
- return SNOW;
+ return SNOW;
}
else if (
_tcsstr(cond, _T("drizzle")) != NULL ||
- _tcsstr(cond, _T("rain")) != NULL)
- {
+ _tcsstr(cond, _T("rain")) != NULL) {
return RAIN;
}
// set the icon using langpack
- for (int i=0; i < 9; i++) {
+ for (int i = 0; i < 9; i++) {
TCHAR LangPackStr[64], LangPackStr1[128];
int j = 0;
do {
@@ -399,8 +396,7 @@ WORD GetIcon(const TCHAR* cond, WIDATA *Data)
if (_tcsstr(cond, LangPackStr1) != NULL)
return statusValue[i];
// loop until the translation string exists (ie, the translated string is differ from original)
- }
- while (mir_tstrcmp(TranslateTS(LangPackStr), LangPackStr));
+ } while (mir_tstrcmp(TranslateTS(LangPackStr), LangPackStr));
}
return NA;
@@ -409,70 +405,72 @@ WORD GetIcon(const TCHAR* cond, WIDATA *Data)
//============ STRING CONVERSIONS ============
// this function convert the string to the format with 1 upper case followed by lower case char
-void CaseConv(TCHAR *str)
+void CaseConv(TCHAR *str)
{
TCHAR *pstr;
BOOL nextUp = TRUE;
CharLowerBuff(str, (DWORD)mir_tstrlen(str));
- for(pstr = str; *pstr; pstr++) {
+ for (pstr = str; *pstr; pstr++) {
if (*pstr == ' ' || *pstr == '-')
nextUp = TRUE;
else {
TCHAR ch = *(TCHAR*)pstr;
if (nextUp)
- *pstr = ( TCHAR )CharUpper((LPTSTR)ch);
+ *pstr = (TCHAR)CharUpper((LPTSTR)ch);
nextUp = FALSE;
-} } }
+ }
+ }
+}
// the next 2 functions are copied from miranda source
// str = the string to modify
-void TrimString(char *str)
+void TrimString(char *str)
{
size_t len, start;
len = mir_strlen(str);
- while(len && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
- for(start=0; (unsigned char)str[start] <= ' ' && str[start]; start++);
- memmove(str, str+start, len-start+1);
+ while (len && (unsigned char)str[len - 1] <= ' ') str[--len] = 0;
+ for (start = 0; (unsigned char)str[start] <= ' ' && str[start]; start++);
+ memmove(str, str + start, len - start + 1);
}
-void TrimString(WCHAR *str)
+void TrimString(WCHAR *str)
{
size_t len, start;
len = mir_wstrlen(str);
- while(len && (unsigned char)str[len-1] <= ' ') str[--len] = 0;
- for(start=0; (unsigned char)str[start] <= ' ' && str[start]; start++);
- memmove(str, str+start, (len-start+1)*sizeof(WCHAR));
+ while (len && (unsigned char)str[len - 1] <= ' ') str[--len] = 0;
+ for (start = 0; (unsigned char)str[start] <= ' ' && str[start]; start++);
+ memmove(str, str + start, (len - start + 1)*sizeof(WCHAR));
}
// convert \t to tab and \n to linefeed
-void ConvertBackslashes(char *str)
+void ConvertBackslashes(char *str)
{
- for (char *pstr=str; *pstr; pstr = CharNextA(pstr)) {
+ for (char *pstr = str; *pstr; pstr = CharNextA(pstr)) {
if (*pstr == '\\') {
- switch(pstr[1]) {
- case 'n': *pstr = '\n'; break;
- case 't': *pstr = '\t'; break;
- default: *pstr = pstr[1]; break;
+ switch (pstr[1]) {
+ case 'n': *pstr = '\n'; break;
+ case 't': *pstr = '\t'; break;
+ default: *pstr = pstr[1]; break;
}
- memmove(pstr+1, pstr+2, mir_strlen(pstr+2)+1);
-} } }
+ memmove(pstr + 1, pstr + 2, mir_strlen(pstr + 2) + 1);
+ }
+ }
+}
// replace spaces with _T("%20"
// dis = original string
// return value = the modified string with space -> _T("%20"
-char *GetSearchStr(char *dis)
+char *GetSearchStr(char *dis)
{
char *pstr = dis;
size_t len = mir_strlen(dis);
- while (*pstr != 0)
- {
- if (*pstr == ' ')
- {
- memmove(pstr+3, pstr+1, len);
+ while (*pstr != 0) {
+ if (*pstr == ' ') {
+ memmove(pstr + 3, pstr + 1, len);
memcpy(pstr, _T("%20"), 3);
pstr += 2;
}
@@ -488,7 +486,7 @@ char *GetSearchStr(char *dis)
// w = WEATHERINFO data to be parsed
// dis = the string to parse
// return value = the parsed string
-TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str)
+TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str)
{
TCHAR lpzDate[32], chr;
char name[256], temp[2];
@@ -499,22 +497,21 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str)
str[0] = 0;
// looking character by character
- for (i=0; i < mir_tstrlen(dis); i++) {
+ for (i = 0; i < mir_tstrlen(dis); i++) {
// for the escape characters
if (dis[i] == '\\') {
i++;
chr = dis[i];
switch (chr) {
- case '%': mir_tstrcat(str, _T("%")); break;
- case 't': mir_tstrcat(str, _T("\t")); break;
- case 'n': mir_tstrcat(str, _T("\r\n")); break;
- case '\\': mir_tstrcat(str, _T("\\")); break;
- }
+ case '%': mir_tstrcat(str, _T("%")); break;
+ case 't': mir_tstrcat(str, _T("\t")); break;
+ case 'n': mir_tstrcat(str, _T("\r\n")); break;
+ case '\\': mir_tstrcat(str, _T("\\")); break;
+ }
}
// for the % varaibles
- else if (dis[i] == '%')
- {
+ else if (dis[i] == '%') {
i++;
chr = dis[i];
// turn capitalized characters to small case
@@ -552,8 +549,8 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str)
mir_strcat(name, temp);
}
// access the database to get its value
- if ( !db_get_ts(w->hContact, WEATHERCONDITION, name, &dbv)) {
- if (dbv.ptszVal != TranslateTS(NODATA) && dbv.ptszVal != TranslateT("<Error>"))
+ if (!db_get_ts(w->hContact, WEATHERCONDITION, name, &dbv)) {
+ if (dbv.ptszVal != TranslateTS(NODATA) && dbv.ptszVal != TranslateT("<Error>"))
mir_tstrcat(str, dbv.ptszVal);
db_free(&dbv);
}
@@ -564,13 +561,14 @@ TCHAR* GetDisplay(WEATHERINFO *w, const TCHAR *dis, TCHAR* str)
else {
mir_sntprintf(lpzDate, _countof(lpzDate), _T("%c"), dis[i]);
mir_tstrcat(str, lpzDate);
- } }
+ }
+ }
return str;
}
TCHAR svcReturnText[MAX_TEXT_SIZE];
-INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam)
+INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam)
{
WEATHERINFO winfo = LoadWeatherInfo(wParam);
return (INT_PTR)GetDisplay(&winfo, (TCHAR*)lParam, svcReturnText);
@@ -581,7 +579,7 @@ INT_PTR GetDisplaySvcFunc(WPARAM wParam, LPARAM lParam)
// get service data module internal name
// mod/id <- the mod part
// pszID = original 2-part id, return the service internal name
-void GetSvc(TCHAR *pszID)
+void GetSvc(TCHAR *pszID)
{
TCHAR *chop = _tcsstr(pszID, _T("/"));
if (chop != NULL) *chop = '\0';
@@ -591,10 +589,10 @@ void GetSvc(TCHAR *pszID)
// get the id use for update without the service internal name
// mod/id <- the id part
// pszID = original 2-part id, return the single part id
-void GetID(TCHAR *pszID)
+void GetID(TCHAR *pszID)
{
TCHAR *chop = _tcsstr(pszID, _T("/"));
- if (chop != NULL) mir_tstrcpy(pszID, chop+1);
+ if (chop != NULL) mir_tstrcpy(pszID, chop + 1);
else pszID[0] = 0;
}
@@ -604,7 +602,7 @@ void GetID(TCHAR *pszID)
// code = the error code obtained when updating weather
// str = the string for the error
-TCHAR *GetError(int code)
+TCHAR *GetError(int code)
{
TCHAR *str, str2[100];
switch (code) {
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp
index d9aac9ab94..c1c5a53168 100644
--- a/plugins/Weather/src/weather_data.cpp
+++ b/plugins/Weather/src/weather_data.cpp
@@ -40,7 +40,7 @@ void GetStationID(MCONTACT hContact, TCHAR* id, size_t idlen)
// initialize weather info by loading values from database
// hContact = current contact handle
// return value = the current weather information in WEATHERINFO struct
-WEATHERINFO LoadWeatherInfo(MCONTACT hContact)
+WEATHERINFO LoadWeatherInfo(MCONTACT hContact)
{
// obtaining values from the DB
// assuming station ID must exist at all time, but others does not have to
@@ -86,15 +86,15 @@ WEATHERINFO LoadWeatherInfo(MCONTACT hContact)
// getting weather setting from database
// return 0 on success
-int DBGetData(MCONTACT hContact, char *setting, DBVARIANT *dbv)
+int DBGetData(MCONTACT hContact, char *setting, DBVARIANT *dbv)
{
- if ( db_get_ts(hContact, WEATHERCONDITION, setting, dbv)) {
+ if (db_get_ts(hContact, WEATHERCONDITION, setting, dbv)) {
size_t len = mir_strlen(setting) + 1;
char *set = (char*)alloca(len + 1);
*set = '#';
memcpy(set + 1, setting, len);
- if ( db_get_ts(hContact, WEATHERCONDITION, set, dbv))
+ if (db_get_ts(hContact, WEATHERCONDITION, set, dbv))
return 1;
}
return 0;
@@ -103,12 +103,12 @@ int DBGetData(MCONTACT hContact, char *setting, DBVARIANT *dbv)
int DBGetStaticString(MCONTACT hContact, const char *szModule, const char *valueName, TCHAR *dest, size_t dest_len)
{
DBVARIANT dbv;
- if ( db_get_ts( hContact, szModule, valueName, &dbv ))
+ if (db_get_ts(hContact, szModule, valueName, &dbv))
return 1;
- _tcsncpy( dest, dbv.ptszVal, dest_len );
- dest[ dest_len-1 ] = 0;
- db_free( &dbv );
+ _tcsncpy(dest, dbv.ptszVal, dest_len);
+ dest[dest_len - 1] = 0;
+ db_free(&dbv);
return 0;
}
@@ -117,7 +117,7 @@ int DBGetStaticString(MCONTACT hContact, const char *szModule, const char *value
// erase all current weather information from database
// lastver = the last used version number in dword (using PLUGIN_MAKE_VERSION)
-void EraseAllInfo()
+void EraseAllInfo()
{
TCHAR str[255];
int ContactCount = 0;
@@ -125,11 +125,11 @@ void EraseAllInfo()
DBVARIANT dbv;
// loop through all contacts
for (MCONTACT hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) {
- db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE);
- db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE);
+ 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 ( db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ if (db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>"));
db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never");
db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
@@ -140,29 +140,29 @@ void EraseAllInfo()
DBDataManage(hContact, WDBM_REMOVE, 0, 0);
db_set_s(hContact, "UserInfo", "MyNotes", "");
// reset update tag
- db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE);
+ db_set_b(hContact, WEATHERPROTONAME, "IsUpdated", FALSE);
// reset logging settings
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log", &dbv)) {
- db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0));
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "Log", &dbv)) {
+ db_set_b(hContact, WEATHERPROTONAME, "File", (BYTE)(dbv.ptszVal[0] != 0));
db_free(&dbv);
}
- else db_set_b(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, _countof(opt.Default));
opt.DefStn = hContact;
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
mir_sntprintf(str, _countof(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
}
}
// get the handle of the default station
if (opt.DefStn == NULL) {
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "ID",&dbv)) {
- if ( !mir_tstrcmp(dbv.ptszVal, opt.Default))
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ if (!mir_tstrcmp(dbv.ptszVal, opt.Default))
opt.DefStn = hContact;
db_free(&dbv);
}
@@ -175,83 +175,76 @@ void EraseAllInfo()
// if (ContactCount != 0) status = ONLINE;
// in case where the default station is missing
if (opt.DefStn == NULL && ContactCount != 0) {
- if ( !db_get_ts(LastContact, WEATHERPROTONAME, "ID", &dbv)) {
+ if (!db_get_ts(LastContact, WEATHERPROTONAME, "ID", &dbv)) {
_tcsncpy(opt.Default, dbv.ptszVal, _countof(opt.Default) - 1);
db_free(&dbv);
}
opt.DefStn = LastContact;
- if ( !db_get_ts(LastContact,WEATHERPROTONAME, "Nick",&dbv)) {
+ if (!db_get_ts(LastContact, WEATHERPROTONAME, "Nick", &dbv)) {
mir_sntprintf(str, _countof(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
}
}
// save option in case of default station changed
db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
}
-void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data)
+void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data)
{
TCHAR str[MAX_DATA_LEN];
// convert the unit
- if ( mir_tstrcmp(Data, TranslateT("<Error>")) && mir_tstrcmp(Data, NODATA) && mir_tstrcmp(Data, TranslateTS(NODATA))) {
+ if (mir_tstrcmp(Data, TranslateT("<Error>")) && mir_tstrcmp(Data, NODATA) && mir_tstrcmp(Data, TranslateTS(NODATA))) {
// temperature
- if ( !mir_tstrcmp(UpdateData->Name, _T("Temperature")) || !mir_tstrcmp(UpdateData->Name, _T("High")) ||
- !mir_tstrcmp(UpdateData->Name, _T("Low")) || !mir_tstrcmp(UpdateData->Name, _T("Feel")) ||
+ if (!mir_tstrcmp(UpdateData->Name, _T("Temperature")) || !mir_tstrcmp(UpdateData->Name, _T("High")) ||
+ !mir_tstrcmp(UpdateData->Name, _T("Low")) || !mir_tstrcmp(UpdateData->Name, _T("Feel")) ||
!mir_tstrcmp(UpdateData->Name, _T("Dewpoint")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("C")) || !mir_tstrcmpi(UpdateData->Unit, _T("F")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("K")))
- {
+ !mir_tstrcmpi(UpdateData->Unit, _T("C")) || !mir_tstrcmpi(UpdateData->Unit, _T("F")) ||
+ !mir_tstrcmpi(UpdateData->Unit, _T("K"))) {
GetTemp(Data, UpdateData->Unit, str);
mir_tstrcpy(Data, str);
}
// pressure
- else if ( !mir_tstrcmp(UpdateData->Name, _T("Pressure")) || !mir_tstrcmpi(UpdateData->Unit, _T("HPA")) ||
+ else if (!mir_tstrcmp(UpdateData->Name, _T("Pressure")) || !mir_tstrcmpi(UpdateData->Unit, _T("HPA")) ||
!mir_tstrcmpi(UpdateData->Unit, _T("KPA")) || !mir_tstrcmpi(UpdateData->Unit, _T("MB")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("TORR")) || !mir_tstrcmpi(UpdateData->Unit, _T("IN")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("MM")))
- {
+ !mir_tstrcmpi(UpdateData->Unit, _T("TORR")) || !mir_tstrcmpi(UpdateData->Unit, _T("IN")) ||
+ !mir_tstrcmpi(UpdateData->Unit, _T("MM"))) {
GetPressure(Data, UpdateData->Unit, str);
mir_tstrcpy(Data, str);
}
// speed
- else if ( !mir_tstrcmp(UpdateData->Name, _T("Wind Speed")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM/H")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("M/S")) || !mir_tstrcmpi(UpdateData->Unit, _T("MPH")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("KNOTS")))
- {
+ else if (!mir_tstrcmp(UpdateData->Name, _T("Wind Speed")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM/H")) ||
+ !mir_tstrcmpi(UpdateData->Unit, _T("M/S")) || !mir_tstrcmpi(UpdateData->Unit, _T("MPH")) ||
+ !mir_tstrcmpi(UpdateData->Unit, _T("KNOTS"))) {
GetSpeed(Data, UpdateData->Unit, str);
mir_tstrcpy(Data, str);
}
// visibility
- else if ( !mir_tstrcmp(UpdateData->Name, _T("Visibility")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("MILES")))
- {
+ else if (!mir_tstrcmp(UpdateData->Name, _T("Visibility")) || !mir_tstrcmpi(UpdateData->Unit, _T("KM")) ||
+ !mir_tstrcmpi(UpdateData->Unit, _T("MILES"))) {
GetDist(Data, UpdateData->Unit, str);
mir_tstrcpy(Data, str);
}
// elevation
- else if ( !mir_tstrcmp(UpdateData->Name, _T("Elevation")) || !mir_tstrcmpi(UpdateData->Unit, _T("FT")) ||
- !mir_tstrcmpi(UpdateData->Unit, _T("M")))
- {
+ else if (!mir_tstrcmp(UpdateData->Name, _T("Elevation")) || !mir_tstrcmpi(UpdateData->Unit, _T("FT")) ||
+ !mir_tstrcmpi(UpdateData->Unit, _T("M"))) {
GetElev(Data, UpdateData->Unit, str);
mir_tstrcpy(Data, str);
}
// converting case for condition to the upper+lower format
- else if ( !mir_tstrcmpi(UpdateData->Unit, _T("COND")))
+ else if (!mir_tstrcmpi(UpdateData->Unit, _T("COND")))
CaseConv(Data);
// degree sign
- else if ( !mir_tstrcmpi(UpdateData->Unit, _T("DEG")))
- {
- if ( !opt.DoNotAppendUnit) mir_tstrcat(Data, opt.DegreeSign);
+ else if (!mir_tstrcmpi(UpdateData->Unit, _T("DEG"))) {
+ if (!opt.DoNotAppendUnit) mir_tstrcat(Data, opt.DegreeSign);
}
// percent sign
- else if ( !mir_tstrcmpi(UpdateData->Unit, _T("%")))
- {
- if ( !opt.DoNotAppendUnit) mir_tstrcat(Data, _T("%"));
+ else if (!mir_tstrcmpi(UpdateData->Unit, _T("%"))) {
+ if (!opt.DoNotAppendUnit) mir_tstrcat(Data, _T("%"));
}
// truncating strings for day/month to 2 or 3 characters
- else if ( !mir_tstrcmpi(UpdateData->Unit, _T("DAY")) || !mir_tstrcmpi(UpdateData->Unit, _T("MONTH")))
+ else if (!mir_tstrcmpi(UpdateData->Unit, _T("DAY")) || !mir_tstrcmpi(UpdateData->Unit, _T("MONTH")))
if (opt.dUnit > 1 && mir_tstrlen(Data) > opt.dUnit)
Data[opt.dUnit] = '\0';
}
@@ -264,7 +257,7 @@ void ConvertDataValue(WIDATAITEM *UpdateData, TCHAR *Data)
// Data = the string containing weather data obtained from UpdateData
// global var. used: szInfo = the downloaded string
-void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
+void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
{
TCHAR last = 0, current, *start, *end;
unsigned startloc = 0, endloc = 0, respos = 0;
@@ -288,7 +281,7 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
// the end string must be found too
if (UpdateData->End[0] != 0)
end = _tcsstr(szInfo, UpdateData->End);
- else
+ else
end = _tcsstr(szInfo, _T(" "));
if (end != NULL) {
@@ -298,7 +291,7 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
end += mir_tstrlen(UpdateData->End);
last = '\n';
}
-
+
// ignore if not both of the string found - this prevent crashes
if (start != NULL && end != NULL) {
// begin reading the data from start location to end location
@@ -307,12 +300,10 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
while (startloc < endloc) {
if (szInfo[startloc] == '<') tag = TRUE;
else if (szInfo[startloc] == '&' &&
- (szInfo[startloc+1] == ';' || szInfo[startloc+2] == ';' || szInfo[startloc+3] == ';' ||
- szInfo[startloc+4] == ';' || szInfo[startloc+5] == ';' || szInfo[startloc+6] == ';'))
- {
+ (szInfo[startloc + 1] == ';' || szInfo[startloc + 2] == ';' || szInfo[startloc + 3] == ';' ||
+ szInfo[startloc + 4] == ';' || szInfo[startloc + 5] == ';' || szInfo[startloc + 6] == ';')) {
// ...but do NOT strip &minus;
- if ((endloc - startloc) > 7 &&_tcsncmp(szInfo + startloc, _T("&minus;"), 7) == 0)
- {
+ if ((endloc - startloc) > 7 && _tcsncmp(szInfo + startloc, _T("&minus;"), 7) == 0) {
Data[respos++] = '-';
startloc += 7;
continue;
@@ -322,7 +313,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 = ' ';
@@ -348,7 +339,7 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
}
// get the last character
- if (last != ' ')
+ if (last != ' ')
Data[respos++] = last;
// null terminate the string
@@ -378,7 +369,7 @@ void wSetData(char **Data, const char *Value)
else *Data = "";
}
-void wSetData(WCHAR **Data, const char *Value)
+void wSetData(WCHAR **Data, const char *Value)
{
if (Value[0] != 0)
*Data = mir_a2u(Value);
@@ -386,7 +377,7 @@ void wSetData(WCHAR **Data, const char *Value)
*Data = L"";
}
-void wSetData(WCHAR **Data, const WCHAR *Value)
+void wSetData(WCHAR **Data, const WCHAR *Value)
{
if (Value[0] != 0)
*Data = mir_wstrdup(Value);
@@ -396,14 +387,14 @@ void wSetData(WCHAR **Data, const WCHAR *Value)
// A safer free function that free memory for a string
// Data = the string occuping the data to be freed
-void wfree(char **Data)
+void wfree(char **Data)
{
if (*Data && mir_strlen(*Data) > 0)
mir_free(*Data);
*Data = NULL;
}
-void wfree(WCHAR **Data)
+void wfree(WCHAR **Data)
{
if (*Data && mir_wstrlen(*Data) > 0)
mir_free(*Data);
diff --git a/plugins/Weather/src/weather_http.cpp b/plugins/Weather/src/weather_http.cpp
index 7d6f0e1ff0..89cac41c2f 100644
--- a/plugins/Weather/src/weather_http.cpp
+++ b/plugins/Weather/src/weather_http.cpp
@@ -29,11 +29,9 @@ HANDLE hNetlibUser, hNetlibHttp;
int findHeader(NETLIBHTTPREQUEST *nlhrReply, char *hdr)
{
- int res = -1, i;
- for (i=0; i<nlhrReply->headersCount; i++)
- {
- if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0)
- {
+ int res = -1, i;
+ for (i = 0; i < nlhrReply->headersCount; i++) {
+ if (_stricmp(nlhrReply->headers[i].szName, hdr) == 0) {
res = i;
break;
}
@@ -48,11 +46,11 @@ int findHeader(NETLIBHTTPREQUEST *nlhrReply, char *hdr)
// return value = 0 for success, 1 or HTTP error code for failure
// global var used: szData, szInfo = containing the retrieved data
-int InternetDownloadFile (char *szUrl, char *cookie, char *userAgent, TCHAR **szData)
+int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, TCHAR **szData)
{
if (userAgent == NULL || userAgent[0] == 0)
userAgent = NETLIB_USER_AGENT;
-
+
NETLIBHTTPHEADER headers[5];
headers[0].szName = "User-Agent";
headers[0].szValue = userAgent;
@@ -80,7 +78,7 @@ int InternetDownloadFile (char *szUrl, char *cookie, char *userAgent, TCHAR **sz
// download the page
NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
if (nlhrReply == 0) {
- // if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code
+ // if the data does not downloaded successfully (ie. disconnected), then return 1000 as error code
*szData = (TCHAR*)mir_alloc(512);
// store the error code in szData
mir_tstrcpy(*szData, _T("NetLib error occurred!!"));
@@ -110,7 +108,7 @@ int InternetDownloadFile (char *szUrl, char *cookie, char *userAgent, TCHAR **sz
tmp = *end; *end = 0;
method = strstr(beg, "http-equiv=\"");
- if (method && _strnicmp(method+12, "Content-Type", 12) == 0 && strstr(method, "utf-8")) {
+ if (method && _strnicmp(method + 12, "Content-Type", 12) == 0 && strstr(method, "utf-8")) {
bIsUtf = true;
break;
}
@@ -121,7 +119,7 @@ int InternetDownloadFile (char *szUrl, char *cookie, char *userAgent, TCHAR **sz
TCHAR *retVal = NULL;
if (bIsUtf)
- retVal = mir_utf8decodeT( nlhrReply->pData );
+ retVal = mir_utf8decodeT(nlhrReply->pData);
if (retVal == NULL)
retVal = mir_a2t(nlhrReply->pData);
*szData = retVal;
@@ -138,27 +136,26 @@ int InternetDownloadFile (char *szUrl, char *cookie, char *userAgent, TCHAR **sz
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);
return result;
}
//============ NETLIB INITIALIZATION ============
// initialize netlib support for weather protocol
-void NetlibInit(void)
+void NetlibInit(void)
{
- NETLIBUSER nlu = {0};
+ NETLIBUSER nlu = { 0 };
nlu.cbSize = sizeof(nlu);
- nlu.flags = NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION|NUF_TCHAR;
+ 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)
+void NetlibHttpDisconnect(void)
{
- if (hNetlibHttp)
- {
+ if (hNetlibHttp) {
HANDLE hConn = hNetlibHttp;
hNetlibHttp = NULL;
Netlib_CloseHandle(hConn);
diff --git a/plugins/Weather/src/weather_icons.cpp b/plugins/Weather/src/weather_icons.cpp
index 16d8468cd9..8b69cffcd0 100644
--- a/plugins/Weather/src/weather_icons.cpp
+++ b/plugins/Weather/src/weather_icons.cpp
@@ -51,7 +51,7 @@ HICON LoadIconEx(const char* name, bool big)
HANDLE GetIconHandle(const char* name)
{
- for (int i=0; i < _countof(iconList); i++)
+ for (int i = 0; i < _countof(iconList); i++)
if (mir_strcmp(iconList[i].szName, name) == 0)
return iconList[i].hIcolib;
diff --git a/plugins/Weather/src/weather_info.cpp b/plugins/Weather/src/weather_info.cpp
index 4e865b42aa..590150dc36 100644
--- a/plugins/Weather/src/weather_info.cpp
+++ b/plugins/Weather/src/weather_info.cpp
@@ -30,53 +30,51 @@ regrading the loading of ini contents
//============ INI INFORMATION ============
// List INI Information for all loaded INI files
-void INIInfo(HWND hwndDlg)
+void INIInfo(HWND hwndDlg)
{
- TCHAR str[16];
+ TCHAR str[16];
size_t memused = 0;
-
+
HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
ListView_DeleteAllItems(hIniList);
- LVITEM lvi = {0};
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_TEXT;
lvi.iItem = 0;
- for (WIDATALIST *Item = WIHead;Item != NULL;Item = Item->next)
- {
+ for (WIDATALIST *Item = WIHead; Item != NULL; Item = Item->next) {
// get the data for the ini file
lvi.iSubItem = 0;
lvi.pszText = Item->Data.InternalName;
- ListView_InsertItem(hIniList, &lvi);
+ ListView_InsertItem(hIniList, &lvi);
lvi.iSubItem = 1;
lvi.pszText = Item->Data.Author;
- ListView_SetItem(hIniList, &lvi);
+ ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 2;
lvi.pszText = Item->Data.Version;
- ListView_SetItem(hIniList, &lvi);
+ ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 3;
- switch (Item->Data.InternalVer)
- {
- case 1: lvi.pszText = _T("1.0"); break;
- case 2: lvi.pszText = _T("1.1"); break;
- case 3: lvi.pszText = _T("1.1a"); break;
- case 4: lvi.pszText = _T("1.2"); break;
- case 5: lvi.pszText = _T("1.3"); break;
- case 6: lvi.pszText = _T("1.4"); break;
- case 7: lvi.pszText = _T("1.5"); break;
- default: lvi.pszText = _T(""); break;
+ switch (Item->Data.InternalVer) {
+ case 1: lvi.pszText = _T("1.0"); break;
+ case 2: lvi.pszText = _T("1.1"); break;
+ case 3: lvi.pszText = _T("1.1a"); break;
+ case 4: lvi.pszText = _T("1.2"); break;
+ case 5: lvi.pszText = _T("1.3"); break;
+ case 6: lvi.pszText = _T("1.4"); break;
+ case 7: lvi.pszText = _T("1.5"); break;
+ default: lvi.pszText = _T(""); break;
}
- ListView_SetItem(hIniList, &lvi);
+ ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 4;
lvi.pszText = _ltot(Item->Data.UpdateDataCount, str, 10);
- ListView_SetItem(hIniList, &lvi);
+ ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 5;
lvi.pszText = Item->Data.DisplayName;
- ListView_SetItem(hIniList, &lvi);
+ ListView_SetItem(hIniList, &lvi);
lvi.iSubItem = 6;
lvi.pszText = Item->Data.ShortFileName;
- ListView_SetItem(hIniList, &lvi);
+ ListView_SetItem(hIniList, &lvi);
memused += Item->Data.MemUsed;
@@ -90,8 +88,8 @@ static const struct tag_Columns
{
const TCHAR *name;
unsigned size;
-}
-columns[] =
+}
+columns[] =
{
{ LPGENT("Name"), 70 },
{ LPGENT("Author"), 100 },
@@ -103,36 +101,34 @@ columns[] =
};
-INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
+INT_PTR CALLBACK DlgProcINIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
{
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- {
+ {
HWND hIniList = GetDlgItem(hwndDlg, IDC_INFOLIST);
- LVCOLUMN lvc = {0};
+ LVCOLUMN lvc = { 0 };
lvc.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
lvc.fmt = LVCFMT_LEFT;
- for ( int i=0; i<7; ++i) {
+ for (int i = 0; i < 7; ++i) {
lvc.iSubItem = i;
- lvc.pszText = TranslateTS(columns[i].name);
+ lvc.pszText = TranslateTS(columns[i].name);
lvc.cx = columns[i].size;
- ListView_InsertColumn(hIniList, i, &lvc);
- }
+ ListView_InsertColumn(hIniList, i, &lvc);
+ }
INIInfo(hwndDlg);
- }
+ }
break;
- case WM_DESTROY:
+ case WM_DESTROY:
break;
case WM_COMMAND:
- if ( HIWORD(wParam) == BN_CLICKED &&
- LOWORD(wParam) == IDC_RELOADINI )
- {
+ if (HIWORD(wParam) == BN_CLICKED &&
+ LOWORD(wParam) == IDC_RELOADINI) {
DestroyWIList();
LoadWIData(true);
INIInfo(hwndDlg);
@@ -150,14 +146,12 @@ void GetINIInfo(TCHAR *pszSvc)
TCHAR str2[2048];
WIDATA *sData = GetWIData(pszSvc);
// if the service does not exist among the loaded INI's
- if (sData == NULL)
- {
+ if (sData == NULL) {
mir_sntprintf(str2, _countof(str2), TranslateT("The corresponding INI file for \"%s\" is not found."), pszSvc);
- MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK | MB_ICONINFORMATION);
}
// if exist, get the information
- else
- {
+ else {
mir_sntprintf(str2, _countof(str2), TranslateT("Weather INI information for \"%s\":"), pszSvc);
mir_tstrncat(str2, _T("\n\n"), _countof(str2) - mir_tstrlen(str2));
mir_tstrncat(str2, TranslateT("Name:"), _countof(str2) - mir_tstrlen(str2));
@@ -203,7 +197,7 @@ void GetINIInfo(TCHAR *pszSvc)
mir_tstrncat(str2, sData->Description, _countof(str2) - mir_tstrlen(str2));
// display the message box and quit
- MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL, str2, TranslateT("Weather INI information"), MB_OK | MB_ICONINFORMATION);
}
}
@@ -211,7 +205,7 @@ void GetINIInfo(TCHAR *pszSvc)
// a message box for displaying the list of custom variables
// can be found when click on "More" in text option dialog
-void MoreVarList(void)
+void MoreVarList(void)
{
TCHAR str[10240], tempstr[1024];
@@ -219,16 +213,14 @@ void MoreVarList(void)
_tcsncpy(str, VARS_LIST, _countof(str) - 1);
mir_tstrncat(str, _T("\n\n"), _countof(str) - mir_tstrlen(str));
// loop through all weather services to find custom variables
- for (WIDATALIST *Item = WIHead;Item != NULL;Item = Item->next)
- {
+ for (WIDATALIST *Item = WIHead; Item != NULL; Item = Item->next) {
// loop through all update items in a service
- for (WIDATAITEMLIST *WItem = Item->Data.UpdateData;WItem != NULL;WItem = WItem->Next)
- {
+ for (WIDATAITEMLIST *WItem = Item->Data.UpdateData; WItem != NULL; WItem = WItem->Next) {
// the custom variable is defined as "%[<variable name>]"
// ignore the "hi" item and hidden items
- if ( mir_tstrcmp(WItem->Item.Name, _T("Ignore")) && WItem->Item.Name[0] != '#') {
+ if (mir_tstrcmp(WItem->Item.Name, _T("Ignore")) && WItem->Item.Name[0] != '#') {
mir_sntprintf(tempstr, _countof(tempstr), _T("%c[%s]"), '%', WItem->Item.Name);
- TCHAR* find = _tcsstr(str, tempstr);
+ TCHAR *find = _tcsstr(str, tempstr);
// if the custom variable does not exist in the list, add it to the list
if (find == NULL) {
mir_tstrncat(str, tempstr, _countof(str) - mir_tstrlen(str));
@@ -243,6 +235,6 @@ void MoreVarList(void)
*find = '\0';
// display the list in a message box
- MessageBox(NULL, str, TranslateT("More Variables"), MB_OK|MB_ICONINFORMATION|MB_TOPMOST);
+ MessageBox(NULL, str, TranslateT("More Variables"), MB_OK | MB_ICONINFORMATION | MB_TOPMOST);
}
diff --git a/plugins/Weather/src/weather_ini.cpp b/plugins/Weather/src/weather_ini.cpp
index 946f98cf8f..e69bc56fda 100644
--- a/plugins/Weather/src/weather_ini.cpp
+++ b/plugins/Weather/src/weather_ini.cpp
@@ -33,7 +33,7 @@ HWND hWndSetup;
// add an item into weather service data list
// Data = the service data to be added to the list
-void WIListAdd(WIDATA Data)
+void WIListAdd(WIDATA Data)
{
// create a new datalist item and point to the data
WIDATALIST *newItem = (WIDATALIST*)mir_alloc(sizeof(WIDATALIST));
@@ -51,21 +51,20 @@ void WIListAdd(WIDATA Data)
WIDATA* GetWIData(TCHAR *pszServ)
{
// loop through the list to find matching internal name
- for (WIDATALIST *Item = WIHead;Item != NULL;Item = Item->next)
+ for (WIDATALIST *Item = WIHead; Item != NULL; Item = Item->next)
// if internal name found, return the data
- if ( mir_tstrcmp(Item->Data.InternalName, pszServ) == 0)
+ if (mir_tstrcmp(Item->Data.InternalName, pszServ) == 0)
return &Item->Data;
-
+
// return NULL when no match found
return NULL;
}
// remove all service data from memory
-void DestroyWIList(void)
+void DestroyWIList(void)
{
// free the list one by one
- while (WIHead != NULL)
- {
+ while (WIHead != NULL) {
WIDATALIST *wi = WIHead;
WIHead = wi->next;
FreeWIData(&wi->Data); // free the data struct
@@ -118,18 +117,18 @@ void FreeDataItem(WIDATAITEM *Item)
//============ Condition Icon List ============
// initiate icon assignmet list
-void WICondListInit(WICONDLIST *List)
+void WICondListInit(WICONDLIST *List)
{
List->Tail = NULL;
List->Head = NULL;
}
// add a new update item into the current list
-void WICondListAdd(char *str, WICONDLIST *List)
+void WICondListAdd(char *str, WICONDLIST *List)
{
WICONDITEM *newItem = (WICONDITEM*)mir_alloc(sizeof(WICONDITEM));
wSetData(&newItem->Item, str);
- CharLowerBuff(newItem->Item, (DWORD)mir_tstrlen( newItem->Item ));
+ CharLowerBuff(newItem->Item, (DWORD)mir_tstrlen(newItem->Item));
newItem->Next = NULL;
if (List->Tail == NULL) List->Head = newItem;
else List->Tail->Next = newItem;
@@ -142,9 +141,9 @@ bool IsContainedInCondList(const TCHAR *pszStr, WICONDLIST *List)
// loop through the list to find matching internal name
for (WICONDITEM *Item = List->Head; Item != NULL; Item = Item->Next) {
// if internal name found, return true indicating that the data is found
- if ( _tcsstr(pszStr, Item->Item))
+ if (_tcsstr(pszStr, Item->Item))
return true;
-
+
}
// return false when no match found
return false;
@@ -154,8 +153,7 @@ bool IsContainedInCondList(const TCHAR *pszStr, WICONDLIST *List)
void DestroyCondList(WICONDLIST *List)
{
// free the list one by one
- for (WICONDITEM *temp = List->Head;temp != NULL;temp = List->Head)
- {
+ for (WICONDITEM *temp = List->Head; temp != NULL; temp = List->Head) {
List->Head = temp->Next;
wfree(&temp->Item); // free the data struct
mir_free(temp);
@@ -194,25 +192,24 @@ bool LoadWIData(bool dial)
chop = _tcsrchr(FileName, '\\');
chop[1] = '\0';
mir_tstrncat(FileName, fd.cFileName, _countof(FileName) - mir_tstrlen(FileName));
- if ( mir_tstrcmpi(fd.cFileName, _T("SAMPLE_INI.INI"))) {
+ if (mir_tstrcmpi(fd.cFileName, _T("SAMPLE_INI.INI"))) {
WIDATA Data;
LoadStationData(FileName, fd.cFileName, &Data);
if (Data.Enabled)
WIListAdd(Data);
}
// look through the entire "plugins\weather" directory
- }
- while(FindNextFile(hFind, &fd));
+ } while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
-
+
if (WIHead == NULL) {
// no ini found, display an error message box.
if (dial)
hWndSetup = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SETUP), NULL, DlgProcSetup);
else
- MessageBox(NULL,
- TranslateT("No update data file is found. Please check your Plugins\\Weather directory."),
+ MessageBox(NULL,
+ TranslateT("No update data file is found. Please check your Plugins\\Weather directory."),
TranslateT("Weather Protocol"), MB_OK | MB_ICONERROR);
return false;
}
@@ -235,7 +232,7 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
"FOG",
"SNOW SHOWER",
"SNOW",
- "RAIN SHOWER",
+ "RAIN SHOWER",
"RAIN",
"PARTLY CLOUDY",
"CLOUDY",
@@ -255,25 +252,24 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
TrimString(Line);
// make sure it is a valid weather protocol ini file
- if ( !mir_strcmp(Line, "[Weather 0.3.x Update Data]"))
+ if (!mir_strcmp(Line, "[Weather 0.3.x Update Data]"))
Data->InternalVer = 1;
- else if ( !mir_strcmp(Line, "[Weather 0.3.x Update Data 1.1]"))
+ else if (!mir_strcmp(Line, "[Weather 0.3.x Update Data 1.1]"))
Data->InternalVer = 2;
- else if ( !mir_strcmp(Line, "[Weather 0.3.x Update Data 1.1a]"))
+ else if (!mir_strcmp(Line, "[Weather 0.3.x Update Data 1.1a]"))
Data->InternalVer = 3;
- else if ( !mir_strcmp(Line, "[Weather 0.3.x Update Data 1.2]"))
+ else if (!mir_strcmp(Line, "[Weather 0.3.x Update Data 1.2]"))
Data->InternalVer = 4;
- else if ( !mir_strcmp(Line, "[Weather 0.3.x Update Data 1.3]"))
+ else if (!mir_strcmp(Line, "[Weather 0.3.x Update Data 1.3]"))
Data->InternalVer = 5;
- else if ( !mir_strcmp(Line, "[Weather 0.3.x Update Data 1.4]"))
+ else if (!mir_strcmp(Line, "[Weather 0.3.x Update Data 1.4]"))
Data->InternalVer = 6;
- else if ( !mir_strcmp(Line, "[Weather 0.3.x Update Data 1.5]"))
+ else if (!mir_strcmp(Line, "[Weather 0.3.x Update Data 1.5]"))
Data->InternalVer = 7;
- else
- {
+ else {
TCHAR str[4096];
mir_sntprintf(str, _countof(str), TranslateT("Invalid ini format for: %s"), pszFile);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONERROR);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONERROR);
fclose(pfile);
return;
}
@@ -325,13 +321,13 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
// initialize the linked list for update items
Data->UpdateDataCount = 0;
- Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + (mir_tstrlen(pszShortFile) + mir_tstrlen(pszFile) + 20)*sizeof( TCHAR );
+ Data->MemUsed = sizeof(WIDATA) + sizeof(WIDATALIST) + (mir_tstrlen(pszShortFile) + mir_tstrlen(pszFile) + 20)*sizeof(TCHAR);
Data->UpdateData = NULL;
Data->UpdateDataTail = NULL;
// initialize the icon assignment list
- for (int i=0; i<10; i++)
- WICondListInit( &Data->CondList[i] );
+ for (int i = 0; i < 10; i++)
+ WICondListInit(&Data->CondList[i]);
while (!feof(pfile)) {
// determine current tag
@@ -342,24 +338,23 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
// if the line is a group header/footer
if (Line[0] == '[') {
- char *chop = strchr(Line+1,']');
+ char *chop = strchr(Line + 1, ']');
if (chop == NULL)
continue;
-
- if (Line[1] != '/') { // if it is not a footer (for old ini)
+
+ if (Line[1] != '/') { // if it is not a footer (for old ini)
// save the group name
- Temp = (char *)mir_alloc(mir_strlen(Line)+10);
- strncpy(Temp, Line+1, chop-Line-1);
- Temp[chop-Line-1] = 0;
+ Temp = (char *)mir_alloc(mir_strlen(Line) + 10);
+ strncpy(Temp, Line + 1, chop - Line - 1);
+ Temp[chop - Line - 1] = 0;
wfree(&Group);
wSetData(&Group, Temp);
// see if it is a update item, if it is, add a new item to the linked list
// if (_stricmp(Group, "HEADER") && _stricmp(Group, "DEFAULT") && _stricmp(Group, "ID SEARCH") &&
// strcmpi(Group, "NAME SEARCH"))
// wSetData(&DataItem.Name, Group);
- if (_stricmp(Group, "HEADER") && _stricmp(Group, "DEFAULT") && _stricmp(Group, "ID SEARCH") &&
- _stricmp(Group, "NAME SEARCH") && _stricmp(Group, "ICONS"))
- {
+ if (_stricmp(Group, "HEADER") && _stricmp(Group, "DEFAULT") && _stricmp(Group, "ID SEARCH") &&
+ _stricmp(Group, "NAME SEARCH") && _stricmp(Group, "ICONS")) {
wSetData(&DataItem.Name, Temp);
DataItem.Type = WID_NORMAL;
WIItemListAdd(&DataItem, Data);
@@ -367,8 +362,7 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
}
mir_free(Temp);
}
- else
- {
+ else {
wfree(&Group);
wSetData(&Group, "");
}
@@ -378,91 +372,91 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
if (Value == NULL) continue;
// get the string before '=' (ValName) and after '=' (Value)
- ValName = (char *)mir_alloc(mir_strlen(Line)+1);
- strncpy(ValName, Line, Value-Line);
- ValName[Value-Line] = 0;
+ ValName = (char *)mir_alloc(mir_strlen(Line) + 1);
+ strncpy(ValName, Line, Value - Line);
+ ValName[Value - Line] = 0;
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(ValName, "USERAGENT")) wSetData(&Data->UserAgent, 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(ValName, "USERAGENT")) wSetData(&Data->UserAgent, 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")) {
- for (int i=0; i<10; i++) {
- if ( !_stricmp(ValName, statusStr[i])) {
+ else if (!_stricmp(Group, "ICONS")) {
+ for (int i = 0; i < 10; i++) {
+ if (!_stricmp(ValName, statusStr[i])) {
WICondListAdd(Value, &Data->CondList[i]);
break;
}
}
}
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 = mir_tstrlen(nm) + 1;
- Data->UpdateDataTail->Item.Name = nm = ( TCHAR* )mir_realloc(nm, sizeof(TCHAR)*(len + 3));
- memmove(nm + 1, nm, len*sizeof( TCHAR ));
+ Data->UpdateDataTail->Item.Name = nm = (TCHAR*)mir_realloc(nm, sizeof(TCHAR)*(len + 3));
+ memmove(nm + 1, nm, len*sizeof(TCHAR));
*nm = '#';
}
}
- else if ( !_stricmp(ValName, "SET DATA")) {
+ else if (!_stricmp(ValName, "SET DATA")) {
Data->UpdateDataTail->Item.Type = WID_SET;
wSetData(&Data->UpdateDataTail->Item.End, Value);
}
- else if ( !_stricmp(ValName, "BREAK DATA")) {
+ else if (!_stricmp(ValName, "BREAK DATA")) {
Data->UpdateDataTail->Item.Type = WID_BREAK;
wSetData(&Data->UpdateDataTail->Item.Break, Value);
}
@@ -483,12 +477,11 @@ void LoadStationData(TCHAR *pszFile, TCHAR *pszShortFile, WIDATA *Data)
// free the WIDATA struct from memory
// Data = the struct to be freed
-void FreeWIData(WIDATA *Data)
+void FreeWIData(WIDATA *Data)
{
// free update items linked list first
WIDATAITEMLIST *WItem = Data->UpdateData;
- while (WItem != NULL)
- {
+ while (WItem != NULL) {
Data->UpdateData = WItem->Next;
FreeDataItem(&WItem->Item);
mir_free(WItem);
@@ -523,27 +516,26 @@ void FreeWIData(WIDATA *Data)
FreeDataItem(&Data->NameSearch.Multiple.ID);
wfree(&Data->ShortFileName);
wfree(&Data->FileName);
- for (int i=0; i<10; i++)
+ for (int i = 0; i < 10; i++)
DestroyCondList(&Data->CondList[i]);
}
//============ WEATHER INI SETUP DIALOG ============
-INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
// make the buttons flat
- SendDlgItemMessage(hwndDlg,IDC_STEP1, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg,IDC_STEP2, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg,IDC_STEP3, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg,IDC_STEP4, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_STEP1, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_STEP2, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_STEP3, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_STEP4, BUTTONSETASFLATBTN, TRUE, 0);
// set icons
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx("main", TRUE));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx("main", TRUE));
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx("main", FALSE));
WindowList_Add(hWindowList, hwndDlg, NULL);
@@ -551,13 +543,13 @@ INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_STEP1:
// update current data
Utils_OpenUrl("http://miranda-ng.org/");
break;
- case IDC_STEP2:
+ case IDC_STEP2:
{
TCHAR szPath[1024];
GetModuleFileName(GetModuleHandle(NULL), szPath, _countof(szPath));
@@ -573,9 +565,9 @@ INT_PTR CALLBACK DlgProcSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
case IDC_STEP3:
if (LoadWIData(false))
- MessageBox(NULL,
- TranslateT("All update data has been reloaded."),
- TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
+ MessageBox(NULL,
+ TranslateT("All update data has been reloaded."),
+ TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
break;
case IDC_STEP4:
diff --git a/plugins/Weather/src/weather_opt.cpp b/plugins/Weather/src/weather_opt.cpp
index d6181671ec..4733e8cb1d 100644
--- a/plugins/Weather/src/weather_opt.cpp
+++ b/plugins/Weather/src/weather_opt.cpp
@@ -119,7 +119,7 @@ void LoadOptions(void)
opt.DoNotAppendUnit = db_get_b(NULL, WEATHERPROTONAME, "DoNotAppendUnit", 0);
opt.NoFrac = db_get_b(NULL, WEATHERPROTONAME, "NoFractions", 0);
-
+
// texts
if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "DisplayText"))
wSetData(&opt.cText, TranslateTS(szValue));
@@ -321,34 +321,34 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
// load units
switch (opt.tUnit) { // temperature
- case 1: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T1); break;
- case 2: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T2); break;
+ case 1: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T1); break;
+ case 2: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T2); break;
}
switch (opt.wUnit) { // wind
- case 1: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W1); break;
- case 2: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W2); break;
- case 3: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W3); break;
- case 4: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W4); break;
+ case 1: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W1); break;
+ case 2: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W2); break;
+ case 3: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W3); break;
+ case 4: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W4); break;
}
switch (opt.vUnit) { // visibility
- case 1: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V1); break;
- case 2: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V2); break;
+ case 1: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V1); break;
+ case 2: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V2); break;
}
switch (opt.pUnit) { // pressure
- case 1: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P1); break;
- case 2: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P2); break;
- case 3: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P3); break;
- case 4: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P4); break;
+ case 1: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P1); break;
+ case 2: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P2); break;
+ case 3: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P3); break;
+ case 4: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P4); break;
}
switch (opt.dUnit) { // pressure
- case 1: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D1); break;
- case 2: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D2); break;
- case 3: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D3); break;
+ case 1: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D1); break;
+ case 2: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D2); break;
+ case 3: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D3); break;
}
switch (opt.eUnit) { // elev
- case 1: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E1); break;
- case 2: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E2); break;
+ case 1: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E1); break;
+ case 2: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E2); break;
}
opt_startup = FALSE;
@@ -356,10 +356,10 @@ 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 (!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:
@@ -527,13 +527,13 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
TranslateMenu(hMenu1);
switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) {
case ID_MPREVIEW:
- {
- // show the preview in a message box, using the weather data from the default station
- WEATHERINFO winfo = LoadWeatherInfo(opt.DefStn);
- GetDisplay(&winfo, *var[LOWORD(wParam) - IDC_TM1], str);
- MessageBox(NULL, str, TranslateT("Weather Protocol Text Preview"), MB_OK | MB_TOPMOST);
- break;
- }
+ {
+ // show the preview in a message box, using the weather data from the default station
+ WEATHERINFO winfo = LoadWeatherInfo(opt.DefStn);
+ GetDisplay(&winfo, *var[LOWORD(wParam) - IDC_TM1], str);
+ MessageBox(NULL, str, TranslateT("Weather Protocol Text Preview"), MB_OK | MB_TOPMOST);
+ break;
+ }
case ID_MRESET:
unsigned varo = LOWORD(wParam) - IDC_TM1;
// remove the old setting from db and free memory
diff --git a/plugins/Weather/src/weather_popup.cpp b/plugins/Weather/src/weather_popup.cpp
index 31934095cc..4835761da6 100644
--- a/plugins/Weather/src/weather_popup.cpp
+++ b/plugins/Weather/src/weather_popup.cpp
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* This file contain the source related to weather popups, including popup
- options, popup display, and the code for popup process.
+ options, popup display, and the code for popup process.
*/
#include "stdafx.h"
@@ -32,12 +32,11 @@ static HANDLE hPopupContact;
// display weather popups
// wParam = the contact to display popup
// lParam = whether the weather data is changed or not
-int WeatherPopup(WPARAM hContact, LPARAM lParam)
+int WeatherPopup(WPARAM hContact, LPARAM lParam)
{
// determine if the popup should display or not
if (opt.UsePopup && opt.UpdatePopup && (!opt.PopupOnChange || (BOOL)lParam) &&
- !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0))
- {
+ !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0)) {
WEATHERINFO winfo = LoadWeatherInfo(hContact);
// setup the popup
@@ -47,10 +46,10 @@ int WeatherPopup(WPARAM hContact, LPARAM lParam)
GetDisplay(&winfo, opt.pTitle, ppd.lptzContactName);
GetDisplay(&winfo, opt.pText, ppd.lptzText);
ppd.PluginWindowProc = PopupDlgProc;
- ppd.colorBack = (opt.UseWinColors)?GetSysColor(COLOR_BTNFACE):opt.BGColour;
- ppd.colorText = (opt.UseWinColors)?GetSysColor(COLOR_WINDOWTEXT):opt.TextColour;
+ ppd.colorBack = (opt.UseWinColors) ? GetSysColor(COLOR_BTNFACE) : opt.BGColour;
+ ppd.colorText = (opt.UseWinColors) ? GetSysColor(COLOR_WINDOWTEXT) : opt.TextColour;
ppd.iSeconds = opt.pDelay;
- PUAddPopupT( &ppd );
+ PUAddPopupT(&ppd);
}
return 0;
}
@@ -62,20 +61,19 @@ int WeatherPopup(WPARAM hContact, LPARAM lParam)
// lParam = display type
// Type can either be SM_WARNING, SM_NOTIFY, or SM_WEATHERALERT
-int WeatherError(WPARAM wParam, LPARAM lParam)
+int WeatherError(WPARAM wParam, LPARAM lParam)
{
- if ( !opt.UsePopup)
+ if (!opt.UsePopup)
return 0;
- TCHAR* tszMsg = ( TCHAR* )wParam;
+ TCHAR* tszMsg = (TCHAR*)wParam;
if ((DWORD)lParam == SM_WARNING)
- PUShowMessageT( tszMsg, SM_WARNING );
+ PUShowMessageT(tszMsg, SM_WARNING);
else if ((DWORD)lParam == SM_NOTIFY)
- PUShowMessageT( tszMsg, SM_NOTIFY);
- else if ((DWORD)lParam == SM_WEATHERALERT)
- {
- POPUPDATAT ppd = {0};
+ PUShowMessageT(tszMsg, SM_NOTIFY);
+ else if ((DWORD)lParam == SM_WEATHERALERT) {
+ POPUPDATAT ppd = { 0 };
TCHAR str1[512], str2[512];
// get the 2 strings
@@ -88,19 +86,19 @@ int WeatherError(WPARAM wParam, LPARAM lParam)
str1[0] = 0;
chop = _tcschr(str2, 255);
if (chop != NULL)
- _tcsncpy(str2, chop+1, _countof(str2) - 1);
+ _tcsncpy(str2, chop + 1, _countof(str2) - 1);
else
str2[0] = 0;
// setup the popup
- ppd.lchIcon = (HICON)LoadImage(NULL, MAKEINTRESOURCE(OIC_BANG), IMAGE_ICON,
+ ppd.lchIcon = (HICON)LoadImage(NULL, MAKEINTRESOURCE(OIC_BANG), IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
mir_tstrcpy(ppd.lptzContactName, str1);
mir_tstrcpy(ppd.lptzText, str2);
- ppd.colorBack = (opt.UseWinColors)?GetSysColor(COLOR_BTNFACE):opt.BGColour;
- ppd.colorText = (opt.UseWinColors)?GetSysColor(COLOR_WINDOWTEXT):opt.TextColour;
+ ppd.colorBack = (opt.UseWinColors) ? GetSysColor(COLOR_BTNFACE) : opt.BGColour;
+ ppd.colorText = (opt.UseWinColors) ? GetSysColor(COLOR_WINDOWTEXT) : opt.TextColour;
ppd.iSeconds = opt.pDelay;
- PUAddPopupT( &ppd );
+ PUAddPopupT(&ppd);
}
return 0;
}
@@ -121,13 +119,13 @@ int WPShowMessage(TCHAR* lpzText, WORD kind)
// popup dialog pocess
// for selecting actions when click on the popup window
// use for displaying contact menu
-LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
DWORD ID = 0;
MCONTACT hContact;
hContact = PUGetContact(hWnd);
- switch(message) {
+ switch (message) {
case WM_COMMAND:
ID = opt.LeftClickAction;
if (ID != IDM_M7) PUDeletePopup(hWnd);
@@ -150,7 +148,7 @@ LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
// process for the popup window
// containing the code for popup actions
-LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
POINT pt;
HMENU hMenu;
@@ -179,7 +177,7 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
hMenu = Menu_BuildContactMenu(wParam);
GetCursorPos(&pt);
hPopupContact = (HANDLE)wParam;
- TrackPopupMenu(hMenu,TPM_LEFTALIGN,pt.x,pt.y,0,hWnd,NULL);
+ TrackPopupMenu(hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL);
DestroyMenu(hMenu);
break;
@@ -204,22 +202,22 @@ LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
//============ POPUP OPTIONS ============
// used to select the menu item for popup action menu
-static void SelectMenuItem(HMENU hMenu, int Check)
+static void SelectMenuItem(HMENU hMenu, int Check)
{
- for (int i=0; i <= GetMenuItemCount(hMenu)-1; i++)
- CheckMenuItem(hMenu, i, MF_BYPOSITION|((int)GetMenuItemID(hMenu, i) == Check)*8);
+ for (int i = 0; i <= GetMenuItemCount(hMenu) - 1; i++)
+ CheckMenuItem(hMenu, i, MF_BYPOSITION | ((int)GetMenuItemID(hMenu, i) == Check) * 8);
}
// temporary read the current option to memory
// but does not write to the database
-void ReadPopupOpt(HWND hdlg)
+void ReadPopupOpt(HWND hdlg)
{
TCHAR text[MAX_TEXT_SIZE];
TCHAR str[512];
// popup colour
- opt.TextColour = SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_GETCOLOUR,0,0);
- opt.BGColour = SendDlgItemMessage(hdlg,IDC_BGCOLOUR,CPM_GETCOLOUR,0,0);
+ opt.TextColour = SendDlgItemMessage(hdlg, IDC_TEXTCOLOUR, CPM_GETCOLOUR, 0, 0);
+ opt.BGColour = SendDlgItemMessage(hdlg, IDC_BGCOLOUR, CPM_GETCOLOUR, 0, 0);
// get delay time
GetDlgItemText(hdlg, IDC_DELAY, str, _countof(str));
@@ -244,7 +242,7 @@ void ReadPopupOpt(HWND hdlg)
}
// copied and modified from NewStatusNotify
-INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int ID;
TCHAR str[512];
@@ -259,7 +257,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
SaveOptions();
// click actions
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
GetMenuString(hMenu1, opt.LeftClickAction, str, _countof(str), MF_BYCOMMAND);
SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
@@ -273,11 +271,11 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings ? BST_CHECKED : BST_UNCHECKED);
- SetDlgItemText(hdlg,IDC_PText, opt.pText);
- SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
+ SetDlgItemText(hdlg, IDC_PText, opt.pText);
+ SetDlgItemText(hdlg, IDC_PTitle, opt.pTitle);
// setting popup delay option
_ltot(opt.pDelay, str, 10);
- SetDlgItemText(hdlg,IDC_DELAY, str);
+ SetDlgItemText(hdlg, IDC_DELAY, str);
if (opt.pDelay == -1)
CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
else if (opt.pDelay == 0)
@@ -303,12 +301,12 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_COMMAND:
// 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) &&
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ if (!((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) &&
(HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())))
- SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ 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.
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_BGCOLOUR: //Fall through
case IDC_TEXTCOLOUR:
// select new colors
@@ -331,17 +329,18 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_RightClick:
// right click action selection menu
button = GetDlgItem(hdlg, IDC_RightClick);
- GetWindowRect(button, &pos);
+ GetWindowRect(button, &pos);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
TranslateMenu(hMenu1);
SelectMenuItem(hMenu1, opt.RightClickAction);
- ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
- if (ID) opt.RightClickAction = ID;
+ ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
+ if (ID)
+ opt.RightClickAction = ID;
DestroyMenu(hMenu);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
@@ -351,17 +350,17 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_LeftClick:
// left click action selection menu
button = GetDlgItem(hdlg, IDC_LeftClick);
- GetWindowRect(button, &pos);
+ GetWindowRect(button, &pos);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
TranslateMenu(hMenu1);
SelectMenuItem(hMenu1, opt.LeftClickAction);
- ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
+ ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
if (ID) opt.LeftClickAction = ID;
DestroyMenu(hMenu);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
hMenu1 = GetSubMenu(hMenu, 0);
GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
@@ -388,19 +387,19 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_PDEF:
// set the default value for popup texts
SetTextDefault("Pp");
- SetDlgItemText(hdlg,IDC_PText, opt.pText);
- SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
+ SetDlgItemText(hdlg, IDC_PText, opt.pText);
+ SetDlgItemText(hdlg, IDC_PTitle, opt.pTitle);
wfree(&opt.pText);
wfree(&opt.pTitle);
break;
case IDC_VAR3:
// display variable list
- _tcsncpy(str, _T(" \n"),_countof(str) - 1); // to make the message box wider
+ _tcsncpy(str, _T(" \n"), _countof(str) - 1); // to make the message box wider
mir_tstrncat(str, VAR_LIST_POPUP, _countof(str) - mir_tstrlen(str));
mir_tstrncat(str, _T("\n"), _countof(str) - mir_tstrlen(str));
mir_tstrncat(str, CUSTOM_VARS, _countof(str) - mir_tstrlen(str));
- MessageBox(NULL, str, TranslateT("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
+ MessageBox(NULL, str, TranslateT("Variable List"), MB_OK | MB_ICONASTERISK | MB_TOPMOST);
break;
case IDC_PREVIEW:
@@ -414,17 +413,16 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
break;
-
+
case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY: {
- ReadPopupOpt(hdlg);
-
- // save the options, and update main menu
- SaveOptions();
- UpdatePopupMenu(opt.UsePopup);
- return TRUE;
- }
+ case PSN_APPLY:
+ ReadPopupOpt(hdlg);
+
+ // save the options, and update main menu
+ SaveOptions();
+ UpdatePopupMenu(opt.UsePopup);
+ return TRUE;
}
break;
}
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp
index 78bf4c6a10..a213106160 100644
--- a/plugins/Weather/src/weather_update.cpp
+++ b/plugins/Weather/src/weather_update.cpp
@@ -34,7 +34,7 @@ UPDATELIST *UpdateListTail;
// retrieve weather info and display / log them
// hContact = current contact
-int UpdateWeather(MCONTACT hContact)
+int UpdateWeather(MCONTACT hContact)
{
TCHAR str[256], str2[MAX_TEXT_SIZE];
DBVARIANT dbv;
@@ -152,7 +152,7 @@ int UpdateWeather(MCONTACT hContact)
db_set_b(hContact, WEATHERPROTONAME, "IsUpdated", TRUE);
// save info for default weather condition
- if ( !mir_tstrcmp(winfo.id, opt.Default) && !opt.NoProtoCondition) {
+ if (!mir_tstrcmp(winfo.id, opt.Default) && !opt.NoProtoCondition) {
// save current condition for default station to be displayed after the update
old_status = status;
status = winfo.status;
@@ -168,13 +168,13 @@ int UpdateWeather(MCONTACT hContact)
if (db_get_b(hContact, WEATHERPROTONAME, "File", 0)) {
// external log
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log",&dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "Log", &dbv)) {
// for the option for overwriting the file, delete old file first
- if (db_get_b(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"));
+ FILE *file = _tfopen(dbv.ptszVal, _T("a"));
db_free(&dbv);
if (file != NULL) {
// write data to the file and close
@@ -197,7 +197,7 @@ int UpdateWeather(MCONTACT hContact)
dbei.flags = DBEF_READ | DBEF_UTF;
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.pBlob = szMessage;
- dbei.cbBlob = (DWORD)mir_strlen(szMessage)+1;
+ dbei.cbBlob = (DWORD)mir_strlen(szMessage) + 1;
db_event_add(hContact, &dbei);
}
@@ -223,7 +223,7 @@ int UpdateWeather(MCONTACT hContact)
// a linked list queue for updating weather station
// this function add a weather contact to the end of queue for update
// hContact = current contact
-void UpdateListAdd(MCONTACT hContact)
+void UpdateListAdd(MCONTACT hContact)
{
UPDATELIST *newItem = (UPDATELIST*)mir_alloc(sizeof(UPDATELIST));
newItem->hContact = hContact;
@@ -247,14 +247,14 @@ MCONTACT UpdateGetFirst()
WaitForSingleObject(hUpdateMutex, INFINITE);
if (UpdateListHead != NULL) {
- UPDATELIST* Item = UpdateListHead;
+ UPDATELIST* Item = UpdateListHead;
hContact = Item->hContact;
UpdateListHead = Item->next;
mir_free(Item);
if (UpdateListHead == NULL)
- UpdateListTail = NULL;
+ UpdateListTail = NULL;
}
ReleaseMutex(hUpdateMutex);
@@ -262,7 +262,7 @@ MCONTACT UpdateGetFirst()
return hContact;
}
-void DestroyUpdateList(void)
+void DestroyUpdateList(void)
{
WaitForSingleObject(hUpdateMutex, INFINITE);
@@ -284,11 +284,11 @@ void DestroyUpdateList(void)
// update all weather station
// AutoUpdate = true if it is from automatic update using timer
// false if it is from update by clicking the main menu
-void UpdateAll(BOOL AutoUpdate, BOOL RemoveData)
+void UpdateAll(BOOL AutoUpdate, BOOL RemoveData)
{
// add all weather contact to the update queue list
for (MCONTACT hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME))
- if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate) {
+ if (!db_get_b(hContact, WEATHERPROTONAME, "AutoUpdate", FALSE) || !AutoUpdate) {
if (RemoveData)
DBDataManage((MCONTACT)hContact, WDBM_REMOVE, 0, 0);
UpdateListAdd(hContact);
@@ -296,13 +296,13 @@ 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);
}
// update a single station
// wParam = handle for the weather station that is going to be updated
-INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM)
+INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM)
{
if (IsMyContact(wParam)) {
// add the station to the end of the update queue
@@ -311,7 +311,7 @@ INT_PTR UpdateSingleStation(WPARAM wParam, 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);
}
@@ -320,7 +320,7 @@ INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM)
// update a single station with removing the old data
// wParam = handle for the weather station that is going to be updated
-INT_PTR UpdateSingleRemove(WPARAM wParam, LPARAM)
+INT_PTR UpdateSingleRemove(WPARAM wParam, LPARAM)
{
if (IsMyContact(wParam)) {
// add the station to the end of the update queue, and also remove old data
@@ -329,7 +329,7 @@ INT_PTR UpdateSingleRemove(WPARAM wParam, 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);
}
@@ -338,7 +338,7 @@ INT_PTR UpdateSingleRemove(WPARAM wParam, LPARAM)
// update all weather thread
// this thread update each weather station from the queue
-void UpdateThreadProc(LPVOID)
+void UpdateThreadProc(LPVOID)
{
WaitForSingleObject(hUpdateMutex, INFINITE);
if (ThreadRunning) {
@@ -349,7 +349,7 @@ void UpdateThreadProc(LPVOID)
ReleaseMutex(hUpdateMutex);
// update weather by getting the first station from the queue until the queue is empty
- while (UpdateListHead != NULL && !Miranda_Terminated())
+ while (UpdateListHead != NULL && !Miranda_Terminated())
UpdateWeather(UpdateGetFirst());
NetlibHttpDisconnect();
@@ -378,7 +378,7 @@ INT_PTR UpdateAllRemove(WPARAM, LPARAM)
// getting weather data and save them into the database
// hContact = the contact to get the data
-int GetWeatherData(MCONTACT hContact)
+int GetWeatherData(MCONTACT hContact)
{
// get eacnh part of the id's
TCHAR id[256];
@@ -401,14 +401,14 @@ int GetWeatherData(MCONTACT hContact)
// get the update strings (loaded to memory from ini files)
WIDATA *Data = GetWIData(Svc);
- if (Data == NULL)
+ if (Data == NULL)
return SVC_NOT_FOUND; // the ini for the station cannot be found
WORD cond = NA;
char loc[256];
- for (int i=0; i < 4; ++i) {
+ for (int i = 0; i < 4; ++i) {
// generate update URL
- switch(i) {
+ switch (i) {
case 0:
mir_snprintf(loc, _countof(loc), Data->UpdateURL, _T2A(id));
break;
@@ -439,7 +439,7 @@ int GetWeatherData(MCONTACT hContact)
mir_free(szData);
return retval;
}
- if ( _tcsstr(szData, _T("Document Not Found")) != NULL) {
+ if (_tcsstr(szData, _T("Document Not Found")) != NULL) {
mir_free(szData);
return DOC_NOT_FOUND;
}
@@ -460,11 +460,11 @@ int GetWeatherData(MCONTACT hContact)
// if it is a normal item with start= and end=, then parse through the downloaded string
// to get a data value.
GetDataValue(&Item->Item, DataValue, &szInfo);
- if ( mir_tstrcmp(Item->Item.Name, _T("Condition")) && mir_tstrcmpi(Item->Item.Unit, _T("Cond")))
+ if (mir_tstrcmp(Item->Item.Name, _T("Condition")) && mir_tstrcmpi(Item->Item.Unit, _T("Cond")))
_tcsncpy(DataValue, TranslateTS(DataValue), MAX_DATA_LEN - 1);
break;
- case WID_SET:
+ case WID_SET:
{
// for the "Set Data=" operation
DBVARIANT dbv;
@@ -480,25 +480,25 @@ int GetWeatherData(MCONTACT hContact)
// the end of the string, last item
chop = _tcsstr(str, _T(" & "));
if (chop == NULL)
- chop = _tcschr(str, '\0');
+ chop = _tcschr(str, '\0');
- stl = min(sizeof(str2)-1, (unsigned)(chop-str-2));
- _tcsncpy(str2, str+1, stl);
+ stl = min(sizeof(str2) - 1, (unsigned)(chop - str - 2));
+ _tcsncpy(str2, str + 1, stl);
str2[stl] = 0;
- switch(str[0]) {
+ switch (str[0]) {
case '[': // variable, add the value to the result string
hasvar = TRUE;
- if ( !DBGetData(hContact, _T2A(str2), &dbv)) {
+ if (!DBGetData(hContact, _T2A(str2), &dbv)) {
mir_tstrncat(DataValue, dbv.ptszVal, _countof(DataValue) - mir_tstrlen(DataValue));
- DataValue[_countof(DataValue)-1] = 0;
+ DataValue[_countof(DataValue) - 1] = 0;
db_free(&dbv);
}
break;
case'\"': // constant, add it to the result string
mir_tstrncat(DataValue, TranslateTS(str2), _countof(DataValue) - mir_tstrlen(DataValue));
- DataValue[_countof(DataValue)-1] = 0;
+ DataValue[_countof(DataValue) - 1] = 0;
break;
}
@@ -506,16 +506,16 @@ int GetWeatherData(MCONTACT 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:
+ 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, _countof(DataValue));
- DataValue[_countof(DataValue)-1] = 0;
+ DataValue[_countof(DataValue) - 1] = 0;
db_free(&dbv);
}
else {
@@ -537,23 +537,23 @@ int GetWeatherData(MCONTACT hContact)
ConvertDataValue(&Item->Item, DataValue);
// write the 2 strings created from the break operation
- if (Item->Item.End[0])
+ if (Item->Item.End[0])
db_set_ts(hContact, WEATHERCONDITION, _T2A(Item->Item.End), end);
break;
- } }
+ }
+ }
// don't store data if it is not available
- if ((DataValue[0] != 0 && mir_tstrcmp(DataValue, NODATA) &&
+ if ((DataValue[0] != 0 && mir_tstrcmp(DataValue, NODATA) &&
mir_tstrcmp(DataValue, TranslateTS(NODATA)) && mir_tstrcmp(Item->Item.Name, _T("Ignore"))) ||
- ( !mir_tstrcmp(Item->Item.Name, _T("Alert")) && i == 0))
- {
+ (!mir_tstrcmp(Item->Item.Name, _T("Alert")) && i == 0)) {
// temporary workaround for mToolTip to show feel-like temperature
- if ( !mir_tstrcmp(Item->Item.Name, _T("Feel")))
+ if (!mir_tstrcmp(Item->Item.Name, _T("Feel")))
db_set_ts(hContact, WEATHERCONDITION, "Heat Index", DataValue);
GetStationID(hContact, Svc, _countof(Svc));
- if ( !mir_tstrcmp(Svc, opt.Default))
+ if (!mir_tstrcmp(Svc, opt.Default))
db_set_ts(NULL, DEFCURRENTWEATHER, _T2A(Item->Item.Name), DataValue);
- if ( !mir_tstrcmp(Item->Item.Name, _T("Condition"))) {
+ if (!mir_tstrcmp(Item->Item.Name, _T("Condition"))) {
TCHAR buf[128], *cbuf;
mir_sntprintf(buf, _T("#%s Weather"), DataValue);
cbuf = TranslateTS(buf);
@@ -563,7 +563,7 @@ int GetWeatherData(MCONTACT hContact)
CharLowerBuff(DataValue, (DWORD)mir_tstrlen(DataValue));
cond = GetIcon(DataValue, Data);
}
- else if ( mir_tstrcmpi(Item->Item.Unit, _T("Cond")) == 0) {
+ else if (mir_tstrcmpi(Item->Item.Unit, _T("Cond")) == 0) {
TCHAR buf[128], *cbuf;
mir_sntprintf(buf, _T("#%s Weather"), DataValue);
cbuf = TranslateTS(buf);
@@ -587,24 +587,24 @@ int GetWeatherData(MCONTACT hContact)
//============ UPDATE TIMERS ============
// main auto-update timer
-void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
+void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
{
// only run if it is not current updating and the auto update option is enabled
- if ( !ThreadRunning && opt.CAutoUpdate && !Miranda_Terminated() && (opt.NoProtoCondition || status == ID_STATUS_ONLINE))
+ if (!ThreadRunning && opt.CAutoUpdate && !Miranda_Terminated() && (opt.NoProtoCondition || status == ID_STATUS_ONLINE))
UpdateAll(TRUE, FALSE);
}
// temporary timer for first run
// when this is run, it kill the old startup timer and create the permenant one above
-void CALLBACK timerProc2(HWND, UINT, UINT_PTR, DWORD)
+void CALLBACK timerProc2(HWND, UINT, UINT_PTR, DWORD)
{
KillTimer(NULL, timerId);
ThreadRunning = FALSE;
- if ( Miranda_Terminated())
+ if (Miranda_Terminated())
return;
if (opt.StartupUpdate && opt.NoProtoCondition)
UpdateAll(FALSE, FALSE);
- timerId = SetTimer(NULL, 0, ((int)opt.UpdateTime)*60000, (TIMERPROC)timerProc);
+ timerId = SetTimer(NULL, 0, ((int)opt.UpdateTime) * 60000, (TIMERPROC)timerProc);
}
diff --git a/plugins/Weather/src/weather_userinfo.cpp b/plugins/Weather/src/weather_userinfo.cpp
index ba96ef88c7..96abec033a 100644
--- a/plugins/Weather/src/weather_userinfo.cpp
+++ b/plugins/Weather/src/weather_userinfo.cpp
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/*
+/*
This file contain the source that is related to display contact
information, including the one shows in user detail and the brief
information
@@ -31,7 +31,7 @@ information
// initialize user info
// lParam = current contact
-int UserInfoInit(WPARAM wParam, LPARAM lParam)
+int UserInfoInit(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
@@ -50,7 +50,7 @@ int UserInfoInit(WPARAM wParam, LPARAM lParam)
// register the contact info page
odp.pszTemplate = MAKEINTRESOURCEA(IDD_USERINFO);
odp.pfnDlgProc = DlgProcUIPage;
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
UserInfo_AddPage(wParam, &odp);
}
}
@@ -59,14 +59,14 @@ int UserInfoInit(WPARAM wParam, LPARAM lParam)
// dialog process for the weather tab under user info
// lParam = current contact
-INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
WEATHERINFO w;
TCHAR str[MAX_TEXT_SIZE];
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
- case WM_INITDIALOG:
+ case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_MOREDETAIL, BUTTONSETASFLATBTN, TRUE, 0);
// save the contact handle for later use
@@ -76,14 +76,14 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
w = LoadWeatherInfo(lParam);
SetDlgItemText(hwndDlg, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"), str));
- SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON,
+ SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON,
(WPARAM)Skin_LoadProtoIcon(WEATHERPROTONAME,
- db_get_w(hContact, WEATHERPROTONAME, "StatusIcon",0)), 0);
+ db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", 0)), 0);
{ // bold and enlarge the current condition
LOGFONT lf;
- HFONT hNormalFont = (HFONT)SendDlgItemMessage(hwndDlg,IDC_INFO2,WM_GETFONT,0,0);
- GetObject(hNormalFont,sizeof(lf),&lf);
+ HFONT hNormalFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_GETFONT, 0, 0);
+ GetObject(hNormalFont, sizeof(lf), &lf);
lf.lfWeight = FW_BOLD;
lf.lfWidth = 7;
lf.lfHeight = 15;
@@ -107,14 +107,14 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
SetDlgItemText(hwndDlg, IDC_INFO13, w.vis);
break;
- case WM_DESTROY:
+ case WM_DESTROY:
IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(hwndDlg, IDC_INFOICON, STM_SETICON, 0, 0));
DeleteObject((HFONT)SendDlgItemMessage(hwndDlg, IDC_INFO2, WM_GETFONT, 0, 0));
break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
- case IDC_MOREDETAIL:
+ switch (LOWORD(wParam)) {
+ case IDC_MOREDETAIL:
HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
if (hMoreDataDlg == NULL)
hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL, DlgProcMoreData, hContact);
@@ -155,7 +155,7 @@ static int BriefDlgResizer(HWND, LPARAM, UTILRESIZECONTROL *urc)
// dialog process for more data in the user info window
// lParam = contact handle
-INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static const unsigned tabstops = 48;
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
@@ -166,7 +166,7 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
hContact = lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact);
- SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_AUTOURLDETECT, (WPARAM) TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_AUTOURLDETECT, (WPARAM)TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_SETEVENTMASK, 0, ENM_LINK);
SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_SETMARGINS, EC_LEFTMARGIN, 5);
SendDlgItemMessage(hwndDlg, IDC_MTEXT, EM_SETTABSTOPS, 1, (LPARAM)&tabstops);
@@ -219,7 +219,7 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
RedrawWindow(GetDlgItem(hwndDlg, IDC_HEADERBAR), NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
break;
- case WM_SIZE:
+ case WM_SIZE:
{
RECT rc;
HWND hList = GetDlgItem(hwndDlg, IDC_DATALIST);
@@ -227,10 +227,10 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
ListView_SetColumnWidth(hList, 1, ListView_GetColumnWidth(hList, 1) + (int)LOWORD(lParam) - (rc.right - rc.left));
Utils_ResizeDialog(hwndDlg, hInst, MAKEINTRESOURCEA(IDD_BRIEF), BriefDlgResizer);
- }
+ }
break;
- case WM_GETMINMAXINFO:
+ case WM_GETMINMAXINFO:
{
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
@@ -242,13 +242,13 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
// close the info window
DestroyWindow(hwndDlg);
break;
- case IDC_MUPDATE:
+ case IDC_MUPDATE:
{
HWND hList = GetDlgItem(hwndDlg, IDC_DATALIST);
@@ -273,13 +273,13 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
break;
case IDC_MTOGGLE:
- if (IsWindowVisible(GetDlgItem(hwndDlg,IDC_DATALIST)))
+ if (IsWindowVisible(GetDlgItem(hwndDlg, IDC_DATALIST)))
SetDlgItemText(hwndDlg, IDC_MTOGGLE, TranslateT("More Info"));
else
SetDlgItemText(hwndDlg, IDC_MTOGGLE, TranslateT("Brief Info"));
- ShowWindow(GetDlgItem(hwndDlg,IDC_DATALIST), (int)!IsWindowVisible(
- GetDlgItem(hwndDlg,IDC_DATALIST)));
- ShowWindow(GetDlgItem(hwndDlg,IDC_MTEXT), (int)!IsWindowVisible(GetDlgItem(hwndDlg,IDC_MTEXT)));
+ ShowWindow(GetDlgItem(hwndDlg, IDC_DATALIST), (int)!IsWindowVisible(
+ GetDlgItem(hwndDlg, IDC_DATALIST)));
+ ShowWindow(GetDlgItem(hwndDlg, IDC_MTEXT), (int)!IsWindowVisible(GetDlgItem(hwndDlg, IDC_MTEXT)));
break;
}
break;
@@ -307,7 +307,7 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
DestroyWindow(hwndDlg);
break;
- case WM_DESTROY:
+ case WM_DESTROY:
ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0));
ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0));
@@ -321,7 +321,7 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
// set the title of the dialog and on the which rectangle
// also load brief info into message box
-void LoadBriefInfoText(HWND hwndDlg, MCONTACT hContact)
+void LoadBriefInfoText(HWND hwndDlg, MCONTACT hContact)
{
WEATHERINFO winfo;
TCHAR str[4096];
@@ -329,7 +329,7 @@ void LoadBriefInfoText(HWND hwndDlg, MCONTACT 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)db_get_b(hContact, WEATHERPROTONAME, "IsUpdated", FALSE))
+ if (!(BOOL)db_get_b(hContact, WEATHERPROTONAME, "IsUpdated", FALSE))
_tcsncpy(str, WEATHER_NO_INFO, _countof(str) - 1);
else
// set the display text and show the message box
@@ -343,7 +343,7 @@ void LoadBriefInfoText(HWND hwndDlg, MCONTACT hContact)
// show brief information dialog
// wParam = current contact
-int BriefInfo(WPARAM wParam, LPARAM)
+int BriefInfo(WPARAM wParam, LPARAM)
{
// make sure that the contact is actually a weather one
if (IsMyContact(wParam)) {
@@ -362,7 +362,7 @@ int BriefInfo(WPARAM wParam, LPARAM)
return 0;
}
-INT_PTR BriefInfoSvc(WPARAM wParam, LPARAM lParam)
+INT_PTR BriefInfoSvc(WPARAM wParam, LPARAM lParam)
{
return BriefInfo(wParam, lParam);
}