diff options
Diffstat (limited to 'protocols/Teams/src/teams_popups.cpp')
-rw-r--r-- | protocols/Teams/src/teams_popups.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/protocols/Teams/src/teams_popups.cpp b/protocols/Teams/src/teams_popups.cpp new file mode 100644 index 0000000000..59cca9e937 --- /dev/null +++ b/protocols/Teams/src/teams_popups.cpp @@ -0,0 +1,100 @@ +/* +Copyright (c) 2025 Miranda NG team (https://miranda-ng.org) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "stdafx.h" + +void CTeamsProto::InitPopups() +{ + wchar_t desc[256]; + char name[256]; + + POPUPCLASS ppc = {}; + ppc.flags = PCF_UNICODE; + ppc.pszName = name; + ppc.pszDescription.w = desc; + + mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Notifications")); + mir_snprintf(name, "%s_%s", m_szModuleName, "Notification"); + ppc.hIcon = g_plugin.getIcon(IDI_NOTIFY); + ppc.iSeconds = 5; + m_PopupClasses.insert(Popup_RegisterClass(&ppc)); + + mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Errors")); + mir_snprintf(name, "%s_%s", m_szModuleName, "Error"); + ppc.hIcon = g_plugin.getIcon(IDI_ERRORICON); + ppc.iSeconds = -1; + m_PopupClasses.insert(Popup_RegisterClass(&ppc)); + + mir_snwprintf(desc, L"%s/%s", m_tszUserName, TranslateT("Calls")); + mir_snprintf(name, "%s_%s", m_szModuleName, "Call"); + ppc.hIcon = g_plugin.getIcon(IDI_CALL); + ppc.iSeconds = 30; + ppc.PluginWindowProc = PopupDlgProcCall; + m_PopupClasses.insert(Popup_RegisterClass(&ppc)); +} + +void CTeamsProto::UninitPopups() +{ + for (auto &it : m_PopupClasses) + Popup_UnregisterClass(it); +} + +void CTeamsProto::ShowNotification(const wchar_t *caption, const wchar_t *message, MCONTACT hContact, int type) +{ + if (Miranda_IsTerminated()) + return; + + CMStringA className(FORMAT, "%s_", m_szModuleName); + + switch (type) { + case 1: + className.Append("Error"); + break; + + default: + className.Append("Notification"); + break; + } + + POPUPDATACLASS ppd = {}; + ppd.szTitle.w = caption; + ppd.szText.w = message; + ppd.pszClassName = className.GetBuffer(); + ppd.hContact = hContact; + Popup_AddClass(&ppd); +} + +void CTeamsProto::ShowNotification(const wchar_t *message, MCONTACT hContact) +{ + ShowNotification(_T(MODULENAME), message, hContact); +} + +LRESULT CTeamsProto::PopupDlgProcCall(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_CONTEXTMENU: + PUDeletePopup(hPopup); + CallService(MODULENAME "/IncomingCallPP", 0, PUGetContact(hPopup)); + break; + case WM_COMMAND: + PUDeletePopup(hPopup); + CallService(MODULENAME"/IncomingCallPP", 1, PUGetContact(hPopup)); + break; + } + + return DefWindowProc(hPopup, uMsg, wParam, lParam); +} |