summaryrefslogtreecommitdiff
path: root/plugins/VoiceService/src
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 /plugins/VoiceService/src
parent342391d137b0a3c3ad367b4d74526ac725efb869 (diff)
VoiceService:
- slightly redesigned call's dialog - unused timer removed;
Diffstat (limited to 'plugins/VoiceService/src')
-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
5 files changed, 50 insertions, 55 deletions
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;