summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/res/resource.rc26
-rw-r--r--protocols/VKontakte/src/misc.cpp5
-rw-r--r--protocols/VKontakte/src/resource.h9
-rw-r--r--protocols/VKontakte/src/version.h4
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp4
-rw-r--r--protocols/VKontakte/src/vk_dialogs.cpp43
-rw-r--r--protocols/VKontakte/src/vk_dialogs.h34
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp38
-rw-r--r--protocols/VKontakte/src/vk_proto.h2
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp6
11 files changed, 163 insertions, 10 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index dbaaa47e0d..3cd6af5e73 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -114,6 +114,10 @@ BEGIN
BOTTOMMARGIN, 182
END
+ IDD_CAPTCHAFORM, DIALOG
+ BEGIN
+ END
+
IDD_INVITE, DIALOG
BEGIN
LEFTMARGIN, 7
@@ -137,6 +141,15 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 127
END
+
+ IDD_CONTACTDELETE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 276
+ VERTGUIDE, 29
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 80
+ END
END
#endif // APSTUDIO_INVOKED
@@ -371,6 +384,19 @@ BEGIN
CONTROL "Only for friends",IDC_ONLY_FRIENDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,61,98,248,10
END
+IDD_CONTACTDELETE DIALOGEX 0, 0, 283, 87
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "Ok",IDOK,117,66,50,14
+ CTEXT "",IDC_STATIC_TXT,7,7,275,18
+ CONTROL "",IDC_CH_REMOVE_FROM_FRIEND,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,33,254,10
+ CONTROL "",IDC_CH_CLEARHISTORY,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,29,45,253,10
+END
+
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 6b7f12dad1..8821dad4fb 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1515,3 +1515,8 @@ void CVkProto::AddVkDeactivateEvent(MCONTACT hContact, CMStringW& wszType)
db_event_add(hContact, &dbei);
}
+int CVkProto::DeleteContact(MCONTACT hContact)
+{
+ setByte(hContact, "SilentDelete", 1);
+ return db_delete_contact(hContact);
+}
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index 79b0cbb797..6fccad6815 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -25,6 +25,7 @@
#define IDI_WALL 121
#define IDI_MARKMESSAGESASREAD 122
#define IDD_OPT_MENU 122
+#define IDD_CONTACTDELETE 123
#define IDI_KEYS 203
#define IDC_LOGIN 1001
#define IDC_PASSWORD 1002
@@ -128,14 +129,18 @@
#define IDC_SENDVKURLSASATTACH 1111
#define IDC_LOADSENTATTACH 1112
#define IDC_ADD_MES_LINK_MES_ATT 1113
+#define IDC_STATIC_TXT 1114
+#define IDC_CH_REMOVE_FROM_FRIEND 1115
+#define IDC_CH_CLEARHISTORY 1116
// Next default values for new objects
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 123
+#define _APS_NEXT_RESOURCE_VALUE 124
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1114
+#define _APS_NEXT_CONTROL_VALUE 1116
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index f9362e3e33..06d869510f 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
-#define __RELEASE_NUM 2
-#define __BUILD_NUM 23
+#define __RELEASE_NUM 3
+#define __BUILD_NUM 0
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index e48e3979e4..43eb705527 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -611,7 +611,7 @@ void CVkProto::LeaveChat(int chat_id, bool close_window, bool delete_chat)
Chat_Control(m_szModuleName, cc->m_wszId, SESSION_OFFLINE);
if (delete_chat)
- db_delete_contact(cc->m_hContact);
+ DeleteContact(cc->m_hContact);
else
setByte(cc->m_hContact, "off", (int)true);
m_chats.remove(cc);
@@ -676,7 +676,7 @@ INT_PTR __cdecl CVkProto::SvcDestroyKickChat(WPARAM hContact, LPARAM)
<< INT_PARAM("chatid", chat_id)
);
- db_delete_contact(hContact);
+ DeleteContact(hContact);
return 0;
}
diff --git a/protocols/VKontakte/src/vk_dialogs.cpp b/protocols/VKontakte/src/vk_dialogs.cpp
index 94ebc96a97..3948482328 100644
--- a/protocols/VKontakte/src/vk_dialogs.cpp
+++ b/protocols/VKontakte/src/vk_dialogs.cpp
@@ -241,4 +241,47 @@ void CVkGCCreateForm::ResetListOptions(CCtrlClc *clCList)
clCList->SetHideOfflineRoot(true);
for (int i = 0; i <= FONTID_MAX; i++)
clCList->SetTextColor(i, GetSysColor(COLOR_WINDOWTEXT));
+}
+
+////////////////////////////////// IDD_CONTACTDELETE //////////////////////////////////////
+
+CVkContactDeleteForm::CVkContactDeleteForm(CVkProto *proto, CONTACTDELETE_FORM_PARAMS *param) :
+ CVkDlgBase(proto, IDD_CONTACTDELETE, false),
+ m_btnOk(this, IDOK),
+ m_stText(this, IDC_STATIC_TXT),
+ m_cbDeleteFromFriendlist(this, IDC_CH_REMOVE_FROM_FRIEND),
+ m_cbDeleteDialog(this, IDC_CH_CLEARHISTORY),
+ m_param(param)
+{
+ m_btnOk.OnClick = Callback(this, &CVkContactDeleteForm::btnOk_OnOk);
+}
+
+void CVkContactDeleteForm::OnInitDialog()
+{
+ CMStringW szText(FORMAT, TranslateT("You delete %s from the contact list.\nWhat needs to be done additionally?"),
+ m_param->pwszNick);
+ m_stText.SetText(szText.c_str());
+
+ szText.Format(TranslateT("Remove %s from your friend list"), m_param->pwszNick);
+ m_cbDeleteFromFriendlist.SetText(szText.c_str());
+ m_cbDeleteFromFriendlist.SetState(m_param->bDeleteFromFriendlist && m_param->bEnableDeleteFromFriendlist);
+ m_cbDeleteFromFriendlist.Enable(m_param->bEnableDeleteFromFriendlist);
+
+
+ szText.Format(TranslateT("Ñlear server history with %s"), m_param->pwszNick);
+ m_cbDeleteDialog.SetText(szText.c_str());
+ m_cbDeleteDialog.SetState(m_param->bDeleteDialog);
+
+ szText.Format(TranslateT("Deleting %s from contact list"), m_param->pwszNick);
+ SetCaption(szText.c_str());
+}
+
+void CVkContactDeleteForm::btnOk_OnOk(CCtrlButton*)
+{
+
+ m_param->bDeleteDialog = m_cbDeleteDialog.GetState() != 0;
+ m_param->bDeleteFromFriendlist = m_param->bEnableDeleteFromFriendlist
+ && (m_cbDeleteFromFriendlist.GetState() != 0);
+
+ EndDialog(m_hwnd, 1);
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_dialogs.h b/protocols/VKontakte/src/vk_dialogs.h
index 9e65d92daf..4f61f5ceb9 100644
--- a/protocols/VKontakte/src/vk_dialogs.h
+++ b/protocols/VKontakte/src/vk_dialogs.h
@@ -118,4 +118,38 @@ public:
void btnOk_OnOk(CCtrlButton*);
void FilterList(CCtrlClc*);
void ResetListOptions(CCtrlClc*);
+};
+
+////////////////////////////////// IDD_CONTACTDELETE //////////////////////////////////////
+
+struct CONTACTDELETE_FORM_PARAMS
+{
+ wchar_t *pwszNick;
+ bool bDeleteFromFriendlist;
+ bool bEnableDeleteFromFriendlist;
+ bool bDeleteDialog;
+
+ CONTACTDELETE_FORM_PARAMS(wchar_t *nick, bool _bDeleteFromFriendlist, bool _bEnableDeleteFromFriendlist, bool _bDeleteDialog) :
+ pwszNick(nick),
+ bDeleteFromFriendlist(_bDeleteFromFriendlist),
+ bEnableDeleteFromFriendlist(_bEnableDeleteFromFriendlist),
+ bDeleteDialog(_bDeleteDialog)
+ {}
+
+};
+
+
+class CVkContactDeleteForm : public CVkDlgBase
+{
+ CCtrlBase m_stText;
+ CCtrlCheck m_cbDeleteFromFriendlist;
+ CCtrlCheck m_cbDeleteDialog;
+ CCtrlButton m_btnOk;
+
+ CONTACTDELETE_FORM_PARAMS *m_param;
+
+public:
+ CVkContactDeleteForm(CVkProto *proto, CONTACTDELETE_FORM_PARAMS *param);
+ void OnInitDialog();
+ void btnOk_OnOk(CCtrlButton*);
}; \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index 64654c3813..ac0d732d46 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -24,7 +24,7 @@ void CVkProto::AddFeedSpecialUser()
MCONTACT hContact = FindUser(VK_FEED_USER);
if (!bSpecialContact) {
if (hContact)
- db_delete_contact(hContact);
+ DeleteContact(hContact);
return;
}
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index dec31de534..60131a3586 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -547,6 +547,9 @@ int CVkProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
case EV_PROTO_ONOPTIONS:
return OnOptionsInit(wParam, lParam);
+
+ case EV_PROTO_ONCONTACTDELETED:
+ return OnContactDeleted(wParam, lParam);
}
return 1;
@@ -679,4 +682,39 @@ int CVkProto::GetInfo(MCONTACT hContact, int)
return 1;
RetrieveUserInfo(userID);
return 0;
+}
+
+int CVkProto::OnContactDeleted(WPARAM hContact, LPARAM)
+{
+ ptrW pwszNick(db_get_wsa(hContact, m_szModuleName, "Nick"));
+ debugLogW(L"CVkProto::OnContactDeleted %s", pwszNick);
+
+ if (getBool(hContact, "SilentDelete") || isChatRoom((MCONTACT)hContact))
+ return 0;
+
+ LONG userID = getDword(hContact, "ID", VK_INVALID_USER);
+ if (userID == VK_INVALID_USER || userID == VK_FEED_USER)
+ return 0;
+
+ CONTACTDELETE_FORM_PARAMS *param = new CONTACTDELETE_FORM_PARAMS(pwszNick, true, !getBool(hContact, "Auth", true), true);
+ CVkContactDeleteForm dlg(this, param);
+ dlg.DoModal();
+
+ debugLogW(L"CVkProto::OnContactDeleted %s DeleteDialog=%d DeleteFromFriendlist=%d", pwszNick, param->bDeleteDialog, param->bDeleteFromFriendlist);
+ if (param->bDeleteDialog || param->bDeleteFromFriendlist)
+ return 0;
+
+ CMStringA code(FORMAT, "var userID=\"%d\";", userID);
+ if (param->bDeleteDialog)
+ code += "API.messages.deleteDialog({\"user_id\":userID,count:10000});";
+
+ if (param->bDeleteFromFriendlist)
+ code += "API.friends.delete({\"user_id\":userID});";
+
+ code += "return 1;";
+
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
+ << CHAR_PARAM("code", code));
+
+ return 0;
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 4e3868fdec..d1e00cdb6e 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -73,6 +73,7 @@ struct CVkProto : public PROTO<CVkProto>
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl OnPreShutdown(WPARAM, LPARAM);
+ int __cdecl OnContactDeleted(WPARAM, LPARAM);
void OnOAuthAuthorize(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void OnReceiveAvatar(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
@@ -357,6 +358,7 @@ private:
void SetInvisible(MCONTACT hContact);
CMStringW RemoveBBC(CMStringW& wszSrc);
void AddVkDeactivateEvent(MCONTACT hContact, CMStringW & wszType);
+ int DeleteContact(MCONTACT hContact);
void InitQueue();
void UninitQueue();
void ExecuteRequest(AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 4a2f33f133..e89d4d6416 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -779,7 +779,7 @@ void CVkProto::OnReceiveFriends(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq
bool bIsFriendGroup = IsGroupUser(hContact) && getBool(hContact, "friend");
if (userID == m_myUserId || userID == VK_FEED_USER || bIsFriendGroup)
continue;
- db_delete_contact(hContact);
+ DeleteContact(hContact);
}
arContacts.destroy();
@@ -918,10 +918,10 @@ INT_PTR __cdecl CVkProto::SvcBanUser(WPARAM hContact, LPARAM)
return 1;
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveSmth)
- << CHAR_PARAM("code", code));
+ << CHAR_PARAM("code", code.c_str()));
if (m_vkOptions.bRemoveFromCList)
- db_delete_contact(hContact);
+ DeleteContact(hContact);
return 0;
}