diff options
-rw-r--r-- | commonheaders.h | 4 | ||||
-rw-r--r-- | init.cpp | 8 | ||||
-rw-r--r-- | messages.cpp | 6 | ||||
-rw-r--r-- | new_gpg.vcproj | 8 | ||||
-rw-r--r-- | utilities.cpp | 57 | ||||
-rw-r--r-- | 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 <m_protomod.h> #include <m_protosvc.h> #include <m_netlib.h> +#include <m_jabber.h> #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 @@ -20,6 +20,8 @@ bool bAppendTags = false;
TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag;
+list <JabberAccount*> 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 @@ -633,6 +633,10 @@ </FileConfiguration>
</File>
<File
+ RelativePath=".\jabber_account.cpp"
+ >
+ </File>
+ <File
RelativePath=".\main.cpp"
>
<FileConfiguration
@@ -678,6 +682,10 @@ >
</File>
<File
+ RelativePath=".\jabber_account.h"
+ >
+ </File>
+ <File
RelativePath=".\main.h"
>
</File>
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 <JabberAccount*> Accounts; + void AddHandlers(); + int count = 0; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&count, &accounts); + list <JabberAccount*>::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 <JabberAccount*> Accounts; + list <JabberAccount*>::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 |