diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2012-10-24 18:32:11 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2012-10-24 18:32:11 +0000 |
commit | 38ce5b30b86aa7ae479713426d7a5a4f6fb0f619 (patch) | |
tree | 6bd71ddc0ead9327eba5a1eccb8acc1373e4c227 /protocols | |
parent | 5ca299a56b6cc35845d0480e6a3f9862e1f36f10 (diff) |
fixed auth menu creation
git-svn-id: http://svn.miranda-ng.org/main/trunk@2066 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Skype/src/skype_menus.cpp | 54 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 34 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 4 |
3 files changed, 52 insertions, 40 deletions
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index 7e92097b06..58a6b603bc 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -36,22 +36,52 @@ CSkypeProto* CSkypeProto::GetInstanceByHContact(HANDLE hContact) return NULL;
}
-INT_PTR SkypeMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam)
+template<int (__cdecl CSkypeProto::*Scn)(WPARAM, LPARAM)>
+INT_PTR GlobalService(WPARAM wParam, LPARAM lParam)
{
- CSkypeProto* ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam);
- return(ppro) ? ppro->OnMenuHandleRequestAuth(wParam, lParam) : 0;
+ CSkypeProto *ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam);
+ return ppro ? (ppro->*Scn)(wParam, lParam) : 0;
}
-INT_PTR SkypeMenuHandleGrantAuth(WPARAM wParam, LPARAM lParam)
+int CSkypeProto::RequestAuth(WPARAM wParam, LPARAM lParam)
{
- CSkypeProto* ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam);
- return(ppro) ? ppro->OnMenuHandleGrantAuth(wParam, lParam) : 0;
+ if (this->IsOnline() && wParam)
+ {
+ HANDLE hContact = (HANDLE)wParam;
+ TCHAR* szMessage = (TCHAR*)lParam;
+ CContact::Ref contact;
+ SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
+ g_skype->GetContact(sid, contact);
+
+ contact->SendAuthRequest(::mir_u2a(szMessage));
+ this->DeleteSetting(hContact, "Grant");
+
+ return 0;
+ }
+
+ return 1;
}
-INT_PTR SkypeMenuRevokeAuth(WPARAM wParam, LPARAM lParam)
+int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam)
{
- CSkypeProto* ppro = CSkypeProto::GetInstanceByHContact((HANDLE)wParam);
- return(ppro) ? ppro->OnMenuRevokeAuth(wParam, lParam) : 0;
+ CContact::Ref contact;
+ HANDLE hContact = (HANDLE)wParam;
+ SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
+ g_skype->GetContact(sid, contact);
+ contact->SetBuddyStatus(true/*Contact::AUTHORIZED_BY_ME*/);
+
+ return 0;
+}
+
+int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam)
+{
+ CContact::Ref contact;
+ HANDLE hContact = (HANDLE)wParam;
+ SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
+ g_skype->GetContact(sid, contact);
+ contact->SetBuddyStatus(false/*CContact::BLOCKED_BY_ME*/);
+
+ return 0;
}
static void sttEnableMenuItem(HANDLE hMenuItem, BOOL bEnable)
@@ -109,7 +139,7 @@ void CSkypeProto::InitMenus() mi.icolibItem = CSkypeProto::GetIconHandle("authReuest");
mi.pszService = "Skype/ReqAuth";
g_hContactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_REQUEST] = CreateServiceFunction(mi.pszService, SkypeMenuHandleRequestAuth);
+ g_hContactMenuSvc[CMI_AUTH_REQUEST] = CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RequestAuth>);
// "Grant authorization"
mi.pszService = "Skype/GrantAuth";
@@ -117,7 +147,7 @@ void CSkypeProto::InitMenus() mi.position = -2000001001;
mi.icolibItem = CSkypeProto::GetIconHandle("authGrant");
g_hContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_GRANT] = CreateServiceFunction(mi.pszService, SkypeMenuHandleGrantAuth);
+ g_hContactMenuSvc[CMI_AUTH_GRANT] = CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GrantAuth>);
// Revoke auth
mi.pszService = "Skype/RevokeAuth";
@@ -125,7 +155,7 @@ void CSkypeProto::InitMenus() mi.position = -2000001002;
mi.icolibItem = CSkypeProto::GetIconHandle("authRevoke");
g_hContactMenuItems[CMI_AUTH_REVOKE] = Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_REVOKE] = CreateServiceFunction(mi.pszService, SkypeMenuRevokeAuth);
+ g_hContactMenuSvc[CMI_AUTH_REVOKE] = CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RevokeAuth>);
}
void CSkypeProto::UninitMenus()
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 3b6ee25f25..750ea27a12 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -67,38 +67,28 @@ HANDLE __cdecl CSkypeProto::AddToListByEvent(int flags, int iContact, HANDLE hDb }
int __cdecl CSkypeProto::Authorize(HANDLE hDbEvent)
-{
+{
if (this->IsOnline() && hDbEvent)
{
HANDLE hContact = this->GetContactFromAuthEvent(hDbEvent);
if (hContact == INVALID_HANDLE_VALUE)
return 1;
- CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- g_skype->GetContact(sid, contact);
- contact->SetBuddyStatus(true/*Contact::AUTHORIZED_BY_ME*/);
-
- return 0;
+ return CSkypeProto::GrantAuth((WPARAM)hContact, NULL);
}
return 1;
}
int __cdecl CSkypeProto::AuthDeny(HANDLE hDbEvent, const TCHAR* szReason)
-{
+{
if (this->IsOnline())
{
HANDLE hContact = this->GetContactFromAuthEvent(hDbEvent);
if (hContact == INVALID_HANDLE_VALUE)
return 1;
- CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- g_skype->GetContact(sid, contact);
- contact->SetBuddyStatus(false/*CContact::BLOCKED_BY_ME*/);
-
- return 0;
+ return CSkypeProto::RevokeAuth((WPARAM)hContact, NULL);
}
return 1;
@@ -126,20 +116,8 @@ int __cdecl CSkypeProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* pre) }
int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
-{
- if (this->IsOnline() && hContact)
- {
- CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- g_skype->GetContact(sid, contact);
-
- contact->SendAuthRequest(::mir_u2a(szMessage));
- this->DeleteSetting(hContact, "Grant");
-
- return 0;
- }
-
- return 1;
+{
+ return CSkypeProto::RequestAuth((WPARAM)hContact, (LPARAM)szMessage);
}
HANDLE __cdecl CSkypeProto::ChangeInfo( int iInfoType, void* pInfoData ) { return 0; }
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 9bedb853a8..6337a39b05 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -78,6 +78,10 @@ public: virtual int __cdecl OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam );
+ virtual int __cdecl RequestAuth(WPARAM, LPARAM);
+ virtual int __cdecl GrantAuth(WPARAM, LPARAM);
+ virtual int __cdecl RevokeAuth(WPARAM, LPARAM);
+
// events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
int __cdecl OnPreShutdown(WPARAM, LPARAM);
|