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 | |
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')
-rw-r--r-- | protocols/Tox/Tox_12.vcxproj | 4 | ||||
-rw-r--r-- | protocols/Tox/Tox_12.vcxproj.filters | 12 | ||||
-rw-r--r-- | protocols/Tox/res/Icons/audio_call.ico | bin | 1150 -> 5430 bytes | |||
-rw-r--r-- | protocols/Tox/res/Icons/audio_end.ico | bin | 0 -> 5430 bytes | |||
-rw-r--r-- | protocols/Tox/res/Icons/audio_ring.ico | bin | 0 -> 5430 bytes | |||
-rw-r--r-- | protocols/Tox/res/Icons/audio_start.ico | bin | 0 -> 5430 bytes | |||
-rw-r--r-- | protocols/Tox/res/resource.rc | 21 | ||||
-rw-r--r-- | protocols/Tox/src/api_av.cpp | 100 | ||||
-rw-r--r-- | protocols/Tox/src/common.h | 6 | ||||
-rw-r--r-- | protocols/Tox/src/resource.h | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_chatrooms.h | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_events.cpp | 31 | ||||
-rw-r--r-- | protocols/Tox/src/tox_icons.cpp | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_multimedia.cpp | 101 | ||||
-rw-r--r-- | protocols/Tox/src/tox_multimedia.h | 24 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 9 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 10 |
17 files changed, 261 insertions, 70 deletions
diff --git a/protocols/Tox/Tox_12.vcxproj b/protocols/Tox/Tox_12.vcxproj index 377bdf8a47..c9699a69cd 100644 --- a/protocols/Tox/Tox_12.vcxproj +++ b/protocols/Tox/Tox_12.vcxproj @@ -212,6 +212,7 @@ copy docs\tox.ini "$(SolutionDir)$(Configuration)64\Plugins" /y</Command> <ClInclude Include="src\tox_dialogs.h" />
<ClInclude Include="src\tox_icons.h" />
<ClInclude Include="src\tox_menus.h" />
+ <ClInclude Include="src\tox_multimedia.h" />
<ClInclude Include="src\tox_options.h" />
<ClInclude Include="src\tox_proto.h" />
<ClInclude Include="src\tox_transfer.h" />
@@ -256,6 +257,9 @@ copy docs\tox.ini "$(SolutionDir)$(Configuration)64\Plugins" /y</Command> </ItemGroup>
<ItemGroup>
<Image Include="res\icons\audio_call.ico" />
+ <Image Include="res\Icons\audio_end.ico" />
+ <Image Include="res\Icons\audio_ring.ico" />
+ <Image Include="res\Icons\audio_start.ico" />
<Image Include="res\icons\tox.ico" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/protocols/Tox/Tox_12.vcxproj.filters b/protocols/Tox/Tox_12.vcxproj.filters index 88c4bd4376..2960f9c774 100644 --- a/protocols/Tox/Tox_12.vcxproj.filters +++ b/protocols/Tox/Tox_12.vcxproj.filters @@ -66,6 +66,9 @@ <ClInclude Include="include\toxav.h">
<Filter>Header Files\api</Filter>
</ClInclude>
+ <ClInclude Include="src\tox_multimedia.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\tox_proto.cpp">
@@ -171,5 +174,14 @@ <Image Include="res\icons\audio_call.ico">
<Filter>Resource Files\Icons</Filter>
</Image>
+ <Image Include="res\Icons\audio_start.ico">
+ <Filter>Resource Files\Icons</Filter>
+ </Image>
+ <Image Include="res\Icons\audio_end.ico">
+ <Filter>Resource Files\Icons</Filter>
+ </Image>
+ <Image Include="res\Icons\audio_ring.ico">
+ <Filter>Resource Files\Icons</Filter>
+ </Image>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/protocols/Tox/res/Icons/audio_call.ico b/protocols/Tox/res/Icons/audio_call.ico Binary files differindex 3e9cbe2d94..555d0cb874 100644 --- a/protocols/Tox/res/Icons/audio_call.ico +++ b/protocols/Tox/res/Icons/audio_call.ico diff --git a/protocols/Tox/res/Icons/audio_end.ico b/protocols/Tox/res/Icons/audio_end.ico Binary files differnew file mode 100644 index 0000000000..9698282053 --- /dev/null +++ b/protocols/Tox/res/Icons/audio_end.ico diff --git a/protocols/Tox/res/Icons/audio_ring.ico b/protocols/Tox/res/Icons/audio_ring.ico Binary files differnew file mode 100644 index 0000000000..77c4aa9640 --- /dev/null +++ b/protocols/Tox/res/Icons/audio_ring.ico diff --git a/protocols/Tox/res/Icons/audio_start.ico b/protocols/Tox/res/Icons/audio_start.ico Binary files differnew file mode 100644 index 0000000000..4863643b52 --- /dev/null +++ b/protocols/Tox/res/Icons/audio_start.ico diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc index 13cd90fe18..715d433055 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc @@ -64,6 +64,9 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL // remains consistent on all systems.
IDI_TOX ICON "icons\\tox.ico"
IDI_AUDIO_CALL ICON "icons\\audio_call.ico"
+IDI_AUDIO_END ICON "icons\\audio_end.ico"
+IDI_AUDIO_RING ICON "icons\\audio_ring.ico"
+IDI_AUDIO_START ICON "icons\\audio_start.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -196,6 +199,16 @@ BEGIN CONTROL "",IDC_CCLIST,"CListControl",WS_TABSTOP | 0x16f,7,7,176,145,WS_EX_CLIENTEDGE
END
+IDD_AUDIO DIALOGEX 0, 0, 119, 28
+STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST
+CAPTION "Audio call"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,7,7,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,62,7,50,14
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -281,6 +294,14 @@ BEGIN HORZGUIDE, 152
HORZGUIDE, 158
END
+
+ IDD_AUDIO, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 112
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 21
+ END
END
#endif // APSTUDIO_INVOKED
diff --git a/protocols/Tox/src/api_av.cpp b/protocols/Tox/src/api_av.cpp index 4f517187ac..afcf544bbf 100644 --- a/protocols/Tox/src/api_av.cpp +++ b/protocols/Tox/src/api_av.cpp @@ -12,99 +12,99 @@ void toxav_kill(ToxAv *av) CreateFunction<void(*)(ToxAv*)>(__FUNCTION__)(av);
}
-uint32_t toxav_do_interval(ToxAv *av) -{ - return CreateFunction<uint32_t(*)(ToxAv*)>(__FUNCTION__)(av); -} - -void toxav_do(ToxAv *av) -{ - CreateFunction<void(*)(ToxAv*)>(__FUNCTION__)(av); -} - -void toxav_register_callstate_callback(ToxAv *av, ToxAVCallback cb, ToxAvCallbackID id, void *userdata) -{ - CreateFunction<void(*)(ToxAv*, ToxAVCallback, ToxAvCallbackID, void*)>(__FUNCTION__)(av, cb, id, userdata); -} - +uint32_t toxav_do_interval(ToxAv *av)
+{
+ return CreateFunction<uint32_t(*)(ToxAv*)>(__FUNCTION__)(av);
+}
+
+void toxav_do(ToxAv *av)
+{
+ CreateFunction<void(*)(ToxAv*)>(__FUNCTION__)(av);
+}
+
+void toxav_register_callstate_callback(ToxAv *av, ToxAVCallback cb, ToxAvCallbackID id, void *userdata)
+{
+ CreateFunction<void(*)(ToxAv*, ToxAVCallback, ToxAvCallbackID, void*)>(__FUNCTION__)(av, cb, id, userdata);
+}
+
int toxav_call(ToxAv *av, int32_t *call_index, int friend_id, const ToxAvCSettings *csettings, int ringing_seconds)
{
return CreateFunction<int(*)(ToxAv*, int32_t*, int, const ToxAvCSettings*, int)>(__FUNCTION__)(av, call_index, friend_id, csettings, ringing_seconds);
-} - +}
+
int toxav_hangup(ToxAv *av, int32_t call_index)
{
return CreateFunction<int(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
-} - +}
+
int toxav_answer(ToxAv *av, int32_t call_index, const ToxAvCSettings *csettings)
{
return CreateFunction<int(*)(ToxAv*, int32_t, const ToxAvCSettings*)>(__FUNCTION__)(av, call_index, csettings);
-} - +}
+
int toxav_reject(ToxAv *av, int32_t call_index, const char *reason)
{
return CreateFunction<int(*)(ToxAv*, int32_t, const char*)>(__FUNCTION__)(av, call_index, reason);
-} - +}
+
int toxav_cancel(ToxAv *av, int32_t call_index, int peer_id, const char *reason)
{
return CreateFunction<int(*)(ToxAv*, int32_t, int, const char*)>(__FUNCTION__)(av, call_index, peer_id, reason);
-} - +}
+
int toxav_change_settings(ToxAv *av, int32_t call_index, const ToxAvCSettings *csettings)
{
return CreateFunction<int(*)(ToxAv*, int32_t, const ToxAvCSettings*)>(__FUNCTION__)(av, call_index, csettings);
-} - +}
+
int toxav_stop_call(ToxAv *av, int32_t call_index)
{
return CreateFunction<int(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
-} - +}
+
int toxav_prepare_transmission(ToxAv *av, int32_t call_index, int support_video)
{
return CreateFunction<int(*)(ToxAv*, int32_t, int)>(__FUNCTION__)(av, call_index, support_video);
-} - +}
+
int toxav_kill_transmission(ToxAv *av, int32_t call_index)
{
return CreateFunction<int(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
-} - +}
+
int toxav_get_peer_csettings(ToxAv *av, int32_t call_index, int peer, ToxAvCSettings *dest)
{
return CreateFunction<int(*)(ToxAv*, int32_t, int, ToxAvCSettings*)>(__FUNCTION__)(av, call_index, peer, dest);
-} - +}
+
int toxav_get_peer_id(ToxAv *av, int32_t call_index, int peer)
{
return CreateFunction<int(*)(ToxAv*, int32_t, int)>(__FUNCTION__)(av, call_index, peer);
-} - +}
+
ToxAvCallState toxav_get_call_state(ToxAv *av, int32_t call_index)
{
return CreateFunction<ToxAvCallState(*)(ToxAv*, int32_t)>(__FUNCTION__)(av, call_index);
-} - +}
+
int toxav_capability_supported(ToxAv *av, int32_t call_index, ToxAvCapabilities capability)
{
return CreateFunction<int(*)(ToxAv*, int32_t, ToxAvCapabilities)>(__FUNCTION__)(av, call_index, capability);
-} - +}
+
Tox *toxav_get_tox(ToxAv *av)
{
return CreateFunction<Tox*(*)(ToxAv*)>(__FUNCTION__)(av);
-} - +}
+
int toxav_get_active_count(ToxAv *av)
{
return CreateFunction<int(*)(ToxAv*)>(__FUNCTION__)(av);
-} - -/* AUDIO FUNCTIONS */ - -void toxav_register_audio_callback(ToxAv *av, ToxAvAudioCallback cb, void *userdata) -{ - CreateFunction<void(*)(ToxAv*, ToxAvAudioCallback, void*)>(__FUNCTION__)(av, cb, userdata); +}
+
+/* AUDIO FUNCTIONS */
+
+void toxav_register_audio_callback(ToxAv *av, ToxAvAudioCallback cb, void *userdata)
+{
+ CreateFunction<void(*)(ToxAv*, ToxAvAudioCallback, void*)>(__FUNCTION__)(av, cb, userdata);
}
\ No newline at end of file diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h index 0c5fa59879..75c1e48f58 100644 --- a/protocols/Tox/src/common.h +++ b/protocols/Tox/src/common.h @@ -52,6 +52,7 @@ struct CToxProto; #include "tox_dialogs.h"
#include "tox_options.h"
#include "tox_transfer.h"
+#include "tox_multimedia.h"
#include "tox_chatrooms.h"
#include "tox_proto.h"
@@ -84,7 +85,10 @@ extern HINSTANCE g_hInstance; enum TOX_DB_EVENT
{
DB_EVENT_ACTION = 10001,
- DB_EVENT_AUDIO_CALL = 20001
+ DB_EVENT_AUDIO_CALL = 20001,
+ DB_EVENT_AUDIO_RING = 20002,
+ DB_EVENT_AUDIO_START = 20003,
+ DB_EVENT_AUDIO_END = 20004
};
#define PSR_AUDIO "/RecvAudio"
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h index 8b06bab10e..5ffc062970 100644 --- a/protocols/Tox/src/resource.h +++ b/protocols/Tox/src/resource.h @@ -11,9 +11,13 @@ #define IDD_OPTIONS_NODES 107
#define IDD_ADDNODE 108
#define IDD_NODE_EDITOR 109
-#define IDI_ICON1 109
#define IDI_AUDIO_CALL 109
#define IDD_OPTIONS_AV 110
+#define IDD_AUDIO 111
+#define IDI_AUDIO_END 112
+#define IDI_AUDIO_RING 113
+#define IDI_ICON3 114
+#define IDI_AUDIO_START 114
#define IDD_CHATROOM_INVITE 172
#define IDC_CCLIST 173
#define IDC_EDITSCR 174
@@ -48,7 +52,7 @@ //
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 110
+#define _APS_NEXT_RESOURCE_VALUE 115
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1025
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/protocols/Tox/src/tox_chatrooms.h b/protocols/Tox/src/tox_chatrooms.h index 0f51a7391e..419b26bacd 100644 --- a/protocols/Tox/src/tox_chatrooms.h +++ b/protocols/Tox/src/tox_chatrooms.h @@ -1,6 +1,8 @@ #ifndef _TOX_CHATROOMS_H_
#define _TOX_CHATROOMS_H_
+#define WM_AUDIO_END (WM_PROTO_LAST + 100)
+
struct ChatRoomInviteParam
{
CToxProto *proto;
diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index 255358d687..f1e21e955a 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -25,6 +25,21 @@ void CToxProto::InitCustomDbEvents() dbEventType.descr = Translate("Audio call");
dbEventType.eventIcon = GetIconHandle("audio_call");
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
+ dbEventType.eventType = DB_EVENT_AUDIO_RING;
+ dbEventType.descr = Translate("Audio ring");
+ dbEventType.eventIcon = GetIconHandle("audio_ring");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
+ dbEventType.eventType = DB_EVENT_AUDIO_START;
+ dbEventType.descr = Translate("Audio start");
+ dbEventType.eventIcon = GetIconHandle("audio_start");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
+ dbEventType.eventType = DB_EVENT_AUDIO_END;
+ dbEventType.descr = Translate("Audio end");
+ dbEventType.eventIcon = GetIconHandle("audio_end");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
}
int CToxProto::OnDbEventAdded(WPARAM hContact, LPARAM hEvent)
@@ -56,10 +71,22 @@ int CToxProto::OnDbEventAdded(WPARAM hContact, LPARAM hEvent) switch (dbei.eventType)
{
case DB_EVENT_AUDIO_CALL:
- mir_snprintf(szService, SIZEOF(szService), "%s/AudioCall", GetContactProto(hContact));
+ mir_snprintf(szService, SIZEOF(szService), "%s/Audio/Call", GetContactProto(hContact));
+ break;
+
+ case DB_EVENT_AUDIO_RING:
+ mir_snprintf(szService, SIZEOF(szService), "%s/Audio/Ring", GetContactProto(hContact));
+ break;
+
+ case DB_EVENT_AUDIO_START:
+ mir_snprintf(szService, SIZEOF(szService), "%s/Audio/Start", GetContactProto(hContact));
+ break;
+
+ case DB_EVENT_AUDIO_END:
+ mir_snprintf(szService, SIZEOF(szService), "%s/Audio/End", GetContactProto(hContact));
break;
- default: + default:
return 0;
}
cle.pszService = szService;
diff --git a/protocols/Tox/src/tox_icons.cpp b/protocols/Tox/src/tox_icons.cpp index 9a62c5069b..5600283ae0 100644 --- a/protocols/Tox/src/tox_icons.cpp +++ b/protocols/Tox/src/tox_icons.cpp @@ -4,6 +4,9 @@ IconInfo CToxProto::Icons[] = {
{ LPGENT("Protocol icon"), "main", IDI_TOX },
{ LPGENT("Audio call"), "audio_call", IDI_AUDIO_CALL },
+ { LPGENT("Audio ring"), "audio_ring", IDI_AUDIO_RING },
+ { LPGENT("Audio start"), "audio_start", IDI_AUDIO_START },
+ { LPGENT("Audio end"), "audio_end", IDI_AUDIO_END },
};
void CToxProto::InitIcons()
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) { }
diff --git a/protocols/Tox/src/tox_multimedia.h b/protocols/Tox/src/tox_multimedia.h new file mode 100644 index 0000000000..3dd5ad475b --- /dev/null +++ b/protocols/Tox/src/tox_multimedia.h @@ -0,0 +1,24 @@ +#ifndef _TOX_MULTIMEDIA_H_
+#define _TOX_MULTIMEDIA_H_
+
+class CToxAudioCall : public CToxDlgBase
+{
+private:
+ int callId;
+
+ CCtrlButton ok;
+ CCtrlButton cancel;
+
+protected:
+ void OnInitDialog();
+ void OnOk(CCtrlBase*);
+ void OnCancel(CCtrlBase*);
+ void OnClose();
+
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
+
+public:
+ CToxAudioCall(CToxProto *proto, int callId);
+};
+
+#endif //_TOX_MULTIMEDIA_H_
\ No newline at end of file diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 55285f9b31..0b3947cd74 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -14,6 +14,7 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : // services
CreateProtoService(PSR_AUDIO, &CToxProto::OnRecvAudioCall);
+ CreateProtoService("/Audio/Ring", &CToxProto::OnAudioRing);
// avatars
CreateProtoService(PS_GETAVATARCAPS, &CToxProto::GetAvatarCaps);
@@ -23,10 +24,14 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : // nick
CreateProtoService(PS_SETMYNICKNAME, &CToxProto::SetMyNickname);
+
+ hAudioDialogs = WindowList_Create();
}
CToxProto::~CToxProto()
{
+ WindowList_Destroy(hAudioDialogs);
+
mir_free(accountName);
UninitNetlib();
}
@@ -213,12 +218,10 @@ int CToxProto::SetAwayMsg(int, const PROTOCHAR *msg) {
if (IsOnline())
{
- ptrA statusMessage(msg == NULL ? mir_strdup("") : mir_utf8encodeT(msg));
+ ptrA statusMessage(mir_utf8encodeT(msg));
TOX_ERR_SET_INFO error;
if (tox_self_set_status_message(tox, (uint8_t*)(char*)statusMessage, min(TOX_MAX_STATUS_MESSAGE_LENGTH, mir_strlen(statusMessage)), &error))
- {
debugLogA("CToxProto::SetAwayMsg: failed to set status status message %s (%d)", msg, error);
- }
}
return 0;
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 8d75753713..6fc1dc9c9c 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -6,9 +6,9 @@ struct CToxProto : public PROTO<CToxProto> friend CToxPasswordEditor;
friend CToxOptionsMain;
friend CToxOptionsNodeList;
+ friend CToxAudioCall;
public:
-
//////////////////////////////////////////////////////////////////////////////////////
//Ctors
@@ -241,8 +241,12 @@ private: void OnGotFriendAvatarInfo(FileTransferParam *transfer, const uint8_t *hash);
// multimedia
- std::map<int, int> calls;
+ HANDLE hAudioDialogs;
+ std::map<MCONTACT, int> calls;
+
static void OnFriendAudio(void *agent, int32_t callId, const int16_t *PCM, uint16_t size, void *arg);
+ INT_PTR __cdecl OnRecvAudioCall(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnAudioRing(WPARAM hContact, LPARAM lParam);
static void OnAvInvite(void*, int32_t callId, void *arg);
static void OnAvRinging(void*, int32_t callId, void *arg);
@@ -254,8 +258,6 @@ private: static void OnAvRequestTimeout(void*, int32_t callId, void *arg);
static void OnAvPeerTimeout(void*, int32_t callId, void *arg);
- INT_PTR __cdecl OnRecvAudioCall(WPARAM wParam, LPARAM lParam);
-
// utils
TOX_USER_STATUS MirandaToToxStatus(int status);
int ToxToMirandaStatus(TOX_USER_STATUS userstatus);
|