diff options
29 files changed, 180 insertions, 292 deletions
diff --git a/include/m_icq.h b/include/m_icq.h index b268f2466e..01d5e08b65 100644 --- a/include/m_icq.h +++ b/include/m_icq.h @@ -46,18 +46,6 @@ typedef struct { } ICQSEARCHRESULT;
-// Request authorization
-// wParam = (WPARAM)hContact
-#define MS_REQ_AUTH "/ReqAuth"
-
-// Grant authorization
-// wParam = (WPARAM)hContact;
-#define MS_GRANT_AUTH "/GrantAuth"
-
-// Revoke authorization
-// wParam = (WPARAM)hContact
-#define MS_REVOKE_AUTH "/RevokeAuth"
-
// Open ICQ profile
// wParam = (WPARAM)hContact
#define MS_OPEN_PROFILE "/OpenProfile"
diff --git a/include/m_protoint.h b/include/m_protoint.h index d105f55862..5a7e115a74 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -95,7 +95,10 @@ public: char* m_szModuleName; // internal protocol name, also its database module name
HANDLE m_hProtoIcon; // icon to be displayed in the account manager
HNETLIBUSER m_hNetlibUser; // network agent
- HGENMENU m_hMainMenuItem; // if protocol menus are displayed in the main menu, this is the root
+ HGENMENU m_hmiMainMenu; // if protocol menus are displayed in the main menu, this is the root
+ HGENMENU m_hmiReqAuth; // a menu item for /RequestAuth service
+ HGENMENU m_hmiGrantAuth; // a menu item for /GrantAuth service
+ HGENMENU m_hmiRevokeAuth; // a menu item for /RevokeAuth service
PROTO_INTERFACE(const char *pszModuleName, const wchar_t *ptszUserName);
~PROTO_INTERFACE();
diff --git a/include/m_protosvc.h b/include/m_protosvc.h index e376c3d4ab..723b7260ae 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -575,6 +575,27 @@ struct PROTOFILERESUME #define PS_GETUNREADEMAILCOUNT "/GetUnreadEmailCount"
///////////////////////////////////////////////////////////////////////////////
+// Gets called when a user clicks the "Request auth" menu item
+// wParam = hContact
+// lParam = 0
+
+#define PS_MENU_REQAUTH "/ReqAuth"
+
+///////////////////////////////////////////////////////////////////////////////
+// Gets called when a user clicks the "Grant auth" menu item
+// wParam = hContact
+// lParam = 0
+
+#define PS_MENU_GRANTAUTH "/GrantAuth"
+
+///////////////////////////////////////////////////////////////////////////////
+// Gets called when a user clicks the "Revoke auth" menu item
+// wParam = hContact
+// lParam = 0
+
+#define PS_MENU_REVOKEAUTH "/RevokeAuth"
+
+///////////////////////////////////////////////////////////////////////////////
// SENDING SERVICES
// these should be called with CallContactService()
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index be0f917120..b40314a8e3 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -57,6 +57,10 @@ FacebookProto::FacebookProto(const char* proto_name, const wchar_t* username) : CreateProtoService(PS_JOINCHAT, &FacebookProto::OnJoinChat); CreateProtoService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat); + CreateProtoService(PS_MENU_REQAUTH, &FacebookProto::RequestFriendship); + CreateProtoService(PS_MENU_GRANTAUTH, &FacebookProto::ApproveFriendship); + CreateProtoService(PS_MENU_REVOKEAUTH, &FacebookProto::CancelFriendship); + HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu); HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit); HookProtoEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged); @@ -769,13 +773,11 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam) return 0; } -INT_PTR FacebookProto::RequestFriendship(WPARAM wParam, LPARAM) +INT_PTR FacebookProto::RequestFriendship(WPARAM hContact, LPARAM) { - if (wParam == 0 || isOffline()) + if (hContact == 0 || isOffline()) return 1; - MCONTACT hContact = MCONTACT(wParam); - ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id == nullptr) return 1; @@ -784,23 +786,21 @@ INT_PTR FacebookProto::RequestFriendship(WPARAM wParam, LPARAM) return 0; } -INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam, LPARAM) +INT_PTR FacebookProto::ApproveFriendship(WPARAM hContact, LPARAM) { - if (wParam == 0 || isOffline()) + if (hContact == 0 || isOffline()) return 1; - MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); - ForkThread(&FacebookProto::ApproveContactToServer, hContact); + ForkThread(&FacebookProto::ApproveContactToServer, new MCONTACT(hContact)); return 0; } -INT_PTR FacebookProto::DenyFriendship(WPARAM wParam, LPARAM) +INT_PTR FacebookProto::DenyFriendship(WPARAM hContact, LPARAM) { - if (wParam == 0 || isOffline()) + if (hContact == 0 || isOffline()) return 1; - MCONTACT *hContact = new MCONTACT((MCONTACT)wParam); - ForkThread(&FacebookProto::IgnoreFriendshipRequest, hContact); + ForkThread(&FacebookProto::IgnoreFriendshipRequest, new MCONTACT(hContact)); return 0; } diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp index 91466a877f..70c0835308 100644 --- a/protocols/FacebookRM/src/theme.cpp +++ b/protocols/FacebookRM/src/theme.cpp @@ -27,9 +27,6 @@ extern OBJLIST<FacebookProto> g_Instances; // Contact menu items
HGENMENU g_hContactMenuVisitProfile;
HGENMENU g_hContactMenuVisitFriendship;
-HGENMENU g_hContactMenuAuthRevoke;
-HGENMENU g_hContactMenuAuthAsk;
-HGENMENU g_hContactMenuAuthGrant;
HGENMENU g_hContactMenuAuthCancel;
HGENMENU g_hContactMenuAuthDeny;
HGENMENU g_hContactMenuPoke;
@@ -97,9 +94,6 @@ static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) // Hide our all contact menu items first
Menu_ShowItem(g_hContactMenuVisitProfile, false);
Menu_ShowItem(g_hContactMenuVisitFriendship, false);
- Menu_ShowItem(g_hContactMenuAuthRevoke, false);
- Menu_ShowItem(g_hContactMenuAuthAsk, false);
- Menu_ShowItem(g_hContactMenuAuthGrant, false);
Menu_ShowItem(g_hContactMenuAuthCancel, false);
Menu_ShowItem(g_hContactMenuAuthDeny, false);
Menu_ShowItem(g_hContactMenuPoke, false);
@@ -166,14 +160,6 @@ void InitContactMenus() CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::LoadHistory>);
g_hContactMenuLoadHistory = Menu_AddContactMenuItem(&mi);
- SET_UID(mi, 0x619efdcb, 0x99c0, 0x44a8, 0xbf, 0x28, 0xc3, 0xe0, 0x2f, 0xb3, 0x7e, 0x77);
- mi.position = -2000006010;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE);
- mi.name.a = LPGEN("Cancel friendship");
- mi.pszService = "FacebookProto/CancelFriendship";
- CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::CancelFriendship>);
- g_hContactMenuAuthRevoke = Menu_AddContactMenuItem(&mi);
-
SET_UID(mi, 0x6d6b49b9, 0x71b8, 0x4a57, 0xab, 0x80, 0xc3, 0xb2, 0xbe, 0x2b, 0x9b, 0xf5);
mi.position = -2000006011;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE);
@@ -181,23 +167,6 @@ void InitContactMenus() mi.pszService = "FacebookProto/CancelFriendshipRequest";
CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::OnCancelFriendshipRequest>);
g_hContactMenuAuthCancel = Menu_AddContactMenuItem(&mi);
-
- SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
- mi.position = -2000006012;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
- mi.name.a = LPGEN("Request friendship");
- mi.pszService = "FacebookProto/RequestFriendship";
- CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::RequestFriendship>);
- g_hContactMenuAuthAsk = Menu_AddContactMenuItem(&mi);
-
- SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30);
- mi.position = -2000006013;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_GRANT);
- mi.name.a = LPGEN("Approve friendship");
- mi.pszService = "FacebookProto/ApproveFriendship";
- CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::ApproveFriendship>);
- g_hContactMenuAuthGrant = Menu_AddContactMenuItem(&mi);
-
SET_UID(mi, 0x29d0a371, 0xb8a7, 0x4fb2, 0x91, 0x10, 0x13, 0x6f, 0x8c, 0x5f, 0xb5, 0x7);
mi.position = -2000006014;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE);
@@ -225,12 +194,12 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) if (!isOffline() && !bIsChatroom && !bIsPage) {
bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- Menu_ShowItem(g_hContactMenuAuthAsk, ctrlPressed || type == CONTACT_NONE || !type);
- Menu_ShowItem(g_hContactMenuAuthGrant, ctrlPressed || type == CONTACT_APPROVE);
- Menu_ShowItem(g_hContactMenuAuthDeny, ctrlPressed || type == CONTACT_APPROVE);
- Menu_ShowItem(g_hContactMenuAuthRevoke, ctrlPressed || type == CONTACT_FRIEND);
- Menu_ShowItem(g_hContactMenuAuthCancel, ctrlPressed || type == CONTACT_REQUEST);
+ Menu_ShowItem(m_hmiReqAuth, ctrlPressed || type == CONTACT_NONE || !type);
+ Menu_ShowItem(m_hmiGrantAuth, ctrlPressed || type == CONTACT_APPROVE);
+ Menu_ShowItem(m_hmiRevokeAuth, ctrlPressed || type == CONTACT_FRIEND);
+ Menu_ShowItem(g_hContactMenuAuthCancel, ctrlPressed || type == CONTACT_REQUEST);
+ Menu_ShowItem(g_hContactMenuAuthDeny, ctrlPressed || type == CONTACT_APPROVE);
Menu_ShowItem(g_hContactMenuPoke, true);
}
@@ -299,7 +268,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM, LPARAM) void FacebookProto::ToggleStatusMenuItems(bool bEnable)
{
- Menu_EnableItem(m_hMainMenuItem, bEnable);
+ Menu_EnableItem(m_hmiMainMenu, bEnable);
Menu_EnableItem(m_hStatusMind, bEnable);
Menu_EnableItem(m_hMenuServicesRoot, bEnable);
}
diff --git a/protocols/IcqOscarJ/src/changeinfo.h b/protocols/IcqOscarJ/src/changeinfo.h index d3b25626c5..4c90b617f4 100644 --- a/protocols/IcqOscarJ/src/changeinfo.h +++ b/protocols/IcqOscarJ/src/changeinfo.h @@ -96,7 +96,7 @@ struct ChangeInfoData : public MZeroedObject void FreeStoredDbSettings(void);
int ChangesMade(void);
void ClearChangeFlags(void);
- int SaveSettingsToDb(HWND hwndDlg);
+ int SaveSettingsToDb(void);
//upload.cpp
int UploadSettings(void);
diff --git a/protocols/IcqOscarJ/src/db.cpp b/protocols/IcqOscarJ/src/db.cpp index 06063b0302..5daf759ed6 100644 --- a/protocols/IcqOscarJ/src/db.cpp +++ b/protocols/IcqOscarJ/src/db.cpp @@ -162,7 +162,7 @@ static INT_PTR CALLBACK PwConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, return FALSE;
}
-int ChangeInfoData::SaveSettingsToDb(HWND hwnd)
+int ChangeInfoData::SaveSettingsToDb()
{
int ret = 1;
diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp index b754a2e5ab..992cbe8ad7 100644 --- a/protocols/IcqOscarJ/src/dlgproc.cpp +++ b/protocols/IcqOscarJ/src/dlgproc.cpp @@ -416,7 +416,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break;
case IDC_SAVE:
- if (!dat->SaveSettingsToDb(hwndDlg))
+ if (!dat->SaveSettingsToDb())
break;
EnableDlgItem(hwndDlg, IDC_SAVE, FALSE);
diff --git a/protocols/IcqOscarJ/src/icq_constants.h b/protocols/IcqOscarJ/src/icq_constants.h index 4b806fa6af..c03a6ec2cd 100644 --- a/protocols/IcqOscarJ/src/icq_constants.h +++ b/protocols/IcqOscarJ/src/icq_constants.h @@ -41,12 +41,9 @@ #define ISI_ADD_TO_SERVLIST 3
/* Contact menu item indexes */
-#define ICMI_AUTH_REQUEST 0
-#define ICMI_AUTH_GRANT 1
-#define ICMI_AUTH_REVOKE 2
-#define ICMI_ADD_TO_SERVLIST 3
-#define ICMI_XSTATUS_DETAILS 4
-#define ICMI_OPEN_PROFILE 5
+#define ICMI_ADD_TO_SERVLIST 0
+#define ICMI_XSTATUS_DETAILS 1
+#define ICMI_OPEN_PROFILE 2
/* Some default settings */
#define DEFAULT_SERVER_PORT 5190
diff --git a/protocols/IcqOscarJ/src/icq_menu.cpp b/protocols/IcqOscarJ/src/icq_menu.cpp index 65c0ea5bb9..f4450d0095 100644 --- a/protocols/IcqOscarJ/src/icq_menu.cpp +++ b/protocols/IcqOscarJ/src/icq_menu.cpp @@ -27,8 +27,8 @@ #include <m_skin.h>
-HGENMENU g_hContactMenuItems[6];
-HANDLE g_hContactMenuSvc[6];
+HGENMENU g_hContactMenuItems[3];
+HANDLE g_hContactMenuSvc[3];
static int sttCompareProtocols(const CIcqProto *p1, const CIcqProto *p2)
{
@@ -50,24 +50,6 @@ static CIcqProto* IcqGetInstanceByHContact(MCONTACT hContact) return nullptr;
}
-static INT_PTR IcqMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam)
-{
- CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
- return (ppro) ? ppro->RequestAuthorization(wParam, lParam) : 0;
-}
-
-static INT_PTR IcqMenuHandleGrantAuth(WPARAM wParam, LPARAM lParam)
-{
- CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
- return (ppro) ? ppro->GrantAuthorization(wParam, lParam) : 0;
-}
-
-static INT_PTR IcqMenuHandleRevokeAuth(WPARAM wParam, LPARAM lParam)
-{
- CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
- return (ppro) ? ppro->RevokeAuthorization(wParam, lParam) : 0;
-}
-
static INT_PTR IcqMenuHandleAddServContact(WPARAM wParam, LPARAM lParam)
{
CIcqProto* ppro = IcqGetInstanceByHContact(wParam);
@@ -88,9 +70,6 @@ static INT_PTR IcqMenuHandleOpenProfile(WPARAM wParam, LPARAM lParam) static int IcqPrebuildContactMenu( WPARAM wParam, LPARAM lParam )
{
- Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_REQUEST], FALSE);
- Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_GRANT], FALSE);
- Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_REVOKE], FALSE);
Menu_ShowItem(g_hContactMenuItems[ICMI_ADD_TO_SERVLIST], FALSE);
Menu_ShowItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS], FALSE);
Menu_ShowItem(g_hContactMenuItems[ICMI_OPEN_PROFILE], FALSE);
@@ -113,30 +92,6 @@ void g_MenuInit(void) CMenuItem mi;
mi.pszService = str;
-
- // "Request authorization"
- mir_strcpy(pszDest, MS_REQ_AUTH); CreateServiceFunction(str, IcqMenuHandleRequestAuth );
- SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
- mi.name.a = LPGEN("Request authorization");
- mi.position = 1000030000;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
- g_hContactMenuItems[ICMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
-
- // "Grant authorization"
- mir_strcpy(pszDest, MS_GRANT_AUTH); CreateServiceFunction(str, IcqMenuHandleGrantAuth);
- SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30);
- mi.name.a = LPGEN("Grant authorization");
- mi.position = 1000029999;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_GRANT);
- g_hContactMenuItems[ICMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
-
- // "Revoke authorization"
- mir_strcpy(pszDest, MS_REVOKE_AUTH); CreateServiceFunction(str, IcqMenuHandleRevokeAuth);
- SET_UID(mi, 0x619efdcb, 0x99c0, 0x44a8, 0xbf, 0x28, 0xc3, 0xe0, 0x2f, 0xb3, 0x7e, 0x77);
- mi.name.a = LPGEN("Revoke authorization");
- mi.position = 1000029998;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE);
- g_hContactMenuItems[ICMI_AUTH_REVOKE] = Menu_AddContactMenuItem(&mi);
// "Add to server list"
mir_strcpy(pszDest, MS_ICQ_ADDSERVCONTACT); CreateServiceFunction(str, IcqMenuHandleAddServContact);
@@ -164,9 +119,6 @@ void g_MenuInit(void) void g_MenuUninit(void)
{
- Menu_RemoveItem(g_hContactMenuItems[ICMI_AUTH_REQUEST]);
- Menu_RemoveItem(g_hContactMenuItems[ICMI_AUTH_GRANT]);
- Menu_RemoveItem(g_hContactMenuItems[ICMI_AUTH_REVOKE]);
Menu_RemoveItem(g_hContactMenuItems[ICMI_ADD_TO_SERVLIST]);
Menu_RemoveItem(g_hContactMenuItems[ICMI_XSTATUS_DETAILS]);
Menu_RemoveItem(g_hContactMenuItems[ICMI_OPEN_PROFILE]);
@@ -188,11 +140,10 @@ int CIcqProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM) DWORD dwUin = getContactUin(hContact);
- Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_REQUEST],
- dwUin && (bCtrlPressed || (getByte(hContact, "Auth", 0) && getWord(hContact, DBSETTING_SERVLIST_ID, 0))));
- Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_GRANT], dwUin && (bCtrlPressed || getByte(hContact, "Grant", 0)));
- Menu_ShowItem(g_hContactMenuItems[ICMI_AUTH_REVOKE],
- dwUin && (bCtrlPressed || (getByte("PrivacyItems", 0) && !getByte(hContact, "Grant", 0))));
+ Menu_ShowItem(m_hmiReqAuth, dwUin && (bCtrlPressed || (getByte(hContact, "Auth", 0) && getWord(hContact, DBSETTING_SERVLIST_ID, 0))));
+ Menu_ShowItem(m_hmiGrantAuth, dwUin && (bCtrlPressed || getByte(hContact, "Grant", 0)));
+ Menu_ShowItem(m_hmiRevokeAuth, dwUin && (bCtrlPressed || (getByte("PrivacyItems", 0) && !getByte(hContact, "Grant", 0))));
+
Menu_ShowItem(g_hContactMenuItems[ICMI_ADD_TO_SERVLIST],
m_bSsiEnabled && !getWord(hContact, DBSETTING_SERVLIST_ID, 0) &&
!getWord(hContact, DBSETTING_SERVLIST_IGNORE, 0) &&
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp index fb9a2928d6..8cc92b3f96 100644 --- a/protocols/IcqOscarJ/src/icq_proto.cpp +++ b/protocols/IcqOscarJ/src/icq_proto.cpp @@ -134,9 +134,9 @@ CIcqProto::CIcqProto(const char* aProtoName, const wchar_t* aUserName) : CreateProtoService(MS_ICQ_ADDSERVCONTACT, &CIcqProto::AddServerContact);
- CreateProtoService(MS_REQ_AUTH, &CIcqProto::RequestAuthorization);
- CreateProtoService(MS_GRANT_AUTH, &CIcqProto::GrantAuthorization);
- CreateProtoService(MS_REVOKE_AUTH, &CIcqProto::RevokeAuthorization);
+ CreateProtoService(PS_MENU_REQAUTH, &CIcqProto::RequestAuthorization);
+ CreateProtoService(PS_MENU_GRANTAUTH, &CIcqProto::GrantAuthorization);
+ CreateProtoService(PS_MENU_REVOKEAUTH, &CIcqProto::RevokeAuthorization);
CreateProtoService(MS_XSTATUS_SHOWDETAILS, &CIcqProto::ShowXStatusDetails);
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index d39685912b..35d24eb16d 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -88,24 +88,6 @@ static CJabberProto* JabberGetInstanceByHContact(MCONTACT hContact) return nullptr;
}
-static INT_PTR JabberMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam)
-{
- CJabberProto *ppro = JabberGetInstanceByHContact(wParam);
- return(ppro) ? ppro->OnMenuHandleRequestAuth(wParam, lParam) : 0;
-}
-
-static INT_PTR JabberMenuHandleGrantAuth(WPARAM wParam, LPARAM lParam)
-{
- CJabberProto *ppro = JabberGetInstanceByHContact(wParam);
- return(ppro) ? ppro->OnMenuHandleGrantAuth(wParam, lParam) : 0;
-}
-
-static INT_PTR JabberMenuRevokeAuth(WPARAM wParam, LPARAM lParam)
-{
- CJabberProto *ppro = JabberGetInstanceByHContact(wParam);
- return(ppro) ? ppro->OnMenuRevokeAuth(wParam, lParam) : 0;
-}
-
static INT_PTR JabberMenuConvertChatContact(WPARAM wParam, LPARAM lParam)
{
CJabberProto *ppro = JabberGetInstanceByHContact(wParam);
@@ -202,33 +184,6 @@ void g_MenuInit(void) CMenuItem mi;
mi.flags = CMIF_UNMOVABLE;
- // "Request authorization"
- SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
- mi.name.a = LPGEN("Request authorization");
- mi.position = -2000001000;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
- mi.pszService = "Jabber/ReqAuth";
- g_hMenuRequestAuth = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, JabberMenuHandleRequestAuth);
-
- // "Grant authorization"
- SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30);
- mi.pszService = "Jabber/GrantAuth";
- mi.name.a = LPGEN("Grant authorization");
- mi.position = -2000001001;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_GRANT);
- g_hMenuGrantAuth = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, JabberMenuHandleGrantAuth);
-
- // Revoke auth
- SET_UID(mi, 0x619efdcb, 0x99c0, 0x44a8, 0xbf, 0x28, 0xc3, 0xe0, 0x2f, 0xb3, 0x7e, 0x77);
- mi.pszService = "Jabber/RevokeAuth";
- mi.name.a = LPGEN("Revoke authorization");
- mi.position = -2000001002;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE);
- g_hMenuRevokeAuth = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, JabberMenuRevokeAuth);
-
// "Convert Chat/Contact"
SET_UID(mi, 0xa98894ec, 0xbaa6, 0x4e1e, 0x8d, 0x75, 0x72, 0xc, 0xae, 0x25, 0xd8, 0x87);
mi.pszService = "Jabber/ConvertChatContact";
@@ -535,7 +490,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleGrantAuth(WPARAM hContact, LPARAM) return 0;
}
-INT_PTR __cdecl CJabberProto::OnMenuRevokeAuth(WPARAM hContact, LPARAM)
+INT_PTR __cdecl CJabberProto::OnMenuHandleRevokeAuth(WPARAM hContact, LPARAM)
{
if (hContact != 0 && m_bJabberOnline) {
ptrW jid(getWStringA(hContact, "jid"));
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index a360260186..38e378b18c 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -105,6 +105,10 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : CreateProtoService(PS_SETMYAVATAR, &CJabberProto::JabberSetAvatar);
CreateProtoService(PS_SETMYNICKNAME, &CJabberProto::JabberSetNickname);
+ CreateProtoService(PS_MENU_REQAUTH, &CJabberProto::OnMenuHandleRequestAuth);
+ CreateProtoService(PS_MENU_GRANTAUTH, &CJabberProto::OnMenuHandleGrantAuth);
+ CreateProtoService(PS_MENU_REVOKEAUTH, &CJabberProto::OnMenuHandleRevokeAuth);
+
CreateProtoService(JS_DB_GETEVENTTEXT_CHATSTATES, &CJabberProto::OnGetEventTextChatStates);
CreateProtoService(JS_DB_GETEVENTTEXT_PRESENCE, &CJabberProto::OnGetEventTextPresence);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 350b5e438c..718a788e1f 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -562,7 +562,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface INT_PTR __cdecl OnMenuTransportLogin(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnMenuTransportResolve(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnMenuBookmarkAdd(WPARAM wParam, LPARAM lParam);
- INT_PTR __cdecl OnMenuRevokeAuth(WPARAM wParam, LPARAM lParam);
+ INT_PTR __cdecl OnMenuHandleRevokeAuth(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl OnMenuHandleResource(WPARAM wParam, LPARAM lParam, LPARAM res);
INT_PTR __cdecl OnMenuHandleDirectPresence(WPARAM wParam, LPARAM lParam, LPARAM res);
INT_PTR __cdecl OnMenuSetPriority(WPARAM wParam, LPARAM lParam, LPARAM dwDelta);
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp index bcf3f98315..55c4a4288f 100644 --- a/protocols/SkypeWeb/src/skype_menus.cpp +++ b/protocols/SkypeWeb/src/skype_menus.cpp @@ -35,8 +35,9 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
bool isBlocked = getBool(hContact, "IsBlocked", false);
- Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
- Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
+ Menu_ShowItem(m_hmiReqAuth, isCtrlPressed || isAuthNeed);
+ Menu_ShowItem(m_hmiGrantAuth, isCtrlPressed || isGrantNeed);
+
Menu_ShowItem(ContactMenuItems[CMI_BLOCK], true);
Menu_ShowItem(ContactMenuItems[CMI_UNBLOCK], isCtrlPressed || isBlocked);
Menu_ShowItem(ContactMenuItems[CMI_GETSERVERHISTORY], true);
@@ -60,24 +61,6 @@ void CSkypeProto::InitMenus() CMenuItem mi;
mi.flags = CMIF_UNICODE;
- // Request authorization
- mi.pszService = MODULE"/RequestAuth";
- mi.name.w = LPGENW("Request authorization");
- mi.position = CMI_POSITION + CMI_AUTH_REQUEST;
- mi.hIcolibItem = ::Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
- SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
- ContactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::OnRequestAuth>);
-
- // Grant authorization
- mi.pszService = MODULE"/GrantAuth";
- mi.name.w = LPGENW("Grant authorization");
- mi.position = CMI_POSITION + CMI_AUTH_GRANT;
- mi.hIcolibItem = ::Skin_GetIconHandle(SKINICON_AUTH_GRANT);
- SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30);
- ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::OnGrantAuth>);
-
mi.pszService = MODULE"/GetHistory";
mi.name.w = LPGENW("Get server history");
mi.position = CMI_POSITION + CMI_GETSERVERHISTORY;
diff --git a/protocols/SkypeWeb/src/skype_menus.h b/protocols/SkypeWeb/src/skype_menus.h index 675be24f1d..6dbb857699 100644 --- a/protocols/SkypeWeb/src/skype_menus.h +++ b/protocols/SkypeWeb/src/skype_menus.h @@ -22,8 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. enum
{
- CMI_AUTH_REQUEST,
- CMI_AUTH_GRANT,
CMI_GETSERVERHISTORY,
CMI_BLOCK,
CMI_UNBLOCK,
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index d43e3cb012..3b665b3f0a 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -39,6 +39,9 @@ CSkypeProto::CSkypeProto(const char* protoName, const wchar_t* userName) : CreateProtoService(PS_GETMYAVATAR, &CSkypeProto::SvcGetMyAvatar); CreateProtoService(PS_SETMYAVATAR, &CSkypeProto::SvcSetMyAvatar); + CreateProtoService(PS_MENU_REQAUTH, &CSkypeProto::OnRequestAuth); + CreateProtoService(PS_MENU_GRANTAUTH, &CSkypeProto::OnGrantAuth); + CreateProtoService("/IncomingCallCLE", &CSkypeProto::OnIncomingCallCLE); CreateProtoService("/IncomingCallPP", &CSkypeProto::OnIncomingCallPP); diff --git a/protocols/Steam/src/steam_menus.cpp b/protocols/Steam/src/steam_menus.cpp index 2387f19f9d..5e0941a713 100644 --- a/protocols/Steam/src/steam_menus.cpp +++ b/protocols/Steam/src/steam_menus.cpp @@ -13,7 +13,6 @@ INT_PTR GlobalService(WPARAM wParam, LPARAM lParam) int CSteamProto::AuthRequestCommand(WPARAM hContact, LPARAM)
{
ProtoChainSend(hContact, PSS_AUTHREQUEST, 0, 0);
-
return 0;
}
@@ -94,8 +93,8 @@ int CSteamProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
bool authNeeded = getBool(hContact, "Auth", 0);
- Menu_ShowItem(contactMenuItems[CMI_AUTH_REQUEST], authNeeded || ctrlPressed);
- Menu_ShowItem(contactMenuItems[CMI_AUTH_REVOKE], !authNeeded || ctrlPressed);
+ Menu_ShowItem(m_hmiReqAuth, authNeeded || ctrlPressed);
+ Menu_ShowItem(m_hmiRevokeAuth, !authNeeded || ctrlPressed);
bool isBlocked = getBool(hContact, "Block", 0);
Menu_ShowItem(contactMenuItems[CMI_BLOCK], !isBlocked || ctrlPressed);
@@ -139,24 +138,6 @@ void CSteamProto::InitMenus() CMenuItem mi;
mi.flags = CMIF_UNICODE;
- // "Request authorization"
- SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
- mi.pszService = MODULE "/AuthRequest";
- mi.name.w = LPGENW("Request authorization");
- mi.position = -201001000 + CMI_AUTH_REQUEST;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
- contactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CSteamProto::AuthRequestCommand>);
-
- // "Revoke authorization"
- SET_UID(mi, 0x619efdcb, 0x99c0, 0x44a8, 0xbf, 0x28, 0xc3, 0xe0, 0x2f, 0xb3, 0x7e, 0x77);
- mi.pszService = MODULE "/RevokeAuth";
- mi.name.w = LPGENW("Revoke authorization");
- mi.position = -201001001 + CMI_AUTH_REVOKE;
- mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE);
- contactMenuItems[CMI_AUTH_REVOKE] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CSteamProto::AuthRevokeCommand>);
-
// "Block"
SET_UID(mi, 0xc6169b8f, 0x53ab, 0x4242, 0xbe, 0x90, 0xe2, 0x4a, 0xa5, 0x73, 0x88, 0x32);
mi.pszService = MODULE "/Block";
diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 586565c8cb..2a3b1dd732 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -63,6 +63,10 @@ CSteamProto::CSteamProto(const char* protoName, const wchar_t* userName) CreateProtoService(PS_GETCUSTOMSTATUSICON, &CSteamProto::OnGetXStatusIcon); CreateProtoService(PS_GETADVANCEDSTATUSICON, &CSteamProto::OnRequestAdvStatusIconIdx); + // menus + CreateProtoService(PS_MENU_REQAUTH, &CSteamProto::AuthRequestCommand); + CreateProtoService(PS_MENU_REVOKEAUTH, &CSteamProto::AuthRevokeCommand); + // custom db events API CreateProtoService(STEAM_DB_GETEVENTTEXT_CHATSTATES, &CSteamProto::OnGetEventTextChatStates); diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 2478eb3223..d37f35b071 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -19,13 +19,9 @@ struct STEAM_SEARCH_RESULT enum
{
- CMI_AUTH_REQUEST,
- //CMI_AUTH_GRANT,
- CMI_AUTH_REVOKE,
CMI_BLOCK,
CMI_UNBLOCK,
CMI_JOIN_GAME,
- //SMI_BLOCKED_LIST,
CMI_MAX // this item shall be the last one
};
@@ -59,25 +55,25 @@ public: ~CSteamProto();
// PROTO_INTERFACE
- virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT *psr);
+ virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT *psr);
- virtual int __cdecl Authorize(MEVENT hDbEvent);
+ virtual int __cdecl Authorize(MEVENT hDbEvent);
virtual int __cdecl AuthRecv(MCONTACT, PROTORECVEVENT*);
- virtual int __cdecl AuthDeny(MEVENT hDbEvent, const wchar_t *szReason);
- virtual int __cdecl AuthRequest(MCONTACT hContact, const wchar_t *szMessage);
+ virtual int __cdecl AuthDeny(MEVENT hDbEvent, const wchar_t *szReason);
+ virtual int __cdecl AuthRequest(MCONTACT hContact, const wchar_t *szMessage);
- virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
+ virtual DWORD_PTR __cdecl GetCaps(int type, MCONTACT hContact = NULL);
- virtual HANDLE __cdecl SearchBasic(const wchar_t *id);
+ virtual HANDLE __cdecl SearchBasic(const wchar_t *id);
virtual HANDLE __cdecl SearchByName(const wchar_t *nick, const wchar_t *firstName, const wchar_t *lastName);
- virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char *msg);
+ virtual int __cdecl SendMsg(MCONTACT hContact, int flags, const char *msg);
- virtual int __cdecl SetStatus(int iNewStatus);
+ virtual int __cdecl SetStatus(int iNewStatus);
- virtual int __cdecl UserIsTyping(MCONTACT hContact, int type);
+ virtual int __cdecl UserIsTyping(MCONTACT hContact, int type);
- virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam);
+ virtual int __cdecl OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam);
// instances
static CSteamProto* InitAccount(const char* protoName, const wchar_t *userName);
diff --git a/protocols/Tox/src/main.cpp b/protocols/Tox/src/main.cpp index 99cd7607a1..6bff578137 100644 --- a/protocols/Tox/src/main.cpp +++ b/protocols/Tox/src/main.cpp @@ -37,7 +37,6 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC int OnModulesLoaded(WPARAM, LPARAM) { CToxProto::InitIcons(); - CToxProto::InitContactMenu(); hProfileFolderPath = FoldersRegisterCustomPathT("Tox", "ProfilesFolder", MIRANDA_USERDATAT, TranslateT("Profiles folder")); diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp index 5694689e1a..9dc0ee8b79 100644 --- a/protocols/Tox/src/tox_menus.cpp +++ b/protocols/Tox/src/tox_menus.cpp @@ -1,9 +1,12 @@ #include "stdafx.h"
-HGENMENU CToxProto::ContactMenuItems[CMI_MAX];
+// HGENMENU CToxProto::ContactMenuItems[CMI_MAX];
int CToxProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
{
+ // for (auto &it : ContactMenuItems)
+ // Menu_ShowItem(it, false);
+
if (!hContact)
return 0;
@@ -16,48 +19,14 @@ int CToxProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
bool isAuthNeed = getByte(hContact, "Auth", 0) > 0;
- Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
+ Menu_ShowItem(m_hmiReqAuth, isCtrlPressed || isAuthNeed);
bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
- Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
+ Menu_ShowItem(m_hmiGrantAuth, isCtrlPressed || isGrantNeed);
return 0;
}
-int CToxProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
-{
- for (auto &it : ContactMenuItems)
- Menu_ShowItem(it, FALSE);
- CToxProto *proto = CToxProto::GetContactAccount(hContact);
- return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
-}
-
-void CToxProto::InitContactMenu()
-{
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CToxProto::PrebuildContactMenu);
-
- CMenuItem mi;
- mi.flags = CMIF_UNICODE;
-
- // Request authorization
- SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
- mi.pszService = MODULE"/RequestAuth";
- mi.name.w = LPGENW("Request authorization");
- mi.position = CMI_POSITION + CMI_AUTH_REQUEST;
- mi.hIcolibItem = ::Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
- ContactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnRequestAuth>);
-
- // Grant authorization
- SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30);
- mi.pszService = MODULE"/GrantAuth";
- mi.name.w = LPGENW("Grant authorization");
- mi.position = CMI_POSITION + CMI_AUTH_GRANT;
- mi.hIcolibItem = ::Skin_GetIconHandle(SKINICON_AUTH_GRANT);
- ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnGrantAuth>);
-}
-
int CToxProto::UpdateStatusMenu(WPARAM, LPARAM)
{
bool isOnline = IsOnline();
diff --git a/protocols/Tox/src/tox_menus.h b/protocols/Tox/src/tox_menus.h index 85b9f55055..e7c0d10340 100644 --- a/protocols/Tox/src/tox_menus.h +++ b/protocols/Tox/src/tox_menus.h @@ -5,8 +5,6 @@ enum CMI_MENU_ITEMS
{
- CMI_AUTH_REQUEST,
- CMI_AUTH_GRANT,
CMI_MAX // this item shall be the last one
};
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index f5c435b89a..a6159e06f3 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -24,12 +24,18 @@ CToxProto::CToxProto(const char* protoName, const wchar_t* userName) CreateProtoService(PS_GETMYAVATAR, &CToxProto::GetMyAvatar);
CreateProtoService(PS_SETMYAVATAR, &CToxProto::SetMyAvatar);
+ // menus
+ CreateProtoService(PS_MENU_REQAUTH, &CToxProto::OnRequestAuth);
+ CreateProtoService(PS_MENU_GRANTAUTH, &CToxProto::OnGrantAuth);
+
// nick
CreateProtoService(PS_SETMYNICKNAME, &CToxProto::SetMyNickname);
// events
CreateServiceFunction(MODULE "/GetEventIcon", &CToxProto::EventGetIcon);
+ HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CToxProto::OnPrebuildContactMenu);
+
hTerminateEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
}
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 97acbe5dac..cfbee1b4ec 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -11,7 +11,7 @@ struct CToxProto : public PROTO<CToxProto> public:
//////////////////////////////////////////////////////////////////////////////////////
- //Ctors
+ // Ctors
CToxProto(const char *protoName, const wchar_t *userName);
~CToxProto();
@@ -55,9 +55,6 @@ public: // icons
static void InitIcons();
- // menus
- static void InitContactMenu();
-
// utils
static void ShowNotification(const wchar_t *message, int flags = 0, MCONTACT hContact = NULL);
@@ -139,8 +136,7 @@ private: // menus
static HGENMENU ContactMenuItems[CMI_MAX];
- int OnPrebuildContactMenu(WPARAM hContact, LPARAM);
- static int PrebuildContactMenu(WPARAM hContact, LPARAM lParam);
+ int __cdecl OnPrebuildContactMenu(WPARAM hContact, LPARAM);
HGENMENU StatusMenuItems[SMI_MAX];
int OnInitStatusMenu();
@@ -257,13 +253,6 @@ private: static bool IsFileExists(const wchar_t* path);
MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, PBYTE pBlob, size_t cbBlob);
-
- template<INT_PTR(__cdecl CToxProto::*Service)(WPARAM, LPARAM)>
- static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam)
- {
- CToxProto *proto = CToxProto::GetContactAccount((MCONTACT)wParam);
- return proto ? (proto->*Service)(wParam, lParam) : 0;
- }
};
#endif //_TOX_PROTO_H_
\ No newline at end of file diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index b4aa1f4d3a..70fbf68454 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void InitGroupMenus(void);
void InitFramesMenus(void);
+void InitProtoMenus(void);
void InitTrayMenus(void);
#define MS_CLIST_HKSTATUS "Clist/HK/SetStatus"
@@ -1134,6 +1135,7 @@ void InitCustomMenus(void) // other menus
InitGroupMenus();
InitFramesMenus();
+ InitProtoMenus();
InitTrayMenus();
// initialize hotkeys
diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp index 74f502ead0..6fd467fdfd 100644 --- a/src/mir_app/src/menu_utils.cpp +++ b/src/mir_app/src/menu_utils.cpp @@ -223,9 +223,9 @@ MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(PROTO_INTERFACE *pThis) return nullptr;
if (db_get_b(0, "CList", "MoveProtoMenus", TRUE)) {
- if (pThis->m_hMainMenuItem != nullptr) {
- Menu_RemoveItem(pThis->m_hMainMenuItem);
- pThis->m_hMainMenuItem = nullptr;
+ if (pThis->m_hmiMainMenu != nullptr) {
+ Menu_RemoveItem(pThis->m_hmiMainMenu);
+ pThis->m_hmiMainMenu = nullptr;
}
return cli.pfnGetProtocolMenu(pThis->m_szModuleName);
}
@@ -255,7 +255,7 @@ MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(PROTO_INTERFACE *pThis) }
hex2bin(szUid, &mi.uid, sizeof(mi.uid));
- return pThis->m_hMainMenuItem = Menu_AddMainMenuItem(&mi);
+ return pThis->m_hmiMainMenu = Menu_AddMainMenuItem(&mi);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index ca48ba145e..d7090a080f 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -1014,8 +1014,8 @@ static int OnAccListChanged(WPARAM eventCode, LPARAM lParam) replaceStrW(pa->ppro->m_tszUserName, pa->tszAccountName);
pa->ppro->OnEvent(EV_PROTO_ONRENAME, 0, lParam);
- if (pa->ppro->m_hMainMenuItem)
- Menu_ModifyItem(pa->ppro->m_hMainMenuItem, pa->tszAccountName);
+ if (pa->ppro->m_hmiMainMenu)
+ Menu_ModifyItem(pa->ppro->m_hmiMainMenu, pa->tszAccountName);
}
}
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 199e730fd8..41c97b9a79 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -77,6 +77,74 @@ void PROTO_INTERFACE::setAllContactStatuses(int iStatus, bool bSkipChats) }
/////////////////////////////////////////////////////////////////////////////////////////
+// protocol menus
+
+static HGENMENU hReqAuth = nullptr, hGrantAuth = nullptr, hRevokeAuth = nullptr;
+
+static INT_PTR __cdecl stubRequestAuth(WPARAM hContact, LPARAM)
+{
+ const char *szProto = GetContactProto(hContact);
+ if (szProto)
+ ProtoCallService(szProto, PS_MENU_REQAUTH, hContact, 0);
+ return 0;
+}
+
+static INT_PTR __cdecl stubGrantAuth(WPARAM hContact, LPARAM)
+{
+ const char *szProto = GetContactProto(hContact);
+ if (szProto)
+ ProtoCallService(szProto, PS_MENU_GRANTAUTH, hContact, 0);
+ return 0;
+}
+
+static INT_PTR __cdecl stubRevokeAuth(WPARAM hContact, LPARAM)
+{
+ const char *szProto = GetContactProto(hContact);
+ if (szProto)
+ ProtoCallService(szProto, PS_MENU_REVOKEAUTH, hContact, 0);
+ return 0;
+}
+
+static int __cdecl ProtoPrebuildContactMenu(WPARAM, LPARAM)
+{
+ Menu_ShowItem(hReqAuth, false);
+ Menu_ShowItem(hGrantAuth, false);
+ Menu_ShowItem(hRevokeAuth, false);
+ return 0;
+}
+
+void InitProtoMenus(void)
+{
+ // "Request authorization"
+ CMenuItem mi;
+ SET_UID(mi, 0x36375a1f, 0xc142, 0x4d6e, 0xa6, 0x57, 0xe4, 0x76, 0x5d, 0xbc, 0x59, 0x8e);
+ mi.pszService = "Proto/Menu/ReqAuth";
+ mi.name.a = LPGEN("Request authorization");
+ mi.position = -2000001002;
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REQUEST);
+ hReqAuth = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, stubRequestAuth);
+
+ // "Grant authorization"
+ SET_UID(mi, 0x4c90452a, 0x869a, 0x4a81, 0xaf, 0xa8, 0x28, 0x34, 0xaf, 0x2b, 0x6b, 0x30);
+ mi.pszService = "Proto/Menu/GrantAuth";
+ mi.name.a = LPGEN("Grant authorization");
+ mi.position = -2000001001;
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_GRANT);
+ hGrantAuth = Menu_AddContactMenuItem(&mi);
+
+ // "Revoke authorization"
+ SET_UID(mi, 0x619efdcb, 0x99c0, 0x44a8, 0xbf, 0x28, 0xc3, 0xe0, 0x2f, 0xb3, 0x7e, 0x77);
+ mi.pszService = "Proto/Menu/RevokeAuth";
+ mi.name.a = LPGEN("Revoke authorization");
+ mi.position = -2000001000;
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_AUTH_REVOKE);
+ hRevokeAuth = Menu_AddContactMenuItem(&mi);
+
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, ProtoPrebuildContactMenu);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// protocol constructor & destructor
PROTO_INTERFACE::PROTO_INTERFACE(const char *pszModuleName, const wchar_t *ptszUserName)
@@ -87,6 +155,10 @@ PROTO_INTERFACE::PROTO_INTERFACE(const char *pszModuleName, const wchar_t *ptszU m_hProtoIcon = IcoLib_IsManaged(Skin_LoadProtoIcon(pszModuleName, ID_STATUS_ONLINE));
m_tszUserName = mir_wstrdup(ptszUserName);
db_set_resident(m_szModuleName, "Status");
+
+ m_hmiReqAuth = hReqAuth;
+ m_hmiGrantAuth = hGrantAuth;
+ m_hmiRevokeAuth = hRevokeAuth;
}
PROTO_INTERFACE::~PROTO_INTERFACE()
|