summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-02-23 19:54:57 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-02-23 19:54:57 +0000
commit326215e3557c3fdd0595d585cb9f645edeffedb9 (patch)
tree6bc8d24eaf4966d47fcfea86493f3830beacc454 /protocols
parenta142d261af1f740156898be29c3724b8a517a77a (diff)
Tox: group chats are disabled, untill it won't be rewritten in tox core
git-svn-id: http://svn.miranda-ng.org/main/trunk@12253 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Tox/Tox_12.vcxproj1
-rw-r--r--protocols/Tox/Tox_12.vcxproj.filters3
-rw-r--r--protocols/Tox/src/api_groupchats.cpp5
-rw-r--r--protocols/Tox/src/common.h3
-rw-r--r--protocols/Tox/src/tox_accounts.cpp2
-rw-r--r--protocols/Tox/src/tox_chatrooms.cpp76
-rw-r--r--protocols/Tox/src/tox_network.cpp1
-rw-r--r--protocols/Tox/src/tox_proto.cpp8
-rw-r--r--protocols/Tox/src/tox_proto.h4
9 files changed, 61 insertions, 42 deletions
diff --git a/protocols/Tox/Tox_12.vcxproj b/protocols/Tox/Tox_12.vcxproj
index 6c1124e464..e1503116bd 100644
--- a/protocols/Tox/Tox_12.vcxproj
+++ b/protocols/Tox/Tox_12.vcxproj
@@ -203,6 +203,7 @@
<ClInclude Include="src\common.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\tox_address.h" />
+ <ClInclude Include="src\tox_chatrooms.h" />
<ClInclude Include="src\tox_dns.h" />
<ClInclude Include="src\tox_options.h" />
<ClInclude Include="src\tox_proto.h" />
diff --git a/protocols/Tox/Tox_12.vcxproj.filters b/protocols/Tox/Tox_12.vcxproj.filters
index 4361341f01..4a3b598362 100644
--- a/protocols/Tox/Tox_12.vcxproj.filters
+++ b/protocols/Tox/Tox_12.vcxproj.filters
@@ -54,6 +54,9 @@
<ClInclude Include="src\tox_options.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="src\tox_chatrooms.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\tox_proto.cpp">
diff --git a/protocols/Tox/src/api_groupchats.cpp b/protocols/Tox/src/api_groupchats.cpp
index a84c4eaab9..eb8b01603d 100644
--- a/protocols/Tox/src/api_groupchats.cpp
+++ b/protocols/Tox/src/api_groupchats.cpp
@@ -39,11 +39,12 @@ int tox_del_groupchat(Tox *tox, int groupnumber)
int tox_group_peer_pubkey(const Tox *tox, int groupnumber, int peernumber, uint8_t *pk)
{
-}
+}*/
int tox_invite_friend(Tox *tox, int32_t friendnumber, int groupnumber)
{
-}*/
+ return CreateFunction<int(*)(Tox*, int32_t, int)>(__FUNCTION__)(tox, friendnumber, groupnumber);
+}
int tox_join_groupchat(Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length)
{
diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h
index 9d4b7dfedc..d450211fe8 100644
--- a/protocols/Tox/src/common.h
+++ b/protocols/Tox/src/common.h
@@ -39,11 +39,14 @@
#include <toxencryptsave.h>
#include <toxav.h>
+struct CToxProto;
+
#include "version.h"
#include "resource.h"
#include "tox_address.h"
#include "tox_options.h"
#include "tox_transfer.h"
+#include "tox_chatrooms.h"
#include "tox_proto.h"
extern HINSTANCE g_hInstance;
diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp
index c2d84e9515..ce435043d7 100644
--- a/protocols/Tox/src/tox_accounts.cpp
+++ b/protocols/Tox/src/tox_accounts.cpp
@@ -28,7 +28,7 @@ int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
HookProtoEvent(ME_USERINFO_INITIALISE, &CToxProto::OnUserInfoInit);
HookProtoEvent(ME_MSG_PRECREATEEVENT, &CToxProto::OnPreCreateMessage);
- InitGroupChatModule();
+ //InitGroupChatModule();
return 0;
}
diff --git a/protocols/Tox/src/tox_chatrooms.cpp b/protocols/Tox/src/tox_chatrooms.cpp
index 684cac1246..f17a5869a5 100644
--- a/protocols/Tox/src/tox_chatrooms.cpp
+++ b/protocols/Tox/src/tox_chatrooms.cpp
@@ -119,17 +119,39 @@ INT_PTR CToxProto::OnCreateChatRoom(WPARAM, LPARAM)
{
return 1;
}
- int groupNumber = tox_add_groupchat(tox);
- if (groupNumber == TOX_ERROR)
- {
- return 1;
- }
- MCONTACT hContact = AddChatRoom(groupNumber);
- if (!hContact)
+
+ ChatRoomInviteParam param = { this };
+
+ if (DialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_CHATROOM_INVITE),
+ NULL,
+ CToxProto::ChatRoomInviteProc,
+ (LPARAM)&param) == IDOK && !param.invitedContacts.empty())
{
- return 1;
+ int groupNumber = tox_add_groupchat(tox);
+ if (groupNumber == TOX_ERROR)
+ {
+ return 1;
+ }
+ for (std::vector<MCONTACT>::iterator it = param.invitedContacts.begin(); it != param.invitedContacts.end(); ++it)
+ {
+ ToxBinAddress pubKey = ptrA(getStringA(*it, TOX_SETTINGS_ID));
+ int32_t friendNumber = tox_get_friend_number(tox, pubKey);
+ if (friendNumber == TOX_ERROR || tox_invite_friend(tox, friendNumber, groupNumber) == TOX_ERROR)
+ {
+ return 1;
+ }
+ }
+ MCONTACT hContact = AddChatRoom(groupNumber);
+ if (!hContact)
+ {
+ return 1;
+ }
+ return 0;
}
- return 0;
+
+ return 1;
}
void CToxProto::InitGroupChatModule()
@@ -190,7 +212,8 @@ void CToxProto::OnGroupChatInvite(Tox *tox, int32_t friendNumber, uint8_t type,
void CToxProto::ChatValidateContact(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact)
{
- //if (mir_strcmpi(GetContactProto(hContact), m_szModuleName) == 0 && !isChatRoom(hContact))
+ bool isProtoContact = mir_strcmpi(GetContactProto(hContact), m_szModuleName) == 0;
+ if (isProtoContact && !isChatRoom(hContact))
{
if (std::find(contacts.begin(), contacts.end(), hContact) != contacts.end())
{
@@ -205,7 +228,7 @@ void CToxProto::ChatPrepare(HWND hwndList, const std::vector<MCONTACT> &contacts
{
if (hContact == NULL)
{
- hContact = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
+ hContact = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
}
while (hContact)
{
@@ -259,17 +282,17 @@ std::vector<MCONTACT> CToxProto::GetInvitedContacts(HWND hwndList, MCONTACT hCon
INT_PTR CALLBACK CToxProto::ChatRoomInviteProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST);
- CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ ChatRoomInviteParam *param = (ChatRoomInviteParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- proto = (CToxProto*)lParam;
+ param = (ChatRoomInviteParam*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
{
- HWND hwndClist = GetDlgItem(hwndDlg, IDC_CCLIST);
- SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE);
+ //HWND hwndClist = GetDlgItem(hwndDlg, IDC_CCLIST);
+ //SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE);
}
}
break;
@@ -288,15 +311,13 @@ INT_PTR CALLBACK CToxProto::ChatRoomInviteProc(HWND hwndDlg, UINT msg, WPARAM wP
case CLN_NEWCONTACT:
if ((nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
{
- std::vector<MCONTACT> invitedContacts;
- proto->ChatValidateContact(nmc->hdr.hwndFrom, invitedContacts, (MCONTACT)nmc->hItem);
+ param->proto->ChatValidateContact(nmc->hdr.hwndFrom, param->invitedContacts, (MCONTACT)nmc->hItem);
}
break;
case CLN_LISTREBUILT:
{
- std::vector<MCONTACT> invitedContacts;
- proto->ChatPrepare(nmc->hdr.hwndFrom, invitedContacts);
+ param->proto->ChatPrepare(nmc->hdr.hwndFrom, param->invitedContacts);
}
break;
}
@@ -308,19 +329,10 @@ INT_PTR CALLBACK CToxProto::ChatRoomInviteProc(HWND hwndDlg, UINT msg, WPARAM wP
switch (LOWORD(wParam))
{
case IDOK:
- {
- std::vector<MCONTACT> invitedContacts = GetInvitedContacts(hwndList);
- if (invitedContacts.empty())
- {
- proto->ShowNotification(TranslateT("You did not select any contact"));
- }
- else
- {
- //SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- EndDialog(hwndDlg, IDOK);
- }
- }
- break;
+ //SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ param->invitedContacts = param->proto->GetInvitedContacts(hwndList);
+ EndDialog(hwndDlg, IDOK);
+ break;
case IDCANCEL:
EndDialog(hwndDlg, IDCANCEL);
diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp
index ac39e053ff..694d966753 100644
--- a/protocols/Tox/src/tox_network.cpp
+++ b/protocols/Tox/src/tox_network.cpp
@@ -97,7 +97,6 @@ void CToxProto::TryConnect()
debugLogA("CToxProto::PollingThread: successfuly connected to DHT");
ForkThread(&CToxProto::LoadFriendList, NULL);
- ForkThread(&CToxProto::LoadChatRoomList, NULL);
m_iStatus = m_iDesiredStatus;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus);
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index 117c7f8ec9..1a22017a6a 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -49,8 +49,8 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) :
CreateProtoService(PS_SETMYNICKNAME, &CToxProto::SetMyNickname);
// chat rooms
- CreateProtoService(PS_JOINCHAT, &CToxProto::OnJoinChatRoom);
- CreateProtoService(PS_LEAVECHAT, &CToxProto::OnLeaveChatRoom);
+ //CreateProtoService(PS_JOINCHAT, &CToxProto::OnJoinChatRoom);
+ //CreateProtoService(PS_LEAVECHAT, &CToxProto::OnLeaveChatRoom);
// transfers
transfers = new CTransferList();
@@ -290,8 +290,8 @@ int __cdecl CToxProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM
case EV_PROTO_ONCONTACTDELETED:
return OnContactDeleted(wParam, lParam);
- case EV_PROTO_ONMENU:
- return OnInitStatusMenu();
+ //case EV_PROTO_ONMENU:
+ // return OnInitStatusMenu();
}
return 1;
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index 0ff5060f14..66225cc626 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -178,8 +178,8 @@ private:
static void OnGroupChatInvite(Tox *tox, int32_t friendNumber, uint8_t type, const uint8_t *data, const uint16_t length, void *arg);
- static void ChatValidateContact(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact = NULL);
- static void ChatPrepare(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact = NULL);
+ void ChatValidateContact(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact = NULL);
+ void ChatPrepare(HWND hwndList, const std::vector<MCONTACT> &contacts, MCONTACT hContact = NULL);
static std::vector<MCONTACT> GetInvitedContacts(HWND hwndList, MCONTACT hContact = NULL);
static INT_PTR CALLBACK ChatRoomInviteProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);