summaryrefslogtreecommitdiff
path: root/protocols/Tox
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox')
-rw-r--r--protocols/Tox/Tox_12.vcxproj1
-rw-r--r--protocols/Tox/Tox_12.vcxproj.filters3
-rw-r--r--protocols/Tox/res/resource.rc70
-rw-r--r--protocols/Tox/src/common.h1
-rw-r--r--protocols/Tox/src/resource.h18
-rw-r--r--protocols/Tox/src/tox_chatrooms.h2
-rw-r--r--protocols/Tox/src/tox_contacts.cpp18
-rw-r--r--protocols/Tox/src/tox_dialogs.h34
-rw-r--r--protocols/Tox/src/tox_multimedia.cpp301
-rw-r--r--protocols/Tox/src/tox_multimedia.h65
-rw-r--r--protocols/Tox/src/tox_options.cpp2
-rw-r--r--protocols/Tox/src/tox_profile.h19
-rw-r--r--protocols/Tox/src/tox_proto.h13
13 files changed, 348 insertions, 199 deletions
diff --git a/protocols/Tox/Tox_12.vcxproj b/protocols/Tox/Tox_12.vcxproj
index c9699a69cd..b2884d8412 100644
--- a/protocols/Tox/Tox_12.vcxproj
+++ b/protocols/Tox/Tox_12.vcxproj
@@ -214,6 +214,7 @@ copy docs\tox.ini "$(SolutionDir)$(Configuration)64\Plugins" /y</Command>
<ClInclude Include="src\tox_menus.h" />
<ClInclude Include="src\tox_multimedia.h" />
<ClInclude Include="src\tox_options.h" />
+ <ClInclude Include="src\tox_profile.h" />
<ClInclude Include="src\tox_proto.h" />
<ClInclude Include="src\tox_transfer.h" />
<ClInclude Include="src\version.h" />
diff --git a/protocols/Tox/Tox_12.vcxproj.filters b/protocols/Tox/Tox_12.vcxproj.filters
index 2960f9c774..7440c2c617 100644
--- a/protocols/Tox/Tox_12.vcxproj.filters
+++ b/protocols/Tox/Tox_12.vcxproj.filters
@@ -69,6 +69,9 @@
<ClInclude Include="src\tox_multimedia.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\tox_profile.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\tox_proto.cpp">
diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc
index 0e19a4ecbf..5009436e01 100644
--- a/protocols/Tox/res/resource.rc
+++ b/protocols/Tox/res/resource.rc
@@ -173,7 +173,7 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,156,97,50,14
END
-IDD_OPTIONS_AV DIALOGEX 0, 0, 310, 230
+IDD_OPTIONS_MULTIMEDIA DIALOGEX 0, 0, 310, 230
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -183,7 +183,6 @@ BEGIN
COMBOBOX IDC_AUDIOINPUT,12,26,138,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Audio output device",-1,12,42,65,8
COMBOBOX IDC_AUDIOOUTPUT,12,52,138,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CONTROL "Filter audio",IDC_AUDIOFILTER,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,157,28,51,10
LTEXT "Video input device",-1,15,68,59,8,NOT WS_VISIBLE
COMBOBOX IDC_COMBO_VIDEOINPUT,12,78,138,30,CBS_DROPDOWN | CBS_SORT | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
END
@@ -199,14 +198,49 @@ BEGIN
CONTROL "",IDC_CCLIST,"CListControl",WS_TABSTOP | 0x16f,7,7,176,145,WS_EX_CLIENTEDGE
END
-IDD_AUDIO DIALOGEX 0, 0, 119, 28
+IDD_CALL DIALOGEX 0, 0, 185, 119
STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOPMOST
-CAPTION "Audio call"
+CAPTION "Call"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "OK",IDOK,7,7,50,14
- PUSHBUTTON "Cancel",IDCANCEL,62,7,50,14
+ DEFPUSHBUTTON "End",IDCANCEL,67,97,50,15
+END
+
+IDD_CALL_RECEIVE DIALOGEX 0, 0, 239, 111
+STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST
+CAPTION "Incoming call"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Answer",IDOK,64,89,50,15
+ PUSHBUTTON "Reject",IDCANCEL,127,90,50,14
+ LTEXT "From:",IDC_STATIC,8,22,24,9,SS_CENTERIMAGE
+ CONTROL "",IDC_FROM,"Static",SS_SIMPLE | SS_NOPREFIX | WS_GROUP,41,23,191,9
+ LTEXT "Date:",IDC_STATIC,8,37,28,9,SS_CENTERIMAGE
+ CONTROL "",IDC_DATE,"Static",SS_SIMPLE | SS_NOPREFIX | WS_GROUP,41,36,191,9
+ CONTROL "&User menu",IDC_USERMENU,"MButtonClass",NOT WS_VISIBLE | WS_TABSTOP,178,7,16,14,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "User &details",IDC_DETAILS,"MButtonClass",NOT WS_VISIBLE | WS_TABSTOP,197,7,16,14,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "&History",IDC_HISTORY,"MButtonClass",NOT WS_VISIBLE | WS_TABSTOP,216,7,16,14,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,7,9,12,12
+ LTEXT "",IDC_NAME2,21,9,137,9,SS_NOPREFIX | SS_CENTERIMAGE
+END
+
+IDD_CALL_SEND DIALOGEX 0, 0, 239, 95
+STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST
+CAPTION "Outgoing call"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Call",IDOK,64,73,50,15
+ PUSHBUTTON "Cancel",IDCANCEL,127,74,50,14
+ LTEXT "To:",-1,8,22,24,9,SS_CENTERIMAGE
+ CONTROL "",IDC_FROM,"Static",SS_SIMPLE | SS_NOPREFIX | WS_GROUP,41,23,191,9
+ CONTROL "&User menu",IDC_USERMENU,"MButtonClass",NOT WS_VISIBLE | WS_TABSTOP,178,7,16,14,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "User &details",IDC_DETAILS,"MButtonClass",NOT WS_VISIBLE | WS_TABSTOP,197,7,16,14,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "&History",IDC_HISTORY,"MButtonClass",NOT WS_VISIBLE | WS_TABSTOP,216,7,16,14,WS_EX_NOACTIVATE | 0x10000000L
+ CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,7,9,12,12
+ LTEXT "",IDC_NAME2,21,9,137,9,SS_NOPREFIX | SS_CENTERIMAGE
END
@@ -272,7 +306,7 @@ BEGIN
HORZGUIDE, 67
END
- IDD_OPTIONS_AV, DIALOG
+ IDD_OPTIONS_MULTIMEDIA, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 303
@@ -295,12 +329,28 @@ BEGIN
HORZGUIDE, 158
END
- IDD_AUDIO, DIALOG
+ IDD_CALL, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 178
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 112
+ END
+
+ IDD_CALL_RECEIVE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 232
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 104
+ END
+
+ IDD_CALL_SEND, DIALOG
BEGIN
LEFTMARGIN, 7
- RIGHTMARGIN, 112
+ RIGHTMARGIN, 232
TOPMARGIN, 7
- BOTTOMMARGIN, 21
+ BOTTOMMARGIN, 88
END
END
#endif // APSTUDIO_INVOKED
diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h
index a470d0ae10..3e20832f55 100644
--- a/protocols/Tox/src/common.h
+++ b/protocols/Tox/src/common.h
@@ -53,6 +53,7 @@ struct CToxProto;
#include "tox_menus.h"
#include "tox_address.h"
#include "tox_dialogs.h"
+#include "tox_profile.h"
#include "tox_options.h"
#include "tox_transfer.h"
#include "tox_multimedia.h"
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h
index 5ffc062970..6bb9ffc284 100644
--- a/protocols/Tox/src/resource.h
+++ b/protocols/Tox/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by e:\Projects\C++\MirandaNG\protocols\Tox\res\resource.rc
+// Used by D:\Projects\MirandaNG\protocols\Tox\res\resource.rc
//
#define IDI_TOX 100
#define IDD_USER_INFO 101
@@ -11,25 +11,29 @@
#define IDD_OPTIONS_NODES 107
#define IDD_ADDNODE 108
#define IDD_NODE_EDITOR 109
-#define IDI_AUDIO_CALL 109
-#define IDD_OPTIONS_AV 110
-#define IDD_AUDIO 111
+#define IDD_OPTIONS_MULTIMEDIA 110
+#define IDD_CALL 111
#define IDI_AUDIO_END 112
#define IDI_AUDIO_RING 113
-#define IDI_ICON3 114
#define IDI_AUDIO_START 114
+#define IDI_AUDIO_CALL 115
#define IDD_CHATROOM_INVITE 172
#define IDC_CCLIST 173
#define IDC_EDITSCR 174
+#define IDD_CALL_RECEIVE 175
+#define IDD_CALL_SEND 176
#define IDC_TOXID 1001
#define IDC_CLIPBOARD 1002
#define IDC_SEARCH 1003
#define IDC_PASSWORD 1004
#define IDC_NAME 1005
+#define IDC_FROM 1005
#define IDC_GROUP 1006
+#define IDC_DATE 1006
#define IDC_ENABLE_UDP 1007
#define IDC_ENABLE_IPV6 1008
#define IDC_PROFILE_EXPORT 1009
+#define IDC_NAME2 1009
#define IDC_DNS_ID 1010
#define IDC_PROFILE_NEW 1011
#define IDC_SAVEPERMANENT 1012
@@ -47,6 +51,10 @@
#define IDC_AUDIOOUTPUT 1022
#define IDC_AUDIOFILTER 1023
#define IDC_COMBO_VIDEOINPUT 1024
+#define IDC_DETAILS 1069
+#define IDC_USERMENU 1071
+#define IDC_HISTORY 1080
+#define IDC_PROTOCOL 1580
// Next default values for new objects
//
diff --git a/protocols/Tox/src/tox_chatrooms.h b/protocols/Tox/src/tox_chatrooms.h
index 419b26bacd..0f51a7391e 100644
--- a/protocols/Tox/src/tox_chatrooms.h
+++ b/protocols/Tox/src/tox_chatrooms.h
@@ -1,8 +1,6 @@
#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_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp
index 3fa7c26580..838a9fde7e 100644
--- a/protocols/Tox/src/tox_contacts.cpp
+++ b/protocols/Tox/src/tox_contacts.cpp
@@ -69,7 +69,7 @@ MCONTACT CToxProto::GetContact(const char *pubKey)
return hContact;
}
-MCONTACT CToxProto::AddContact(const char *address, const std::tstring &dnsId, bool isTemporary)
+MCONTACT CToxProto::AddContact(const char *address, const TCHAR *dnsId, bool isTemporary)
{
MCONTACT hContact = GetContact(address);
if (!hContact)
@@ -79,9 +79,9 @@ MCONTACT CToxProto::AddContact(const char *address, const std::tstring &dnsId, b
setString(hContact, TOX_SETTINGS_ID, address);
- if (!dnsId.empty())
+ if (dnsId && mir_tstrlen(dnsId))
{
- setTString(hContact, TOX_SETTINGS_DNS, dnsId.c_str());
+ setTString(hContact, TOX_SETTINGS_DNS, dnsId);
}
DBVARIANT dbv;
@@ -196,10 +196,11 @@ INT_PTR CToxProto::OnGrantAuth(WPARAM hContact, LPARAM)
{
if (!IsOnline())
{
- return -1;
+ // TODO: warn
+ return 0;
}
- ToxBinAddress pubKey(ptrA(getStringA(hContact, TOX_SETTINGS_ID)), TOX_PUBLIC_KEY_SIZE * 2);
+ ToxBinAddress pubKey(ptrA(getStringA(hContact, TOX_SETTINGS_ID)));
TOX_ERR_FRIEND_ADD error;
tox_friend_add_norequest(tox, pubKey, &error);
if (error != TOX_ERR_FRIEND_ADD_OK)
@@ -209,10 +210,12 @@ INT_PTR CToxProto::OnGrantAuth(WPARAM hContact, LPARAM)
}
// trim address to public key
- setString(hContact, TOX_SETTINGS_ID, pubKey.ToHex());
+ // setString(hContact, TOX_SETTINGS_ID, pubKey.ToHex());
db_unset(hContact, "CList", "NotOnList");
delSetting(hContact, "Grant");
+ SaveToxProfile();
+
return 0;
}
@@ -220,7 +223,8 @@ int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM)
{
if (!IsOnline())
{
- return -1;
+ // TODO: warn
+ return 0;
}
if (!isChatRoom(hContact))
diff --git a/protocols/Tox/src/tox_dialogs.h b/protocols/Tox/src/tox_dialogs.h
index c78c7a8943..d72c83eb92 100644
--- a/protocols/Tox/src/tox_dialogs.h
+++ b/protocols/Tox/src/tox_dialogs.h
@@ -1,21 +1,33 @@
#ifndef _TOX_DIALOGS_H_
#define _TOX_DIALOGS_H_
-typedef CProtoDlgBase<CToxProto> CToxDlgBase;
-
-class CToxPasswordEditor : public CToxDlgBase
+class CCtrlLabel : public CCtrlData
{
-private:
- CCtrlEdit password;
- CCtrlCheck savePermanently;
+ typedef CCtrlData CSuper;
- CCtrlButton ok;
+public:
+ CCtrlLabel(CDlgBase *dlg, int ctrlId) :
+ CSuper(dlg, ctrlId)
+ {
+ }
-protected:
- void OnOk(CCtrlButton*);
+ virtual void OnInit()
+ {
+ CSuper::OnInit();
+ OnReset();
+ }
-public:
- CToxPasswordEditor(CToxProto *proto);
+ virtual void OnReset()
+ {
+ if (GetDataType() == DBVT_TCHAR)
+ SetText(LoadText());
+ else if (GetDataType() != DBVT_DELETED)
+ SetInt(LoadInt());
+ }
};
+///////////////////////////////////////////////
+
+typedef CProtoDlgBase<CToxProto> CToxDlgBase;
+
#endif //_TOX_DIALOGS_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp
index 729a75f17f..fa08e66ea5 100644
--- a/protocols/Tox/src/tox_multimedia.cpp
+++ b/protocols/Tox/src/tox_multimedia.cpp
@@ -1,18 +1,31 @@
#include "common.h"
-/* AUDIO RECEIVING */
+CToxCallDlgBase::CToxCallDlgBase(CToxProto *proto, int idDialog, MCONTACT hContact) :
+ CToxDlgBase(proto, idDialog, false), hContact(hContact)
+{
+}
-CToxAudioCall::CToxAudioCall(CToxProto *proto, MCONTACT hContact) :
-CToxDlgBase(proto, IDD_AUDIO, false),
-hContact(hContact), isCallStarted(false),
-ok(this, IDOK), cancel(this, IDCANCEL)
+void CToxCallDlgBase::OnInitDialog()
{
- m_autoClose = CLOSE_ON_CANCEL;
- ok.OnClick = Callback(this, &CToxAudioCall::OnOk);
- cancel.OnClick = Callback(this, &CToxAudioCall::OnCancel);
+ Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, typeid(this).name());
+}
+
+void CToxCallDlgBase::OnClose()
+{
+ //WindowList_Remove(m_proto->hAudioDialogs, m_hwnd);
+ Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, typeid(this).name());
+}
+
+INT_PTR CToxCallDlgBase::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ if (msg == WM_CALL_END)
+ if (wParam == hContact)
+ Close();
+
+ return CToxDlgBase::DlgProc(msg, wParam, lParam);
}
-void CToxAudioCall::SetIcon(const char *name)
+void CToxCallDlgBase::SetIcon(const char *name)
{
char iconName[100];
mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", MODULE, name);
@@ -20,34 +33,138 @@ void CToxAudioCall::SetIcon(const char *name)
SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon(iconName, 32));
}
-void CToxAudioCall::OnInitDialog()
+void CToxCallDlgBase::SetTitle(const TCHAR *title)
{
- Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "AudioCallWindow");
+ SetWindowText(m_hwnd, title);
}
-void CToxAudioCall::OnClose()
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+CToxIncomingCall::CToxIncomingCall(CToxProto *proto, MCONTACT hContact) :
+ CToxCallDlgBase(proto, IDD_CALL_RECEIVE, hContact),
+ from(this, IDC_FROM), date(this, IDC_DATE),
+ answer(this, IDOK), reject(this, IDCANCEL)
{
- WindowList_Remove(m_proto->hAudioDialogs, m_hwnd);
- Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "AudioCallWindow");
+ answer.OnClick = Callback(this, &CToxIncomingCall::OnAnswer);
}
-INT_PTR CToxAudioCall::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+void CToxIncomingCall::OnInitDialog()
{
- if (msg == WM_AUDIO_END)
- if (wParam == hContact)
- Close();
+ TCHAR *nick = pcli->pfnGetContactDisplayName(hContact, 0);
+ from.SetText(nick);
- return CToxDlgBase::DlgProc(msg, wParam, lParam);
+ TCHAR title[MAX_PATH];
+ mir_sntprintf(title, SIZEOF(title), TranslateT("Incoming call from %s"), nick);
+ SetTitle(title);
+ SetIcon("audio_ring");
+}
+
+void CToxIncomingCall::OnClose()
+{
+ toxav_reject(m_proto->toxAv, m_proto->calls[hContact], NULL);
+}
+
+void CToxIncomingCall::OnAnswer(CCtrlBase*)
+{
+ ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
+ if (cSettings == NULL)
+ {
+ Close();
+ return;
+ }
+
+ if (toxav_answer(m_proto->toxAv, m_proto->calls[hContact], cSettings) == TOX_ERROR)
+ {
+ m_proto->debugLogA(__FUNCTION__": failed to start call");
+ Close();
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+CToxOutgoingCall::CToxOutgoingCall(CToxProto *proto, MCONTACT hContact) :
+ CToxCallDlgBase(proto, IDD_CALL_SEND, hContact),
+ to(this, IDC_FROM), call(this, IDOK), cancel(this, IDCANCEL)
+{
+ m_autoClose = CLOSE_ON_CANCEL;
+ call.OnClick = Callback(this, &CToxOutgoingCall::OnCall);
+ cancel.OnClick = Callback(this, &CToxOutgoingCall::OnCancel);
+}
+
+void CToxOutgoingCall::OnInitDialog()
+{
+ TCHAR *nick = pcli->pfnGetContactDisplayName(hContact, 0);
+ to.SetText(nick);
+
+ TCHAR title[MAX_PATH];
+ mir_sntprintf(title, SIZEOF(title), TranslateT("Outgoing call to %s"), nick);
+ SetTitle(title);
+ SetIcon("audio_end");
}
-void CToxAudioCall::OnStartCall()
+void CToxOutgoingCall::OnCall(CCtrlBase*)
+{
+ ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
+ if (cSettings == NULL)
+ {
+ Close();
+ return;
+ }
+
+ int friendNumber = m_proto->GetToxFriendNumber(hContact);
+ if (friendNumber == UINT32_MAX)
+ {
+ Close();
+ return;
+ }
+
+ int32_t callId;
+ if (toxav_call(m_proto->toxAv, &callId, friendNumber, cSettings, 10) == TOX_ERROR)
+ {
+ m_proto->debugLogA(__FUNCTION__": failed to start outgoing call");
+ return;
+ }
+ m_proto->calls[hContact] = callId;
+
+ char *message = mir_utf8encodeT(TranslateT("Outgoing call"));
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = m_proto->m_szModuleName;
+ dbei.timestamp = time(NULL);
+ dbei.eventType = DB_EVENT_AUDIO_CALL;
+ dbei.flags = DBEF_UTF;
+ dbei.pBlob = (PBYTE)message;
+ dbei.cbSize = mir_strlen(message);
+ db_event_add(hContact, &dbei);
+
+ call.Enable(FALSE);
+ SetIcon("audio_call");
+}
+
+void CToxOutgoingCall::OnCancel(CCtrlBase*)
+{
+ if (!call.Enabled())
+ toxav_cancel(m_proto->toxAv, m_proto->calls[hContact], 0, NULL);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+CToxCallDialog::CToxCallDialog(CToxProto *proto, MCONTACT hContact) :
+ CToxCallDlgBase(proto, IDD_CALL, hContact), end(this, IDCANCEL)
+{
+}
+
+void CToxCallDialog::OnInitDialog()
{
- ok.Enable(FALSE);
- isCallStarted = true;
SetIcon("audio_start");
}
-//
+void CToxCallDialog::OnClose()
+{
+ toxav_hangup(m_proto->toxAv, m_proto->calls[hContact]);
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
ToxAvCSettings* CToxProto::GetAudioCSettings()
{
@@ -83,7 +200,7 @@ ToxAvCSettings* CToxProto::GetAudioCSettings()
cSettings->audio_bitrate = 8 * 1000;
cSettings->audio_sample_rate = 48000;
}
- /*else if ((wic.dwFormats & WAVE_FORMAT_4S16) || (wic.dwFormats & WAVE_FORMAT_4M16))
+ else if ((wic.dwFormats & WAVE_FORMAT_4S16) || (wic.dwFormats & WAVE_FORMAT_4M16))
{
cSettings->audio_bitrate = 16 * 1000;
cSettings->audio_sample_rate = 24000;
@@ -112,7 +229,7 @@ ToxAvCSettings* CToxProto::GetAudioCSettings()
{
cSettings->audio_bitrate = 8 * 1000;
cSettings->audio_sample_rate = 8000;
- }*/
+ }
else
{
debugLogA(__FUNCTION__": failed to parse input device caps");
@@ -123,43 +240,9 @@ ToxAvCSettings* CToxProto::GetAudioCSettings()
return cSettings;
}
-// incoming call flow
-
-CToxIncomingAudioCall::CToxIncomingAudioCall(CToxProto *proto, MCONTACT hContact) :
-CToxAudioCall(proto, hContact)
-{
-}
-
-void CToxIncomingAudioCall::OnInitDialog()
-{
- SetIcon("audio_ring");
- CToxAudioCall::OnInitDialog();
-}
-
-void CToxIncomingAudioCall::OnOk(CCtrlBase*)
-{
- ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
- if (cSettings == NULL)
- {
- Close();
- return;
- }
-
- if (toxav_answer(m_proto->toxAv, m_proto->calls[hContact], cSettings) == TOX_ERROR)
- {
- m_proto->debugLogA(__FUNCTION__": failed to start call");
- Close();
- }
-}
-
-void CToxIncomingAudioCall::OnCancel(CCtrlBase*)
-{
- if (!isCallStarted)
- toxav_reject(m_proto->toxAv, m_proto->calls[hContact], NULL);
- else
- toxav_hangup(m_proto->toxAv, m_proto->calls[hContact]);
-}
+/* AUDIO RECEIVING */
+// incoming call flow
void CToxProto::OnAvInvite(void*, int32_t callId, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
@@ -244,9 +327,9 @@ INT_PTR CToxProto::OnRecvAudioCall(WPARAM hContact, LPARAM lParam)
INT_PTR CToxProto::OnAudioRing(WPARAM wParam, LPARAM lParam)
{
CLISTEVENT *cle = (CLISTEVENT*)lParam;
- CToxAudioCall *audioCall = new CToxIncomingAudioCall(this, cle->hContact);
- audioCall->Show();
- WindowList_Add(hAudioDialogs, audioCall->GetHwnd(), cle->hContact);
+ CDlgBase *incomingCallDlg = new CToxIncomingCall(this, cle->hContact);
+ incomingCallDlg->Show();
+ WindowList_Add(hAudioDialogs, incomingCallDlg->GetHwnd(), cle->hContact);
return 0;
}
@@ -286,73 +369,17 @@ void CToxProto::OnAvCancel(void*, int32_t callId, void *arg)
dbei.cbSize = mir_strlen(message);
db_event_add(hContact, &dbei);
- WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
+ WindowList_Broadcast(proto->hAudioDialogs, WM_CALL_END, hContact, 0);
}
/* AUDIO SENDING */
// outcoming audio flow
-CToxOutgoingAudioCall::CToxOutgoingAudioCall(CToxProto *proto, MCONTACT hContact) :
-CToxAudioCall(proto, hContact)
-{
-}
-
-void CToxOutgoingAudioCall::OnInitDialog()
-{
- SetIcon("audio_end");
- CToxAudioCall::OnInitDialog();
-}
-
-void CToxOutgoingAudioCall::OnOk(CCtrlBase*)
-{
- int32_t callId;
- int friendNumber = m_proto->GetToxFriendNumber(hContact);
- if (friendNumber == UINT32_MAX)
- {
- Close();
- return;
- }
-
- ToxAvCSettings *cSettings = m_proto->GetAudioCSettings();
- if (cSettings == NULL)
- {
- Close();
- return;
- }
-
- if (toxav_call(m_proto->toxAv, &callId, friendNumber, cSettings, 10) == TOX_ERROR)
- {
- m_proto->debugLogA(__FUNCTION__": failed to start outgoing call");
- return;
- }
- m_proto->calls[hContact] = callId;
- SetIcon("audio_call");
-
- char *message = mir_utf8encodeT(TranslateT("Outgoing call"));
-
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.szModule = m_proto->m_szModuleName;
- dbei.timestamp = time(NULL);
- dbei.eventType = DB_EVENT_AUDIO_CALL;
- dbei.flags = DBEF_UTF;
- dbei.pBlob = (PBYTE)message;
- dbei.cbSize = mir_strlen(message);
- db_event_add(hContact, &dbei);
-}
-
-void CToxOutgoingAudioCall::OnCancel(CCtrlBase*)
-{
- if (!isCallStarted)
- toxav_cancel(m_proto->toxAv, m_proto->calls[hContact], 0, NULL);
- else
- toxav_hangup(m_proto->toxAv, m_proto->calls[hContact]);
-}
-
INT_PTR CToxProto::OnSendAudioCall(WPARAM hContact, LPARAM)
{
- CToxAudioCall *audioCall = new CToxOutgoingAudioCall(this, hContact);
- audioCall->Show();
- WindowList_Add(hAudioDialogs, audioCall->GetHwnd(), hContact);
+ CDlgBase *outgoingCallDlg = new CToxOutgoingCall(this, hContact);
+ outgoingCallDlg->Show();
+ WindowList_Add(hAudioDialogs, outgoingCallDlg->GetHwnd(), hContact);
return 0;
}
@@ -388,7 +415,7 @@ void CToxProto::OnAvReject(void*, int32_t callId, void *arg)
dbei.cbSize = mir_strlen(message);
db_event_add(hContact, &dbei);
- WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
+ WindowList_Broadcast(proto->hAudioDialogs, WM_CALL_END, hContact, 0);
}
void CToxProto::OnAvCallTimeout(void*, int32_t callId, void *arg)
@@ -422,7 +449,7 @@ void CToxProto::OnAvCallTimeout(void*, int32_t callId, void *arg)
dbei.cbSize = mir_strlen(message);
db_event_add(hContact, &dbei);
- WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
+ WindowList_Broadcast(proto->hAudioDialogs, WM_CALL_END, hContact, 0);
}
/* --- */
@@ -487,9 +514,12 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg)
return;
}
- //HWND hwnd = WindowList_Find(proto->hAudioDialogs, hContact);
- //CToxAudioCall *audioCall = (CToxAudioCall*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- //audioCall->OnStartCall();
+ if (toxav_prepare_transmission(proto->toxAv, callId, false) == TOX_ERROR)
+ {
+ proto->debugLogA(__FUNCTION__": failed to prepare audio transmition");
+ toxav_hangup(proto->toxAv, callId);
+ return;
+ }
char *message = mir_utf8encodeT(TranslateT("Call started"));
@@ -502,12 +532,9 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg)
dbei.cbSize = mir_strlen(message);
db_event_add(hContact, &dbei);
- if (toxav_prepare_transmission(proto->toxAv, callId, false) == TOX_ERROR)
- {
- proto->debugLogA(__FUNCTION__": failed to prepare audio transmition");
- toxav_hangup(proto->toxAv, callId);
- return;
- }
+ CDlgBase *callDlg = new CToxCallDialog(proto, hContact);
+ callDlg->Show();
+ WindowList_Add(proto->hAudioDialogs, callDlg->GetHwnd(), hContact);
}
void CToxProto::OnAvEnd(void*, int32_t callId, void *arg)
@@ -542,7 +569,7 @@ void CToxProto::OnAvEnd(void*, int32_t callId, void *arg)
dbei.cbSize = mir_strlen(message);
db_event_add(hContact, &dbei);
- WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
+ WindowList_Broadcast(proto->hAudioDialogs, WM_CALL_END, hContact, 0);
}
void CToxProto::OnAvPeerTimeout(void*, int32_t callId, void *arg)
@@ -580,7 +607,7 @@ void CToxProto::OnAvPeerTimeout(void*, int32_t callId, void *arg)
dbei.cbSize = mir_strlen(message);
db_event_add(hContact, &dbei);
- WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
+ WindowList_Broadcast(proto->hAudioDialogs, WM_CALL_END, hContact, 0);
toxav_kill_transmission(proto->toxAv, callId);
}
diff --git a/protocols/Tox/src/tox_multimedia.h b/protocols/Tox/src/tox_multimedia.h
index f69430a142..68f35bef56 100644
--- a/protocols/Tox/src/tox_multimedia.h
+++ b/protocols/Tox/src/tox_multimedia.h
@@ -1,53 +1,78 @@
#ifndef _TOX_MULTIMEDIA_H_
#define _TOX_MULTIMEDIA_H_
-class CToxAudioCall : public CToxDlgBase
+#define WM_CALL_END (WM_PROTO_LAST + 100)
+
+class CToxCallDlgBase : public CToxDlgBase
{
protected:
MCONTACT hContact;
- bool isCallStarted;
-
- CCtrlButton ok;
- CCtrlButton cancel;
-
- void SetIcon(const char *name);
virtual void OnInitDialog();
- void OnClose();
+ virtual void OnClose();
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
- virtual void OnOk(CCtrlBase*) = 0;
- virtual void OnCancel(CCtrlBase*) = 0;
+ void SetIcon(const char *name);
+ void SetTitle(const TCHAR *title);
public:
- CToxAudioCall(CToxProto *proto, MCONTACT hContact);
-
- void OnStartCall();
+ CToxCallDlgBase(CToxProto *proto, int idDialog, MCONTACT hContact);
};
-class CToxIncomingAudioCall : public CToxAudioCall
+///////////////////////////////////////////////
+
+class CToxIncomingCall : public CToxCallDlgBase
{
+private:
+ CCtrlLabel from;
+ CCtrlLabel date;
+
+ CCtrlButton answer;
+ CCtrlButton reject;
+
protected:
void OnInitDialog();
+ void OnClose();
- void OnOk(CCtrlBase*);
- void OnCancel(CCtrlBase*);
+ void OnAnswer(CCtrlBase*);
public:
- CToxIncomingAudioCall(CToxProto *proto, MCONTACT hContact);
+ CToxIncomingCall(CToxProto *proto, MCONTACT hContact);
};
-class CToxOutgoingAudioCall : public CToxAudioCall
+///////////////////////////////////////////////
+
+class CToxOutgoingCall : public CToxCallDlgBase
{
+private:
+ CCtrlLabel to;
+ CCtrlButton call;
+ CCtrlButton cancel;
+
protected:
void OnInitDialog();
+ //void OnClose();
- void OnOk(CCtrlBase*);
+ void OnCall(CCtrlBase*);
void OnCancel(CCtrlBase*);
public:
- CToxOutgoingAudioCall(CToxProto *proto, MCONTACT hContact);
+ CToxOutgoingCall(CToxProto *proto, MCONTACT hContact);
+};
+
+///////////////////////////////////////////////
+
+class CToxCallDialog : public CToxCallDlgBase
+{
+protected:
+ CCtrlButton end;
+
+ void OnInitDialog();
+ void OnClose();
+
+public:
+ CToxCallDialog(CToxProto *proto, MCONTACT hContact);
};
#endif //_TOX_MULTIMEDIA_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index d80e08370e..6023ea62dd 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -196,7 +196,7 @@ void CToxOptionsMain::OnApply()
/////////////////////////////////////////////////////////////////////////////////
CToxOptionsMultimedia::CToxOptionsMultimedia(CToxProto *proto)
- : CToxDlgBase(proto, IDD_OPTIONS_AV, false),
+ : CToxDlgBase(proto, IDD_OPTIONS_MULTIMEDIA, false),
m_audioInput(this, IDC_AUDIOINPUT),
m_audioOutput(this, IDC_AUDIOOUTPUT)
{
diff --git a/protocols/Tox/src/tox_profile.h b/protocols/Tox/src/tox_profile.h
new file mode 100644
index 0000000000..796f264d5b
--- /dev/null
+++ b/protocols/Tox/src/tox_profile.h
@@ -0,0 +1,19 @@
+#ifndef _TOX_PROFILE_H_
+#define _TOX_PROFILE_H_
+
+class CToxPasswordEditor : public CToxDlgBase
+{
+private:
+ CCtrlEdit password;
+ CCtrlCheck savePermanently;
+
+ CCtrlButton ok;
+
+protected:
+ void OnOk(CCtrlButton*);
+
+public:
+ CToxPasswordEditor(CToxProto *proto);
+};
+
+#endif //_TOX_PROFILE_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index 2f15e16477..946dcb9039 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -6,9 +6,10 @@ struct CToxProto : public PROTO<CToxProto>
friend CToxPasswordEditor;
friend CToxOptionsMain;
friend CToxOptionsNodeList;
- friend CToxAudioCall;
- friend CToxIncomingAudioCall;
- friend CToxOutgoingAudioCall;
+ friend CToxCallDlgBase;
+ friend CToxIncomingCall;
+ friend CToxOutgoingCall;
+ friend CToxCallDialog;
public:
//////////////////////////////////////////////////////////////////////////////////////
@@ -153,7 +154,7 @@ private:
MCONTACT GetContact(const int friendNumber);
MCONTACT GetContact(const char *pubKey);
- MCONTACT AddContact(const char *address, const std::tstring &dnsId, bool isTemporary = false);
+ MCONTACT AddContact(const char *address, const TCHAR *dnsId = NULL, bool isTemporary = false);
MCONTACT GetContactFromAuthEvent(MEVENT hEvent);
@@ -173,8 +174,8 @@ private:
static void OnConnectionStatusChanged(Tox *tox, uint32_t friendNumber, TOX_CONNECTION status, void *arg);
// contacts search
- void __cdecl SearchByNameAsync(void* arg);
- void __cdecl SearchFailedAsync(void* arg);
+ void __cdecl SearchByNameAsync(void *arg);
+ void __cdecl SearchFailedAsync(void *arg);
static INT_PTR CALLBACK SearchDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);