From 35aba3d91e39932517046ff84ab7d3e4ef0cf932 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 1 Mar 2019 11:47:16 +0300 Subject: ICQ-WIM: - advanced options moved to the separate dialog; - option added to launch a browser on tray icon click; - now additional email events aren't added if one is already active; - duplicate notification removed --- protocols/ICQ-WIM/src/options.cpp | 101 +++++++++++++++++++++++++++----------- protocols/ICQ-WIM/src/poll.cpp | 3 +- protocols/ICQ-WIM/src/proto.cpp | 3 +- protocols/ICQ-WIM/src/proto.h | 2 + protocols/ICQ-WIM/src/resource.h | 4 +- protocols/ICQ-WIM/src/utils.cpp | 10 +++- 6 files changed, 90 insertions(+), 33 deletions(-) (limited to 'protocols/ICQ-WIM/src') diff --git a/protocols/ICQ-WIM/src/options.cpp b/protocols/ICQ-WIM/src/options.cpp index 7faab09b7d..b93772543f 100644 --- a/protocols/ICQ-WIM/src/options.cpp +++ b/protocols/ICQ-WIM/src/options.cpp @@ -154,45 +154,92 @@ void CIcqProto::OnLoginViaPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe class CIcqOptionsDlg : public CProtoDlgBase { - CCtrlEdit edtUin, edtPassword, edtDiff1, edtDiff2; - CCtrlSpin spin1, spin2; - CCtrlCombo cmbStatus1, cmbStatus2; - CCtrlCheck chkHideChats, chkTrayIcon; + CCtrlEdit edtUin, edtPassword; + CCtrlCheck chkHideChats, chkTrayIcon, chkLaunchMailbox; CCtrlButton btnCreate; CMStringW wszOldPass; public: CIcqOptionsDlg(CIcqProto *ppro, int iDlgID, bool bFullDlg) : CProtoDlgBase(ppro, iDlgID), - spin1(this, IDC_SPIN1, 32000), - spin2(this, IDC_SPIN2, 32000), edtUin(this, IDC_UIN), - edtDiff1(this, IDC_DIFF1), - edtDiff2(this, IDC_DIFF2), btnCreate(this, IDC_REGISTER), - cmbStatus1(this, IDC_STATUS1), - cmbStatus2(this, IDC_STATUS2), edtPassword(this, IDC_PASSWORD), chkTrayIcon(this, IDC_USETRAYICON), - chkHideChats(this, IDC_HIDECHATS) + chkHideChats(this, IDC_HIDECHATS), + chkLaunchMailbox(this, IDC_LAUNCH_MAILBOX) { btnCreate.OnClick = Callback(this, &CIcqOptionsDlg::onClick_Register); - edtDiff1.OnChange = Callback(this, &CIcqOptionsDlg::onChange_Timeout1); - edtDiff2.OnChange = Callback(this, &CIcqOptionsDlg::onChange_Timeout2); - CreateLink(edtUin, ppro->m_szOwnId); CreateLink(edtPassword, ppro->m_szPassword); if (bFullDlg) { - CreateLink(spin1, ppro->m_iTimeDiff1); - CreateLink(spin2, ppro->m_iTimeDiff2); CreateLink(chkHideChats, ppro->m_bHideGroupchats); CreateLink(chkTrayIcon, ppro->m_bUseTrayIcon); + CreateLink(chkLaunchMailbox, ppro->m_bLaunchMailbox); + + chkTrayIcon.OnChange = Callback(this, &CIcqOptionsDlg::onChange_Tray); } wszOldPass = ppro->m_szPassword; } + bool OnInitDialog() override + { + onChange_Tray(0); + return true; + } + + bool OnApply() override + { + if (wszOldPass != ptrW(edtPassword.GetText())) { + m_proto->delSetting(DB_KEY_ATOKEN); + m_proto->delSetting(DB_KEY_SESSIONKEY); + m_proto->delSetting(DB_KEY_PHONEREG); + } + return true; + } + + void onChange_Tray(CCtrlCheck*) + { + chkLaunchMailbox.Enable(chkTrayIcon.GetState()); + } + + void onClick_Register(CCtrlButton*) + { + CIcqRegistrationDlg dlg(m_proto); + dlg.SetParent(m_hwnd); + if (dlg.DoModal()) // force exit to avoid data corruption + PostMessage(m_hwndParent, WM_COMMAND, MAKELONG(IDCANCEL, BN_CLICKED), 0); + } +}; + +///////////////////////////////////////////////////////////////////////////////////////// +// Advanced options + +class CIcqOptionsAdv : public CProtoDlgBase +{ + CCtrlEdit edtDiff1, edtDiff2; + CCtrlSpin spin1, spin2; + CCtrlCombo cmbStatus1, cmbStatus2; + +public: + CIcqOptionsAdv(CIcqProto *ppro) : + CProtoDlgBase(ppro, IDD_OPTIONS_ADV), + spin1(this, IDC_SPIN1, 32000), + spin2(this, IDC_SPIN2, 32000), + edtDiff1(this, IDC_DIFF1), + edtDiff2(this, IDC_DIFF2), + cmbStatus1(this, IDC_STATUS1), + cmbStatus2(this, IDC_STATUS2) + { + edtDiff1.OnChange = Callback(this, &CIcqOptionsAdv::onChange_Timeout1); + edtDiff2.OnChange = Callback(this, &CIcqOptionsAdv::onChange_Timeout2); + + CreateLink(spin1, ppro->m_iTimeDiff1); + CreateLink(spin2, ppro->m_iTimeDiff2); + } + bool OnInitDialog() override { if (cmbStatus1.GetHwnd()) { @@ -221,22 +268,9 @@ public: m_proto->m_iStatus2 = cmbStatus2.GetItemData(cmbStatus2.GetCurSel()); } - if (wszOldPass != ptrW(edtPassword.GetText())) { - m_proto->delSetting(DB_KEY_ATOKEN); - m_proto->delSetting(DB_KEY_SESSIONKEY); - m_proto->delSetting(DB_KEY_PHONEREG); - } return true; } - void onClick_Register(CCtrlButton*) - { - CIcqRegistrationDlg dlg(m_proto); - dlg.SetParent(m_hwnd); - if (dlg.DoModal()) // force exit to avoid data corruption - PostMessage(m_hwndParent, WM_COMMAND, MAKELONG(IDCANCEL, BN_CLICKED), 0); - } - void onChange_Timeout1(CCtrlEdit*) { bool bEnabled = edtDiff1.GetInt() != 0; @@ -253,6 +287,9 @@ public: } }; +///////////////////////////////////////////////////////////////////////////////////////// +// Services + INT_PTR CIcqProto::CreateAccMgrUI(WPARAM, LPARAM hwndParent) { CIcqOptionsDlg *pDlg = new CIcqOptionsDlg(this, IDD_OPTIONS_ACCMGR, false); @@ -268,7 +305,13 @@ int CIcqProto::OnOptionsInit(WPARAM wParam, LPARAM) odp.flags = ODPF_UNICODE | ODPF_BOLDGROUPS; odp.szGroup.w = LPGENW("Network"); odp.position = 1; + + odp.szTab.w = LPGENW("General"); odp.pDialog = new CIcqOptionsDlg(this, IDD_OPTIONS_FULL, true); g_plugin.addOptions(wParam, &odp); + + odp.szTab.w = LPGENW("Advanced"); + odp.pDialog = new CIcqOptionsAdv(this); + g_plugin.addOptions(wParam, &odp); return 0; } diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index eaf477f384..8c0147bca8 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -220,7 +220,8 @@ void CIcqProto::ProcessNotification(const JSONNode &ev) m_szMailBox = (*root)["email"].as_mstring(); m_unreadEmails = (*root)["unreadCount"].as_int(); - if (m_unreadEmails > 0) { + // we notify about initial mail count only during login + if (m_bFirstBos && m_unreadEmails > 0) { CMStringW wszMessage(FORMAT, TranslateT("You have %d unread emails"), m_unreadEmails); EmailNotification(wszMessage); } diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 247492bc45..8b6fe3b126 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -52,7 +52,8 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : m_iTimeDiff2(this, "TimeDiff2", 0), m_szPassword(this, "Password"), m_bHideGroupchats(this, "HideChats", true), - m_bUseTrayIcon(this, "UseTrayIcon", false) + m_bUseTrayIcon(this, "UseTrayIcon", false), + m_bLaunchMailbox(this, "LaunchMailbox", true) { 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 10b7280488..8dfa81a8cc 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -37,6 +37,7 @@ #define ICQ_API_SERVER "https://api.icq.net" #define ICQ_ROBUST_SERVER "https://rapi.icq.net" +#define PS_DUMMY "/DoNothing" #define PS_GOTO_INBOX "/GotoInbox" #define WIM_CAP_VOIP_VOICE "094613504c7f11d18222444553540000" @@ -334,6 +335,7 @@ public: CMOption m_szPassword; // password, if present CMOption m_bHideGroupchats; // don't pop up group chat windows on startup CMOption m_bUseTrayIcon; // use tray icon notifications + CMOption m_bLaunchMailbox; // launch browser to view email CMOption m_iTimeDiff1; // set this status to m_iStatus1 after this interval of secs CMOption m_iStatus1; CMOption m_iTimeDiff2; // set this status to m_iStatus2 after this interval of secs diff --git a/protocols/ICQ-WIM/src/resource.h b/protocols/ICQ-WIM/src/resource.h index f738e14180..32ab58a703 100644 --- a/protocols/ICQ-WIM/src/resource.h +++ b/protocols/ICQ-WIM/src/resource.h @@ -10,6 +10,7 @@ #define IDD_EDITIGNORE 106 #define IDI_INBOX 107 #define IDI_MAIL_NOTIFY 108 +#define IDD_OPTIONS_ADV 109 #define IDC_PASSWORD 1001 #define IDC_UIN 1002 #define IDC_UIN2 1003 @@ -29,6 +30,7 @@ #define IDC_SPIN1 1018 #define IDC_STATUS1 1019 #define IDC_USETRAYICON 1020 +#define IDC_LAUNCH_MAILBOX 1021 #define IDC_DIFF2 1023 #define IDC_SPIN2 1024 #define IDC_STATUS2 1025 @@ -37,7 +39,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 109 +#define _APS_NEXT_RESOURCE_VALUE 110 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1021 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index fb4df6b568..988984d781 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -333,7 +333,15 @@ void CIcqProto::EmailNotification(const wchar_t *pwszText) if (m_bUseTrayIcon) { char szServiceFunction[MAX_PATH]; - mir_snprintf(szServiceFunction, "%s%s", m_szModuleName, PS_GOTO_INBOX); + if (m_bLaunchMailbox) + mir_snprintf(szServiceFunction, "%s%s", m_szModuleName, PS_GOTO_INBOX); + else + mir_snprintf(szServiceFunction, "%s%s", m_szModuleName, PS_DUMMY); + + int i = 0; + while (CLISTEVENT *pcle = g_clistApi.pfnGetEvent(-1, i++)) + if (!mir_strcmp(pcle->pszService, szServiceFunction)) + return; CLISTEVENT cle = {}; cle.hDbEvent = 1; -- cgit v1.2.3