summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-06-15 14:39:18 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-06-15 14:39:18 +0300
commitfecf5df530e8da455c2417a5023cce5daae1292c (patch)
tree64e665ca8d796429dccf220da829645a5678ad99
parent1d9ba06c9210745c220a421c8bae5043b60c0650 (diff)
fixed add\delete contacts handling
modified: init.cpp modified: utilities.cpp
-rw-r--r--init.cpp6
-rw-r--r--utilities.cpp33
2 files changed, 30 insertions, 9 deletions
diff --git a/init.cpp b/init.cpp
index a858ef9..4ccdd0a 100644
--- a/init.cpp
+++ b/init.cpp
@@ -88,14 +88,16 @@ void InitVars()
extern int JuickOptInit(WPARAM wParam,LPARAM lParam);
extern int GetJabberInterface(WPARAM, LPARAM);
-extern int HandleNewContact(WPARAM w, LPARAM l);
+extern int HandleDbNewContact(WPARAM w, LPARAM l);
+extern int HandleDbContactDeleted(WPARAM w, LPARAM l);
extern void FindJuickAccounts();
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam)
{
GetJabberInterface(0,0);
HookEvent(ME_OPT_INITIALISE, JuickOptInit);
hAccountsChanges = HookEvent(ME_PROTO_ACCLISTCHANGED, GetJabberInterface);
- hDbContactAdded = HookEvent(ME_DB_CONTACT_ADDED, HandleNewContact);
+ hDbContactAdded = HookEvent(ME_DB_CONTACT_ADDED, HandleDbNewContact);
+ hDbContactAdded = HookEvent(ME_DB_CONTACT_DELETED, HandleDbContactDeleted);
FindJuickAccounts();
return 0;
}
diff --git a/utilities.cpp b/utilities.cpp
index b50af4a..776bcab 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -65,7 +65,7 @@ int GetJabberInterface(WPARAM, LPARAM) //get interface for all jabber accounts,
return 0;
}
-int HandleNewContact(WPARAM w, LPARAM l)
+int HandleDbNewContact(WPARAM w, LPARAM l)
{
for(int i = 0; i < GetAccountsCount(); i++)
{
@@ -78,21 +78,40 @@ int HandleNewContact(WPARAM w, LPARAM l)
{
if(_tcsstr(_T(JUICK_JID), tmp))
{
- IJabberNetInterface *ijnet = acc->JabberInterface->Net();
if(!acc->hPrescenseHandler && !acc->hMessageHandler && !acc->hIqHandler)
{
+ IJabberNetInterface *ijnet = acc->JabberInterface->Net();
acc->hPrescenseHandler = ijnet->AddPresenceHandler(acc->PrescenseHandler(acc->JabberInterface, acc->pNODE, acc->ppUserData));
acc->hMessageHandler = ijnet->AddMessageHandler(acc->MessageHandler(acc->JabberInterface, acc->mNODE, acc->mpUserData), JABBER_MESSAGE_TYPE_ANY, 0, 0); //hm...
acc->hIqHandler = ijnet->AddIqHandler(acc->IqHandler(acc->JabberInterface, acc->iNODE, acc->ipUserData), JABBER_IQ_TYPE_ANY, 0, 0); //hm...
}
}
}
- else if (acc->hPrescenseHandler && acc->hMessageHandler && acc->hIqHandler)
+ acc = acc->next;
+ }
+ return 0;
+}
+int HandleDbContactDeleted(WPARAM w, LPARAM l)
+{
+ for(int i = 0; i < GetAccountsCount(); i++)
+ {
+ JabberAccount *acc = &Accounts;
+ if(!acc)
+ break;
+ IJabberSysInterface *ijsys = acc->JabberInterface->Sys();
+ LPTSTR tmp = ijsys->ContactToJID(HANDLE(w));
+ if(tmp)
{
- IJabberNetInterface *ijnet = acc->JabberInterface->Net();
- ijnet->RemoveHandler(acc->hPrescenseHandler);
- ijnet->RemoveHandler(acc->hMessageHandler);
- ijnet->RemoveHandler(acc->hIqHandler);
+ if(_tcsstr(_T(JUICK_JID), tmp))
+ {
+ if(acc->hPrescenseHandler && acc->hMessageHandler && acc->hIqHandler)
+ {
+ IJabberNetInterface *ijnet = acc->JabberInterface->Net();
+ ijnet->RemoveHandler(acc->hPrescenseHandler);
+ ijnet->RemoveHandler(acc->hMessageHandler);
+ ijnet->RemoveHandler(acc->hIqHandler);
+ }
+ }
}
acc = acc->next;
}