diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-07 13:49:07 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-07 13:49:07 +0000 |
commit | 84f85ceac0f993be95dda89584749ea59fe5b8e7 (patch) | |
tree | 2231a79773b63436a9586f6cf1f35f1893c80793 /protocols/Tox/src/tox_proto.cpp | |
parent | c56192dd999c079ebd935a6736315de3a5d60a05 (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/tox_proto.cpp')
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 161 |
1 files changed, 161 insertions, 0 deletions
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 |