summaryrefslogtreecommitdiff
path: root/protocols/Tox/src
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-08-07 13:49:07 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-08-07 13:49:07 +0000
commit84f85ceac0f993be95dda89584749ea59fe5b8e7 (patch)
tree2231a79773b63436a9586f6cf1f35f1893c80793 /protocols/Tox/src
parentc56192dd999c079ebd935a6736315de3a5d60a05 (diff)
Tox added from branch
git-svn-id: http://svn.miranda-ng.org/main/trunk@10115 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r--protocols/Tox/src/common.h25
-rw-r--r--protocols/Tox/src/main.cpp52
-rw-r--r--protocols/Tox/src/resource.hbin0 -> 992 bytes
-rw-r--r--protocols/Tox/src/stdafx.cpp18
-rw-r--r--protocols/Tox/src/tox_contacts.cpp70
-rw-r--r--protocols/Tox/src/tox_events.cpp29
-rw-r--r--protocols/Tox/src/tox_instances.cpp44
-rw-r--r--protocols/Tox/src/tox_proto.cpp161
-rw-r--r--protocols/Tox/src/tox_proto.h108
-rw-r--r--protocols/Tox/src/tox_services.cpp16
-rw-r--r--protocols/Tox/src/version.h15
11 files changed, 538 insertions, 0 deletions
diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h
new file mode 100644
index 0000000000..f27fc74af8
--- /dev/null
+++ b/protocols/Tox/src/common.h
@@ -0,0 +1,25 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#include <winsock2.h>
+#include <windows.h>
+
+#include <newpluginapi.h>
+
+#include <m_protoint.h>
+#include <m_protomod.h>
+#include <m_protosvc.h>
+
+#include <m_database.h>
+#include <m_langpack.h>
+
+#include "version.h"
+#include "resource.h"
+
+#include "..\include\tox\tox.h"
+
+extern HINSTANCE g_hInstance;
+
+#include "tox_proto.h"
+
+#endif //_COMMON_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp
new file mode 100644
index 0000000000..f9322d7f3e
--- /dev/null
+++ b/protocols/Tox/src/main.cpp
@@ -0,0 +1,52 @@
+#include "common.h"
+
+int hLangpack;
+HINSTANCE g_hInstance;
+
+PLUGININFOEX pluginInfo =
+{
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {00272A3E-F5FA-4090-8B67-3E62AC1EE0B4}
+ {0x272a3e, 0xf5fa, 0x4090, {0x8b, 0x67, 0x3e, 0x62, 0xac, 0x1e, 0xe0, 0xb4}}
+};
+
+DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
+{
+ g_hInstance = hInstance;
+
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ mir_getLP(&pluginInfo);
+
+ PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
+ pd.szName = "TOX";
+ pd.type = PROTOTYPE_PROTOCOL;
+ pd.fnInit = (pfnInitProto)CToxProto::InitProtoInstance;
+ pd.fnUninit = (pfnUninitProto)CToxProto::UninitProtoInstance;
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ return 0;
+} \ No newline at end of file
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h
new file mode 100644
index 0000000000..161dc416c0
--- /dev/null
+++ b/protocols/Tox/src/resource.h
Binary files differ
diff --git a/protocols/Tox/src/stdafx.cpp b/protocols/Tox/src/stdafx.cpp
new file mode 100644
index 0000000000..7d92b0fd29
--- /dev/null
+++ b/protocols/Tox/src/stdafx.cpp
@@ -0,0 +1,18 @@
+/*
+Copyright (c) 2013-14 Miranda NG project (http://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "common.h"
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp
new file mode 100644
index 0000000000..263e922595
--- /dev/null
+++ b/protocols/Tox/src/tox_contacts.cpp
@@ -0,0 +1,70 @@
+#include "common.h"
+
+bool CToxProto::IsProtoContact(MCONTACT hContact)
+{
+ return ::lstrcmpiA(::GetContactProto(hContact), m_szModuleName) == 0;
+}
+
+MCONTACT CToxProto::GetContactByUserId(const wchar_t *userId)
+{
+ MCONTACT hContact = NULL;
+
+ //EnterCriticalSection(&contact_search_lock);
+
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ {
+ ptrW cUserId(::db_get_wsa(hContact, m_szModuleName, "UserID"));
+ if (lstrcmpi(cUserId, userId) == 0)
+ break;
+ }
+
+ //LeaveCriticalSection(&contact_search_lock);
+
+ return hContact;
+}
+
+MCONTACT CToxProto::AddContact(const wchar_t *userId, const wchar_t *nick, bool isHidden)
+{
+ MCONTACT hContact = GetContactByUserId(userId);
+ if ( !hContact)
+ {
+ hContact = (MCONTACT)::CallService(MS_DB_CONTACT_ADD, 0, 0);
+ ::CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName);
+
+ db_set_b(hContact, "CList", "NotOnList", 1);
+
+ if (isHidden)
+ db_set_b(hContact, "CList", "Hidden", 1);
+
+ setWString(hContact, "UserId", userId);
+ setWString(hContact, "Nick", nick);
+ }
+
+ return hContact;
+}
+
+void __cdecl CToxProto::SearchByUidAsync(void* arg)
+{
+ ptrW userId((wchar_t*)arg);
+
+ //MCONTACT hContact = GetContactByUserId(userId);
+ //if (hContact)
+ //{
+ // ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
+ // ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)TOX_SEARCH_BYUID, 0);
+ // return;
+ //}
+
+ //// there will be placed code
+ //// that will search for contact by userId
+ // ...
+ // ...
+ //// and call
+ PROTOSEARCHRESULT psr = {0};
+ psr.cbSize = sizeof(psr);
+ //// get user id [and nick]
+ //psr.id = userId;
+ //psr.nick = nick;
+
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)TOX_SEARCH_BYUID, (LPARAM)&psr);
+} \ No newline at end of file
diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp
new file mode 100644
index 0000000000..550cdd2999
--- /dev/null
+++ b/protocols/Tox/src/tox_events.cpp
@@ -0,0 +1,29 @@
+#include "common.h"
+
+void CToxProto::OnFriendRequest(Tox *tox, const uint8_t *userId, const uint8_t *message, const uint16_t messageSize, void *arg)
+{
+}
+
+void CToxProto::OnFriendMessage(Tox *tox, const int friendId, const uint8_t *message, const uint16_t messageSize, void *arg)
+{
+}
+
+void CToxProto::OnFriendNameChange(Tox *tox, const int friendId, const uint8_t *name, const uint16_t nameSize, void *arg)
+{
+}
+
+void CToxProto::OnStatusMessageChanged(Tox *tox, const int friendId, const uint8_t* message, const uint16_t messageSize, void *arg)
+{
+}
+
+void CToxProto::OnUserStatusChanged(Tox *tox, int32_t friendnumber, uint8_t TOX_USERSTATUS, void *userdata)
+{
+}
+
+void CToxProto::OnConnectionStatusChanged(Tox *tox, const int friendId, const uint8_t status, void *arg)
+{
+}
+
+void CToxProto::OnAction(Tox *tox, const int friendId, const uint8_t *message, const uint16_t messageSize, void *arg)
+{
+} \ No newline at end of file
diff --git a/protocols/Tox/src/tox_instances.cpp b/protocols/Tox/src/tox_instances.cpp
new file mode 100644
index 0000000000..ea010f894a
--- /dev/null
+++ b/protocols/Tox/src/tox_instances.cpp
@@ -0,0 +1,44 @@
+#include "common.h"
+
+LIST<CToxProto> CToxProto::instanceList(1, CToxProto::CompareProtos);
+
+int CToxProto::CompareProtos(const CToxProto *p1, const CToxProto *p2)
+{
+ return wcscmp(p1->m_tszUserName, p2->m_tszUserName);
+}
+
+CToxProto* CToxProto::InitProtoInstance(const char* protoName, const wchar_t* userName)
+{
+ CToxProto *ppro = new CToxProto(protoName, userName);
+ CToxProto::instanceList.insert(ppro);
+
+ return ppro;
+}
+
+int CToxProto::UninitProtoInstance(CToxProto* ppro)
+{
+ CToxProto::instanceList.remove(ppro);
+
+ delete ppro;
+
+ return 0;
+}
+
+void CToxProto::UninitInstances()
+{
+ CToxProto::instanceList.destroy();
+}
+
+CToxProto* CToxProto::GetContactInstance(MCONTACT hContact)
+{
+ char *proto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ if (proto == NULL)
+ return NULL;
+
+ for (int i = 0; i < CToxProto::instanceList.getCount(); i++)
+ if ( !::strcmp(proto, CToxProto::instanceList[i]->m_szModuleName))
+ return CToxProto::instanceList[i];
+
+ return NULL;
+} \ No newline at end of file
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
new file mode 100644
index 0000000000..00303c8f0d
--- /dev/null
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -0,0 +1,161 @@
+#include "common.h"
+
+CToxProto::CToxProto(const char* protoName, const TCHAR* userName) :
+ PROTO<CToxProto>(protoName, userName),
+ _tox(tox_new(0))
+{
+ tox_callback_friend_request(_tox, OnFriendRequest, this);
+ tox_callback_friend_message(_tox, OnFriendMessage, this);
+ tox_callback_friend_action(_tox, OnAction, this);
+ tox_callback_name_change(_tox, OnFriendNameChange, this);
+ tox_callback_status_message(_tox, OnStatusMessageChanged, this);
+ tox_callback_user_status(_tox, OnUserStatusChanged, this);
+ tox_callback_connection_status(_tox, OnConnectionStatusChanged, this);
+
+ CreateProtoService(PS_CREATEACCMGRUI, &CToxProto::CreateAccMgrUI);
+}
+
+CToxProto::~CToxProto()
+{
+ tox_kill(_tox);
+}
+
+void CALLBACK CToxProto::TimerProc(HWND, UINT, UINT_PTR idEvent, DWORD)
+{
+ CToxProto *ppro = (CToxProto*)idEvent;
+
+ tox_do(ppro->_tox);
+}
+
+MCONTACT __cdecl CToxProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
+{
+ MCONTACT hContact = AddContact(psr->id, psr->nick);
+
+ return hContact;
+}
+
+MCONTACT __cdecl CToxProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent) { return 0; }
+
+int __cdecl CToxProto::Authorize(HANDLE hDbEvent) { return 0; }
+int __cdecl CToxProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason) { return 0; }
+int __cdecl CToxProto::AuthRecv(MCONTACT hContact, PROTORECVEVENT*) { return 0; }
+int __cdecl CToxProto::AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage) { return 0; }
+
+HANDLE __cdecl CToxProto::ChangeInfo(int iInfoType, void* pInfoData) { return 0; }
+
+HANDLE __cdecl CToxProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath) { return 0; }
+int __cdecl CToxProto::FileCancel(MCONTACT hContact, HANDLE hTransfer) { return 0; }
+int __cdecl CToxProto::FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason) { return 0; }
+int __cdecl CToxProto::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename) { return 0; }
+
+DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact)
+{
+ switch(type)
+ {
+ case PFLAGNUM_1:
+ return PF1_IM | PF1_AUTHREQ | PF1_BASICSEARCH | PF1_ADDSEARCHRES;
+ case PFLAGNUM_2:
+ return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND;
+ case PFLAGNUM_4:
+ return PF4_SUPPORTTYPING;
+ case PFLAG_UNIQUEIDTEXT:
+ return (INT_PTR)"User Id";
+ case PFLAG_UNIQUEIDSETTING:
+ return (DWORD_PTR)"UserId";
+ }
+
+ return 0;
+}
+int __cdecl CToxProto::GetInfo(MCONTACT hContact, int infoType) { return 0; }
+
+HANDLE __cdecl CToxProto::SearchBasic(const PROTOCHAR* id)
+{
+ //if ( !IsOnline()) return 0;
+
+ this->ForkThread(&CToxProto::SearchByUidAsync, (void*)id);
+
+ return (HANDLE)TOX_SEARCH_BYUID;
+}
+
+HANDLE __cdecl CToxProto::SearchByEmail(const PROTOCHAR* email) { return 0; }
+HANDLE __cdecl CToxProto::SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName) { return 0; }
+HWND __cdecl CToxProto::SearchAdvanced(HWND owner) { return 0; }
+HWND __cdecl CToxProto::CreateExtendedSearchUI(HWND owner) { return 0; }
+
+int __cdecl CToxProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT*) { return 0; }
+int __cdecl CToxProto::RecvFile(MCONTACT hContact, PROTOFILEEVENT*) { return 0; }
+int __cdecl CToxProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT*) { return 0; }
+int __cdecl CToxProto::RecvUrl(MCONTACT hContact, PROTORECVEVENT*) { return 0; }
+
+int __cdecl CToxProto::SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT* hContactsList) { return 0; }
+HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles) { return 0; }
+int __cdecl CToxProto::SendMsg(MCONTACT hContact, int flags, const char* msg) { return 0; }
+int __cdecl CToxProto::SendUrl(MCONTACT hContact, int flags, const char* url) { return 0; }
+
+int __cdecl CToxProto::SetApparentMode(MCONTACT hContact, int mode) { return 0; }
+
+int __cdecl CToxProto::SetStatus(int iNewStatus)
+{
+ if (iNewStatus == this->m_iDesiredStatus)
+ return 0;
+
+ int old_status = this->m_iStatus;
+ this->m_iDesiredStatus = iNewStatus;
+
+ if (iNewStatus == ID_STATUS_OFFLINE)
+ {
+ // lgout
+ m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
+
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+
+ return 0;
+ }
+ else
+ {
+ if (old_status == ID_STATUS_OFFLINE/* && !this->IsOnline()*/)
+ {
+ m_iStatus = ID_STATUS_CONNECTING;
+
+ // login
+ //_timer = SetTimer(NULL, (UINT_PTR)this, 30, (TIMERPROC)CToxProto::TimerProc);
+ }
+ else
+ {
+ // set tox status
+ TOX_USERSTATUS userstatus;
+ switch (iNewStatus)
+ {
+ case ID_STATUS_ONLINE:
+ userstatus = TOX_USERSTATUS_NONE;
+ break;
+ case ID_STATUS_AWAY:
+ userstatus = TOX_USERSTATUS_AWAY;
+ break;
+ case ID_STATUS_OCCUPIED:
+ userstatus = TOX_USERSTATUS_BUSY;
+ break;
+ default:
+ userstatus = TOX_USERSTATUS_INVALID;
+ break;
+ }
+ tox_set_user_status(_tox, userstatus);
+
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+
+ return 0;
+ }
+ }
+
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+
+ return 0;
+}
+
+HANDLE __cdecl CToxProto::GetAwayMsg(MCONTACT hContact) { return 0; }
+int __cdecl CToxProto::RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt) { return 0; }
+int __cdecl CToxProto::SetAwayMsg(int iStatus, const PROTOCHAR* msg) { return 0; }
+
+int __cdecl CToxProto::UserIsTyping(MCONTACT hContact, int type) { return 0; }
+
+int __cdecl CToxProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam) { return 0; } \ No newline at end of file
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
new file mode 100644
index 0000000000..37fee20593
--- /dev/null
+++ b/protocols/Tox/src/tox_proto.h
@@ -0,0 +1,108 @@
+#ifndef _TOX_PROTO_H_
+#define _TOX_PROTO_H_
+
+#include "common.h"
+
+#define TOX_SEARCH_BYUID 1001
+
+struct CToxProto : public PROTO<CToxProto>
+{
+public:
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ //Ctors
+
+ CToxProto(const char *protoName, const wchar_t *userName);
+ ~CToxProto();
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ // Virtual functions
+
+ virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
+ virtual MCONTACT __cdecl AddToListByEvent(int flags, int iContact, HANDLE hDbEvent);
+
+ virtual int __cdecl Authorize(HANDLE hDbEvent);
+ virtual int __cdecl AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason);
+ virtual int __cdecl AuthRecv(MCONTACT hContact, PROTORECVEVENT*);
+ virtual int __cdecl AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage);
+
+ virtual HANDLE __cdecl ChangeInfo(int iInfoType, void* pInfoData);
+
+ virtual HANDLE __cdecl FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szPath);
+ virtual int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer);
+ virtual int __cdecl FileDeny(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* szReason);
+ virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** szFilename);
+
+ virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
+ virtual int __cdecl GetInfo(MCONTACT hContact, int infoType);
+
+ virtual HANDLE __cdecl SearchBasic(const PROTOCHAR* id);
+ virtual HANDLE __cdecl SearchByEmail(const PROTOCHAR* email);
+ virtual HANDLE __cdecl SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName);
+ virtual HWND __cdecl SearchAdvanced(HWND owner);
+ virtual HWND __cdecl CreateExtendedSearchUI(HWND owner);
+
+ virtual int __cdecl RecvContacts(MCONTACT hContact, PROTORECVEVENT*);
+ virtual int __cdecl RecvFile(MCONTACT hContact, PROTOFILEEVENT*);
+ virtual int __cdecl RecvMsg(MCONTACT hContact, PROTORECVEVENT*);
+ virtual int __cdecl RecvUrl(MCONTACT hContact, PROTORECVEVENT*);
+
+ virtual int __cdecl SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT* hContactsList);
+ virtual HANDLE __cdecl SendFile(MCONTACT hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles);
+ virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char* msg);
+ virtual int __cdecl SendUrl(MCONTACT hContact, int flags, const char* url);
+
+ virtual int __cdecl SetApparentMode(MCONTACT hContact, int mode);
+ virtual int __cdecl SetStatus(int iNewStatus);
+
+ virtual HANDLE __cdecl GetAwayMsg(MCONTACT hContact);
+ virtual int __cdecl RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt);
+ virtual int __cdecl SetAwayMsg(int iStatus, const PROTOCHAR* msg);
+
+ virtual int __cdecl UserIsTyping(MCONTACT hContact, int type);
+
+ virtual int __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam);
+
+ // instances
+ static CToxProto* InitProtoInstance(const char* protoName, const wchar_t* userName);
+ static int UninitProtoInstance(CToxProto* ppro);
+
+ static CToxProto* GetContactInstance(MCONTACT hContact);
+ static void UninitInstances();
+
+private:
+
+ // instances
+ static LIST<CToxProto> instanceList;
+ static int CompareProtos(const CToxProto *p1, const CToxProto *p2);
+
+ static void CALLBACK TimerProc(HWND, UINT, UINT_PTR idEvent, DWORD);
+
+ // Instance data:
+ Tox *_tox;
+ UINT_PTR _timer;
+
+ //services
+ INT_PTR __cdecl CreateAccMgrUI(WPARAM, LPARAM);
+
+ //events
+ static void OnFriendRequest(Tox *tox, const uint8_t *userId, const uint8_t *message, const uint16_t messageSize, void *arg);
+ static void OnFriendMessage(Tox *tox, const int friendId, const uint8_t *message, const uint16_t messageSize, void *arg);
+ static void OnFriendNameChange(Tox *tox, const int friendId, const uint8_t *name, const uint16_t nameSize, void *arg);
+ static void OnStatusMessageChanged(Tox *tox, const int friendId, const uint8_t* message, const uint16_t messageSize, void *arg);
+ static void OnUserStatusChanged(Tox *tox, int32_t friendnumber, uint8_t TOX_USERSTATUS, void *userdata);
+ static void OnConnectionStatusChanged(Tox *tox, const int friendId, const uint8_t status, void *arg);
+ static void OnAction(Tox *tox, const int friendId, const uint8_t *message, const uint16_t messageSize, void *arg);
+
+ // contacts
+ bool IsProtoContact(MCONTACT hContact);
+ MCONTACT GetContactByUserId(const wchar_t *userId);
+ MCONTACT CToxProto::AddContact(const wchar_t*userId, const wchar_t *nick, bool isHidden = false);
+
+ void __cdecl SearchByUidAsync(void* arg);
+
+ // dialogs
+ static INT_PTR CALLBACK AccountManagerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+};
+
+#endif //_TOX_PROTO_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/tox_services.cpp b/protocols/Tox/src/tox_services.cpp
new file mode 100644
index 0000000000..dfd4907737
--- /dev/null
+++ b/protocols/Tox/src/tox_services.cpp
@@ -0,0 +1,16 @@
+#include "common.h"
+
+INT_PTR CALLBACK CToxProto::AccountManagerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ return FALSE;
+}
+
+INT_PTR CToxProto::CreateAccMgrUI(WPARAM, LPARAM lParam)
+{
+ return (INT_PTR)CreateDialogParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_ACCMGR),
+ (HWND)lParam,
+ &CToxProto::AccountManagerProc,
+ (LPARAM)this);
+} \ No newline at end of file
diff --git a/protocols/Tox/src/version.h b/protocols/Tox/src/version.h
new file mode 100644
index 0000000000..f81fce4d79
--- /dev/null
+++ b/protocols/Tox/src/version.h
@@ -0,0 +1,15 @@
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 11
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 0
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "Tox Protocol"
+#define __INTERNAL_NAME "Tox"
+#define __FILENAME "Tox.dll"
+#define __DESCRIPTION "Tox protocol support for Miranda NG."
+#define __AUTHOR "ForNeVeR, unsane"
+#define __AUTHOREMAIL ""
+#define __AUTHORWEB "http://miranda-ng.org/p/Tox/"
+#define __COPYRIGHT "© 2014 Miranda NG project"