diff options
author | George Hazan <ghazan@miranda.im> | 2022-09-02 21:54:41 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-09-02 21:54:41 +0300 |
commit | 55162f6b82e3ca164fc6987144c6573ba03fb017 (patch) | |
tree | 0ebaab6b9c8237875fe7ce59512d8d4a860e7b21 /plugins | |
parent | 93a0e9a4b94c6032d6cbafb83dab8e364d298f84 (diff) |
VoiceService: fix for logic
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ExternalAPI/m_voice.h | 3 | ||||
-rw-r--r-- | plugins/VoiceService/res/resource.rc | 4 | ||||
-rw-r--r-- | plugins/VoiceService/src/VoiceCall.cpp | 42 | ||||
-rw-r--r-- | plugins/VoiceService/src/VoiceProvider.cpp | 5 | ||||
-rw-r--r-- | plugins/VoiceService/src/hooks.cpp | 4 | ||||
-rw-r--r-- | plugins/VoiceService/src/options.cpp | 5 | ||||
-rw-r--r-- | plugins/VoiceService/src/options.h | 3 | ||||
-rw-r--r-- | plugins/VoiceService/src/resource.h | 2 | ||||
-rw-r--r-- | plugins/VoiceService/src/services.cpp | 83 | ||||
-rw-r--r-- | plugins/VoiceService/src/stdafx.h | 5 |
10 files changed, 60 insertions, 96 deletions
diff --git a/plugins/ExternalAPI/m_voice.h b/plugins/ExternalAPI/m_voice.h index b538d6d4a3..bf6ae19881 100644 --- a/plugins/ExternalAPI/m_voice.h +++ b/plugins/ExternalAPI/m_voice.h @@ -46,6 +46,8 @@ return: VOICE_CAPS_* #define VOICE_STATE_ON_HOLD 3 #define VOICE_STATE_ENDED 4 #define VOICE_STATE_BUSY 5 +#define VOICE_STATE_READY 6 +#define VOICE_STATE_SETSTATUS 7 struct VOICE_CALL { @@ -63,6 +65,7 @@ struct VOICE_CALL // where no contact is associated and the caller has a name and a number. int state; // VOICE_STATE_* + const wchar_t *szStatus; }; /* diff --git a/plugins/VoiceService/res/resource.rc b/plugins/VoiceService/res/resource.rc index 56aed66bd4..ba96a5171b 100644 --- a/plugins/VoiceService/res/resource.rc +++ b/plugins/VoiceService/res/resource.rc @@ -72,6 +72,8 @@ BEGIN RTEXT "On left click:",IDC_LEFT_ACTION_L,13,132,62,9 COMBOBOX IDC_LEFT_ACTION,83,132,156,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Preview",IDC_PREV,131,161,50,14 + CONTROL "Show incoming call dialog immediately ",IDC_IMMDIALOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,180,308,12 + CONTROL "Catch focus on this dialog",IDC_IMMDIALOG_FOCUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,200,308,12 END IDD_NEW_CALL DIALOG 0, 0, 229, 87 @@ -123,7 +125,7 @@ BEGIN END IDD_VOICECALL DIALOGEX 0, 0, 160, 119 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | NOT WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Unknown call" FONT 8, "Ms Shell Dlg", 0, 0, 0x1 BEGIN diff --git a/plugins/VoiceService/src/VoiceCall.cpp b/plugins/VoiceService/src/VoiceCall.cpp index 4cf8ef6dda..972d8e0ce0 100644 --- a/plugins/VoiceService/src/VoiceCall.cpp +++ b/plugins/VoiceService/src/VoiceCall.cpp @@ -26,6 +26,7 @@ static wchar_t *popupTitles[] = { LPGENW("Voice call on hold"), LPGENW("Voice call ended"), LPGENW("Voice call busy"), + LPGENW("Voice call ready"), }; static wchar_t *stateTexts[] = { @@ -35,6 +36,7 @@ static wchar_t *stateTexts[] = { LPGENW("Call from %s is on hold"), LPGENW("Call from %s has ended"), LPGENW("%s is busy"), + LPGENW("Ready to call %s"), }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -68,7 +70,7 @@ VoiceCall::VoiceCall(VoiceProvider *module, const char *id) : m_calltimer.OnEvent = Callback(this, &VoiceCall::OnCallTimer); CreateDisplayName(); - Show(SW_SHOWNORMAL); + Create(); } VoiceCall::~VoiceCall() @@ -114,6 +116,8 @@ void VoiceCall::OnCommand_Drop(CCtrlButton *) Close(); else Drop(); + if (state == VOICE_STATE_READY) + Close(); } void VoiceCall::OnCallTimer(CTimer *) @@ -197,11 +201,11 @@ void VoiceCall::RemoveNotifications() DestroyWindow(hwnd); hwnd = NULL; } -/* + if (clistBlinking) { - g_clistApi.pfnRemoveEvent(hContact, MEVENT(0xBABABEDA)); + g_clistApi.pfnRemoveEvent(hContact, MEVENT(1001)); clistBlinking = false; - }*/ + } } void VoiceCall::SetState(int aState) @@ -223,8 +227,11 @@ void VoiceCall::SetState(int aState) SetCaption(TranslateT("Incoming call")); m_btnAnswer.Enable(true); m_lblStatus.SetText(TranslateT("Ringing")); - SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); - SetWindowPos(GetHwnd(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + if(opts.opt_bImmDialog) { + Show(opts.opt_bImmDialogFocus ? SW_SHOWNORMAL : SW_SHOWNOACTIVATE); + SetWindowPos(GetHwnd(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + SetWindowPos(GetHwnd(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); + } break; case VOICE_STATE_CALLING: incoming = false; @@ -248,6 +255,13 @@ void VoiceCall::SetState(int aState) m_btnAnswer.Enable(false); m_btnDrop.SetText(TranslateT("Close")); break; + case VOICE_STATE_READY: + m_lblStatus.SetText(TranslateT("Ready")); + m_btnAnswer.Enable(true); + m_btnAnswer.SetText(TranslateT("Call")); + m_btnDrop.SetText(TranslateT("Close")); + Show(); + break; default: m_lblStatus.SetText(TranslateT("Unknown state")); break; @@ -268,8 +282,16 @@ void VoiceCall::SetState(int aState) Notify(); } -void VoiceCall::Notify(bool popup, bool sound, bool /*clist*/) +void VoiceCall::SetStatus(const wchar_t *text) { + m_lblStatus.SetText(text); +} + +void VoiceCall::Notify(bool popup, bool sound, bool clist) +{ + if(opts.opt_bImmDialog) + return; + if (popup) { wchar_t text[512]; mir_snwprintf(text, TranslateW(stateTexts[state]), displayName); @@ -279,7 +301,7 @@ void VoiceCall::Notify(bool popup, bool sound, bool /*clist*/) if (sound) Skin_PlaySound(g_sounds[state].szName); -/* + if (clist && state == VOICE_STATE_RINGING) { CLISTEVENT ce = {}; ce.hContact = hContact; @@ -292,7 +314,7 @@ void VoiceCall::Notify(bool popup, bool sound, bool /*clist*/) IcoLib_ReleaseIcon(ce.hIcon); clistBlinking = true; - }*/ + } } bool VoiceCall::IsFinished() @@ -317,7 +339,7 @@ void VoiceCall::Drop() bool VoiceCall::CanAnswer() { - return state == -1 || state == VOICE_STATE_RINGING || state == VOICE_STATE_ON_HOLD; + return state == -1 || state == VOICE_STATE_RINGING || state == VOICE_STATE_ON_HOLD || state == VOICE_STATE_READY; } void VoiceCall::Answer() diff --git a/plugins/VoiceService/src/VoiceProvider.cpp b/plugins/VoiceService/src/VoiceProvider.cpp index a5ec34d27c..8246865158 100644 --- a/plugins/VoiceService/src/VoiceProvider.cpp +++ b/plugins/VoiceService/src/VoiceProvider.cpp @@ -45,6 +45,11 @@ static int VoiceState(WPARAM wParam, LPARAM) VoiceCall *call = FindVoiceCall(in->moduleName, in->id, !IsFinalState(in->state)); if (call == NULL) return 0; + + if(in->state == VOICE_STATE_SETSTATUS) { + call->SetStatus(in->szStatus); + return 0; + } call->AppendCallerID(in->hContact, (in->flags & VOICE_UNICODE) ? in->szName.w : _A2T(in->szName.a), diff --git a/plugins/VoiceService/src/hooks.cpp b/plugins/VoiceService/src/hooks.cpp index 46d9885bf3..007208b8fa 100644 --- a/plugins/VoiceService/src/hooks.cpp +++ b/plugins/VoiceService/src/hooks.cpp @@ -25,13 +25,14 @@ static IconItem mainIcons[] = { { LPGEN("Secure"), "secure", IDI_SECURE }, }; -static IconItem stateIcons[] = { +static IconItem stateIcons[NUM_STATES] = { { LPGEN("Talking"), "talking", IDI_TALKING }, { LPGEN("Ringing"), "ringing", IDI_RINGING }, { LPGEN("Calling"), "calling", IDI_CALLING }, { LPGEN("On Hold"), "onhold", IDI_ON_HOLD }, { LPGEN("Ended"), "ended", IDI_ENDED }, { LPGEN("Busy"), "busy", IDI_BUSY }, + { LPGEN("Ready"), "ready", IDI_BUSY }, }; static IconItem actionIcons[] = { @@ -48,6 +49,7 @@ SoundDescr g_sounds[NUM_STATES] = { { "voice_holded", LPGENW("Put a call on Hold") }, { "voice_ended", LPGENW("End of call") }, { "voice_busy", LPGENW("Busy signal") }, + { "voice_ready", LPGENW("Ready") }, }; ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/VoiceService/src/options.cpp b/plugins/VoiceService/src/options.cpp index 3de9ffc247..bf669725fc 100644 --- a/plugins/VoiceService/src/options.cpp +++ b/plugins/VoiceService/src/options.cpp @@ -43,7 +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_CLOSEPOPUP }, + + { &opts.opt_bImmDialog, CONTROL_CHECKBOX, IDC_IMMDIALOG, "PopupsRightClick", FALSE }, + { &opts.opt_bImmDialogFocus, CONTROL_CHECKBOX, IDC_IMMDIALOG_FOCUS, "PopupsLeftClick", FALSE } }; static void PopupsEnableDisableCtrls(HWND hwndDlg) diff --git a/plugins/VoiceService/src/options.h b/plugins/VoiceService/src/options.h index 89667ed586..bd8e1bed37 100644 --- a/plugins/VoiceService/src/options.h +++ b/plugins/VoiceService/src/options.h @@ -43,6 +43,9 @@ struct Options { COLORREF popup_text_color; WORD popup_left_click_action; WORD popup_right_click_action; + + bool opt_bImmDialog; + bool opt_bImmDialogFocus; }; extern Options opts; diff --git a/plugins/VoiceService/src/resource.h b/plugins/VoiceService/src/resource.h index c17adc638d..5acd8de97c 100644 --- a/plugins/VoiceService/src/resource.h +++ b/plugins/VoiceService/src/resource.h @@ -71,6 +71,8 @@ #define IDC_LIST 1079 #define IDC_ANSWERBTN 1204 #define IDC_DROPBTN 1205 +#define IDC_IMMDIALOG 1206 +#define IDC_IMMDIALOG_FOCUS 1207 #define ID_FRAMEPOPUP_ANSWERCALL 40001 #define ID_FRAMEPOPUP_DROPCALL 40002 #define ID_FRAMEPOPUP_HOLDCALL 40003 diff --git a/plugins/VoiceService/src/services.cpp b/plugins/VoiceService/src/services.cpp index ad99378728..410cb0f171 100644 --- a/plugins/VoiceService/src/services.cpp +++ b/plugins/VoiceService/src/services.cpp @@ -21,91 +21,12 @@ Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////////////// -static INT_PTR CALLBACK DlgProcNewCall(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - VoiceCall *call = (VoiceCall *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { - call = (VoiceCall *)lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - - wchar_t text[1024]; - - VoiceCall *currentCall = GetTalkingCall(); - if (currentCall == NULL) { - mir_snwprintf(text, TranslateT("%s wants to start a voice call with you. What you want to do?"), - call->displayName); - } - else if (currentCall->CanHold()) { - mir_snwprintf(text, TranslateT("%s wants to start a voice call with you. What you want to do?\n\nIf you answer the call, the current call will be put on hold."), - call->displayName); - } - else { - mir_snwprintf(text, TranslateT("%s wants to start a voice call with you. What you want to do?\n\nIf you answer the call, the current call will be dropped."), - call->displayName); - } - - SendMessage(GetDlgItem(hwndDlg, IDC_TEXT), WM_SETTEXT, 0, (LPARAM)text); - - HICON hIcon = g_plugin.getIcon(IDI_RINGING); - SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); - IcoLib_ReleaseIcon(hIcon); - - if (call->hContact == NULL) - ShowWindow(GetDlgItem(hwndDlg, IDC_AUTO), SW_HIDE); - } - return TRUE; - - case WM_COMMAND: - switch (wParam) { - case ID_ANSWER: - if (call->hContact != NULL && IsDlgButtonChecked(hwndDlg, IDC_AUTO)) - g_plugin.setWord(call->hContact, "AutoAccept", AUTO_ACCEPT); - - Answer(call); - - DestroyWindow(hwndDlg); - break; - - case ID_DROP: - if (call->hContact != NULL && IsDlgButtonChecked(hwndDlg, IDC_AUTO)) - g_plugin.setWord(call->hContact, "AutoAccept", AUTO_DROP); - - call->Drop(); - - DestroyWindow(hwndDlg); - break; - } - break; - - case WM_CLOSE: - call->Notify(false, false, true); - DestroyWindow(hwndDlg); - break; - - case WM_DESTROY: - call->SetNewCallHWND(NULL); - break; - } - - return FALSE; -} - static INT_PTR CListDblClick(WPARAM, LPARAM lParam) { - return 0; CLISTEVENT *ce = (CLISTEVENT *)lParam; - VoiceCall *call = (VoiceCall *)ce->lParam; - - HWND hwnd = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_NEW_CALL), NULL, DlgProcNewCall, (LPARAM)call); - - ShowWindow(hwnd, SW_SHOWNORMAL); - - call->SetNewCallHWND(hwnd); + auto *call = (VoiceCall *)ce->lParam; + call->Show(SW_SHOWNORMAL); return 0; } diff --git a/plugins/VoiceService/src/stdafx.h b/plugins/VoiceService/src/stdafx.h index 6fcd01ff9c..47f002cba6 100644 --- a/plugins/VoiceService/src/stdafx.h +++ b/plugins/VoiceService/src/stdafx.h @@ -81,7 +81,7 @@ struct CMPlugin : public PLUGIN<CMPlugin> #define ACTION_HOLD 2 #define ACTION_DROP 3 -#define NUM_STATES 6 +#define NUM_STATES 7 #define AUTO_NOTHING 0 #define AUTO_ACCEPT 1 @@ -115,7 +115,7 @@ private: HANDLE state_hook; }; -class VoiceCall : CDlgBase +class VoiceCall : public CDlgBase { public: VoiceProvider *module; @@ -135,6 +135,7 @@ public: void AppendCallerID(MCONTACT hContact, const wchar_t *name, const wchar_t *number); void SetState(int state); + void SetStatus(const wchar_t *text); void Drop(); void Answer(); |