diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-15 21:29:20 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-15 21:29:20 +0000 |
commit | f2dcf0c403d9083ec794376ba690d79727a6d318 (patch) | |
tree | a81596bcb1694d033f0a843c66111841fefa9a17 /protocols/Tox/src/tox_multimedia.cpp | |
parent | da9ae2242b65c735ccda30107cd2f8ee5a021948 (diff) |
Tox: audio support pt.3
git-svn-id: http://svn.miranda-ng.org/main/trunk@12850 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_multimedia.cpp')
-rw-r--r-- | protocols/Tox/src/tox_multimedia.cpp | 101 |
1 files changed, 93 insertions, 8 deletions
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index ba795bb0d7..3d6931eedc 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -1,5 +1,62 @@ #include "common.h"
+/* AUDIO RECEIVING */
+
+CToxAudioCall::CToxAudioCall(CToxProto *proto, int callId) :
+ CToxDlgBase(proto, IDD_AUDIO, false), callId(callId),
+ ok(this, IDOK), cancel(this, IDCANCEL)
+{
+ m_autoClose = CLOSE_ON_CANCEL;
+ ok.OnClick = Callback(this, &CToxAudioCall::OnOk);
+ cancel.OnClick = Callback(this, &CToxAudioCall::OnCancel);
+}
+
+void CToxAudioCall::OnInitDialog()
+{
+ char iconName[100];
+ mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", MODULE, "audio_call");
+ SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon(iconName, 16));
+ SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(iconName, 32));
+
+ Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "AudioCallWindow");
+}
+
+void CToxAudioCall::OnOk(CCtrlBase*)
+{
+ ok.Enable(FALSE);
+ ToxAvCSettings cSettings;// = av_DefaultSettings;
+ //cSettings.call_type = av_TypeAudio;
+ toxav_get_peer_csettings(m_proto->toxAv, callId, 0, &cSettings);
+
+ toxav_answer(m_proto->toxAv, callId, &cSettings);
+}
+
+void CToxAudioCall::OnCancel(CCtrlBase*)
+{
+ if (ok.Enabled())
+ toxav_reject(m_proto->toxAv, callId, NULL);
+ else
+ {
+ int friendNumber = toxav_get_peer_id(m_proto->toxAv, callId, 0);
+ toxav_cancel(m_proto->toxAv, callId, friendNumber, NULL);
+ }
+}
+
+void CToxAudioCall::OnClose()
+{
+ WindowList_Remove(m_proto->hAudioDialogs, m_hwnd);
+ Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "AudioCallWindow");
+}
+
+INT_PTR CToxAudioCall::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (msg == WM_AUDIO_END)
+ Close();
+
+ return CToxDlgBase::DlgProc(msg, wParam, lParam);
+}
+
+// incoming call flow
void CToxProto::OnAvInvite(void*, int32_t callId, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
@@ -37,31 +94,59 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) PROTORECVEVENT recv = { 0 };
recv.timestamp = time(NULL);
- recv.flags = PREF_UTF;
- recv.szMessage = mir_utf8encodeT(TranslateT("Incoming call"));
+ recv.lParam = callId;
+ //recv.flags = PREF_UTF;
+ //recv.szMessage = mir_utf8encodeT(TranslateT("Incoming audio call"));
ProtoChainRecv(hContact, PSR_AUDIO, hContact, (LPARAM)&recv);
}
+// save event to db
INT_PTR CToxProto::OnRecvAudioCall(WPARAM hContact, LPARAM lParam)
{
PROTORECVEVENT *pre = (PROTORECVEVENT*)lParam;
+ calls[hContact] = pre->lParam;
+
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.szModule = m_szModuleName;
dbei.timestamp = pre->timestamp;
- dbei.flags = DBEF_UTF;
- dbei.eventType = DB_EVENT_AUDIO_CALL;
- dbei.cbBlob = (DWORD)mir_strlen(pre->szMessage) + 1;
- dbei.pBlob = (PBYTE)pre->szMessage;
+ //dbei.flags = DBEF_UTF;
+ dbei.eventType = DB_EVENT_AUDIO_RING;
+
+ //dbei.cbBlob = (DWORD)mir_strlen(pre->szMessage) + 1;
+ //dbei.pBlob = (PBYTE)pre->szMessage;
return (INT_PTR)db_event_add(hContact, &dbei);
}
+//
+INT_PTR CToxProto::OnAudioRing(WPARAM hContact, LPARAM lParam)
+{
+ CToxAudioCall *audioCall = new CToxAudioCall(this, calls[hContact]);
+ audioCall->Show();
+ WindowList_Add(hAudioDialogs, audioCall->GetHwnd(), hContact);
+ return 0;
+}
+
void CToxProto::OnAvRinging(void*, int32_t callId, void *arg) { }
void CToxProto::OnAvStart(void*, int32_t callId, void *arg) { }
-void CToxProto::OnAvEnd(void*, int32_t callId, void *arg) { }
+
+void CToxProto::OnAvEnd(void*, int32_t callId, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, 0, 0);
+}
+
void CToxProto::OnAvReject(void*, int32_t callId, void *arg) { }
-void CToxProto::OnAvCancel(void*, int32_t callId, void *arg) { }
+
+void CToxProto::OnAvCancel(void*, int32_t callId, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, 0, 0);
+}
+
void CToxProto::OnAvCsChange(void*, int32_t callId, void *arg) { }
void CToxProto::OnAvRequestTimeout(void*, int32_t callId, void *arg) { }
void CToxProto::OnAvPeerTimeout(void*, int32_t callId, void *arg) { }
|