summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-08-18 14:58:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-08-18 14:58:35 +0300
commit2ae332ebe40fd751360a9f95223c5c0df6c98da7 (patch)
treeae1c148566e5d2eb281e1dffa62a53f26666f369
parent342391d137b0a3c3ad367b4d74526ac725efb869 (diff)
VoiceService:
- slightly redesigned call's dialog - unused timer removed;
-rw-r--r--plugins/VoiceService/res/resource.rc30
-rw-r--r--plugins/VoiceService/src/VoiceCall.cpp66
-rw-r--r--plugins/VoiceService/src/hooks.cpp18
-rw-r--r--plugins/VoiceService/src/main.cpp2
-rw-r--r--plugins/VoiceService/src/resource.h1
-rw-r--r--plugins/VoiceService/src/stdafx.h18
-rw-r--r--protocols/JabberG/src/jabber_voip.cpp2
7 files changed, 67 insertions, 70 deletions
diff --git a/plugins/VoiceService/res/resource.rc b/plugins/VoiceService/res/resource.rc
index a9656b7f76..8556f0c753 100644
--- a/plugins/VoiceService/res/resource.rc
+++ b/plugins/VoiceService/res/resource.rc
@@ -150,25 +150,25 @@ BEGIN
BS_AUTOCHECKBOX | WS_TABSTOP,11,64,275,12
END
-IDD_VOICECALL DIALOGEX 0, 0, 180, 116
+IDD_VOICECALL DIALOGEX 0, 0, 160, 109
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
+ LTEXT "Call will disclose IP address to the peer and his server", -1, 25, 89, 130, 15, SS_LEFT, WS_EX_LEFT
+ ICON 32515, -1, 5, 89, 15, 15, SS_ICON | SS_REALSIZECONTROL, WS_EX_LEFT
+ CTEXT "Established", IDC_STATUS, 6, 49, 148, 10, SS_CENTER | SS_CENTERIMAGE, WS_EX_LEFT
+ CONTROL "", -1, WC_STATIC, SS_BLACKFRAME, 5, 48, 150, 12, WS_EX_LEFT
+ CONTROL "", -1, WC_STATIC, SS_ETCHEDHORZ, 0, 85, 163, 1, WS_EX_LEFT
+ AUTOCHECKBOX "M", IDC_MUTE, 128, 30, 12, 12, BS_ICON | BS_PUSHLIKE, WS_EX_LEFT
+ AUTOCHECKBOX "V", IDC_GGG, 143, 30, 12, 12, BS_ICON | BS_PUSHLIKE, WS_EX_LEFT
+ ICON "", IDC_VIDEO, 113, 30, 12, 12, SS_ICON | SS_REALSIZECONTROL, WS_EX_LEFT
+ LTEXT "", IDC_DESCR, 45, 4, 115, 10, SS_LEFT | SS_WORDELLIPSIS, WS_EX_LEFT
+ LTEXT "", IDC_ADDRESS, 45, 13, 115, 10, SS_LEFT | SS_WORDELLIPSIS, WS_EX_LEFT
+ ICON "", IDC_ENCRYPTED, 98, 30, 12, 12, SS_ICON | SS_REALSIZECONTROL, WS_EX_LEFT
+ CONTROL "", IDC_AVATAR, WC_STATIC, SS_BITMAP | SS_REALSIZECONTROL, 5, 6, 35, 35, WS_EX_LEFT
+ PUSHBUTTON "Drop", IDC_DROPBTN, 90, 66, 65, 13, 0, WS_EX_LEFT
+ DEFPUSHBUTTON "Answer", IDC_ANSWERBTN, 5, 66, 65, 13, 0, WS_EX_LEFT
}
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/VoiceService/src/VoiceCall.cpp b/plugins/VoiceService/src/VoiceCall.cpp
index 920153d511..4d5285761d 100644
--- a/plugins/VoiceService/src/VoiceCall.cpp
+++ b/plugins/VoiceService/src/VoiceCall.cpp
@@ -48,7 +48,8 @@ VoiceCall::VoiceCall(VoiceProvider *module, const char *id) :
m_btnDrop(this, IDC_DROPBTN),
m_lblStatus(this, IDC_STATUS),
m_calltimer(this, 1),
- m_lblContactName(this, IDC_DESCR)
+ m_lblContactName(this, IDC_DESCR),
+ m_lblAddress(this, IDC_ADDRESS)
{
hContact = NULL;
name[0] = 0;
@@ -79,29 +80,44 @@ VoiceCall::~VoiceCall()
bool VoiceCall::OnInitDialog()
{
+ Button_SetIcon_IcoLib(m_hwnd, IDC_DROPBTN, g_plugin.getIconHandle(IDI_ACTION_DROP));
+ Button_SetIcon_IcoLib(m_hwnd, IDC_ANSWERBTN, g_plugin.getIconHandle(IDI_ACTION_ANSWER));
return true;
}
-void VoiceCall::OnCommand_Answer(CCtrlButton*)
+bool VoiceCall::OnClose()
+{
+ Button_FreeIcon_IcoLib(m_hwnd, IDC_DROPBTN);
+ Button_FreeIcon_IcoLib(m_hwnd, IDC_ANSWERBTN);
+
+ calls.remove(this);
+ RefreshFrame();
+ return false;
+}
+
+void VoiceCall::OnCommand_Answer(CCtrlButton *)
{
Answer();
}
-void VoiceCall::OnCommand_Drop(CCtrlButton*)
+void VoiceCall::OnCommand_Drop(CCtrlButton *)
{
- Drop();
+ if (state == VOICE_STATE_ENDED || state == VOICE_STATE_BUSY)
+ Close();
+ else
+ Drop();
}
-void VoiceCall::OnCallTimer(CTimer*)
+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)
+ 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);
+ mir_snwprintf(text, _countof(text), L"%s%d:%02d", hrs, (mins) % 60, m_nsec % 60);
m_lblStatus.SetText(text);
}
@@ -112,6 +128,10 @@ void VoiceCall::AppendCallerID(MCONTACT aHContact, const wchar_t *aName, const w
if (aHContact != NULL) {
hContact = aHContact;
changed = true;
+
+ AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
+ if (ace && (INT_PTR)ace != CALLSERVICE_NOTFOUND && (ace->dwFlags & AVS_BITMAP_VALID))
+ SendMessage(GetDlgItem(m_hwnd, IDC_AVATAR), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)ace->hbmPic);
}
if (!IsEmptyW(aName)) {
@@ -156,7 +176,11 @@ void VoiceCall::CreateDisplayName()
else {
lstrcpyn(displayName, TranslateT("Unknown number"), _countof(displayName));
}
- m_lblContactName.SetText(displayName);
+
+ if (contact)
+ m_lblContactName.SetText(contact);
+ if (number[0])
+ m_lblAddress.SetText(number);
}
void VoiceCall::RemoveNotifications()
@@ -179,9 +203,9 @@ void VoiceCall::SetState(int aState)
state = aState;
RemoveNotifications();
-
+
wchar_t text[512];
- switch(state) {
+ switch (state) {
case VOICE_STATE_TALKING:
m_calltimer.Start(1000);
m_lblStatus.SetText(L"0:00");
@@ -192,8 +216,8 @@ void VoiceCall::SetState(int aState)
SetCaption(L"Incoming call");
m_btnAnswer.Enable(true);
m_lblStatus.SetText(L"Ringing");
- BringWindowToTop(GetHwnd());
- SetForegroundWindow(GetHwnd());
+ 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;
@@ -210,18 +234,20 @@ void VoiceCall::SetState(int aState)
m_calltimer.Stop();
mir_snwprintf(text, _countof(text), L"Call ended %s", m_lblStatus.GetText());
m_lblStatus.SetText(text);
- m_btnAnswer.Enable(true);
+ m_btnAnswer.Enable(false);
+ m_btnDrop.SetText(L"Close");
break;
case VOICE_STATE_BUSY:
m_lblStatus.SetText(L"Busy");
- m_btnAnswer.Enable(true);
+ m_btnAnswer.Enable(false);
+ m_btnDrop.SetText(L"Close");
break;
default:
m_lblStatus.SetText(L"Unknown state");
break;
}
-
- if(state != VOICE_STATE_ON_HOLD)
+
+ if (state != VOICE_STATE_ON_HOLD)
m_nsec = 0;
if (IsFinished()) {
@@ -236,7 +262,7 @@ void VoiceCall::SetState(int aState)
Notify();
}
-void VoiceCall::Notify(bool popup, bool sound, bool clist)
+void VoiceCall::Notify(bool popup, bool sound, bool /*clist*/)
{
if (popup) {
wchar_t text[512];
diff --git a/plugins/VoiceService/src/hooks.cpp b/plugins/VoiceService/src/hooks.cpp
index 52a8eafbda..cab92f8f83 100644
--- a/plugins/VoiceService/src/hooks.cpp
+++ b/plugins/VoiceService/src/hooks.cpp
@@ -415,21 +415,6 @@ VoiceCall* FindVoiceCall(MCONTACT hContact)
return nullptr;
}
-void Timers::ClearEvents(CTimer*)
-{
- DWORD now = GetTickCount();
- bool refresh = false;
- for (auto &call : calls.rev_iter()) {
- if (call->state == VOICE_STATE_ENDED && call->end_time + TIME_TO_SHOW_ENDED_CALL < now) {
- calls.remove(calls.indexOf(&call));
- refresh = true;
- }
- }
-
- if (refresh)
- RefreshFrame();
-}
-
bool CanCall(MCONTACT hContact, BOOL now)
{
for (auto &it : modules)
@@ -690,8 +675,6 @@ int ModulesLoaded(WPARAM, LPARAM)
g_plugin.addSound(it.szName, LPGENW("Voice Calls"), it.wszDescr);
g_plugin.addSound("voice_dialpad", LPGENW("Voice Calls"), LPGENW("Dialpad press"));
- g_timers.m_timer.Start(1000);
-
// Accounts
for (auto *pa : Accounts())
AddAccount(pa);
@@ -702,7 +685,6 @@ int ModulesLoaded(WPARAM, LPARAM)
int PreShutdown(WPARAM, LPARAM)
{
- g_timers.m_timer.Stop();
DeInitFrames();
DeInitOptions();
return 0;
diff --git a/plugins/VoiceService/src/main.cpp b/plugins/VoiceService/src/main.cpp
index d2c2f9fe1a..fd9062dfc2 100644
--- a/plugins/VoiceService/src/main.cpp
+++ b/plugins/VoiceService/src/main.cpp
@@ -19,8 +19,6 @@ Boston, MA 02111-1307, USA.
#include "stdafx.h"
-Timers g_timers;
-
// Prototypes ///////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx =
diff --git a/plugins/VoiceService/src/resource.h b/plugins/VoiceService/src/resource.h
index a2006d13af..648519b83c 100644
--- a/plugins/VoiceService/src/resource.h
+++ b/plugins/VoiceService/src/resource.h
@@ -85,6 +85,7 @@
#define IDC_AVATAR 40106
#define IDC_DROP 40107
#define IDC_ANSWER 40108
+#define IDC_ADDRESS 40109
// Next default values for new objects
diff --git a/plugins/VoiceService/src/stdafx.h b/plugins/VoiceService/src/stdafx.h
index 2787006dd0..23c16fc374 100644
--- a/plugins/VoiceService/src/stdafx.h
+++ b/plugins/VoiceService/src/stdafx.h
@@ -55,6 +55,7 @@ using namespace std;
#include <m_metacontacts.h>
#include <m_fontservice.h>
#include <m_skin.h>
+#include <m_avatars.h>
#include <m_voice.h>
#include <m_voiceservice.h>
@@ -65,20 +66,6 @@ using namespace std;
#include "frame.h"
#include "popup.h"
-struct Timers
-{
- Timers() :
- m_timer(Miranda_GetSystemWindow(), (UINT_PTR)this)
- {
- m_timer.OnEvent = Callback(this, &Timers::ClearEvents);
- }
-
- CTimer m_timer;
- void ClearEvents(CTimer *);
-};
-
-extern Timers g_timers;
-
/////////////////////////////////////////////////////////////////////////////////////////
struct CMPlugin : public PLUGIN<CMPlugin>
@@ -185,10 +172,11 @@ private:
void OnCommand_Drop(CCtrlButton*);
void OnCallTimer(CTimer*);
bool OnInitDialog() override;
+ bool OnClose() override;
CCtrlButton m_btnAnswer;
CCtrlButton m_btnDrop;
- CCtrlLabel m_lblStatus, m_lblContactName;
+ CCtrlLabel m_lblStatus, m_lblContactName, m_lblAddress;
int m_nsec;
CTimer m_calltimer;
diff --git a/protocols/JabberG/src/jabber_voip.cpp b/protocols/JabberG/src/jabber_voip.cpp
index 71426c95ee..37a8a80c36 100644
--- a/protocols/JabberG/src/jabber_voip.cpp
+++ b/protocols/JabberG/src/jabber_voip.cpp
@@ -530,6 +530,7 @@ INT_PTR CJabberProto::JabberVOIP_call(WPARAM hContact, LPARAM)
vc.flags = 0;
vc.hContact = hContact; // Contact associated with the call (can be NULL)
vc.state = VOICE_STATE_CALLING;
+ vc.szNumber.a = m_voipPeerJid;
NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0);
}
@@ -546,6 +547,7 @@ INT_PTR CJabberProto::JabberVOIP_answercall(WPARAM id, LPARAM)
vc.hContact = HContactFromJID(m_voipPeerJid);
vc.state = VOIPCallAccept(m_offerNode, m_voipPeerJid) ? VOICE_STATE_TALKING : VOICE_STATE_ENDED;
+ vc.szNumber.a = m_voipPeerJid;
NotifyEventHooks(m_hVoiceEvent, WPARAM(&vc), 0);
return 0;
}