diff options
Diffstat (limited to 'protocols/Tox/src/tox_menus.cpp')
-rw-r--r-- | protocols/Tox/src/tox_menus.cpp | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp index ed70ad8a7b..34b3047fb4 100644 --- a/protocols/Tox/src/tox_menus.cpp +++ b/protocols/Tox/src/tox_menus.cpp @@ -21,9 +21,6 @@ int CToxProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
- bool isContactOnline = GetContactStatus(hContact) > ID_STATUS_OFFLINE;
- Menu_ShowItem(ContactMenuItems[CMI_AUDIO_CALL], toxThread->ToxAV() && isContactOnline);
-
return 0;
}
@@ -35,7 +32,7 @@ int CToxProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam) return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
}
-void CToxProto::InitMenus()
+void CToxProto::InitContactMenu()
{
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, &CToxProto::PrebuildContactMenu);
@@ -59,19 +56,29 @@ void CToxProto::InitMenus() mi.hIcolibItem = ::Skin_GetIconHandle(SKINICON_AUTH_GRANT);
ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnGrantAuth>);
+}
+
+int CToxProto::PrebuildStatusMenu(WPARAM, LPARAM)
+{
+ bool isOnline = IsOnline();
+ Menu_EnableItem(StatusMenuItems[SMI_PASSWORD], isOnline);
+ Menu_EnableItem(StatusMenuItems[SMI_PASSWORD_CREATE], isOnline);
+ Menu_EnableItem(StatusMenuItems[SMI_PASSWORD_CHANGE], isOnline);
+ Menu_EnableItem(StatusMenuItems[SMI_PASSWORD_REMOVE], isOnline);
+
+ pass_ptrW password(getWStringA(TOX_SETTINGS_PASSWORD));
+ bool passwordExists = mir_wstrlen(password) > 0;
+ Menu_ShowItem(StatusMenuItems[SMI_PASSWORD_CREATE], !passwordExists);
+ Menu_ShowItem(StatusMenuItems[SMI_PASSWORD_CHANGE], passwordExists);
+ Menu_ShowItem(StatusMenuItems[SMI_PASSWORD_REMOVE], passwordExists);
- // Start audio call
- SET_UID(mi, 0x116cb7fe, 0xce37, 0x429c, 0xb0, 0xa9, 0x7d, 0xe7, 0x70, 0x59, 0xc3, 0x95);
- mi.pszService = MODULE"/Audio/Call";
- mi.name.w = LPGENW("Call");
- mi.position = -2000020000 + CMI_AUDIO_CALL;
- mi.hIcolibItem = GetIconHandle(IDI_AUDIO_START);
- ContactMenuItems[CMI_AUDIO_CALL] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnSendAudioCall>);
+ return 0;
}
int CToxProto::OnInitStatusMenu()
{
+ HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &CToxProto::PrebuildStatusMenu);
+
CMenuItem mi;
mi.flags = CMIF_UNICODE;
mi.root = Menu_GetProtocolRoot(this);
@@ -81,16 +88,34 @@ int CToxProto::OnInitStatusMenu() CreateProtoService(mi.pszService, &CToxProto::OnCopyToxID);
mi.name.w = LPGENW("Copy Tox ID");
mi.position = SMI_POSITION + SMI_TOXID_COPY;
- Menu_AddProtoMenuItem(&mi, m_szModuleName);
-
- // Create group chat command
- /*
- mi.pszService = "/CreateChatRoom";
- CreateProtoService(mi.pszService, &CToxProto::OnCreateChatRoom);
- mi.name.w = LPGENW("Create group chat");
- mi.position = SMI_POSITION + SMI_GROUPCHAT_CREATE;
- mi.hIcolibItem = Skin_GetIconHandle("conference");
- HGENMENU hCreateChatRoom = Menu_AddProtoMenuItem(&mi, m_szModuleName);*/
+ StatusMenuItems[SMI_TOXID_COPY] = Menu_AddProtoMenuItem(&mi, m_szModuleName);
+
+ // Password
+ mi.pszService = nullptr;
+ mi.name.w = LPGENW("Password");
+ StatusMenuItems[SMI_PASSWORD] = Menu_AddProtoMenuItem(&mi, m_szModuleName);
+ mi.root = StatusMenuItems[SMI_PASSWORD];
+
+ // Create password command
+ mi.pszService = "/CreatePassword";
+ CreateProtoService(mi.pszService, &CToxProto::OnCreatePassword);
+ mi.name.w = LPGENW("Create password");
+ mi.position = SMI_PASSWORD_CREATE;
+ StatusMenuItems[SMI_PASSWORD_CREATE] = Menu_AddProtoMenuItem(&mi, m_szModuleName);
+
+ // Change password command
+ mi.pszService = "/ChangePassword";
+ CreateProtoService(mi.pszService, &CToxProto::OnChangePassword);
+ mi.name.w = LPGENW("Change password");
+ mi.position = SMI_PASSWORD_CHANGE;
+ StatusMenuItems[SMI_PASSWORD_CHANGE] = Menu_AddProtoMenuItem(&mi, m_szModuleName);
+
+ // Remove password command
+ mi.pszService = "/RemovePassword";
+ CreateProtoService(mi.pszService, &CToxProto::OnRemovePassword);
+ mi.name.w = LPGENW("Remove password");
+ mi.position = SMI_PASSWORD_REMOVE;
+ StatusMenuItems[SMI_PASSWORD_REMOVE] = Menu_AddProtoMenuItem(&mi, m_szModuleName);
return 0;
}
|