From 7eb9adcbf1e804638ec92ced431e8212b60af751 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 5 Oct 2013 18:21:33 +0000 Subject: more meat on the bones git-svn-id: http://svn.miranda-ng.org/main/trunk@6352 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/main.cpp | 81 ++++++++++ protocols/VKontakte/src/resource.h | 16 ++ protocols/VKontakte/src/stdafx.h | 3 + protocols/VKontakte/src/vk.h | 2 + protocols/VKontakte/src/vk_options.cpp | 51 ++++++ protocols/VKontakte/src/vk_proto.cpp | 248 ++++++++++++++++++++++++++++++ protocols/VKontakte/src/vk_proto.h | 81 ++++++++++ protocols/VKontakte/vk_10.vcxproj | 4 + protocols/VKontakte/vk_10.vcxproj.filters | 12 ++ protocols/VKontakte/vk_11.vcxproj | 4 + protocols/VKontakte/vk_11.vcxproj.filters | 12 ++ 11 files changed, 514 insertions(+) create mode 100644 protocols/VKontakte/src/resource.h create mode 100644 protocols/VKontakte/src/vk_options.cpp create mode 100644 protocols/VKontakte/src/vk_proto.cpp create mode 100644 protocols/VKontakte/src/vk_proto.h diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp index d788c2781d..32e3246751 100644 --- a/protocols/VKontakte/src/main.cpp +++ b/protocols/VKontakte/src/main.cpp @@ -16,3 +16,84 @@ along with this program. If not, see . */ #include "stdafx.h" +#include "version.h" + +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = +{ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {32579908-724B-467F-ADAD-22B6359A749A} + { 0x32579908, 0x724b, 0x467f, {0xad, 0xad, 0x22, 0xb6, 0x35, 0x9a, 0x74, 0x9a}} +}; + +///////////////////////////////////////////////////////////////////////////////////////// + +BOOL WINAPI DllMain(HINSTANCE hModule, DWORD, LPVOID) +{ + hInst = hModule; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST}; + +///////////////////////////////////////////////////////////////////////////////////////// +// OnModulesLoaded - execute some code when all plugins are initialized + +static int OnModulesLoaded(WPARAM, LPARAM) +{ + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// OnLoad - initialize the plugin instance + +static CVkProto* vkProtoInit(const char* pszProtoName, const TCHAR *tszUserName) +{ + CVkProto *ppro = new CVkProto(pszProtoName, tszUserName); + return ppro; +} + +static int vkProtoUninit(CVkProto *ppro) +{ + delete ppro; + return 0; +} + +extern "C" int __declspec(dllexport) Load() +{ + mir_getLP(&pluginInfo); + + // Register protocol module + PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; + pd.szName = "VKontakte"; + pd.fnInit = (pfnInitProto)vkProtoInit; + pd.fnUninit = (pfnUninitProto)vkProtoUninit; + pd.type = PROTOTYPE_PROTOCOL; + CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); + + HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// Unload - destroy the plugin instance + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h new file mode 100644 index 0000000000..dc2b908493 --- /dev/null +++ b/protocols/VKontakte/src/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// +#define IDD_ACCMGRUI 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index 2672a9d5a5..e3137a17a5 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -33,6 +33,7 @@ along with this program. If not, see . #include #include +#include #include #include #include @@ -57,4 +58,6 @@ along with this program. If not, see . #include "win2k.h" +#include "resource.h" #include "vk.h" +#include "vk_proto.h" diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 6b79f6eac0..23d92fa906 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -14,3 +14,5 @@ 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 . */ + +extern HINSTANCE hInst; \ No newline at end of file diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp new file mode 100644 index 0000000000..a854a9f335 --- /dev/null +++ b/protocols/VKontakte/src/vk_options.cpp @@ -0,0 +1,51 @@ +/* +Copyright (C) 2013 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 . +*/ + +#include "stdafx.h" + +////////////////////////////////////////////////////////////////////////////// +// Account manager dialog + +INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + return 0; +}; + +INT_PTR CVkProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam) +{ + return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ACCMGRUI), (HWND)lParam, VKAccountProc, (LPARAM)this); +} + +////////////////////////////////////////////////////////////////////////////// +// Options + +int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = {sizeof(odp)}; + odp.hInstance = hInst; + odp.ptszTitle = m_tszUserName; + odp.dwInitParam = LPARAM(this); + odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE; + + odp.position = 1; + odp.ptszGroup = LPGENT("Network"); + odp.ptszTab = LPGENT("Account"); + odp.pszTemplate = 0; // MAKEINTRESOURCEA(IDD_OPTIONS); + odp.pfnDlgProc = 0; // OptionsProc; + Options_AddPage(wParam, &odp); + return 0; +} diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp new file mode 100644 index 0000000000..ca1e8193fd --- /dev/null +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -0,0 +1,248 @@ +/* +Copyright (C) 2013 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 . +*/ + +#include "stdafx.h" + +CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : + PROTO(szModuleName, ptszUserName) +{ +} + +CVkProto::~CVkProto() +{ +} + +int CVkProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +int CVkProto::OnPreShutdown(WPARAM wParam, LPARAM lParam) +{ + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +DWORD_PTR CVkProto::GetCaps(int type, HANDLE hContact) +{ + switch(type) { + case PFLAGNUM_1: + return PF1_IM | PF1_CHAT | PF1_SERVERCLIST | PF1_AUTHREQ | PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_MODEMSG; + + case PFLAGNUM_2: + return PF2_ONLINE | PF2_INVISIBLE | PF2_ONTHEPHONE | PF2_IDLE; // | PF2_SHORTAWAY; + + case PFLAGNUM_3: + return PF2_ONLINE; // | PF2_SHORTAWAY; + + case PFLAGNUM_4: + return PF4_NOCUSTOMAUTH | PF4_FORCEADDED | PF4_IMSENDUTF | PF4_AVATARS | PF4_SUPPORTTYPING | PF4_NOAUTHDENYREASON | PF4_IMSENDOFFLINE; + + case PFLAGNUM_5: + return PF2_ONTHEPHONE; + + case PFLAG_MAXLENOFMESSAGE: + return 2000; + + case PFLAG_UNIQUEIDTEXT: + return (DWORD_PTR)"VK ID"; + + case PFLAG_UNIQUEIDSETTING: + return (DWORD_PTR)"ID"; + } + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +int CVkProto::SetStatus(int new_status) +{ + return 0; +} + +HANDLE CVkProto::SearchBasic(const PROTOCHAR* id) +{ + return 0; +} + +HANDLE CVkProto::SearchByEmail(const PROTOCHAR* email) +{ + return 0; +} + +HANDLE CVkProto::SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName) +{ + return 0; +} + +HANDLE CVkProto::AddToList(int flags, PROTOSEARCHRESULT* psr) +{ + return NULL; +} + +int CVkProto::AuthRequest(HANDLE hContact,const PROTOCHAR *message) +{ + return 0; +} + +int CVkProto::Authorize(HANDLE hDbEvent) +{ + //if (!hDbEvent) + return 1; +} + +int CVkProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason) +{ + //if (!hDbEvent || isOffline()) + return 1; +} + +int CVkProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre) +{ + return 0; +} + +int CVkProto::SendMsg(HANDLE hContact, int flags, const char *msg) +{ + return 0; +} + +int CVkProto::UserIsTyping(HANDLE hContact, int type) +{ + return 0; +} + +HANDLE CVkProto::AddToListByEvent(int flags,int iContact,HANDLE hDbEvent) +{ + return NULL; +} + +int CVkProto::AuthRecv(HANDLE hContact,PROTORECVEVENT *) +{ + return 1; +} + +HANDLE CVkProto::ChangeInfo(int type,void *info_data) +{ + MessageBoxA(0,"ChangeInfo","",0); + return NULL; +} + +HANDLE CVkProto::FileAllow(HANDLE hContact,HANDLE hTransfer,const PROTOCHAR *path) +{ + return NULL; +} + +int CVkProto::FileCancel(HANDLE hContact,HANDLE hTransfer) +{ + return 1; +} + +int CVkProto::FileDeny(HANDLE hContact,HANDLE hTransfer,const PROTOCHAR *reason) +{ + return 1; +} + +int CVkProto::FileResume(HANDLE hTransfer,int *action,const PROTOCHAR **filename) +{ + return 1; +} + +int CVkProto::GetInfo(HANDLE hContact, int infoType) +{ + // TODO: Most probably some ProtoAck should be here instead + return 1; +} + +HWND CVkProto::SearchAdvanced(HWND owner) +{ + return NULL; +} + +HWND CVkProto::CreateExtendedSearchUI(HWND owner) +{ + return NULL; +} + +int CVkProto::RecvContacts(HANDLE hContact,PROTORECVEVENT *) +{ + return 1; +} + +int CVkProto::RecvFile(HANDLE hContact,PROTORECVFILET *) +{ + return 1; +} + +int CVkProto::RecvUrl(HANDLE hContact,PROTORECVEVENT *) +{ + return 1; +} + +int CVkProto::SendContacts(HANDLE hContact,int flags,int nContacts,HANDLE *hContactsList) +{ + return 1; +} + +HANDLE CVkProto::SendFile(HANDLE hContact,const PROTOCHAR *desc, PROTOCHAR **files) +{ + return NULL; +} + +int CVkProto::SendUrl(HANDLE hContact,int flags,const char *url) +{ + return 1; +} + +int CVkProto::SetApparentMode(HANDLE hContact,int mode) +{ + return 1; +} + +int CVkProto::RecvAwayMsg(HANDLE hContact,int mode,PROTORECVEVENT *evt) +{ + return 1; +} + +HANDLE CVkProto::GetAwayMsg(HANDLE hContact) +{ + return 0; // Status messages are disabled +} + +int CVkProto::SetAwayMsg(int status, const PROTOCHAR *msg) +{ + return 0; // Status messages are disabled +} + +////////////////////////////////////////////////////////////////////////////// + +int CVkProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) +{ + switch(event) { + case EV_PROTO_ONLOAD: + return OnModulesLoaded(wParam,lParam); + + case EV_PROTO_ONEXIT: + return OnPreShutdown(wParam,lParam); + + case EV_PROTO_ONOPTIONS: + return OnOptionsInit(wParam,lParam); + } + + return 1; +} diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h new file mode 100644 index 0000000000..ffb92c5990 --- /dev/null +++ b/protocols/VKontakte/src/vk_proto.h @@ -0,0 +1,81 @@ +/* +Copyright (C) 2013 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 . +*/ + +struct CVkProto : public PROTO +{ + CVkProto(const char*, const TCHAR*); + ~CVkProto(); + + //==================================================================================== + // PROTO_INTERFACE + //==================================================================================== + + virtual HANDLE __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr); + virtual HANDLE __cdecl AddToListByEvent(int flags, int iContact, HANDLE hDbEvent); + + virtual int __cdecl Authorize(HANDLE hDbEvent); + virtual int __cdecl AuthDeny(HANDLE hDbEvent, const TCHAR *szReason); + virtual int __cdecl AuthRecv(HANDLE hContact, PROTORECVEVENT*); + virtual int __cdecl AuthRequest(HANDLE hContact, const TCHAR *szMessage); + + virtual HANDLE __cdecl ChangeInfo(int iInfoType, void* pInfoData); + + virtual HANDLE __cdecl FileAllow(HANDLE hContact, HANDLE hTransfer, const TCHAR *szPath); + virtual int __cdecl FileCancel(HANDLE hContact, HANDLE hTransfer); + virtual int __cdecl FileDeny(HANDLE hContact, HANDLE hTransfer, const TCHAR *szReason); + virtual int __cdecl FileResume(HANDLE hTransfer, int* action, const TCHAR** szFilename); + + virtual DWORD_PTR __cdecl GetCaps(int type, HANDLE hContact = NULL); + virtual int __cdecl GetInfo(HANDLE hContact, int infoType); + + virtual HANDLE __cdecl SearchBasic(const TCHAR *id); + virtual HANDLE __cdecl SearchByEmail(const TCHAR *email); + virtual HANDLE __cdecl SearchByName(const TCHAR *nick, const TCHAR *firstName, const TCHAR *lastName); + virtual HWND __cdecl SearchAdvanced(HWND owner); + virtual HWND __cdecl CreateExtendedSearchUI(HWND owner); + + virtual int __cdecl RecvContacts(HANDLE hContact, PROTORECVEVENT*); + virtual int __cdecl RecvFile(HANDLE hContact, PROTORECVFILET*); + virtual int __cdecl RecvMsg(HANDLE hContact, PROTORECVEVENT*); + virtual int __cdecl RecvUrl(HANDLE hContact, PROTORECVEVENT*); + + virtual int __cdecl SendContacts(HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList); + virtual HANDLE __cdecl SendFile(HANDLE hContact, const TCHAR *szDescription, TCHAR** ppszFiles); + virtual int __cdecl SendMsg(HANDLE hContact, int flags, const char* msg); + virtual int __cdecl SendUrl(HANDLE hContact, int flags, const char* url); + + virtual int __cdecl SetApparentMode(HANDLE hContact, int mode); + virtual int __cdecl SetStatus(int iNewStatus); + + virtual HANDLE __cdecl GetAwayMsg(HANDLE hContact); + virtual int __cdecl RecvAwayMsg(HANDLE hContact, int mode, PROTORECVEVENT* evt); + virtual int __cdecl SetAwayMsg(int m_iStatus, const TCHAR *msg); + + virtual int __cdecl UserIsTyping(HANDLE hContact, int type); + + virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam); + + //==== Events ======================================================================== + + int __cdecl OnModulesLoaded(WPARAM, LPARAM); + int __cdecl OnOptionsInit(WPARAM, LPARAM); + int __cdecl OnPreShutdown(WPARAM, LPARAM); + + //==== Services ====================================================================== + + INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); +}; diff --git a/protocols/VKontakte/vk_10.vcxproj b/protocols/VKontakte/vk_10.vcxproj index 82d222613c..fe83ab85d1 100644 --- a/protocols/VKontakte/vk_10.vcxproj +++ b/protocols/VKontakte/vk_10.vcxproj @@ -173,11 +173,15 @@ Create Create + + + + diff --git a/protocols/VKontakte/vk_10.vcxproj.filters b/protocols/VKontakte/vk_10.vcxproj.filters index 7c10ef224e..1d83c9190c 100644 --- a/protocols/VKontakte/vk_10.vcxproj.filters +++ b/protocols/VKontakte/vk_10.vcxproj.filters @@ -21,6 +21,12 @@ Source Files + + Source Files + + + Source Files + @@ -32,6 +38,12 @@ Header Files + + Header Files + + + Header Files + diff --git a/protocols/VKontakte/vk_11.vcxproj b/protocols/VKontakte/vk_11.vcxproj index 5829d35b69..07e71e00bc 100644 --- a/protocols/VKontakte/vk_11.vcxproj +++ b/protocols/VKontakte/vk_11.vcxproj @@ -176,10 +176,14 @@ Create Create + + + + diff --git a/protocols/VKontakte/vk_11.vcxproj.filters b/protocols/VKontakte/vk_11.vcxproj.filters index a153d9aed5..ccfedcabb8 100644 --- a/protocols/VKontakte/vk_11.vcxproj.filters +++ b/protocols/VKontakte/vk_11.vcxproj.filters @@ -21,6 +21,12 @@ Source Files + + Source Files + + + Source Files + @@ -29,6 +35,12 @@ Header Files + + Header Files + + + Header Files + -- cgit v1.2.3