diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-05-06 19:50:10 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-05-06 19:50:10 +0000 |
commit | 83e7cec51dafbdd664cb0ece45d0e1b2d1d789bf (patch) | |
tree | 87e1a30ee5e423869762fbe5f91be5b06394d00f /protocols/Skype | |
parent | adc684b43edcca8d5433339993621b26e4fdd2b5 (diff) |
- add "invite to chat" button in group chat dialog
- add notification about ending of group call
git-svn-id: http://svn.miranda-ng.org/main/trunk@4595 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype.h | 11 | ||||
-rw-r--r-- | protocols/Skype/src/skype_chat.cpp | 308 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 69 |
3 files changed, 213 insertions, 175 deletions
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index 1dac385ea4..8ddc5d225c 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -54,18 +54,19 @@ #define SKYPE_SEARCH_BYEMAIL 1002
#define SKYPE_SEARCH_BYNAMES 1003
-#define BBB_ID_CONF_SPAWN 1
+#define BBB_ID_CONF_INVITE 2001
+#define BBB_ID_CONF_SPAWN 2002
#define SKYPE_DB_EVENT_TYPE_EMOTE 10001
#define SKYPE_DB_EVENT_TYPE_CALL 10010
-#define CMI_AUTH_REVOKE 0
-#define CMI_AUTH_REQUEST 1
-#define CMI_AUTH_GRANT 2
+#define CMI_AUTH_REVOKE 1
+#define CMI_AUTH_REQUEST 2
+#define CMI_AUTH_GRANT 3
#define CMI_TEMS_COUNT 3
-#define SMI_CHAT_INVITE 0
+#define SMI_CHAT_INVITE 1
class CSkype;
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 742786a3a6..4f73eda6a2 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -20,61 +20,6 @@ wchar_t *CSkypeProto::Roles[] = #define SKYPE_CHAT_GROUP_RETRIED 4
#define SKYPE_CHAT_GROUP_OUTLAW 5
-bool CSkypeProto::IsChatRoom(HANDLE hContact)
-{
- return ::db_get_b(hContact, this->m_szModuleName, "ChatRoom", 0) > 0;
-}
-
-HANDLE CSkypeProto::GetChatRoomByCid(const wchar_t *cid)
-{
- HANDLE hContact = ::db_find_first();
- while (hContact)
- {
- if (this->IsProtoContact(hContact) && this->IsChatRoom(hContact))
- {
- mir_ptr<wchar_t> chatID(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
- if ( lstrcmp(cid, chatID) == 0)
- return hContact;
- }
-
- hContact = ::db_find_next(hContact);
- }
-
- return 0;
-}
-
-HANDLE CSkypeProto::AddChatRoom(CConversation::Ref conversation)
-{
- SEString data;
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid = ::mir_utf8decodeW(data);
-
- HANDLE hContact = this->GetChatRoomByCid(cid);
- if ( !hContact)
- {
- hContact = (HANDLE)::CallService(MS_DB_CONTACT_ADD, 0, 0);
- ::CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName);
-
- conversation->GetPropDisplayname(data);
- mir_ptr<wchar_t> name = ::mir_utf8decodeW(data);
-
- ::db_set_b(hContact, this->m_szModuleName, "ChatRoom", 1);
- ::db_set_ws(hContact, this->m_szModuleName, "ChatRoomID", cid);
- ::db_set_ws(hContact, this->m_szModuleName, "Nick", name);
- ::db_set_w(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE);
- ::db_set_w(hContact, this->m_szModuleName, "ApparentMode", ID_STATUS_OFFLINE);
-
- mir_ptr<wchar_t> defaultGroup = ::db_get_wsa(NULL, "Chat", "AddToGroup");
- if (defaultGroup)
- {
- ::db_set_ws(hContact, "CList", "Group", defaultGroup);
- }
- }
-
- return hContact;
-}
-
void CSkypeProto::ChatValidateContact(HANDLE hItem, HWND hwndList, const StringList &contacts)
{
//HANDLE hContact = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
@@ -145,6 +90,156 @@ void CSkypeProto::GetInvitedContacts(HANDLE hItem, HWND hwndList, StringList &ch }
}
+INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ InviteChatParam *param = (InviteChatParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ param = (InviteChatParam *)lParam;
+ {
+ HWND hwndClist = GetDlgItem(hwndDlg, IDC_CCLIST);
+ SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE);
+ }
+ break;
+
+ case WM_CLOSE:
+ ::EndDialog(hwndDlg, 0);
+ break;
+
+ case WM_NOTIFY:
+ {
+ NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lParam;
+ if (nmc->hdr.idFrom == IDC_CCLIST)
+ {
+ switch (nmc->hdr.code)
+ {
+ case CLN_NEWCONTACT:
+ if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
+ {
+ param->ppro->ChatValidateContact(nmc->hItem, nmc->hdr.hwndFrom, param->invitedContacts);
+ }
+ break;
+
+ case CLN_LISTREBUILT:
+ if (param)
+ {
+ param->ppro->ChatPrepare(NULL, nmc->hdr.hwndFrom, param->invitedContacts);
+ }
+ break;
+ }
+ }
+ }
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_ADDSCR:
+ if (param->ppro->IsOnline())
+ {
+ wchar_t sid[SKYPE_SID_LIMIT];
+ ::GetDlgItemText(hwndDlg, IDC_EDITSCR, sid, SIZEOF(sid));
+
+ CLCINFOITEM cii = {0};
+ cii.cbSize = sizeof(cii);
+ cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS;
+ cii.pszText = ::wcslwr(sid);
+
+ HANDLE hItem = (HANDLE)::SendDlgItemMessage(
+ hwndDlg,
+ IDC_CCLIST,
+ CLM_ADDINFOITEM,
+ 0,
+ (LPARAM)&cii);
+ ::SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1);
+ }
+ break;
+
+ case IDOK:
+ {
+ HWND hwndList = ::GetDlgItem(hwndDlg, IDC_CCLIST);
+
+ param->invitedContacts.clear();
+ param->ppro->GetInvitedContacts(NULL, hwndList, param->invitedContacts);
+
+ if ( !param->invitedContacts.empty())
+ {
+ //SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)bct);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ ::EndDialog(hwndDlg, IDOK);
+ }
+ else
+ param->ppro->ShowNotification(::TranslateT("You did not select any contact"));
+ }
+ break;
+
+ case IDCANCEL:
+ ::EndDialog(hwndDlg, IDCANCEL);
+ break;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+bool CSkypeProto::IsChatRoom(HANDLE hContact)
+{
+ return ::db_get_b(hContact, this->m_szModuleName, "ChatRoom", 0) > 0;
+}
+
+HANDLE CSkypeProto::GetChatRoomByCid(const wchar_t *cid)
+{
+ HANDLE hContact = ::db_find_first();
+ while (hContact)
+ {
+ if (this->IsProtoContact(hContact) && this->IsChatRoom(hContact))
+ {
+ mir_ptr<wchar_t> chatID(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
+ if ( lstrcmp(cid, chatID) == 0)
+ return hContact;
+ }
+
+ hContact = ::db_find_next(hContact);
+ }
+
+ return 0;
+}
+
+HANDLE CSkypeProto::AddChatRoom(CConversation::Ref conversation)
+{
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid = ::mir_utf8decodeW(data);
+
+ HANDLE hContact = this->GetChatRoomByCid(cid);
+ if ( !hContact)
+ {
+ hContact = (HANDLE)::CallService(MS_DB_CONTACT_ADD, 0, 0);
+ ::CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName);
+
+ conversation->GetPropDisplayname(data);
+ mir_ptr<wchar_t> name = ::mir_utf8decodeW(data);
+
+ ::db_set_b(hContact, this->m_szModuleName, "ChatRoom", 1);
+ ::db_set_ws(hContact, this->m_szModuleName, "ChatRoomID", cid);
+ ::db_set_ws(hContact, this->m_szModuleName, "Nick", name);
+ ::db_set_w(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE);
+ ::db_set_w(hContact, this->m_szModuleName, "ApparentMode", ID_STATUS_OFFLINE);
+
+ mir_ptr<wchar_t> defaultGroup = ::db_get_wsa(NULL, "Chat", "AddToGroup");
+ if (defaultGroup)
+ {
+ ::db_set_ws(hContact, "CList", "Group", defaultGroup);
+ }
+ }
+
+ return hContact;
+}
+
static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
void CSkypeProto::InitChat()
@@ -464,13 +559,13 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam) }
break;
- case GC_USER_CHANMGR:
+ /*case GC_USER_CHANMGR:
if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
{
StringList invitedContacts(this->GetChatUsers(cid));
this->InviteConactsToChat(conversation, invitedContacts);
}
- break;
+ break;*/
case GC_USER_PRIVMESS:
::CallService(MS_MSG_SENDMESSAGE, (WPARAM)this->GetContactBySid(sid), 0);
@@ -525,7 +620,7 @@ int __cdecl CSkypeProto::OnGCMenuHook(WPARAM, LPARAM lParam) {
static const struct gc_item Items[] =
{
- { TranslateT("&Invite user..."), 10, MENU_ITEM, FALSE },
+ { TranslateT("Invite to conference"), 10, MENU_ITEM, FALSE },
{ TranslateT("&Leave chat session"), 20, MENU_ITEM, FALSE }
};
gcmi->nItems = SIZEOF(Items);
@@ -550,7 +645,7 @@ int __cdecl CSkypeProto::OnGCMenuHook(WPARAM, LPARAM lParam) static const struct gc_item Items[] =
{
{ TranslateT("User &details"), 10, MENU_ITEM, FALSE },
- { TranslateT("User &history"), 20, MENU_ITEM, FALSE }
+ { TranslateT("User &history"), 20, MENU_ITEM, FALSE },
};
gcmi->nItems = SIZEOF(Items);
gcmi->Item = (gc_item*)Items;
@@ -600,99 +695,4 @@ void CSkypeProto::UpdateChatUserStatus(CContact::Ref contact) 0,
CSkypeProto::SkypeToMirandaStatus(availability));
}
-}
-
-INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- InviteChatParam *param = (InviteChatParam *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
-
- switch (msg) {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
-
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- param = (InviteChatParam *)lParam;
- {
- HWND hwndClist = GetDlgItem(hwndDlg, IDC_CCLIST);
- SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE);
- }
- break;
-
- case WM_CLOSE:
- ::EndDialog(hwndDlg, 0);
- break;
-
- case WM_NOTIFY:
- {
- NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lParam;
- if (nmc->hdr.idFrom == IDC_CCLIST)
- {
- switch (nmc->hdr.code)
- {
- case CLN_NEWCONTACT:
- if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
- {
- param->ppro->ChatValidateContact(nmc->hItem, nmc->hdr.hwndFrom, param->invitedContacts);
- }
- break;
-
- case CLN_LISTREBUILT:
- if (param)
- {
- param->ppro->ChatPrepare(NULL, nmc->hdr.hwndFrom, param->invitedContacts);
- }
- break;
- }
- }
- }
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam)) {
- case IDC_ADDSCR:
- if (param->ppro->IsOnline())
- {
- wchar_t sid[SKYPE_SID_LIMIT];
- ::GetDlgItemText(hwndDlg, IDC_EDITSCR, sid, SIZEOF(sid));
-
- CLCINFOITEM cii = {0};
- cii.cbSize = sizeof(cii);
- cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS;
- cii.pszText = ::wcslwr(sid);
-
- HANDLE hItem = (HANDLE)::SendDlgItemMessage(
- hwndDlg,
- IDC_CCLIST,
- CLM_ADDINFOITEM,
- 0,
- (LPARAM)&cii);
- ::SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1);
- }
- break;
-
- case IDOK:
- {
- HWND hwndList = ::GetDlgItem(hwndDlg, IDC_CCLIST);
-
- param->invitedContacts.clear();
- param->ppro->GetInvitedContacts(NULL, hwndList, param->invitedContacts);
-
- if ( !param->invitedContacts.empty())
- {
- //SetWindowLongPtr(hwndDlg, 0, (LONG_PTR)bct);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- ::EndDialog(hwndDlg, IDOK);
- }
- else
- param->ppro->ShowNotification(::TranslateT("You did not select any contact"));
- }
- break;
-
- case IDCANCEL:
- ::EndDialog(hwndDlg, IDCANCEL);
- break;
- }
- break;
- }
- return FALSE;
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index fa75b0d5fe..4cc82e4853 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -12,6 +12,13 @@ int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM) BBButton bbd = { sizeof(bbd) };
bbd.pszModuleName = MODULE;
+ bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON;
+ bbd.ptszTooltip = ::TranslateT("Invite to conference");
+ bbd.hIcon = CSkypeProto::GetIconHandle("confInvite");
+ bbd.dwButtonID = BBB_ID_CONF_INVITE;
+ bbd.dwDefPos = 100 + bbd.dwButtonID;
+ ::CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
+
bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON;
bbd.ptszTooltip = ::TranslateT("Spawn conference");
bbd.hIcon = CSkypeProto::GetIconHandle("confSpawn");
@@ -67,20 +74,6 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) return 0;
}
-int __cdecl CSkypeProto::OnSrmmWindowOpen(WPARAM, LPARAM lParam)
-{
- MessageWindowEventData *ev = (MessageWindowEventData*)lParam;
- if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact)
- {
- BBButton bbd = { sizeof(bbd) };
- bbd.pszModuleName = MODULE;
- bbd.dwButtonID = BBB_ID_CONF_SPAWN;
- bbd.bbbFlags = (!strcmp( GetContactProto(ev->hContact), this->m_szModuleName)) ? 0 : BBSF_HIDDEN | BBSF_DISABLED;
- ::CallService(MS_BB_SETBUTTONSTATE, (WPARAM)ev->hContact, (LPARAM)&bbd);
- }
- return 0;
-}
-
INT_PTR __cdecl CSkypeProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam)
{
return (int)::CreateDialogParam(
@@ -110,13 +103,41 @@ int __cdecl CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) return 0;
}
+int __cdecl CSkypeProto::OnSrmmWindowOpen(WPARAM, LPARAM lParam)
+{
+ MessageWindowEventData *ev = (MessageWindowEventData*)lParam;
+ if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact)
+ {
+ BBButton bbd = { sizeof(bbd) };
+ bbd.pszModuleName = MODULE;
+ bbd.bbbFlags = (!strcmp( GetContactProto(ev->hContact), this->m_szModuleName)) ? 0 : BBSF_HIDDEN | BBSF_DISABLED;
+
+ bbd.dwButtonID = BBB_ID_CONF_INVITE;
+ ::CallService(MS_BB_SETBUTTONSTATE, (WPARAM)ev->hContact, (LPARAM)&bbd);
+
+ bbd.dwButtonID = BBB_ID_CONF_SPAWN;
+ ::CallService(MS_BB_SETBUTTONSTATE, (WPARAM)ev->hContact, (LPARAM)&bbd);
+ }
+ return 0;
+}
+
int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam)
{
HANDLE hContact = (HANDLE)wParam;
CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam;
- if (cbcd->dwButtonId == BBB_ID_CONF_SPAWN)
+ switch (cbcd->dwButtonId)
{
+ case BBB_ID_CONF_INVITE:
+ if (this->IsOnline() && this->IsChatRoom(hContact))
+ {
+ StringList targets = this->GetChatUsers(mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID")));
+
+ this->StartChat(targets);
+ }
+ break;
+
+ case BBB_ID_CONF_SPAWN:
if (this->IsOnline() && !this->IsChatRoom(hContact))
{
StringList targets;
@@ -124,6 +145,7 @@ int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam) this->StartChat(targets);
}
+ break;
}
return 1;
@@ -575,7 +597,22 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa conversation->GetPropIdentity(data);
mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
HANDLE hContact = this->GetChatRoomByCid(cid);
- this->RaiseChatEvent(cid, this->login, /*GC_EVENT_NOTICE*/ 0x0020, /*GCEF_ADDTOLOG*/ 0x0001, 0, NULL, ::TranslateT("There was incoming call"));
+ this->RaiseChatEvent(cid, this->login, /*GC_EVENT_INFORMATION*/ 0x0100, /*GCEF_ADDTOLOG*/ 0x0001, 0, NULL, ::TranslateT("Group call"));
+ }
+ break;
+
+ case CMessage::ENDED_LIVESESSION:
+
+ CConversation::TYPE type;
+ conversation->GetPropType(type);
+ if (type != CConversation::DIALOG)
+ {
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+ HANDLE hContact = this->GetChatRoomByCid(cid);
+ this->RaiseChatEvent(cid, this->login, /*GC_EVENT_INFORMATION*/ 0x0100, /*GCEF_ADDTOLOG*/ 0x0001, 0, NULL, ::TranslateT("The call is completed"));
}
break;
|