aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Morten Kvarving <cptspiff@gmail.com>2015-09-10 18:33:47 +0200
committerRainer Hochecker <fernetmenta@online.de>2015-09-12 07:33:23 +0200
commit9a3a46174c5cb1ee81318b40fbc7b028df3adabb (patch)
tree324010e1b5ddc385c5cec414abbc8a739792b198
parent599195096beefb8c1f91ab4d959f4f5055563f1d (diff)
move profile related builtins to separate file
-rw-r--r--xbmc/interfaces/builtins/Builtins.cpp65
-rw-r--r--xbmc/interfaces/builtins/Makefile1
-rw-r--r--xbmc/interfaces/builtins/ProfileBuiltins.cpp125
-rw-r--r--xbmc/interfaces/builtins/ProfileBuiltins.h30
4 files changed, 159 insertions, 62 deletions
diff --git a/xbmc/interfaces/builtins/Builtins.cpp b/xbmc/interfaces/builtins/Builtins.cpp
index 7b87d620dd..5ce0452115 100644
--- a/xbmc/interfaces/builtins/Builtins.cpp
+++ b/xbmc/interfaces/builtins/Builtins.cpp
@@ -111,6 +111,7 @@
#include "AddonBuiltins.h"
#include "LibraryBuiltins.h"
+#include "ProfileBuiltins.h"
#include "SkinBuiltins.h"
#include "SystemBuiltins.h"
@@ -133,7 +134,6 @@ typedef struct
const BUILT_IN commands[] = {
{ "Help", false, "This help message" },
- { "Mastermode", false, "Control master mode" },
{ "SetGUILanguage", true, "Set GUI Language" },
{ "ActivateWindow", true, "Activate the specified window" },
{ "ActivateWindowAndFocus", true, "Activate the specified window and sets focus to the specified id" },
@@ -161,7 +161,6 @@ const BUILT_IN commands[] = {
{ "Mute", false, "Mute the player" },
{ "SetVolume", true, "Set the current volume" },
{ "Dialog.Close", true, "Close a dialog" },
- { "System.LogOff", false, "Log off current user" },
{ "Resolution", true, "Change Kodi's Resolution" },
{ "SetFocus", true, "Change current focus to a different control id" },
{ "PageDown", true, "Send a page down event to the pagecontrol with given id" },
@@ -179,7 +178,6 @@ const BUILT_IN commands[] = {
{ "Control.SetFocus", true, "Change current focus to a different control id" },
{ "Control.Message", true, "Send a given message to a control within a given window" },
{ "SendClick", true, "Send a click message from the given control to the given window" },
- { "LoadProfile", true, "Load the specified profile (note; if locks are active it won't work)" },
{ "SetProperty", true, "Sets a window property for the current focused window/dialog (key,value)" },
{ "ClearProperty", true, "Clears a window property for the current focused window/dialog (key,value)" },
{ "PlayWith", true, "Play the selected item with the specified core" },
@@ -214,6 +212,7 @@ CBuiltins::CBuiltins()
{
RegisterCommands<CAddonBuiltins>();
RegisterCommands<CLibraryBuiltins>();
+ RegisterCommands<CProfileBuiltins>();
RegisterCommands<CSkinBuiltins>();
RegisterCommands<CSystemBuiltins>();
}
@@ -338,38 +337,7 @@ int CBuiltins::Execute(const std::string& execString)
}
}
- if (execute == "loadprofile")
- {
- int index = CProfilesManager::GetInstance().GetProfileIndex(parameter);
- bool prompt = (params.size() == 2 && StringUtils::EqualsNoCase(params[1], "prompt"));
- bool bCanceled;
- if (index >= 0
- && (CProfilesManager::GetInstance().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE
- || g_passwordManager.IsProfileLockUnlocked(index,bCanceled,prompt)))
- {
- CApplicationMessenger::GetInstance().PostMsg(TMSG_LOADPROFILE, index);
- }
- }
- else if (execute == "mastermode")
- {
- if (g_passwordManager.bMasterUser)
- {
- g_passwordManager.bMasterUser = false;
- g_passwordManager.LockSources(true);
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(20052),g_localizeStrings.Get(20053));
- }
- else if (g_passwordManager.IsMasterLockUnlocked(true))
- {
- g_passwordManager.LockSources(false);
- g_passwordManager.bMasterUser = true;
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(20052),g_localizeStrings.Get(20054));
- }
-
- CUtil::DeleteVideoDatabaseDirectoryCache();
- CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE);
- g_windowManager.SendMessage(msg);
- }
- else if (execute == "setguilanguage")
+ if (execute == "setguilanguage")
{
if (params.size())
{
@@ -1088,33 +1056,6 @@ int CBuiltins::Execute(const std::string& execString)
((CGUIDialog *)window)->Close(bForce);
}
}
- else if (execute == "system.logoff")
- {
- // there was a commit from cptspiff here which was reverted
- // for keeping the behaviour from Eden in Frodo - see
- // git rev 9ee5f0047b
- if (g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN)
- return -1;
-
- g_application.StopPlaying();
- if (g_application.IsMusicScanning())
- g_application.StopMusicScan();
-
- if (CVideoLibraryQueue::GetInstance().IsRunning())
- CVideoLibraryQueue::GetInstance().CancelAllJobs();
-
- ADDON::CAddonMgr::GetInstance().StopServices(true);
-
- g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_DOWN,1);
- CProfilesManager::GetInstance().LoadMasterProfileForLogin();
- g_passwordManager.bMasterUser = false;
-
- if (!ActivateWindow(WINDOW_LOGIN_SCREEN))
- return false;
-
- if (!CNetworkServices::GetInstance().StartEventServer()) // event server could be needed in some situations
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(33102), g_localizeStrings.Get(33100));
- }
else if (execute == "pagedown")
{
int id = atoi(parameter.c_str());
diff --git a/xbmc/interfaces/builtins/Makefile b/xbmc/interfaces/builtins/Makefile
index e6db8db63d..cb5a23a46a 100644
--- a/xbmc/interfaces/builtins/Makefile
+++ b/xbmc/interfaces/builtins/Makefile
@@ -1,6 +1,7 @@
SRCS = AddonBuiltins.cpp
SRCS += Builtins.cpp
SRCS += LibraryBuiltins.cpp
+SRCS += ProfileBuiltins.cpp
SRCS += SkinBuiltins.cpp
SRCS += SystemBuiltins.cpp
diff --git a/xbmc/interfaces/builtins/ProfileBuiltins.cpp b/xbmc/interfaces/builtins/ProfileBuiltins.cpp
new file mode 100644
index 0000000000..302320bf7b
--- /dev/null
+++ b/xbmc/interfaces/builtins/ProfileBuiltins.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ProfileBuiltins.h"
+
+#include "addons/AddonManager.h"
+#include "Application.h"
+#include "messaging/ApplicationMessenger.h"
+#include "dialogs/GUIDialogKaiToast.h"
+#include "guilib/LocalizeStrings.h"
+#include "guilib/GUIWindowManager.h"
+#include "GUIPassword.h"
+#include "GUIUserMessages.h"
+#include "network/Network.h"
+#include "network/NetworkServices.h"
+#include "profiles/ProfilesManager.h"
+#include "Util.h"
+#include "utils/StringUtils.h"
+#include "video/VideoLibraryQueue.h"
+
+using namespace KODI::MESSAGING;
+
+/*! \brief Load a profile.
+ * \param params The parameters.
+ * \details params[0] = The profile name.
+ * params[1] = "prompt" to allow unlocking dialogs (optional)
+ */
+static int LoadProfile(const std::vector<std::string>& params)
+{
+ int index = CProfilesManager::GetInstance().GetProfileIndex(params[0]);
+ bool prompt = (params.size() == 2 && StringUtils::EqualsNoCase(params[1], "prompt"));
+ bool bCanceled;
+ if (index >= 0
+ && (CProfilesManager::GetInstance().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE
+ || g_passwordManager.IsProfileLockUnlocked(index,bCanceled,prompt)))
+ {
+ CApplicationMessenger::GetInstance().PostMsg(TMSG_LOADPROFILE, index);
+ }
+
+ return 0;
+}
+
+/*! \brief Log off currently signed in profile.
+ * \param params (ignored)
+ */
+static int LogOff(const std::vector<std::string>& params)
+{
+ // there was a commit from cptspiff here which was reverted
+ // for keeping the behaviour from Eden in Frodo - see
+ // git rev 9ee5f0047b
+ if (g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN)
+ return -1;
+
+ g_application.StopPlaying();
+ if (g_application.IsMusicScanning())
+ g_application.StopMusicScan();
+
+ if (CVideoLibraryQueue::GetInstance().IsRunning())
+ CVideoLibraryQueue::GetInstance().CancelAllJobs();
+
+ ADDON::CAddonMgr::GetInstance().StopServices(true);
+
+ g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_DOWN,1);
+ CProfilesManager::GetInstance().LoadMasterProfileForLogin();
+ g_passwordManager.bMasterUser = false;
+
+ g_application.WakeUpScreenSaverAndDPMS();
+ g_windowManager.ActivateWindow(WINDOW_LOGIN_SCREEN, {}, false);
+
+ if (!CNetworkServices::GetInstance().StartEventServer()) // event server could be needed in some situations
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(33102), g_localizeStrings.Get(33100));
+
+ return 0;
+}
+
+/*! \brief Toggle master mode.
+ * \param params (ignored)
+ */
+static int MasterMode(const std::vector<std::string>& params)
+{
+ if (g_passwordManager.bMasterUser)
+ {
+ g_passwordManager.bMasterUser = false;
+ g_passwordManager.LockSources(true);
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(20052),g_localizeStrings.Get(20053));
+ }
+ else if (g_passwordManager.IsMasterLockUnlocked(true))
+ {
+ g_passwordManager.LockSources(false);
+ g_passwordManager.bMasterUser = true;
+ CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Warning, g_localizeStrings.Get(20052),g_localizeStrings.Get(20054));
+ }
+
+ CUtil::DeleteVideoDatabaseDirectoryCache();
+ CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE);
+ g_windowManager.SendMessage(msg);
+
+ return 0;
+}
+
+CBuiltins::CommandMap CProfileBuiltins::GetOperations() const
+{
+ return {
+ {"loadprofile", {"Load the specified profile (note; if locks are active it won't work)", 1, LoadProfile}},
+ {"mastermode", {"Control master mode", 0, MasterMode}},
+ {"system.logoff", {"Log off current user", 0, LogOff}}
+ };
+}
diff --git a/xbmc/interfaces/builtins/ProfileBuiltins.h b/xbmc/interfaces/builtins/ProfileBuiltins.h
new file mode 100644
index 0000000000..62f2ed8c77
--- /dev/null
+++ b/xbmc/interfaces/builtins/ProfileBuiltins.h
@@ -0,0 +1,30 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2015 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "Builtins.h"
+
+//! \brief Class providing profile related built-in commands.
+class CProfileBuiltins
+{
+public:
+ //! \brief Returns the map of operations.
+ CBuiltins::CommandMap GetOperations() const;
+};