summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-08-15 21:41:54 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-08-15 21:41:54 +0300
commit092ca1a988e83bed078e077bc20d80abf0d5eabd (patch)
tree8ba9f7493d9e3f7f6a4e73f2317900ce1ab51a5f
parentae0df4746dbc5aa414f935dcb4691c527cd06d5b (diff)
VoiceService: more UI classes
-rw-r--r--plugins/VoiceService/res/resource.rc22
-rw-r--r--plugins/VoiceService/src/VoiceCall.cpp107
-rw-r--r--plugins/VoiceService/src/resource.h16
-rw-r--r--plugins/VoiceService/src/services.cpp1
-rw-r--r--plugins/VoiceService/src/stdafx.h12
5 files changed, 142 insertions, 16 deletions
diff --git a/plugins/VoiceService/res/resource.rc b/plugins/VoiceService/res/resource.rc
index 4d9963652f..a9656b7f76 100644
--- a/plugins/VoiceService/res/resource.rc
+++ b/plugins/VoiceService/res/resource.rc
@@ -1,5 +1,7 @@
//Microsoft Developer Studio generated resource script.
//
+#include <windows.h>
+#include <commctrl.h>
#include "..\src\resource.h"
#define APSTUDIO_READONLY_SYMBOLS
@@ -148,6 +150,26 @@ BEGIN
BS_AUTOCHECKBOX | WS_TABSTOP,11,64,275,12
END
+IDD_VOICECALL DIALOGEX 0, 0, 180, 116
+STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
+CAPTION "Unknown call"
+FONT 8, "Ms Shell Dlg", 0, 0, 1
+{
+ LTEXT "Call will disclose IP address to the peer and his server", 0, 27, 96, 147, 17, SS_LEFT, WS_EX_LEFT
+ ICON 32515, -1, 6, 96, 15, 15, SS_ICON | SS_REALSIZECONTROL, WS_EX_LEFT
+ CTEXT "Established", IDC_STATUS, 6, 46, 168, 12, SS_CENTER | SS_CENTERIMAGE, WS_EX_TRANSPARENT
+ CONTROL "", -1, WC_STATIC, WS_DISABLED | SS_ETCHEDHORZ, 1, 60, 179, 1, WS_EX_STATICEDGE
+ CONTROL "", -1, WC_STATIC, SS_ETCHEDHORZ, 1, 45, 179, 1, WS_EX_LEFT
+ CONTROL "", -1, WC_STATIC, SS_ETCHEDHORZ, 1, 93, 179, 1, WS_EX_LEFT
+ AUTOCHECKBOX "M", IDC_MUTE, 138, 27, 15, 15, BS_PUSHLIKE, WS_EX_LEFT
+ AUTOCHECKBOX "V", IDC_GGG, 159, 27, 15, 15, BS_PUSHLIKE, WS_EX_LEFT
+ ICON "", IDC_VIDEO, 120, 27, 15, 15, SS_ICON | SS_REALSIZECONTROL, WS_EX_LEFT
+ LTEXT "", IDC_DESCR, 45, 6, 129, 18, SS_LEFT, WS_EX_LEFT
+ ICON "", IDC_ENCRYPTED, 102, 27, 15, 15, SS_ICON | SS_REALSIZECONTROL, WS_EX_LEFT
+ CONTROL "", IDC_AVATAR, WC_STATIC, SS_BLACKFRAME, 6, 6, 33, 33, WS_EX_LEFT
+ PUSHBUTTON "Drop", IDC_DROPBTN, 111, 69, 63, 15, 0, WS_EX_LEFT
+ DEFPUSHBUTTON "Answer", IDC_ANSWERBTN, 6, 69, 63, 15, 0, WS_EX_LEFT
+}
/////////////////////////////////////////////////////////////////////////////
//
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;
};