diff options
author | George Hazan <ghazan@miranda.im> | 2022-08-15 21:41:54 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-08-15 21:41:54 +0300 |
commit | 092ca1a988e83bed078e077bc20d80abf0d5eabd (patch) | |
tree | 8ba9f7493d9e3f7f6a4e73f2317900ce1ab51a5f /plugins/VoiceService/src | |
parent | ae0df4746dbc5aa414f935dcb4691c527cd06d5b (diff) |
VoiceService: more UI classes
Diffstat (limited to 'plugins/VoiceService/src')
-rw-r--r-- | plugins/VoiceService/src/VoiceCall.cpp | 107 | ||||
-rw-r--r-- | plugins/VoiceService/src/resource.h | 16 | ||||
-rw-r--r-- | plugins/VoiceService/src/services.cpp | 1 | ||||
-rw-r--r-- | plugins/VoiceService/src/stdafx.h | 12 |
4 files changed, 120 insertions, 16 deletions
diff --git a/plugins/VoiceService/src/VoiceCall.cpp b/plugins/VoiceService/src/VoiceCall.cpp index a0df61dcfd..920153d511 100644 --- a/plugins/VoiceService/src/VoiceCall.cpp +++ b/plugins/VoiceService/src/VoiceCall.cpp @@ -40,8 +40,15 @@ static wchar_t *stateTexts[] = { ///////////////////////////////////////////////////////////////////////////////////////// // VoiceCall class members -VoiceCall::VoiceCall(VoiceProvider *module, const char *id) - : module(module), id(mir_strdup(id)) +VoiceCall::VoiceCall(VoiceProvider *module, const char *id) : + CDlgBase(g_plugin, IDD_VOICECALL), + module(module), + id(mir_strdup(id)), + m_btnAnswer(this, IDC_ANSWERBTN), + m_btnDrop(this, IDC_DROPBTN), + m_lblStatus(this, IDC_STATUS), + m_calltimer(this, 1), + m_lblContactName(this, IDC_DESCR) { hContact = NULL; name[0] = 0; @@ -53,7 +60,14 @@ VoiceCall::VoiceCall(VoiceProvider *module, const char *id) incoming = false; secure = false; hwnd = NULL; + m_nsec = 0; + + m_btnAnswer.OnClick = Callback(this, &VoiceCall::OnCommand_Answer); + m_btnDrop.OnClick = Callback(this, &VoiceCall::OnCommand_Drop); + m_calltimer.OnEvent = Callback(this, &VoiceCall::OnCallTimer); + CreateDisplayName(); + Show(); } VoiceCall::~VoiceCall() @@ -63,6 +77,34 @@ VoiceCall::~VoiceCall() id = NULL; } +bool VoiceCall::OnInitDialog() +{ + return true; +} + +void VoiceCall::OnCommand_Answer(CCtrlButton*) +{ + Answer(); +} + +void VoiceCall::OnCommand_Drop(CCtrlButton*) +{ + Drop(); +} + +void VoiceCall::OnCallTimer(CTimer*) +{ + m_nsec++; + wchar_t text[256], hrs[11]; + hrs[0]=0; + int mins = m_nsec/60; + int hours = m_nsec/3600; + if(hours) + mir_snwprintf(hrs, _countof(hrs), L"%d:", hours); + mir_snwprintf(text, _countof(text), L"%s%d:%02d", hrs, (mins)%60, m_nsec%60); + m_lblStatus.SetText(text); +} + void VoiceCall::AppendCallerID(MCONTACT aHContact, const wchar_t *aName, const wchar_t *aNumber) { bool changed = false; @@ -114,6 +156,7 @@ void VoiceCall::CreateDisplayName() else { lstrcpyn(displayName, TranslateT("Unknown number"), _countof(displayName)); } + m_lblContactName.SetText(displayName); } void VoiceCall::RemoveNotifications() @@ -122,26 +165,64 @@ void VoiceCall::RemoveNotifications() DestroyWindow(hwnd); hwnd = NULL; } - +/* if (clistBlinking) { - g_clistApi.pfnRemoveEvent(hContact, (LPARAM)this); + g_clistApi.pfnRemoveEvent(hContact, MEVENT(0xBABABEDA)); clistBlinking = false; - } + }*/ } void VoiceCall::SetState(int aState) { if (state == aState) return; + state = aState; - if (aState == VOICE_STATE_RINGING) + RemoveNotifications(); + + wchar_t text[512]; + switch(state) { + case VOICE_STATE_TALKING: + m_calltimer.Start(1000); + m_lblStatus.SetText(L"0:00"); + m_btnAnswer.Enable(false); + break; + case VOICE_STATE_RINGING: incoming = true; - else if (aState == VOICE_STATE_CALLING) + SetCaption(L"Incoming call"); + m_btnAnswer.Enable(true); + m_lblStatus.SetText(L"Ringing"); + BringWindowToTop(GetHwnd()); + SetForegroundWindow(GetHwnd()); + break; + case VOICE_STATE_CALLING: incoming = false; - - RemoveNotifications(); - - state = aState; + SetCaption(L"Outgoing call"); + m_lblStatus.SetText(L"Calling"); + m_btnAnswer.Enable(false); + break; + case VOICE_STATE_ON_HOLD: + m_lblStatus.SetText(L"Holded"); + m_btnAnswer.Enable(true); + m_btnAnswer.SetText(L"Unhold"); + break; + case VOICE_STATE_ENDED: + m_calltimer.Stop(); + mir_snwprintf(text, _countof(text), L"Call ended %s", m_lblStatus.GetText()); + m_lblStatus.SetText(text); + m_btnAnswer.Enable(true); + break; + case VOICE_STATE_BUSY: + m_lblStatus.SetText(L"Busy"); + m_btnAnswer.Enable(true); + break; + default: + m_lblStatus.SetText(L"Unknown state"); + break; + } + + if(state != VOICE_STATE_ON_HOLD) + m_nsec = 0; if (IsFinished()) { if (end_time == 0) @@ -166,7 +247,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; @@ -179,7 +260,7 @@ void VoiceCall::Notify(bool popup, bool sound, bool clist) IcoLib_ReleaseIcon(ce.hIcon); clistBlinking = true; - } + }*/ RefreshFrame(); } diff --git a/plugins/VoiceService/src/resource.h b/plugins/VoiceService/src/resource.h index 4f4307b746..a2006d13af 100644 --- a/plugins/VoiceService/src/resource.h +++ b/plugins/VoiceService/src/resource.h @@ -69,12 +69,24 @@ #define IDC_RIGHT_ACTION_L 1073 #define IDC_LEFT_ACTION_L 1074 #define IDC_LIST 1079 -#define IDC_ANSWER 1204 -#define IDC_DROP 1205 +#define IDC_ANSWERBTN 1204 +#define IDC_DROPBTN 1205 #define ID_FRAMEPOPUP_ANSWERCALL 40001 #define ID_FRAMEPOPUP_DROPCALL 40002 #define ID_FRAMEPOPUP_HOLDCALL 40003 +#define IDD_VOICECALL 40099 +#define IDC_STATUS 40100 +#define IDC_MUTE 40101 +#define IDC_GGG 40102 +#define IDC_VIDEO 40103 +#define IDC_DESCR 40104 +#define IDC_ENCRYPTED 40105 +#define IDC_AVATAR 40106 +#define IDC_DROP 40107 +#define IDC_ANSWER 40108 + + // Next default values for new objects // #ifdef APSTUDIO_INVOKED diff --git a/plugins/VoiceService/src/services.cpp b/plugins/VoiceService/src/services.cpp index 0d33415b27..c8607ca99a 100644 --- a/plugins/VoiceService/src/services.cpp +++ b/plugins/VoiceService/src/services.cpp @@ -96,6 +96,7 @@ static INT_PTR CALLBACK DlgProcNewCall(HWND hwndDlg, UINT msg, WPARAM wParam, LP static INT_PTR CListDblClick(WPARAM, LPARAM lParam) { + return 0; CLISTEVENT *ce = (CLISTEVENT *)lParam; VoiceCall *call = (VoiceCall *)ce->lParam; diff --git a/plugins/VoiceService/src/stdafx.h b/plugins/VoiceService/src/stdafx.h index 45fd220cdf..2f3cbc4f75 100644 --- a/plugins/VoiceService/src/stdafx.h +++ b/plugins/VoiceService/src/stdafx.h @@ -122,7 +122,7 @@ private: HANDLE state_hook; }; -class VoiceCall +class VoiceCall : CDlgBase { public: VoiceProvider *module; @@ -165,6 +165,16 @@ private: void RemoveNotifications(); void CreateDisplayName(); + void OnCommand_Answer(CCtrlButton*); + void OnCommand_Drop(CCtrlButton*); + void OnCallTimer(CTimer*); + bool OnInitDialog() override; + + CCtrlButton m_btnAnswer; + CCtrlButton m_btnDrop; + CCtrlLabel m_lblStatus, m_lblContactName; + int m_nsec; + CTimer m_calltimer; }; |