diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-14 05:59:56 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-14 05:59:56 +0000 |
commit | 708f9efe9c79a3b2fbdd953e02b6448ce5ad9b97 (patch) | |
tree | 3dc1ffcc6ea8abc73d480de36b63b69cdcc94c58 /protocols/VKontakte/src | |
parent | e9a8795aed41e22c74d7bbcd0f9705ecdb885461 (diff) |
VKontakte:
add ‘Advanced’ option page
move some options to ‘Advanced’ page
rework sticker support part 1 (patch by alitor, edited)
git-svn-id: http://svn.miranda-ng.org/main/trunk@10777 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/resource.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_options.cpp | 136 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 31 |
5 files changed, 129 insertions, 43 deletions
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index 27e79c4b4c..83b0ee499d 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -7,6 +7,7 @@ #define IDD_OPT_MAIN 103
#define IDD_INVITE 104
#define IDD_GC_CREATE 105
+#define IDD_OPT_ADV 106
#define IDI_NOTIFICATION 109
#define IDI_FRIENDADD 110
#define IDI_BAN 111
@@ -43,6 +44,7 @@ #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
#define IDC_ONRECEIVE 1040
#define IDC_ONREPLY 1041
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index f415020918..084ca326ff 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -118,18 +118,12 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L SetDlgItemText(hwndDlg, IDC_GROUPNAME, ppro->getGroup());
}
+
CheckDlgButton(hwndDlg, IDC_DELIVERY, ppro->m_bServerDelivery);
- CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats);
- CheckDlgButton(hwndDlg, IDC_AUTOCLEAN, ppro->getByte("AutoClean", 0));
- 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_SYNCHISTOTYONONLINE, ppro->m_bAutoSyncHistory);
+ CheckDlgButton(hwndDlg, IDC_AUTOCLEAN, ppro->getByte("AutoClean", 0));
+
CheckDlgButton(hwndDlg, IDC_ONREAD, (ppro->m_iMarkMessageReadOn == markOnRead));
CheckDlgButton(hwndDlg, IDC_ONRECEIVE, (ppro->m_iMarkMessageReadOn == markOnReceive));
CheckDlgButton(hwndDlg, IDC_ONREPLY, (ppro->m_iMarkMessageReadOn == markOnReply));
@@ -149,18 +143,10 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
- case IDC_DELIVERY:
- case IDC_HIDECHATS:
- case IDC_AUTOCLEAN:
- case IDC_MESASUREAD:
- case IDC_SYNCHISTOTYONONLINE:
+ case IDC_DELIVERY:
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:
- case IDC_REMOVE_FROM_CLIST:
+ case IDC_SYNCHISTOTYONONLINE:
+ case IDC_AUTOCLEAN:
case IDC_ONREAD:
case IDC_ONRECEIVE:
case IDC_ONREPLY:
@@ -190,14 +176,8 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L ppro->m_bServerDelivery = IsDlgButtonChecked(hwndDlg, IDC_DELIVERY) == BST_CHECKED;
ppro->setByte("ServerDelivery", ppro->m_bServerDelivery);
-
- ppro->m_bHideChats = IsDlgButtonChecked(hwndDlg, IDC_HIDECHATS) == BST_CHECKED;
- ppro->setByte("HideChats", ppro->m_bHideChats);
-
+
ppro->setByte("AutoClean", IsDlgButtonChecked(hwndDlg, IDC_AUTOCLEAN) == BST_CHECKED);
-
- ppro->m_bMesAsUnread = IsDlgButtonChecked(hwndDlg, IDC_MESASUREAD) == BST_CHECKED;
- ppro->setByte("MesAsUnread", ppro->m_bMesAsUnread);
ppro->m_bAutoSyncHistory = IsDlgButtonChecked(hwndDlg, IDC_SYNCHISTOTYONONLINE) == BST_CHECKED;
ppro->setByte("AutoSyncHistory", ppro->m_bAutoSyncHistory);
@@ -205,9 +185,89 @@ 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);
+ if (IsDlgButtonChecked(hwndDlg, IDC_ONREAD) == BST_CHECKED)
+ ppro->m_iMarkMessageReadOn = markOnRead;
+ if (IsDlgButtonChecked(hwndDlg, IDC_ONRECEIVE) == BST_CHECKED)
+ ppro->m_iMarkMessageReadOn = markOnReceive;
+ if (IsDlgButtonChecked(hwndDlg, IDC_ONREPLY) == BST_CHECKED)
+ ppro->m_iMarkMessageReadOn = markOnReply;
+ if (IsDlgButtonChecked(hwndDlg, IDC_ONTYPING) == BST_CHECKED)
+ ppro->m_iMarkMessageReadOn = markOnTyping;
+ ppro->setByte("MarkMessageReadOn", ppro->m_iMarkMessageReadOn);
+ }
+ 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_PTR CALLBACK CVkProto::OptionsAdvProc(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, true));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon));
+
+ CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats);
+ CheckDlgButton(hwndDlg, IDC_MESASUREAD, ppro->m_bMesAsUnread);
+ CheckDlgButton(hwndDlg, IDC_ADD_IMG_BBC, ppro->m_bAddImgBbc);
+ CheckDlgButton(hwndDlg, IDC_STICKERS_AS_SMYLES, ppro->m_bStikersAsSmyles);
+ 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);
+
+ return TRUE;
+
+ case WM_COMMAND:
+ 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:
+ case IDC_REMOVE_FROM_CLIST:
+ 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) {
+ ppro->m_bHideChats = IsDlgButtonChecked(hwndDlg, IDC_HIDECHATS) == BST_CHECKED;
+ ppro->setByte("HideChats", ppro->m_bHideChats);
+
+ 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);
@@ -221,17 +281,8 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L ppro->setByte("RemoveFromFrendlistOnBanUser", ppro->m_bRemoveFromFrendlist);
ppro->m_bRemoveFromClist = IsDlgButtonChecked(hwndDlg, IDC_REMOVE_FROM_CLIST) == BST_CHECKED;
- ppro->setByte("RemoveFromClistOnBanUser", ppro->m_bRemoveFromClist);
+ ppro->setByte("RemoveFromClistOnBanUser", ppro->m_bRemoveFromClist);
- if (IsDlgButtonChecked(hwndDlg, IDC_ONREAD) == BST_CHECKED)
- ppro->m_iMarkMessageReadOn = markOnRead;
- if (IsDlgButtonChecked(hwndDlg, IDC_ONRECEIVE) == BST_CHECKED)
- ppro->m_iMarkMessageReadOn = markOnReceive;
- if (IsDlgButtonChecked(hwndDlg, IDC_ONREPLY) == BST_CHECKED)
- ppro->m_iMarkMessageReadOn = markOnReply;
- if (IsDlgButtonChecked(hwndDlg, IDC_ONTYPING) == BST_CHECKED)
- ppro->m_iMarkMessageReadOn = markOnTyping;
- ppro->setByte("MarkMessageReadOn", ppro->m_iMarkMessageReadOn);
}
break;
@@ -255,11 +306,18 @@ int CVkProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) odp.ptszTitle = m_tszUserName;
odp.dwInitParam = LPARAM(this);
odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
- odp.position = 1;
odp.ptszGroup = LPGENT("Network");
+
odp.ptszTab = LPGENT("Account");
+ odp.position = 1;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN);
odp.pfnDlgProc = &CVkProto::OptionsProc;
Options_AddPage(wParam, &odp);
+
+ odp.ptszTab = LPGENT("Advanced");
+ odp.position = 2;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_ADV);
+ odp.pfnDlgProc = &CVkProto::OptionsAdvProc;
+ Options_AddPage(wParam, &odp);
return 0;
}
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 1f5fe02cbf..47edff6722 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -74,6 +74,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) : 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);
// Set all contacts offline -- in case we crashed
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 5381a7b37d..df52642791 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -408,6 +408,7 @@ private: m_bRemoveFromClist,
m_bPopUpSyncHistory,
m_bAddImgBbc,
+ m_bStikersAsSmyles,
m_bUserForceOnlineOnActivity;
enum MarkMsgReadOn{ markOnRead, markOnReceive, markOnReply, markOnTyping };
@@ -434,6 +435,7 @@ private: 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);
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 5d36024b34..7fea5b8ab6 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -1213,8 +1213,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")) || !lstrcmp(ptszType, _T("sticker"))) {
- JSONNODE *pPhoto = json_get(pAttach, mir_t2a(ptszType));
+ if (!lstrcmp(ptszType, _T("photo"))) {
+ JSONNODE *pPhoto = json_get(pAttach, "photo");
if (pPhoto == NULL) continue;
ptrT ptszLink;
@@ -1228,8 +1228,7 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments) int iWidth = json_as_int(json_get(pPhoto, "width"));
int iHeight = json_as_int(json_get(pPhoto, "height"));
- ptrT ptszTypeTranslate((lstrcmp(ptszType, _T("photo")) == 0) ? TranslateT("Photo") : TranslateT("Sticker"));
- res.AppendFormat(_T("%s: %s (%dx%d)"), ptszTypeTranslate, ptszLink, iWidth, iHeight);
+ res.AppendFormat(_T("%s: %s (%dx%d)"), TranslateT("Photo"), ptszLink, iWidth, iHeight);
if (m_bAddImgBbc)
res.AppendFormat(L"\n\t[img]%s[/img]", ptszLink);
}
@@ -1272,6 +1271,30 @@ CMString CVkProto::GetAttachmentDescr(JSONNODE *pAttachments) 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 : L" ", fromID, id);
}
+ else if (!lstrcmp(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(L"[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(L"%s", ptszLink);
+
+ if (m_bAddImgBbc)
+ res.AppendFormat(L"[img]%s[/img]", ptszLink);
+ }
+ }
else res.AppendFormat(TranslateT("Unsupported or unknown attachment type: %s"), ptszType);
res.AppendChar('\n');
|