diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-10 23:09:50 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-10 23:09:50 +0300 |
commit | 7346b03e8c19eb1c99aa7cb64948c662194ff83d (patch) | |
tree | 6456dce415e70ac9a6c98f00e9f8b96993fc87f8 /protocols/ICQ-WIM/src/poll.cpp | |
parent | 3ed82dc60191a4bee2a1d59e9da51b5106d019fb (diff) |
fixes #1835 (basic support for MRA mail notifications: displays unread message count, incoming emails, popups)
Diffstat (limited to 'protocols/ICQ-WIM/src/poll.cpp')
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 907505dc28..d417b09d9c 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -108,6 +108,8 @@ void CIcqProto::ProcessEvent(const JSONNode &ev) ProcessGroupChat(pData); else if (szType == L"myInfo") ProcessMyInfo(pData); + else if (szType == L"notification") + ProcessNotification(pData); else if (szType == L"permitDeny") ProcessPermissions(pData); else if (szType == L"presence") @@ -198,6 +200,44 @@ void CIcqProto::ProcessMyInfo(const JSONNode &ev) CheckAvatarChange(0, ev); } +void CIcqProto::ProcessNotification(const JSONNode &ev) +{ + for (auto &fld : ev["fields"]) { + const JSONNode &email = fld["mailbox.newMessage"]; + if (email) { + CMStringW wszFrom(email["from"].as_mstring()); + CMStringW wszSubj(email["subject"].as_mstring()); + m_unreadEmails = email["unreadCount"].as_int(); + + POPUPDATAT Popup = {}; + mir_snwprintf(Popup.lptzText, LPGENW("You received e-mail from %s: %s"), wszFrom.c_str(), wszSubj.c_str()); + Popup.lchIcon = IcoLib_GetIconByHandle(Skin_GetIconHandle(SKINICON_EVENT_MESSAGE), true); + if (g_bPopupService) { + wcsncpy_s(Popup.lptzContactName, m_tszUserName, _TRUNCATE); + CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&Popup, 0); + } + + char szServiceFunction[MAX_PATH]; + mir_snprintf(szServiceFunction, "%s%s", m_szModuleName, PS_GOTO_INBOX); + + CLISTEVENT cle = {}; + cle.lpszProtocol = m_szModuleName; + cle.hIcon = Popup.lchIcon; + cle.flags = (CLEF_UNICODE | CLEF_PROTOCOLGLOBAL); + cle.pszService = szServiceFunction; + cle.szTooltip.w = Popup.lptzText; + g_clistApi.pfnAddEvent(&cle); + } + + const JSONNode &status = fld["mailbox.status"]; + if (status) { + JSONROOT root(status.as_string().c_str()); + m_szMailBox = (*root)["email"].as_mstring(); + m_unreadEmails = (*root)["unreadCount"].as_int(); + } + } +} + void CIcqProto::ProcessPresence(const JSONNode &ev) { CMStringW aimId = ev["aimId"].as_mstring(); |