summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/VKontakte/res/resource.rc20
-rw-r--r--protocols/VKontakte/src/misc.cpp111
-rw-r--r--protocols/VKontakte/src/resource.h3
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_dialogs.cpp20
-rw-r--r--protocols/VKontakte/src/vk_dialogs.h2
-rw-r--r--protocols/VKontakte/src/vk_history.cpp24
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp65
-rw-r--r--protocols/VKontakte/src/vk_options.cpp38
-rw-r--r--protocols/VKontakte/src/vk_options.h11
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp9
-rw-r--r--protocols/VKontakte/src/vk_struct.h19
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp91
13 files changed, 212 insertions, 203 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index 5badf44389..04052a8f97 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -111,7 +111,7 @@ BEGIN
VERTGUIDE, 192
VERTGUIDE, 288
TOPMARGIN, 7
- BOTTOMMARGIN, 177
+ BOTTOMMARGIN, 182
END
IDD_INVITE, DIALOG
@@ -286,31 +286,33 @@ BEGIN
EDITTEXT IDC_RET_CHAT_MES,134,208,157,12,ES_AUTOHSCROLL
END
-IDD_OPT_MAIN DIALOGEX 0, 0, 304, 182
+IDD_OPT_MAIN DIALOGEX 0, 0, 304, 187
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Login settings",IDC_STATIC,4,8,293,50
+ GROUPBOX "Login settings",IDC_STATIC,4,8,293,49
RTEXT "E-mail or phone number:",IDC_STATIC,12,17,150,10
EDITTEXT IDC_LOGIN,167,16,121,12,ES_AUTOHSCROLL
RTEXT "Password:",IDC_STATIC,12,30,150,10
EDITTEXT IDC_PASSWORD,167,30,121,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,59,44,174,11
- GROUPBOX "Local settings",IDC_STATIC,4,59,293,115
+ GROUPBOX "Local settings",IDC_STATIC,4,58,293,122
RTEXT "Contact list group:",IDC_STATIC,12,71,150,8
EDITTEXT IDC_GROUPNAME,167,69,121,12,ES_AUTOHSCROLL
RTEXT "Language for names and titles:",IDC_STATIC,12,86,148,10
COMBOBOX IDC_COMBO_LANGUAGE,167,84,121,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
- CONTROL "Server-side delivery confirmation",IDC_DELIVERY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,157,278,10
- CONTROL "Use local time for received messages",IDC_USE_LOCAL_TIME,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,137,278,10
- CONTROL "Load only friends to local contact list",IDC_LOADONLYFRIENDS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,147,278,10
RTEXT "Mark message as read:",IDC_STATIC,12,101,150,12,SS_CENTERIMAGE
COMBOBOX IDC_COMBO_MARKASREAD,167,101,121,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
RTEXT "Sync history on protocol online:",IDC_STATIC,12,117,150,12,SS_CENTERIMAGE
COMBOBOX IDC_COMBO_SYNCHISTORY,167,117,121,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ CONTROL "Load last messages when message window open and local history is empty",IDC_LASTHISTORYLOAD,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,133,278,10
+ CONTROL "Use local time for received messages",IDC_USE_LOCAL_TIME,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,143,278,10
+ CONTROL "Load only friends to local contact list",IDC_LOADONLYFRIENDS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,153,278,10
+ CONTROL "Server-side delivery confirmation",IDC_DELIVERY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,163,278,10
END
IDD_CAPTCHAFORM DIALOGEX 0, 0, 258, 224
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index fb518e1420..885f00f9a1 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-static const char *szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" , "preview"};
+static const char *szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" , "preview" };
static const char *szGiftTypes[] = { "thumb_256", "thumb_96", "thumb_48" };
@@ -102,14 +102,14 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
const BYTE *s;
int outputLen;
- for (outputLen = 0, s = (const BYTE*)szUrl; *s; s++)
+ for (outputLen = 0, s = (const BYTE*)szUrl; *s; s++)
if ((*s & 0x80 && !strict) || // UTF-8 multibyte
('0' <= *s && *s <= '9') || //0-9
('A' <= *s && *s <= 'Z') || //ABC...XYZ
('a' <= *s && *s <= 'z') || //abc...xyz
- *s == '~' || *s == '-' || *s == '_' || *s == '.' || *s == ' ')
+ *s == '~' || *s == '-' || *s == '_' || *s == '.' || *s == ' ')
outputLen++;
- else
+ else
outputLen += 3;
char *szOutput = (char*)mir_alloc(outputLen + 1);
@@ -122,9 +122,9 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
('0' <= *s && *s <= '9') || //0-9
('A' <= *s && *s <= 'Z') || //ABC...XYZ
('a' <= *s && *s <= 'z') || //abc...xyz
- *s == '~' || *s == '-' || *s == '_' || *s == '.')
+ *s == '~' || *s == '-' || *s == '_' || *s == '.')
*d++ = *s;
- else if (*s == ' ')
+ else if (*s == ' ')
*d++ = '+';
else {
*d++ = '%';
@@ -132,8 +132,8 @@ char* ExpUrlEncode(const char *szUrl, bool strict)
*d++ = szHexDigits[*s & 0xF];
}
- *d = '\0';
- return szOutput;
+ *d = '\0';
+ return szOutput;
}
@@ -216,7 +216,7 @@ MCONTACT CVkProto::FindChat(LONG dwUserid)
return NULL;
}
-bool CVkProto::IsGroupUser(MCONTACT hContact)
+bool CVkProto::IsGroupUser(MCONTACT hContact)
{
if (getBool(hContact, "IsGroup", false))
return true;
@@ -374,10 +374,10 @@ static CMStringA getAttr(char *szSrc, LPCSTR szAttrName)
p1 += 2;
char *p2 = strchr(p1, '\"');
*pEnd = '>';
- if (p2 == NULL)
+ if (p2 == NULL)
return "";
- return CMStringA(p1, (int)(p2-p1));
+ return CMStringA(p1, (int)(p2 - p1));
}
bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResult)
@@ -386,11 +386,11 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
szResult.Empty();
char *pFormBeg = strstr(pBody, "<form ");
- if (pFormBeg == NULL)
+ if (pFormBeg == NULL)
return false;
char *pFormEnd = strstr(pFormBeg, "</form>");
- if (pFormEnd == NULL)
+ if (pFormEnd == NULL)
return false;
*pFormEnd = 0;
@@ -400,7 +400,7 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
CMStringA result;
char *pFieldBeg = pFormBeg;
while (true) {
- if ((pFieldBeg = strstr(pFieldBeg+1, "<input ")) == NULL)
+ if ((pFieldBeg = strstr(pFieldBeg + 1, "<input ")) == NULL)
break;
CMStringA type = getAttr(pFieldBeg, "type");
@@ -428,7 +428,7 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul
MessageBoxW(NULL, wszTitle, TranslateT("Attention!"), MB_ICONWARNING | MB_OK);
}
}
-
+
value = RunConfirmationCode(wszTitle);
}
@@ -496,7 +496,7 @@ void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr)
if (!szCookieName.IsEmpty() && !szDomain.IsEmpty()) {
int k;
- for (k=0; k < m_cookies.getCount(); k++) {
+ for (k = 0; k < m_cookies.getCount(); k++) {
if (m_cookies[k].m_name == szCookieName) {
m_cookies[k].m_value = szCookieVal;
break;
@@ -513,7 +513,7 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq)
debugLogA("CVkProto::ApplyCookies");
CMStringA szCookie;
- for (int i=0; i < m_cookies.getCount(); i++) {
+ for (int i = 0; i < m_cookies.getCount(); i++) {
if (!strstr(pReq->m_szUrl, m_cookies[i].m_domain))
continue;
@@ -538,7 +538,7 @@ void __cdecl CVkProto::DBAddAuthRequestThread(void *p)
for (int i = 0; i < MAX_RETRIES && IsEmpty(ptrW(db_get_wsa(param->hContact, m_szModuleName, "Nick"))); i++) {
Sleep(1500);
-
+
if (!IsOnline())
return;
}
@@ -638,7 +638,7 @@ void CVkProto::SetMirVer(MCONTACT hContact, int platform)
case 3584591: // Windows 8.x
case 6:
MirVer = L"VKontakte (Windows)";
- break;
+ break;
case 7:
MirVer = L"VKontakte (Website)";
break;
@@ -678,6 +678,13 @@ int CVkProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
if (event->uType == MSG_WINDOW_EVT_OPENING && !ServiceExists(MS_MESSAGESTATE_UPDATE))
SetSrmmReadStatus(event->hContact);
+ if (event->uType == MSG_WINDOW_EVT_OPENING && m_vkOptions.bLoadLastMessageOnMsgWindowsOpen
+ && getDword(event->hContact, "lastmsgid", -1) == -1 && !isChatRoom(event->hContact)) {
+ m_bNotifyForEndLoadingHistory = false;
+ GetServerHistory(event->hContact, 0, 100, 0, 0, true);
+ }
+
+
return 0;
}
@@ -699,7 +706,7 @@ void CVkProto::SetSrmmReadStatus(MCONTACT hContact)
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
}
-void CVkProto::MarkDialogAsRead(MCONTACT hContact)
+void CVkProto::MarkDialogAsRead(MCONTACT hContact)
{
debugLogA("CVkProto::MarkDialogAsRead");
if (!IsOnline())
@@ -711,7 +718,7 @@ void CVkProto::MarkDialogAsRead(MCONTACT hContact)
MEVENT hDBEvent = NULL;
MCONTACT hMContact = db_mc_tryMeta(hContact);
- while ((hDBEvent = db_event_firstUnread(hContact)) != NULL)
+ while ((hDBEvent = db_event_firstUnread(hContact)) != NULL)
{
DBEVENTINFO dbei = {};
if (!db_event_get(hDBEvent, &dbei) && !mir_strcmp(m_szModuleName, dbei.szModule))
@@ -741,7 +748,7 @@ char* CVkProto::GetStickerId(const char *Msg, int &stickerid)
CMStringA szMsg(Msg, int(mir_strlen(Msg) - mir_strlen(tmpMsg)));
szMsg.Append(&tmpMsg[retLen]);
retMsg = mir_strdup(szMsg.Trim());
- }
+ }
}
return retMsg;
@@ -780,7 +787,7 @@ CMStringA CVkProto::GetAttachmentsFromMessage(const char *Msg)
for (int i = 0; i < _countof(szVKLinkParam) && !pos2; i++) {
pos2 = strstr(pos, szVKLinkParam[i]);
- if (pos2 && (!nextpos || pos2 < nextpos))
+ if (pos2 && (!nextpos || pos2 < nextpos))
pos = pos2 + mir_strlen(szVKLinkParam[i]);
}
@@ -796,13 +803,13 @@ CMStringA CVkProto::GetAttachmentsFromMessage(const char *Msg)
if (iRes == 2) {
CMStringA szAttachment(FORMAT, szAttachmentMasks[i], iOwner, iId);
CMStringA szAttachment2;
-
+
if (nextpos)
szAttachment2 = GetAttachmentsFromMessage(pos + szAttachment.GetLength());
-
+
if (!szAttachment2.IsEmpty())
szAttachment += "," + szAttachment2;
-
+
return szAttachment;
}
else if (iRes == 1)
@@ -825,12 +832,12 @@ int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam)
szListeningTo += "Enabled";
if (!strcmp(cws->szSetting, szListeningTo)) {
MusicSendMetod iOldMusicSendMetod = (MusicSendMetod)getByte("OldMusicSendMetod", sendBroadcastAndStatus);
-
+
if (cws->value.bVal == 0)
setByte("OldMusicSendMetod", m_vkOptions.iMusicSendMetod);
else
db_unset(0, m_szModuleName, "OldMusicSendMetod");
-
+
m_vkOptions.iMusicSendMetod = cws->value.bVal == 0 ? sendNone : iOldMusicSendMetod;
setByte("MusicSendMetod", m_vkOptions.iMusicSendMetod);
}
@@ -866,13 +873,13 @@ CMStringW CVkProto::SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeed
{ L"like_photo", vkPhoto, vkUsers, TranslateT("liked your photo") },
{ L"like_video", vkVideo, vkUsers, TranslateT("liked your video") },
{ L"like_comment_photo", vkComment, vkUsers, TranslateT("liked your comment to photo") },
- { L"like_comment_video", vkComment, vkUsers, TranslateT("liked your comment to video" ) },
+ { L"like_comment_video", vkComment, vkUsers, TranslateT("liked your comment to video") },
{ L"like_comment_topic", vkComment, vkUsers, TranslateT("liked your comment to topic") },
{ L"copy_post", vkPost, vkCopy, TranslateT("shared your post") },
{ L"copy_photo", vkPhoto, vkCopy, TranslateT("shared your photo") },
{ L"copy_video", vkVideo, vkCopy, TranslateT("shared your video") },
{ L"mention_comments", vkPost, vkComment, L"mentioned you in comment" },
- { L"mention_comment_photo", vkPhoto, vkComment, L"mentioned you in comment to photo" },
+ { L"mention_comment_photo", vkPhoto, vkComment, L"mentioned you in comment to photo" },
{ L"mention_comment_video", vkVideo, vkComment, L"mentioned you in comment to video" }
};
@@ -1012,7 +1019,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res += SetBBCString(TranslateT("Attachments:"), iBBC, vkbbcB);
res.AppendChar('\n');
-
+
for (auto it = jnAttachments.begin(); it != jnAttachments.end(); ++it) {
const JSONNode &jnAttach = (*it);
@@ -1025,7 +1032,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res += GetVkPhotoItem(jnPhoto, iBBC);
}
- else if (wszType ==L"audio") {
+ else if (wszType == L"audio") {
const JSONNode &jnAudio = jnAttach["audio"];
if (!jnAudio)
continue;
@@ -1043,7 +1050,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
SetBBCString(TranslateT("Audio"), iBBC, vkbbcB),
SetBBCString(wszAudio, iBBC, vkbbcUrl, wszUrl));
}
- else if (wszType ==L"video") {
+ else if (wszType == L"video") {
const JSONNode &jnVideo = jnAttach["video"];
if (!jnVideo)
continue;
@@ -1079,7 +1086,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res.AppendFormat(L"%s: %s",
SetBBCString(TranslateT("Wall post"), iBBC, vkbbcUrl, wszUrl),
wszText.IsEmpty() ? L" " : wszText);
-
+
const JSONNode &jnCopyHystory = jnWall["copy_history"];
for (auto aCHit = jnCopyHystory.begin(); aCHit != jnCopyHystory.end(); ++aCHit) {
const JSONNode &jnCopyHystoryItem = (*aCHit);
@@ -1148,10 +1155,10 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
res.AppendFormat(L"%s: %s",
SetBBCString(TranslateT("Link"), iBBC, vkbbcB),
SetBBCString(wszTitle, iBBC, vkbbcUrl, wszUrl));
-
+
if (!wszCaption.IsEmpty())
res.AppendFormat(L"\n\t%s", SetBBCString(wszCaption, iBBC, vkbbcI));
-
+
if (jnLink["photo"])
res.AppendFormat(L"\n\t%s", GetVkPhotoItem(jnLink["photo"], iBBC));
@@ -1177,13 +1184,13 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
SetBBCString(wszTitle, iBBC, vkbbcUrl, wszUrl));
if (!wszPhoto.IsEmpty())
- res.AppendFormat(L"\n\t%s: %s",
- SetBBCString(TranslateT("Photo"), iBBC, vkbbcB),
- SetBBCString(wszPhoto, iBBC, vkbbcImg));
-
+ res.AppendFormat(L"\n\t%s: %s",
+ SetBBCString(TranslateT("Photo"), iBBC, vkbbcB),
+ SetBBCString(wszPhoto, iBBC, vkbbcImg));
+
if (jnMarket["price"] && jnMarket["price"]["text"])
- res.AppendFormat(L"\n\t%s: %s",
- SetBBCString(TranslateT("Price"), iBBC, vkbbcB),
+ res.AppendFormat(L"\n\t%s: %s",
+ SetBBCString(TranslateT("Price"), iBBC, vkbbcB),
jnMarket["price"]["text"].as_mstring());
if (!wszDescription.IsEmpty())
@@ -1235,7 +1242,7 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
int iUserId = jnUser["id"].as_int();
CMStringW wszNick(FORMAT, L"%s %s", jnUser["first_name"].as_mstring(), jnUser["last_name"].as_mstring());
CMStringW wszLink(FORMAT, L"https://vk.com/id%d", iUserId);
-
+
CVkUserInfo *vkUser = new CVkUserInfo(jnUser["id"].as_int(), false, wszNick, wszLink, FindUser(iUserId));
vkUsers.insert(vkUser);
}
@@ -1251,13 +1258,13 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
if (vkUser) {
wszNick = vkUser->m_wszUserNick;
wszUrl = vkUser->m_wszLink;
- }
+ }
else {
MCONTACT hContact = FindUser(uid);
if (hContact || uid == m_msgId)
wszNick = ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"));
- else
- wszNick = TranslateT("(Unknown contact)");
+ else
+ wszNick = TranslateT("(Unknown contact)");
wszUrl.AppendFormat(L"https://vk.com/id%d", uid);
}
@@ -1320,7 +1327,7 @@ void CVkProto::SetInvisible(MCONTACT hContact)
setDword(hContact, "InvisibleTS", (DWORD)now);
}
-CMStringW CVkProto::RemoveBBC(CMStringW& wszSrc)
+CMStringW CVkProto::RemoveBBC(CMStringW& wszSrc)
{
static const wchar_t *wszSimpleBBCodes[][2] = {
{ L"[b]", L"[/b]" },
@@ -1336,14 +1343,14 @@ CMStringW CVkProto::RemoveBBC(CMStringW& wszSrc)
{ L"[color=", L"[/color]" },
};
- CMStringW wszRes(wszSrc);
- CMStringW wszLow(wszSrc);
+ CMStringW wszRes(wszSrc);
+ CMStringW wszLow(wszSrc);
wszLow.MakeLower();
for (int i = 0; i < _countof(wszSimpleBBCodes); i++) {
CMStringW wszOpenTag(wszSimpleBBCodes[i][0]);
CMStringW wszCloseTag(wszSimpleBBCodes[i][1]);
-
+
int lenOpen = wszOpenTag.GetLength();
int lenClose = wszCloseTag.GetLength();
@@ -1380,7 +1387,7 @@ CMStringW CVkProto::RemoveBBC(CMStringW& wszSrc)
while (true) {
if ((posOpen = wszLow.Find(wszOpenTag, posOpen)) < 0)
break;
-
+
if ((posOpen2 = wszLow.Find(L"]", posOpen + lenOpen)) < 0)
break;
@@ -1407,7 +1414,7 @@ void CVkProto::ShowCaptchaInBrowser(HBITMAP hBitmap)
return;
CMStringW wszHTMLPath(FORMAT, L"%s\\miranda_captcha.html", wszTempDir);
-
+
FILE *pFile = _wfopen(wszHTMLPath, L"w");
if (pFile == NULL)
return;
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index edfaff5ac3..15ac29bc9c 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Включаемый файл, созданный в Microsoft Visual C++.
-// Используется d:\svn\protocols\VKontakte\res\resource.rc
+// Используется d:\github\miranda-ng\protocols\VKontakte\res\resource.rc
//
#define IDOPENBROWSER 3
#define IDD_ACCMGRUI 101
@@ -41,6 +41,7 @@
#define IDC_CLIST 1013
#define IDC_HIDECHATS 1014
#define IDC_CONTACT 1015
+#define IDC_LASTHISTORYLOAD 1019
#define IDC_LOADONLYFRIENDS 1020
#define IDC_MESASUREAD 1025
#define IDC_SYNC_MSG_STATUS 1026
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 6c45de27ca..7b75abe875 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 2
-#define __BUILD_NUM 11
+#define __BUILD_NUM 12
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_dialogs.cpp b/protocols/VKontakte/src/vk_dialogs.cpp
index 8f8420e827..64b0b5927c 100644
--- a/protocols/VKontakte/src/vk_dialogs.cpp
+++ b/protocols/VKontakte/src/vk_dialogs.cpp
@@ -119,10 +119,10 @@ CVkWallPostForm::CVkWallPostForm(CVkProto *proto, WALLPOST_FORM_PARAMS *param) :
void CVkWallPostForm::OnInitDialog()
{
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_WALL));
-
+
CMStringW wszTitle(FORMAT, TranslateT("Wall message for %s"), m_param->pwszNick);
SetCaption(wszTitle);
-
+
m_btnShare.Disable();
}
@@ -148,9 +148,9 @@ void CVkWallPostForm::On_edtValue_Change(CCtrlEdit*)
////////////////////////////////// IDD_INVITE /////////////////////////////////////////////
CVkInviteChatForm::CVkInviteChatForm(CVkProto *proto) :
- CVkDlgBase(proto, IDD_INVITE, false),
- m_btnOk(this, IDOK),
- m_cbxCombo(this, IDC_CONTACT),
+ CVkDlgBase(proto, IDD_INVITE, false),
+ m_btnOk(this, IDOK),
+ m_cbxCombo(this, IDC_CONTACT),
m_hContact(NULL)
{
m_btnOk.OnClick = Callback(this, &CVkInviteChatForm::btnOk_OnOk);
@@ -162,7 +162,7 @@ void CVkInviteChatForm::OnInitDialog()
if (!m_proto->isChatRoom(hContact)) {
wchar_t *pwszNick = pcli->pfnGetContactDisplayName(hContact, 0);
m_cbxCombo.AddString(pwszNick, hContact);
- }
+ }
}
}
@@ -175,9 +175,9 @@ void CVkInviteChatForm::btnOk_OnOk(CCtrlButton*)
////////////////////////////////// IDD_GC_CREATE //////////////////////////////////////////
CVkGCCreateForm::CVkGCCreateForm(CVkProto *proto) :
- CVkDlgBase(proto, IDD_GC_CREATE, false),
- m_btnOk(this, IDOK),
- m_clCList(this, IDC_CLIST),
+ CVkDlgBase(proto, IDD_GC_CREATE, false),
+ m_btnOk(this, IDOK),
+ m_clCList(this, IDC_CLIST),
m_edtTitle(this, IDC_TITLE)
{
m_btnOk.OnClick = Callback(this, &CVkGCCreateForm::btnOk_OnOk);
@@ -186,7 +186,7 @@ CVkGCCreateForm::CVkGCCreateForm(CVkProto *proto) :
void CVkGCCreateForm::OnInitDialog()
{
- SetWindowLongPtr(m_clCList.GetHwnd(), GWL_STYLE, GetWindowLongPtr(m_clCList.GetHwnd(), GWL_STYLE)
+ SetWindowLongPtr(m_clCList.GetHwnd(), GWL_STYLE, GetWindowLongPtr(m_clCList.GetHwnd(), GWL_STYLE)
| CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE);
m_clCList.SendMsg(CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
diff --git a/protocols/VKontakte/src/vk_dialogs.h b/protocols/VKontakte/src/vk_dialogs.h
index c6a6bc26d1..993e50ce3e 100644
--- a/protocols/VKontakte/src/vk_dialogs.h
+++ b/protocols/VKontakte/src/vk_dialogs.h
@@ -45,7 +45,7 @@ public:
void On_btnOpenInBrowser_Click(CCtrlButton*);
void On_btnOk_Click(CCtrlButton*);
void On_edtValue_Change(CCtrlEdit*);
-
+
};
////////////////////////////////// IDD_WALLPOST ///////////////////////////////////////////
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index 4f4bfb15fc..8883238694 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -60,7 +60,7 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM, LPARAM)
if (userID == VK_INVALID_USER || userID == VK_FEED_USER)
continue;
-
+
MEVENT hDBEvent = db_event_first(hContact);
while (hDBEvent) {
MEVENT hDBEventNext = db_event_next(hContact, hDBEvent);
@@ -74,10 +74,10 @@ INT_PTR __cdecl CVkProto::SvcGetAllServerHistory(WPARAM, LPARAM)
m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = true;
debugLogA("CVkProto::SvcGetAllServerHistory for ID=%d m_iLoadHistoryTask=%d", userID, m_iLoadHistoryTask);
}
-
+
db_unset(hContact, m_szModuleName, "lastmsgid");
GetServerHistory(hContact, 0, MAXHISTORYMIDSPERONE, 0, 0);
-
+
}
return 1;
@@ -132,9 +132,9 @@ void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int
"var Jdx=0;var CFMsgs=parseInt(FMsgs[Idx].length);while(Jdx<CFMsgs){"
"Uids.unshift(FMsgs[Idx][Jdx].user_id);Jdx=Jdx+1;};Idx=Idx+1;};"
"var FUsers=API.users.get({\"user_ids\":Uids,\"name_case\":\"gen\"});"
- "return{\"count\":index,\"datetime\":iTime,\"items\":ret,\"fwd_users\":FUsers,\"once\":%d,\"rcount\":iReqCount};",
+ "return{\"count\":index,\"datetime\":iTime,\"items\":ret,\"fwd_users\":FUsers,\"once\":%d,\"rcount\":iReqCount};",
iOffset, iCount, userID, iTime, iLastMsgId, (int)once);
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveHistoryMessages)
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveHistoryMessages, AsyncHttpRequest::rpLow)
<< CHAR_PARAM("code", code))->pUserInfo = new CVkSendMsgParam(hContact, iLastMsgId, iOffset);
}
@@ -185,9 +185,9 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
if (!jnResponse) {
if (!pReq->bNeedsRestart || m_bTerminated) {
mir_cslock lck(m_csLoadHistoryTask);
- if (m_iLoadHistoryTask > 0)
+ if (m_iLoadHistoryTask > 0)
m_iLoadHistoryTask--;
-
+
ptrW pwszNick(db_get_wsa(param->hContact, m_szModuleName, "Nick"));
CMStringW str(FORMAT, TranslateT("Error loading message history for %s from server."), pwszNick);
@@ -205,7 +205,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
return;
}
- int iTime = jnResponse["datetime"].as_int();
+ int iTime = jnResponse["datetime"].as_int();
const JSONNode &jnMsgs = jnResponse["items"];
const JSONNode &jnFUsers = jnResponse["fwd_users"];
@@ -217,7 +217,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
const JSONNode &jnMsg = (*it);
int mid = jnMsg["id"].as_int();
- if (iLastMsgId < mid)
+ if (iLastMsgId < mid)
iLastMsgId = mid;
char szMid[40];
@@ -226,8 +226,8 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
CMStringW wszBody(jnMsg["body"].as_mstring());
int datetime = jnMsg["date"].as_int();
int isOut = jnMsg["out"].as_int();
- int isRead = jnMsg["read_state"].as_int();
- int uid = jnMsg["user_id"].as_int();
+ int isRead = jnMsg["read_state"].as_int();
+ int uid = jnMsg["user_id"].as_int();
const JSONNode &jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages) {
@@ -289,7 +289,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
if (m_iLoadHistoryTask == 0 && m_bNotifyForEndLoadingHistoryAllContact) {
MsgPopup(NULL, TranslateT("Loading messages for all contacts is completed."), TranslateT("Loading history"));
- m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
+ m_bNotifyForEndLoadingHistoryAllContact = m_bNotifyForEndLoadingHistory = false;
}
}
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index a627fbaf93..c13efc9516 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -44,7 +44,7 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
return 0;
bool bIsChat = isChatRoom(hContact);
- LONG iUserID = getDword(hContact, bIsChat ? "vk_chat_id" : "ID" , VK_INVALID_USER);
+ LONG iUserID = getDword(hContact, bIsChat ? "vk_chat_id" : "ID", VK_INVALID_USER);
if (iUserID == VK_INVALID_USER || iUserID == VK_FEED_USER) {
ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact));
@@ -55,9 +55,9 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
ptrA pszRetMsg(GetStickerId(szMsg, StickerId));
ULONG uMsgId = ::InterlockedIncrement(&m_msgId);
- AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, bIsChat? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh)
+ AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, bIsChat ? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh)
<< INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserID)
- << INT_PARAM("random_id", ((LONG) time(NULL)) * 100 + uMsgId % 100);
+ << INT_PARAM("random_id", ((LONG)time(NULL)) * 100 + uMsgId % 100);
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
if (StickerId)
@@ -75,13 +75,13 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg)
if (!bIsChat)
pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId);
-
+
Push(pReq);
if (!m_bServerDelivery && !bIsChat)
ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact, uMsgId));
- if (!IsEmpty(pszRetMsg))
+ if (!IsEmpty(pszRetMsg))
SendMsg(hContact, 0, pszRetMsg);
return uMsgId;
@@ -102,7 +102,7 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
if (jnResponse) {
UINT mid;
- if (jnResponse.type() != JSON_STRING)
+ if (jnResponse.type() != JSON_STRING)
mid = jnResponse.as_int();
else if (swscanf(jnResponse.as_mstring(), L"%d", &mid) != 1)
mid = 0;
@@ -122,7 +122,7 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
if (param->pFUP) {
ProtoBroadcastAck(param->hContact, ACKTYPE_FILE, iResult, (HANDLE)(param->pFUP));
- if (!pReq->bNeedsRestart || m_bTerminated)
+ if (!pReq->bNeedsRestart || m_bTerminated)
delete param->pFUP;
}
else if (m_bServerDelivery)
@@ -142,7 +142,7 @@ int CVkProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
MCONTACT hContact = db_event_getContact(hDbEvent);
if (!hContact)
return 0;
-
+
CMStringA szProto(GetContactProto(hContact));
if (szProto.IsEmpty() || szProto != m_szModuleName)
return 0;
@@ -210,11 +210,11 @@ void CVkProto::RetrieveUnreadMessages()
debugLogA("CVkProto::RetrieveUnreadMessages");
if (!IsOnline())
return;
-
+
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveDlgs, AsyncHttpRequest::rpHigh)
<< CHAR_PARAM("code", "var dlg=API.messages.getDialogs({\"count\":200});"
- "var users=API.friends.areFriends({\"user_ids\":dlg.items@.message@.user_id});"
- "return{\"dialogs\":dlg, \"users\":users};"));
+ "var users=API.friends.areFriends({\"user_ids\":dlg.items@.message@.user_id});var groups=API.groups.get();"
+ "return{\"dialogs\":dlg, \"users\":users, \"groups\":groups.items};"));
}
void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
@@ -256,7 +256,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments());
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
- wszBody += wszFwdMessages;
+ wszBody += wszFwdMessages;
}
CMStringW wszAttachmentDescr;
@@ -354,21 +354,31 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
if (!jnDlgs)
return;
- OBJLIST<CVKUsersAreFriend> lufUsers(20, NumericKeySortT);
+ LIST<void> lufUsers(20, PtrKeySortT);
const JSONNode &jnUsers = jnResponse["users"];
- if (jnUsers) {
+ if (jnUsers)
for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
int iUserId = (*it)["user_id"].as_int();
int iStatus = (*it)["friend_status"].as_int();
- CVKUsersAreFriend* ufUser = lufUsers.find((CVKUsersAreFriend*)&iUserId);
- if (ufUser)
+ // iStatus == 3 - user is friend
+ // uid < 0 - user is group
+ if (iUserId < 0 || iStatus != 3 || lufUsers.indexOf((HANDLE)iUserId) != -1)
continue;
- ufUser = new CVKUsersAreFriend(iUserId, iStatus);
- lufUsers.insert(ufUser);
- }
- }
+ lufUsers.insert((HANDLE)iUserId);
+ }
+
+ const JSONNode &jnGroups = jnResponse["groups"];
+ if (jnGroups)
+ for (auto it = jnGroups.begin(); it != jnGroups.end(); ++it) {
+ int iUserId = 1000000000 + (*it).as_int();
+
+ if (lufUsers.indexOf((HANDLE)iUserId) != -1)
+ continue;
+
+ lufUsers.insert((HANDLE)iUserId);
+ }
CMStringA szGroupIds;
@@ -382,19 +392,16 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
int uid = 0;
MCONTACT hContact(NULL);
-
+
int chatid = jnDlg["chat_id"].as_int();
if (!chatid) {
uid = jnDlg["user_id"].as_int();
+ int iSearchId = (uid < 0) ? 1000000000 - uid : uid;
+ int iIndex = lufUsers.indexOf((HANDLE)iSearchId);
+ debugLogA("CVkProto::OnReceiveDlgs UserId = %d, iIndex = %d, numUnread = %d", uid, iIndex, numUnread);
- CVKUsersAreFriend* ufUser = lufUsers.find((CVKUsersAreFriend*)&uid);
- int iFriendStatus = ufUser ? ufUser->iStatus : 0;
- debugLogA("CVkProto::OnReceiveDlgs UserId = %d, FriendStatus = %d, numUnread = %d", uid, iFriendStatus, numUnread);
-
- // iFriendStatus == 3 - user is friend
- // uid > 0 - user is not group and etc.
- if (m_vkOptions.bLoadOnlyFriends && uid > 0 && numUnread == 0 && iFriendStatus != 3)
+ if (m_vkOptions.bLoadOnlyFriends && numUnread == 0 && iIndex == -1)
continue;
hContact = FindUser(uid, true);
@@ -414,7 +421,7 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
}
}
}
-
+
if (chatid) {
debugLogA("CVkProto::OnReceiveDlgs chatid = %d", chatid);
if (m_chats.find((CVkChatInfo*)&chatid) == NULL)
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index 15cec12e55..2f6f6e0b29 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -28,7 +28,7 @@ INT_PTR CVkProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
-CVkAccMgrForm::CVkAccMgrForm(CVkProto *proto, HWND hwndParent):
+CVkAccMgrForm::CVkAccMgrForm(CVkProto *proto, HWND hwndParent) :
CVkDlgBase(proto, IDD_ACCMGRUI, false),
m_edtLogin(this, IDC_LOGIN),
m_edtPassword(this, IDC_PASSWORD),
@@ -121,7 +121,7 @@ static CVKLang vkLangCodes[] = {
{ L"it", LPGENW("Italian") },
};
-static CVKSync vkHistorySyncMethods[] =
+static CVKSync vkHistorySyncMethods[] =
{
{ TranslateT("off"), SyncHistoryMetod::syncOff },
{ TranslateT("automatically"), SyncHistoryMetod::syncAuto },
@@ -137,7 +137,7 @@ static CVKMarkMsgRead vkMarkMsgAsReadMethods[] =
{ TranslateT("on typing"), MarkMsgReadOn::markOnTyping }
};
-CVkOptionAccountForm::CVkOptionAccountForm(CVkProto *proto):
+CVkOptionAccountForm::CVkOptionAccountForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_OPT_MAIN, false),
m_edtLogin(this, IDC_LOGIN),
m_edtPassword(this, IDC_PASSWORD),
@@ -145,6 +145,7 @@ CVkOptionAccountForm::CVkOptionAccountForm(CVkProto *proto):
m_edtGroupName(this, IDC_GROUPNAME),
m_cbxVKLang(this, IDC_COMBO_LANGUAGE),
m_cbDelivery(this, IDC_DELIVERY),
+ m_cbLoadLastMessageOnMsgWindowsOpen(this, IDC_LASTHISTORYLOAD),
m_cbUseLocalTime(this, IDC_USE_LOCAL_TIME),
m_cbLoadOnlyFriends(this, IDC_LOADONLYFRIENDS),
m_cbxMarkAsRead(this, IDC_COMBO_MARKASREAD),
@@ -153,6 +154,7 @@ CVkOptionAccountForm::CVkOptionAccountForm(CVkProto *proto):
CreateLink(m_edtLogin, "Login", L"");
CreateLink(m_edtGroupName, m_proto->m_vkOptions.pwszDefaultGroup);
CreateLink(m_cbDelivery, m_proto->m_vkOptions.bServerDelivery);
+ CreateLink(m_cbLoadLastMessageOnMsgWindowsOpen, m_proto->m_vkOptions.bLoadLastMessageOnMsgWindowsOpen);
CreateLink(m_cbUseLocalTime, m_proto->m_vkOptions.bUseLocalTime);
CreateLink(m_cbLoadOnlyFriends, m_proto->m_vkOptions.bLoadOnlyFriends);
}
@@ -177,13 +179,13 @@ void CVkOptionAccountForm::OnInitDialog()
m_cbxMarkAsRead.SetCurSel(iListIndex);
iListIndex = SyncHistoryMetod::syncOff;
- for (int i = 0; i < _countof(vkHistorySyncMethods); i++) {
+ for (int i = 0; i < _countof(vkHistorySyncMethods); i++) {
m_cbxSyncHistory.InsertString((wchar_t *)vkHistorySyncMethods[i].type, i, vkHistorySyncMethods[i].data);
if (vkHistorySyncMethods[i].data == m_proto->m_vkOptions.iSyncHistoryMetod)
iListIndex = i;
}
m_cbxSyncHistory.SetCurSel(iListIndex);
-
+
iListIndex = 0;
for (int i = 0; i < _countof(vkLangCodes); i++) {
m_cbxVKLang.InsertString(TranslateW(vkLangCodes[i].szDescription), i, (LPARAM)vkLangCodes[i].szCode);
@@ -191,7 +193,7 @@ void CVkOptionAccountForm::OnInitDialog()
iListIndex = i;
}
m_cbxVKLang.SetCurSel(iListIndex);
-
+
}
void CVkOptionAccountForm::OnApply()
@@ -199,7 +201,7 @@ void CVkOptionAccountForm::OnApply()
m_proto->m_vkOptions.iSyncHistoryMetod = m_cbxSyncHistory.GetItemData(m_cbxSyncHistory.GetCurSel());
m_proto->m_vkOptions.iMarkMessageReadOn = m_cbxMarkAsRead.GetItemData(m_cbxMarkAsRead.GetCurSel());
m_proto->m_vkOptions.pwszVKLang = (wchar_t *)m_cbxVKLang.GetItemData(m_cbxVKLang.GetCurSel());
-
+
ptrW pwszGroupName(m_edtGroupName.GetText());
if (mir_wstrcmp(m_pwszOldGroup, pwszGroupName)) {
Clist_GroupCreate(NULL, pwszGroupName);
@@ -219,12 +221,12 @@ void CVkOptionAccountForm::OnApply()
if (bPassChanged || mir_wstrcmpi(m_pwszOldLogin, pwszNewLogin))
m_proto->ClearAccessToken();
m_pwszOldLogin = pwszNewLogin;
-
+
}
////////////////////// Advanced page /////////////////////////////////////////
-CVkOptionAdvancedForm::CVkOptionAdvancedForm(CVkProto *proto):
+CVkOptionAdvancedForm::CVkOptionAdvancedForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_OPT_ADV, false),
m_cbHideChats(this, IDC_HIDECHATS),
m_cbSyncReadMessageStatusFromServer(this, IDC_SYNC_MSG_STATUS),
@@ -307,7 +309,7 @@ void CVkOptionAdvancedForm::On_cbSendVKLinksAsAttachmentsChange(CCtrlCheck *)
////////////////////// News and notifications ////////////////////////////////
-CVkOptionFeedsForm::CVkOptionFeedsForm(CVkProto *proto):
+CVkOptionFeedsForm::CVkOptionFeedsForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_OPT_FEEDS, false),
m_cbNewsEnabled(this, IDC_NEWS_ENBL),
m_edtNewsInterval(this, IDC_ED_INT_NEWS),
@@ -367,11 +369,11 @@ CVkOptionFeedsForm::CVkOptionFeedsForm(CVkProto *proto):
void CVkOptionFeedsForm::OnInitDialog()
{
m_spNewsInterval.SetRange(60 * 24, 1);
- m_spNewsInterval.SetPosition(m_proto->m_vkOptions.iNewsInterval);
+ m_spNewsInterval.SetPosition(m_proto->m_vkOptions.iNewsInterval);
m_spNotificationsInterval.SetRange(60 * 24, 1);
m_spNotificationsInterval.SetPosition(m_proto->m_vkOptions.iNotificationsInterval);
-
+
On_cbNewsEnabledChange(&m_cbNewsEnabled);
On_cbNotificationsEnabledChange(&m_cbNotificationsEnabled);
}
@@ -411,7 +413,7 @@ void CVkOptionFeedsForm::On_cbNotificationsEnabledChange(CCtrlCheck*)
////////////////////// View page /////////////////////////////////////////////
-CVkOptionViewForm::CVkOptionViewForm(CVkProto *proto):
+CVkOptionViewForm::CVkOptionViewForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_OPT_VIEW, false),
m_cbIMGBBCSupportOff(this, IDC_IMG_OFF),
m_cbIMGBBCSupportFullSize(this, IDC_IMG_FULLSIZE),
@@ -444,7 +446,7 @@ void CVkOptionViewForm::OnInitDialog()
m_cbBBCForNewsOff.SetState(m_proto->m_vkOptions.iBBCForNews == BBCSupport::bbcNo);
m_cbBBCForNewsBasic.SetState(m_proto->m_vkOptions.iBBCForNews == BBCSupport::bbcBasic);
m_cbBBCForNewsAdvanced.SetState(m_proto->m_vkOptions.iBBCForNews == BBCSupport::bbcAdvanced);
-
+
m_cbBBCForAttachmentsOff.SetState(m_proto->m_vkOptions.iBBCForAttachments == BBCSupport::bbcNo);
m_cbBBCForAttachmentsBasic.SetState(m_proto->m_vkOptions.iBBCForAttachments == BBCSupport::bbcBasic);
m_cbBBCForAttachmentsAdvanced.SetState(m_proto->m_vkOptions.iBBCForAttachments == BBCSupport::bbcAdvanced);
@@ -478,7 +480,7 @@ void CVkOptionViewForm::OnApply()
////////////////////// Menu page /////////////////////////////////////////////
-CVkOptionMenuForm::CVkOptionMenuForm(CVkProto *proto):
+CVkOptionMenuForm::CVkOptionMenuForm(CVkProto *proto) :
CVkDlgBase(proto, IDD_OPT_MENU, false),
m_cbMenuEnabled0(this, IDC_SHOW_MENU0),
m_cbMenuEnabled1(this, IDC_SHOW_MENU1),
@@ -499,10 +501,10 @@ CVkOptionMenuForm::CVkOptionMenuForm(CVkProto *proto):
void CVkOptionMenuForm::OnApply()
{
- if (MessageBoxW(NULL,
+ if (MessageBoxW(NULL,
TranslateT("These changes will take effect after Miranda NG restart.\nWould you like to restart it now?"),
- TranslateT("VKontakte protocol"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES)
- CallServiceSync(MS_SYSTEM_RESTART, 1, 0);
+ TranslateT("VKontakte protocol"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES)
+ CallServiceSync(MS_SYSTEM_RESTART, 1, 0);
}
diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h
index 9758d95ddf..f58dcff171 100644
--- a/protocols/VKontakte/src/vk_options.h
+++ b/protocols/VKontakte/src/vk_options.h
@@ -29,7 +29,7 @@ class CVkAccMgrForm : public CVkDlgBase
CCtrlEdit m_edtLogin;
CCtrlEdit m_edtPassword;
CCtrlHyperlink m_hlLink;
-
+
pass_ptrW m_pwszOldPass;
ptrW m_pwszOldLogin;
@@ -49,6 +49,7 @@ class CVkOptionAccountForm : public CVkDlgBase
CCtrlEdit m_edtGroupName;
CCtrlCombo m_cbxVKLang;
CCtrlCheck m_cbDelivery;
+ CCtrlCheck m_cbLoadLastMessageOnMsgWindowsOpen;
CCtrlCheck m_cbUseLocalTime;
CCtrlCheck m_cbLoadOnlyFriends;
CCtrlCombo m_cbxSyncHistory;
@@ -105,7 +106,7 @@ public:
class CVkOptionFeedsForm : public CVkDlgBase
{
CCtrlCheck m_cbNewsEnabled;
-
+
CCtrlEdit m_edtNewsInterval;
CCtrlSpin m_spNewsInterval;
@@ -129,7 +130,7 @@ class CVkOptionFeedsForm : public CVkDlgBase
CCtrlCheck m_cbNewsSourceFollowing;
CCtrlCheck m_cbNewsSourceIncludeBanned;
CCtrlCheck m_cbNewsSourceNoReposts;
-
+
CCtrlCheck m_cbNotificationFilterComments;
CCtrlCheck m_cbNotificationFilterLikes;
CCtrlCheck m_cbNotificationFilterReposts;
@@ -153,7 +154,7 @@ class CVkOptionViewForm : public CVkDlgBase
CCtrlCheck m_cbIMGBBCSupportFullSize;
CCtrlCheck m_cbIMGBBCSupport130;
CCtrlCheck m_cbIMGBBCSupport604;
-
+
CCtrlCheck m_cbBBCForNewsOff;
CCtrlCheck m_cbBBCForNewsBasic;
CCtrlCheck m_cbBBCForNewsAdvanced;
@@ -167,7 +168,7 @@ class CVkOptionViewForm : public CVkDlgBase
CCtrlCheck m_cbStikersAsSmyles;
CCtrlCheck m_cbShortenLinksForAudio;
CCtrlCheck m_cbUseNonStandardNotifications;
-
+
public:
CVkOptionViewForm(CVkProto *proto);
void OnInitDialog();
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index 67eec095fa..d931f2d911 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -44,13 +44,13 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url
bIsMainConn = false;
bExpUrlEncode = (BYTE)ppro->m_vkOptions.bUseNonStandardUrlEncode != 0;
AddHeader("Connection", "keep-alive");
-
+
if (*_url == '/') { // relative url leads to a site
m_szUrl = ((bSecure) ? "https://" : "http://") + CMStringA("api.vk.com");
m_szUrl += _url;
bIsMainConn = true;
}
- else
+ else
m_szUrl = _url;
flags = VK_NODUMPHEADERS | NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
@@ -167,6 +167,7 @@ CVkChatUser* CVkChatInfo::GetUserById(int user_id)
/////////////////////////////////////////////////////////////////////////////////////////
CVKOptions::CVKOptions(PROTO_INTERFACE *proto) :
+ bLoadLastMessageOnMsgWindowsOpen(proto, "LoadLastMessageOnMsgWindowsOpen", true),
bLoadOnlyFriends(proto, "LoadOnlyFriends", false),
bServerDelivery(proto, "BsDirect", true),
bHideChats(proto, "HideChats", true),
@@ -214,7 +215,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) :
bLoadFullCList(proto, "LoadFullCList", false),
bShowVkDeactivateEvents(proto, "ShowVkDeactivateEvents", true),
- bShowProtoMenuItem0(proto, "ShowProtoMenuItem0", true),
+ bShowProtoMenuItem0(proto, "ShowProtoMenuItem0", true),
bShowProtoMenuItem1(proto, "ShowProtoMenuItem1", true),
bShowProtoMenuItem2(proto, "ShowProtoMenuItem2", true),
bShowProtoMenuItem3(proto, "ShowProtoMenuItem3", true),
@@ -242,7 +243,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) :
// Note: Delete this code after next stable build
int iAutoClean = db_get_b(NULL, proto->m_szModuleName, "AutoClean", -1);
if (iAutoClean != -1) {
- bLoadOnlyFriends = (BYTE) iAutoClean;
+ bLoadOnlyFriends = (BYTE)iAutoClean;
db_set_b(NULL, proto->m_szModuleName, "LoadOnlyFriends", bLoadOnlyFriends);
db_unset(NULL, proto->m_szModuleName, "AutoClean");
}
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index 45ddd37fcf..88642cccd4 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -255,9 +255,9 @@ struct CVKInteres {
wchar_t *pwszTranslate;
};
-struct CVKLang {
- wchar_t *szCode;
- wchar_t *szDescription;
+struct CVKLang {
+ wchar_t *szCode;
+ wchar_t *szDescription;
};
enum MarkMsgReadOn : BYTE { markOnRead, markOnReceive, markOnReply, markOnTyping };
@@ -287,6 +287,7 @@ struct CVkCookie
};
struct CVKOptions {
+ CMOption<BYTE> bLoadLastMessageOnMsgWindowsOpen;
CMOption<BYTE> bLoadOnlyFriends;
CMOption<BYTE> bServerDelivery;
CMOption<BYTE> bHideChats;
@@ -357,7 +358,7 @@ struct CVKOptions {
CMOption<wchar_t*> pwszVKLang;
CVKOptions(PROTO_INTERFACE *proto);
-
+
__forceinline BBCSupport BBCForNews() { return (BBCSupport)(BYTE)iBBCForNews; };
__forceinline BBCSupport BBCForAttachments() { return (BBCSupport)(BYTE)iBBCForAttachments; };
@@ -366,14 +367,4 @@ struct CVKOptions {
struct CVKDeactivateEvent {
wchar_t *wszType;
char *szDescription;
-};
-
-struct CVKUsersAreFriend {
- CVKUsersAreFriend(int _iUserId, int _iStatus) :
- iUserId(_iUserId),
- iStatus(_iStatus)
- {}
-
- int iUserId;
- int iStatus;
}; \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 9bec13a8f6..a6dd0b385d 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -23,9 +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, last_seen, online, status, country, city, relation, interests, activities, "
- "music, movies, tv, books, games, quotes, 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";
/////////////////////////////////////////////////////////////////////////////////////////
@@ -33,7 +33,7 @@ void CVkProto::ShutdownSession()
{
debugLogA("CVkProto::ShutdownSession");
m_bTerminated = true;
- if (m_hWorkerThread)
+ if (m_hWorkerThread)
SetEvent(m_evRequestsQueue);
OnLoggedOut();
}
@@ -55,7 +55,7 @@ static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
for (int i = 0; i < vk_Instances.getCount(); i++)
if (vk_Instances[i]->IsOnline()) {
vk_Instances[i]->debugLogA("Tic timer for %i - %s", i, vk_Instances[i]->m_szModuleName);
- vk_Instances[i]->OnTimerTic();
+ vk_Instances[i]->OnTimerTic();
}
}
@@ -136,14 +136,14 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
if (reply->resultCode == 302) { // manual redirect
LPCSTR pszLocation = findHeader(reply, "Location");
if (pszLocation) {
- if (!_strnicmp(pszLocation, szBlankUrl, sizeof(szBlankUrl)-1)) {
+ if (!_strnicmp(pszLocation, szBlankUrl, sizeof(szBlankUrl) - 1)) {
m_szAccessToken = NULL;
LPCSTR p = strstr(pszLocation, VK_TOKEN_BEG);
if (p) {
- p += sizeof(VK_TOKEN_BEG)-1;
- for (LPCSTR q = p+1; *q; q++) {
+ p += sizeof(VK_TOKEN_BEG) - 1;
+ for (LPCSTR q = p + 1; *q; q++) {
if (*q == '&' || *q == '=' || *q == '\"') {
- m_szAccessToken = mir_strndup(p, q-p);
+ m_szAccessToken = mir_strndup(p, q - p);
break;
}
}
@@ -175,7 +175,7 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
Push(pRedirectReq);
}
}
- else
+ else
ConnectionFailed(LOGINERR_NOSERVER);
return;
}
@@ -250,7 +250,7 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
m_myUserId = jnUser["id"].as_int();
setDword("ID", m_myUserId);
-
+
OnLoggedIn();
RetrieveUserInfo(m_myUserId);
RetrieveUnreadMessages();
@@ -302,14 +302,14 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
setWString(hContact, "Nick", wszNick);
wszValue = jnItem["deactivated"].as_mstring();
- CMStringW wszOldDeactivated(ptrW(db_get_wsa(hContact, m_szModuleName, "Deactivated")));
+ CMStringW wszOldDeactivated(ptrW(db_get_wsa(hContact, m_szModuleName, "Deactivated")));
if (wszValue != wszOldDeactivated) {
AddVkDeactivateEvent(hContact, wszValue);
- if (wszValue.IsEmpty())
- db_unset(hContact, m_szModuleName, "Deactivated");
- else
+ if (wszValue.IsEmpty())
+ db_unset(hContact, m_szModuleName, "Deactivated");
+ else
setWString(hContact, "Deactivated", wszValue);
- }
+ }
if (!wszValue.IsEmpty())
return hContact;
@@ -340,7 +340,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
if (jnLastSeen) {
int iLastSeen = jnLastSeen["time"].as_int();
int iOldLastSeen = db_get_dw(hContact, "BuddyExpectator", "LastSeen");
- if (iLastSeen && iLastSeen > iOldLastSeen) {
+ if (iLastSeen && iLastSeen > iOldLastSeen) {
db_set_dw(hContact, "BuddyExpectator", "LastSeen", (DWORD)iLastSeen);
db_set_w(hContact, "BuddyExpectator", "LastStatus", ID_STATUS_ONLINE);
}
@@ -360,7 +360,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
SetMirVer(hContact, 7); // vk.com
else if (online_app != 0)
SetMirVer(hContact, online_app); // App
- else
+ else
SetMirVer(hContact, 1); // m.vk.com
}
else
@@ -413,21 +413,21 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
}
// MaritalStatus
- BYTE cMaritalStatus[] = {0, 10, 11, 12, 20, 70, 50, 60, 80};
+ BYTE cMaritalStatus[] = { 0, 10, 11, 12, 20, 70, 50, 60, 80 };
if (jnItem["relation"] && jnItem["relation"].as_int() < _countof(cMaritalStatus))
setByte(hContact, "MaritalStatus", cMaritalStatus[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") },
+ CVKInteres vkInteres[] = {
+ { "interests", TranslateT("Interests") },
+ { "activities", TranslateT("Activities") },
+ { "music", TranslateT("Music") },
+ { "movies", TranslateT("Movies") },
{ "tv", TranslateT("TV") },
- { "books", TranslateT("Books") },
+ { "books", TranslateT("Books") },
{ "games", TranslateT("Games") },
- { "quotes", TranslateT("Quotes") }
+ { "quotes", TranslateT("Quotes") }
};
int iInteres = 0;
@@ -436,7 +436,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
wszValue = jnItem[vkInteres[i].szField].as_mstring();
if (wszValue.IsEmpty())
continue;
-
+
CMStringA InteresCat(FORMAT, "Interest%dCat", iInteres);
CMStringA InteresText(FORMAT, "Interest%dText", iInteres);
@@ -444,7 +444,7 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self)
setWString(hContact, InteresText, wszValue);
iInteres++;
-
+
}
for (int i = iInteres; iInteres > 0; i++) {
@@ -501,7 +501,7 @@ void CVkProto::RetrieveGroupInfo(LONG groupID)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/groups.getById.json", true, &CVkProto::OnReceiveGroupInfo)
<< CHAR_PARAM("fields", "description")
- << INT_PARAM("group_id", -1*groupID));
+ << INT_PARAM("group_id", -1 * groupID));
}
void CVkProto::RetrieveGroupInfo(CMStringA& groupIDs)
@@ -535,7 +535,7 @@ void CVkProto::RetrieveUsersInfo(bool bFreeOffline, bool bRepeat)
if (!userIDs.IsEmpty())
userIDs.AppendChar(',');
userIDs.AppendFormat(L"%i", userID);
-
+
if (i == MAX_CONTACTS_PER_REQUEST)
break;
i++;
@@ -655,13 +655,10 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
for (auto it = jnResponse.begin(); it != jnResponse.end(); ++it) {
const JSONNode &jnItem = (*it);
-
+
int iGroupId = (-1)*jnItem["id"].as_int();
bool bIsMember = jnItem["is_member"].as_bool();
- if (!bIsMember && m_vkOptions.bLoadOnlyFriends)
- continue;
-
MCONTACT hContact = FindUser(iGroupId, true);
if (!hContact)
continue;
@@ -671,13 +668,13 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
wszValue = jnItem["name"].as_mstring();
if (!wszValue.IsEmpty())
setWString(hContact, "Nick", wszValue);
-
+
setWord(hContact, "Status", ID_STATUS_ONLINE);
setByte(hContact, "Auth", !bIsMember);
setByte(hContact, "friend", bIsMember);
setByte(hContact, "IsGroup", 1);
-
+
wszValue = jnItem["screen_name"].as_mstring();
if (!wszValue.IsEmpty()) {
setWString(hContact, "domain", wszValue);
@@ -685,7 +682,7 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
setWString(hContact, "Homepage", wszValue);
}
- wszValue = jnItem["description"].as_mstring();
+ wszValue = jnItem["description"].as_mstring();
if (!wszValue.IsEmpty())
setWString(hContact, "About", wszValue);
@@ -693,8 +690,8 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
if (!wszValue.IsEmpty()) {
SetAvatarUrl(hContact, wszValue);
ReloadAvatarInfo(hContact);
- }
-
+ }
+
wszValue = jnItem["status"].as_mstring();
db_set_ws(hContact, "CList", "StatusMsg", wszValue);
@@ -738,13 +735,13 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
if (!jnResponse)
return;
-
+
CVkSendMsgParam *param = (CVkSendMsgParam *)pReq->pUserInfo;
bool bCleanContacts = (param->iMsgID != 0);
delete param;
LIST<void> arContacts(10, PtrKeySortT);
-
+
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (!isChatRoom(hContact) && !IsGroupUser(hContact))
setByte(hContact, "Auth", 1);
@@ -776,7 +773,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
continue;
db_delete_contact(hContact);
}
-
+
arContacts.destroy();
}
@@ -795,7 +792,7 @@ INT_PTR __cdecl CVkProto::SvcAddAsFriend(WPARAM hContact, LPARAM)
INT_PTR CVkProto::SvcWipeNonFriendContacts(WPARAM, LPARAM)
{
debugLogA("CVkProto::SvcWipeNonFriendContacts");
- if (IDNO == MessageBoxW(NULL, TranslateT("Are you sure to wipe local contacts missing in your friend list?"),
+ if (IDNO == MessageBoxW(NULL, TranslateT("Are you sure to wipe local contacts missing in your friend list?"),
TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 0;
@@ -905,13 +902,13 @@ INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM)
ptrW pwszNick(db_get_wsa(hContact, m_szModuleName, "Nick"));
CMStringW pwszMsg(FORMAT, TranslateT("Are you sure to ban %s? %s%sContinue?"),
- IsEmpty(pwszNick) ? TranslateT("(Unknown contact)") : pwszNick,
+ IsEmpty(pwszNick) ? TranslateT("(Unknown contact)") : pwszNick,
wszVarWarning.IsEmpty() ? L" " : TranslateT("\nIt will also"),
wszVarWarning.IsEmpty() ? L"\n" : wszVarWarning);
if (IDNO == MessageBoxW(NULL, pwszMsg, TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
return 1;
-
+
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
<< CHAR_PARAM("code", code));
@@ -956,7 +953,7 @@ INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
debugLogA("CVkProto::SvcVisitProfile");
if (isChatRoom(hContact)) {
ptrW wszHomepage(db_get_wsa(hContact, m_szModuleName, "Homepage"));
- if(!IsEmpty(wszHomepage))
+ if (!IsEmpty(wszHomepage))
Utils_OpenUrlW(wszHomepage);
return 0;
}
@@ -969,7 +966,7 @@ INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
wszUrl.Append(wszDomain);
else
wszUrl.AppendFormat(L"id%i", userID);
-
+
Utils_OpenUrlW(wszUrl);
return 0;
} \ No newline at end of file