summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/TipperYM/src/stdafx.h1
-rw-r--r--protocols/Weather/src/stdafx.h9
-rw-r--r--protocols/Weather/src/weather_data.cpp51
-rw-r--r--protocols/Weather/src/weather_update.cpp10
-rw-r--r--protocols/Weather/src/weather_userinfo.cpp111
5 files changed, 91 insertions, 91 deletions
diff --git a/plugins/TipperYM/src/stdafx.h b/plugins/TipperYM/src/stdafx.h
index 9e0a280fa9..83205f53fe 100644
--- a/plugins/TipperYM/src/stdafx.h
+++ b/plugins/TipperYM/src/stdafx.h
@@ -54,6 +54,7 @@ Boston, MA 02111-1307, USA.
#include <m_variables.h>
#include <m_smileyadd.h>
#include <m_imgsrvc.h>
+#include <m_tipper.h>
#include "resource.h"
#include "version.h"
diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h
index 8ad0babd09..956ce498b9 100644
--- a/protocols/Weather/src/stdafx.h
+++ b/protocols/Weather/src/stdafx.h
@@ -92,10 +92,6 @@ enum EWeatherCondition
#define MAX_TEXT_SIZE 4096
#define MAX_DATA_LEN 1024
-// db info mangement mode
-#define WDBM_REMOVE 1
-#define WDBM_DETAILDISPLAY 2
-
// more info list column width
#define LIST_COLUMN 150
@@ -146,11 +142,6 @@ wchar_t *GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t* str);
wchar_t *GetError(int code);
/////////////////////////////////////////////////////////////////////////////////////////
-// functions in weather_data.c
-
-void DBDataManage(MCONTACT hContact, uint16_t Mode, WPARAM wParam, LPARAM lParam);
-
-/////////////////////////////////////////////////////////////////////////////////////////
// functions in weather_info.c
const wchar_t *GetDefaultText(int c);
diff --git a/protocols/Weather/src/weather_data.cpp b/protocols/Weather/src/weather_data.cpp
index 9cc0a3c9cc..b7e9e7c0fc 100644
--- a/protocols/Weather/src/weather_data.cpp
+++ b/protocols/Weather/src/weather_data.cpp
@@ -108,7 +108,7 @@ void CWeatherProto::EraseAllInfo()
}
else db_free(&dbv);
- DBDataManage(hContact, WDBM_REMOVE, 0, 0);
+ db_delete_module(hContact, WEATHERCONDITION);
db_set_s(hContact, "UserInfo", "MyNotes", "");
// reset update tag
setByte(hContact, "IsUpdated", FALSE);
@@ -243,55 +243,6 @@ void CWeatherProto::ConvertDataValue(WIDATAITEM *p)
}
/////////////////////////////////////////////////////////////////////////////////////////
-// remove or display the weather information for a contact
-// hContact - the contact in which the info is going to be removed
-
-static int GetWeatherDataFromDB(const char *szSetting, void *lparam)
-{
- LIST<char> *pList = (LIST<char>*)lparam;
- pList->insert(mir_strdup(szSetting));
- return 0;
-}
-
-void DBDataManage(MCONTACT hContact, uint16_t Mode, WPARAM wParam, LPARAM)
-{
- // get all the settings and store them in a temporary list
- LIST<char> arSettings(10);
- db_enum_settings(hContact, GetWeatherDataFromDB, WEATHERCONDITION, &arSettings);
-
- // begin deleting settings
- auto T = arSettings.rev_iter();
- for (auto &str : T) {
- ptrW wszText(db_get_wsa(hContact, WEATHERCONDITION, str));
- if (wszText == nullptr)
- continue;
-
- switch (Mode) {
- case WDBM_REMOVE:
- db_unset(hContact, WEATHERCONDITION, str);
- break;
-
- case WDBM_DETAILDISPLAY:
- // skip the "WeatherInfo" variable
- if (!mir_strcmp(str, "WeatherInfo") || !mir_strcmp(str, "Ignore") || str[0] == '#')
- continue;
-
- _A2T strW(str);
- HWND hList = GetDlgItem((HWND)wParam, IDC_DATALIST);
- LV_ITEM lvi = {};
- lvi.mask = LVIF_TEXT | LVIF_PARAM;
- lvi.lParam = T.indexOf(&str);
- lvi.pszText = TranslateW(strW);
- lvi.iItem = ListView_InsertItem(hList, &lvi);
- lvi.pszText = wszText;
- ListView_SetItemText(hList, lvi.iItem, 1, wszText);
- break;
- }
- mir_free(str);
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// data query
MHttpResponse* CWeatherProto::RunQuery(const wchar_t *id, int days)
diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp
index 2af9dc3cc8..c1f51db943 100644
--- a/protocols/Weather/src/weather_update.cpp
+++ b/protocols/Weather/src/weather_update.cpp
@@ -277,7 +277,7 @@ void CWeatherProto::UpdateAll(BOOL AutoUpdate, BOOL RemoveData)
for (auto &hContact : AccContacts())
if (!getByte(hContact, "AutoUpdate") || !AutoUpdate) {
if (RemoveData)
- DBDataManage(hContact, WDBM_REMOVE, 0, 0);
+ db_delete_module(hContact, WEATHERCONDITION);
UpdateListAdd(hContact);
}
@@ -311,12 +311,12 @@ INT_PTR CWeatherProto::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 CWeatherProto::UpdateSingleRemove(WPARAM wParam, LPARAM)
+INT_PTR CWeatherProto::UpdateSingleRemove(WPARAM hContact, LPARAM)
{
- if (IsMyContact(wParam)) {
+ if (IsMyContact(hContact)) {
// add the station to the end of the update queue, and also remove old data
- DBDataManage(wParam, WDBM_REMOVE, 0, 0);
- UpdateListAdd(wParam);
+ db_delete_module(hContact, WEATHERCONDITION);
+ UpdateListAdd(hContact);
// 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
diff --git a/protocols/Weather/src/weather_userinfo.cpp b/protocols/Weather/src/weather_userinfo.cpp
index e49d0e94aa..0679ddf6e9 100644
--- a/protocols/Weather/src/weather_userinfo.cpp
+++ b/protocols/Weather/src/weather_userinfo.cpp
@@ -30,27 +30,45 @@ information
/////////////////////////////////////////////////////////////////////////////////////////
// dialog for more data in the user info window
+static unsigned tabstops = 48;
+
+static int GetWeatherDataFromDB(const char *szSetting, void *lparam)
+{
+ auto *pList = (OBJLIST<char>*)lparam;
+ pList->insert(newStr(szSetting));
+ return 0;
+}
+
class CBriefInfoDlg : public CWeatherDlgBase
{
- static const unsigned tabstops = 48;
MCONTACT hContact;
+ wchar_t m_buf[4098];
+ int iOldItem = -1;
UI_MESSAGE_MAP(CBriefInfoDlg, CWeatherDlgBase);
UI_MESSAGE(WM_UPDATEDATA, OnUpdate);
UI_MESSAGE_MAP_END();
+ CTimer m_timer;
CCtrlButton btnUpdate, btnWebpage, btnToggle;
+ CCtrlListView m_list;
public:
CBriefInfoDlg(CWeatherProto *ppro, MCONTACT _1) :
CWeatherDlgBase(ppro, IDD_BRIEF),
hContact(_1),
+ m_list(this, IDC_DATALIST),
+ m_timer(this, 1),
btnToggle(this, IDC_MTOGGLE),
btnUpdate(this, IDC_MUPDATE),
btnWebpage(this, IDC_MWEBPAGE)
{
SetMinSize(350, 300);
+ m_list.OnHotTrack = Callback(this, &CBriefInfoDlg::onList_Track);
+
+ m_timer.OnEvent = Callback(this, &CBriefInfoDlg::onTimer);
+
btnToggle.OnClick = Callback(this, &CBriefInfoDlg::onClick_Toggle);
btnUpdate.OnClick = Callback(this, &CBriefInfoDlg::onClick_Update);
btnWebpage.OnClick = Callback(this, &CBriefInfoDlg::onClick_Webpage);
@@ -65,13 +83,12 @@ public:
// get the list to display
{
- HWND hList = GetDlgItem(m_hwnd, IDC_DATALIST);
RECT aRect = {};
- GetClientRect(hList, &aRect);
+ GetClientRect(m_list.GetHwnd(), &aRect);
// managing styles
- DWORD dwStyle = LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP;
- ListView_SetExtendedListViewStyleEx(hList, dwStyle, dwStyle);
+ DWORD dwStyle = LVS_EX_FULLROWSELECT;
+ m_list.SetExtendedListViewStyleEx(dwStyle, dwStyle);
// inserting columns
LV_COLUMN lvc = {};
@@ -79,16 +96,15 @@ public:
lvc.cx = LIST_COLUMN;
lvc.pszText = TranslateT("Variable");
- ListView_InsertColumn(hList, 0, &lvc);
+ m_list.InsertColumn(0, &lvc);
lvc.cx = aRect.right - LIST_COLUMN - GetSystemMetrics(SM_CXVSCROLL) - 3;
lvc.pszText = TranslateT("Information");
- ListView_InsertColumn(hList, 1, &lvc);
+ m_list.InsertColumn(1, &lvc);
- // inserting data
- SendMessage(m_hwnd, WM_UPDATEDATA, 0, 0);
+ // insert data
+ OnUpdate();
}
- TranslateDialogDefault(m_hwnd);
// prevent dups of the window
WindowList_Add(hDataWindowList, m_hwnd, hContact);
@@ -117,12 +133,7 @@ public:
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
case IDC_DATALIST:
- {
- HWND hList = GetDlgItem(m_hwnd, IDC_DATALIST);
- RECT rc;
- GetWindowRect(hList, &rc);
- ListView_SetColumnWidth(hList, 1, ListView_GetColumnWidth(hList, 1) + urc->dlgNewSize.cx - (rc.right - rc.left));
- }
+ m_list.SetColumnWidth(1, urc->dlgNewSize.cx - m_list.GetColumnWidth(0) - GetSystemMetrics(SM_CXVSCROLL));
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP | RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
case IDC_MUPDATE:
@@ -136,9 +147,9 @@ public:
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
- INT_PTR OnUpdate(UINT, WPARAM, LPARAM)
+ INT_PTR OnUpdate(UINT = 0, WPARAM = 0, LPARAM = 0)
{
- ListView_DeleteAllItems(GetDlgItem(m_hwnd, IDC_DATALIST));
+ m_list.DeleteAllItems();
wchar_t str[4096];
@@ -157,7 +168,31 @@ public:
SetWindowTextW(m_hwnd, winfo.city);
SetDlgItemTextW(m_hwnd, IDC_HEADERBAR, str);
- DBDataManage(hContact, WDBM_DETAILDISPLAY, (WPARAM)m_hwnd, 0);
+ // get all the settings and store them in a temporary list
+ LIST<char> arSettings(10);
+ db_enum_settings(hContact, GetWeatherDataFromDB, WEATHERCONDITION, &arSettings);
+
+ auto T = arSettings.rev_iter();
+ for (auto &it: T) {
+ CMStringW wszText(db_get_wsm(hContact, WEATHERCONDITION, it));
+ if (wszText.IsEmpty())
+ continue;
+
+ // skip the "WeatherInfo" variable
+ if (!mir_strcmp(it, "WeatherInfo") || !mir_strcmp(it, "Ignore") || it[0] == '#')
+ continue;
+
+ wszText.Replace(L"; ", L";\r\n ");
+
+ _A2T strW(it);
+ LV_ITEM lvi = {};
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
+ lvi.lParam = T.indexOf(&it);
+ lvi.pszText = TranslateW(strW);
+ lvi.iItem = m_list.InsertItem(&lvi);
+ lvi.pszText = wszText.GetBuffer();
+ m_list.SetItemText(lvi.iItem, 1, wszText);
+ }
// set icons
HICON hIcon = m_proto->GetStatusIconBig(hContact);
@@ -168,22 +203,45 @@ public:
return 0;
}
- void onClick_Update(CCtrlButton *)
+ void onList_Track(CCtrlListView::TEventInfo *ev)
{
- HWND hList = GetDlgItem(m_hwnd, IDC_DATALIST);
+ auto *nlv = ev->nmlv;
+ if (nlv->iItem == -1 || nlv->iItem == iOldItem || nlv->iSubItem != 1)
+ return;
+
+ iOldItem = nlv->iItem;
+ m_list.GetItemText(nlv->iItem, nlv->iSubItem, m_buf, _countof(m_buf));
+ m_timer.Start(100);
+ }
+
+ void onTimer(CTimer *pTimer)
+ {
+ pTimer->Stop();
+
+ if (wcslen(m_buf) > 50) {
+ CLCINFOTIP ti = {};
+ ti.cbSize = sizeof(TOOLINFO);
+ ti.hItem = (HANDLE)iOldItem;
+ Tipper_ShowTip(m_buf, &ti);
+ }
+ else Tipper_Hide();
+ }
+
+ void onClick_Update(CCtrlButton *)
+ {
// update current data
// set the text to "updating"
SetDlgItemText(m_hwnd, IDC_MTEXT, TranslateT("Retrieving new data, please wait..."));
- ListView_DeleteAllItems(hList);
+ m_list.DeleteAllItems();
LV_ITEM lvi = {};
lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.lParam = 1;
lvi.pszText = L"";
- lvi.iItem = ListView_InsertItem(hList, &lvi);
+ lvi.iItem = m_list.InsertItem(&lvi);
lvi.pszText = TranslateT("Retrieving new data, please wait...");
- ListView_SetItemText(hList, lvi.iItem, 1, lvi.pszText);
+ m_list.SetItemText(lvi.iItem, 1, lvi.pszText);
m_proto->UpdateSingleStation(hContact, 0);
}
@@ -194,12 +252,11 @@ public:
void onClick_Toggle(CCtrlButton *)
{
- if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_DATALIST)))
+ if (IsWindowVisible(m_list.GetHwnd()))
SetDlgItemText(m_hwnd, IDC_MTOGGLE, TranslateT("More Info"));
else
SetDlgItemText(m_hwnd, IDC_MTOGGLE, TranslateT("Brief Info"));
- ShowWindow(GetDlgItem(m_hwnd, IDC_DATALIST), (int)!IsWindowVisible(
- GetDlgItem(m_hwnd, IDC_DATALIST)));
+ ShowWindow(m_list.GetHwnd(), (int)!IsWindowVisible(m_list.GetHwnd()));
ShowWindow(GetDlgItem(m_hwnd, IDC_MTEXT), (int)!IsWindowVisible(GetDlgItem(m_hwnd, IDC_MTEXT)));
}
};