Project

General

Profile

Feature #312 » System.HasAddon.patch

dandar3, 18/08/2014 08:38 PM

View differences:

xbmc.vcproj (working copy)
Name="Database"
Filter="">
<File
RelativePath=".\xbmc\AddonDatabase.cpp">
</File>
<File
RelativePath=".\xbmc\AddonDatabase.h">
</File>
<File
RelativePath=".\xbmc\music\Album.cpp">
</File>
<File
xbmc/AddonDatabase.cpp (revision 0)
#include "AddonDatabase.h"
#include "settings/Settings.h"
#include "FileSystem/Directory.h"
using namespace XFILE;
/*
* Returns true if the specified addon is installed on the system.
*/
bool CAddonDatabase::HasAddon(const CStdString& addonID) {
// Check if exists as full path.
// e.g. "special://home/scripts/XBMC Subtitles"
if (CDirectory::Exists(addonID)) {
return true;
}
// Check if "script.NAME" exists.
// Allows for "script.xbmc.subtitles" -> "special://home/scripts/xbmc subtitles"
if (addonID.Left(7).Equals("script.")) {
CStdString scriptName = addonID.Mid(7);
scriptName.Replace(".", " ");
CStdString scriptsFolder = g_settings.GetScriptsFolder() + "/" + scriptName;
if (CDirectory::Exists(scriptsFolder.c_str())) {
return true;
}
}
// Default
return false;
}
xbmc/AddonDatabase.h (revision 0)
#include "utils/StdString.h"
class CAddonDatabase
{
public:
/* Returns true if the specified addon is installed on the system. */
static bool HasAddon(const CStdString& addonID);
};
xbmc/GUIInfoManager.cpp (working copy)
#include "utils/log.h"
#include "interfaces/info/InfoBool.h"
#include "AddonDatabase.h"
using namespace std;
using namespace XFILE;
......
return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_GET_BOOL : SYSTEM_GET_BOOL, ConditionalStringParameter(strTest.Mid(15,strTest.size()-16)), 0));
else if (strTest.Left(15).Equals("system.setting("))
return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_SETTING : SYSTEM_SETTING, ConditionalStringParameter(strTest.Mid(15,strTest.size()-16)), 0));
else if (strTest.Left(16).Equals("system.hasaddon(")) {
int addon = ConditionalStringParameter(strTest.Mid(16, strTest.GetLength() - 17));
return AddMultiInfo(GUIInfo(bNegate ? -SYSTEM_HAS_ADDON: SYSTEM_HAS_ADDON, addon));
}
}
// library test conditions
else if (strTest.Left(7).Equals("library"))
......
bReturn = false;
}
break;
case SYSTEM_HAS_ADDON:
{
CStdString addon = m_stringParameters[info.GetData1()];
bReturn = CAddonDatabase::HasAddon(addon);
}
break;
case CONTROL_GROUP_HAS_FOCUS:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
xbmc/GUIInfoManager.h (working copy)
#define SYSTEM_OPENGL_RENDERER 708
#define SYSTEM_OPENGL_VERSION 709
#define SYSTEM_SETTING 710
#define SYSTEM_HAS_ADDON 711
#define LIBRARY_HAS_MUSIC 720
#define LIBRARY_HAS_VIDEO 721
(2-2/2)