diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-11-29 14:02:02 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-11-29 14:02:02 +0000 |
commit | 425e0f8eb79c6779ebe40f75cce92194ed103389 (patch) | |
tree | 0f45cba281a1772c69007516a45e60c128619754 /protocols | |
parent | 63611a72e967abd262e35d8683d9e14126accd68 (diff) |
VKontakte:
replace (MCONTACT)-1 to INVALID_CONTACT_ID
fix freeze contacts in online status
git-svn-id: http://svn.miranda-ng.org/main/trunk@11150 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 40 |
3 files changed, 38 insertions, 14 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 4b6b9af959..ab404f82c9 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -456,7 +456,7 @@ MCONTACT CVkProto::MContactFromDbEvent(HANDLE hDbEvent) {
debugLogA("CVkProto::MContactFromDbEvent"); if (!hDbEvent || !IsOnline()) - return (MCONTACT)-1; + return INVALID_CONTACT_ID; DWORD body[2]; DBEVENTINFO dbei = { sizeof(dbei) }; @@ -464,9 +464,9 @@ MCONTACT CVkProto::MContactFromDbEvent(HANDLE hDbEvent) dbei.pBlob = (PBYTE)&body; if (db_event_get(hDbEvent, &dbei)) - return (MCONTACT)-1; + return INVALID_CONTACT_ID; if (dbei.eventType != EVENTTYPE_AUTHREQUEST || strcmp(dbei.szModule, m_szModuleName)) - return (MCONTACT)-1; + return INVALID_CONTACT_ID; MCONTACT hContact = DbGetAuthEventContact(&dbei); db_unset(hContact, m_szModuleName, "ReqAuth");
@@ -475,7 +475,7 @@ MCONTACT CVkProto::MContactFromDbEvent(HANDLE hDbEvent) void CVkProto::SetMirVer(MCONTACT hContact, int platform)
{
- if (hContact == NULL || hContact == -1)
+ if (hContact == NULL || hContact == INVALID_CONTACT_ID)
return;
if (platform == -1){
db_unset(hContact, m_szModuleName, "MirVer");
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 9dc10e69ee..3f38487f2c 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -624,7 +624,7 @@ int CVkProto::Authorize(HANDLE hDbEvent) if (!IsOnline())
return 1;
MCONTACT hContact = MContactFromDbEvent(hDbEvent);
- if (hContact == -1)
+ if (hContact == INVALID_CONTACT_ID)
return 1;
return AuthRequest(hContact, NULL);
@@ -636,7 +636,7 @@ int CVkProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason) if (!IsOnline())
return 1;
MCONTACT hContact = MContactFromDbEvent(hDbEvent);
- if (hContact == -1)
+ if (hContact == INVALID_CONTACT_ID)
return 1;
return SvcDeleteFriend(hContact,(LPARAM)true);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 326833dc79..159b703365 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -249,13 +249,15 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
{
- debugLogA("CVkProto::SetContactInfo");
- if (pItem == NULL)
- return -1;
+ if (pItem == NULL){
+ debugLogA("CVkProto::SetContactInfo pItem == NULL");
+ return INVALID_CONTACT_ID;
+ }
LONG userid = json_as_int(json_get(pItem, "id"));
+ debugLogA("CVkProto::SetContactInfo %d", userid);
if (userid == 0)
- return -1;
+ return NULL;
MCONTACT hContact = FindUser(userid, flag);
@@ -267,7 +269,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self) SetContactInfo(pItem, flag, true);
}
else if (hContact == NULL)
- return -1;
+ return NULL;
CMString tszNick, tszValue;
int iValue;
@@ -430,7 +432,27 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (pUsers == NULL)
return;
- for (size_t i = 0; SetContactInfo(json_at(pUsers, i)) != -1; i++);
+ LIST<void> arContacts(10, PtrKeySortT);
+ MCONTACT hContact;
+
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ if (!isChatRoom(hContact))
+ arContacts.insert((HANDLE)hContact);
+
+ for (size_t i = 0; (hContact = SetContactInfo(json_at(pUsers, i))) != INVALID_CONTACT_ID; i++)
+ if (hContact)
+ arContacts.remove((HANDLE)hContact);
+
+ for (int i = 0; i < arContacts.getCount(); i++){
+ hContact = (MCONTACT)arContacts[i];
+ if (getDword(hContact, "ID", -1) == m_myUserId)
+ continue;
+ if (getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE){
+ setWord(hContact, "Status", ID_STATUS_OFFLINE);
+ SetMirVer(hContact, -1);
+ }
+ }
+ arContacts.destroy();
JSONNODE *pRequests = json_get(pResponse, "requests");
if (pRequests == NULL)
@@ -446,7 +468,7 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe LONG userid = json_as_int(pInfo);
if (userid == 0)
break;
- MCONTACT hContact = FindUser(userid, true);
+ hContact = FindUser(userid, true);
if (!getBool(hContact, "ReqAuth", false)){
RetrieveUserInfo(userid);
setByte(hContact, "ReqAuth", 1);
@@ -497,7 +519,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq for (int i = 0; i<iCount; i++) {
MCONTACT hContact = SetContactInfo(json_at(pItems, i), true);
- if (hContact == NULL || hContact == -1)
+ if (hContact == NULL || hContact == INVALID_CONTACT_ID)
continue;
arContacts.remove((HANDLE)hContact);
@@ -507,6 +529,8 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq if (bCleanContacts)
for (int i = 0; i < arContacts.getCount(); i++)
CallService(MS_DB_CONTACT_DELETE, (WPARAM)arContacts[i], 0);
+
+ arContacts.destroy();
}
/////////////////////////////////////////////////////////////////////////////////////////
|