summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-06-14 14:25:55 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-06-14 14:25:55 +0300
commit0510e1e7b42979598e9b4c072addbbf0ae517bab (patch)
tree165b6a6d885e1feae3fd323d382f5e6f3f5fee15
parente073c336539d16e57c73a4620107ecffae70d927 (diff)
modified: globals.h
modified: init.cpp modified: utilities.cpp
-rw-r--r--globals.h1
-rw-r--r--init.cpp11
-rw-r--r--utilities.cpp31
3 files changed, 39 insertions, 4 deletions
diff --git a/globals.h b/globals.h
index c3dd0ae..0eff761 100644
--- a/globals.h
+++ b/globals.h
@@ -1,3 +1,4 @@
#ifndef GLOBALS_H
#define GLOBALS_H
+#define JUICK_JID "juick@juick.com"
#endif
diff --git a/init.cpp b/init.cpp
index 9c165de..a858ef9 100644
--- a/init.cpp
+++ b/init.cpp
@@ -20,7 +20,7 @@
#define PLUGIN_NAME "juick"
HINSTANCE hInst;
-static HANDLE hAccountsChanges;
+static HANDLE hAccountsChanges, hDbContactAdded;
PLUGINLINK *pluginLink;
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam);
extern char *date();
@@ -88,12 +88,15 @@ void InitVars()
extern int JuickOptInit(WPARAM wParam,LPARAM lParam);
extern int GetJabberInterface(WPARAM, LPARAM);
-
+extern int HandleNewContact(WPARAM w, LPARAM l);
+extern void FindJuickAccounts();
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam)
{
GetJabberInterface(0,0);
- HANDLE hHookOptionInit = HookEvent(ME_OPT_INITIALISE, JuickOptInit);
- hAccountsChanges = HookEvent(ME_PROTO_ACCLISTCHANGED, GetJabberInterface);
+ HookEvent(ME_OPT_INITIALISE, JuickOptInit);
+ hAccountsChanges = HookEvent(ME_PROTO_ACCLISTCHANGED, GetJabberInterface);
+ hDbContactAdded = HookEvent(ME_DB_CONTACT_ADDED, HandleNewContact);
+ FindJuickAccounts();
return 0;
}
diff --git a/utilities.cpp b/utilities.cpp
index 10349f4..9e0f7c2 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -65,6 +65,37 @@ int GetJabberInterface(WPARAM, LPARAM) //get interface for all jabber accounts,
return 0;
}
+int HandleNewContact(WPARAM w, LPARAM l)
+{
+ IJabberSysInterface *ijsys;
+ JabberAccount *acc = &Accounts;
+ for(int i = 0; i < GetAccountsCount(); i++)
+ {
+ if(!acc)
+ break;
+ ijsys = acc->JabberInterface->Sys();
+ if(_tcsstr(_T(JUICK_JID), ijsys->ContactToJID(HANDLE(w))))
+ ; //juick contact found, need to add xmpp traffic handlers for this account.
+ acc = acc->next;
+ }
+ return 0;
+}
+
+void FindJuickAccounts()
+{
+ IJabberSysInterface *ijsys;
+ JabberAccount *acc = &Accounts;
+ for(int i = 0; i < GetAccountsCount(); i++)
+ {
+ if(!acc)
+ break;
+ ijsys = acc->JabberInterface->Sys();
+ if(ijsys->ContactFromJID(_T(JUICK_JID)))
+ ; //juick contact found, need to add xmpp traffic handlers for this account.
+ acc = acc->next;
+ }
+}
+
BOOL JabberAccount::operator!()
{
if(!this)