Skip to content

Commit

Permalink
[addons] add setting for enabling/disabling zip install
Browse files Browse the repository at this point in the history
  • Loading branch information
tamland committed Jan 13, 2016
1 parent 61e14b1 commit 5fac156
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 10 deletions.
26 changes: 25 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -17812,7 +17812,31 @@ msgctxt "#36614"
msgid "Show add-ons that are currently running in the background."
msgstr ""

#empty strings from id 36615 to 36899
#: system/settings/settings.xml
msgctxt "#36615"
msgid "Unknown sources"
msgstr ""

#. Description of setting "System -> Add-ons -> Unknown sources" with label #36615
#: system/settings/settings.xml
msgctxt "#36616"
msgid "Allow installation of add-ons from unknown sources."
msgstr ""

msgctxt "#36617"
msgid "For security, installation of add-ons from unknown sources is disabled."
msgstr ""

msgctxt "#36618"
msgid "Warning!"
msgstr ""

#. Text in confirm dialog when enabling setting "System -> Add-ons -> Unknown sources"
msgctxt "#36619"
msgid "Add-ons will be given access to personal data stored on this device. By allowing, you agree that you are solely responsible for any loss of data, unwanted behaviour, or damage to your device that may result from using these add-ons. Proceed?"
msgstr ""

#empty strings from id 36620 to 36899

#: xbmc/media/MediaType.cpp
msgctxt "#36900"
Expand Down
5 changes: 5 additions & 0 deletions system/settings/settings.xml
Expand Up @@ -2911,6 +2911,11 @@
<dependency type="enable" setting="general.addonupdates">0</dependency>
</dependencies>
</setting>
<setting id="addons.unknownsources" type="boolean" label="36615" help="36616">
<level>1</level>
<default>false</default>
<control type="toggle" />
</setting>
</group>
<group id="2">
<setting id="addons.managedependencies" type="action" label="24996" help="36613">
Expand Down
17 changes: 15 additions & 2 deletions xbmc/addons/AddonSystemSettings.cpp
Expand Up @@ -22,6 +22,7 @@
#include "addons/AddonSystemSettings.h"
#include "addons/RepositoryUpdater.h"
#include "guilib/GUIWindowManager.h"
#include "messaging/helpers/DialogHelper.h"
#include "settings/Settings.h"


Expand All @@ -34,7 +35,7 @@ CAddonSystemSettings& CAddonSystemSettings::GetInstance()
return inst;
}

void CAddonSystemSettings::OnSettingAction(const CSetting* setting)
void CAddonSystemSettings::OnSettingAction(const CSetting* setting)
{
if (setting->GetId() == CSettings::SETTING_ADDONS_MANAGE_DEPENDENCIES)
{
Expand All @@ -46,6 +47,18 @@ void CAddonSystemSettings::OnSettingAction(const CSetting* setting)
std::vector<std::string> params{"addons://running/", "return"};
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
}
};
}

void CAddonSystemSettings::OnSettingChanged(const CSetting* setting)
{
using namespace KODI::MESSAGING::HELPERS;

if (setting->GetId() == CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES
&& CSettings::GetInstance().GetBool(CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES)
&& ShowYesNoDialogText(36618, 36619) != DialogResponse::YES)
{
CSettings::GetInstance().SetBool(CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES, false);
}
}

}
1 change: 1 addition & 0 deletions xbmc/addons/AddonSystemSettings.h
Expand Up @@ -34,6 +34,7 @@ class CAddonSystemSettings : public ISettingCallback
public:
static CAddonSystemSettings& GetInstance();
void OnSettingAction(const CSetting* setting) override;
void OnSettingChanged(const CSetting* setting) override;

