diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-20 19:40:35 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-20 19:40:35 +0000 |
commit | 0ab99d5195c16d19aecf0e6d6867cc0a6ddfd66d (patch) | |
tree | 3b40d7449034a6fbf8b1c1b9af99e880295a32a7 /protocols | |
parent | 4cbbc64544a96d365e0e1862b122b9dec8faf601 (diff) |
SkypeWeb: Chat creating part 1.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12986 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/SkypeWeb/res/resource.rc | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/chatrooms.h | 4 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/resource.h | 3 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 94 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_menus.cpp | 9 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_menus.h | 9 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 3 |
7 files changed, 119 insertions, 5 deletions
diff --git a/protocols/SkypeWeb/res/resource.rc b/protocols/SkypeWeb/res/resource.rc index bbebeb1a15..e52911174e 100644 --- a/protocols/SkypeWeb/res/resource.rc +++ b/protocols/SkypeWeb/res/resource.rc @@ -77,7 +77,7 @@ BEGIN DEFPUSHBUTTON "ОК",IDOK,96,233,50,14
PUSHBUTTON "Cancel",IDCANCEL,148,233,50,14
CONTROL "Настраиваемый1",IDC_CLIST,"",WS_TABSTOP,7,20,191,122
- EDITTEXT IDC_EDIT1,7,161,191,61,ES_AUTOHSCROLL
+ EDITTEXT IDC_TITLE,7,161,191,61,ES_AUTOHSCROLL | ES_WANTRETURN
CTEXT "New chat's title:",IDC_STATIC,7,148,191,11
CTEXT "Mark users you want to invite to a new chat",IDC_STATIC,7,7,191,8
END
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h index d23e86832c..49a3ef9892 100644 --- a/protocols/SkypeWeb/src/requests/chatrooms.h +++ b/protocols/SkypeWeb/src/requests/chatrooms.h @@ -45,7 +45,7 @@ public: class CreateChatroomRequest : public HttpRequest
{
public:
- CreateChatroomRequest(const char *regToken, const LIST<char> &skypenames, const LIST<char> &roles, const char *server = SKYPE_ENDPOINTS_HOST) :
+ CreateChatroomRequest(const char *regToken, const LIST<char> &skypenames,const char *selfname, const char *server = SKYPE_ENDPOINTS_HOST) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/threads", server)
{
//{"members":[{"id":"8:user3","role":"User"},{"id":"8:user2","role":"User"},{"id":"8:user1","role":"Admin"}]}
@@ -57,7 +57,7 @@ public: CMStringA data = "{\"members\":[";
for (int i = 0; i < skypenames.getCount(); i++)
- data.AppendFormat("{\"id\":\"8:%s\",\"role\":\"%s\"},", skypenames[i], roles[i]);
+ data.AppendFormat("{\"id\":\"8:%s\",\"role\":\"%s\"},", skypenames[i], !mir_strcmpi(skypenames[i], selfname) ? "Admin" : "User");
data.Truncate(data.GetLength() - 1);
data.Append("]}");
diff --git a/protocols/SkypeWeb/src/resource.h b/protocols/SkypeWeb/src/resource.h index 7b9b729528..4b77d63e7d 100644 --- a/protocols/SkypeWeb/src/resource.h +++ b/protocols/SkypeWeb/src/resource.h @@ -20,8 +20,7 @@ #define IDC_RADIO4 1033
#define IDC_STATIC_MARC_AS_READ 1034
#define IDC_CLIST 1035
-#define IDC_EDIT1 1036
-#define IDC_COMBO1 1037
+#define IDC_TITLE 1036
#define IDC_CONTACT 1037
// Next default values for new objects
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 237954214e..f2dbe7b229 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -561,4 +561,98 @@ INT_PTR CSkypeProto::InviteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM }
return 0;
+}
+
+INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
+{
+ if (!IsOnline())
+ return 1;
+ DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_GC_CREATE), NULL, GcCreateDlgProc, (LPARAM)this);
+ return 0;
+}
+
+static void FilterContacts(HWND hwndDlg, CSkypeProto *ppro)
+{
+ HWND hwndClist = GetDlgItem(hwndDlg, IDC_CLIST);
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *proto = GetContactProto(hContact);
+ if (mir_strcmp(proto, ppro->m_szModuleName) || ppro->isChatRoom(hContact))
+ if (HANDLE hItem = (HANDLE)SendMessage(hwndClist, CLM_FINDCONTACT, hContact, 0))
+ SendMessage(hwndClist, CLM_DELETEITEM, (WPARAM)hItem, 0);
+ }
+}
+
+static void ResetOptions(HWND hwndDlg)
+{
+ HWND hwndClist = GetDlgItem(hwndDlg, IDC_CLIST);
+ SendMessage(hwndClist, CLM_SETHIDEEMPTYGROUPS, 1, 0);
+ SendMessage(hwndClist, CLM_GETHIDEOFFLINEROOT, 1, 0);
+}
+
+INT_PTR CSkypeProto::GcCreateDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ CSkypeProto *ppro = (CSkypeProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ NMCLISTCONTROL* nmc;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ ppro = (CSkypeProto*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ {
+ HWND hwndClist = GetDlgItem(hwndDlg, IDC_CLIST);
+ SetWindowLongPtr(hwndClist, GWL_STYLE,
+ GetWindowLongPtr(hwndClist, GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
+ SendMessage(hwndClist, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
+
+ ResetOptions(hwndDlg);
+ }
+ return TRUE;
+
+ case WM_NOTIFY:
+ nmc = (NMCLISTCONTROL*)lParam;
+ if (nmc->hdr.idFrom == IDC_CLIST && nmc->hdr.code == CLN_LISTREBUILT)
+ FilterContacts(hwndDlg, ppro);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+
+ case IDOK:
+ HWND hwndClist = GetDlgItem(hwndDlg, IDC_CLIST);
+ LIST<char>uids(1);
+ for (MCONTACT hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName)) {
+ if (ppro->isChatRoom(hContact))
+ continue;
+
+ if (int hItem = SendMessage(hwndClist, CLM_FINDCONTACT, hContact, 0)) {
+ if (SendMessage(hwndClist, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
+ ptrA uid(db_get_sa(hContact, ppro->m_szModuleName, SKYPE_SETTINGS_ID));
+ uids.insert(uid);
+ }
+ }
+ }
+
+ TCHAR tszTitle[1024];
+ GetDlgItemText(hwndDlg, IDC_TITLE, tszTitle, SIZEOF(tszTitle));
+ ppro->CreateNewChat(uids, tszTitle);
+ for (int i = 0; i < uids.getCount(); i++)
+ mir_free(uids[i]);
+ uids.destroy();
+ EndDialog(hwndDlg, 0);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void CSkypeProto::CreateNewChat(LIST<char> &uids, LPCTSTR ptszTitle)
+{
+ if (!IsOnline())
+ return;
+ SendRequest(new CreateChatroomRequest(RegToken, uids, m_szModuleName, Server));
}
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp index d2fe63157e..1b4494312e 100644 --- a/protocols/SkypeWeb/src/skype_menus.cpp +++ b/protocols/SkypeWeb/src/skype_menus.cpp @@ -104,6 +104,15 @@ int CSkypeProto::OnInitStatusMenu() mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
mi.icolibItem = GetSkinIconHandle("main");
hStatusMunuRoot = /*m_hMenuRoot = */Menu_AddProtoMenuItem(&mi);
+
+ /*
+ mi.pszService = MODULE"/CreateNewChat";
+ mi.ptszName = LPGENT("Create new chat");
+ mi.position = 10009 + PMI_CREATECHAT;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_CHAT_JOIN);
+ ProtoMenuItems[PMI_CREATECHAT] = Menu_AddProtoMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SvcCreateChat>);
+ */
}
/*else
{
diff --git a/protocols/SkypeWeb/src/skype_menus.h b/protocols/SkypeWeb/src/skype_menus.h index 437a8bb947..99a15ef920 100644 --- a/protocols/SkypeWeb/src/skype_menus.h +++ b/protocols/SkypeWeb/src/skype_menus.h @@ -28,6 +28,15 @@ enum CMI_MAX // this item shall be the last one
};
+enum ProtoMenuIndexes {
+ PMI_CREATECHAT,
+ PMI_SETSTATUSMSG,
+ PMI_WALLPOST,
+ PMI_LOADVKNEWS,
+ PMI_VISITPROFILE,
+ PMI_COUNT
+};
+
#define SMI_POSITION 200000
#endif //_SKYPE_MENUS_H_
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 4e01934d88..761a8c7305 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -244,6 +244,9 @@ private: void ChangeChatTopic(const char * chat_id, const char *topic, const char *initiator);
static INT_PTR __stdcall InviteDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR __stdcall GcCreateDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl SvcCreateChat(WPARAM, LPARAM);
+ void CreateNewChat(LIST<char> &uids, LPCTSTR ptszTitle);
//polling
void __cdecl PollingThread(void*);
|