Permalink
Browse files

changed: screensavers are now supported via cpluff schema

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@29799 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
1 parent 1b2781c commit b6076e599698c82f0e607cc42c7a25b8ca83ca9e alcoheca committed May 5, 2010
Showing with 135 additions and 84 deletions.
  1. +1 −1 xbmc/Application.cpp
  2. +58 −34 xbmc/addons/Addon.cpp
  3. +1 −1 xbmc/addons/Addon.h
  4. +6 −3 xbmc/addons/AddonDll.h
  5. +68 −43 xbmc/addons/AddonManager.cpp
  6. +1 −2 xbmc/addons/AddonManager.h
View
@@ -4321,7 +4321,7 @@ void CApplication::ActivateScreenSaver(bool forceType /*= false */)
if (g_windowManager.HasModalDialog() || (IsPlayingVideo() && g_guiSettings.GetBool("screensaver.usedimonpause")))
m_screenSaverMode = "_virtual.dim";
// Check if we are Playing Audio and Vis instead Screensaver!
- else if (IsPlayingAudio() && g_guiSettings.GetBool("screensaver.usemusicvisinstead") && g_guiSettings.GetString("musicplayer.visualisation") != "None")
+ else if (IsPlayingAudio() && g_guiSettings.GetBool("screensaver.usemusicvisinstead") && g_guiSettings.GetString("musicplayer.visualisation") != "_virtual.none")
{ // activate the visualisation
m_screenSaverMode = "_virtual.viz";
g_windowManager.ActivateWindow(WINDOW_VISUALISATION);
View
@@ -113,7 +113,7 @@ const CStdString TranslateType(const ADDON::TYPE &type, bool pretty/*=false*/)
{
if (pretty)
return g_localizeStrings.Get(24008);
- return "screensaver";
+ return "xbmc.ui.screensaver";
}
case ADDON::ADDON_VIZ:
{
@@ -165,7 +165,7 @@ const ADDON::TYPE TranslateType(const CStdString &string)
if (string.Equals("pvrclient")) return ADDON_PVRDLL;
else if (string.Equals("scraper")) return ADDON_SCRAPER;
else if (string.Equals("scraper-library")) return ADDON_SCRAPER_LIBRARY;
- else if (string.Equals("screensaver")) return ADDON_SCREENSAVER;
+ else if (string.Equals("xbmc.ui.screensaver")) return ADDON_SCREENSAVER;
else if (string.Equals("visualization")) return ADDON_VIZ;
else if (string.Equals("visualization-library")) return ADDON_VIZ_LIBRARY;
else if (string.Equals("plugin")) return ADDON_PLUGIN;
@@ -214,14 +214,21 @@ bool AddonVersion::operator<=(const AddonVersion &rhs) const
CStdString AddonVersion::Print() const
{
CStdString out;
- out.Format("%s %s", g_localizeStrings.Get(24051), str); // "Version: <str>"
+ out.Format("%s %s", g_localizeStrings.Get(24051), str); // "Version <str>"
return CStdString(out);
}
AddonProps::AddonProps(cp_plugin_info_t *props)
: id(props->identifier)
, version(props->version)
-{}
+ , name(props->name)
+ , path(props->plugin_path)
+ , author(props->provider_name)
+{
+ //FIXME only considers the first registered extension for each addon
+ if (props->extensions->ext_point_id)
+ type = TranslateType(props->extensions->ext_point_id);
+}
/**
* CAddon
@@ -232,8 +239,7 @@ CAddon::CAddon(cp_plugin_info_t *props)
: m_props(props)
, m_parent(AddonPtr())
{
- if (m_props.libname.IsEmpty()) BuildLibName();
- else m_strLibName = m_props.libname;
+ BuildLibName(props);
BuildProfilePath();
CUtil::AddFileToFolder(Profile(), "settings.xml", m_userSettingsPath);
m_enabled = true;
@@ -279,37 +285,55 @@ const AddonVersion CAddon::Version()
//TODO platform/path crap should be negotiated between the addon and
// the handler for it's type
-void CAddon::BuildLibName()
+void CAddon::BuildLibName(cp_plugin_info_t *props)
{
- m_strLibName = "default";
- CStdString ext;
- switch (m_props.type)
+ if (!props)
{
- case ADDON_SCRAPER:
- case ADDON_SCRAPER_LIBRARY:
- ext = ADDON_SCRAPER_EXT;
- break;
- case ADDON_SCREENSAVER:
- ext = ADDON_SCREENSAVER_EXT;
- break;
- case ADDON_SKIN:
- m_strLibName = "skin.xml";
- return;
- case ADDON_VIZ:
- ext = ADDON_VIS_EXT;
- break;
- case ADDON_SCRIPT:
- case ADDON_PLUGIN:
- ext = ADDON_PYTHON_EXT;
- break;
- default:
- m_strLibName.clear();
- return;
+ m_strLibName = "default";
+ CStdString ext;
+ switch (m_props.type)
+ {
+ case ADDON_SCRAPER:
+ case ADDON_SCRAPER_LIBRARY:
+ ext = ADDON_SCRAPER_EXT;
+ break;
+ case ADDON_SCREENSAVER:
+ ext = ADDON_SCREENSAVER_EXT;
+ break;
+ case ADDON_SKIN:
+ m_strLibName = "skin.xml";
+ return;
+ case ADDON_VIZ:
+ ext = ADDON_VIS_EXT;
+ break;
+ case ADDON_SCRIPT:
+ case ADDON_PLUGIN:
+ ext = ADDON_PYTHON_EXT;
+ break;
+ default:
+ m_strLibName.clear();
+ return;
+ }
+ // extensions are returned as *.ext
+ // so remove the asterisk
+ ext.erase(0,1);
+ m_strLibName.append(ext);
+ }
+ else
+ {
+ switch (m_props.type)
+ {
+ case ADDON_SCREENSAVER:
+ {
+ CStdString temp = CAddonMgr::Get()->GetExtValue(props->extensions->configuration, "@library");
+ m_strLibName = temp;
+ }
+ break;
+ default:
+ m_strLibName.clear();
+ break;
+ }
}
- // extensions are returned as *.ext
- // so remove the asterisk
- ext.erase(0,1);
- m_strLibName.append(ext);
}
/**
View
@@ -173,7 +173,7 @@ class CAddon : public IAddon
bool m_hasStrings;
bool m_checkedStrings;
- void BuildLibName();
+ void BuildLibName(cp_plugin_info_t *props = NULL);
CStdString m_profile;
CStdString m_strLibName;
bool m_enabled;
View
@@ -115,7 +115,7 @@ bool CAddonDll<TheDll, TheStruct, TheProps>::LoadDll()
CStdString strFileName;
if (!Parent())
{
- strFileName = Path() + LibName();
+ strFileName = CUtil::AddFileToFolder(Path(), LibName());
}
else
{ //FIXME hack to load same Dll twice
@@ -207,8 +207,11 @@ void CAddonDll<TheDll, TheStruct, TheProps>::Destroy()
/* Unload library file */
try
{
- m_pDll->Destroy();
- m_pDll->Unload();
+ if (m_pDll)
+ {
+ m_pDll->Destroy();
+ m_pDll->Unload();
+ }
}
catch (std::exception &e)
{
@@ -102,6 +102,7 @@ CAddonMgr* CAddonMgr::Get()
if (!m_pInstance)
{
m_pInstance = new CAddonMgr();
+ m_pInstance->Init();
}
return m_pInstance;
}
@@ -137,8 +138,8 @@ bool CAddonMgr::Init()
if (!m_cpluff->IsLoaded())
{
- CLog::Log(LOGERROR, "ADDONS: Fatal Error, could not load cpluff");
- assert(false);
+ CLog::Log(LOGERROR, "ADDONS: Fatal Error, could not load libcpluff");
+ return false;
}
cp_log_severity_t log;
@@ -155,7 +156,7 @@ bool CAddonMgr::Init()
if (status != CP_OK)
{
CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_init() returned status: %i", status);
- assert(false);
+ return false;
}
//TODO could separate addons into different contexts
@@ -164,29 +165,38 @@ bool CAddonMgr::Init()
assert(m_cp_context);
if (!CSpecialProtocol::XBMCIsHome())
{
- status = m_cpluff->register_pcollection(m_cp_context, _P("special://home/addons/cpluff"));
- assert(status == CP_OK);
+ status = m_cpluff->register_pcollection(m_cp_context, _P("special://home/addons"));
+ }
+ status = m_cpluff->register_pcollection(m_cp_context, _P("special://xbmc/addons"));
+ if (status != CP_OK)
+ {
+ CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_pcollection() returned status: %i", status);
+ return false;
}
- status = m_cpluff->register_pcollection(m_cp_context, _P("special://xbmc/addons/cpluff"));
- assert(status == CP_OK);
+
status = m_cpluff->register_logger(m_cp_context, cp_logger, &CAddonMgr::m_pInstance, CP_LOG_INFO);
- assert(status == CP_OK);
- status = m_cpluff->scan_plugins(m_cp_context, 0);
-}
+ if (status != CP_OK)
+ {
+ CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_logger() returned status: %i", status);
+ return false;
+ }
-bool CAddonMgr::HasAddons2(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/)
-{
- cp_status_t status;
- int num;
- CStdString ext_point(TranslateType(type));
- cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
- if (status == CP_OK)
- return (num > 0);
- return false;
+ status = m_cpluff->scan_plugins(m_cp_context, 0);
+ return true;
}
bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
{
+ if (type == ADDON_SCREENSAVER)
+ {
+ cp_status_t status;
+ int num;
+ CStdString ext_point(TranslateType(type));
+ cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
+ if (status == CP_OK)
+ return (num > 0);
+ }
+
if (m_addons.empty())
{
VECADDONS add;
@@ -198,6 +208,7 @@ bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTE
VECADDONS addons;
return GetAddons(type, addons, content, enabledOnly);
+
}
bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabledOnly/*= true*/)
@@ -218,26 +229,26 @@ bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabledOnly/*= true*/)
return !addons.empty();
}
-bool CAddonMgr::GetAddons2(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content)
-{
- cp_status_t status;
- int num;
- CStdString ext_point(TranslateType(type));
- cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
- for(int i=0; i <num; i++)
- {
- AddonPtr addon(AddonFactory(exts[i]));
- if (addon)
- addons.push_back(addon);
- }
- m_cpluff->release_info(m_cp_context, exts);
- return addons.size();
-}
-
bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
{
CSingleLock lock(m_critSection);
addons.clear();
+ if (type == ADDON_SCREENSAVER)
+ {
+ cp_status_t status;
+ int num;
+ CStdString ext_point(TranslateType(type));
+ cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
+ for(int i=0; i <num; i++)
+ {
+ AddonPtr addon(AddonFactory(exts[i]));
+ if (addon)
+ addons.push_back(addon);
+ }
+ m_cpluff->release_info(m_cp_context, exts);
+ return addons.size();
+ }
+
if (m_addons.find(type) != m_addons.end())
{
IVECADDONS itr = m_addons[type].begin();
@@ -259,9 +270,22 @@ bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYP
bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly/*= true*/)
{
CSingleLock lock(m_critSection);
- if (type != ADDON_UNKNOWN && m_addons.find(type) == m_addons.end())
+ if (type != ADDON_UNKNOWN
+ && type != ADDON_SCREENSAVER
+ && m_addons.find(type) == m_addons.end())
return false;
+ if (type == ADDON_SCREENSAVER)
+ {
+ cp_status_t status;
+ cp_plugin_info_t *cpaddon = NULL;
+ cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
+ if (status == CP_OK && cpaddon->extensions)
+ return (addon = AddonFactory(cpaddon->extensions));
+ else
+ return false;
+ }
+
if (m_idMap[str])
{
addon = m_idMap[str];
@@ -290,13 +314,6 @@ bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &typ
return false;
}
-AddonPtr CAddonMgr::GetAddon2(const CStdString &str)
-{
- CSingleLock lock(m_critSection);
-
- return AddonPtr();
-}
-
//TODO handle all 'default' cases here, not just scrapers & vizs
bool CAddonMgr::GetDefault(const TYPE &type, AddonPtr &addon, const CONTENT_TYPE &content)
{
@@ -854,6 +871,14 @@ void CAddonMgr::OnJobComplete(unsigned int jobID, bool success, CJob* job)
* libcpluff interaction
*/
+CStdString CAddonMgr::GetExtValue(cp_cfg_element_t *base, const char *path)
+{
+ const char *value = NULL;
+ if (base && (value = m_cpluff->lookup_cfg_value(base, path)))
+ return CStdString(value);
+ else return CStdString();
+}
+
void CAddonMgr::CPluffFatalError(const char *msg)
{
CLog::Log(LOGERROR, "ADDONS: CPluffFatalError(%s)", msg);
@@ -86,9 +86,7 @@ namespace ADDON
bool GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type = ADDON_UNKNOWN, bool enabledOnly = true);
AddonPtr GetAddon2(const CStdString &str);
bool HasAddons(const TYPE &type, const CONTENT_TYPE &content = CONTENT_NONE, bool enabledOnly = true);
- bool HasAddons2(const TYPE &type, const CONTENT_TYPE &content = CONTENT_NONE);
bool GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content = CONTENT_NONE, bool enabled = true);
- bool GetAddons2(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content = CONTENT_NONE);
bool GetAllAddons(VECADDONS &addons, bool enabledOnly = true);
CStdString GetString(const CStdString &id, const int number);
@@ -106,6 +104,7 @@ namespace ADDON
/* libcpluff */
bool GetExtensions(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content);
+ CStdString GetExtValue(cp_cfg_element_t *base, const char *path);
void CPluffFatalError(const char *msg);
void CPluffLog(cp_log_severity_t level, const char *msg, const char *apid, void *user_data);
cp_context_t *m_cp_context;

0 comments on commit b6076e5

Please sign in to comment.