summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/misc.cpp20
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp13
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp30
-rw-r--r--protocols/VKontakte/src/vk_files.cpp16
-rw-r--r--protocols/VKontakte/src/vk_proto.h17
-rw-r--r--protocols/VKontakte/src/vk_search.cpp32
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp28
9 files changed, 101 insertions, 59 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 833dbebceb..c80990c01f 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -19,6 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" };
+CMString json_as_CMString(JSONNODE* pNode)
+{
+ ptrT pString(json_as_string(pNode));
+ CMString tszString = pString;
+ return tszString;
+}
+
+
LPCSTR findHeader(NETLIBHTTPREQUEST *pReq, LPCSTR szField)
{
for (int i = 0; i < pReq->headersCount; i++)
@@ -80,6 +88,9 @@ AsyncHttpRequest::AsyncHttpRequest()
AddHeader("Accept-Encoding", "booo");
pUserInfo = NULL;
m_iRetry = MAX_RETRIES;
+ bNeedsRestart = false;
+ bIsMainConn = false;
+ m_pFunc = NULL;
}
AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc)
@@ -107,6 +118,8 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url
m_pFunc = pFunc;
pUserInfo = NULL;
m_iRetry = MAX_RETRIES;
+ bNeedsRestart = false;
+ bIsMainConn = false;
}
AsyncHttpRequest::~AsyncHttpRequest()
@@ -306,7 +319,8 @@ void CVkProto::OnReceiveSmth(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
JSONROOT pRoot;
JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
- debugLog(_T("CVkProto::OnReceiveSmth %s"), json_as_string(pResponse));
+ ptrT ptszLog(json_as_string(pResponse));
+ debugLog(_T("CVkProto::OnReceiveSmth %s"), ptszLog);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -750,7 +764,7 @@ CMString CVkProto::GetVkPhotoItem(JSONNODE *pPhoto, BBCSupport iBBC)
tszRes.AppendFormat(_T("%s (%dx%d)"), SetBBCString(TranslateT("Photo"), iBBC, vkbbcUrl, ptszLink).GetBuffer(), iWidth, iHeight);
if (m_iIMGBBCSupport)
tszRes.AppendFormat(_T("\n\t[img]%s[/img]"), ptszPreviewLink ? ptszPreviewLink : (ptszLink ? ptszLink : _T("")));
- CMString tszText = json_as_string(json_get(pPhoto, "text"));
+ CMString tszText = json_as_CMString(json_get(pPhoto, "text"));
if (!tszText.IsEmpty())
tszRes += "\n" + tszText;
@@ -930,7 +944,7 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments, BBCSupport iBBC)
ptrT ptszUrl(json_as_string(json_get(pLink, "url")));
ptrT ptszTitle(json_as_string(json_get(pLink, "title")));
ptrT ptszDescription(json_as_string(json_get(pLink, "description")));
- CMString tszImage(json_as_string(json_get(pLink, "image_src")));
+ CMString tszImage(json_as_CMString(json_get(pLink, "image_src")));
res.AppendFormat(_T("%s: %s"),
SetBBCString(TranslateT("Link"), iBBC, vkbbcB).GetBuffer(),
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 76cc6393fd..66ff82d699 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 0
-#define __BUILD_NUM 39
+#define __BUILD_NUM 40
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h
index 1649b3659c..2a20d681ad 100644
--- a/protocols/VKontakte/src/vk.h
+++ b/protocols/VKontakte/src/vk.h
@@ -80,6 +80,8 @@ struct CVkProto;
extern LIST<CVkProto> vk_Instances;
extern HINSTANCE hInst;
+CMString json_as_CMString(JSONNODE* pNode);
+
LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField);
bool tlstrstr(TCHAR* _s1, TCHAR* _s2);
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 698198cf94..8b1a567ad2 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -41,11 +41,11 @@ CVkChatInfo* CVkProto::AppendChat(int id, JSONNODE *pDlg)
if (c != NULL)
return c;
- ptrT tszTitle;
+ ptrT ptszTitle;
c = new CVkChatInfo(id);
if (pDlg != NULL) {
- tszTitle = json_as_string(json_get(pDlg, "title"));
- c->m_tszTopic = mir_tstrdup((tszTitle != NULL) ? tszTitle : _T(""));
+ ptszTitle = json_as_string(json_get(pDlg, "title"));
+ c->m_tszTopic = mir_tstrdup((ptszTitle != NULL) ? ptszTitle : _T(""));
}
CMString sid;
@@ -55,7 +55,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, JSONNODE *pDlg)
GCSESSION gcw = { sizeof(gcw) };
gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
- gcw.ptszName = tszTitle;
+ gcw.ptszName = ptszTitle;
gcw.ptszID = sid;
CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw);
@@ -66,7 +66,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, JSONNODE *pDlg)
CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci);
c->m_hContact = gci.hContact;
- setTString(gci.hContact, "Nick", tszTitle);
+ setTString(gci.hContact, "Nick", ptszTitle);
m_chats.insert(c);
GCDEST gcd = { m_szModuleName, sid, GC_EVENT_ADDGROUP };
@@ -369,6 +369,7 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam)
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
Push(pReq);
}
+ break;
case GC_USER_LOGMENU:
LogMenuHook(cc, gch);
@@ -570,7 +571,7 @@ void CVkProto::KickFromChat(int chat_id, int user_id, JSONNODE* pMsg)
return;
MCONTACT hContact = FindUser(user_id, false);
- CMString msg = json_as_string(json_get(pMsg, "body"));
+ CMString msg = json_as_CMString(json_get(pMsg, "body"));
if (msg.IsEmpty()) {
msg = TranslateT("You've been kicked by ");
if (hContact != NULL)
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index 1fda776488..1c9daf9df9 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -107,11 +107,11 @@ void CVkProto::CreateVkUserInfoList(OBJLIST<CVkUserInfo> &vkUsers, JSONNODE *pRe
if (!UserId)
continue;
- CMString tszNick = json_as_string(json_get(pProfile, "first_name"));
+ CMString tszNick = json_as_CMString(json_get(pProfile, "first_name"));
tszNick.AppendChar(' ');
- tszNick += json_as_string(json_get(pProfile, "last_name"));
+ tszNick += json_as_CMString(json_get(pProfile, "last_name"));
CMString tszLink = _T("https://vk.com/");
- tszLink += json_as_string(json_get(pProfile, "screen_name"));
+ tszLink += json_as_CMString(json_get(pProfile, "screen_name"));
CVkUserInfo * vkUser = new CVkUserInfo(UserId, false, tszNick, tszLink, FindUser(UserId));
vkUsers.insert(vkUser);
}
@@ -123,9 +123,9 @@ void CVkProto::CreateVkUserInfoList(OBJLIST<CVkUserInfo> &vkUsers, JSONNODE *pRe
if (!UserId)
continue;
- CMString tszNick = json_as_string(json_get(pProfile, "name"));
+ CMString tszNick = json_as_CMString(json_get(pProfile, "name"));
CMString tszLink = _T("https://vk.com/");
- tszLink += json_as_string(json_get(pProfile, "screen_name"));
+ tszLink += json_as_CMString(json_get(pProfile, "screen_name"));
CVkUserInfo * vkUser = new CVkUserInfo(UserId, true, tszNick, tszLink);
vkUsers.insert(vkUser);
}
@@ -144,9 +144,9 @@ CVKNewsItem* CVkProto::GetVkNewsItem(JSONNODE *pItem, OBJLIST<CVkUserInfo> &vkUs
LONG iSourceId = json_as_int(json_get(pItem, "source_id"));
iSourceId = iSourceId ? iSourceId : json_as_int(json_get(pItem, "owner_id"));
LONG iPostId = json_as_int(json_get(pItem, "post_id"));
- CMString tszText = json_as_string(json_get(pItem, "text"));
+ CMString tszText = json_as_CMString(json_get(pItem, "text"));
- vkNewsItem->tszType = json_as_string(json_get(pItem, "type"));
+ vkNewsItem->tszType = json_as_CMString(json_get(pItem, "type"));
vkNewsItem->vkUser = GetVkUserInfo(iSourceId, vkUsers);
vkNewsItem->bIsGroup = vkNewsItem->vkUser->m_bIsGroup;
vkNewsItem->tDate = json_as_int(json_get(pItem, "date"));
@@ -270,7 +270,7 @@ CMString CVkProto::GetVkFeedback(JSONNODE *pFeedback, VKObjType vkFeedbackType,
if (iUserId) {
vkUser = GetVkUserInfo(iUserId, vkUsers);
- CMString tszText = json_as_string(json_get(pFeedback, "text"));
+ CMString tszText = json_as_CMString(json_get(pFeedback, "text"));
tszRes.AppendFormat(tszFormat, SetBBCString(vkUser->m_tszUserNick.GetBuffer(), m_iBBCForNews, vkbbcUrl, vkUser->m_tszLink.GetBuffer()), ClearFormatNick(tszText).GetBuffer());
}
@@ -302,11 +302,11 @@ CVKNewsItem* CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType, TC
else if (vkParentType == vkVideo) {
LONG iOwnerId = json_as_int(json_get(pParent, "owner_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
- CMString tszTitle = json_as_string(json_get(pParent, "title"));
+ CMString tszTitle = json_as_CMString(json_get(pParent, "title"));
vkNotificationItem->tszId.AppendFormat(_T("%d_%d"), iOwnerId, iId);
vkNotificationItem->tszLink.AppendFormat(_T("https://vk.com/video%s"), vkNotificationItem->tszId.GetBuffer());
- CMString tszText = json_as_string(json_get(pParent, "text"));
+ CMString tszText = json_as_CMString(json_get(pParent, "text"));
ClearFormatNick(tszText);
if (!tszText.IsEmpty())
@@ -323,7 +323,7 @@ CVKNewsItem* CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType, TC
vkNotificationItem->tszId.AppendFormat(_T("%d_%d"), iOwnerId, iId);
vkNotificationItem->tszLink.AppendFormat(_T("https://vk.com/wall%s%s"), vkNotificationItem->tszId.GetBuffer(), ptszReplyLink ? ptszReplyLink : _T(""));
- CMString tszText = json_as_string(json_get(pParent, "text"));
+ CMString tszText = json_as_CMString(json_get(pParent, "text"));
ClearFormatNick(tszText);
if (!tszText.IsEmpty())
@@ -337,12 +337,12 @@ CVKNewsItem* CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType, TC
else if (vkParentType == vkTopic) {
LONG iOwnerId = json_as_int(json_get(pParent, "owner_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
- CMString tszTitle = json_as_string(json_get(pParent, "title"));
+ CMString tszTitle = json_as_CMString(json_get(pParent, "title"));
vkNotificationItem->tszId.AppendFormat(_T("%d_%d"), iOwnerId, iId);
vkNotificationItem->tszLink.AppendFormat(_T("https://vk.com/topic%s%s"),
vkNotificationItem->tszId.GetBuffer(), ptszReplyLink ? ptszReplyLink : _T(""));
- CMString tszText = json_as_string(json_get(pParent, "text"));
+ CMString tszText = json_as_CMString(json_get(pParent, "text"));
ClearFormatNick(tszText);
if (!tszText.IsEmpty())
@@ -354,7 +354,7 @@ CVKNewsItem* CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType, TC
vkNotificationItem->tszText.AppendFormat(_T("\n%s"), SetBBCString(tszTitle.GetBuffer(), m_iBBCForNews, vkbbcUrl, vkNotificationItem->tszLink.GetBuffer()).GetBuffer());
}
else if (vkParentType == vkComment) {
- CMString tszText = json_as_string(json_get(pParent, "text"));
+ CMString tszText = json_as_CMString(json_get(pParent, "text"));
ClearFormatNick(tszText);
JSONNODE *pNode = json_get(pParent, "photo");
@@ -391,7 +391,7 @@ CVKNewsItem* CVkProto::GetVkNotificationsItem(JSONNODE *pItem, OBJLIST<CVkUserIn
if (pItem == NULL)
return NULL;
- CMString tszType = json_as_string(json_get(pItem, "type"));
+ CMString tszType = json_as_CMString(json_get(pItem, "type"));
VKObjType vkFeedbackType = vkNull, vkParentType = vkNull;
CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType);
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index 05115bfaa6..79e5edc400 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -50,7 +50,8 @@ CVkFileUploadParam::VKFileType CVkFileUploadParam::GetType()
_tsplitpath(FileName, DRIVE, DIR, FNAME, EXT);
CMStringA fn;
- fn.AppendFormat("%s%s", mir_utf8encodeT(FNAME), mir_utf8encodeT(EXT));
+ ptrA pszFNAME(mir_utf8encodeT(FNAME)), pszEXT(mir_utf8encodeT(EXT));
+ fn.AppendFormat("%s%s", pszFNAME, pszEXT);
fname = mir_strdup(fn.GetBuffer());
if (tlstrstr(img, EXT)) {
@@ -173,7 +174,7 @@ void CVkProto::OnReciveUploadServer(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
return;
}
- CMStringA uri = json_as_string(json_get(pResponse, "upload_url"));
+ CMStringA uri = json_as_CMString(json_get(pResponse, "upload_url"));
if (uri.IsEmpty()) {
SendFileFiled(fup);
return;
@@ -253,17 +254,18 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
JSONROOT pRoot;
CheckJsonResponse(pReq, reply, pRoot);
- CMString server = json_as_string(json_get(pRoot, "server"));
- CMString hash = json_as_string(json_get(pRoot, "hash"));
+ ptrT server(json_as_string(json_get(pRoot, "server")));
+ ptrT hash(json_as_string(json_get(pRoot, "hash")));
CMString upload;
AsyncHttpRequest *pUploadReq;
switch (fup->GetType()) {
case CVkFileUploadParam::typeImg:
- upload = json_as_string(json_get(pRoot, "photo"));
+ upload = json_as_CMString(json_get(pRoot, "photo"));
if (upload == _T("[]")) {
SendFileFiled(fup, _T("NotUpload Photo"));
+ return;
}
pUploadReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/photos.saveMessagesPhoto.json", true, &CVkProto::OnReciveUploadFile)
<< TCHAR_PARAM("server", server)
@@ -272,7 +274,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
<< VER_API;
break;
case CVkFileUploadParam::typeAudio:
- upload = json_as_string(json_get(pRoot, "audio"));
+ upload = json_as_CMString(json_get(pRoot, "audio"));
if (upload == _T("[]")) {
SendFileFiled(fup, _T("NotUpload Audio"));
return;
@@ -284,7 +286,7 @@ void CVkProto::OnReciveUpload(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
<< VER_API;
break;
case CVkFileUploadParam::typeDoc:
- upload = json_as_string(json_get(pRoot, "file"));
+ upload = json_as_CMString(json_get(pRoot, "file"));
if (upload.IsEmpty()) {
SendFileFiled(fup, _T("NotUpload Doc"));
return;
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 3a562ad312..1e29b642b7 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -106,7 +106,11 @@ struct CVkSendMsgParam
struct CVkChatMessage : public MZeroedObject
{
- CVkChatMessage(int _id) : m_mid(_id) {}
+ CVkChatMessage(int _id) :
+ m_mid(_id),
+ m_uid(0),
+ m_date(0),
+ m_bHistory(false){}
int m_mid, m_uid, m_date;
bool m_bHistory;
@@ -115,7 +119,11 @@ struct CVkChatMessage : public MZeroedObject
struct CVkChatUser : public MZeroedObject
{
- CVkChatUser(int _id) : m_uid(_id) {}
+ CVkChatUser(int _id) :
+ m_uid(_id),
+ m_bDel(false),
+ m_bUnknown(false)
+ {}
int m_uid;
bool m_bDel, m_bUnknown;
@@ -127,7 +135,10 @@ struct CVkChatInfo : public MZeroedObject
CVkChatInfo(int _id) :
m_users(10, NumericKeySortT),
m_msgs(10, NumericKeySortT),
- m_chatid(_id)
+ m_chatid(_id),
+ m_admin_id(0),
+ m_bHistoryRead(0),
+ m_hContact(INVALID_CONTACT_ID)
{}
int m_chatid, m_admin_id;
diff --git a/protocols/VKontakte/src/vk_search.cpp b/protocols/VKontakte/src/vk_search.cpp
index b4503fe1b2..6eef22a8f8 100644
--- a/protocols/VKontakte/src/vk_search.cpp
+++ b/protocols/VKontakte/src/vk_search.cpp
@@ -132,12 +132,18 @@ void CVkProto::OnSearch(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
PROTOSEARCHRESULT psr = { sizeof(psr) };
psr.flags = PSR_TCHAR;
- psr.id = mir_wstrdup(json_as_string(json_get(pRecord, "id")));
- psr.firstName = mir_wstrdup(json_as_string(json_get(pRecord, "first_name")));
- psr.lastName = mir_wstrdup(json_as_string(json_get(pRecord, "last_name")));
- psr.nick = mir_wstrdup(json_as_string(json_get(pRecord, "nickname")));
+ ptrT pId(json_as_string(json_get(pRecord, "id")));
+ ptrT pFirstName(json_as_string(json_get(pRecord, "first_name")));
+ ptrT pLastName(json_as_string(json_get(pRecord, "last_name")));
+ ptrT pNick(json_as_string(json_get(pRecord, "nickname")));
+ ptrT pDomain(json_as_string(json_get(pRecord, "domain")));
+
+ psr.id = mir_wstrdup(pId);
+ psr.firstName = mir_wstrdup(pFirstName);
+ psr.lastName = mir_wstrdup(pLastName);
+ psr.nick = mir_wstrdup(pNick);
if (!psr.nick || !psr.nick[0])
- psr.nick = mir_wstrdup(json_as_string(json_get(pRecord, "domain")));
+ psr.nick = mir_wstrdup(pDomain);
bool filter = true;
if (pParam) {
@@ -191,11 +197,17 @@ void CVkProto::OnSearchByMail(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
PROTOSEARCHRESULT psr = { sizeof(psr) };
psr.flags = PSR_TCHAR;
- psr.id = mir_wstrdup(json_as_string(json_get(pRecord, "id")));
- psr.firstName = mir_wstrdup(json_as_string(json_get(pRecord, "first_name")));
- psr.lastName = mir_wstrdup(json_as_string(json_get(pRecord, "last_name")));
- psr.nick = mir_wstrdup(json_as_string(json_get(pRecord, "nickname")));
- psr.email = mir_wstrdup(json_as_string(json_get(pRecord, "contact")));
+ ptrT pId(json_as_string(json_get(pRecord, "id")));
+ ptrT pFirstName(json_as_string(json_get(pRecord, "first_name")));
+ ptrT pLastName(json_as_string(json_get(pRecord, "last_name")));
+ ptrT pNick(json_as_string(json_get(pRecord, "nickname")));
+ ptrT pEmail(json_as_string(json_get(pRecord, "contact")));
+
+ psr.id = mir_wstrdup(pId);
+ psr.firstName = mir_wstrdup(pFirstName);
+ psr.lastName = mir_wstrdup(pLastName);
+ psr.nick = mir_wstrdup(pNick);
+ psr.email = mir_wstrdup(pEmail);
if (!psr.nick || !psr.nick[0])
psr.nick = psr.email;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 93c8816972..cdf8809212 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -274,14 +274,14 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
CMString tszNick, tszValue;
int iValue;
- tszValue = json_as_string(json_get(pItem, "first_name"));
+ tszValue = json_as_CMString(json_get(pItem, "first_name"));
if (!tszValue.IsEmpty()) {
setTString(hContact, "FirstName", tszValue.GetBuffer());
tszNick.Append(tszValue);
tszNick.AppendChar(' ');
}
- tszValue = json_as_string(json_get(pItem, "last_name"));
+ tszValue = json_as_CMString(json_get(pItem, "last_name"));
if (!tszValue.IsEmpty()) {
setTString(hContact, "LastName", tszValue.GetBuffer());
tszNick.Append(tszValue);
@@ -294,7 +294,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
if (sex)
setByte(hContact, "Gender", sex == 2 ? 'M' : 'F');
- tszValue = json_as_string(json_get(pItem, "bdate"));
+ tszValue = json_as_CMString(json_get(pItem, "bdate"));
if (!tszValue.IsEmpty()) {
int d, m, y, iReadCount;
iReadCount = _stscanf(tszValue.GetBuffer(), _T("%d.%d.%d"), &d, &m, &y);
@@ -306,7 +306,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
}
}
- tszValue = json_as_string(json_get(pItem, "photo_100"));
+ tszValue = json_as_CMString(json_get(pItem, "photo_100"));
if (!tszValue.IsEmpty()) {
SetAvatarUrl(hContact, tszValue);
ReloadAvatarInfo(hContact);
@@ -317,7 +317,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
setWord(hContact, "Status", iNewStatus);
if (iNewStatus == ID_STATUS_ONLINE) {
- int online_app = _ttoi(json_as_string(json_get(pItem, "online_app")));
+ int online_app = _ttoi(json_as_CMString(json_get(pItem, "online_app")));
int online_mobile = json_as_int(json_get(pItem, "online_mobile"));
if (online_app == 0 && online_mobile == 0)
@@ -333,15 +333,15 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
if ((iValue = json_as_int(json_get(pItem, "timezone"))) != 0)
setByte(hContact, "Timezone", iValue * -2);
- tszValue = json_as_string(json_get(pItem, "mobile_phone"));
+ tszValue = json_as_CMString(json_get(pItem, "mobile_phone"));
if (!tszValue.IsEmpty())
setTString(hContact, "Cellular", tszValue.GetBuffer());
- tszValue = json_as_string(json_get(pItem, "home_phone"));
+ tszValue = json_as_CMString(json_get(pItem, "home_phone"));
if (!tszValue.IsEmpty())
setTString(hContact, "Phone", tszValue.GetBuffer());
- tszValue = json_as_string(json_get(pItem, "status"));
+ tszValue = json_as_CMString(json_get(pItem, "status"));
CMString tszOldStatus(db_get_tsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg"));
if (tszValue != tszOldStatus) {
db_set_ts(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", tszValue.GetBuffer());
@@ -349,7 +349,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
JSONNODE* pAudio = json_get(pItem, "status_audio");
if (pAudio != NULL) {
db_set_ts(hContact, m_szModuleName, "ListeningTo", tszValue.GetBuffer());
- tszValue = json_as_string(json_get(pAudio, "url"));
+ tszValue = json_as_CMString(json_get(pAudio, "url"));
db_set_ts(hContact, m_szModuleName, "AudioUrl", tszValue.GetBuffer());
}
else if (tszValue.GetBuffer()[0] == TCHAR(9835) && tszValue.GetLength() > 2)
@@ -358,12 +358,12 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
db_unset(hContact, m_szModuleName, "ListeningTo");
}
- tszValue = json_as_string(json_get(pItem, "about"));
+ tszValue = json_as_CMString(json_get(pItem, "about"));
if (!tszValue.IsEmpty())
setTString(hContact, "About", tszValue.GetBuffer());
- tszValue = json_as_string(json_get(pItem, "domain"));
+ tszValue = json_as_CMString(json_get(pItem, "domain"));
if (!tszValue.IsEmpty()) {
setTString(hContact, "domain", tszValue.GetBuffer());
CMString tszUrl("https://vk.com/");
@@ -650,8 +650,8 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
}
if (chat_id != 0) {
- CMString action_chat = json_as_string(json_get(pMsg, "action"));
- int action_mid = _ttoi(json_as_string(json_get(pMsg, "action_mid")));
+ CMString action_chat = json_as_CMString(json_get(pMsg, "action"));
+ int action_mid = _ttoi(json_as_CMString(json_get(pMsg, "action_mid")));
if ((action_chat == "chat_kick_user") && (action_mid == m_myUserId))
KickFromChat(chat_id, uid, pMsg);
else
@@ -976,7 +976,7 @@ void CVkProto::OnReceiveStatus(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
JSONNODE *pAudio = json_get(pResponse, "audio");
if (pAudio == NULL) {
- CMString StatusText = json_as_string(json_get(pResponse, "text"));
+ CMString StatusText = json_as_CMString(json_get(pResponse, "text"));
if (StatusText.GetBuffer()[0] != TCHAR(9835))
setTString("OldStatusMsg", StatusText.GetBuffer());
}