From d296f9f99daf102b9af5d56690e2bd00d61c1267 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 24 Jul 2018 11:11:26 +0300 Subject: database: - senseless fiels ptszVal removed from DBVARIANT, pwszVal is used instead; - if you want db_get to return a string, you need to use db_get_s. --- plugins/Weather/src/weather_addstn.cpp | 4 ++-- plugins/Weather/src/weather_contacts.cpp | 16 ++++++++-------- plugins/Weather/src/weather_conv.cpp | 4 ++-- plugins/Weather/src/weather_data.cpp | 10 +++++----- plugins/Weather/src/weather_mwin.cpp | 2 +- plugins/Weather/src/weather_svcs.cpp | 2 +- plugins/Weather/src/weather_update.cpp | 22 +++++++++++----------- 7 files changed, 30 insertions(+), 30 deletions(-) (limited to 'plugins/Weather/src') diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index fdc28202b9..367dd686c8 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -45,7 +45,7 @@ INT_PTR WeatherAddToList(WPARAM, LPARAM lParam) DBVARIANT dbv; // check ID to see if the contact already exist in the database if (!db_get_ws(hContact, WEATHERPROTONAME, "ID", &dbv)) { - if (!mir_wstrcmpi(psr->email.w, dbv.ptszVal)) { + if (!mir_wstrcmpi(psr->email.w, dbv.pwszVal)) { // 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)) { @@ -109,7 +109,7 @@ INT_PTR WeatherAddToList(WPARAM, LPARAM lParam) opt.DefStn = hContact; if (!db_get_ws(hContact, WEATHERPROTONAME, "Nick", &dbv)) { // notification message box - mir_snwprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); + mir_snwprintf(str, TranslateT("%s is now the default weather station"), dbv.pwszVal); db_free(&dbv); MessageBox(nullptr, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); } diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp index 5fdb1d097d..62fdf93ffc 100644 --- a/plugins/Weather/src/weather_contacts.cpp +++ b/plugins/Weather/src/weather_contacts.cpp @@ -43,7 +43,7 @@ INT_PTR ViewLog(WPARAM wParam, LPARAM lParam) DBVARIANT dbv; if (!db_get_ws(wParam, WEATHERPROTONAME, "Log", &dbv)) { if (dbv.pszVal[0] != 0) - ShellExecute((HWND)lParam, L"open", dbv.ptszVal, L"", L"", SW_SHOW); + ShellExecute((HWND)lParam, L"open", dbv.pwszVal, L"", L"", SW_SHOW); db_free(&dbv); } else // display warning dialog if no path is specified @@ -159,19 +159,19 @@ static INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPA // start to get the settings // if the setting not exist, leave the dialog box blank if (!db_get_ws(hContact, WEATHERPROTONAME, "ID", &dbv)) { - SetDlgItemText(hwndDlg, IDC_ID, dbv.ptszVal); + SetDlgItemText(hwndDlg, IDC_ID, dbv.pwszVal); // check if the station is a default station - CheckDlgButton(hwndDlg, IDC_DEFA, mir_wstrcmp(dbv.ptszVal, opt.Default) != 0 ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_DEFA, mir_wstrcmp(dbv.pwszVal, opt.Default) != 0 ? BST_CHECKED : BST_UNCHECKED); db_free(&dbv); } if (!db_get_ws(hContact, WEATHERPROTONAME, "Nick", &dbv)) { - SetDlgItemText(hwndDlg, IDC_NAME, dbv.ptszVal); + SetDlgItemText(hwndDlg, IDC_NAME, dbv.pwszVal); db_free(&dbv); } if (!db_get_ws(hContact, WEATHERPROTONAME, "Log", &dbv)) { - SetDlgItemText(hwndDlg, IDC_LOG, dbv.ptszVal); + SetDlgItemText(hwndDlg, IDC_LOG, dbv.pwszVal); // if the log path is not empty, check the checkbox for external log - if (dbv.ptszVal[0]) CheckDlgButton(hwndDlg, IDC_External, BST_CHECKED); + if (dbv.pwszVal[0]) CheckDlgButton(hwndDlg, IDC_External, BST_CHECKED); db_free(&dbv); } // enable/disable the browse button depending on the value of external log checkbox @@ -183,11 +183,11 @@ static INT_PTR CALLBACK DlgProcChange(HWND hwndDlg, UINT msg, WPARAM wParam, LPA CheckDlgButton(hwndDlg, IDC_Internal, db_get_b(hContact, WEATHERPROTONAME, "History", 0) ? BST_CHECKED : BST_UNCHECKED); if (!db_get_ws(hContact, WEATHERPROTONAME, "InfoURL", &dbv)) { - SetDlgItemText(hwndDlg, IDC_IURL, dbv.ptszVal); + SetDlgItemText(hwndDlg, IDC_IURL, dbv.pwszVal); db_free(&dbv); } if (!db_get_ws(hContact, WEATHERPROTONAME, "MapURL", &dbv)) { - SetDlgItemText(hwndDlg, IDC_MURL, dbv.ptszVal); + SetDlgItemText(hwndDlg, IDC_MURL, dbv.pwszVal); db_free(&dbv); } diff --git a/plugins/Weather/src/weather_conv.cpp b/plugins/Weather/src/weather_conv.cpp index c58751a072..27b8569ccf 100644 --- a/plugins/Weather/src/weather_conv.cpp +++ b/plugins/Weather/src/weather_conv.cpp @@ -547,8 +547,8 @@ wchar_t* GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t* str) } // access the database to get its value if (!db_get_ws(w->hContact, WEATHERCONDITION, name, &dbv)) { - if (dbv.ptszVal != TranslateW(NODATA) && dbv.ptszVal != TranslateT("")) - mir_wstrcat(str, dbv.ptszVal); + if (dbv.pwszVal != TranslateW(NODATA) && dbv.pwszVal != TranslateT("")) + mir_wstrcat(str, dbv.pwszVal); db_free(&dbv); } break; diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp index cc3fcbbf27..8137b19c0d 100644 --- a/plugins/Weather/src/weather_data.cpp +++ b/plugins/Weather/src/weather_data.cpp @@ -131,7 +131,7 @@ void EraseAllInfo() db_set_b(hContact, WEATHERPROTONAME, "IsUpdated", FALSE); // reset logging settings if (!db_get_ws(hContact, WEATHERPROTONAME, "Log", &dbv)) { - db_set_b(hContact, WEATHERPROTONAME, "File", (BYTE)(dbv.ptszVal[0] != 0)); + db_set_b(hContact, WEATHERPROTONAME, "File", (BYTE)(dbv.pwszVal[0] != 0)); db_free(&dbv); } else db_set_b(hContact, WEATHERPROTONAME, "File", FALSE); @@ -142,7 +142,7 @@ void EraseAllInfo() opt.DefStn = hContact; if (!db_get_ws(hContact, WEATHERPROTONAME, "Nick", &dbv)) { - mir_snwprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); + mir_snwprintf(str, TranslateT("%s is now the default weather station"), dbv.pwszVal); db_free(&dbv); MessageBox(nullptr, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); } @@ -150,7 +150,7 @@ void EraseAllInfo() // get the handle of the default station if (opt.DefStn == NULL) { if (!db_get_ws(hContact, WEATHERPROTONAME, "ID", &dbv)) { - if (!mir_wstrcmp(dbv.ptszVal, opt.Default)) + if (!mir_wstrcmp(dbv.pwszVal, opt.Default)) opt.DefStn = hContact; db_free(&dbv); } @@ -164,12 +164,12 @@ void EraseAllInfo() // in case where the default station is missing if (opt.DefStn == NULL && ContactCount != 0) { if (!db_get_ws(LastContact, WEATHERPROTONAME, "ID", &dbv)) { - wcsncpy(opt.Default, dbv.ptszVal, _countof(opt.Default) - 1); + wcsncpy(opt.Default, dbv.pwszVal, _countof(opt.Default) - 1); db_free(&dbv); } opt.DefStn = LastContact; if (!db_get_ws(LastContact, WEATHERPROTONAME, "Nick", &dbv)) { - mir_snwprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal); + mir_snwprintf(str, TranslateT("%s is now the default weather station"), dbv.pwszVal); db_free(&dbv); MessageBox(nullptr, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION); } diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp index f2181b8475..7208b267df 100644 --- a/plugins/Weather/src/weather_mwin.cpp +++ b/plugins/Weather/src/weather_mwin.cpp @@ -234,7 +234,7 @@ static void addWindow(MCONTACT hContact) return; wchar_t winname[512]; - mir_snwprintf(winname, L"Weather: %s", dbv.ptszVal); + mir_snwprintf(winname, L"Weather: %s", dbv.pwszVal); db_free(&dbv); HWND hWnd = CreateWindow(L"WeatherFrame", L"", WS_CHILD | WS_VISIBLE, diff --git a/plugins/Weather/src/weather_svcs.cpp b/plugins/Weather/src/weather_svcs.cpp index 6a3351c463..df1b3af7fd 100644 --- a/plugins/Weather/src/weather_svcs.cpp +++ b/plugins/Weather/src/weather_svcs.cpp @@ -175,7 +175,7 @@ static void __cdecl WeatherGetAwayMsgThread(void *arg) MCONTACT hContact = (DWORD_PTR)arg; DBVARIANT dbv; if (!db_get_ws(hContact, "CList", "StatusMsg", &dbv)) { - ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal); + ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.pwszVal); db_free(&dbv); } else ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0); diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index 3b616388f2..81c9da2ac1 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -57,7 +57,7 @@ int UpdateWeather(MCONTACT hContact) if (opt.ShowWarnings) { // show warnings by popup mir_snwprintf(str, _countof(str) - 105, - TranslateT("Unable to retrieve weather information for %s"), dbv.ptszVal); + TranslateT("Unable to retrieve weather information for %s"), dbv.pwszVal); mir_wstrncat(str, L"\n", _countof(str) - mir_wstrlen(str)); wchar_t *tszError = GetError(code); mir_wstrncat(str, tszError, _countof(str) - mir_wstrlen(str)); @@ -66,7 +66,7 @@ int UpdateWeather(MCONTACT hContact) } // log to netlib Netlib_LogfW(hNetlibUser, L"Error! Update cannot continue... Start to free memory"); - Netlib_LogfW(hNetlibUser, L"<-- Error occurs while updating station: %s -->", dbv.ptszVal); + Netlib_LogfW(hNetlibUser, L"<-- Error occurs while updating station: %s -->", dbv.pwszVal); if (!dbres) db_free(&dbv); return 1; } @@ -81,19 +81,19 @@ int UpdateWeather(MCONTACT hContact) // compare the old condition and determine if the weather had changed if (opt.UpdateOnlyConditionChanged) { // consider condition change if (!db_get_ws(hContact, WEATHERPROTONAME, "LastCondition", &dbv)) { - if (mir_wstrcmpi(winfo.cond, dbv.ptszVal)) Ch = TRUE; // the weather condition is changed + if (mir_wstrcmpi(winfo.cond, dbv.pwszVal)) Ch = TRUE; // the weather condition is changed db_free(&dbv); } else Ch = TRUE; if (!db_get_ws(hContact, WEATHERPROTONAME, "LastTemperature", &dbv)) { - if (mir_wstrcmpi(winfo.temp, dbv.ptszVal)) Ch = TRUE; // the temperature is changed + if (mir_wstrcmpi(winfo.temp, dbv.pwszVal)) Ch = TRUE; // the temperature is changed db_free(&dbv); } else Ch = TRUE; } else { // consider update time change if (!db_get_ws(hContact, WEATHERPROTONAME, "LastUpdate", &dbv)) { - if (mir_wstrcmpi(winfo.update, dbv.ptszVal)) Ch = TRUE; // the update time is changed + if (mir_wstrcmpi(winfo.update, dbv.pwszVal)) Ch = TRUE; // the update time is changed db_free(&dbv); } else Ch = TRUE; @@ -101,10 +101,10 @@ int UpdateWeather(MCONTACT hContact) // have weather alert issued? dbres = db_get_ws(hContact, WEATHERCONDITION, "Alert", &dbv); - if (!dbres && dbv.ptszVal[0] != 0) { + if (!dbres && dbv.pwszVal[0] != 0) { if (opt.AlertPopup && !db_get_b(hContact, WEATHERPROTONAME, "DPopUp", 0) && Ch) { // display alert popup - mir_snwprintf(str, L"Alert for %s%c%s", winfo.city, 255, dbv.ptszVal); + mir_snwprintf(str, L"Alert for %s%c%s", winfo.city, 255, dbv.pwszVal); WPShowMessage(str, SM_WEATHERALERT); } // alert issued, set display to italic @@ -169,10 +169,10 @@ int UpdateWeather(MCONTACT hContact) if (!db_get_ws(hContact, WEATHERPROTONAME, "Log", &dbv)) { // for the option for overwriting the file, delete old file first if (db_get_b(hContact, WEATHERPROTONAME, "Overwrite", 0)) - DeleteFile(dbv.ptszVal); + DeleteFile(dbv.pwszVal); // open the file and set point to the end of file - FILE *file = _wfopen(dbv.ptszVal, L"a"); + FILE *file = _wfopen(dbv.pwszVal, L"a"); db_free(&dbv); if (file != nullptr) { // write data to the file and close @@ -486,7 +486,7 @@ int GetWeatherData(MCONTACT hContact) case '[': // variable, add the value to the result string hasvar = TRUE; if (!DBGetData(hContact, _T2A(str2), &dbv)) { - mir_wstrncat(DataValue, dbv.ptszVal, _countof(DataValue) - mir_wstrlen(DataValue)); + mir_wstrncat(DataValue, dbv.pwszVal, _countof(DataValue) - mir_wstrlen(DataValue)); DataValue[_countof(DataValue) - 1] = 0; db_free(&dbv); } @@ -510,7 +510,7 @@ int GetWeatherData(MCONTACT hContact) // for the "Break Data=" operation DBVARIANT dbv; if (!DBGetData(hContact, _T2A(Item->Item.Start), &dbv)) { - wcsncpy(DataValue, dbv.ptszVal, _countof(DataValue)); + wcsncpy(DataValue, dbv.pwszVal, _countof(DataValue)); DataValue[_countof(DataValue) - 1] = 0; db_free(&dbv); } -- cgit v1.2.3