From 3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 9 Apr 2013 21:40:22 +0000 Subject: - the kernel filters out contacts by proto names much faster than a plugin; - database cycles simplified git-svn-id: http://svn.miranda-ng.org/main/trunk@4404 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Yahoo/src/services.cpp | 19 +++++----- protocols/Yahoo/src/yahoo.cpp | 76 +++++++++++++++++++--------------------- 2 files changed, 44 insertions(+), 51 deletions(-) (limited to 'protocols/Yahoo/src') diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp index b7db4b3c8d..2e91c9fdb6 100644 --- a/protocols/Yahoo/src/services.cpp +++ b/protocols/Yahoo/src/services.cpp @@ -31,17 +31,14 @@ void CYahooProto::logoff_buddies() { //set all contacts to 'offline' - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - SetWord( hContact, "Status", ID_STATUS_OFFLINE ); - SetDword(hContact, "IdleTS", 0); - SetDword(hContact, "PictLastCheck", 0); - SetDword(hContact, "PictLoading", 0); - db_unset(hContact, "CList", "StatusMsg"); - db_unset(hContact, m_szModuleName, "YMsg"); - db_unset(hContact, m_szModuleName, "YGMsg"); - //db_unset(hContact, m_szModuleName, "MirVer"); - } + for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + SetWord( hContact, "Status", ID_STATUS_OFFLINE ); + SetDword(hContact, "IdleTS", 0); + SetDword(hContact, "PictLastCheck", 0); + SetDword(hContact, "PictLoading", 0); + db_unset(hContact, "CList", "StatusMsg"); + db_unset(hContact, m_szModuleName, "YMsg"); + db_unset(hContact, m_szModuleName, "YGMsg"); } } diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp index 0f16a241e3..cfbff5ebfd 100644 --- a/protocols/Yahoo/src/yahoo.cpp +++ b/protocols/Yahoo/src/yahoo.cpp @@ -284,19 +284,17 @@ void CYahooProto::AddBuddy(HANDLE hContact, const char *group, const TCHAR *msg) HANDLE CYahooProto::getbuddyH(const char *yahoo_id) { - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - DBVARIANT dbv; - if (GetString(hContact, YAHOO_LOGINID, &dbv)) - continue; - - int tCompareResult = lstrcmpiA( dbv.pszVal, yahoo_id ); - db_free( &dbv ); - if ( tCompareResult ) - continue; - - return hContact; - } + for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + DBVARIANT dbv; + if (GetString(hContact, YAHOO_LOGINID, &dbv)) + continue; + + int tCompareResult = lstrcmpiA( dbv.pszVal, yahoo_id ); + db_free( &dbv ); + if ( tCompareResult ) + continue; + + return hContact; } return NULL; @@ -604,39 +602,37 @@ void CYahooProto::ext_got_stealth(char *stealthlist) if (stealthlist) stealth = y_strsplit(stealthlist, ",", -1); - for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - if (IsMyContact(hContact)) { - DBVARIANT dbv; - if (GetString( hContact, YAHOO_LOGINID, &dbv)) - continue; + for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { + DBVARIANT dbv; + if (GetString( hContact, YAHOO_LOGINID, &dbv)) + continue; - found = 0; + found = 0; - for(s = stealth; s && *s; s++) { + for(s = stealth; s && *s; s++) { - if (lstrcmpiA(*s, dbv.pszVal) == 0) { - YAHOO_DEBUGLOG("GOT id = %s", dbv.pszVal); - found = 1; - break; - } + if (lstrcmpiA(*s, dbv.pszVal) == 0) { + YAHOO_DEBUGLOG("GOT id = %s", dbv.pszVal); + found = 1; + break; } + } - /* Check the stealth list */ - if (found) { /* we have him on our Stealth List */ - YAHOO_DEBUGLOG("Setting STEALTH for id = %s", dbv.pszVal); - /* need to set the ApparentMode thingy */ - if (ID_STATUS_OFFLINE != GetWord(hContact, "ApparentMode", 0)) - GetWord(hContact, "ApparentMode", ID_STATUS_OFFLINE); - - } else { /* he is not on the Stealth List */ - //LOG(("Resetting STEALTH for id = %s", dbv.pszVal)); - /* need to delete the ApparentMode thingy */ - if (GetWord(hContact, "ApparentMode", 0)) - db_unset(hContact, m_szModuleName, "ApparentMode"); - } + /* Check the stealth list */ + if (found) { /* we have him on our Stealth List */ + YAHOO_DEBUGLOG("Setting STEALTH for id = %s", dbv.pszVal); + /* need to set the ApparentMode thingy */ + if (ID_STATUS_OFFLINE != GetWord(hContact, "ApparentMode", 0)) + GetWord(hContact, "ApparentMode", ID_STATUS_OFFLINE); + + } else { /* he is not on the Stealth List */ + //LOG(("Resetting STEALTH for id = %s", dbv.pszVal)); + /* need to delete the ApparentMode thingy */ + if (GetWord(hContact, "ApparentMode", 0)) + db_unset(hContact, m_szModuleName, "ApparentMode"); + } - db_free( &dbv ); - } + db_free( &dbv ); } } -- cgit v1.2.3