summaryrefslogtreecommitdiff
path: root/protocols/ICQ-WIM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-28 13:11:54 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-28 13:11:54 +0300
commit08932ac81d01d7673029c8ed64791e4e985e019d (patch)
tree26a7a8b8194949504cd61923f4b814d41415d92e /protocols/ICQ-WIM/src
parent6e8bc6e0f7b998e4d3b6755d3b4113b5a083cefa (diff)
ICQ-WIM:
- new option to use a tray icon notification; - now left click on popup also opens a mailbox; - popup is displayed on start too, if there are new emails - version bump
Diffstat (limited to 'protocols/ICQ-WIM/src')
-rw-r--r--protocols/ICQ-WIM/src/options.cpp4
-rw-r--r--protocols/ICQ-WIM/src/poll.cpp25
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp3
-rw-r--r--protocols/ICQ-WIM/src/proto.h11
-rw-r--r--protocols/ICQ-WIM/src/resource.h5
-rw-r--r--protocols/ICQ-WIM/src/utils.cpp46
6 files changed, 62 insertions, 32 deletions
diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp
index 09fce66101..7faab09b7d 100644
--- a/protocols/ICQ-WIM/src/options.cpp
+++ b/protocols/ICQ-WIM/src/options.cpp
@@ -157,7 +157,7 @@ class CIcqOptionsDlg : public CProtoDlgBase<CIcqProto>
CCtrlEdit edtUin, edtPassword, edtDiff1, edtDiff2;
CCtrlSpin spin1, spin2;
CCtrlCombo cmbStatus1, cmbStatus2;
- CCtrlCheck chkHideChats;
+ CCtrlCheck chkHideChats, chkTrayIcon;
CCtrlButton btnCreate;
CMStringW wszOldPass;
@@ -173,6 +173,7 @@ public:
cmbStatus1(this, IDC_STATUS1),
cmbStatus2(this, IDC_STATUS2),
edtPassword(this, IDC_PASSWORD),
+ chkTrayIcon(this, IDC_USETRAYICON),
chkHideChats(this, IDC_HIDECHATS)
{
btnCreate.OnClick = Callback(this, &CIcqOptionsDlg::onClick_Register);
@@ -186,6 +187,7 @@ public:
CreateLink(spin1, ppro->m_iTimeDiff1);
CreateLink(spin2, ppro->m_iTimeDiff2);
CreateLink(chkHideChats, ppro->m_bHideGroupchats);
+ CreateLink(chkTrayIcon, ppro->m_bUseTrayIcon);
}
wszOldPass = ppro->m_szPassword;
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp
index 25d34b5e8d..eaf477f384 100644
--- a/protocols/ICQ-WIM/src/poll.cpp
+++ b/protocols/ICQ-WIM/src/poll.cpp
@@ -200,20 +200,6 @@ void CIcqProto::ProcessMyInfo(const JSONNode &ev)
CheckAvatarChange(0, ev);
}
-void CIcqProto::EmailNotification(const wchar_t *pwszText)
-{
- char szServiceFunction[MAX_PATH];
- mir_snprintf(szServiceFunction, "%s%s", m_szModuleName, PS_GOTO_INBOX);
-
- CLISTEVENT cle = {};
- cle.hDbEvent = 1;
- cle.hIcon = IcoLib_GetIconByHandle(iconList[1].hIcolib);
- cle.flags = CLEF_UNICODE;
- cle.pszService = szServiceFunction;
- cle.szTooltip.w = pwszText;
- g_clistApi.pfnAddEvent(&cle);
-}
-
void CIcqProto::ProcessNotification(const JSONNode &ev)
{
for (auto &fld : ev["fields"]) {
@@ -224,15 +210,8 @@ void CIcqProto::ProcessNotification(const JSONNode &ev)
CMStringW wszSubj((*root)["subject"].as_mstring());
m_unreadEmails = (*root)["unreadCount"].as_int();
- POPUPDATAW Popup = {};
- mir_snwprintf(Popup.lpwzText, LPGENW("You received e-mail from %s: %s"), wszFrom.c_str(), wszSubj.c_str());
- Popup.lchIcon = IcoLib_GetIconByHandle(iconList[1].hIcolib);
- if (g_bPopupService) {
- wcsncpy_s(Popup.lpwzContactName, m_tszUserName, _TRUNCATE);
- CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&Popup, 0);
- }
-
- EmailNotification(Popup.lpwzText);
+ CMStringW wszMessage(FORMAT, TranslateT("You received e-mail from %s: %s"), wszFrom.c_str(), wszSubj.c_str());
+ EmailNotification(wszMessage);
}
const JSONNode &status = fld["mailbox.status"];
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index b587c1976f..247492bc45 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -51,7 +51,8 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) :
m_iTimeDiff1(this, "TimeDiff1", 0),
m_iTimeDiff2(this, "TimeDiff2", 0),
m_szPassword(this, "Password"),
- m_bHideGroupchats(this, "HideChats", 1)
+ m_bHideGroupchats(this, "HideChats", true),
+ m_bUseTrayIcon(this, "UseTrayIcon", false)
{
db_set_resident(m_szModuleName, "IdleTS");
db_set_resident(m_szModuleName, "OnlineTS");
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h
index 8125aae649..10b7280488 100644
--- a/protocols/ICQ-WIM/src/proto.h
+++ b/protocols/ICQ-WIM/src/proto.h
@@ -330,12 +330,13 @@ public:
CIcqProto(const char*, const wchar_t*);
~CIcqProto();
- CMOption<wchar_t*> m_szOwnId; // our own aim id
- CMOption<wchar_t*> m_szPassword; // password, if present
- CMOption<BYTE> m_bHideGroupchats; // don't pop up group chat windows on startup
- CMOption<DWORD> m_iTimeDiff1; // set this status to m_iStatus1 after this interval of secs
+ CMOption<wchar_t*> m_szOwnId; // our own aim id
+ CMOption<wchar_t*> m_szPassword; // password, if present
+ CMOption<BYTE> m_bHideGroupchats; // don't pop up group chat windows on startup
+ CMOption<BYTE> m_bUseTrayIcon; // use tray icon notifications
+ CMOption<DWORD> m_iTimeDiff1; // set this status to m_iStatus1 after this interval of secs
CMOption<DWORD> m_iStatus1;
- CMOption<DWORD> m_iTimeDiff2; // set this status to m_iStatus2 after this interval of secs
+ CMOption<DWORD> m_iTimeDiff2; // set this status to m_iStatus2 after this interval of secs
CMOption<DWORD> m_iStatus2;
void CheckStatus(void);
diff --git a/protocols/ICQ-WIM/src/resource.h b/protocols/ICQ-WIM/src/resource.h
index ce308ae793..f738e14180 100644
--- a/protocols/ICQ-WIM/src/resource.h
+++ b/protocols/ICQ-WIM/src/resource.h
@@ -8,7 +8,7 @@
#define IDD_INFO_ICQ 104
#define IDD_REGISTER 105
#define IDD_EDITIGNORE 106
-#define IDI_INBOX 107
+#define IDI_INBOX 107
#define IDI_MAIL_NOTIFY 108
#define IDC_PASSWORD 1001
#define IDC_UIN 1002
@@ -28,6 +28,7 @@
#define IDC_DIFF1 1017
#define IDC_SPIN1 1018
#define IDC_STATUS1 1019
+#define IDC_USETRAYICON 1020
#define IDC_DIFF2 1023
#define IDC_SPIN2 1024
#define IDC_STATUS2 1025
@@ -38,7 +39,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 109
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1020
+#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp
index 7467ffee31..fb4df6b568 100644
--- a/protocols/ICQ-WIM/src/utils.cpp
+++ b/protocols/ICQ-WIM/src/utils.cpp
@@ -298,3 +298,49 @@ char* time2text(time_t time)
return "<invalid>";
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message) {
+ case WM_CONTEXTMENU:
+ PUDeletePopup(hWnd);
+ break;
+
+ case WM_COMMAND:
+ CIcqProto *ppro = (CIcqProto*)PUGetPluginData(hWnd);
+ CallProtoService(ppro->m_szModuleName, PS_GOTO_INBOX);
+ PUDeletePopup(hWnd);
+ break;
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+void CIcqProto::EmailNotification(const wchar_t *pwszText)
+{
+ if (g_bPopupService) {
+ POPUPDATAW Popup = {};
+ Popup.lchIcon = IcoLib_GetIconByHandle(iconList[0].hIcolib);
+ wcsncpy_s(Popup.lpwzText, pwszText, _TRUNCATE);
+ wcsncpy_s(Popup.lpwzContactName, m_tszUserName, _TRUNCATE);
+ Popup.iSeconds = 20;
+ Popup.PluginData = this;
+ Popup.PluginWindowProc = PopupDlgProc;
+ PUAddPopupW(&Popup);
+ }
+
+ if (m_bUseTrayIcon) {
+ char szServiceFunction[MAX_PATH];
+ mir_snprintf(szServiceFunction, "%s%s", m_szModuleName, PS_GOTO_INBOX);
+
+ CLISTEVENT cle = {};
+ cle.hDbEvent = 1;
+ cle.hIcon = IcoLib_GetIconByHandle(iconList[0].hIcolib);
+ cle.flags = CLEF_UNICODE;
+ cle.pszService = szServiceFunction;
+ cle.szTooltip.w = pwszText;
+ g_clistApi.pfnAddEvent(&cle);
+ }
+}