diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-10 21:31:29 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-10 21:31:29 +0000 |
commit | 61281c4de68a2223400176bc24d42743b3a21b98 (patch) | |
tree | 76d8ca43355c6047d7c076fdd249b9cd76e07eb7 /protocols | |
parent | 09509db69203537d336a2d2b3451e5bba32d8aec (diff) |
VK: kick & invite work ok in chats
git-svn-id: http://svn.miranda-ng.org/main/trunk@7583 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/res/resource.rc | 18 | ||||
-rw-r--r-- | protocols/VKontakte/src/main.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/resource.h | 6 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 97 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 4 |
6 files changed, 106 insertions, 23 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc index d4cd5ae63e..92b9b0ee02 100644 --- a/protocols/VKontakte/res/resource.rc +++ b/protocols/VKontakte/res/resource.rc @@ -69,6 +69,16 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,200,203,50,14
END
+IDD_INVITE DIALOGEX 0, 0, 191, 65
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Invite user to chat"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "OK",IDOK,79,44,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,134,44,50,14
+ LTEXT "Choose one of your contacts to be invited:",IDC_STATIC,7,15,177,8
+ COMBOBOX IDC_CONTACT,7,26,177,99,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+END
/////////////////////////////////////////////////////////////////////////////
//
@@ -100,6 +110,14 @@ BEGIN TOPMARGIN, 7
BOTTOMMARGIN, 217
END
+
+ IDD_INVITE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 184
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 58
+ END
END
#endif // APSTUDIO_INVOKED
diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp index 87a9bda6a5..5715acede3 100644 --- a/protocols/VKontakte/src/main.cpp +++ b/protocols/VKontakte/src/main.cpp @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. HINSTANCE hInst;
int hLangpack;
+CLIST_INTERFACE *pcli;
PLUGININFOEX pluginInfo =
{
@@ -77,6 +78,7 @@ static int vkProtoUninit(CVkProto *ppro) extern "C" int __declspec(dllexport) Load()
{
mir_getLP(&pluginInfo);
+ mir_getCLI();
InitIcons();
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h index db17b49f6f..b6843eb8bb 100644 --- a/protocols/VKontakte/src/resource.h +++ b/protocols/VKontakte/src/resource.h @@ -5,6 +5,7 @@ #define IDD_ACCMGRUI 101
#define IDD_CAPTCHAFORM 102
#define IDD_OPT_MAIN 103
+#define IDD_INVITE 104
#define IDI_KEYS 203
#define IDC_LOGIN 1001
#define IDC_PASSWORD 1002
@@ -18,15 +19,16 @@ #define IDC_SUBMIT 1010
#define IDC_DELIVERY 1011
#define IDC_GROUPNAME 1012
+#define IDC_CONTACT 1015
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1015
+#define _APS_NEXT_CONTROL_VALUE 1016
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index ac2fbb3d20..131344c505 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 7
+#define __BUILD_NUM 8
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 3f6c97bf1c..1935fb7b73 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -23,20 +23,6 @@ enum IDM_KICK, IDM_INFO
};
-static gc_item sttLogListItems[] =
-{
- { LPGENT("&Invite a user"), IDM_INVITE, MENU_ITEM },
- { LPGENT("View/change &topic"), IDM_TOPIC, MENU_POPUPITEM },
- { NULL, 0, MENU_SEPARATOR },
- { LPGENT("&Destroy room"), IDM_DESTROY, MENU_POPUPITEM }
-};
-
-static gc_item sttListItems[] =
-{
- { LPGENT("&User details"), IDM_INFO, MENU_ITEM },
- { LPGENT("&Kick"), IDM_KICK, MENU_ITEM }
-};
-
static LPCTSTR sttStatuses[] = { LPGENT("Participants"), LPGENT("Owners") };
CVkChatInfo* CVkProto::AppendChat(int id, JSONNODE *pDlg)
@@ -52,7 +38,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, JSONNODE *pDlg) c = new CVkChatInfo(id);
if (pDlg != NULL) {
tszTitle = json_as_string(json_get(pDlg, "title"));
- c->m_tszTitle = mir_tstrdup((tszTitle != NULL) ? tszTitle : _T(""));
+ c->m_tszTopic = mir_tstrdup((tszTitle != NULL) ? tszTitle : _T(""));
}
CMString sid; sid.Format(_T("%S_%d"), m_szModuleName, id);
@@ -134,8 +120,8 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe JSONNODE *info = json_get(pResponse, "info");
if (info != NULL) {
ptrT tszTitle(json_as_string(json_get(info, "title")));
- if (lstrcmp(tszTitle, cc->m_tszTitle)) {
- cc->m_tszTitle = mir_tstrdup(tszTitle);
+ if (lstrcmp(tszTitle, cc->m_tszTopic)) {
+ cc->m_tszTopic = mir_tstrdup(tszTitle);
GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_TOPIC };
GCEVENT gce = { sizeof(GCEVENT), &gcd };
@@ -160,18 +146,20 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe TCHAR tszId[20];
_itot(uid, tszId, 10);
- bool bNew = false;
+ bool bNew;
CVkChatUser *cu = cc->m_users.find((CVkChatUser*)&uid);
if (cu == NULL) {
cc->m_users.insert(cu = new CVkChatUser(uid));
bNew = true;
}
+ else bNew = cu->m_bUnknown;
cu->m_bDel = false;
ptrT fName(json_as_string(json_get(pUser, "first_name")));
ptrT lName(json_as_string(json_get(pUser, "last_name")));
CMString tszNick = CMString(fName).Trim() + _T(" ") + CMString(lName).Trim();
cu->m_tszTitle = mir_tstrdup(tszNick);
+ cu->m_bUnknown = false;
cu->m_tszImage = json_as_string(json_get(pUser, "photo"));
@@ -199,6 +187,8 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe GCEVENT gce = { sizeof(GCEVENT), &gcd };
gce.ptszUID = tszId;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ cc->m_users.remove(i);
}
}
@@ -267,6 +257,7 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCTSTR if (cu == NULL) {
cc->m_users.insert(cu = new CVkChatUser(uid));
cu->m_tszTitle = mir_tstrdup(TranslateT("Unknown"));
+ cu->m_bUnknown = true;
}
GCDEST gcd = { m_szModuleName, cc->m_tszId, GC_EVENT_MESSAGE };
@@ -368,12 +359,67 @@ void CVkProto::OnSendChatMsg(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) /////////////////////////////////////////////////////////////////////////////////////////
+static INT_PTR CALLBACK InviteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ CVkProto *ppro = (CVkProto*)lParam;
+ HWND hwndCombo = GetDlgItem(hwndDlg, IDC_CONTACT);
+ for (HANDLE hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName)) {
+ TCHAR *ptszNick = pcli->pfnGetContactDisplayName(hContact, 0);
+ int idx = SendMessage(hwndCombo, CB_ADDSTRING, 0, LPARAM(ptszNick));
+ SendMessage(hwndCombo, CB_SETITEMDATA, idx, (LPARAM)hContact);
+ }
+ SendMessage(hwndCombo, CB_SETCURSEL, 0, 0);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+
+ case IDOK:
+ int idx = SendDlgItemMessage(hwndDlg, IDC_CONTACT, CB_GETCURSEL, 0, 0);
+ if (idx != -1)
+ EndDialog(hwndDlg, SendDlgItemMessage(hwndDlg, IDC_CONTACT, CB_GETITEMDATA, idx, 0));
+ else
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+ }
+ }
+
+ return 0;
+}
+
void CVkProto::LogMenuHook(CVkChatInfo *cc, GCHOOK *gch)
{
+ HANDLE hContact;
char szChatId[20];
_itoa(cc->m_chatid, szChatId, 10);
switch (gch->dwData) {
+ case IDM_INVITE:
+ hContact = (HANDLE)DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INVITE), NULL, InviteDlgProc, (LPARAM)this);
+ if (hContact != NULL) {
+ int uid = getDword(hContact, "ID", -1);
+ if (uid == -1) break;
+
+ char szUid[20];
+ _itoa(uid, szUid, 10);
+
+ HttpParam params[] = {
+ { "uid", szUid },
+ { "chat_id", szChatId },
+ { "access_token", m_szAccessToken }
+ };
+ PushAsyncHttpRequest(REQUEST_GET, "/method/messages.addChatUser.json", true, NULL, SIZEOF(params), params);
+ }
+ break;
+
case IDM_DESTROY:
if (IDYES == MessageBox(NULL,
TranslateT("This chat is going to be destroyed forever with all its contents. This action cannot be undone. Are you sure?"),
@@ -424,12 +470,27 @@ void CVkProto::NickMenuHook(CVkChatInfo *cc, GCHOOK *gch) { "access_token", m_szAccessToken }
};
PushAsyncHttpRequest(REQUEST_GET, "/method/messages.removeChatUser.json", true, NULL, SIZEOF(params), params);
+ cu->m_bUnknown = true;
break;
}
}
/////////////////////////////////////////////////////////////////////////////////////////
+static gc_item sttLogListItems[] =
+{
+ { LPGENT("&Invite a user"), IDM_INVITE, MENU_ITEM },
+ { LPGENT("View/change &topic"), IDM_TOPIC, MENU_POPUPITEM },
+ { NULL, 0, MENU_SEPARATOR },
+ { LPGENT("&Destroy room"), IDM_DESTROY, MENU_POPUPITEM }
+};
+
+static gc_item sttListItems[] =
+{
+ { LPGENT("&User details"), IDM_INFO, MENU_ITEM },
+ { LPGENT("&Kick"), IDM_KICK, MENU_ITEM }
+};
+
int CVkProto::OnGcMenuHook(WPARAM, LPARAM lParam)
{
GCMENUITEMS* gcmi = (GCMENUITEMS*)lParam;
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 81b9300b5e..1bd1cc8c85 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -42,7 +42,7 @@ struct CVkChatUser : public MZeroedObject CVkChatUser(int _id) : m_uid(_id) {}
int m_uid;
- bool m_bDel;
+ bool m_bDel, m_bUnknown;
ptrT m_tszTitle, m_tszImage;
};
@@ -56,7 +56,7 @@ struct CVkChatInfo : public MZeroedObject int m_chatid, m_admin_id;
bool m_bHistoryRead;
- ptrT m_tszTitle, m_tszId;
+ ptrT m_tszTopic, m_tszId;
HANDLE m_hContact;
OBJLIST<CVkChatUser> m_users;
OBJLIST<CVkChatMessage> m_msgs;
|