From 315ffb3628684434969b1f740860036a280dddfc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 26 Mar 2013 20:54:17 +0000 Subject: Google account autodetect git-svn-id: http://svn.miranda-ng.org/main/trunk@4208 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/GTalkExt/src/handlers.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'protocols/GTalkExt/src/handlers.cpp') diff --git a/protocols/GTalkExt/src/handlers.cpp b/protocols/GTalkExt/src/handlers.cpp index 83e4c036ad..157c890205 100644 --- a/protocols/GTalkExt/src/handlers.cpp +++ b/protocols/GTalkExt/src/handlers.cpp @@ -403,12 +403,31 @@ BOOL SendHandler(IJabberInterface *ji, HXML node, void *pUserData) } } +///////////////////////////////////////////////////////////////////////////////////////// + +IJabberInterface* IsGoogleAccount(LPCSTR szModuleName) +{ + IJabberInterface *japi = getJabberApi(szModuleName); + if (!japi) return NULL; + + DBVARIANT dbv; + if ( DBGetContactSettingString(NULL, szModuleName, "ManualHost", &dbv)) + return NULL; + + __try { + return (!strcmp(dbv.pszVal, "talk.google.com")) ? japi : NULL; + } + __finally { + db_free(&dbv); + } +} + int AccListChanged(WPARAM wParam, LPARAM lParam) { - if (PRAC_ADDED == wParam) { - IJabberInterface *japi = getJabberApi(((PROTOACCOUNT*)lParam)->szModuleName); - if (japi) - japi->Net()->AddSendHandler(SendHandler); + if (wParam == PRAC_ADDED) { + IJabberInterface *ji = IsGoogleAccount(((PROTOACCOUNT*)lParam)->szModuleName); + if (ji) + ji->Net()->AddSendHandler(SendHandler); } return 0; } @@ -418,10 +437,10 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) int count; PROTOACCOUNT **protos; ProtoEnumAccounts(&count, &protos); - for (int i = 0; i < count; i++) { - IJabberInterface *japi = getJabberApi(protos[i]->szModuleName); - if (japi) - japi->Net()->AddSendHandler(SendHandler); + for (int i=0; i < count; i++) { + IJabberInterface *ji = IsGoogleAccount(protos[i]->szModuleName); + if (ji) + ji->Net()->AddSendHandler(SendHandler); } HookEvent(ME_JABBER_MENUINIT, InitMenus); -- cgit v1.2.3