summaryrefslogtreecommitdiff
path: root/plugins/Weather/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-22 20:30:18 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-22 20:30:18 +0000
commita5f52c9e4d4eb819ede04e55899e5699269e8397 (patch)
tree6f75e65fcfa503a66014729685cee6ce51f5904a /plugins/Weather/src
parentab5cc6ac36ed37b7c44d8d74d6906af17ac5be61 (diff)
- more correct version of settings initialization
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@7830 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Weather/src')
-rw-r--r--plugins/Weather/src/weather.cpp17
-rw-r--r--plugins/Weather/src/weather_data.cpp105
-rw-r--r--plugins/Weather/src/weather_opt.cpp416
-rw-r--r--plugins/Weather/src/weather_update.cpp17
-rw-r--r--plugins/Weather/src/weather_userinfo.cpp71
5 files changed, 283 insertions, 343 deletions
diff --git a/plugins/Weather/src/weather.cpp b/plugins/Weather/src/weather.cpp
index f93dded751..58b6f60f74 100644
--- a/plugins/Weather/src/weather.cpp
+++ b/plugins/Weather/src/weather.cpp
@@ -133,12 +133,7 @@ int WeatherInit(WPARAM wParam,LPARAM lParam)
// weather user detail
HookEvent(ME_USERINFO_INITIALISE, UserInfoInit);
-
HookEvent(ME_TTB_MODULELOADED, OnToolbarLoaded);
-
- hDataWindowList = WindowList_Create();
- hWindowList = WindowList_Create();
-
return 0;
}
@@ -213,13 +208,16 @@ extern "C" int __declspec(dllexport) Load(void)
HookEvent(ME_SYSTEM_PRESHUTDOWN, WeatherShutdown);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, BuildContactMenu);
+ hDataWindowList = WindowList_Create();
+ hWindowList = WindowList_Create();
+
hUpdateMutex = CreateMutex(NULL, FALSE, NULL);
// register weather protocol
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
pd.szName = WEATHERPROTONAME;
pd.type = (opt.NoProtoCondition) ? PROTOTYPE_VIRTUAL : PROTOTYPE_PROTOCOL;
- CallService(MS_PROTO_REGISTERMODULE,0, (LPARAM)&pd);
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
// initialize weather protocol services
InitServices();
@@ -230,10 +228,9 @@ extern "C" int __declspec(dllexport) Load(void)
// window needed for popup commands
TCHAR SvcFunc[100];
- mir_sntprintf( SvcFunc, SIZEOF(SvcFunc), _T("%s__PopupWindow"), _T(WEATHERPROTONAME));
- hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW,_T("static"),SvcFunc,0,CW_USEDEFAULT,CW_USEDEFAULT,
- CW_USEDEFAULT,CW_USEDEFAULT,HWND_DESKTOP,NULL, hInst,NULL);
+ mir_sntprintf(SvcFunc, SIZEOF(SvcFunc), _T("%s__PopupWindow"), _T(WEATHERPROTONAME));
+ hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, _T("static"), SvcFunc, 0, CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hInst, NULL);
SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LONG_PTR)PopupWndProc);
-
return 0;
}
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp
index 78ff5e60b4..4f5aaaa0ad 100644
--- a/plugins/Weather/src/weather_data.cpp
+++ b/plugins/Weather/src/weather_data.cpp
@@ -30,10 +30,10 @@ saving individual weather data for a weather contact.
// hContact = the current contact handle
// return value = the string for station ID
-void GetStationID(HANDLE hContact, TCHAR* id, size_t idlen)
+void GetStationID(HANDLE hContact, TCHAR* id, size_t idlen)
{
// accessing the database
- if ( DBGetStaticString(hContact, WEATHERPROTONAME, "ID", id, idlen))
+ if (DBGetStaticString(hContact, WEATHERPROTONAME, "ID", id, idlen))
id[0] = 0;
}
@@ -49,35 +49,35 @@ WEATHERINFO LoadWeatherInfo(HANDLE hContact)
winfo.hContact = hContact;
GetStationID(hContact, winfo.id, SIZEOF(winfo.id));
- if ( DBGetStaticString(hContact, WEATHERPROTONAME, "Nick", winfo.city, SIZEOF(winfo.city)))
+ if (DBGetStaticString(hContact, WEATHERPROTONAME, "Nick", winfo.city, SIZEOF(winfo.city)))
_tcscpy(winfo.city, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Update", winfo.update, SIZEOF(winfo.update)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Update", winfo.update, SIZEOF(winfo.update)))
_tcscpy(winfo.update, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Condition", winfo.cond, SIZEOF(winfo.cond)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Condition", winfo.cond, SIZEOF(winfo.cond)))
_tcscpy(winfo.cond, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Temperature", winfo.temp, SIZEOF(winfo.temp)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Temperature", winfo.temp, SIZEOF(winfo.temp)))
_tcscpy(winfo.temp, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "High", winfo.high, SIZEOF(winfo.high)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "High", winfo.high, SIZEOF(winfo.high)))
_tcscpy(winfo.high, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Low", winfo.low, SIZEOF(winfo.low)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Low", winfo.low, SIZEOF(winfo.low)))
_tcscpy(winfo.low, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, SIZEOF(winfo.sunset)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, SIZEOF(winfo.sunset)))
_tcscpy(winfo.sunset, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, SIZEOF(winfo.sunrise)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, SIZEOF(winfo.sunrise)))
_tcscpy(winfo.sunrise, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, SIZEOF(winfo.wind)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, SIZEOF(winfo.wind)))
_tcscpy(winfo.wind, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, SIZEOF(winfo.winddir)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, SIZEOF(winfo.winddir)))
_tcscpy(winfo.winddir, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, SIZEOF(winfo.dewpoint)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, SIZEOF(winfo.dewpoint)))
_tcscpy(winfo.dewpoint, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, SIZEOF(winfo.pressure)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, SIZEOF(winfo.pressure)))
_tcscpy(winfo.pressure, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Visibility", winfo.vis, SIZEOF(winfo.vis)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Visibility", winfo.vis, SIZEOF(winfo.vis)))
_tcscpy(winfo.vis, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Humidity", winfo.humid, SIZEOF(winfo.humid)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Humidity", winfo.humid, SIZEOF(winfo.humid)))
_tcscpy(winfo.humid, NODATA);
- if ( DBGetStaticString(hContact, WEATHERCONDITION, "Feel", winfo.feel, SIZEOF(winfo.feel)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Feel", winfo.feel, SIZEOF(winfo.feel)))
_tcscpy(winfo.feel, NODATA);
winfo.status = (WORD)db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE);
@@ -284,6 +284,7 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
szInfo = start;
}
}
+
// the end string must be found too
if (UpdateData->End[0] != 0)
end = _tcsstr(szInfo, UpdateData->End);
@@ -297,14 +298,13 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
end += _tcslen(UpdateData->End);
last = '\n';
}
+
// ignore if not both of the string found - this prevent crashes
- if (start != NULL && end != NULL)
- {
+ if (start != NULL && end != NULL) {
// begin reading the data from start location to end location
// remove all HTML tag in between, as well as leading space, ending space,
// multiple spaces, tabs, and return key
- while (startloc < endloc)
- {
+ while (startloc < endloc) {
if (szInfo[startloc] == '<') tag = TRUE;
else if (szInfo[startloc] == '&' &&
(szInfo[startloc+1] == ';' || szInfo[startloc+2] == ';' || szInfo[startloc+3] == ';' ||
@@ -368,41 +368,38 @@ void GetDataValue(WIDATAITEM *UpdateData, TCHAR *Data, TCHAR** szData)
// copy a string into a new memory location
// Data = the field the data is copied to
// Value = the original string, the string where data is copied from
-void wSetData(char **Data, const char *Value)
+void wSetData(char **Data, const char *Value)
{
- if (Value[0] != 0)
- {
- char *newData = (char*)mir_alloc(strlen(Value)+3);
+ if (Value[0] != 0) {
+ char *newData = (char*)mir_alloc(strlen(Value) + 3);
strcpy(newData, Value);
*Data = newData;
}
- else
- *Data = "";
+ else *Data = "";
}
void wSetData(WCHAR **Data, const char *Value)
{
if (Value[0] != 0)
- *Data = mir_a2u( Value );
+ *Data = mir_a2u(Value);
else
*Data = L"";
}
void wSetData(WCHAR **Data, const WCHAR *Value)
{
- if (Value[0] != 0) {
- WCHAR *newData = (WCHAR*)mir_alloc( sizeof(WCHAR)*(wcslen(Value)+3));
- wcscpy(newData, Value);
- *Data = newData;
- }
- else *Data = L"";
+ if (Value[0] != 0)
+ *Data = mir_wstrdup(Value);
+ else
+ *Data = L"";
}
// A safer free function that free memory for a string
// Data = the string occuping the data to be freed
void wfree(char **Data)
{
- if (*Data && strlen(*Data) > 0) mir_free(*Data);
+ if (*Data && strlen(*Data) > 0)
+ mir_free(*Data);
*Data = NULL;
}
@@ -417,17 +414,17 @@ void wfree(WCHAR **Data)
// get single setting that is found
// szSetting = the setting name
// lparam = the counter
-int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam)
+int GetWeatherDataFromDB(const char *szSetting, LPARAM lparam)
{
LIST<char> *pList = (LIST<char>*)lparam;
- pList->insert( mir_strdup(szSetting));
+ pList->insert(mir_strdup(szSetting));
return 0;
}
// remove or display the weather information for a contact
// hContact - the contact in which the info is going to be removed
-void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam)
+void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam)
{
LIST<char> arSettings(10);
@@ -439,35 +436,33 @@ void DBDataManage(HANDLE hContact, WORD Mode, WPARAM wParam, LPARAM lParam)
CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact, (LPARAM)&dbces);
// begin deleting settings
- for (int i=arSettings.getCount()-1; i >= 0; i--) {
+ for (int i = arSettings.getCount() - 1; i >= 0; i--) {
char *szSetting = arSettings[i];
-
+
DBVARIANT dbv;
- if ( !db_get_ts(hContact, WEATHERCONDITION, szSetting, &dbv)) {
+ if (!db_get_ts(hContact, WEATHERCONDITION, szSetting, &dbv)) {
switch (Mode) {
case WDBM_REMOVE:
db_unset(hContact, WEATHERCONDITION, szSetting);
break;
- case WDBM_DETAILDISPLAY:
+ case WDBM_DETAILDISPLAY:
// skip the "WeatherInfo" variable
- if ( !strcmp(szSetting, "WeatherInfo") || !strcmp(szSetting, "Ignore") || szSetting[0] == '#')
+ if (!strcmp(szSetting, "WeatherInfo") || !strcmp(szSetting, "Ignore") || szSetting[0] == '#')
continue;
- else {
- HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST);
- LV_ITEM lvi = { 0 };
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.lParam = i;
- lvi.pszText = TranslateTS( _A2T(szSetting ));
- lvi.iItem = ListView_InsertItem(hList, &lvi);
- lvi.pszText = dbv.ptszVal;
- ListView_SetItemText(hList, lvi.iItem, 1, dbv.ptszVal );
- break;
- }
+
+ HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST);
+ LV_ITEM lvi = { 0 };
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.lParam = i;
+ lvi.pszText = TranslateTS(_A2T(szSetting));
+ lvi.iItem = ListView_InsertItem(hList, &lvi);
+ lvi.pszText = dbv.ptszVal;
+ ListView_SetItemText(hList, lvi.iItem, 1, dbv.ptszVal);
+ break;
}
db_free(&dbv);
}
mir_free(szSetting);
}
- arSettings.destroy();
}
diff --git a/plugins/Weather/src/weather_opt.cpp b/plugins/Weather/src/weather_opt.cpp
index 558b35175f..1a2158747e 100644
--- a/plugins/Weather/src/weather_opt.cpp
+++ b/plugins/Weather/src/weather_opt.cpp
@@ -31,57 +31,47 @@ int RedrawFrame(WPARAM wParam, LPARAM lParam);
// set a string to default
// in = string to determine which field to set default "CBNEHXPp"
-void SetTextDefault(const char* in)
+void SetTextDefault(const char* in)
{
TCHAR str[MAX_TEXT_SIZE];
- if (strchr(in, 'C') != NULL)
- {
+ if (strchr(in, 'C') != NULL) {
_tcscpy(str, C_DEFAULT);
wSetData(&opt.cText, str);
}
- if (strchr(in, 'b') != NULL)
- {
+ if (strchr(in, 'b') != NULL) {
_tcscpy(str, b_DEFAULT);
wSetData(&opt.bTitle, str);
}
- if (strchr(in, 'B') != NULL)
- {
+ if (strchr(in, 'B') != NULL) {
_tcscpy(str, B_DEFAULT);
wSetData(&opt.bText, str);
}
- if (strchr(in, 'N') != NULL)
- {
+ if (strchr(in, 'N') != NULL) {
_tcscpy(str, N_DEFAULT);
wSetData(&opt.nText, str);
}
- if (strchr(in, 'E') != NULL)
- {
+ if (strchr(in, 'E') != NULL) {
_tcscpy(str, E_DEFAULT);
wSetData(&opt.eText, str);
}
- if (strchr(in, 'H') != NULL)
- {
+ if (strchr(in, 'H') != NULL) {
_tcscpy(str, H_DEFAULT);
wSetData(&opt.hText, str);
}
- if (strchr(in, 'X') != NULL)
- {
+ if (strchr(in, 'X') != NULL) {
_tcscpy(str, X_DEFAULT);
wSetData(&opt.xText, str);
}
- if (strchr(in, 'P') != NULL)
- {
+ if (strchr(in, 'P') != NULL) {
_tcscpy(str, P_DEFAULT);
wSetData(&opt.pTitle, str);
}
- if (strchr(in, 'p') != NULL)
- {
+ if (strchr(in, 'p') != NULL) {
_tcscpy(str, p_DEFAULT);
wSetData(&opt.pText, str);
}
- if (strchr(in, 'S') != NULL)
- {
+ if (strchr(in, 'S') != NULL) {
_tcscpy(str, s_DEFAULT);
wSetData(&opt.sText, str);
}
@@ -102,7 +92,7 @@ void DestroyOptions(void)
}
// load options from database + set default if the setting does not exist
-void LoadOptions(void)
+void LoadOptions(void)
{
ZeroMemory(&opt, sizeof(opt));
@@ -115,7 +105,7 @@ void LoadOptions(void)
opt.RemoveOldData = db_get_b(NULL, WEATHERPROTONAME, "RemoveOld", false);
opt.MakeItalic = db_get_b(NULL, WEATHERPROTONAME, "MakeItalic", true);
opt.AvatarSize = db_get_b(NULL, WEATHERPROTONAME, "AvatarSize", 128);
-
+
// units
opt.tUnit = db_get_w(NULL, WEATHERPROTONAME, "tUnit", 1);
opt.wUnit = db_get_w(NULL, WEATHERPROTONAME, "wUnit", 2);
@@ -124,63 +114,52 @@ void LoadOptions(void)
opt.dUnit = db_get_w(NULL, WEATHERPROTONAME, "dUnit", 1);
opt.eUnit = db_get_w(NULL, WEATHERPROTONAME, "eUnit", 2);
- DBVARIANT dbv;
- if (db_get_ts(NULL, WEATHERPROTONAME, "DegreeSign",&dbv))
- _tcscpy(opt.DegreeSign, _T(""));
- else {
- _tcscpy(opt.DegreeSign, dbv.ptszVal);
- db_free(&dbv);
- }
+ ptrT szValue(db_get_tsa(NULL, WEATHERPROTONAME, "DegreeSign"));
+ _tcsncpy_s(opt.DegreeSign, SIZEOF(opt.DegreeSign), (szValue == NULL) ? _T("") : szValue, _TRUNCATE);
+
opt.DoNotAppendUnit = db_get_b(NULL, WEATHERPROTONAME, "DoNotAppendUnit", 0);
opt.NoFrac = db_get_b(NULL, WEATHERPROTONAME, "NoFractions", 0);
+
// texts
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "DisplayText", &dbv)) {
- wSetData(&opt.cText, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("C");
-
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "BriefTextTitle", &dbv)) {
- wSetData(&opt.bTitle, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("b");
-
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "BriefText", &dbv)) {
- wSetData(&opt.bText, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("B");
-
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "NoteText", &dbv)) {
- wSetData(&opt.nText, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("N");
-
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "ExtText", &dbv)) {
- wSetData(&opt.eText, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("E");
-
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "HistoryText", &dbv)) {
- wSetData(&opt.hText, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("H");
-
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "ExtraText", &dbv)) {
- wSetData(&opt.xText, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("X");
-
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "StatusText", &dbv)) {
- wSetData(&opt.sText, TranslateTS(dbv.ptszVal));
- db_free(&dbv);
- }
- else SetTextDefault("S");
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "DisplayText"))
+ wSetData(&opt.cText, TranslateTS(szValue));
+ else
+ SetTextDefault("C");
+
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "BriefTextTitle"))
+ wSetData(&opt.bTitle, TranslateTS(szValue));
+ else
+ SetTextDefault("b");
+
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "BriefText"))
+ wSetData(&opt.bText, TranslateTS(szValue));
+ else
+ SetTextDefault("B");
+
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "NoteText"))
+ wSetData(&opt.nText, TranslateTS(szValue));
+ else
+ SetTextDefault("N");
+
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "ExtText"))
+ wSetData(&opt.eText, TranslateTS(szValue));
+ else
+ SetTextDefault("E");
+
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "HistoryText"))
+ wSetData(&opt.hText, TranslateTS(szValue));
+ else
+ SetTextDefault("H");
+
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "ExtraText"))
+ wSetData(&opt.xText, TranslateTS(szValue));
+ else
+ SetTextDefault("X");
+
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "StatusText"))
+ wSetData(&opt.sText, TranslateTS(szValue));
+ else
+ SetTextDefault("S");
// advanced
opt.DisCondIcon = db_get_b(NULL, WEATHERPROTONAME, "DisableConditionIcon", false);
@@ -200,28 +179,25 @@ void LoadOptions(void)
// popup delay
opt.pDelay = db_get_dw(NULL, WEATHERPROTONAME, "PopupDelay", 0);
// popup texts
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "PopupTitle",&dbv)) {
- wSetData(&opt.pTitle, dbv.ptszVal);
- db_free(&dbv);
- }
- else SetTextDefault("P");
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "PopupTitle"))
+ wSetData(&opt.pTitle, szValue);
+ else
+ SetTextDefault("P");
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "PopupText",&dbv)) {
- wSetData(&opt.pText, dbv.ptszVal);
- db_free(&dbv);
- }
- else SetTextDefault("p");
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "PopupText"))
+ wSetData(&opt.pText, szValue);
+ else
+ SetTextDefault("p");
// misc
- if ( !db_get_ts(NULL, WEATHERPROTONAME, "Default",&dbv)) {
- _tcscpy(opt.Default, dbv.ptszVal);
- db_free(&dbv);
- }
- else opt.Default[0] = 0;
+ if (szValue = db_get_tsa(NULL, WEATHERPROTONAME, "Default"))
+ _tcsncpy_s(opt.Default, SIZEOF(opt.Default), szValue, _TRUNCATE);
+ else
+ opt.Default[0] = 0;
}
// save the options to database
-void SaveOptions(void)
+void SaveOptions(void)
{
// main options
db_set_b(NULL, WEATHERPROTONAME, "StartupUpdate", (BYTE)opt.StartupUpdate);
@@ -278,35 +254,35 @@ void SaveOptions(void)
//============ OPTION INITIALIZATION ============
// register the weather option pages
-int OptInit(WPARAM wParam,LPARAM lParam)
+int OptInit(WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = hInst;
// plugin options
- odp.position = 95600;
+ odp.position = 95600;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
- odp.pfnDlgProc = OptionsProc;
- odp.ptszGroup = LPGENT("Network");
- odp.ptszTitle = _T(WEATHERPROTOTEXT);
- odp.ptszTab = LPGENT("General");
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.pfnDlgProc = OptionsProc;
+ odp.ptszGroup = LPGENT("Network");
+ odp.ptszTitle = _T(WEATHERPROTOTEXT);
+ odp.ptszTab = LPGENT("General");
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
Options_AddPage(wParam, &odp);
// text options
odp.pszTemplate = MAKEINTRESOURCEA(IDD_TEXTOPT);
- odp.pfnDlgProc = DlgProcText;
- odp.ptszTab = LPGENT("Display");
+ odp.pfnDlgProc = DlgProcText;
+ odp.ptszTab = LPGENT("Display");
Options_AddPage(wParam, &odp);
// if popup service exists, load the weather popup options
- if (( ServiceExists(MS_POPUP_ADDPOPUPT))) {
- odp.position = 100000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP);
- odp.ptszGroup = LPGENT("Popups");
+ if ((ServiceExists(MS_POPUP_ADDPOPUPT))) {
+ odp.position = 100000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP);
+ odp.ptszGroup = LPGENT("Popups");
odp.groupPosition = 910000000;
- odp.ptszTab = NULL;
- odp.pfnDlgProc = DlgPopupOpts;
+ odp.ptszTab = NULL;
+ odp.pfnDlgProc = DlgPopupOpts;
Options_AddPage(wParam, &odp);
}
@@ -316,11 +292,11 @@ int OptInit(WPARAM wParam,LPARAM lParam)
//============ MAIN OPTIONS ============
// weather options
-INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
+INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
TCHAR str[512];
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
opt_startup = TRUE;
TranslateDialogDefault(hdlg);
@@ -333,61 +309,61 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETPOS, 0, opt.AvatarSize);
SendDlgItemMessage(hdlg, IDC_AVATARSIZE, EM_LIMITTEXT, 3, 0);
- CheckDlgButton(hdlg, IDC_STARTUPUPD, opt.StartupUpdate);
- CheckDlgButton(hdlg, IDC_UPDATE, opt.AutoUpdate);
- CheckDlgButton(hdlg, IDC_PROTOCOND, !opt.NoProtoCondition);
- CheckDlgButton(hdlg, IDC_UPDCONDCHG, opt.UpdateOnlyConditionChanged);
- CheckDlgButton(hdlg, IDC_REMOVEOLD, opt.RemoveOldData);
- CheckDlgButton(hdlg, IDC_MAKEI, opt.MakeItalic);
- CheckDlgButton(hdlg, IDC_DISCONDICON, opt.DisCondIcon);
+ CheckDlgButton(hdlg, IDC_STARTUPUPD, opt.StartupUpdate);
+ CheckDlgButton(hdlg, IDC_UPDATE, opt.AutoUpdate);
+ CheckDlgButton(hdlg, IDC_PROTOCOND, !opt.NoProtoCondition);
+ CheckDlgButton(hdlg, IDC_UPDCONDCHG, opt.UpdateOnlyConditionChanged);
+ CheckDlgButton(hdlg, IDC_REMOVEOLD, opt.RemoveOldData);
+ CheckDlgButton(hdlg, IDC_MAKEI, opt.MakeItalic);
+ CheckDlgButton(hdlg, IDC_DISCONDICON, opt.DisCondIcon);
CheckDlgButton(hdlg, IDC_DONOTAPPUNITS, opt.DoNotAppendUnit);
- CheckDlgButton(hdlg, IDC_NOFRAC, opt.NoFrac);
+ CheckDlgButton(hdlg, IDC_NOFRAC, opt.NoFrac);
// 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;
return 0;
case WM_COMMAND:
- if (HIWORD(wparam)==BN_CLICKED && GetFocus()==(HWND)lparam)
- if ( !opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
- if ( !((LOWORD(wparam) == IDC_UPDATE || LOWORD(wparam) == IDC_DEGREE) &&
+ if (HIWORD(wparam) == BN_CLICKED && GetFocus() == (HWND)lparam)
+ if (!opt_startup) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ if (!((LOWORD(wparam) == IDC_UPDATE || LOWORD(wparam) == IDC_DEGREE) &&
(HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus())))
- if ( !opt_startup) SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ if (!opt_startup) SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
return 0;
case WM_NOTIFY:
- switch(((LPNMHDR)lparam)->code) {
+ switch (((LPNMHDR)lparam)->code) {
case PSN_APPLY:
// change the status for weather protocol
if (IsDlgButtonChecked(hdlg, IDC_PROTOCOND) && opt.DefStn != NULL) {
@@ -401,7 +377,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
opt.UpdateTime = (WORD)_ttoi(str);
if (opt.UpdateTime < 1) opt.UpdateTime = 1;
KillTimer(NULL, timerId);
- timerId = SetTimer(NULL, 0, opt.UpdateTime*60000, (TIMERPROC)timerProc);
+ timerId = SetTimer(NULL, 0, opt.UpdateTime * 60000, (TIMERPROC)timerProc);
// other general options
GetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign, sizeof(opt.DegreeSign));
@@ -478,39 +454,38 @@ void FreeTextVar(void)
// text option dialog
-static const char *varname[8] = {"C", "b", "B", "N", "X", "E", "H", "S"};
-static const int cname[8] = {IDC_CTEXT, IDC_BTITLE, IDC_BTEXT, IDC_NTEXT, IDC_XTEXT, IDC_ETEXT, IDC_HTEXT, IDC_BTITLE2 };
-static TCHAR* const *var[8] = {&opt.cText, &opt.bTitle, &opt.bText, &opt.nText, &opt.xText, &opt.eText, &opt.hText, &opt.sText };
+static const char *varname[8] = { "C", "b", "B", "N", "X", "E", "H", "S" };
+static const int cname[8] = { IDC_CTEXT, IDC_BTITLE, IDC_BTEXT, IDC_NTEXT, IDC_XTEXT, IDC_ETEXT, IDC_HTEXT, IDC_BTITLE2 };
+static TCHAR* const *var[8] = { &opt.cText, &opt.bTitle, &opt.bText, &opt.nText, &opt.xText, &opt.eText, &opt.hText, &opt.sText };
-INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
RECT rc, pos;
HWND button;
HMENU hMenu, hMenu1;
TCHAR str[4096];
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
opt_startup = TRUE;
// set windows position, make it top-most
- GetWindowRect(hdlg, &rc);
- SetWindowPos(hdlg, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
+ GetWindowRect(hdlg, &rc);
+ SetWindowPos(hdlg, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE);
TranslateDialogDefault(hdlg);
// generate the display text for variable list
_tcscpy(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
SetDlgItemText(hdlg, IDC_VARLIST, str);
// make the more variable and other buttons flat
- SendMessage(GetDlgItem(hdlg,IDC_MORE), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM1), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM2), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM3), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM4), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM5), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM6), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM7), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_TM8), BUTTONSETASFLATBTN, TRUE, 0);
- SendMessage(GetDlgItem(hdlg,IDC_RESET), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_MORE), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM1), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM2), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM3), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM4), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM5), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM6), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM7), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_TM8), BUTTONSETASFLATBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hdlg, IDC_RESET), BUTTONSETASFLATBTN, TRUE, 0);
// load the settings
LoadTextSettings(hdlg);
opt_startup = FALSE;
@@ -518,7 +493,7 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_COMMAND:
if (opt_startup) return TRUE;
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_CTEXT:
case IDC_BTITLE:
case IDC_BTEXT:
@@ -528,7 +503,7 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_HTEXT:
case IDC_BTITLE2:
if (HIWORD(wParam) == EN_CHANGE)
- SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
break;
case IDC_MORE:
@@ -542,52 +517,46 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_TM4:
case IDC_TM5:
case IDC_TM6:
- case IDC_TM7:
- case IDC_TM8:
- {
- WEATHERINFO winfo;
-
- // display the menu
- button = GetDlgItem(hdlg, LOWORD(wParam));
- GetWindowRect(button, &pos);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMMENU));
- hMenu1 = GetSubMenu(hMenu, 0);
- 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
- 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
- TCHAR* vartmp = *var[varo];
- wfree(&vartmp);
- SetTextDefault(varname[varo]);
- SetDlgItemText(hdlg, cname[varo], *var[varo]);
- }
- break;
- }
- DestroyMenu(hMenu);
+ case IDC_TM7:
+ case IDC_TM8:
+ WEATHERINFO winfo;
+ // display the menu
+ button = GetDlgItem(hdlg, LOWORD(wParam));
+ GetWindowRect(button, &pos);
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMMENU));
+ hMenu1 = GetSubMenu(hMenu, 0);
+ 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
+ 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
+ TCHAR* vartmp = *var[varo];
+ wfree(&vartmp);
+ SetTextDefault(varname[varo]);
+ SetDlgItemText(hdlg, cname[varo], *var[varo]);
break;
}
+ DestroyMenu(hMenu);
+ break;
case IDC_RESET:
// left click action selection menu
button = GetDlgItem(hdlg, IDC_RESET);
- GetWindowRect(button, &pos);
- hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMENU));
+ GetWindowRect(button, &pos);
+ hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TMENU));
hMenu1 = GetSubMenu(hMenu, 0);
TranslateMenu(hMenu1);
- switch(TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL))
- {
+ switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL)) {
case ID_T1:
// reset to the strings in memory, discard all changes
- LoadTextSettings(hdlg);
+ LoadTextSettings(hdlg);
break;
case ID_T2:
@@ -602,35 +571,32 @@ INT_PTR CALLBACK DlgProcText(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
}
return TRUE;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->code)
- {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- {
- // save the option
- TCHAR textstr[MAX_TEXT_SIZE];
- // free memory for old settings
- FreeTextVar();
- // save new settings to memory
- GetDlgItemText(hdlg, IDC_CTEXT, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.cText, textstr);
- GetDlgItemText(hdlg, IDC_BTEXT, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.bText, textstr);
- GetDlgItemText(hdlg, IDC_BTITLE, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.bTitle, textstr);
- GetDlgItemText(hdlg, IDC_ETEXT, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.eText, textstr);
- GetDlgItemText(hdlg, IDC_NTEXT, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.nText, textstr);
- GetDlgItemText(hdlg, IDC_HTEXT, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.hText, textstr);
- GetDlgItemText(hdlg, IDC_XTEXT, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.xText, textstr);
- GetDlgItemText(hdlg, IDC_BTITLE2, textstr, MAX_TEXT_SIZE);
- wSetData(&opt.sText, textstr);
- SaveOptions();
- UpdateAllInfo(0, 0);
- break;
- }
+ // save the option
+ TCHAR textstr[MAX_TEXT_SIZE];
+ // free memory for old settings
+ FreeTextVar();
+ // save new settings to memory
+ GetDlgItemText(hdlg, IDC_CTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.cText, textstr);
+ GetDlgItemText(hdlg, IDC_BTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.bText, textstr);
+ GetDlgItemText(hdlg, IDC_BTITLE, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.bTitle, textstr);
+ GetDlgItemText(hdlg, IDC_ETEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.eText, textstr);
+ GetDlgItemText(hdlg, IDC_NTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.nText, textstr);
+ GetDlgItemText(hdlg, IDC_HTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.hText, textstr);
+ GetDlgItemText(hdlg, IDC_XTEXT, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.xText, textstr);
+ GetDlgItemText(hdlg, IDC_BTITLE2, textstr, MAX_TEXT_SIZE);
+ wSetData(&opt.sText, textstr);
+ SaveOptions();
+ UpdateAllInfo(0, 0);
+ break;
}
break;
}
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp
index c013902ea4..ace0423881 100644
--- a/plugins/Weather/src/weather_update.cpp
+++ b/plugins/Weather/src/weather_update.cpp
@@ -58,7 +58,7 @@ int UpdateWeather(HANDLE hContact)
// error occurs if the return value is not equals to 0
if (opt.ShowWarnings) {
// show warnings by popup
- mir_sntprintf(str, SIZEOF(str) - 105,
+ mir_sntprintf(str, SIZEOF(str) - 105,
TranslateT("Unable to retrieve weather information for %s"), dbv.ptszVal);
_tcscat(str, _T("\n"));
_tcscat(str, GetError(code));
@@ -80,19 +80,19 @@ int UpdateWeather(HANDLE hContact)
// compare the old condition and determine if the weather had changed
if (opt.UpdateOnlyConditionChanged) { // consider condition change
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "LastCondition", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "LastCondition", &dbv)) {
if (_tcsicmp(winfo.cond, dbv.ptszVal)) Ch = TRUE; // the weather condition is changed
db_free(&dbv);
}
else Ch = TRUE;
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "LastTemperature", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "LastTemperature", &dbv)) {
if (_tcsicmp(winfo.temp, dbv.ptszVal)) Ch = TRUE; // the temperature is changed
db_free(&dbv);
}
else Ch = TRUE;
}
else { // consider update time change
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "LastUpdate", &dbv)) {
+ if (!db_get_ts(hContact, WEATHERPROTONAME, "LastUpdate", &dbv)) {
if (_tcsicmp(winfo.update, dbv.ptszVal)) Ch = TRUE; // the update time is changed
db_free(&dbv);
}
@@ -101,7 +101,7 @@ int UpdateWeather(HANDLE hContact)
// have weather alert issued?
dbres = db_get_ts(hContact, WEATHERCONDITION, "Alert", &dbv);
- if ( !dbres && dbv.ptszVal[0] != 0) {
+ if (!dbres && dbv.ptszVal[0] != 0) {
if (opt.AlertPopup && !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) {
// display alert popup
mir_sntprintf(str, SIZEOF(str), _T("Alert for %s%c%s"), winfo.city, 255, dbv.ptszVal);
@@ -113,8 +113,8 @@ int UpdateWeather(HANDLE hContact)
SkinPlaySound("weatheralert");
}
// alert dropped, set the display back to normal
- else db_unset(hContact, WEATHERPROTONAME, "ApparentMode");
- if ( !dbres) db_free(&dbv);
+ else db_unset(hContact, WEATHERPROTONAME, "ApparentMode");
+ if (!dbres) db_free(&dbv);
// backup current condition for checking if the weather is changed or not
db_set_ts(hContact, WEATHERPROTONAME, "LastLog", winfo.update);
@@ -209,7 +209,8 @@ int UpdateWeather(HANDLE hContact)
// update brief info if its opened
HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
- if (hMoreDataDlg != NULL) PostMessage(hMoreDataDlg, WM_UPDATEDATA, 0, 0);
+ if (hMoreDataDlg != NULL)
+ PostMessage(hMoreDataDlg, WM_UPDATEDATA, 0, 0);
return 0;
}
diff --git a/plugins/Weather/src/weather_userinfo.cpp b/plugins/Weather/src/weather_userinfo.cpp
index 7d06772caa..955b46639b 100644
--- a/plugins/Weather/src/weather_userinfo.cpp
+++ b/plugins/Weather/src/weather_userinfo.cpp
@@ -115,20 +115,15 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_MOREDETAIL:
- {
- HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
- if (hMoreDataDlg == NULL)
- hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL,
- DlgProcMoreData, (LPARAM)hContact);
- else
- {
- SetForegroundWindow(hMoreDataDlg);
- SetFocus(hMoreDataDlg);
- }
- ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 0);
- ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 1);
- break;
+ HWND hMoreDataDlg = WindowList_Find(hDataWindowList, hContact);
+ if (hMoreDataDlg == NULL)
+ hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL, DlgProcMoreData, (LPARAM)hContact);
+ else {
+ SetForegroundWindow(hMoreDataDlg);
+ SetFocus(hMoreDataDlg);
}
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 0);
+ ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 1);
}
break;
}
@@ -139,8 +134,7 @@ INT_PTR CALLBACK DlgProcUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
static int BriefDlgResizer(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc)
{
- switch(urc->wId)
- {
+ switch (urc->wId) {
case IDC_HEADERBAR:
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORX_WIDTH;
@@ -156,11 +150,9 @@ static int BriefDlgResizer(HWND hwnd, LPARAM lParam, UTILRESIZECONTROL *urc)
case IDCANCEL:
return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
}
- return RD_ANCHORX_LEFT|RD_ANCHORY_TOP;
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
-
-
// 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)
@@ -168,8 +160,7 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
static const unsigned tabstops = 48;
HANDLE hContact = (HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
// save the contact handle for later use
hContact = (HANDLE)lParam;
@@ -222,7 +213,6 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
// set icons
{
WORD statusIcon = db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", 0);
-
ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedProtoIconBig(WEATHERPROTONAME, statusIcon)));
ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadSkinnedProtoIcon(WEATHERPROTONAME, statusIcon)));
}
@@ -236,12 +226,10 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
GetWindowRect(hList, &rc);
ListView_SetColumnWidth(hList, 1, ListView_GetColumnWidth(hList, 1) +
(int)LOWORD(lParam) - (rc.right - rc.left));
- }
- {
- UTILRESIZEDIALOG urd = {0};
- urd.cbSize = sizeof(urd);
- urd.hwndDlg = hwndDlg;
- urd.hInstance = hInst;
+
+ UTILRESIZEDIALOG urd = { sizeof(urd) };
+ urd.hwndDlg = hwndDlg;
+ urd.hInstance = hInst;
urd.lpTemplate = MAKEINTRESOURCEA(IDD_BRIEF);
urd.pfnResizer = BriefDlgResizer;
CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
@@ -260,8 +248,7 @@ 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);
@@ -269,13 +256,14 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
case IDC_MUPDATE:
{
- LV_ITEM lvi = {0};
HWND hList = GetDlgItem(hwndDlg, IDC_DATALIST);
// update current data
// set the text to "updating"
SetDlgItemText(hwndDlg, IDC_MTEXT, TranslateT("Retrieving new data, please wait..."));
ListView_DeleteAllItems(hList);
+
+ LV_ITEM lvi = { 0 };
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.lParam = 1;
lvi.pszText = _T("");
@@ -305,13 +293,11 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
case WM_NOTIFY:
{
LPNMHDR pNmhdr = (LPNMHDR)lParam;
- if (pNmhdr->idFrom == IDC_MTEXT && pNmhdr->code == EN_LINK)
- {
+ if (pNmhdr->idFrom == IDC_MTEXT && pNmhdr->code == EN_LINK) {
ENLINK *enlink = (ENLINK *) lParam;
- TEXTRANGE tr;
- switch (enlink->msg)
- {
+ switch (enlink->msg) {
case WM_LBUTTONUP:
+ TEXTRANGE tr;
tr.chrg = enlink->chrg;
tr.lpstrText = ( LPTSTR )mir_alloc( sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 8));
SendMessage(pNmhdr->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
@@ -320,8 +306,8 @@ INT_PTR CALLBACK DlgProcMoreData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
break;
}
}
- break;
}
+ break;
case WM_CLOSE:
DestroyWindow(hwndDlg);
@@ -368,19 +354,14 @@ void LoadBriefInfoText(HWND hwndDlg, HANDLE hContact)
int BriefInfo(WPARAM wParam, LPARAM lParam)
{
// make sure that the contact is actually a weather one
- if (IsMyContact((HANDLE)wParam))
- {
+ if (IsMyContact((HANDLE)wParam)) {
HWND hMoreDataDlg = WindowList_Find(hDataWindowList,(HANDLE)wParam);
- if (hMoreDataDlg != NULL)
- {
+ if (hMoreDataDlg != NULL) {
SetForegroundWindow(hMoreDataDlg);
SetFocus(hMoreDataDlg);
}
- else
- {
- hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL, DlgProcMoreData,
- (LPARAM)wParam);
- }
+ else hMoreDataDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_BRIEF), NULL, DlgProcMoreData, (LPARAM)wParam);
+
ShowWindow(GetDlgItem(hMoreDataDlg, IDC_DATALIST), 0);
ShowWindow(GetDlgItem(hMoreDataDlg, IDC_MTEXT), 1);
SetDlgItemText(hMoreDataDlg, IDC_MTOGGLE, TranslateT("More Info"));