From de1841e8600420cf3cf35cb73d6e0226a9519687 Mon Sep 17 00:00:00 2001 From: Piotr Piastucki Date: Thu, 4 Jun 2015 12:10:46 +0000 Subject: Fixed a memleak in groupchat Added support for contact list fetching for plain Skype user finally enabling usage of Skype accounts via skylogin.dll (login only working once in a session though, currently cannot find out why). Prevent launching of duplicate keepAliveThread git-svn-id: http://svn.miranda-ng.org/main/trunk@13995 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/src/msn_contact.cpp | 165 +++++++++++++++++++++----------------- 1 file changed, 91 insertions(+), 74 deletions(-) (limited to 'protocols/MSN/src/msn_contact.cpp') diff --git a/protocols/MSN/src/msn_contact.cpp b/protocols/MSN/src/msn_contact.cpp index ea27761a17..0683a6a628 100644 --- a/protocols/MSN/src/msn_contact.cpp +++ b/protocols/MSN/src/msn_contact.cpp @@ -39,7 +39,7 @@ MCONTACT CMsnProto::MSN_HContactFromEmail(const char* wlid, const char* msnNick, hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName); if (netId != NETID_SKYPE) setString(hContact, "e-mail", szEmail); - setStringUtf(hContact, "Nick", msnNick ? msnNick : wlid); + setStringUtf(hContact, "Nick", msnNick ? msnNick : szEmail); setWord(hContact, "netId", netId); setString(hContact, "wlid", szEmail); if (temporary) @@ -148,88 +148,102 @@ bool CMsnProto::MSN_AddUser(MCONTACT hContact, const char* email, int netId, int return true; bool res = false; - if (flags == LIST_FL) { - if (needRemove) { - if (hContact == NULL) { - hContact = MSN_HContactFromEmail(email); - if (hContact == NULL) - return false; - } - - char id[MSN_GUID_LEN]; - if (!db_get_static(hContact, m_szModuleName, "ID", id, sizeof(id))) { - int netId = Lists_GetNetId(email); - if (leaveHotmail) - res = MSN_ABAddRemoveContact(id, netId, false); - else - res = MSN_ABAddDelContactGroup(id, NULL, "ABContactDelete"); - if (res) AddDelUserContList(email, flags, netId, true); - - delSetting(hContact, "GroupID"); - delSetting(hContact, "ID"); - MSN_RemoveEmptyGroups(); - } + if (MyOptions.netId == NETID_SKYPE) { + if (flags & LIST_BL) { + if (needRemove) return MSN_SKYABBlockContact(email, "unblock"); + return MSN_SKYABBlockContact(email, "block"); } - else { - DBVARIANT dbv = { 0 }; - if (!mir_strcmp(email, MyOptions.szEmail)) - getStringUtf("Nick", &dbv); - - unsigned res1 = MSN_ABContactAdd(email, dbv.pszVal, netId, msg, false); - if (netId == NETID_MSN && res1 == 2) { - netId = NETID_LCS; - res = MSN_ABContactAdd(email, dbv.pszVal, netId, msg, false) == 0; - } - else if (netId == NETID_MSN && res1 == 3) { - char szContactID[100]; - hContact = MSN_HContactFromEmail(email); - if (db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)) == 0) { - MSN_ABAddRemoveContact(szContactID, netId, true); - res = true; + else if ((flags & LIST_FL)) { + if (!needRemove) return MSN_SKYABAuthRq(email, msg); + if (!leaveHotmail) return MSN_SKYABDeleteContact(email); + return true; + } + else if ((flags & LIST_AL) && !needRemove) return MSN_SKYABAuthRsp(email, "accept"); + else if ((flags & LIST_RL) && !needRemove) return MSN_SKYABAuthRsp(email, "decline"); + } else { + if (flags == LIST_FL) { + if (needRemove) { + if (hContact == NULL) { + hContact = MSN_HContactFromEmail(email); + if (hContact == NULL) + return false; } - } - else res = (res1 == 0); - if (res) { - DBVARIANT dbv; - if (!db_get_utf(hContact, "CList", "Group", &dbv)) { - MSN_MoveContactToGroup(hContact, dbv.pszVal); - db_free(&dbv); + char id[MSN_GUID_LEN]; + if (!db_get_static(hContact, m_szModuleName, "ID", id, sizeof(id))) { + int netId = Lists_GetNetId(email); + if (leaveHotmail) + res = MSN_ABAddRemoveContact(id, netId, false); + else + res = MSN_ABAddDelContactGroup(id, NULL, "ABContactDelete"); + if (res) AddDelUserContList(email, flags, netId, true); + + delSetting(hContact, "GroupID"); + delSetting(hContact, "ID"); + MSN_RemoveEmptyGroups(); + } + } + else { + DBVARIANT dbv = { 0 }; + if (!mir_strcmp(email, MyOptions.szEmail)) + getStringUtf("Nick", &dbv); + + unsigned res1 = MSN_ABContactAdd(email, dbv.pszVal, netId, msg, false); + if (netId == NETID_MSN && res1 == 2) { + netId = NETID_LCS; + res = MSN_ABContactAdd(email, dbv.pszVal, netId, msg, false) == 0; + } + else if (netId == NETID_MSN && res1 == 3) { + char szContactID[100]; + hContact = MSN_HContactFromEmail(email); + if (db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)) == 0) { + MSN_ABAddRemoveContact(szContactID, netId, true); + res = true; + } } + else res = (res1 == 0); - char szContactID[100]; - if (db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)) == 0) - MSN_ABFind("ABFindByContacts", szContactID); + if (res) { + DBVARIANT dbv; + if (!db_get_utf(hContact, "CList", "Group", &dbv)) { + MSN_MoveContactToGroup(hContact, dbv.pszVal); + db_free(&dbv); + } - MSN_SharingFindMembership(true); - AddDelUserContList(email, flags, netId, false); - } -#ifdef OBSOLETE - else if (netId == 1 && strstr(email, "@yahoo.com") != 0) - MSN_FindYahooUser(email); -#endif + char szContactID[100]; + if (db_get_static(hContact, m_szModuleName, "ID", szContactID, sizeof(szContactID)) == 0) + MSN_ABFind("ABFindByContacts", szContactID); + + MSN_SharingFindMembership(true); + AddDelUserContList(email, flags, netId, false); + } + #ifdef OBSOLETE + else if (netId == 1 && strstr(email, "@yahoo.com") != 0) + MSN_FindYahooUser(email); + #endif - db_free(&dbv); + db_free(&dbv); + } } - } - else if (flags == LIST_LL) { - if (needRemove) - Lists_Remove(LIST_LL, email); - else - Lists_Add(LIST_LL, NETID_MSN, email); - } - else { - if (netId == 0) - netId = Lists_GetNetId(email); - res = MSN_SharingAddDelMember(email, flags, netId, needRemove ? "DeleteMember" : "AddMember"); - AddDelUserContList(email, flags, netId, needRemove); - if ((flags & LIST_BL) && !needRemove) { - ThreadData* thread = MSN_GetThreadByContact(email, SERVER_SWITCHBOARD); - if (thread) thread->sendTerminate(); + else if (flags == LIST_LL) { + if (needRemove) + Lists_Remove(LIST_LL, email); + else + Lists_Add(LIST_LL, NETID_MSN, email); } + else { + if (netId == 0) + netId = Lists_GetNetId(email); + res = MSN_SharingAddDelMember(email, flags, netId, needRemove ? "DeleteMember" : "AddMember"); + AddDelUserContList(email, flags, netId, needRemove); + if ((flags & LIST_BL) && !needRemove) { + ThreadData* thread = MSN_GetThreadByContact(email, SERVER_SWITCHBOARD); + if (thread) thread->sendTerminate(); + } - if ((flags & LIST_PL) && needRemove) - MSN_AddUser(hContact, email, netId, LIST_RL); + if ((flags & LIST_PL) && needRemove) + MSN_AddUser(hContact, email, netId, LIST_RL); + } } return res; } @@ -285,7 +299,10 @@ bool CMsnProto::MSN_RefreshContactList(void) } else { - /* TODO: Add pulling Skype contacts from event server or skypeweb or other unknown method.. */ + // Refresh Skype contact list + MSN_SKYABRefreshClist(); + + // Populate Contact list on MSN network to get status updates of contacts MSN_CreateContList(); } -- cgit v1.2.3