summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-09-29 09:09:40 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-09-29 09:09:40 +0000
commit9f8f51ae8bc32ba91d98a2fbd6a652a55241a7d7 (patch)
treedb4f3e5029dfd049e1e832069b701ec7c115f35b
parente77a3c5664bf839e5e94d27a9fbc8c8a6e2da51d (diff)
VKontakte:
replace icons for add/remove frendlist menuitems fix ‘Add as frend’ menuitem for chats add ‘Report abuse’ and ‘Ban user’ support version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@10621 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/VKontakte/res/resource.rc43
-rw-r--r--protocols/VKontakte/src/resource.h4
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_options.cpp20
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp27
-rw-r--r--protocols/VKontakte/src/vk_proto.h12
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp86
7 files changed, 170 insertions, 24 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index 6f0b51a15e..ec8fcd2ee7 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -40,28 +40,34 @@ 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,7,293,65
- LTEXT "E-mail or phone number:",IDC_STATIC,51,23,95,12
- EDITTEXT IDC_LOGIN,147,23,89,12,ES_AUTOHSCROLL
- LTEXT "Password:",IDC_STATIC,51,39,94,12
- EDITTEXT IDC_PASSWORD,147,39,90,12,ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,59,55,174,12
- GROUPBOX "Local settings",IDC_STATIC,4,73,293,33
- LTEXT "Contact list group:",IDC_STATIC,12,88,146,8
- EDITTEXT IDC_GROUPNAME,167,86,121,12,ES_AUTOHSCROLL
- GROUPBOX "Advanced",IDC_STATIC,4,108,293,124
- CONTROL "Server-side delivery confirmation",IDC_DELIVERY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,120,278,10
- CONTROL "Hide chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,133,278,10
+ GROUPBOX "Login settings",IDC_STATIC,4,7,293,55
+ LTEXT "E-mail or phone number:",IDC_STATIC,51,17,95,12
+ EDITTEXT IDC_LOGIN,147,17,89,12,ES_AUTOHSCROLL
+ LTEXT "Password:",IDC_STATIC,51,31,94,12
+ EDITTEXT IDC_PASSWORD,147,31,90,12,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,59,45,174,12
+ GROUPBOX "Local settings",IDC_STATIC,4,62,293,27
+ LTEXT "Contact list group:",IDC_STATIC,12,74,146,8
+ EDITTEXT IDC_GROUPNAME,167,72,121,12,ES_AUTOHSCROLL
+ GROUPBOX "Advanced",IDC_STATIC,4,90,293,103
+ CONTROL "Server-side delivery confirmation",IDC_DELIVERY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,278,10
+ CONTROL "Hide chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,112,278,10
CONTROL "Automatically wipe local contacts missing in your friend list",IDC_AUTOCLEAN,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,146,278,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,123,278,10
CONTROL "Always notify as unread for all incoming message",IDC_MESASUREAD,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,159,278,10
- CONTROL "Mark read on reply",IDC_MARKREADONREPLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,171,278,10
- CONTROL "Mark read on typing",IDC_MARKREADONTYPING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,184,267,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,134,278,10
+ CONTROL "Mark read on reply",IDC_MARKREADONREPLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,145,278,10
+ CONTROL "Mark read on typing",IDC_MARKREADONTYPING,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,156,267,10
CONTROL "Automatically sync last messages",IDC_SYNCHISTOTYONONLINE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,197,278,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,167,278,10
CONTROL "Use local time for received messages",IDC_USE_LOCAL_TIME,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,209,278,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,178,278,10
+ GROUPBOX "When I ban user...",IDC_STATIC,4,195,293,37
+ CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,206,129,10
+ CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,217,129,10
+ CONTROL "Remove from friend list",IDC_REMOVE_FROM_FRENDLIST,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,155,206,129,10
+ CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,155,217,129,10
END
IDD_CAPTCHAFORM DIALOGEX 0, 0, 258, 224
@@ -133,7 +139,6 @@ BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 297
TOPMARGIN, 7
- BOTTOMMARGIN, 239
END
IDD_INVITE, DIALOG
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index 7c3f798213..33e7184d77 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -29,6 +29,10 @@
#define IDC_SYNCHISTOTYONONLINE 1027
#define IDC_MARKREADONTYPING 1028
#define IDC_USE_LOCAL_TIME 1029
+#define IDC_REPORT_ABUSE 1030
+#define IDC_CLEAR_SERVER_HISTORY 1031
+#define IDC_REMOVE_FROM_FRENDLIST 1032
+#define IDC_REMOVE_FROM_CLIST 1033
// Next default values for new objects
//
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 7603c033e3..1636c02b9e 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 16
+#define __BUILD_NUM 17
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index 147b65e676..6df6285e7f 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -127,6 +127,10 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
CheckDlgButton(hwndDlg, IDC_MARKREADONTYPING, ppro->m_bMarkReadOnTyping);
CheckDlgButton(hwndDlg, IDC_SYNCHISTOTYONONLINE, ppro->m_bAutoSyncHistory);
CheckDlgButton(hwndDlg, IDC_USE_LOCAL_TIME, ppro->m_bUseLocalTime);
+ 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:
@@ -149,6 +153,10 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case IDC_MARKREADONTYPING:
case IDC_SYNCHISTOTYONONLINE:
case IDC_USE_LOCAL_TIME:
+ 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;
@@ -200,6 +208,18 @@ 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_bReportAbuse = IsDlgButtonChecked(hwndDlg, IDC_REPORT_ABUSE) == BST_CHECKED;
+ ppro->setByte("ReportAbuseOnBanUser", ppro->m_bReportAbuse);
+
+ ppro->m_bClearServerHistory = IsDlgButtonChecked(hwndDlg, IDC_CLEAR_SERVER_HISTORY) == BST_CHECKED;
+ ppro->setByte("ClearServerHistoryOnBanUser", ppro->m_bClearServerHistory);
+
+ ppro->m_bRemoveFromFrendlist = IsDlgButtonChecked(hwndDlg, IDC_REMOVE_FROM_FRENDLIST) == BST_CHECKED;
+ ppro->setByte("RemoveFromFrendlistOnBanUser", ppro->m_bRemoveFromFrendlist);
+
+ ppro->m_bRemoveFromClist = IsDlgButtonChecked(hwndDlg, IDC_REMOVE_FROM_CLIST) == BST_CHECKED;
+ ppro->setByte("RemoveFromClistOnBanUser", ppro->m_bRemoveFromClist);
}
break;
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 6741d315c6..c867bf0c65 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -69,6 +69,10 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
m_bMarkReadOnTyping = getBool("MarkReadOnTyping", false) && m_bMarkReadOnReply;
m_bAutoSyncHistory = getBool("AutoSyncHistory", true);
m_bUseLocalTime = getBool("LocalTime", false);
+ m_bReportAbuse = getBool("ReportAbuseOnBanUser", false);
+ m_bClearServerHistory = getBool("ClearServerHistoryOnBanUser", false);
+ m_bRemoveFromFrendlist = getBool("RemoveFromFrendlistOnBanUser", false);
+ m_bRemoveFromClist = getBool("RemoveFromClistOnBanUser", false);
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
@@ -118,6 +122,8 @@ void CVkProto::InitMenus()
CreateProtoService(PS_CREATECHAT, &CVkProto::SvcCreateChat);
CreateProtoService(PS_ADDASFRIEND, &CVkProto::SvcAddAsFriend);
CreateProtoService(PS_DELETEFRIEND, &CVkProto::SvcDeleteFriend);
+ CreateProtoService(PS_BANUSER, &CVkProto::SvcBanUser);
+ CreateProtoService(PS_REPORTABUSE, &CVkProto::SvcReportAbuse);
CLISTMENUITEM mi = { sizeof(mi) };
char szService[100];
@@ -157,18 +163,31 @@ void CVkProto::InitMenus()
mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_ADDASFRIEND);
mi.position = -200001000 + CMI_ADDASFRIEND;
- mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_ADDCONTACT);
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_ADD);
mi.ptszName = LPGENT("Add as friend");
mi.pszService = szService;
g_hContactMenuItems[CMI_ADDASFRIEND] = Menu_AddContactMenuItem(&mi);
mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_DELETEFRIEND);
mi.position = -200001000 + CMI_DELETEFRIEND;
- mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE);
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REVOKE);
mi.ptszName = LPGENT("Delete from friend list");
mi.pszService = szService;
g_hContactMenuItems[CMI_DELETEFRIEND] = Menu_AddContactMenuItem(&mi);
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_BANUSER);
+ mi.position = -200001000 + CMI_BANUSER;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_DELETE);
+ mi.ptszName = LPGENT("Ban user");
+ mi.pszService = szService;
+ g_hContactMenuItems[CMI_BANUSER] = Menu_AddContactMenuItem(&mi);
+
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, PS_REPORTABUSE);
+ mi.position = -200001000 + CMI_REPORTABUSE;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_MIRANDA);
+ mi.ptszName = LPGENT("Report abuse");
+ mi.pszService = szService;
+ g_hContactMenuItems[CMI_REPORTABUSE] = Menu_AddContactMenuItem(&mi);
}
int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
@@ -177,8 +196,10 @@ int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
Menu_ShowItem(g_hContactMenuItems[CMI_GETALLSERVERHISTORY], !isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_VISITPROFILE], !isChatRoom(hContact));
- Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend);
+ Menu_ShowItem(g_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend&&!isChatRoom(hContact));
Menu_ShowItem(g_hContactMenuItems[CMI_DELETEFRIEND], bisFriend);
+ Menu_ShowItem(g_hContactMenuItems[CMI_BANUSER], !isChatRoom(hContact));
+ Menu_ShowItem(g_hContactMenuItems[CMI_REPORTABUSE], !isChatRoom(hContact));
return 0;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 8dc68f26d2..9347e5e909 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PS_VISITPROFILE "/VisitProfile"
#define PS_ADDASFRIEND "/AddAsFriend"
#define PS_DELETEFRIEND "/DeleteFriend"
+#define PS_BANUSER "/BanUser"
+#define PS_REPORTABUSE "/ReportAbuse"
#define MAXHISTORYMIDSPERONE 200
struct CVkProto;
@@ -202,6 +204,8 @@ struct CVkProto : public PROTO<CVkProto>
INT_PTR __cdecl SvcVisitProfile(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcAddAsFriend(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcDeleteFriend(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcBanUser(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcReportAbuse(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcGetAllServerHistory(WPARAM hContact, LPARAM);
void InitMenus();
void UnInitMenus();
@@ -275,6 +279,8 @@ private:
CMI_VISITPROFILE,
CMI_ADDASFRIEND,
CMI_DELETEFRIEND,
+ CMI_BANUSER,
+ CMI_REPORTABUSE,
CMI_COUNT
};
enum ProtoMenuIndexes {
@@ -335,7 +341,11 @@ private:
m_bMarkReadOnReply,
m_bMarkReadOnTyping,
m_bAutoSyncHistory,
- m_bUseLocalTime;
+ m_bUseLocalTime,
+ m_bReportAbuse,
+ m_bClearServerHistory,
+ m_bRemoveFromFrendlist,
+ m_bRemoveFromClist;
LONG m_myUserId;
ptrA m_szAccessToken;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 1189768c0f..f23d7ae880 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -948,6 +948,92 @@ void CVkProto::OnReceiveDeleteFriend(NETLIBHTTPREQUEST* reply, AsyncHttpRequest*
delete param;
}
+INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcBanUser");
+ LONG userID = getDword(hContact, "ID", -1);
+ if (!IsOnline() || (userID == -1))
+ return 1;
+
+ CMStringA code;
+ code.AppendFormat("var userID=\"%d\";API.account.banUser({\"user_id\":userID});", userID);
+ CMString tszVarWarning;
+
+ if (m_bReportAbuse){
+ debugLogA("CVkProto::SvcBanUser m_bReportAbuse = true");
+ code += "API.users.report({\"user_id\":userID,type:\"spam\"});";
+ tszVarWarning = TranslateT(" report abuse on him/her");
+ }
+ if (m_bClearServerHistory){
+ debugLogA("CVkProto::SvcBanUser m_bClearServerHistory = true");
+ code += "API.messages.deleteDialog({\"user_id\":userID,count:10000});";
+ if (!tszVarWarning.IsEmpty())
+ tszVarWarning.AppendChar(L',');
+ tszVarWarning += TranslateT(" clear server history with him/her");
+ }
+ if (m_bRemoveFromFrendlist){
+ debugLogA("CVkProto::SvcBanUser m_bRemoveFromFrendlist = true");
+ code += "API.friends.delete({\"user_id\":userID});";
+ if (!tszVarWarning.IsEmpty())
+ tszVarWarning.AppendChar(L',');
+ tszVarWarning += TranslateT(" remove his/her from you frendlist");
+ }
+ if (m_bRemoveFromClist){
+ debugLogA("CVkProto::SvcBanUser m_bRemoveFromClist = true");
+ if (!tszVarWarning.IsEmpty())
+ tszVarWarning.AppendChar(L',');
+ tszVarWarning += TranslateT(" remove his/her from you contact list");
+ }
+
+ if (!tszVarWarning.IsEmpty())
+ tszVarWarning += ".\n";
+ code += "return 1;";
+
+ CMString formatstr = TranslateT("Are you sure to ban %s? %s%sContinue?"),
+ tszNick = db_get_tsa(hContact, m_szModuleName, "Nick"),
+ ptszMsg;
+
+ ptszMsg.AppendFormat(formatstr,
+ tszNick.IsEmpty() ? TranslateT("(Unknown contact)") : tszNick.GetBuffer(),
+ tszVarWarning.IsEmpty() ? L" " : TranslateT("\nIt will also"),
+ tszVarWarning.IsEmpty() ? L"\n" : tszVarWarning.GetBuffer());
+
+ if (IDNO == MessageBox(NULL, ptszMsg.GetBuffer(), TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ return 1;
+
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
+ << CHAR_PARAM("code", code)
+ << VER_API);
+
+ if (m_bRemoveFromClist)
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+
+ return 0;
+}
+
+INT_PTR __cdecl CVkProto::SvcReportAbuse(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcReportAbuse");
+ LONG userID = getDword(hContact, "ID", -1);
+ if (!IsOnline() || (userID == -1))
+ return 1;
+
+ CMString formatstr = TranslateT("Are you sure to report abuse on %s?"),
+ tszNick = db_get_tsa(hContact, m_szModuleName, "Nick"),
+ ptszMsg;
+ ptszMsg.AppendFormat(formatstr, tszNick.IsEmpty() ? TranslateT("(Unknown contact)") : tszNick);
+ if (IDNO == MessageBox(NULL, ptszMsg.GetBuffer(), TranslateT("Attention!"), MB_ICONWARNING | MB_YESNO))
+ return 1;
+
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.report.json", true, &CVkProto::OnReceiveSmth)
+ << INT_PARAM("user_id", userID)
+ << CHAR_PARAM("type", "spam")
+ << VER_API);
+
+ return 0;
+}
+
+
INT_PTR __cdecl CVkProto::SvcVisitProfile(WPARAM hContact, LPARAM)
{
LONG userID = getDword(hContact, "ID", -1);