summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-02-05 11:10:32 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-02-05 11:10:32 +0000
commit6c5b2ecc6f9e1a7968e4eab4d2e1eeed4f82d1f0 (patch)
treef63019e4dd418ba6357d55d1b690f05820745dcc /protocols/VKontakte
parentdfe76cf65e6f20d5f9c92982a241ffecf6bb3405 (diff)
VKontakte:
fix(???) for empty contact name on friend request (attempt 3) fix memory leaks git-svn-id: http://svn.miranda-ng.org/main/trunk@12006 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/misc.cpp23
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp4
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp23
5 files changed, 34 insertions, 19 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index ebe357b40b..414d9fc65a 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -512,13 +512,28 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq)
/////////////////////////////////////////////////////////////////////////////////////////
+void __cdecl CVkProto::DBAddAuthRequestThread(void *p)
+{
+ MCONTACT hContact = (MCONTACT)p;
+ if (hContact == NULL || hContact == INVALID_CONTACT_ID || !IsOnline())
+ return;
+
+ for (int i = 0; i < MAX_RETRIES && CMString(ptrT(db_get_tsa(hContact, m_szModuleName, "Nick"))).IsEmpty(); i++) {
+ Sleep(1500);
+
+ if (!IsOnline())
+ return;
+ }
+ DBAddAuthRequest(hContact);
+}
+
void CVkProto::DBAddAuthRequest(const MCONTACT hContact)
{
debugLogA("CVkProto::DBAddAuthRequest");
- CMString tszNick = db_get_sa(hContact, m_szModuleName, "Nick");
- CMString tszFirstName = db_get_sa(hContact, m_szModuleName, "FirstName");
- CMString tszLastName = db_get_sa(hContact, m_szModuleName, "LastName");
+ CMString tszNick = ptrT(db_get_tsa(hContact, m_szModuleName, "Nick"));
+ CMString tszFirstName = ptrT(db_get_tsa(hContact, m_szModuleName, "FirstName"));
+ CMString tszLastName = ptrT(db_get_tsa(hContact, m_szModuleName, "LastName"));
ptrA szNick(mir_utf8encodeT(tszNick.GetBuffer()));
ptrA szFirstName(mir_utf8encodeT(tszFirstName.GetBuffer()));
@@ -591,7 +606,7 @@ void CVkProto::SetMirVer(MCONTACT hContact, int platform)
}
CMString MirVer, OldMirVer;
- OldMirVer = db_get_sa(hContact, m_szModuleName, "MirVer");
+ OldMirVer = ptrT(db_get_tsa(hContact, m_szModuleName, "MirVer"));
bool bSetFlag = true;
switch (platform) {
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index aec5954217..1ec4075495 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -575,7 +575,7 @@ void CVkProto::KickFromChat(int chat_id, int user_id, JSONNODE* pMsg)
if (msg.IsEmpty()) {
msg = TranslateT("You've been kicked by ");
if (hContact != NULL)
- msg += db_get_tsa(hContact, m_szModuleName, "Nick");
+ msg += ptrT(db_get_tsa(hContact, m_szModuleName, "Nick"));
else
msg += TranslateT("(Unknown contact)");
}
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 1ab60f23fa..d8215f969e 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -317,7 +317,7 @@ int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
{
LONG userID = getDword(hContact, "ID", -1);
bool bisFriend = (getByte(hContact, "Auth", -1) == 0);
- bool bisBroadcast = !(CMString(db_get_tsa(hContact, m_szModuleName, "AudioUrl")).IsEmpty());
+ bool bisBroadcast = !(CMString(ptrT(db_get_tsa(hContact, m_szModuleName, "AudioUrl"))).IsEmpty());
Menu_ShowItem(g_hContactMenuItems[CMI_VISITPROFILE], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend && !isChatRoom(hContact) && userID != VK_FEED_USER);
Menu_ShowItem(g_hContactMenuItems[CMI_DELETEFRIEND], bisFriend && userID != VK_FEED_USER);
@@ -658,7 +658,7 @@ void CVkProto::OnReceiveAuthRequest(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *
if (iRet == 2) {
CMString msg,
msgformat = TranslateT("User %s added as friend"),
- tszNick = db_get_tsa(param->hContact, m_szModuleName, "Nick");
+ tszNick = ptrT(db_get_tsa(param->hContact, m_szModuleName, "Nick"));
if (tszNick.IsEmpty())
tszNick = TranslateT("(Unknown contact)");
msg.AppendFormat(msgformat, tszNick.GetBuffer());
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 0d1e7f4ce3..7f705edd56 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -403,6 +403,7 @@ struct CVkProto : public PROTO<CVkProto>
void GrabCookies(NETLIBHTTPREQUEST *nhr);
void ApplyCookies(AsyncHttpRequest*);
+ void __cdecl DBAddAuthRequestThread(void *p);
void DBAddAuthRequest(const MCONTACT hContact);
MCONTACT MContactFromDbEvent(MEVENT hDbEvent);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 1dcc570619..d088d03b19 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -109,8 +109,8 @@ void CVkProto::SetServerStatus(int iNewStatus)
return;
int iOldStatus = m_iStatus;
- CMString oldStatusMsg = db_get_tsa(NULL, m_szModuleName, "OldStatusMsg");
- CMString ListeningToMsg = db_get_tsa(NULL, m_szModuleName, "ListeningTo");
+ CMString oldStatusMsg = ptrT(db_get_tsa(NULL, m_szModuleName, "OldStatusMsg"));
+ CMString ListeningToMsg = ptrT(db_get_tsa(NULL, m_szModuleName, "ListeningTo"));
if (iNewStatus == ID_STATUS_OFFLINE) {
m_iStatus = ID_STATUS_OFFLINE;
@@ -346,7 +346,7 @@ MCONTACT CVkProto::SetContactInfo(JSONNODE* pItem, bool flag, bool self)
setTString(hContact, "Phone", tszValue.GetBuffer());
tszValue = json_as_CMString(json_get(pItem, "status"));
- CMString tszOldStatus(db_get_tsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg"));
+ CMString tszOldStatus(ptrT(db_get_tsa(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg")));
if (tszValue != tszOldStatus) {
db_set_ts(hContact, hContact ? "CList" : m_szModuleName, "StatusMsg", tszValue.GetBuffer());
db_unset(hContact, m_szModuleName, "AudioUrl");
@@ -483,9 +483,8 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
hContact = FindUser(userid, true);
if (!getBool(hContact, "ReqAuth", false)) {
RetrieveUserInfo(userid);
- setByte(hContact, "ReqAuth", 1);
- Sleep(3000);
- DBAddAuthRequest(hContact);
+ setByte(hContact, "ReqAuth", 1);
+ ForkThread(&CVkProto::DBAddAuthRequestThread, (void *)hContact);
}
}
}
@@ -1013,7 +1012,7 @@ void CVkProto::RetrieveStatusMusic(const CMString &StatusMsg)
return;
CMString code;
- CMString oldStatusMsg = db_get_tsa(0, m_szModuleName, "OldStatusMsg");
+ CMString oldStatusMsg = ptrT(db_get_tsa(0, m_szModuleName, "OldStatusMsg"));
if (StatusMsg.IsEmpty()) {
if (m_iMusicSendMetod == sendBroadcastOnly)
code = "API.audio.setBroadcast();return null;";
@@ -1101,7 +1100,7 @@ INT_PTR __cdecl CVkProto::SvcDeleteFriend(WPARAM hContact, LPARAM flag)
return 1;
CMString formatstr = TranslateT("Are you sure to delete %s from your friend list?"),
- tszNick = db_get_tsa(hContact, m_szModuleName, "Nick"),
+ tszNick = ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")),
ptszMsg;
if (flag == 0) {
ptszMsg.AppendFormat(formatstr, tszNick.IsEmpty() ? TranslateT("(Unknown contact)") : tszNick);
@@ -1123,7 +1122,7 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST* reply, AsyncHttpRequest*
JSONROOT pRoot;
JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
if (pResponse != NULL) {
- CMString tszNick = db_get_tsa(param->hContact, m_szModuleName, "Nick");
+ CMString tszNick = ptrT(db_get_tsa(param->hContact, m_szModuleName, "Nick"));
if (tszNick.IsEmpty())
tszNick = TranslateT("(Unknown contact)");
CMString msgformat, msg;
@@ -1193,7 +1192,7 @@ INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM)
code += "return 1;";
CMString formatstr = TranslateT("Are you sure to ban %s? %s%sContinue?"),
- tszNick = db_get_tsa(hContact, m_szModuleName, "Nick"),
+ tszNick = ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")),
ptszMsg;
ptszMsg.AppendFormat(formatstr,
@@ -1222,7 +1221,7 @@ INT_PTR __cdecl CVkProto::SvcReportAbuse(WPARAM hContact, LPARAM)
return 1;
CMString formatstr = TranslateT("Are you sure to report abuse on %s?"),
- tszNick = db_get_tsa(hContact, m_szModuleName, "Nick"),
+ tszNick = ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")),
ptszMsg;
ptszMsg.AppendFormat(formatstr, tszNick.IsEmpty() ? TranslateT("(Unknown contact)") : tszNick);
if (IDNO == MessageBox(NULL, ptszMsg.GetBuffer(), TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
@@ -1239,7 +1238,7 @@ INT_PTR __cdecl CVkProto::SvcReportAbuse(WPARAM hContact, LPARAM)
INT_PTR __cdecl CVkProto::SvcOpenBroadcast(WPARAM hContact, LPARAM)
{
debugLogA("CVkProto::SvcOpenBroadcast");
- CMString tszAudio(db_get_tsa(hContact, m_szModuleName, "AudioUrl"));
+ CMString tszAudio(ptrT(db_get_tsa(hContact, m_szModuleName, "AudioUrl")));
if (!tszAudio.IsEmpty())
CallService(MS_UTILS_OPENURL, (WPARAM)OUF_TCHAR, (LPARAM)tszAudio.GetBuffer());