diff options
author | George Hazan <george.hazan@gmail.com> | 2023-10-15 14:43:49 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-10-15 14:43:49 +0300 |
commit | 6e6bc248a3ce5ffbcd3196431789413a178e3bf6 (patch) | |
tree | 2bdeac209e6e0052347913db0f1731216d05e777 | |
parent | 104ef6721d5a3b4c324ec4f2103a6404ca59837f (diff) |
fixes #3732 (VoiceService: добавить открытие диалога вызова при нажатии на всплывающее окно)
-rw-r--r-- | plugins/VoiceService/src/VoiceCall.cpp | 14 | ||||
-rw-r--r-- | plugins/VoiceService/src/options.cpp | 22 | ||||
-rw-r--r-- | plugins/VoiceService/src/options.h | 7 | ||||
-rw-r--r-- | plugins/VoiceService/src/popup.cpp | 166 | ||||
-rw-r--r-- | plugins/VoiceService/src/popup.h | 22 | ||||
-rw-r--r-- | plugins/VoiceService/src/services.cpp | 4 | ||||
-rw-r--r-- | plugins/VoiceService/src/stdafx.h | 37 | ||||
-rw-r--r-- | plugins/VoiceService/src/version.h | 2 |
8 files changed, 105 insertions, 169 deletions
diff --git a/plugins/VoiceService/src/VoiceCall.cpp b/plugins/VoiceService/src/VoiceCall.cpp index 272011b71c..69ac72df98 100644 --- a/plugins/VoiceService/src/VoiceCall.cpp +++ b/plugins/VoiceService/src/VoiceCall.cpp @@ -271,7 +271,7 @@ void VoiceCall::Notify(bool popup, bool sound, bool clist) return; if (popup) - ShowPopup(hContact, displayName, TranslateW(popupTexts[state])); + ShowPopup(hContact, displayName, TranslateW(popupTexts[state]), this); if (clist && state == VOICE_STATE_RINGING) { CLISTEVENT ce = {}; @@ -350,3 +350,15 @@ void VoiceCall::SendDTMF(wchar_t c) CallProtoService(module->name, PS_VOICE_SEND_DTMF, (WPARAM)id, (LPARAM)c); } + +///////////////////////////////////////////////////////////////////////////////////////// + +void ShowCallWindow(VoiceCall *call) +{ + if (calls.indexOf(call) == -1) + return; + + call->Show(); + SetActiveWindow(call->GetHwnd()); + SetForegroundWindow(call->GetHwnd()); +} diff --git a/plugins/VoiceService/src/options.cpp b/plugins/VoiceService/src/options.cpp index f4613bdec8..729b6bfa24 100644 --- a/plugins/VoiceService/src/options.cpp +++ b/plugins/VoiceService/src/options.cpp @@ -43,10 +43,10 @@ static OptPageControl popupsControls[] = { { NULL, CONTROL_RADIO, IDC_DELAYPERMANENT, "PopupsDelayType", POPUP_DELAY_DEFAULT, POPUP_DELAY_PERMANENT }, { &opts.popup_timeout, CONTROL_SPIN, IDC_DELAY, "PopupsTimeout", 10, IDC_DELAY_SPIN, (WORD)1, (WORD)255 }, { &opts.popup_right_click_action, CONTROL_COMBO, IDC_RIGHT_ACTION, "PopupsRightClick", POPUP_ACTION_CLOSEPOPUP }, - { &opts.popup_left_click_action, CONTROL_COMBO, IDC_LEFT_ACTION, "PopupsLeftClick", POPUP_ACTION_CLOSEPOPUP }, + { &opts.popup_left_click_action, CONTROL_COMBO, IDC_LEFT_ACTION, "PopupsLeftClick", POPUP_ACTION_OPENWINDOW }, - { &opts.opt_bImmDialog, CONTROL_CHECKBOX, IDC_IMMDIALOG, "PopupsRightClick", FALSE }, - { &opts.opt_bImmDialogFocus, CONTROL_CHECKBOX, IDC_IMMDIALOG_FOCUS, "PopupsLeftClick", FALSE } + { &opts.opt_bImmDialog, CONTROL_CHECKBOX, IDC_IMMDIALOG, "PopupsRightClick", FALSE }, + { &opts.opt_bImmDialogFocus, CONTROL_CHECKBOX, IDC_IMMDIALOG_FOCUS, "PopupsLeftClick", FALSE }, }; static void PopupsEnableDisableCtrls(HWND hwndDlg) @@ -81,13 +81,19 @@ static void PopupsEnableDisableCtrls(HWND hwndDlg) static INT_PTR CALLBACK PopupsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + HWND hwndCombo; + switch (msg) { case WM_INITDIALOG: - SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Do nothing")); - SendDlgItemMessage(hwndDlg, IDC_RIGHT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Close popup")); - - SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Do nothing")); - SendDlgItemMessage(hwndDlg, IDC_LEFT_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Close popup")); + hwndCombo = GetDlgItem(hwndDlg, IDC_RIGHT_ACTION); + ComboBox_AddString(hwndCombo, TranslateT("Do nothing")); + ComboBox_AddString(hwndCombo, TranslateT("Close popup")); + ComboBox_AddString(hwndCombo, TranslateT("Open call window")); + + hwndCombo = GetDlgItem(hwndDlg, IDC_LEFT_ACTION); + ComboBox_AddString(hwndCombo, TranslateT("Do nothing")); + ComboBox_AddString(hwndCombo, TranslateT("Close popup")); + ComboBox_AddString(hwndCombo, TranslateT("Open call window")); // Needs to be called here in this case { diff --git a/plugins/VoiceService/src/options.h b/plugins/VoiceService/src/options.h index bd8e1bed37..c1a8796b9a 100644 --- a/plugins/VoiceService/src/options.h +++ b/plugins/VoiceService/src/options.h @@ -24,11 +24,12 @@ Boston, MA 02111-1307, USA. #include <windows.h> -#define POPUP_ACTION_DONOTHING 0 +#define POPUP_ACTION_DONOTHING 0 #define POPUP_ACTION_CLOSEPOPUP 1 +#define POPUP_ACTION_OPENWINDOW 2 -#define POPUP_DELAY_DEFAULT 0 -#define POPUP_DELAY_CUSTOM 1 +#define POPUP_DELAY_DEFAULT 0 +#define POPUP_DELAY_CUSTOM 1 #define POPUP_DELAY_PERMANENT 2 diff --git a/plugins/VoiceService/src/popup.cpp b/plugins/VoiceService/src/popup.cpp index bac95b09e0..d165221339 100644 --- a/plugins/VoiceService/src/popup.cpp +++ b/plugins/VoiceService/src/popup.cpp @@ -19,63 +19,62 @@ Boston, MA 02111-1307, USA. #include "stdafx.h" -// Prototypes ///////////////////////////////////////////////////////////////////////////////////// - -#define WMU_ACTION (WM_USER + 1) - - -LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -HWND hPopupWindow = NULL; - +// Handle to popup events -static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); -static LRESULT CALLBACK DumbPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); +struct PopupAction +{ + PopupAction(void *_1, int _2) : + pCall((VoiceCall*)_1), + iAction(_2) + {} + VoiceCall *pCall; + int iAction; +}; +static void CALLBACK ExecuteAction(void *param) +{ + auto *pParam = (PopupAction *)param; -// Functions ////////////////////////////////////////////////////////////////////////////////////// + if (pParam->iAction == POPUP_ACTION_OPENWINDOW) + ShowCallWindow(pParam->pCall); + delete pParam; +} -// Initializations needed by popups -void InitPopups() +static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - // window needed for popup commands - hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, _T("static"), _T(MODULE_NAME) _T("_PopupWindow"), - 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, - NULL, g_plugin.getInst(), NULL); - SetWindowLongPtr(hPopupWindow, GWLP_WNDPROC, (LPARAM)PopupWndProc); -} + switch (message) { + case WM_COMMAND: + CallFunctionAsync(ExecuteAction, new PopupAction(PUGetPluginData(hWnd), opts.popup_left_click_action)); + if (opts.popup_left_click_action != POPUP_ACTION_DONOTHING) + PUDeletePopup(hWnd); -// Deinitializations needed by popups -void DeInitPopups() -{ -} + return TRUE; -void ShowPopup(MCONTACT hContact, const wchar_t *title, const wchar_t *description, ...) -{ - if (!opts.popup_enable) - return; + case WM_CONTEXTMENU: + CallFunctionAsync(ExecuteAction, new PopupAction(PUGetPluginData(hWnd), opts.popup_right_click_action)); + + if (opts.popup_right_click_action != POPUP_ACTION_DONOTHING) + PUDeletePopup(hWnd); - wchar_t text[1024]; + return TRUE; - va_list va; - va_start(va, description); - _vsntprintf(text, _countof(text), description, va); - va_end(va); + case UM_FREEPLUGINDATA: + return TRUE; + } - ShowPopupEx(hContact, title, text, (void*)hContact, POPUP_TYPE_NORMAL, &opts); + return DefWindowProc(hWnd, message, wParam, lParam); } +///////////////////////////////////////////////////////////////////////////////////////// // Show an popup -void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *description, - void *plugin_data, int type, const Options *op) + +static void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *description, void *plugin_data, int type, const Options *op) { // Make popup POPUPDATAW ppd; - - ZeroMemory(&ppd, sizeof(ppd)); ppd.lchContact = hContact; ppd.lchIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(174), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); @@ -88,21 +87,16 @@ void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *descrip wcsncpy_s(ppd.lpwzText, description, _TRUNCATE); if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST) { - if (op->popup_use_default_colors) { - ppd.colorBack = 0; - ppd.colorText = 0; - } - else if (op->popup_use_win_colors) { + if (op->popup_use_win_colors) { ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); } - else { + else if (!op->popup_use_default_colors) { ppd.colorBack = op->popup_bkg_color; ppd.colorText = op->popup_text_color; } } - else // if (type == POPUP_TYPE_ERROR) - { + else { // if (type == POPUP_TYPE_ERROR) ppd.colorBack = RGB(200, 0, 0); ppd.colorText = RGB(255, 255, 255); } @@ -111,10 +105,6 @@ void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *descrip ppd.PluginWindowProc = PopupDlgProc; ppd.PluginData = plugin_data; } - else // if (type == POPUP_TYPE_TEST || type == POPUP_TYPE_ERROR) - { - ppd.PluginWindowProc = DumbPopupDlgProc; - } if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST) { switch (op->popup_delay_type) { @@ -125,88 +115,28 @@ void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *descrip case POPUP_DELAY_PERMANENT: ppd.iSeconds = -1; break; - - //case POPUP_DELAY_DEFAULT: - default: - ppd.iSeconds = 0; - break; } } - else // if (type == POPUP_TYPE_ERROR) - { - ppd.iSeconds = 0; - } // Now that every field has been filled, we want to see the popup. PUAddPopupW(&ppd); } -// Show an error popup +// Show normal popup +void ShowPopup(MCONTACT hContact, const wchar_t *title, const wchar_t *description, void *pUserData) +{ + ShowPopupEx(hContact, title, description, pUserData, POPUP_TYPE_NORMAL, &opts); +} + +// Show error popup void ShowErrPopup(const wchar_t *description, const wchar_t *title) { ShowPopupEx(NULL, title == NULL ? _T(MODULE_NAME) _T(" Error") : title, description, NULL, POPUP_TYPE_ERROR, NULL); } +// Show test popup void ShowTestPopup(const wchar_t *title, const wchar_t *description, const Options *op) { ShowPopupEx(NULL, title, description, NULL, POPUP_TYPE_TEST, op); } - -// Handle to the hidden windows to handle actions for popup clicks -// wParam has the number of MOTD in case of WMU_SHOW_MOTD_DETAILS -LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg == WMU_ACTION) { - // if (lParam == POPUP_ACTION_OPENHISTORY) - // { - // CallService(MS_HISTORY_SHOWCONTACTHISTORY, wParam, 0); - // } - } - return DefWindowProc(hWnd, uMsg, wParam, lParam); -} - - -// Handle to popup events -static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) { - case WM_COMMAND: - SendMessage(hPopupWindow, WMU_ACTION, (WPARAM)PUGetPluginData(hWnd), opts.popup_left_click_action); - - if (opts.popup_left_click_action != POPUP_ACTION_DONOTHING) - PUDeletePopup(hWnd); - - return TRUE; - - case WM_CONTEXTMENU: - SendMessage(hPopupWindow, WMU_ACTION, (WPARAM)PUGetPluginData(hWnd), opts.popup_right_click_action); - - if (opts.popup_right_click_action != POPUP_ACTION_DONOTHING) - PUDeletePopup(hWnd); - - return TRUE; - - case UM_FREEPLUGINDATA: - return TRUE; - } - - return DefWindowProc(hWnd, message, wParam, lParam); -} - - -// Handle to popup events -static LRESULT CALLBACK DumbPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) { - case WM_COMMAND: - case WM_CONTEXTMENU: - PUDeletePopup(hWnd); - return TRUE; - - case UM_FREEPLUGINDATA: - return TRUE; - } - - return DefWindowProc(hWnd, message, wParam, lParam); -} diff --git a/plugins/VoiceService/src/popup.h b/plugins/VoiceService/src/popup.h index 449277c5e4..5c0d948815 100644 --- a/plugins/VoiceService/src/popup.h +++ b/plugins/VoiceService/src/popup.h @@ -21,29 +21,17 @@ Boston, MA 02111-1307, USA. #ifndef __POPUP_H__ # define __POPUP_H__ -// Initializations needed by popups -void InitPopups(); - -// Deinitializations needed by popups -void DeInitPopups(); - - #define POPUP_TYPE_NORMAL 0 #define POPUP_TYPE_TEST 1 #define POPUP_TYPE_ERROR 2 -// Show an popup -void ShowPopup(MCONTACT hContact, const wchar_t *title, const wchar_t *description, ...); +// Show normal popup +void ShowPopup(MCONTACT hContact, const wchar_t *title, const wchar_t *description, void *pUserData); -// Show an test +// Show test popup void ShowTestPopup(const wchar_t *title, const wchar_t *description, const Options *op); -// Show an error popup -void ShowErrPopup(const char *description, const char *title = NULL); - -void ShowPopupEx(MCONTACT hContact, const wchar_t *title, const wchar_t *description, - void *plugin_data, int type, const Options *op); - - +// Show error popup +void ShowErrPopup(const wchar_t *description, const wchar_t *title = 0); #endif // __POPUP_H__ diff --git a/plugins/VoiceService/src/services.cpp b/plugins/VoiceService/src/services.cpp index 68a26cd1d1..00a0793107 100644 --- a/plugins/VoiceService/src/services.cpp +++ b/plugins/VoiceService/src/services.cpp @@ -24,9 +24,7 @@ Boston, MA 02111-1307, USA. static INT_PTR CListDblClick(WPARAM, LPARAM lParam) { CLISTEVENT *ce = (CLISTEVENT *)lParam; - - auto *call = (VoiceCall *)ce->lParam; - call->Show(SW_SHOWNORMAL); + ShowCallWindow((VoiceCall *)ce->lParam); return 0; } diff --git a/plugins/VoiceService/src/stdafx.h b/plugins/VoiceService/src/stdafx.h index 1c99427162..d368feac5c 100644 --- a/plugins/VoiceService/src/stdafx.h +++ b/plugins/VoiceService/src/stdafx.h @@ -21,15 +21,14 @@ Boston, MA 02111-1307, USA. #ifndef __COMMONS_H__ # define __COMMONS_H__ - #include <windows.h> +#include <windowsx.h> #include <tchar.h> #include <stdarg.h> #include <stdio.h> #include <time.h> #include <commctrl.h> - // Disable "...truncated to '255' characters in the debug information" warnings #pragma warning(disable: 4786) @@ -117,6 +116,23 @@ private: class VoiceCall : public CDlgBase { + void CreateDisplayName(); + void RemoveNotifications(); + + bool OnInitDialog() override; + bool OnClose() override; + + void OnCommand_Answer(CCtrlButton *); + void OnCommand_Drop(CCtrlButton *); + void OnCallTimer(CTimer *); + + CCtrlButton m_btnAnswer; + CCtrlButton m_btnDrop; + CCtrlLabel m_lblStatus, m_lblContactName, m_lblAddress; + int m_nsec = 0; + CTimer m_calltimer; + HFONT hContactNameFont; + public: VoiceProvider *module; char *id; // Protocol especific ID for this call @@ -149,22 +165,6 @@ public: bool IsFinished(); void Notify(bool popup = true, bool sound = true, bool clist = true); - -private: - void RemoveNotifications(); - void CreateDisplayName(); - void OnCommand_Answer(CCtrlButton*); - void OnCommand_Drop(CCtrlButton*); - void OnCallTimer(CTimer*); - bool OnInitDialog() override; - bool OnClose() override; - - CCtrlButton m_btnAnswer; - CCtrlButton m_btnDrop; - CCtrlLabel m_lblStatus, m_lblContactName, m_lblAddress; - int m_nsec = 0; - CTimer m_calltimer; - HFONT hContactNameFont; }; extern OBJLIST<VoiceProvider> modules; @@ -177,6 +177,7 @@ bool CanCallNumber(); void HoldOtherCalls(VoiceCall *call); VoiceCall * GetTalkingCall(); bool IsFinalState(int state); +void ShowCallWindow(VoiceCall *call); INT_PTR VoiceRegister(WPARAM wParam, LPARAM lParam); INT_PTR VoiceUnregister(WPARAM wParam, LPARAM lParam); diff --git a/plugins/VoiceService/src/version.h b/plugins/VoiceService/src/version.h index b80a24ec4a..52e3380ea1 100644 --- a/plugins/VoiceService/src/version.h +++ b/plugins/VoiceService/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 3
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
|