From bb3b1c84d2426172e1bd9db94872d5f5fa1e5182 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Mon, 16 Aug 2010 19:16:53 +0300 Subject: infernal crutches --- commonheaders.h | 4 +++- init.cpp | 8 +++++++- messages.cpp | 6 ++---- new_gpg.vcproj | 8 ++++++++ utilities.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ utilities.h | 2 +- 6 files changed, 78 insertions(+), 7 deletions(-) diff --git a/commonheaders.h b/commonheaders.h index 2c3a640..08700d1 100644 --- a/commonheaders.h +++ b/commonheaders.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss, chaos.persei +// Copyright © 2010 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -46,6 +46,7 @@ using std::fstream; #include #include #include +#include #include "resource.h" #include "gpgme.h" @@ -54,4 +55,5 @@ using std::fstream; #include "globals.h" #include "main.h" #include "gpg_wrapper.h" +#include "jabber_account.h" #endif diff --git a/init.cpp b/init.cpp index 4c96d01..65d49b7 100644 --- a/init.cpp +++ b/init.cpp @@ -20,6 +20,8 @@ bool bAppendTags = false; TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag; +list Accounts; + HINSTANCE hInst; HANDLE hLoadPubKey = NULL, hToggleEncryption = NULL, hOnPreBuildContactMenu = NULL, hSendKey = NULL; PLUGINLINK *pluginLink; @@ -135,7 +137,8 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) int RecvMsgSvc(WPARAM w, LPARAM l); int SendMsgSvc(WPARAM w, LPARAM l); int HookSendMsg(WPARAM w, LPARAM l); -// int TestHook(WPARAM w, LPARAM l); + int TestHook(WPARAM w, LPARAM l); + int GetJabberInterface(WPARAM w, LPARAM l); void InitCheck(); @@ -143,8 +146,11 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) FirstRun(); InitCheck(); + GetJabberInterface(0,0); + HookEvent(ME_OPT_INITIALISE, GpgOptInit); HookEvent(ME_DB_EVENT_FILTER_ADD, HookSendMsg); + HookEvent(ME_PROTO_ACCLISTCHANGED, GetJabberInterface); // HookEvent(ME_NETLIB_FASTSEND, TestHook); hOnPreBuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu); diff --git a/messages.cpp b/messages.cpp index a17ff09..1fca963 100644 --- a/messages.cpp +++ b/messages.cpp @@ -313,9 +313,7 @@ int HookSendMsg(WPARAM w, LPARAM l) return 0; } -/*int TestHook(WPARAM w, LPARAM l) +int TestHook(WPARAM w, LPARAM l) { - char *buf = (char*)w; - char *proto = (char*)l; return 0; -} */ \ No newline at end of file +} \ No newline at end of file diff --git a/new_gpg.vcproj b/new_gpg.vcproj index a01a148..dac2ba2 100644 --- a/new_gpg.vcproj +++ b/new_gpg.vcproj @@ -632,6 +632,10 @@ /> + + @@ -677,6 +681,10 @@ RelativePath=".\gpg_wrapper.h" > + + diff --git a/utilities.cpp b/utilities.cpp index 85cb4ec..f909121 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -295,3 +295,60 @@ int ComboBoxAddStringUtf(HWND hCombo, const TCHAR *szString, DWORD data) return item; } + + +int GetJabberInterface(WPARAM w, LPARAM l) //get interface for all jabber accounts, options later +{ + extern list Accounts; + void AddHandlers(); + int count = 0; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&count, &accounts); + list ::iterator p; + Accounts.clear(); + Accounts.push_back(new JabberAccount); + p = Accounts.begin(); + (*p)->setAccountNumber(0); + for(int i = 0; i < count; i++) //get only jabber accounts from all accounts + { + char *tmp = mir_u2a(accounts[i]->tszAccountName); + IJabberInterface *JIftmp = getJabberApi(tmp); + int a = 0; + if(JIftmp) + { + (*p)->setJabberInterface(JIftmp); + (*p)->setAccountName(accounts[i]->tszAccountName); + (*p)->setAccountNumber(a); + (*p)->setSendHandler(INVALID_HANDLE_VALUE); + a++; + p++; + Accounts.push_back(new JabberAccount); + } + mir_free(tmp); + //should i free JIftmp ? + } + Accounts.pop_back(); + AddHandlers(); + return 0; +} + +static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pUserData) +{ + return FALSE; +} + + +void AddHandlers() +{ + extern list Accounts; + list ::iterator p = Accounts.begin(); + for(unsigned int i = 0; i < Accounts.size(); i++, p++) + { + if(!(*p)) + break; + if((*p)->getSendHandler() == INVALID_HANDLE_VALUE) + { + (*p)->setSendHandler((*p)->getJabberInterface()->Net()->AddSendHandler((JABBER_HANDLER_FUNC)SendHandler)); + } + } +} diff --git a/utilities.h b/utilities.h index fc3304d..7d70458 100644 --- a/utilities.h +++ b/utilities.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss, chaos.persei +// Copyright © 2010 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License -- cgit v1.2.3