summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-10-10 09:38:24 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-10-10 09:38:24 +0000
commit0bcce6b2b5fb7cd0962ce096e02f7881abba89ef (patch)
treee61968f83274f5cf0a6743298254b085a9609f0b /protocols/VKontakte/src
parent9c407ec4efd8d884d3258d93e885a292b7fad560 (diff)
VKontakte:
Add sticker support ‘Add [img] for graphical attachments’ options 'Force online status upon user activity’ options git-svn-id: http://svn.miranda-ng.org/main/trunk@10754 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/resource.h4
-rw-r--r--protocols/VKontakte/src/vk_options.cpp11
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.h4
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp40
5 files changed, 47 insertions, 14 deletions
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index ac52b3e97f..27e79c4b4c 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -41,11 +41,11 @@
#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_ONREAD 1039
#define IDC_ONRECEIVE 1040
-#define IDC_REPLY 1041
#define IDC_ONREPLY 1041
-#define IDC_TYPING 1042
#define IDC_ONTYPING 1042
#define IDC_STATIC_MARK_AS_READ 1043
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index b4d1dbfd45..f415020918 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -124,11 +124,12 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
CheckDlgButton(hwndDlg, IDC_MESASUREAD, ppro->m_bMesAsUnread);
CheckDlgButton(hwndDlg, IDC_SYNCHISTOTYONONLINE, ppro->m_bAutoSyncHistory);
CheckDlgButton(hwndDlg, IDC_USE_LOCAL_TIME, ppro->m_bUseLocalTime);
+ CheckDlgButton(hwndDlg, IDC_ADD_IMG_BBC, ppro->m_bAddImgBbc);
+ CheckDlgButton(hwndDlg, IDC_FORCE_ONLINE_ON_ACT, ppro->m_bUserForceOnlineOnActivity);
CheckDlgButton(hwndDlg, IDC_REPORT_ABUSE, ppro->m_bReportAbuse);
CheckDlgButton(hwndDlg, IDC_CLEAR_SERVER_HISTORY, ppro->m_bClearServerHistory);
CheckDlgButton(hwndDlg, IDC_REMOVE_FROM_FRENDLIST, ppro->m_bRemoveFromFrendlist);
CheckDlgButton(hwndDlg, IDC_REMOVE_FROM_CLIST, ppro->m_bRemoveFromClist);
-
CheckDlgButton(hwndDlg, IDC_ONREAD, (ppro->m_iMarkMessageReadOn == markOnRead));
CheckDlgButton(hwndDlg, IDC_ONRECEIVE, (ppro->m_iMarkMessageReadOn == markOnReceive));
CheckDlgButton(hwndDlg, IDC_ONREPLY, (ppro->m_iMarkMessageReadOn == markOnReply));
@@ -154,6 +155,8 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case IDC_MESASUREAD:
case IDC_SYNCHISTOTYONONLINE:
case IDC_USE_LOCAL_TIME:
+ case IDC_ADD_IMG_BBC:
+ case IDC_FORCE_ONLINE_ON_ACT:
case IDC_REPORT_ABUSE:
case IDC_CLEAR_SERVER_HISTORY:
case IDC_REMOVE_FROM_FRENDLIST:
@@ -202,6 +205,12 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
ppro->m_bUseLocalTime = IsDlgButtonChecked(hwndDlg, IDC_USE_LOCAL_TIME) == BST_CHECKED;
ppro->setByte("UseLocalTime", ppro->m_bUseLocalTime);
+ ppro->m_bAddImgBbc = IsDlgButtonChecked(hwndDlg, IDC_ADD_IMG_BBC) == BST_CHECKED;
+ ppro->setByte("AddImgBbc", ppro->m_bAddImgBbc);
+
+ ppro->m_bUserForceOnlineOnActivity = IsDlgButtonChecked(hwndDlg, IDC_FORCE_ONLINE_ON_ACT) == BST_CHECKED;
+ ppro->setByte("UserForceOnlineOnActivity", ppro->m_bUserForceOnlineOnActivity);
+
ppro->m_bReportAbuse = IsDlgButtonChecked(hwndDlg, IDC_REPORT_ABUSE) == BST_CHECKED;
ppro->setByte("ReportAbuseOnBanUser", ppro->m_bReportAbuse);
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 1dfcddc7cc..910c79b0f4 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -73,6 +73,8 @@ 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_bUserForceOnlineOnActivity = getBool("UserForceOnlineOnActivity", false);
// 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 1c5453b463..2aabbe2abe 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -406,7 +406,9 @@ private:
m_bClearServerHistory,
m_bRemoveFromFrendlist,
m_bRemoveFromClist,
- m_bPopUpSyncHistory;
+ m_bPopUpSyncHistory,
+ m_bAddImgBbc,
+ m_bUserForceOnlineOnActivity;
enum MarkMsgReadOn{ markOnRead, markOnReceive, markOnReply, markOnTyping };
int m_iMarkMessageReadOn;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 232703f7ad..d68c299bf4 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -527,7 +527,7 @@ void CVkProto::RetrieveUnreadMessages()
<< VER_API);
}
-static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_130", "photo_75" };
+static char* szImageTypes[] = { "photo_2560", "photo_1280", "photo_807", "photo_604", "photo_256", "photo_130", "photo_128", "photo_75", "photo_64" };
void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
@@ -581,6 +581,8 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
recv.flags |= PREF_CREATEREAD;
if (isOut)
recv.flags |= PREF_SENT;
+ else if (m_bUserForceOnlineOnActivity)
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
recv.timestamp = m_bUseLocalTime?time(NULL):datetime;
recv.tszMessage = ptszBody;
@@ -1060,11 +1062,17 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
case VKPOLL_MSG_DELFLAGS:
flags = json_as_int(json_at(pChild, 2));
uid = json_as_int(json_at(pChild, 3));
- if (((hContact = FindUser(uid)) != NULL) && (flags&VKFLAG_MSGUNREAD)){
- setDword(hContact, "LastMsgReadTime", time(NULL));
- SetSrmmReadStatus(hContact);
+ hContact = FindUser(uid);
+ if (hContact != NULL) {
+ if (flags&VKFLAG_MSGUNREAD){
+ setDword(hContact, "LastMsgReadTime", time(NULL));
+ SetSrmmReadStatus(hContact);
+ }
+ if (m_bUserForceOnlineOnActivity)
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
}
break;
+
case VKPOLL_MSG_ADDED: // new message
msgid = json_as_int(json_at(pChild, 1));
@@ -1078,13 +1086,18 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
mids.AppendChar(',');
mids.AppendFormat("%d", msgid);
break;
+
case VKPOLL_READ_ALL_OUT:
uid = json_as_int(json_at(pChild, 1));
- if ((hContact = FindUser(uid)) != NULL){
+ hContact = FindUser(uid);
+ if (hContact != NULL){
setDword(hContact, "LastMsgReadTime", time(NULL));
SetSrmmReadStatus(hContact);
+ if (m_bUserForceOnlineOnActivity)
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
}
break;
+
case VKPOLL_USR_ONLINE:
uid = -json_as_int(json_at(pChild, 1));
if ((hContact = FindUser(uid)) != NULL)
@@ -1101,8 +1114,12 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
case VKPOLL_USR_UTN:
uid = json_as_int(json_at(pChild, 1));
- if ((hContact = FindUser(uid)) != NULL)
- ForkThread(&CVkProto::ContactTypingThread, (void *)hContact);
+ hContact = FindUser(uid);
+ if (hContact != NULL){
+ ForkThread(&CVkProto::ContactTypingThread, (void *)hContact);
+ if (m_bUserForceOnlineOnActivity)
+ setWord(hContact, "Status", ID_STATUS_ONLINE);
+ }
break;
case VKPOLL_CHAT_CHANGED:
@@ -1183,8 +1200,8 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)
for (int k = 0; (pAttach = json_at(pAttachments, k)) != NULL; k++) {
res.AppendChar('\t');
ptrT ptszType(json_as_string(json_get(pAttach, "type")));
- if (!lstrcmp(ptszType, _T("photo"))) {
- JSONNODE *pPhoto = json_get(pAttach, "photo");
+ if (!lstrcmp(ptszType, _T("photo")) || !lstrcmp(ptszType, _T("sticker"))) {
+ JSONNODE *pPhoto = json_get(pAttach, mir_t2a(ptszType));
if (pPhoto == NULL) continue;
ptrT ptszLink;
@@ -1198,7 +1215,10 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments)
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, iWidth, iHeight);
+ ptrT ptszTypeTranslate((lstrcmp(ptszType, _T("photo")) == 0) ? TranslateT("Photo") : TranslateT("Sticker"));
+ res.AppendFormat(_T("%s: %s (%dx%d)"), ptszTypeTranslate, ptszLink, iWidth, iHeight);
+ if (m_bAddImgBbc)
+ res.AppendFormat(L"\n\t[img]%s[/img]", ptszLink);
}
else if (!lstrcmp(ptszType, _T("audio"))) {
JSONNODE *pAudio = json_get(pAttach, "audio");