diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-05-06 15:11:20 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-05-06 15:11:20 +0000 |
commit | 14eec47b6101e1f96437f7bb1057ee04a3cc4f63 (patch) | |
tree | bf3d11b8902307da42674c38194fce35e8032958 /protocols/Skype | |
parent | c7a87b51ee671f7c5a1bbdd80e001a863f9e7215 (diff) |
- partly fixed chat reaction on incoming call
git-svn-id: http://svn.miranda-ng.org/main/trunk@4591 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype.h | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 55 | ||||
-rw-r--r-- | protocols/Skype/src/skype_hooks.cpp | 23 | ||||
-rw-r--r-- | protocols/Skype/src/skype_menus.cpp | 84 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 15 | ||||
-rw-r--r-- | protocols/Skype/src/skype_utils.cpp | 13 |
7 files changed, 108 insertions, 88 deletions
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index 3573740f4d..1dac385ea4 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -63,9 +63,9 @@ #define CMI_AUTH_REQUEST 1
#define CMI_AUTH_GRANT 2
-#define SMI_CHAT_INVOKE 0
+#define CMI_TEMS_COUNT 3
-#define CMITEMS_COUNT 3
+#define SMI_CHAT_INVITE 0
class CSkype;
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index 6935d107b6..dd45a37b42 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -508,8 +508,15 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa for (size_t i = 0; i < needToKick.size(); i++)
{
const wchar_t *sid = needToKick[i];
- if (::wcsicmp(sid, this->login) != 0 && !alreadyInChat.contains(sid))
+ if (::wcsicmp(sid, this->login) == 0)
+ {
+ HANDLE hContact = this->GetChatRoomByCid(cid);
+ this->ShowNotification(::TranslateT("You have been kicked from the chat room"), 0, hContact);
+ this->LeaveChat(cid);
+ }
+ else if ( !alreadyInChat.contains(sid))
this->KickChatContact(cid, sid);
+ ::mir_free(cid);
}
}
break;
@@ -531,26 +538,42 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa case CMessage::STARTED_LIVESESSION:
conversation->LeaveLiveSession();
- uint timestamp;
- message->GetPropTimestamp(timestamp);
+ CConversation::TYPE type;
+ conversation->GetPropType(type);
+ if (type == CConversation::DIALOG)
+ {
- SEString identity;
- message->GetPropAuthor(identity);
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
- CContact::Ref author;
- g_skype->GetContact(identity, author);
+ SEString identity;
+ message->GetPropAuthor(identity);
- HANDLE hContact = this->AddContact(author);
+ CContact::Ref author;
+ g_skype->GetContact(identity, author);
+
+ HANDLE hContact = this->AddContact(author);
- char *message = ::mir_utf8encode(Translate("Incoming call"));
+ char *message = ::mir_utf8encode(::Translate("Incoming call"));
- this->AddDBEvent(
- hContact,
- SKYPE_DB_EVENT_TYPE_CALL,
- timestamp,
- DBEF_UTF,
- (DWORD)::strlen(message) + 1,
- (PBYTE)message);
+ this->AddDBEvent(
+ hContact,
+ SKYPE_DB_EVENT_TYPE_CALL,
+ timestamp,
+ DBEF_UTF,
+ (DWORD)::strlen(message) + 1,
+ (PBYTE)message);
+ }
+ else
+ {
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ 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"));
+ ::mir_free(cid);
+ }
break;
//case CMessage::REQUESTED_AUTH:
diff --git a/protocols/Skype/src/skype_hooks.cpp b/protocols/Skype/src/skype_hooks.cpp index 07ad8d2dc9..42155750c9 100644 --- a/protocols/Skype/src/skype_hooks.cpp +++ b/protocols/Skype/src/skype_hooks.cpp @@ -11,29 +11,28 @@ void CSkypeProto::InitHookList() void CSkypeProto::UninitHookList()
{
for (int i = 0; i < CSkypeProto::hookList.getCount(); i++)
- {
::UnhookEvent(CSkypeProto::hookList[i]);
- }
+}
+
+HANDLE CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler)
+{
+ HANDLE hook = ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
+ this->instanceHookList.insert(hook);
+ return hook;
}
void CSkypeProto::InitInstanceHookList()
{
- this->instanceHookList.insert(
- this->HookEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit));
- this->instanceHookList.insert(
- this->HookEvent(ME_USERINFO_INITIALISE, &CSkypeProto::OnUserInfoInit));
+ this->HookEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
+ this->HookEvent(ME_USERINFO_INITIALISE, &CSkypeProto::OnUserInfoInit);
- this->instanceHookList.insert(
- this->HookEvent(ME_MSG_PRECREATEEVENT, &CSkypeProto::OnMessagePreCreate));
+ this->HookEvent(ME_MSG_PRECREATEEVENT, &CSkypeProto::OnMessagePreCreate);
- this->instanceHookList.insert(
- this->HookEvent(ME_MSG_BUTTONPRESSED, &CSkypeProto::OnTabSRMMButtonPressed));
+ this->HookEvent(ME_MSG_BUTTONPRESSED, &CSkypeProto::OnTabSRMMButtonPressed);
}
void CSkypeProto::UninitInstanceHookList()
{
for (int i = 0; i < this->instanceHookList.getCount(); i++)
- {
::UnhookEvent(this->instanceHookList[i]);
- }
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index 4a117ffd37..db0cb991a3 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -1,9 +1,8 @@ #include "skype_proto.h"
HANDLE CSkypeProto::hChooserMenu;
-HANDLE CSkypeProto::hPrebuildMenuHook;
-HANDLE CSkypeProto::g_hContactMenuSvc[CMITEMS_COUNT];
-HANDLE CSkypeProto::g_hContactMenuItems[CMITEMS_COUNT];
+HANDLE CSkypeProto::contactMenuItems[CMI_TEMS_COUNT];
+HANDLE CSkypeProto::contactMenuServices[CMI_TEMS_COUNT];
INT_PTR CSkypeProto::MenuChooseService(WPARAM wParam, LPARAM lParam)
{
@@ -13,7 +12,7 @@ INT_PTR CSkypeProto::MenuChooseService(WPARAM wParam, LPARAM lParam) return 0;
}
-static void sttEnableMenuItem(HANDLE hMenuItem, BOOL bEnable)
+void CSkypeProto::EnableMenuItem(HANDLE hMenuItem, BOOL bEnable)
{
CLISTMENUITEM clmi = {0};
clmi.cbSize = sizeof(CLISTMENUITEM);
@@ -21,7 +20,7 @@ static void sttEnableMenuItem(HANDLE hMenuItem, BOOL bEnable) if (!bEnable)
clmi.flags |= CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem, (LPARAM)&clmi);
+ ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem, (LPARAM)&clmi);
}
int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
@@ -31,16 +30,16 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) if (hContact == NULL)
return 0;
- if (this->IsOnline() && !::db_get_b(hContact, this->m_szModuleName, "ChatRoom", 0))
+ if (this->IsOnline() && !this->IsChatRoom(hContact))
{
- bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool ctrlPressed = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
bool authNeed = ::db_get_b(hContact, this->m_szModuleName, "Auth", 0) > 0;
bool grantNeed = ::db_get_b(hContact, this->m_szModuleName, "Grant", 0) > 0;
- sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed);
- sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed);
- sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed));
+ CSkypeProto::EnableMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed);
+ CSkypeProto::EnableMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed);
+ CSkypeProto::EnableMenuItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed));
}
return 0;
@@ -48,27 +47,27 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) CSkypeProto* CSkypeProto::GetInstanceByHContact(HANDLE hContact)
{
- char* proto = (char*)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ char *proto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
if (proto == NULL)
return NULL;
for (int i = 0; i < CSkypeProto::instanceList.getCount(); i++)
- if (!strcmp(proto, CSkypeProto::instanceList[i]->m_szModuleName))
+ if ( !::strcmp(proto, CSkypeProto::instanceList[i]->m_szModuleName))
return CSkypeProto::instanceList[i];
return NULL;
}
-template<int (__cdecl CSkypeProto::*Scn)(WPARAM, LPARAM)>
+template<int (__cdecl CSkypeProto::*Service)(WPARAM, LPARAM)>
INT_PTR GlobalService(WPARAM wParam, LPARAM lParam)
{
CSkypeProto *ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam);
- return ppro ? (ppro->*Scn)(wParam, lParam) : 0;
+ return ppro ? (ppro->*Service)(wParam, lParam) : 0;
}
int CSkypeProto::RequestAuth(WPARAM wParam, LPARAM lParam)
{
- // todo: set default auth request
return this->AuthRequest((HANDLE)wParam, LPGENT("Hi! I\'d like to add you to my contact list"));
}
@@ -115,10 +114,8 @@ INT_PTR CSkypeProto::InviteCommand(WPARAM, LPARAM) int CSkypeProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
- for (size_t i=0; i<SIZEOF(g_hContactMenuItems); i++)
- {
- sttEnableMenuItem(g_hContactMenuItems[i], false);
- }
+ for (size_t i = 0; i < SIZEOF(CSkypeProto::contactMenuItems); i++)
+ CSkypeProto::EnableMenuItem(CSkypeProto::contactMenuItems[i], false);
CSkypeProto* ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam);
return (ppro) ? ppro->OnPrebuildContactMenu(wParam, lParam) : 0;
@@ -137,36 +134,35 @@ void CSkypeProto::InitMenus() CLISTMENUITEM mi = { 0 };
mi.cbSize = sizeof(CLISTMENUITEM);
+ mi.flags = CMIF_TCHAR;
+
+ // "Revoke authorization"
+ mi.pszService = "Skype/RevokeAuth";
+ mi.ptszName = LPGENT("Revoke authorization");
+ mi.position = -2000001000 - CMI_AUTH_REVOKE;
+ mi.icolibItem = CSkypeProto::GetIconHandle("authRevoke");
+ CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE] = ::Menu_AddContactMenuItem(&mi);
+ CSkypeProto::contactMenuServices[CMI_AUTH_REVOKE] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RevokeAuth>);
// "Request authorization"
+ mi.pszService = "Skype/RequestAuth";
mi.ptszName = LPGENT("Request authorization");
- mi.flags = CMIF_TCHAR;
- mi.position = -2000001000;
+ mi.position = -2000001000 - CMI_AUTH_REQUEST;
mi.icolibItem = CSkypeProto::GetIconHandle("authRequest");
- mi.pszService = "Skype/ReqAuth";
- g_hContactMenuItems[CMI_AUTH_REQUEST] = ::Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_REQUEST] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RequestAuth>);
+ CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST] = ::Menu_AddContactMenuItem(&mi);
+ CSkypeProto::contactMenuServices[CMI_AUTH_REQUEST] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RequestAuth>);
// "Grant authorization"
mi.pszService = "Skype/GrantAuth";
mi.ptszName = LPGENT("Grant authorization");
- mi.position = -2000001001;
+ mi.position = -2000001000 - CMI_AUTH_GRANT;
mi.icolibItem = CSkypeProto::GetIconHandle("authGrant");
- g_hContactMenuItems[CMI_AUTH_GRANT] = ::Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_GRANT] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GrantAuth>);
-
- // Revoke auth
- mi.pszService = "Skype/RevokeAuth";
- mi.ptszName = LPGENT("Revoke authorization");
- mi.position = -2000001002;
- mi.icolibItem = CSkypeProto::GetIconHandle("authRevoke");
- g_hContactMenuItems[CMI_AUTH_REVOKE] = ::Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_REVOKE] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RevokeAuth>);
+ CSkypeProto::contactMenuItems[CMI_AUTH_GRANT] = ::Menu_AddContactMenuItem(&mi);
+ CSkypeProto::contactMenuServices[CMI_AUTH_GRANT] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GrantAuth>);
}
void CSkypeProto::UninitMenus()
{
- //::UnhookEvent(CSkypeProto::hPrebuildMenuHook);
}
void CSkypeProto::OnInitStatusMenu()
@@ -178,29 +174,31 @@ void CSkypeProto::OnInitStatusMenu() CLISTMENUITEM mi = { sizeof(mi) };
mi.pszService = text;
- HGENMENU hJabberRoot = ::MO_GetProtoRootMenu(m_szModuleName);
- if (hJabberRoot == NULL) {
+ HGENMENU hSkypeRoot = ::MO_GetProtoRootMenu(m_szModuleName);
+ if (!hSkypeRoot)
+ {
mi.ptszName = m_tszUserName;
mi.position = -1999901006;
mi.hParentMenu = HGENMENU_ROOT;
mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
mi.icolibItem = CSkypeProto::GetIconHandle("main");
- hJabberRoot = m_hMenuRoot = ::Menu_AddProtoMenuItem(&mi);
+ hSkypeRoot = m_hMenuRoot = ::Menu_AddProtoMenuItem(&mi);
}
- else {
+ else
+ {
if (m_hMenuRoot)
::CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)m_hMenuRoot, 0);
m_hMenuRoot = NULL;
}
- mi.hParentMenu = hJabberRoot;
+ mi.hParentMenu = hSkypeRoot;
mi.flags = CMIF_CHILDPOPUP | CMIF_TCHAR;
// Invite Command
- strcpy(tDest, "/InviteCommand");
+ ::strcpy(tDest, "/InviteCommand");
this->CreateServiceObj(tDest, &CSkypeProto::InviteCommand);
mi.ptszName = LPGENT("Invite to conference");
- mi.position = 200001;
+ mi.position = 200000 + SMI_CHAT_INVITE;
mi.icolibItem = CSkypeProto::GetIconHandle("confInvite");
::Menu_AddProtoMenuItem(&mi);
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index ccb5e43057..e0e7f1b74e 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -21,7 +21,7 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) : dbEventType.eventType = SKYPE_DB_EVENT_TYPE_CALL;
dbEventType.descr = "Skype call";
dbEventType.eventIcon = CSkypeProto::GetIconHandle("call");
- ::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+ ::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
this->InitInstanceServiceList();
}
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index d0326c03a8..8a610b3da0 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -371,7 +371,7 @@ protected: void CreateServiceObjParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam);
HANDLE CreateEvent(const char* szService);
- HANDLE HookEvent(const char*, SkypeEventFunc);
+
int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam);
int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
@@ -399,6 +399,9 @@ protected: static LIST<void> hookList;
LIST<void> instanceHookList;
+
+ HANDLE HookEvent(const char*, SkypeEventFunc);
+
void InitInstanceHookList();
void UninitInstanceHookList();
@@ -408,13 +411,15 @@ protected: // menu
HGENMENU m_hMenuRoot;
static HANDLE hChooserMenu;
- static HANDLE hPrebuildMenuHook;
- static HANDLE g_hContactMenuItems[CMITEMS_COUNT];
- static HANDLE g_hContactMenuSvc[CMITEMS_COUNT];
+ static HANDLE contactMenuItems[CMI_TEMS_COUNT];
+ static HANDLE contactMenuServices[CMI_TEMS_COUNT];
+
+ static void EnableMenuItem(HANDLE hMenuItem, BOOL bEnable);
+
static INT_PTR MenuChooseService(WPARAM wParam, LPARAM lParam);
+
int OnPrebuildContactMenu(WPARAM wParam, LPARAM);
-
// database
bool IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag = 0);
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index 4ad81024b3..26421f7e03 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -278,11 +278,6 @@ HANDLE CSkypeProto::CreateEvent(const char* szService) return ::CreateHookableEvent(moduleName);
}
-HANDLE CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler)
-{
- return ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
-}
-
void CSkypeProto::FakeAsync(void *param)
{
::Sleep(100);
@@ -378,11 +373,11 @@ void CSkypeProto::ShowNotification(const wchar_t *caption, const wchar_t *messag {
POPUPDATAW ppd = {0};
ppd.lchContact = hContact;
- if (!hContact)
+ //if (!hContact)
{
- lstrcpyn(ppd.lpwzContactName, caption, MAX_CONTACTNAME);
+ ::wcsncpy(ppd.lpwzContactName, caption, MAX_CONTACTNAME);
}
- lstrcpyn(ppd.lpwzText, message, MAX_SECONDLINE);
+ ::wcsncpy(ppd.lpwzText, message, MAX_SECONDLINE);
ppd.lchIcon = ::Skin_GetIcon("Skype_main");
PUAddPopUpW(&ppd);
@@ -391,7 +386,7 @@ void CSkypeProto::ShowNotification(const wchar_t *caption, const wchar_t *messag void CSkypeProto::ShowNotification(const wchar_t *message, int flags, HANDLE hContact)
{
- CSkypeProto::ShowNotification(TranslateT("Skype Protocol"), message, flags, hContact);
+ CSkypeProto::ShowNotification(::TranslateT(MODULE), message, flags, hContact);
}
char *CSkypeProto::RemoveHtml(const char *text)
|