diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-25 11:22:02 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-12-25 11:22:02 +0000 |
commit | 60074fa377aeaed72a7cb1bb8d3ed7781a68eeb1 (patch) | |
tree | c9eb2a7a979d1af16e66bac18c99b496364cbda8 /protocols/VKontakte | |
parent | 5da4cd56a1a5ea4f2e745bde855f604c52ef36da (diff) |
VKontakte:
move GetAttachmentDescr to misc.cpp
add ‘View settings’ option page and more options for view attachments, news and notification in message log
code cleanup and reorganization
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@11624 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/res/resource.rc | 64 | ||||
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 448 | ||||
-rw-r--r-- | protocols/VKontakte/src/resource.h | 15 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 95 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 101 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 97 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 125 |
9 files changed, 571 insertions, 380 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index 876a6666dd..892a0f6997 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -44,6 +44,14 @@ IDI_BROADCAST ICON "broadcast.ico" #ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
+ IDD_OPT_VIEW, DIALOG
+ BEGIN
+ LEFTMARGIN, 4
+ RIGHTMARGIN, 298
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 124
+ END
+
IDD_OPT_FEEDS, DIALOG
BEGIN
LEFTMARGIN, 4
@@ -63,7 +71,7 @@ BEGIN LEFTMARGIN, 4
RIGHTMARGIN, 297
TOPMARGIN, 7
- BOTTOMMARGIN, 181
+ BOTTOMMARGIN, 157
END
IDD_OPT_MAIN, DIALOG
@@ -104,7 +112,27 @@ END // Dialog
//
-IDD_OPT_FEEDS DIALOGEX 0, 0, 309, 122
+IDD_OPT_VIEW DIALOGEX 0, 0, 304, 131
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "[img] BBCode support for image ",IDC_STATIC,4,8,293,39
+ CONTROL "off",IDC_IMG_OFF,"Button",BS_AUTORADIOBUTTON,12,19,129,10
+ CONTROL "for original size images",IDC_IMG_FULLSIZE,"Button",BS_AUTORADIOBUTTON,12,30,129,10
+ CONTROL "for preview max 130px*130px",IDC_IMG_130,"Button",BS_AUTORADIOBUTTON,154,19,129,10
+ CONTROL "for preview max 604px*604px",IDC_IMG_604,"Button",BS_AUTORADIOBUTTON,154,30,129,10
+ GROUPBOX "BBCode support on news and event notifications",IDC_STATIC,4,50,294,38
+ CONTROL "off",IDC_NEWSBBC_OFF,"Button",BS_AUTORADIOBUTTON,12,61,129,10
+ CONTROL "basic ([b], [i], [u], [s]) ",IDC_NEWSBBC_BASIC,"Button",BS_AUTORADIOBUTTON,12,72,129,10
+ CONTROL "advanced (+[url], [size], [color])",IDC_NEWSBBC_ADV,
+ "Button",BS_AUTORADIOBUTTON,154,61,129,10
+ GROUPBOX "Other",IDC_STATIC,4,90,293,26
+ CONTROL "Process stickers as smileys",IDC_STICKERS_AS_SMYLES,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,278,10
+END
+
+IDD_OPT_FEEDS DIALOGEX 0, 0, 304, 122
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -121,8 +149,6 @@ BEGIN CONTROL "",IDC_SPIN_INT_NOTIF,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,230,67,14,14
CONTROL "Special contact always enabled",IDC_SPEC_CONT_ENBL,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,81,278,10
- CONTROL "BBCode support on news and event notifications",IDC_BBC_NEWS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,92,278,10
END
IDD_ACCMGRUI DIALOGEX 0, 0, 186, 68
@@ -137,33 +163,29 @@ BEGIN CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,0,49,174,12
END
-IDD_OPT_ADV DIALOGEX 0, 0, 304, 191
+IDD_OPT_ADV DIALOGEX 0, 0, 304, 167
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Advanced",IDC_STATIC,4,8,293,69
+ GROUPBOX "Advanced",IDC_STATIC,4,8,293,48
CONTROL "Hide chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,19,278,10
CONTROL "Always notify as unread for all incoming message",IDC_MESASUREAD,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,278,10
- CONTROL "Add [img] BBCode for graphical attachments",IDC_ADD_IMG_BBC,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,41,278,10
- CONTROL "Process stickers as smileys",IDC_STICKERS_AS_SMYLES,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,278,10
CONTROL "Force online status upon user activity",IDC_FORCE_ONLINE_ON_ACT,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,63,278,10
- GROUPBOX "When I ban user...",IDC_STATIC,4,80,293,33
- CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,90,129,10
- CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,129,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,41,278,10
+ GROUPBOX "When I ban user...",IDC_STATIC,4,58,293,33
+ CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,68,129,10
+ CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,79,129,10
CONTROL "Remove from friend list",IDC_REMOVE_FROM_FRENDLIST,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,90,141,10
- CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,101,141,10
- GROUPBOX "Broadcast music...",IDC_STATIC_SEND_MUSIC_METOD,4,116,293,58,WS_GROUP
- CONTROL "off",IDC_SEND_MUSIC_NONE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,127,278,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,68,141,10
+ CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,79,141,10
+ GROUPBOX "Broadcast music...",IDC_STATIC_SEND_MUSIC_METOD,4,94,293,58,WS_GROUP
+ CONTROL "off",IDC_SEND_MUSIC_NONE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,105,278,10
CONTROL "as regular status for unknown music and audio status otherwise",IDC_SEND_MUSIC_BROADCAST_AND_STATUS,
- "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,138,278,11
- CONTROL "as audio status only",IDC_SEND_MUSIC_BROADCAST,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,149,278,10
- CONTROL "as regular status only",IDC_SEND_MUSIC_STATUS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,160,278,10
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,116,278,11
+ CONTROL "as audio status only",IDC_SEND_MUSIC_BROADCAST,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,127,278,10
+ CONTROL "as regular status only",IDC_SEND_MUSIC_STATUS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,138,278,10
END
IDD_OPT_MAIN DIALOGEX 0, 0, 304, 213
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 3e68df1325..051c34f929 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -17,6 +17,127 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
+static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" };
+
+LPCSTR findHeader(NETLIBHTTPREQUEST *pReq, LPCSTR szField)
+{
+ for (int i = 0; i < pReq->headersCount; i++)
+ if (!_stricmp(pReq->headers[i].szName, szField))
+ return pReq->headers[i].szValue;
+
+ return NULL;
+}
+
+bool tlstrstr(TCHAR* _s1, TCHAR* _s2)
+{
+ TCHAR s1[1024], s2[1024];
+
+ _tcsncpy_s(s1, _s1, _TRUNCATE);
+ CharLowerBuff(s1, SIZEOF(s1));
+ _tcsncpy_s(s2, _s2, _TRUNCATE);
+ CharLowerBuff(s2, SIZEOF(s2));
+
+ return _tcsstr(s1, s2) != NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static IconItem iconList[] =
+{
+ { LPGEN("Captcha form icon"), "key", IDI_KEYS },
+ { LPGEN("Notification icon"), "notification", IDI_NOTIFICATION },
+ { LPGEN("Read message icon"), "read", IDI_READMSG },
+ { LPGEN("Visit profile icon"), "profile", IDI_VISITPROFILE },
+ { LPGEN("Load server history icon"), "history", IDI_HISTORY },
+ { LPGEN("Add to friend list icon"), "addfriend", IDI_FRIENDADD },
+ { LPGEN("Delete from friend list icon"), "delfriend", IDI_FRIENDDEL },
+ { LPGEN("Report abuse icon"), "abuse", IDI_ABUSE },
+ { LPGEN("Ban user icon"), "ban", IDI_BAN },
+ { LPGEN("Broadcast icon"), "broadcast", IDI_BROADCAST }
+};
+
+void InitIcons()
+{
+ Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("VKontakte"), iconList, SIZEOF(iconList), "VKontakte");
+}
+
+HANDLE GetIconHandle(int iCommand)
+{
+ for (int i = 0; i < SIZEOF(iconList); i++)
+ if (iconList[i].defIconID == iCommand)
+ return iconList[i].hIcolib;
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+AsyncHttpRequest::AsyncHttpRequest()
+{
+ cbSize = sizeof(NETLIBHTTPREQUEST);
+ m_bApiReq = true;
+ AddHeader("Connection", "keep-alive");
+ AddHeader("Accept-Encoding", "booo");
+ pUserInfo = NULL;
+ m_iRetry = MAX_RETRIES;
+}
+
+AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc)
+{
+ cbSize = sizeof(NETLIBHTTPREQUEST);
+ m_bApiReq = true;
+ AddHeader("Connection", "keep-alive");
+ AddHeader("Accept-Encoding", "booo");
+
+ flags = VK_NODUMPHEADERS | NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
+ if (bSecure)
+ flags |= NLHRF_SSL;
+
+ if (*_url == '/') { // relative url leads to a site
+ m_szUrl = ((bSecure) ? "https://" : "http://") + CMStringA("api.vk.com");
+ m_szUrl += _url;
+ bIsMainConn = true;
+ }
+ else m_szUrl = _url;
+
+ if (bSecure)
+ this << CHAR_PARAM("access_token", ppro->m_szAccessToken);
+
+ requestType = iRequestType;
+ m_pFunc = pFunc;
+ pUserInfo = NULL;
+ m_iRetry = MAX_RETRIES;
+}
+
+AsyncHttpRequest::~AsyncHttpRequest()
+{
+ for (int i = 0; i < headersCount; i++) {
+ mir_free(headers[i].szName);
+ mir_free(headers[i].szValue);
+ }
+ mir_free(headers);
+ mir_free(pData);
+}
+
+void AsyncHttpRequest::AddHeader(LPCSTR szName, LPCSTR szValue)
+{
+ headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount + 1));
+ headers[headersCount].szName = mir_strdup(szName);
+ headers[headersCount].szValue = mir_strdup(szValue);
+ headersCount++;
+}
+
+void AsyncHttpRequest::Redirect(NETLIBHTTPREQUEST *nhr)
+{
+ for (int i = 0; i < nhr->headersCount; i++) {
+ LPCSTR szValue = nhr->headers[i].szValue;
+ if (!_stricmp(nhr->headers[i].szName, "Location"))
+ m_szUrl = szValue;
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
TCHAR* CVkProto::GetUserStoredPassword()
{
debugLogA("CVkProto::GetUserStoredPassword");
@@ -38,6 +159,8 @@ void CVkProto::SetAllContactStatuses(int iStatus) }
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MCONTACT CVkProto::FindUser(LONG dwUserid, bool bCreate)
{
if (!dwUserid)
@@ -79,6 +202,8 @@ MCONTACT CVkProto::FindChat(LONG dwUserid) return NULL;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
bool CVkProto::CheckMid(int guid)
{
for (int i = m_sendIds.getCount() - 1; i >= 0; i--)
@@ -90,14 +215,7 @@ bool CVkProto::CheckMid(int guid) return false;
}
-LPCSTR findHeader(NETLIBHTTPREQUEST *pReq, LPCSTR szField)
-{
- for (int i = 0; i < pReq->headersCount; i++)
- if (!_stricmp(pReq->headers[i].szName, szField))
- return pReq->headers[i].szValue;
-
- return NULL;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
JSONNODE* CVkProto::CheckJsonResponse(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, JSONROOT &pRoot)
{
@@ -181,36 +299,6 @@ void CVkProto::OnReceiveSmth(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) }
/////////////////////////////////////////////////////////////////////////////////////////
-
-static IconItem iconList[] =
-{
- { LPGEN("Captcha form icon"), "key", IDI_KEYS },
- { LPGEN("Notification icon"), "notification", IDI_NOTIFICATION },
- { LPGEN("Read message icon"), "read", IDI_READMSG },
- { LPGEN("Visit profile icon"), "profile", IDI_VISITPROFILE },
- { LPGEN("Load server history icon"), "history", IDI_HISTORY },
- { LPGEN("Add to friend list icon"), "addfriend", IDI_FRIENDADD },
- { LPGEN("Delete from friend list icon"), "delfriend", IDI_FRIENDDEL },
- { LPGEN("Report abuse icon"), "abuse", IDI_ABUSE },
- { LPGEN("Ban user icon"), "ban", IDI_BAN},
- { LPGEN("Broadcast icon"), "broadcast", IDI_BROADCAST}
-};
-
-void InitIcons()
-{
- Icon_Register(hInst, LPGEN("Protocols")"/"LPGEN("VKontakte"), iconList, SIZEOF(iconList), "VKontakte");
-}
-
-HANDLE GetIconHandle(int iCommand)
-{
- for (int i=0; i < SIZEOF(iconList); i++)
- if (iconList[i].defIconID == iCommand)
- return iconList[i].hIcolib;
-
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Quick & dirty form parser
static CMStringA getAttr(char *szSrc, LPCSTR szAttrName)
@@ -292,70 +380,6 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul /////////////////////////////////////////////////////////////////////////////////////////
-AsyncHttpRequest::AsyncHttpRequest()
-{
- cbSize = sizeof(NETLIBHTTPREQUEST);
- m_bApiReq = true;
- AddHeader("Connection", "keep-alive");
- AddHeader("Accept-Encoding", "booo");
- pUserInfo = NULL;
- m_iRetry = MAX_RETRIES;
-}
-
-AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url, bool bSecure, VK_REQUEST_HANDLER pFunc)
-{
- cbSize = sizeof(NETLIBHTTPREQUEST);
- m_bApiReq = true;
- AddHeader("Connection", "keep-alive");
- AddHeader("Accept-Encoding", "booo");
-
- flags = VK_NODUMPHEADERS | NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
- if (bSecure)
- flags |= NLHRF_SSL;
-
- if (*_url == '/') { // relative url leads to a site
- m_szUrl = ((bSecure) ? "https://" : "http://") + CMStringA("api.vk.com");
- m_szUrl += _url;
- bIsMainConn = true;
- }
- else m_szUrl = _url;
-
- if (bSecure)
- this << CHAR_PARAM("access_token", ppro->m_szAccessToken);
-
- requestType = iRequestType;
- m_pFunc = pFunc;
- pUserInfo = NULL;
- m_iRetry = MAX_RETRIES;
-}
-
-AsyncHttpRequest::~AsyncHttpRequest()
-{
- for (int i = 0; i < headersCount; i++) {
- mir_free(headers[i].szName);
- mir_free(headers[i].szValue);
- }
- mir_free(headers);
- mir_free(pData);
-}
-
-void AsyncHttpRequest::AddHeader(LPCSTR szName, LPCSTR szValue)
-{
- headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount + 1));
- headers[headersCount].szName = mir_strdup(szName);
- headers[headersCount].szValue = mir_strdup(szValue);
- headersCount++;
-}
-
-void AsyncHttpRequest::Redirect(NETLIBHTTPREQUEST *nhr)
-{
- for (int i = 0; i < nhr->headersCount; i++) {
- LPCSTR szValue = nhr->headers[i].szValue;
- if (!_stricmp(nhr->headers[i].szName, "Location"))
- m_szUrl = szValue;
- }
-}
-
void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr)
{
debugLogA("CVkProto::GrabCookies");
@@ -414,6 +438,8 @@ void CVkProto::ApplyCookies(AsyncHttpRequest *pReq) pReq->AddHeader("Cookie", szCookie);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CVkProto::DBAddAuthRequest(const MCONTACT hContact)
{
debugLogA("CVkProto::DBAddAuthRequest");
@@ -476,6 +502,8 @@ MCONTACT CVkProto::MContactFromDbEvent(HANDLE hDbEvent) return hContact;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CVkProto::SetMirVer(MCONTACT hContact, int platform)
{
if (hContact == NULL || hContact == INVALID_CONTACT_ID)
@@ -539,17 +567,7 @@ void CVkProto::SetMirVer(MCONTACT hContact, int platform) setTString(hContact, "MirVer", MirVer.GetBuffer());
}
-bool tlstrstr(TCHAR* _s1, TCHAR* _s2)
-{
- TCHAR s1[1024], s2[1024];
-
- _tcsncpy_s(s1, _s1, _TRUNCATE);
- CharLowerBuff(s1, SIZEOF(s1));
- _tcsncpy_s(s2, _s2, _TRUNCATE);
- CharLowerBuff(s2, SIZEOF(s2));
-
- return _tcsstr(s1, s2) != NULL;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
void CVkProto::ContactTypingThread(void *p)
{
@@ -632,11 +650,11 @@ int CVkProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam) return 0;
}
-//////////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////
CMString CVkProto::SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent)
{
- CVkNotification vkNotification[] = {
+ CVKNotification vkNotification[] = {
// type, parent, feedback, string for translate
{ _T("follow"), vkNull, vkUsers, _T("") },
{ _T("friend_accepted"), vkNull, vkUsers, _T("") },
@@ -675,4 +693,204 @@ CMString CVkProto::SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedba break;
}
return tszRes;
+}
+
+CMString CVkProto::GetVkPhotoItem(JSONNODE *pPhoto)
+{
+ CMString tszRes;
+
+ if (pPhoto == NULL)
+ return tszRes;
+
+ ptrT ptszLink, ptszPreviewLink;
+ for (int i = 0; i < SIZEOF(szImageTypes); i++) {
+ JSONNODE *n = json_get(pPhoto, szImageTypes[i]);
+ if (n != NULL) {
+ ptszLink = json_as_string(n);
+ break;
+ }
+ }
+
+ switch (m_iIMGBBCSupport){
+ case imgNo:
+ ptszPreviewLink = NULL;
+ break;
+ case imgFullSize:
+ ptszPreviewLink = ptszLink;
+ break;
+ case imgPreview130:
+ case imgPreview604:
+ ptszPreviewLink = json_as_string(json_get(pPhoto, m_iIMGBBCSupport == imgPreview130 ? "photo_130" : "photo_604"));
+ break;
+ }
+
+ int iWidth = json_as_int(json_get(pPhoto, "width"));
+ int iHeight = json_as_int(json_get(pPhoto, "height"));
+
+ tszRes.AppendFormat(_T("%s: %s (%dx%d)"), TranslateT("Photo"), ptszLink ? ptszLink : _T(""), 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"));
+ if (!tszText.IsEmpty())
+ tszRes += "\n" + tszText;
+
+ return tszRes;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)
+{
+ debugLogA("CVkProto::GetAttachmentDescr");
+ CMString res;
+ res.AppendChar('\n');
+ res += TranslateT("Attachments:");
+ res.AppendChar('\n');
+ JSONNODE *pAttach;
+ for (int k = 0; (pAttach = json_at(pAttachments, k)) != NULL; k++) {
+ res.AppendChar('\t');
+ ptrT ptszType(json_as_string(json_get(pAttach, "type")));
+ if (!mir_tstrcmp(ptszType, _T("photo"))) {
+ JSONNODE *pPhoto = json_get(pAttach, "photo");
+ if (pPhoto == NULL)
+ continue;
+
+ res += GetVkPhotoItem(pPhoto);
+ }
+ else if (!mir_tstrcmp(ptszType, _T("audio"))) {
+ JSONNODE *pAudio = json_get(pAttach, "audio");
+ if (pAudio == NULL)
+ continue;
+
+ ptrT ptszArtist(json_as_string(json_get(pAudio, "artist")));
+ ptrT ptszTitle(json_as_string(json_get(pAudio, "title")));
+ ptrT ptszUrl(json_as_string(json_get(pAudio, "url")));
+ res.AppendFormat(_T("%s: (%s - %s) - %s"),
+ TranslateT("Audio"), ptszArtist, ptszTitle, ptszUrl);
+ }
+ else if (!mir_tstrcmp(ptszType, _T("video"))) {
+ JSONNODE *pVideo = json_get(pAttach, "video");
+ if (pVideo == NULL)
+ continue;
+
+ ptrT ptszTitle(json_as_string(json_get(pVideo, "title")));
+ int vid = json_as_int(json_get(pVideo, "id"));
+ int ownerID = json_as_int(json_get(pVideo, "owner_id"));
+ res.AppendFormat(_T("%s: %s - http://vk.com/video%d_%d"), TranslateT("Video"), ptszTitle, ownerID, vid);
+ }
+ else if (!mir_tstrcmp(ptszType, _T("doc"))) {
+ JSONNODE *pDoc = json_get(pAttach, "doc");
+ if (pDoc == NULL)
+ continue;
+
+ ptrT ptszTitle(json_as_string(json_get(pDoc, "title")));
+ ptrT ptszUrl(json_as_string(json_get(pDoc, "url")));
+ res.AppendFormat(_T("%s: (%s) - %s"), TranslateT("Document"), ptszTitle, ptszUrl);
+ }
+ else if (!mir_tstrcmp(ptszType, _T("wall"))) {
+ JSONNODE *pWall = json_get(pAttach, "wall");
+ if (pWall == NULL)
+ continue;
+
+ ptrT ptszText(json_as_string(json_get(pWall, "text")));
+ int id = json_as_int(json_get(pWall, "id"));
+ int fromID = json_as_int(json_get(pWall, "from_id"));
+ res.AppendFormat(_T("%s: %s - http://vk.com/wall%d_%d"), TranslateT("Wall post"), ptszText ? ptszText : _T(" "), fromID, id);
+ }
+ else if (!mir_tstrcmp(ptszType, _T("sticker"))) {
+ JSONNODE *pSticker = json_get(pAttach, "sticker");
+ if (pSticker == NULL)
+ continue;
+ res.Empty(); // sticker is not really an attachment, so we don't want all that heading info
+
+ if (m_bStikersAsSmyles) {
+ int id = json_as_int(json_get(pSticker, "id"));
+ res.AppendFormat(_T("[sticker:%d]"), id);
+ }
+ else {
+ ptrT ptszLink;
+ for (int i = 0; i < SIZEOF(szImageTypes); i++) {
+ JSONNODE *n = json_get(pSticker, szImageTypes[i]);
+ if (n != NULL) {
+ ptszLink = json_as_string(n);
+ break;
+ }
+ }
+ res.AppendFormat(_T("%s"), ptszLink);
+
+ if (m_iIMGBBCSupport)
+ res.AppendFormat(_T("[img]%s[/img]"), ptszLink);
+ }
+ }
+ else if (!mir_tstrcmp(ptszType, _T("link"))){
+ JSONNODE *pLink = json_get(pAttach, "link");
+ if (pLink == NULL)
+ continue;
+
+ 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")));
+
+ res.AppendFormat(_T("%s: %s (%s)"), TranslateT("Link"), ptszTitle ? ptszTitle : _T(""), ptszUrl ? ptszUrl : _T(""));
+ if (!tszImage.IsEmpty())
+ if (m_iIMGBBCSupport)
+ res.AppendFormat(_T("\n\t%s: [img]%s[/img]"), TranslateT("Image"), tszImage.GetBuffer());
+ else
+ res.AppendFormat(_T("\n\t%s: %s"), TranslateT("Image"), tszImage.GetBuffer());
+
+ if (ptszDescription)
+ res.AppendFormat(_T("\n\t%s"), ptszDescription);
+ }
+ else res.AppendFormat(TranslateT("Unsupported or unknown attachment type: %s"), ptszType);
+
+ res.AppendChar('\n');
+ }
+
+ return res;
+}
+
+CMString CVkProto::SetBBCString(TCHAR *tszString, VKBBCType bbcType, TCHAR *tszAddString)
+{
+ CVKBBCItem bbcItem[] = {
+ { vkbbcB, bbcNo, _T("%s") },
+ { vkbbcB, bbcBasic, _T("[b]%s[/b]") },
+ { vkbbcB, bbcAdvanced, _T("[b]%s[/b]") },
+ { vkbbcI, bbcNo, _T("%s") },
+ { vkbbcI, bbcBasic, _T("[i]%s[/i]") },
+ { vkbbcI, bbcAdvanced, _T("[i]%s[/i]") },
+ { vkbbcS, bbcNo, _T("%s") },
+ { vkbbcS, bbcBasic, _T("[s]%s[/s]") },
+ { vkbbcS, bbcAdvanced, _T("[s]%s[/s]") },
+ { vkbbcU, bbcNo, _T("%s") },
+ { vkbbcU, bbcBasic, _T("[u]%s[/u]") },
+ { vkbbcU, bbcAdvanced, _T("[u]%s[/u]") },
+ { vkbbcUrl, bbcNo, _T("%s (%s)") },
+ { vkbbcUrl, bbcBasic, _T("[b]%s[/b] (%s)") },
+ { vkbbcUrl, bbcAdvanced, _T("[url=%s]%s[/url]") },
+ { vkbbcSize, bbcNo, _T("%s") },
+ { vkbbcSize, bbcBasic, _T("%s") },
+ { vkbbcSize, bbcAdvanced, _T("[size=%s]%s[/size]") },
+ { vkbbcColor, bbcNo, _T("%s") },
+ { vkbbcColor, bbcBasic, _T("%s") },
+ { vkbbcColor, bbcAdvanced, _T("[color=%s]%s[/color]") },
+ };
+
+ TCHAR *ptszFormat;
+ for (int i = 0; i < SIZEOF(bbcItem); i++)
+ if (bbcItem[i].vkBBCType == bbcType && bbcItem[i].vkBBCSettings == m_iBBCForNews){
+ ptszFormat = bbcItem[i].ptszTempate;
+ break;
+ }
+
+ CMString res;
+
+ if (bbcType == vkbbcUrl && m_iBBCForNews != bbcAdvanced)
+ res.AppendFormat(ptszFormat, tszString ? tszString : _T(""), tszAddString ? tszAddString : _T(""));
+ else if (m_iBBCForNews == bbcAdvanced && bbcType >= vkbbcUrl)
+ res.AppendFormat(ptszFormat, tszAddString ? tszAddString : _T(""), tszString ? tszString : _T(""));
+ else
+ res.AppendFormat(ptszFormat, tszString ? tszString : _T(""));
+
+ return res;
}
\ No newline at end of file diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index 404ab529ec..5313811205 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -18,6 +18,7 @@ #define IDI_VISITPROFILE 115
#define IDI_HISTORY 116
#define IDI_BROADCAST 117
+#define IDD_OPT_VIEW 118
#define IDI_KEYS 203
#define IDC_LOGIN 1001
#define IDC_PASSWORD 1002
@@ -41,7 +42,6 @@ #define IDC_CLEAR_SERVER_HISTORY 1031
#define IDC_REMOVE_FROM_FRENDLIST 1032
#define IDC_REMOVE_FROM_CLIST 1033
-#define IDC_ADD_IMG_BBC 1034
#define IDC_FORCE_ONLINE_ON_ACT 1035
#define IDC_STICKERS_AS_SMYLES 1036
#define IDC_ONREAD 1039
@@ -61,21 +61,28 @@ #define IDC_SYNC_LAST3DAY 1053
#define IDC_NEWS_ENBL 1054
#define IDC_NOTIF_ENBL 1055
-#define IDC_BBC_NEWS 1056
#define IDC_ED_INT_NEWS 1057
#define IDC_SPIN_INT_NEWS 1058
#define IDC_ED_INT_NOTIF 1059
#define IDC_SPIN_INT_NOTIF 1060
#define IDC_SPEC_CONT_ENBL 1061
+#define IDC_IMG_OFF 1062
+#define IDC_IMG_FULLSIZE 1063
+#define IDC_IMG_130 1064
+#define IDC_IMG_604 1065
+#define IDC_NEWSBBC_OFF 1066
+#define IDC_NEWSBBC_BASIC 1067
+#define IDC_NEWSBBC_ADV 1068
+#define IDC_IEVIEW 1069
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 118
+#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1062
+#define _APS_NEXT_CONTROL_VALUE 1070
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 906031dc49..142a18f885 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 35
+#define __BUILD_NUM 36
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index 0c9e4b54f8..e4152d5ae5 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -17,8 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
-static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" };
-
void CVkProto::AddFeedSpecialUser()
{
bool bSpecialContact = m_bNewsEnabled || m_bNotificationsEnabled || m_bSpecialContactAlwaysEnabled;
@@ -128,35 +126,6 @@ void CVkProto::CreateVkUserInfoList(OBJLIST<CVkUserInfo> &vkUsers, JSONNODE *pRe }
}
-CMString CVkProto::GetVkPhotoItem(JSONNODE *pPhoto)
-{
- CMString tszRes;
-
- if (pPhoto == NULL)
- return tszRes;
-
- ptrT ptszLink;
- for (int i = 0; i < SIZEOF(szImageTypes); i++) {
- JSONNODE *n = json_get(pPhoto, szImageTypes[i]);
- if (n != NULL) {
- ptszLink = json_as_string(n);
- break;
- }
- }
-
- int iWidth = json_as_int(json_get(pPhoto, "width"));
- int iHeight = json_as_int(json_get(pPhoto, "height"));
-
- tszRes.AppendFormat(_T("%s: %s (%dx%d)"), TranslateT("Photo"), ptszLink ? ptszLink : _T(""), iWidth, iHeight);
- if (m_bAddImgBbc)
- tszRes.AppendFormat(_T("\n\t[img]%s[/img]"), ptszLink);
- CMString tszText = json_as_string(json_get(pPhoto, "text"));
- if (!tszText.IsEmpty())
- tszRes += "\n" + tszText;
-
- return tszRes;
-}
-
//////////////////////////////////////////////////////////////////////////////////////////////////////////
CVKNewsItem* CVkProto::GetVkNewsItem(JSONNODE *pItem, OBJLIST<CVkUserInfo> &vkUsers, bool isRepost)
@@ -232,23 +201,22 @@ CVKNewsItem* CVkProto::GetVkNewsItem(JSONNODE *pItem, OBJLIST<CVkUserInfo> &vkUs }
CMString tszResFormat;
- CMString tszBBCIn = m_bBBCOnNews ? _T("[b]") : _T("");
- CMString tszBBCOut = m_bBBCOnNews ? _T("[/b]") : _T("");
if (!isRepost)
- tszResFormat = Translate("News from %s%s%s (%s)\n%s");
+ tszResFormat = Translate("News from %s\n%s");
else {
- tszResFormat = Translate("\tRepost from %s%s%s (%s)\n%s");
+ tszResFormat = Translate("\tRepost from %s\n%s");
bPostLink = false;
}
- vkNewsItem->tszText.AppendFormat(tszResFormat, tszBBCIn.GetBuffer(), vkNewsItem->vkUser->m_tszUserNick.GetBuffer(), tszBBCOut.GetBuffer(),
- vkNewsItem->vkUser->m_tszLink.GetBuffer(), tszText.GetBuffer());
+ vkNewsItem->tszText.AppendFormat(tszResFormat, SetBBCString(vkNewsItem->vkUser->m_tszUserNick.GetBuffer(), vkbbcUrl,
+ vkNewsItem->vkUser->m_tszLink.GetBuffer()), tszText.GetBuffer());
vkNewsItem->tszId.AppendFormat(_T("%d_%d"), vkNewsItem->vkUser->m_UserId, iPostId);
if (bPostLink) {
vkNewsItem->tszLink = CMString(_T("https://vk.com/wall")) + vkNewsItem->tszId;
- vkNewsItem->tszText.AppendFormat(TranslateT("\nNews link: %s"), vkNewsItem->tszLink.GetBuffer());
+ vkNewsItem->tszText.AppendChar(_T('\n'));
+ vkNewsItem->tszText += SetBBCString(TranslateT("Link"), vkbbcUrl, vkNewsItem->tszLink.GetBuffer());
}
debugLog(_T("CVkProto::GetVkNewsItem %d %d <%s> <%s>"), iSourceId, iPostId, vkNewsItem->tszText.GetBuffer(), tszText.GetBuffer());
@@ -265,19 +233,16 @@ CMString CVkProto::GetVkFeedback(JSONNODE *pFeedback, VKObjType vkFeedbackType, if (!pFeedback || !vkFeedbackType)
return tszRes;
-
- CMString tszBBCIn = m_bBBCOnNews ? _T("[b]") : _T("");
- CMString tszBBCOut = m_bBBCOnNews ? _T("[/b]") : _T("");
CMString tszFormat;
LONG iUserId = 0;
if (vkFeedbackType == vkComment) {
iUserId = json_as_int(json_get(pFeedback, "from_id"));
- tszFormat = _T("%s%s%s (%s) %%s %%s\n%s");
+ tszFormat = _T("%s %%s %%s\n%s");
}
else if (vkFeedbackType == vkPost) {
iUserId = json_as_int(json_get(pFeedback, "owner_id "));
- tszFormat = _T("%s%s%s (%s) %%s %%s\n%s");
+ tszFormat = _T("%s %%s %%s\n%s");
}
else if (vkFeedbackType == VKObjType::vkUsers || vkFeedbackType == vkCopy){
JSONNODE *pUsers = json_get(pFeedback, "items"), *pUserItem;
@@ -290,7 +255,7 @@ CMString CVkProto::GetVkFeedback(JSONNODE *pFeedback, VKObjType vkFeedbackType, vkUser = GetVkUserInfo(iUserId, vkUsers);
if (!tszUsers.IsEmpty())
tszUsers += _T(", ");
- tszUsers.AppendFormat(_T("%s%s%s (%s)"), tszBBCIn.GetBuffer(), vkUser->m_tszUserNick.GetBuffer(), tszBBCOut.GetBuffer(), vkUser->m_tszLink.GetBuffer());
+ tszUsers += SetBBCString(vkUser->m_tszUserNick.GetBuffer(), vkbbcUrl, vkUser->m_tszLink.GetBuffer());
}
tszRes.AppendFormat(_T("%s %%s %%s"), tszUsers.GetBuffer());
vkUser = NULL;
@@ -309,50 +274,50 @@ CMString CVkProto::GetVkFeedback(JSONNODE *pFeedback, VKObjType vkFeedbackType, tszText = tszName + _T(",") + tszBody;
}
- tszRes.AppendFormat(tszFormat, tszBBCIn.GetBuffer(), vkUser->m_tszUserNick.GetBuffer(), tszBBCOut.GetBuffer(), vkUser->m_tszLink.GetBuffer(), tszText.GetBuffer());
+ tszRes.AppendFormat(tszFormat, SetBBCString(vkUser->m_tszUserNick.GetBuffer(), vkbbcUrl, vkUser->m_tszLink.GetBuffer()), tszText.GetBuffer());
}
return tszRes;
}
-CMString CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType)
+CMString CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType, TCHAR *ptszReply)
{
debugLogA("CVkProto::GetVkParent");
CMString tszRes;
if (!pParent || !vkParentType)
return tszRes;
-
- CMString tszBBCIn = m_bBBCOnNews ? _T("[b]") : _T("");
- CMString tszBBCOut = m_bBBCOnNews ? _T("[/b]") : _T("");
-
+
if (vkParentType == vkPhoto) {
CMString tszPhoto = GetVkPhotoItem(pParent);
LONG iOwnerId = json_as_int(json_get(pParent, "owner_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
- CMString tszFormat = _T("\n%s\n%s%s%s: https://vk.com/photo%d_%d");
- tszRes.AppendFormat(tszFormat, tszPhoto.GetBuffer(), tszBBCIn.GetBuffer(), TranslateT("Link"), tszBBCOut.GetBuffer(), iOwnerId, iId);
+
+ CMString tszLink;
+ tszLink.AppendFormat(_T("https://vk.com/photo%d_%d"), iOwnerId, iId);
+ tszRes.AppendFormat(_T("\n%s\n%s"), tszPhoto.GetBuffer(), SetBBCString(TranslateT("Link"), vkbbcUrl, tszLink.GetBuffer()));
}
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 tszFormat = _T("\n%s%s%s\n%s%s%s: https://vk.com/video%d_%d");
- tszRes.AppendFormat(tszFormat, tszBBCIn.GetBuffer(), tszTitle.GetBuffer(), tszBBCOut.GetBuffer(), tszBBCIn.GetBuffer(), TranslateT("Link"), tszBBCOut.GetBuffer(), iOwnerId, iId);
+ CMString tszLink;
+ tszLink.AppendFormat(_T("https://vk.com/video%d_%d"), iOwnerId, iId);
+ tszRes.AppendFormat(_T("\n%s"), SetBBCString(tszTitle.GetBuffer(), vkbbcUrl, tszLink.GetBuffer()));
}
else if (vkParentType == vkPost) {
LONG iOwnerId = json_as_int(json_get(pParent, "from_id"));
LONG iId = json_as_int(json_get(pParent, "id"));
- CMString tszFormat = _T("\n%s%s%s: https://vk.com/wall%d_%d");
- tszRes.AppendFormat(tszFormat, tszBBCIn.GetBuffer(), TranslateT("Link"), tszBBCOut.GetBuffer(), iOwnerId, iId);
+ CMString tszLink;
+ tszLink.AppendFormat(_T("https://vk.com/wall%d_%d%s"), iOwnerId, iId, ptszReply ? ptszReply : _T(""));
+ tszRes.AppendFormat(_T("\n%s"), SetBBCString(TranslateT("Link"), vkbbcUrl, tszLink.GetBuffer()));
}
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 tszFormat = _T("%s%s%s\n%s%s%s: https://vk.com/topic%d_%d");
- tszRes.AppendFormat(tszFormat, tszBBCIn.GetBuffer(), tszTitle.GetBuffer(), tszBBCOut.GetBuffer(), tszBBCIn.GetBuffer(), TranslateT("Link"), tszBBCOut.GetBuffer(), iOwnerId, iId);
+ CMString tszLink;
+ tszLink.AppendFormat(_T("https://vk.com/topic%d_%d%s"), iOwnerId, iId, ptszReply ? ptszReply : _T(""));
+ tszRes.AppendFormat(_T("\n%s"), SetBBCString(tszTitle.GetBuffer(), vkbbcUrl, tszLink.GetBuffer()));
}
else if (vkParentType == vkComment) {
JSONNODE *pNode = json_get(pParent, "photo");
@@ -367,15 +332,17 @@ CMString CVkProto::GetVkParent(JSONNODE *pParent, VKObjType vkParentType) pNode = json_get(pParent, "post");
if (pNode){
- tszRes = GetVkParent(pNode, vkPost);
- tszRes.AppendFormat(_T("?reply=%d"), iId);
+ CMString tszRepl;
+ tszRepl.AppendFormat(_T("?reply=%d"), iId);
+ tszRes = GetVkParent(pNode, vkPost, tszRepl.GetBuffer());
return tszRes;
}
pNode = json_get(pParent, "topic");
if (pNode){
- tszRes = GetVkParent(pNode, vkTopic);
- tszRes.AppendFormat(_T("?reply=%d"), iId);
+ CMString tszRepl;
+ tszRepl.AppendFormat(_T("?reply=%d"), iId);
+ tszRes = GetVkParent(pNode, vkTopic, tszRepl.GetBuffer());
return tszRes;
}
}
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index a6f4aa46b0..e601164676 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -244,8 +244,6 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_MESASUREAD, ppro->m_bMesAsUnread ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_ADD_IMG_BBC, ppro->m_bAddImgBbc ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_STICKERS_AS_SMYLES, ppro->m_bStikersAsSmyles ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_FORCE_ONLINE_ON_ACT, ppro->m_bUserForceOnlineOnActivity ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_REPORT_ABUSE, ppro->m_bReportAbuse ? BST_CHECKED : BST_UNCHECKED);
@@ -264,9 +262,7 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam switch (LOWORD(wParam)) {
case IDC_HIDECHATS:
case IDC_MESASUREAD:
- case IDC_ADD_IMG_BBC:
case IDC_FORCE_ONLINE_ON_ACT:
- case IDC_STICKERS_AS_SMYLES:
case IDC_REPORT_ABUSE:
case IDC_CLEAR_SERVER_HISTORY:
case IDC_REMOVE_FROM_FRENDLIST:
@@ -289,11 +285,8 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam ppro->m_bMesAsUnread = IsDlgButtonChecked(hwndDlg, IDC_MESASUREAD) == BST_CHECKED;
ppro->setByte("MesAsUnread", ppro->m_bMesAsUnread);
- ppro->m_bAddImgBbc = IsDlgButtonChecked(hwndDlg, IDC_ADD_IMG_BBC) == BST_CHECKED;
- ppro->setByte("AddImgBbc", ppro->m_bAddImgBbc);
- ppro->m_bStikersAsSmyles = IsDlgButtonChecked(hwndDlg, IDC_STICKERS_AS_SMYLES) == BST_CHECKED;
- ppro->setByte("StikersAsSmyles", ppro->m_bStikersAsSmyles);
+
ppro->m_bUserForceOnlineOnActivity = IsDlgButtonChecked(hwndDlg, IDC_FORCE_ONLINE_ON_ACT) == BST_CHECKED;
ppro->setByte("UserForceOnlineOnActivity", ppro->m_bUserForceOnlineOnActivity);
@@ -355,7 +348,6 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar CheckDlgButton(hwndDlg, IDC_NEWS_ENBL, ppro->m_bNewsEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NOTIF_ENBL, ppro->m_bNotificationsEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SPEC_CONT_ENBL, ppro->m_bSpecialContactAlwaysEnabled ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_BBC_NEWS, ppro->m_bBBCOnNews ? BST_CHECKED : BST_UNCHECKED);
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETRANGE, 0, MAKELONG(60*24, 1));
SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_NEWS, UDM_SETPOS, 0, ppro->m_iNewsInterval);
@@ -376,7 +368,6 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar case IDC_NEWS_ENBL:
case IDC_NOTIF_ENBL:
case IDC_SPEC_CONT_ENBL:
- case IDC_BBC_NEWS:
if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
@@ -397,9 +388,6 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar ppro->m_bSpecialContactAlwaysEnabled = IsDlgButtonChecked(hwndDlg, IDC_SPEC_CONT_ENBL) == BST_CHECKED;
ppro->setByte("SpecialContactAlwaysEnabled", ppro->m_bSpecialContactAlwaysEnabled);
- ppro->m_bBBCOnNews = IsDlgButtonChecked(hwndDlg, IDC_BBC_NEWS) == BST_CHECKED;
- ppro->setByte("BBCOnNews", ppro->m_bBBCOnNews);
-
TCHAR buffer[5] = { 0 };
GetDlgItemText(hwndDlg, IDC_ED_INT_NEWS, buffer, SIZEOF(buffer));
ppro->setDword("NewsInterval", ppro->m_iNewsInterval = _ttoi(buffer));
@@ -423,6 +411,87 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar return FALSE;
}
+INT_PTR CALLBACK CVkProto::OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ ppro = (CVkProto*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon, 1));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon));
+
+ CheckDlgButton(hwndDlg, IDC_IMG_OFF, (ppro->m_iIMGBBCSupport == imgNo) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_IMG_FULLSIZE, (ppro->m_iIMGBBCSupport == imgFullSize) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_IMG_130, (ppro->m_iIMGBBCSupport == imgPreview130) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_IMG_604, (ppro->m_iIMGBBCSupport == imgPreview604) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_NEWSBBC_OFF, (ppro->m_iBBCForNews == bbcNo) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_NEWSBBC_BASIC, (ppro->m_iBBCForNews == bbcBasic) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_NEWSBBC_ADV, (ppro->m_iBBCForNews == bbcAdvanced) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_STICKERS_AS_SMYLES, ppro->m_bStikersAsSmyles ? BST_CHECKED : BST_UNCHECKED);
+
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_IMG_OFF:
+ case IDC_IMG_FULLSIZE:
+ case IDC_IMG_130:
+ case IDC_IMG_604:
+ case IDC_NEWSBBC_OFF:
+ case IDC_NEWSBBC_BASIC:
+ case IDC_NEWSBBC_ADV:
+ case IDC_STICKERS_AS_SMYLES:
+ if (HIWORD(wParam) == BN_CLICKED && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ break;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_IMG_OFF) == BST_CHECKED)
+ ppro->m_iIMGBBCSupport = imgNo;
+ if (IsDlgButtonChecked(hwndDlg, IDC_IMG_FULLSIZE) == BST_CHECKED)
+ ppro->m_iIMGBBCSupport = imgFullSize;
+ if (IsDlgButtonChecked(hwndDlg, IDC_IMG_130) == BST_CHECKED)
+ ppro->m_iIMGBBCSupport = imgPreview130;
+ if (IsDlgButtonChecked(hwndDlg, IDC_IMG_604) == BST_CHECKED)
+ ppro->m_iIMGBBCSupport = imgPreview604;
+ ppro->setByte("IMGBBCSupport", ppro->m_iIMGBBCSupport);
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_OFF) == BST_CHECKED)
+ ppro->m_iBBCForNews = bbcNo;
+ if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_BASIC) == BST_CHECKED)
+ ppro->m_iBBCForNews = bbcBasic;
+ if (IsDlgButtonChecked(hwndDlg, IDC_NEWSBBC_ADV) == BST_CHECKED)
+ ppro->m_iBBCForNews = bbcAdvanced;
+ ppro->setByte("BBCForNews", ppro->m_iBBCForNews);
+
+ ppro->m_bStikersAsSmyles = IsDlgButtonChecked(hwndDlg, IDC_STICKERS_AS_SMYLES) == BST_CHECKED;
+ ppro->setByte("StikersAsSmyles", ppro->m_bStikersAsSmyles);
+ }
+ break;
+
+ case WM_CLOSE:
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case WM_DESTROY:
+ Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
+ Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
+ break;
+ }
+
+ return FALSE;
+}
+
int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
@@ -449,5 +518,11 @@ int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM) odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_FEEDS);
odp.pfnDlgProc = &CVkProto::OptionsFeedsProc;
Options_AddPage(wParam, &odp);
+
+ odp.ptszTab = LPGENT("View settings");
+ odp.position = 4;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VIEW);
+ odp.pfnDlgProc = &CVkProto::OptionsViewProc;
+ Options_AddPage(wParam, &odp);
return 0;
}
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 8362f77d23..ef47adc411 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -70,7 +70,6 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_bRemoveFromClist = getBool("RemoveFromClistOnBanUser", false);
m_bPopUpSyncHistory = getBool("PopUpSyncHistory", false);
m_iMarkMessageReadOn = getByte("MarkMessageReadOn", 0);
- m_bAddImgBbc = getBool("AddImgBbc", false);
m_bStikersAsSmyles = getBool("StikersAsSmyles", false);
m_bUserForceOnlineOnActivity = getBool("UserForceOnlineOnActivity", false);
m_iMusicSendMetod = getByte("MusicSendMetod", sendBroadcastOnly);
@@ -81,9 +80,10 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : m_bNewsEnabled = getBool("NewsEnabled", false);
m_bNotificationsEnabled = getBool("NotificationsEnabled", false);
m_bSpecialContactAlwaysEnabled = getBool("SpecialContactAlwaysEnabled", false);
- m_bBBCOnNews = getBool("BBCOnNews", false);
m_iNewsInterval = getDword("NewsInterval", 15);
m_iNotificationsInterval = getDword("NotificationsInterval", 1);
+ m_iIMGBBCSupport = getByte("IMGBBCSupport", 0);
+ m_iBBCForNews = getByte("BBCForNews", 0);
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 757026b2b8..5592662f32 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -181,7 +181,7 @@ struct CVkUserInfo : public MZeroedObject { enum VKObjType { vkNull, vkPost, vkPhoto, vkVideo, vkComment, vkTopic, vkUsers, vkCopy };
-struct CVkNotification {
+struct CVKNotification {
TCHAR *ptszType;
VKObjType vkParent, vkFeedback;
TCHAR *ptszTranslate;
@@ -206,6 +206,16 @@ struct CVKNewsItem : public MZeroedObject { bool bIsRepost;
};
+enum VKBBCType { vkbbcB, vkbbcI, vkbbcS, vkbbcU, vkbbcUrl, vkbbcSize, vkbbcColor };
+enum BBCForNewsSupport { bbcNo, bbcBasic, bbcAdvanced };
+
+struct CVKBBCItem {
+ VKBBCType vkBBCType;
+ BBCForNewsSupport vkBBCSettings;
+ TCHAR *ptszTempate;
+};
+
+
struct TFakeAckParams
{
__inline TFakeAckParams(MCONTACT _hContact, int _msgid) :
@@ -277,8 +287,7 @@ struct CVkProto : public PROTO<CVkProto> void OnOAuthAuthorize(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReceiveAvatar(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
- void OnReceiveSmth(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
-
+
//==== Services ======================================================================
INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
@@ -314,7 +323,7 @@ struct CVkProto : public PROTO<CVkProto> void InitPopups(void);
void MsgPopup(MCONTACT hContact, const TCHAR *szMsg, const TCHAR *szTitle, bool err = false);
- //==== Hooks ====+====================================================================
+ //==== Hooks =========================================================================
int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
int __cdecl OnDbEventRead(WPARAM, LPARAM);
@@ -349,7 +358,7 @@ struct CVkProto : public PROTO<CVkProto> CMString GetVkNotificationsItem(JSONNODE *pItem, OBJLIST<CVkUserInfo> &vkUsers, time_t &tDate);
CMString GetVkFeedback(JSONNODE *pFeedback, VKObjType vkFeedbackType, OBJLIST<CVkUserInfo> &vkUsers, CVkUserInfo *vkUser);
- CMString GetVkParent(JSONNODE *pParent, VKObjType vkParentType);
+ CMString GetVkParent(JSONNODE *pParent, VKObjType vkParentType, TCHAR *ptszReply = NULL);
void RetrieveUnreadNews(time_t tLastNewsTime);
void OnReceiveUnreadNews(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
@@ -360,11 +369,41 @@ struct CVkProto : public PROTO<CVkProto> INT_PTR __cdecl SvcLoadVKNews(WPARAM, LPARAM);
- CMString SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent);
-
//==== Misc ==========================================================================
TCHAR* GetUserStoredPassword(void);
+ void SetAllContactStatuses(int status);
+
+ MCONTACT FindUser(LONG userid, bool bCreate = false);
+ MCONTACT FindChat(LONG dwUserid);
+
+ bool CheckMid(int guid);
+
+ JSONNODE* CheckJsonResponse(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, JSONROOT&);
+ bool CheckJsonResult(AsyncHttpRequest *pReq, JSONNODE*);
+ void OnReceiveSmth(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
+
+ bool AutoFillForm(char*, CMStringA&, CMStringA&);
+
+ void GrabCookies(NETLIBHTTPREQUEST *nhr);
+ void ApplyCookies(AsyncHttpRequest*);
+
+ void DBAddAuthRequest(const MCONTACT hContact);
+ MCONTACT MContactFromDbEvent(HANDLE hDbEvent);
+
+ void SetMirVer(MCONTACT hContact, int platform);
+
+ void __cdecl ContactTypingThread(void *p);
+ void SetSrmmReadStatus(MCONTACT hContact);
+
+ char* GetStickerId(const char* Msg, int& stickerid);
+
+ CMString SpanVKNotificationType(CMString& tszType, VKObjType& vkFeedback, VKObjType& vkParent);
+ CMString SetBBCString(TCHAR *tszString, VKBBCType, TCHAR *tszAddString = NULL);
+
+ CMString GetAttachmentDescr(JSONNODE*);
+
+ //====================================================================================
void RetrieveStatusMsg(const CMString &StatusMsg);
void RetrieveStatusMusic(const CMString &StatusMsg);
@@ -386,7 +425,7 @@ struct CVkProto : public PROTO<CVkProto> void RetrieveUnreadMessages();
void OnReceiveMessages(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReceiveDlgs(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
- CMString GetAttachmentDescr(JSONNODE*);
+
void OnSendMessage(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
@@ -404,8 +443,6 @@ struct CVkProto : public PROTO<CVkProto> void OnReceiveAuthRequest(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReceiveDeleteFriend(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
- void DBAddAuthRequest(const MCONTACT hContact);
- MCONTACT MContactFromDbEvent(HANDLE hDbEvent);
void SetServerStatus(int);
@@ -417,11 +454,6 @@ struct CVkProto : public PROTO<CVkProto> __forceinline LPCTSTR getGroup() const { return m_defaultGroup; }
__forceinline void setGroup(LPCTSTR grp) { m_defaultGroup = mir_tstrdup(grp); }
- void SetMirVer(MCONTACT hContact, int platform);
- void SetSrmmReadStatus(MCONTACT hContact);
- void __cdecl ContactTypingThread(void *p);
- char* GetStickerId(const char* Msg, int& stickerid);
-
static UINT_PTR m_timer;
private:
@@ -477,10 +509,9 @@ private: CMStringA m_name, m_value, m_domain;
};
- OBJLIST<Cookie> m_cookies;
- void GrabCookies(NETLIBHTTPREQUEST *nhr);
- void ApplyCookies(AsyncHttpRequest*);
+ OBJLIST<Cookie> m_cookies;
+
void InitQueue();
void UninitQueue();
void ExecuteRequest(AsyncHttpRequest*);
@@ -489,10 +520,6 @@ private: AsyncHttpRequest* Push(AsyncHttpRequest*, int iTimeout = 10000);
bool RunCaptchaForm(LPCSTR szUrl, CMStringA&);
- bool AutoFillForm(char*, CMStringA&, CMStringA&);
-
- bool CheckJsonResult(AsyncHttpRequest *pReq, JSONNODE*);
- JSONNODE* CheckJsonResponse(AsyncHttpRequest *pReq, NETLIBHTTPREQUEST *reply, JSONROOT&);
bool ApplyCaptcha(AsyncHttpRequest *pReq, JSONNODE*);
void ConnectionFailed(int iReason);
@@ -504,13 +531,11 @@ private: void GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen);
void ReloadAvatarInfo(MCONTACT hContact);
- MCONTACT FindUser(LONG userid, bool bCreate = false);
- MCONTACT FindChat(LONG dwUserid);
-
- void SetAllContactStatuses(int status);
-
void __cdecl SendMsgAck(void *param);
+ //============== Options =============================================================
+
+
bool m_prevError,
m_bOnline,
m_bHideChats,
@@ -521,25 +546,27 @@ private: m_bRemoveFromFrendlist,
m_bRemoveFromClist,
m_bPopUpSyncHistory,
- m_bAddImgBbc,
m_bStikersAsSmyles,
m_bUserForceOnlineOnActivity,
m_bNewsEnabled,
m_bNotificationsEnabled,
- m_bSpecialContactAlwaysEnabled,
- m_bBBCOnNews;
+ m_bSpecialContactAlwaysEnabled;
int m_iNewsInterval, m_iNotificationsInterval;
- enum MarkMsgReadOn{ markOnRead, markOnReceive, markOnReply, markOnTyping };
- int m_iMarkMessageReadOn;
+ enum MarkMsgReadOn { markOnRead, markOnReceive, markOnReply, markOnTyping };
+ int m_iMarkMessageReadOn;
- enum SyncHistoryMetod{ syncOff, syncAuto, sync1Days, sync3Days };
+ enum SyncHistoryMetod { syncOff, syncAuto, sync1Days, sync3Days };
int m_iSyncHistoryMetod;
- enum MusicSendMetod{ sendNone, sendStatusOnly, sendBroadcastOnly, sendBroadcastAndStatus };
+ enum MusicSendMetod { sendNone, sendStatusOnly, sendBroadcastOnly, sendBroadcastAndStatus };
int m_iMusicSendMetod;
+ enum IMGBBCSypport { imgNo, imgFullSize, imgPreview130, imgPreview604 };
+ int m_iIMGBBCSupport;
+ int m_iBBCForNews;
+
LONG m_myUserId;
ptrT m_defaultGroup;
@@ -558,11 +585,11 @@ private: ULONG m_msgId;
LIST<void> m_sendIds;
- bool CheckMid(int guid);
static INT_PTR CALLBACK OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
OBJLIST<CVkChatInfo> m_chats;
CVkChatInfo* AppendChat(int id, JSONNODE *pNode);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index e92e85914d..4d1aa375f3 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. UINT_PTR CVkProto::m_timer;
char szBlankUrl[] = "http://api.vk.com/blank.html";
-static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" };
static char VK_TOKEN_BEG[] = "access_token=";
static char fieldsName[] = "id, first_name, last_name, photo_100, bdate, sex, timezone, contacts, online, status, about, domain";
@@ -1249,128 +1248,4 @@ INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM) return 0;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-
-CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)
-{
- debugLogA("CVkProto::GetAttachmentDescr");
- CMString res;
- res.AppendChar('\n');
- res += TranslateT("Attachments:");
- res.AppendChar('\n');
- JSONNODE *pAttach;
- for (int k = 0; (pAttach = json_at(pAttachments, k)) != NULL; k++) {
- res.AppendChar('\t');
- ptrT ptszType(json_as_string(json_get(pAttach, "type")));
- if (!mir_tstrcmp(ptszType, _T("photo"))) {
- JSONNODE *pPhoto = json_get(pAttach, "photo");
- if (pPhoto == NULL)
- continue;
-
- ptrT ptszLink;
- for (int i = 0; i < SIZEOF(szImageTypes); i++) {
- JSONNODE *n = json_get(pPhoto, szImageTypes[i]);
- if (n != NULL) {
- ptszLink = json_as_string(n);
- break;
- }
- }
-
- int iWidth = json_as_int(json_get(pPhoto, "width"));
- int iHeight = json_as_int(json_get(pPhoto, "height"));
- res.AppendFormat(_T("%s: %s (%dx%d)"), TranslateT("Photo"), ptszLink ? ptszLink : _T(""), iWidth, iHeight);
- if (m_bAddImgBbc)
- res.AppendFormat(_T("\n\t[img]%s[/img]"), ptszLink);
- }
- else if (!mir_tstrcmp(ptszType, _T("audio"))) {
- JSONNODE *pAudio = json_get(pAttach, "audio");
- if (pAudio == NULL)
- continue;
-
- ptrT ptszArtist(json_as_string(json_get(pAudio, "artist")));
- ptrT ptszTitle(json_as_string(json_get(pAudio, "title")));
- ptrT ptszUrl(json_as_string(json_get(pAudio, "url")));
- res.AppendFormat(_T("%s: (%s - %s) - %s"),
- TranslateT("Audio"), ptszArtist, ptszTitle, ptszUrl);
- }
- else if (!mir_tstrcmp(ptszType, _T("video"))) {
- JSONNODE *pVideo = json_get(pAttach, "video");
- if (pVideo == NULL)
- continue;
-
- ptrT ptszTitle(json_as_string(json_get(pVideo, "title")));
- int vid = json_as_int(json_get(pVideo, "id"));
- int ownerID = json_as_int(json_get(pVideo, "owner_id"));
- res.AppendFormat(_T("%s: %s - http://vk.com/video%d_%d"), TranslateT("Video"), ptszTitle, ownerID, vid);
- }
- else if (!mir_tstrcmp(ptszType, _T("doc"))) {
- JSONNODE *pDoc = json_get(pAttach, "doc");
- if (pDoc == NULL)
- continue;
- ptrT ptszTitle(json_as_string(json_get(pDoc, "title")));
- ptrT ptszUrl(json_as_string(json_get(pDoc, "url")));
- res.AppendFormat(_T("%s: (%s) - %s"), TranslateT("Document"), ptszTitle, ptszUrl);
- }
- else if (!mir_tstrcmp(ptszType, _T("wall"))) {
- JSONNODE *pWall = json_get(pAttach, "wall");
- if (pWall == NULL)
- continue;
-
- ptrT ptszText(json_as_string(json_get(pWall, "text")));
- int id = json_as_int(json_get(pWall, "id"));
- int fromID = json_as_int(json_get(pWall, "from_id"));
- res.AppendFormat(_T("%s: %s - http://vk.com/wall%d_%d"), TranslateT("Wall post"), ptszText ? ptszText : _T(" "), fromID, id);
- }
- else if (!mir_tstrcmp(ptszType, _T("sticker"))) {
- JSONNODE *pSticker = json_get(pAttach, "sticker");
- if (pSticker == NULL)
- continue;
- res.Empty(); // sticker is not really an attachment, so we don't want all that heading info
-
- if (m_bStikersAsSmyles) {
- int id = json_as_int(json_get(pSticker, "id"));
- res.AppendFormat(_T("[sticker:%d]"), id);
- }
- else {
- ptrT ptszLink;
- for (int i = 0; i < SIZEOF(szImageTypes); i++) {
- JSONNODE *n = json_get(pSticker, szImageTypes[i]);
- if (n != NULL) {
- ptszLink = json_as_string(n);
- break;
- }
- }
- res.AppendFormat(_T("%s"), ptszLink);
-
- if (m_bAddImgBbc)
- res.AppendFormat(_T("[img]%s[/img]"), ptszLink);
- }
- }
- else if (!mir_tstrcmp(ptszType, _T("link"))){
- JSONNODE *pLink = json_get(pAttach, "link");
- if (pLink == NULL)
- continue;
-
- 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")));
-
- res.AppendFormat(_T("%s: %s (%s)"), TranslateT("Link"), ptszTitle ? ptszTitle : _T(""), ptszUrl ? ptszUrl : _T(""));
- if (!tszImage.IsEmpty())
- if (m_bAddImgBbc)
- res.AppendFormat(_T("\n\t%s: [img]%s[/img]"), TranslateT("Image"), tszImage.GetBuffer());
- else
- res.AppendFormat(_T("\n\t%s: %s"), TranslateT("Image"), tszImage.GetBuffer());
-
- if (ptszDescription)
- res.AppendFormat(_T("\n\t%s"), ptszDescription);
- }
- else res.AppendFormat(TranslateT("Unsupported or unknown attachment type: %s"), ptszType);
-
- res.AppendChar('\n');
- }
-
- return res;
-}
|