summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp133
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp4
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp41
-rw-r--r--protocols/VKontakte/src/vk_proto.h14
5 files changed, 127 insertions, 67 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index b700f4f188..d647c9547c 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 14
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index dcd3801207..6e35580af6 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -29,6 +29,81 @@ static LPCWSTR sttStatuses[] = { LPGENW("Participants"), LPGENW("Owners") };
extern JSONNode nullNode;
+INT_PTR __cdecl CVkProto::SvcChatChangeTopic(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcChatChangeTopic");
+ if (!IsOnline())
+ return 1;
+
+ CVkChatInfo* cc = GetChatByContact(hContact);
+ if (!cc)
+ return 1;
+
+ if (LPTSTR pwszNew = ChangeChatTopic(cc)) {
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.editChat.json", true, &CVkProto::OnReceiveSmth)
+ << WCHAR_PARAM("title", pwszNew)
+ << INT_PARAM("chat_id", cc->m_iChatId));
+ mir_free(pwszNew);
+ }
+
+ return 0;
+}
+
+INT_PTR __cdecl CVkProto::SvcChatInviteUser(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcChatInviteUser");
+ if (!IsOnline())
+ return 1;
+
+ CVkChatInfo* cc = GetChatByContact(hContact);
+ if (!cc)
+ return 1;
+
+ CVkInviteChatForm dlg(this);
+ if (dlg.DoModal() && dlg.m_hContact != 0) {
+ LONG uid = getDword(dlg.m_hContact, "ID", VK_INVALID_USER);
+
+ if (uid < 0)
+ MsgPopup(TranslateT("Adding bots to MUC is not supported"), TranslateT("Not supported"));
+ else if (uid != VK_INVALID_USER)
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.addChatUser.json", true, &CVkProto::OnReceiveSmth)
+ << INT_PARAM("user_id", uid)
+ << INT_PARAM("chat_id", cc->m_iChatId));
+ }
+
+ return 0;
+}
+
+INT_PTR __cdecl CVkProto::SvcChatDestroy(WPARAM hContact, LPARAM)
+{
+ debugLogA("CVkProto::SvcChatDestroy");
+ if (!IsOnline())
+ return 1;
+
+ CVkChatInfo* cc = GetChatByContact(hContact);
+ if (!cc)
+ return 1;
+ if (IDYES == MessageBoxW(nullptr,
+ TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"),
+ TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)
+ ) {
+ if (!getBool(hContact, "off"))
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.DestroyChat", true, &CVkProto::OnChatDestroy)
+ << INT_PARAM("chatid", cc->m_iChatId)
+ << INT_PARAM("userid", m_myUserId)
+ )->pUserInfo = cc;
+ else {
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.DestroyKickChat", true, &CVkProto::OnReceiveSmth)
+ << INT_PARAM("chatid", cc->m_iChatId)
+ );
+ DeleteContact(hContact);
+ }
+ }
+
+ return 0;
+}
+
+
CVkChatInfo* CVkProto::AppendConversationChat(int iChatId, const JSONNode& jnItem)
{
debugLogW(L"CVkProto::AppendConversationChat %d", iChatId);
@@ -449,7 +524,7 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, LONG mid, LONG uid, int msgTim
_itoa(mid, szMid, 10);
T2Utf pszBody(pwszBody);
-
+
PROTORECVEVENT pre = {};
pre.szMsgId = szMid;
pre.timestamp = msgTime;
@@ -547,6 +622,10 @@ int CVkProto::OnChatEvent(WPARAM, LPARAM lParam)
case GC_USER_NICKLISTMENU:
NickMenuHook(cc, gch);
break;
+
+ case GC_USER_TYPNOTIFY:
+ UserIsTyping(cc->m_si->hContact, (int)gch->dwData);
+ break;
}
return 1;
}
@@ -591,40 +670,15 @@ void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
switch (gch->dwData) {
case IDM_TOPIC:
- if (LPTSTR pwszNew = ChangeChatTopic(cc)) {
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.editChat.json", true, &CVkProto::OnReceiveSmth)
- << WCHAR_PARAM("title", pwszNew)
- << INT_PARAM("chat_id", cc->m_iChatId));
- mir_free(pwszNew);
- }
+ SvcChatChangeTopic(cc->m_si->hContact, 0);
break;
case IDM_INVITE:
- {
- CVkInviteChatForm dlg(this);
- if (dlg.DoModal() && dlg.m_hContact != 0) {
- LONG uid = getDword(dlg.m_hContact, "ID", VK_INVALID_USER);
-
- if (uid < 0)
- MsgPopup(TranslateT("Adding bots to MUC is not supported"), TranslateT("Not supported"));
- else if (uid != VK_INVALID_USER)
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.addChatUser.json", true, &CVkProto::OnReceiveSmth)
- << INT_PARAM("user_id", uid)
- << INT_PARAM("chat_id", cc->m_iChatId));
- }
- }
+ SvcChatInviteUser(cc->m_si->hContact, 0);
break;
case IDM_DESTROY:
- if (IDYES == MessageBoxW(nullptr,
- TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"),
- TranslateT("Warning"), MB_YESNO | MB_ICONQUESTION)
- )
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.DestroyChat", true, &CVkProto::OnChatDestroy)
- << INT_PARAM("chatid", cc->m_iChatId)
- << INT_PARAM("userid", m_myUserId)
- )->pUserInfo = cc;
-
+ SvcChatDestroy(cc->m_si->hContact, 0);
break;
}
}
@@ -726,27 +780,6 @@ void CVkProto::OnChatLeave(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
LeaveChat(cc->m_iChatId);
}
-INT_PTR __cdecl CVkProto::SvcDestroyKickChat(WPARAM hContact, LPARAM)
-{
- debugLogA("CVkProto::SvcDestroyKickChat");
- if (!IsOnline())
- return 1;
-
- if (!getBool(hContact, "off"))
- return 1;
-
- int chat_id = getDword(hContact, "ID", VK_INVALID_USER);
- if (chat_id == VK_INVALID_USER)
- return 1;
-
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.DestroyKickChat", true, &CVkProto::OnReceiveSmth)
- << INT_PARAM("chatid", chat_id)
- );
-
- DeleteContact(hContact);
-
- return 0;
-}
void CVkProto::OnChatDestroy(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 9fba88b8f9..c0940af108 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -156,12 +156,12 @@ void CVkProto::MarkMessagesRead(const MCONTACT hContact)
return;
LONG userID = getDword(hContact, "ID", VK_INVALID_USER);
- if (userID == VK_INVALID_USER || userID == VK_FEED_USER || isChatRoom(hContact))
+ if (userID == VK_INVALID_USER || userID == VK_FEED_USER)
return;
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.markAsRead.json", true, &CVkProto::OnReceiveSmth, AsyncHttpRequest::rpLow)
<< INT_PARAM("mark_conversation_as_read", 1)
- << INT_PARAM("peer_id", userID));
+ << INT_PARAM("peer_id", isChatRoom(hContact) ? VK_CHAT_FLAG + userID : userID));
}
void CVkProto::RetrieveMessagesByIds(const CMStringA &mids)
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 1bfdecea61..c683c1d4c1 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -224,14 +224,15 @@ void CVkProto::InitMenus()
CreateProtoService(PS_DELETEFRIEND, &CVkProto::SvcDeleteFriend);
CreateProtoService(PS_BANUSER, &CVkProto::SvcBanUser);
CreateProtoService(PS_REPORTABUSE, &CVkProto::SvcReportAbuse);
- CreateProtoService(PS_DESTROYKICKCHAT, &CVkProto::SvcDestroyKickChat);
CreateProtoService(PS_OPENBROADCAST, &CVkProto::SvcOpenBroadcast);
CreateProtoService(PS_LOADVKNEWS, &CVkProto::SvcLoadVKNews);
CreateProtoService(PS_WIPENONFRIENDS, &CVkProto::SvcWipeNonFriendContacts);
CreateProtoService(PS_SETSTATUSMSG, &CVkProto::SvcSetStatusMsg);
CreateProtoService(PS_WALLPOST, &CVkProto::SvcWallPost);
CreateProtoService(PS_MARKMESSAGESASREAD, &CVkProto::SvcMarkMessagesAsRead);
-
+ CreateProtoService(PS_CHATCHANGETOPIC, &CVkProto::SvcChatChangeTopic);
+ CreateProtoService(PS_CHATINVITEUSER, &CVkProto::SvcChatInviteUser);
+ CreateProtoService(PS_CHATDESTROY, &CVkProto::SvcChatDestroy);
// Contact Menu Items
CMenuItem mi(&g_plugin);
@@ -286,19 +287,33 @@ void CVkProto::InitMenus()
SET_UID(mi, 0x56454cb9, 0xd80, 0x4050, 0xbe, 0xfc, 0x2c, 0xf6, 0x10, 0x2a, 0x7d, 0x19);
m_hContactMenuItems[CMI_REPORTABUSE] = Menu_AddContactMenuItem(&mi, m_szModuleName);
- mi.pszService = PS_DESTROYKICKCHAT;
- mi.position = -200001000 + CMI_DESTROYKICKCHAT;
- mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDDEL);
- mi.name.w = LPGENW("Destroy room");
- SET_UID(mi, 0x4fa6e75a, 0x30cd, 0x4482, 0xae, 0x8f, 0x0, 0x38, 0xd0, 0x17, 0x33, 0xcd);
- m_hContactMenuItems[CMI_DESTROYKICKCHAT] = Menu_AddContactMenuItem(&mi, m_szModuleName);
-
mi.pszService = PS_OPENBROADCAST;
mi.position = -200001000 + CMI_OPENBROADCAST;
mi.hIcolibItem = g_plugin.getIconHandle(IDI_BROADCAST);
mi.name.w = LPGENW("Open broadcast");
SET_UID(mi, 0x85251a06, 0xf734, 0x4985, 0x8c, 0x36, 0x6f, 0x66, 0x46, 0xf9, 0xa0, 0x10);
m_hContactMenuItems[CMI_OPENBROADCAST] = Menu_AddContactMenuItem(&mi, m_szModuleName);
+
+ mi.pszService = PS_CHATCHANGETOPIC;
+ mi.position = -200001000 + CMI_CHATCHANGETOPIC;
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_STATUS);
+ mi.name.w = LPGENW("View/change title");
+ SET_UID(mi, 0x104a176, 0xb66c, 0x45b6, 0xb8, 0x51, 0x30, 0x28, 0x36, 0x86, 0xfb, 0x4a);
+ m_hContactMenuItems[CMI_CHATCHANGETOPIC] = Menu_AddContactMenuItem(&mi, m_szModuleName);
+
+ mi.pszService = PS_CHATINVITEUSER;
+ mi.position = -200001000 + CMI_CHATINVITEUSER;
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDADD);
+ mi.name.w = LPGENW("Invite a user");
+ SET_UID(mi, 0xeeb5b4ce, 0xc151, 0x4f73, 0x8d, 0x75, 0x1a, 0x45, 0x55, 0x4c, 0x5f, 0x52);
+ m_hContactMenuItems[CMI_CHATINVITEUSER] = Menu_AddContactMenuItem(&mi, m_szModuleName);
+
+ mi.pszService = PS_CHATDESTROY;
+ mi.position = -200001000 + CMI_CHATDESTROY;
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_FRIENDDEL);
+ mi.name.w = LPGENW("Destroy room");
+ SET_UID(mi, 0x4fa6e75a, 0x30cd, 0x4482, 0xae, 0x8f, 0x0, 0x38, 0xd0, 0x17, 0x33, 0xcd);
+ m_hContactMenuItems[CMI_CHATDESTROY] = Menu_AddContactMenuItem(&mi, m_szModuleName);
mi.pszService = PS_LOADVKNEWS;
mi.position = -200001000 + CMI_LOADVKNEWS;
@@ -367,14 +382,18 @@ int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM)
bool bisBroadcast = !(IsEmpty(ptrW(db_get_wsa(hContact, m_szModuleName, "AudioUrl"))));
bool bIsGroup = IsGroupUser(hContact);
Menu_ShowItem(m_hContactMenuItems[CMI_VISITPROFILE], userID != VK_FEED_USER);
- Menu_ShowItem(m_hContactMenuItems[CMI_MARKMESSAGESASREAD], !isChatRoom(hContact) && userID != VK_FEED_USER);
+ Menu_ShowItem(m_hContactMenuItems[CMI_MARKMESSAGESASREAD], userID != VK_FEED_USER);
Menu_ShowItem(m_hContactMenuItems[CMI_WALLPOST], !isChatRoom(hContact));
Menu_ShowItem(m_hContactMenuItems[CMI_ADDASFRIEND], !bisFriend && !isChatRoom(hContact) && userID != VK_FEED_USER && !bIsGroup);
Menu_ShowItem(m_hContactMenuItems[CMI_DELETEFRIEND], bisFriend && userID != VK_FEED_USER && !bIsGroup);
Menu_ShowItem(m_hContactMenuItems[CMI_BANUSER], !isChatRoom(hContact) && userID != VK_FEED_USER && !bIsGroup);
Menu_ShowItem(m_hContactMenuItems[CMI_REPORTABUSE], !isChatRoom(hContact) && userID != VK_FEED_USER && !bIsGroup);
- Menu_ShowItem(m_hContactMenuItems[CMI_DESTROYKICKCHAT], isChatRoom(hContact) && getBool(hContact, "off"));
Menu_ShowItem(m_hContactMenuItems[CMI_OPENBROADCAST], !isChatRoom(hContact) && bisBroadcast);
+
+ Menu_ShowItem(m_hContactMenuItems[CMI_CHATCHANGETOPIC], isChatRoom(hContact));
+ Menu_ShowItem(m_hContactMenuItems[CMI_CHATINVITEUSER], isChatRoom(hContact));
+ Menu_ShowItem(m_hContactMenuItems[CMI_CHATDESTROY], isChatRoom(hContact));
+
Menu_ShowItem(m_hContactMenuItems[CMI_GETSERVERHISTORY], !isChatRoom(hContact) && userID != VK_FEED_USER);
Menu_ShowItem(m_hContactMenuItems[CMI_LOADVKNEWS], userID == VK_FEED_USER);
for (int i = 0; i < CHMI_COUNT; i++)
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 365c207d1a..a3755e3721 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -33,11 +33,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PS_DELETEFRIEND "/DeleteFriend"
#define PS_BANUSER "/BanUser"
#define PS_REPORTABUSE "/ReportAbuse"
-#define PS_DESTROYKICKCHAT "/DestroyKickChat"
#define PS_OPENBROADCAST "/OpenBroadcast"
#define PS_SETSTATUSMSG "/SetStatusMsg"
#define PS_WALLPOST "/WallPost"
#define PS_MARKMESSAGESASREAD "/MarkMessagesAsRead"
+#define PS_CHATCHANGETOPIC "/ChatChangeTopic"
+#define PS_CHATINVITEUSER "/ChatInviteUser"
+#define PS_CHATDESTROY "/ChatDestroy"
+
+
#define MAXHISTORYMIDSPERONE 100
#define MAX_RETRIES 10
@@ -95,11 +99,13 @@ struct CVkProto : public PROTO<CVkProto>
INT_PTR __cdecl SvcDeleteFriend(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcBanUser(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcReportAbuse(WPARAM hContact, LPARAM);
- INT_PTR __cdecl SvcDestroyKickChat(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcOpenBroadcast(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcWallPost(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcMarkMessagesAsRead(WPARAM hContact, LPARAM);
INT_PTR __cdecl SvcSetStatusMsg(WPARAM, LPARAM);
+ INT_PTR __cdecl SvcChatChangeTopic(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcChatInviteUser(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl SvcChatDestroy(WPARAM hContact, LPARAM);
//==== History Menus ==================================================================
@@ -138,6 +144,9 @@ private:
//==== Enums =========================================================================
enum CLMenuIndexes {
+ CMI_CHATDESTROY,
+ CMI_CHATCHANGETOPIC,
+ CMI_CHATINVITEUSER,
CMI_VISITPROFILE,
CMI_MARKMESSAGESASREAD,
CMI_WALLPOST,
@@ -145,7 +154,6 @@ private:
CMI_DELETEFRIEND,
CMI_BANUSER,
CMI_REPORTABUSE,
- CMI_DESTROYKICKCHAT,
CMI_OPENBROADCAST,
CMI_LOADVKNEWS,
CMI_GETSERVERHISTORY,