diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-03-09 10:29:47 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2016-03-09 10:29:47 +0000 |
commit | c1b1eff82c3101a6bf00550ff27d4ae6823bbdbd (patch) | |
tree | df2ce6dc43ca3db3451b344978488369ba58af71 /protocols/VKontakte/src | |
parent | a7a5b0dbc9f06ef5a083116f4977a88ebcd9cefd (diff) |
VKontakte:
add LastSeen support
add additional user profile fields (country, city, relation, interests, activities, music, movies, tv, books, games, quotes)
add hidden option for lang (‘VKLang’, UNICODE)
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@16449 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 91 |
7 files changed, 104 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 370e4ba624..e94368353d 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1187,9 +1187,12 @@ void CVkProto::SetInvisible(MCONTACT hContact) if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) {
setWord(hContact, "Status", ID_STATUS_INVISIBLE);
SetMirVer(hContact, 1);
+ db_set_w(hContact, "BuddyExpectator", "LastStatus", ID_STATUS_INVISIBLE);
debugLogA("CVkProto::SetInvisible %d set ID_STATUS_INVISIBLE", getDword(hContact, "ID", -1));
}
- setDword(hContact, "InvisibleTS", time(NULL));
+ time_t now = time(NULL);
+ db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)now);
+ setDword(hContact, "InvisibleTS", (DWORD)now);
}
CMString CVkProto::RemoveBBC(CMString& tszSrc)
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 66b24a328c..47165280c4 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 1
-#define __BUILD_NUM 23
+#define __BUILD_NUM 24
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 00f4fd06f0..165de633b9 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -139,6 +139,8 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : if (m_ReturnChatMessage == NULL)
m_ReturnChatMessage = mir_tstrdup(TranslateT("I'm back"));
+ m_VKLang = getTStringA("VKLang");
+
m_iMaxFriendsCount = getDword("MaxFriendsCount", 1000);
// Set all contacts offline -- in case we crashed
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 6d04a33b8d..5cc1c9381b 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -443,6 +443,7 @@ private: LONG m_myUserId;
ptrT m_defaultGroup;
ptrT m_ReturnChatMessage;
+ ptrT m_VKLang;
ptrA
m_pollingServer,
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 872a12cbb3..cc83ceb3b4 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -80,6 +80,8 @@ AsyncHttpRequest* CVkProto::Push(AsyncHttpRequest *pReq, int iTimeout) {
debugLogA("CVkProto::Push");
pReq->timeout = iTimeout;
+ if (pReq->m_bApiReq && m_VKLang)
+ pReq << TCHAR_PARAM("lang", m_VKLang);
{
mir_cslock lck(m_csRequestsQueue);
m_arRequestsQueue.insert(pReq);
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 0d921afc7f..d90d2c452d 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -237,4 +237,9 @@ struct CVKChatContactTypingParam { int m_ChatId;
int m_UserId;
+};
+
+struct CVKInteres {
+ const char *szField;
+ TCHAR *ptszTranslate;
};
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 79ce7295a2..598856ffa0 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -23,7 +23,9 @@ mir_cs CVkProto::m_csTimer; char szBlankUrl[] = "https://oauth.vk.com/blank.html";
static char VK_TOKEN_BEG[] = "access_token=";
static char VK_LOGIN_DOMAIN[] = "https://m.vk.com";
-static char fieldsName[] = "id, first_name, last_name, photo_100, bdate, sex, timezone, contacts, online, status, about, domain";
+static char fieldsName[] = "id, first_name, last_name, photo_100, bdate, sex, timezone, "
+ "contacts, last_seen, online, status, country, city, relation, interests, activities, "
+ "music, movies, tv, books, games, quotes, about, domain";
/////////////////////////////////////////////////////////////////////////////////////////
@@ -305,14 +307,27 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) ReloadAvatarInfo(hContact);
}
+ const JSONNode &jnLastSeen = jnItem["last_seen"];
+ if (jnLastSeen) {
+ int iLastSeen = jnLastSeen["time"].as_int();
+ int iOldLastSeen = db_get_dw(hContact, "BuddyExpectator", "LastSeen");
+ if (iLastSeen && iLastSeen > iOldLastSeen) {
+ db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)iLastSeen);
+ db_set_w(hContact, "BuddyExpectator", "LastStatus", ID_STATUS_ONLINE);
+ }
+ }
+
int iNewStatus = (jnItem["online"].as_int() == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE;
if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != iNewStatus)
setWord(hContact, "Status", iNewStatus);
if (iNewStatus == ID_STATUS_ONLINE) {
+ db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)time(NULL));
+ db_set_w(hContact, "BuddyExpectator", "LastStatus", ID_STATUS_ONLINE);
+
int online_app = _ttoi(jnItem["online_app"].as_mstring());
int online_mobile = jnItem["online_mobile"].as_int();
-
+
if (online_app == 0 && online_mobile == 0)
SetMirVer(hContact, 7); // vk.com
else if (online_app != 0)
@@ -357,6 +372,78 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) db_unset(hContact, m_szModuleName, "AudioUrl");
}
+ const JSONNode &jnCountry = jnItem["country"];
+ if (jnCountry) {
+ tszValue = jnCountry["title"].as_mstring();
+ if (!tszValue.IsEmpty())
+ setTString(hContact, "Country", tszValue);
+ }
+
+ const JSONNode &jnCity = jnItem["city"];
+ if (jnCity) {
+ tszValue = jnCity["title"].as_mstring();
+ if (!tszValue.IsEmpty())
+ setTString(hContact, "City", tszValue);
+ }
+
+ // MaritalStatus
+ TCHAR * ptszMaritalStatus[] = {
+ TranslateT("<not specified>"),
+ TranslateT("single"),
+ TranslateT("in a relationship"),
+ TranslateT("engaged"),
+ TranslateT("married"),
+ TranslateT("it's complicated"),
+ TranslateT("actively searching"),
+ TranslateT("in love")
+ };
+
+ if (jnItem["relation"] && jnItem["relation"].as_int())
+ setTString(hContact, "MaritalStatus", ptszMaritalStatus[jnItem["relation"].as_int()]);
+
+ // interests, activities, music, movies, tv, books, games, quotes
+ CVKInteres vkInteres[] = {
+ { "interests", TranslateT("Interests") },
+ { "activities", TranslateT("Activities") },
+ { "music", TranslateT("Music") },
+ { "movies", TranslateT("Movies") },
+ { "tv", TranslateT("TV") },
+ { "books", TranslateT("Books") },
+ { "games", TranslateT("Games") },
+ { "quotes", TranslateT("Quotes") }
+ };
+
+ int iInteres = 0;
+
+ for (int i = 0; i < _countof(vkInteres); i++) {
+ tszValue = jnItem[vkInteres[i].szField].as_mstring();
+ if (tszValue.IsEmpty())
+ continue;
+
+ CMStringA InteresCat(FORMAT, "Interest%dCat", iInteres);
+ CMStringA InteresText(FORMAT, "Interest%dText", iInteres);
+
+ setTString(hContact, InteresCat, vkInteres[i].ptszTranslate);
+ setTString(hContact, InteresText, tszValue);
+
+ iInteres++;
+
+ }
+
+ for (int i = iInteres; iInteres > 0; i++) {
+ CMStringA InteresCat(FORMAT, "Interest%dCat", iInteres);
+ ptrT ptszCat(db_get_tsa(hContact, m_szModuleName, InteresCat));
+ if (!ptszCat)
+ break;
+ db_unset(hContact, m_szModuleName, InteresCat);
+
+ CMStringA InteresText(FORMAT, "Interest%dText", iInteres);
+ ptrT ptszText(db_get_tsa(hContact, m_szModuleName, InteresText));
+ if (!ptszText)
+ break;
+ db_unset(hContact, m_szModuleName, InteresText);
+ }
+
tszValue = jnItem["about"].as_mstring();
if (!tszValue.IsEmpty())
setTString(hContact, "About", tszValue);
|