private:
CAddonSystemSettings() = default;
Expand Down
25 changes: 18 additions & 7 deletions xbmc/addons/GUIWindowAddonBrowser.cpp
Expand Up @@ -35,6 +35,7 @@
#include "FileItem.h"
#include "filesystem/AddonsDirectory.h"
#include "addons/AddonInstaller.h"
#include "messaging/helpers/DialogHelper.h"
#include "settings/Settings.h"
#include "settings/MediaSourceSettings.h"
#include "utils/StringUtils.h"
Expand Down Expand Up @@ -222,13 +223,23 @@ bool CGUIWindowAddonBrowser::OnClick(int iItem, const std::string &player)
CFileItemPtr item = m_vecItems->Get(iItem);
if (item->GetPath() == "addons://install/")
{
// pop up filebrowser to grab an installed folder
VECSOURCES shares = *CMediaSourceSettings::GetInstance().GetSources("files");
g_mediaManager.GetLocalDrives(shares);
g_mediaManager.GetNetworkLocations(shares);
std::string path;
if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "*.zip", g_localizeStrings.Get(24041), path))
CAddonInstaller::GetInstance().InstallFromZip(path);
using namespace KODI::MESSAGING::HELPERS;

if (!CSettings::GetInstance().GetBool(CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES))
{
if (ShowYesNoDialogText(13106, 36617, 186, 10004) == DialogResponse::YES)
g_windowManager.ActivateWindow(WINDOW_SETTINGS_SYSTEM, "addons");
}
else
{
// pop up filebrowser to grab an installed folder
VECSOURCES shares = *CMediaSourceSettings::GetInstance().GetSources("files");
g_mediaManager.GetLocalDrives(shares);
g_mediaManager.GetNetworkLocations(shares);
std::string path;
if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "*.zip", g_localizeStrings.Get(24041), path))
CAddonInstaller::GetInstance().InstallFromZip(path);
}
return true;
}
if (item->GetPath() == "addons://update_all/")
Expand Down
2 changes: 2 additions & 0 deletions xbmc/settings/Settings.cpp
Expand Up @@ -408,6 +408,7 @@ const std::string CSettings::SETTING_SYSTEM_PLAYLISTSPATH = "system.playlistspat
const std::string CSettings::SETTING_ADDONS_AUTOUPDATES = "general.addonupdates";
const std::string CSettings::SETTING_ADDONS_NOTIFICATIONS = "general.addonnotifications";
const std::string CSettings::SETTING_ADDONS_SHOW_RUNNING = "addons.showrunning";
const std::string CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES = "addons.unknownsources";
const std::string CSettings::SETTING_ADDONS_MANAGE_DEPENDENCIES = "addons.managedependencies";
const std::string CSettings::SETTING_GENERAL_ADDONFOREIGNFILTER = "general.addonforeignfilter";
const std::string CSettings::SETTING_GENERAL_ADDONBROKENFILTER = "general.addonbrokenfilter";
Expand Down Expand Up @@ -1207,6 +1208,7 @@ void CSettings::InitializeISettingCallbacks()
settingSet.clear();
settingSet.insert(CSettings::SETTING_ADDONS_SHOW_RUNNING);
settingSet.insert(CSettings::SETTING_ADDONS_MANAGE_DEPENDENCIES);
settingSet.insert(CSettings::SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES);
m_settingsManager->RegisterCallback(&ADDON::CAddonSystemSettings::GetInstance(), settingSet);

settingSet.clear();
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/Settings.h
Expand Up @@ -365,6 +365,7 @@ class CSettings : public CSettingCreator, public CSettingControlCreator
static const std::string SETTING_ADDONS_NOTIFICATIONS;
static const std::string SETTING_ADDONS_SHOW_RUNNING;
static const std::string SETTING_ADDONS_MANAGE_DEPENDENCIES;
static const std::string SETTING_ADDONS_ALLOW_UNKNOWN_SOURCES;
static const std::string SETTING_GENERAL_ADDONFOREIGNFILTER;
static const std::string SETTING_GENERAL_ADDONBROKENFILTER;

Expand Down

0 comments on commit 5fac156

Please sign in to comment.