summaryrefslogtreecommitdiff
path: root/plugins/Weather/src/weather_addstn.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Weather/src/weather_addstn.cpp')
-rw-r--r--plugins/Weather/src/weather_addstn.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp
index b97dba6b32..50a01b9afb 100644
--- a/plugins/Weather/src/weather_addstn.cpp
+++ b/plugins/Weather/src/weather_addstn.cpp
@@ -196,7 +196,7 @@ static INT_PTR CALLBACK WeatherSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPA
return FALSE;
}
-INT_PTR WeatherCreateAdvancedSearchUI(WPARAM wParam, LPARAM lParam)
+INT_PTR WeatherCreateAdvancedSearchUI(WPARAM, LPARAM lParam)
{
HWND parent = (HWND)lParam;
if (parent)
@@ -206,7 +206,7 @@ INT_PTR WeatherCreateAdvancedSearchUI(WPARAM wParam, LPARAM lParam)
}
// service function for name search
-INT_PTR WeatherAdvancedSearch(WPARAM wParam, LPARAM lParam)
+INT_PTR WeatherAdvancedSearch(WPARAM, LPARAM lParam)
{
if (searchId != -1) return 0; //only one search at a time
@@ -235,16 +235,18 @@ int IDSearchProc(TCHAR *sID, const int searchId, WIIDSEARCH *sData, TCHAR *svc,
// load the page
mir_snprintf(loc, SIZEOF(loc), sData->SearchURL, sID);
- if (InternetDownloadFile(loc, NULL, NULL, &szData) == 0) {
+ BOOL bFound = (InternetDownloadFile(loc, NULL, NULL, &szData) == 0);
+ if (bFound) {
TCHAR* szInfo = szData;
// not found
if ( _tcsstr(szInfo, sData->NotFoundStr) == NULL)
GetDataValue(&sData->Name, str, &szInfo);
}
+
mir_free(szData);
// Station not found exit
- if (str[0] == 0) return 1;
+ if (bFound) return 1;
}
// give no station name but only ID if the search is unavailable
@@ -331,6 +333,9 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
GetDataValue(&sData->Single.ID, str, &szInfo);
mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
}
+ else
+ str[0] = 0;
+
// if no station ID is obtained, quit the search
if (str[0] == 0) {
mir_free(szData);
@@ -339,7 +344,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
// if can't get the name, use the search string as name
if (Name[0] == 0)
- _tcscpy(Name, name);
+ _tcsncpy(Name, name, SIZEOF(Name));
// set the data and broadcast it
PROTOSEARCHRESULT psr = { sizeof(psr) };
@@ -356,7 +361,7 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
// for multiple result
else if (sData->Multiple.Available) { // multiple results
// search for the next occurrence of the string
- for (;;) {
+ while (true) {
// if station ID appears first in the downloaded data
if ( !_tcsicmp(sData->Multiple.First, _T("ID"))) {
GetDataValue(&sData->Multiple.ID, str, &szInfo);
@@ -369,11 +374,16 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
GetDataValue(&sData->Multiple.ID, str, &szInfo);
mir_sntprintf(sID, SIZEOF(sID), _T("%s/%s"), svc, str);
}
+ else
+ break;
+
// if no station ID is obtained, search completed and quit the search
- if (str[0] == 0) break;
+ if (str[0] == 0)
+ break;
+
// if can't get the name, use the search string as name
if (Name[0] == 0)
- _tcscpy(Name, name);
+ _tcsncpy(Name, name, SIZEOF(Name));
PROTOSEARCHRESULT psr = { sizeof(psr) };
psr.flags = PSR_TCHAR;
@@ -383,7 +393,9 @@ int NameSearchProc(TCHAR *name, const int searchId, WINAMESEARCH *sData, TCHAR *
psr.email = sID;
psr.id = sID;
ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)searchId, (LPARAM)&psr);
- } } }
+ }
+ }
+ }
mir_free(szData);
return 0;
@@ -415,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 wParam, LPARAM lParam)
+int WeatherAdd(WPARAM, LPARAM)
{
db_set_s(NULL, "FindAdd", "LastSearched", "Weather");
CallService(MS_FINDADD_FINDADD, 0, 0);