Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 825 lines (736 sloc) 23.34 kB
074db86 merged: addons-fw branch
elupus authored
1 /*
2 * Copyright (C) 2005-2009 Team XBMC
3 * http://www.xbmc.org
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 */
21 #include "AddonManager.h"
22 #include "Addon.h"
1b2781c added: basic cpluff support
alcoheca authored
23 #include "DllLibCPluff.h"
c51b118 Merged cptspiff's code-reshuffle branch.
theuni authored
24 #include "utils/StringUtils.h"
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored
25 #include "utils/JobManager.h"
c51b118 Merged cptspiff's code-reshuffle branch.
theuni authored
26 #include "threads/SingleLock.h"
074db86 merged: addons-fw branch
elupus authored
27 #include "FileItem.h"
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer…
spiff_ authored
28 #include "LangInfo.h"
c51b118 Merged cptspiff's code-reshuffle branch.
theuni authored
29 #include "settings/Settings.h"
30 #include "settings/GUISettings.h"
31 #include "settings/AdvancedSettings.h"
32 #include "utils/log.h"
bbbabb3 @amejia1 Use system implementation of tinyxml instead of internal implementation.
amejia1 authored
33 #include "utils/XBMCTinyXML.h"
074db86 merged: addons-fw branch
elupus authored
34 #ifdef HAS_VISUALISATION
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored
35 #include "Visualisation.h"
074db86 merged: addons-fw branch
elupus authored
36 #endif
37 #ifdef HAS_SCREENSAVER
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored
38 #include "ScreenSaver.h"
074db86 merged: addons-fw branch
elupus authored
39 #endif
40 //#ifdef HAS_SCRAPERS
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored
41 #include "Scraper.h"
074db86 merged: addons-fw branch
elupus authored
42 //#endif
16b848a added: CPluginSource class for all pluginsource addons
alcoheca authored
43 #include "PluginSource.h"
606248f added: addon repository class
spiff_ authored
44 #include "Repository.h"
553d213 changed: finished moving skins to addon framework
alcoheca authored
45 #include "Skin.h"
b55ac44 added: service addons.
blinkseb authored
46 #include "Service.h"
d074c5a remove unnecessary includes
spiff authored
47 #include "Util.h"
af8cb2a Revert "wip"
alcoheca authored
48
88e9b6f changed: expand std namespace
spiff_ authored
49 using namespace std;
50
074db86 merged: addons-fw branch
elupus authored
51 namespace ADDON
52 {
53
b6f0f59 cleanup: Don't expose the AddonManager's privates when not required.
jmarshallnz authored
54 cp_log_severity_t clog_to_cp(int lvl);
55 void cp_fatalErrorHandler(const char *msg);
56 void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data);
074db86 merged: addons-fw branch
elupus authored
57
58 /**********************************************************
59 * CAddonMgr
60 *
61 */
62
88e9b6f changed: expand std namespace
spiff_ authored
63 map<TYPE, IAddonMgrCallback*> CAddonMgr::m_managers;
074db86 merged: addons-fw branch
elupus authored
64
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
65 AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
1b2781c added: basic cpluff support
alcoheca authored
66 {
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
67 if (!PlatformSupportsAddon(props->plugin))
68 return AddonPtr();
69
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
70 /* Check if user directories need to be created */
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
71 const cp_cfg_element_t *settings = GetExtElement(props->configuration, "settings");
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
72 if (settings)
73 CheckUserDirs(settings);
74
1b2781c added: basic cpluff support
alcoheca authored
75 const TYPE type = TranslateType(props->ext_point_id);
76 switch (type)
77 {
78 case ADDON_PLUGIN:
79 case ADDON_SCRIPT:
9a8454a added: script support to media windows. Scripts should use the same e…
jmarshallnz authored
80 return AddonPtr(new CPluginSource(props));
35cf15f changed: get rid of the content types added earlier, favouring extens…
jmarshallnz authored
81 case ADDON_SCRIPT_LIBRARY:
82 case ADDON_SCRIPT_LYRICS:
83 case ADDON_SCRIPT_SUBTITLES:
9d4264e added: Initial support for python module addons.
jmarshallnz authored
84 case ADDON_SCRIPT_MODULE:
113777a merged: r33383,r33386 from webinterface branch
jmarshallnz authored
85 case ADDON_WEB_INTERFACE:
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
86 return AddonPtr(new CAddon(props));
569712f changed: we now only support v2.0 weather add-ons
spiff authored
87 case ADDON_SCRIPT_WEATHER:
88 {
89 // Eden (API v2.0) broke old weather add-ons
90 AddonPtr result(new CAddon(props));
91 AddonVersion ver1 = AddonVersion(GetXbmcApiVersionDependency(result));
92 AddonVersion ver2 = AddonVersion("2.0");
93 if (ver1 < ver2)
94 {
95 CLog::Log(LOGINFO,"%s: Weather add-ons for api < 2.0 unsupported (%s)",__FUNCTION__,result->ID().c_str());
96 return AddonPtr();
97 }
98 return result;
99 }
b55ac44 added: service addons.
blinkseb authored
100 case ADDON_SERVICE:
101 return AddonPtr(new CService(props));
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
102 case ADDON_SCRAPER_ALBUMS:
103 case ADDON_SCRAPER_ARTISTS:
104 case ADDON_SCRAPER_MOVIES:
105 case ADDON_SCRAPER_MUSICVIDEOS:
106 case ADDON_SCRAPER_TVSHOWS:
107 case ADDON_SCRAPER_LIBRARY:
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
108 return AddonPtr(new CScraper(props));
1b2781c added: basic cpluff support
alcoheca authored
109 case ADDON_VIZ:
110 case ADDON_SCREENSAVER:
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
111 { // begin temporary platform handling for Dlls
112 // ideally platforms issues will be handled by C-Pluff
113 // this is not an attempt at a solution
114 CStdString value;
0cefd50 changed: Moved builtin screensavers to addons so that we can utilize …
jmarshallnz authored
115 if (type == ADDON_SCREENSAVER && 0 == strnicmp(props->plugin->identifier, "screensaver.xbmc.builtin.", 25))
116 { // built in screensaver
117 return AddonPtr(new CAddon(props));
118 }
87f3fac @garbear Enable python-based screensavers
garbear authored
119 if (type == ADDON_SCREENSAVER)
120 { // Python screensaver
121 CStdString library = CAddonMgr::Get().GetExtValue(props->configuration, "@library");
122 if (URIUtils::GetExtension(library).Equals(".py", false))
123 return AddonPtr(new CScreenSaver(props));
124 }
3afe96a @Memphiz [osx/ios/atv2] - replace all __APPLE__ (even in conjunction with __ar…
Memphiz authored
125 #if defined(_LINUX) && !defined(TARGET_DARWIN)
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
126 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_linux")) && value.empty())
127 break;
128 #elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
129 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_wingl")) && value.empty())
130 break;
131 #elif defined(_WIN32) && defined(HAS_DX)
132 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_windx")) && value.empty())
133 break;
3afe96a @Memphiz [osx/ios/atv2] - replace all __APPLE__ (even in conjunction with __ar…
Memphiz authored
134 #elif defined(TARGET_DARWIN)
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
135 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_osx")) && value.empty())
136 break;
137 #endif
138 if (type == ADDON_VIZ)
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored
139 {
140 #if defined(HAS_VISUALISATION)
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
141 return AddonPtr(new CVisualisation(props));
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored
142 #endif
143 }
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
144 else
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
145 return AddonPtr(new CScreenSaver(props));
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
146 }
5ff028a added: skin support via cpluff
alcoheca authored
147 case ADDON_SKIN:
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
148 return AddonPtr(new CSkinInfo(props));
1b2781c added: basic cpluff support
alcoheca authored
149 case ADDON_VIZ_LIBRARY:
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
150 return AddonPtr(new CAddonLibrary(props));
9ea9065 changed: Move repositories to cpluff
jmarshallnz authored
151 case ADDON_REPOSITORY:
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
152 return AddonPtr(new CRepository(props));
1b2781c added: basic cpluff support
alcoheca authored
153 default:
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
154 break;
1b2781c added: basic cpluff support
alcoheca authored
155 }
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
156 return AddonPtr();
1b2781c added: basic cpluff support
alcoheca authored
157 }
158
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
159 bool CAddonMgr::CheckUserDirs(const cp_cfg_element_t *settings)
160 {
161 if (!settings)
162 return false;
163
164 const cp_cfg_element_t *userdirs = GetExtElement((cp_cfg_element_t *)settings, "userdirs");
165 if (!userdirs)
166 return false;
167
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
168 ELEMENTS elements;
169 if (!GetExtElements((cp_cfg_element_t *)userdirs, "userdir", elements))
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
170 return false;
171
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
172 ELEMENTS::iterator itr = elements.begin();
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
173 while (itr != elements.end())
174 {
175 CStdString path = GetExtValue(*itr++, "@path");
176 if (!CFile::Exists(path))
177 {
178 if (!CUtil::CreateDirectoryEx(path))
179 {
180 CLog::Log(LOGERROR, "CAddonMgr::CheckUserDirs: Unable to create directory %s.", path.c_str());
181 return false;
182 }
183 }
184 }
185
186 return true;
187 }
188
074db86 merged: addons-fw branch
elupus authored
189 CAddonMgr::CAddonMgr()
190 {
2f07dec ensure m_cpluff is initialized to NULL
Jonathan Marshall authored
191 m_cpluff = NULL;
074db86 merged: addons-fw branch
elupus authored
192 }
193
194 CAddonMgr::~CAddonMgr()
195 {
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior …
jmarshallnz authored
196 DeInit();
074db86 merged: addons-fw branch
elupus authored
197 }
198
47a8196 changed: matched other singelton calls
alcoheca authored
199 CAddonMgr &CAddonMgr::Get()
074db86 merged: addons-fw branch
elupus authored
200 {
47a8196 changed: matched other singelton calls
alcoheca authored
201 static CAddonMgr sAddonMgr;
202 return sAddonMgr;
074db86 merged: addons-fw branch
elupus authored
203 }
204
205 IAddonMgrCallback* CAddonMgr::GetCallbackForType(TYPE type)
206 {
207 if (m_managers.find(type) == m_managers.end())
208 return NULL;
209 else
210 return m_managers[type];
211 }
212
213 bool CAddonMgr::RegisterAddonMgrCallback(const TYPE type, IAddonMgrCallback* cb)
214 {
215 if (cb == NULL)
216 return false;
217
218 m_managers.erase(type);
219 m_managers[type] = cb;
220
221 return true;
222 }
223
224 void CAddonMgr::UnregisterAddonMgrCallback(TYPE type)
225 {
226 m_managers.erase(type);
227 }
228
1b2781c added: basic cpluff support
alcoheca authored
229 bool CAddonMgr::Init()
230 {
231 m_cpluff = new DllLibCPluff;
232 m_cpluff->Load();
233
b700e3f changed: Hold the addons database as a member in the AddonManager. S…
jmarshallnz authored
234 m_database.Open();
235
1b2781c added: basic cpluff support
alcoheca authored
236 if (!m_cpluff->IsLoaded())
237 {
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
238 CLog::Log(LOGERROR, "ADDONS: Fatal Error, could not load libcpluff");
239 return false;
1b2781c added: basic cpluff support
alcoheca authored
240 }
241
242 m_cpluff->set_fatal_error_handler(cp_fatalErrorHandler);
243
244 cp_status_t status;
245 status = m_cpluff->init();
246 if (status != CP_OK)
247 {
248 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_init() returned status: %i", status);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
249 return false;
1b2781c added: basic cpluff support
alcoheca authored
250 }
251
252 //TODO could separate addons into different contexts
253 // would allow partial unloading of addon framework
254 m_cp_context = m_cpluff->create_context(&status);
255 assert(m_cp_context);
8ccc965 @davilla cosmetics, remove _P define, leading underscore for var names is rese…
davilla authored
256 status = m_cpluff->register_pcollection(m_cp_context, CSpecialProtocol::TranslatePath("special://home/addons"));
257 status = m_cpluff->register_pcollection(m_cp_context, CSpecialProtocol::TranslatePath("special://xbmc/addons"));
258 status = m_cpluff->register_pcollection(m_cp_context, CSpecialProtocol::TranslatePath("special://xbmcbin/addons"));
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
259 if (status != CP_OK)
260 {
261 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_pcollection() returned status: %i", status);
262 return false;
1b2781c added: basic cpluff support
alcoheca authored
263 }
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
264
185686a added: even more missing from r29798
alcoheca authored
265 status = m_cpluff->register_logger(m_cp_context, cp_logger,
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
266 &CAddonMgr::Get(), clog_to_cp(g_advancedSettings.m_logLevel));
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
267 if (status != CP_OK)
268 {
269 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_logger() returned status: %i", status);
270 return false;
271 }
1b2781c added: basic cpluff support
alcoheca authored
272
f0b69e1 changed: move the cpluff plugin scanner call to findaddons
spiff_ authored
273 FindAddons();
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
274 return true;
1b2781c added: basic cpluff support
alcoheca authored
275 }
276
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior …
jmarshallnz authored
277 void CAddonMgr::DeInit()
278 {
279 if (m_cpluff)
280 m_cpluff->destroy();
29ce354 fixed: some mem leaks spotted by valgrind (there are many many others)
elupus authored
281 delete m_cpluff;
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior …
jmarshallnz authored
282 m_cpluff = NULL;
b700e3f changed: Hold the addons database as a member in the AddonManager. S…
jmarshallnz authored
283 m_database.Close();
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior …
jmarshallnz authored
284 }
285
56aa69b added: Support for addons to be disabled while still being installed.
jmarshallnz authored
286 bool CAddonMgr::HasAddons(const TYPE &type, bool enabled /*= true*/)
074db86 merged: addons-fw branch
elupus authored
287 {
7672f26 fixed: Ensure HasAddons respects the content type.
jmarshallnz authored
288 // TODO: This isn't particularly efficient as we create an addon type for each addon using the Factory, just so
289 // we can check addon dependencies in the addon constructor.
290 VECADDONS addons;
56aa69b added: Support for addons to be disabled while still being installed.
jmarshallnz authored
291 return GetAddons(type, addons, enabled);
074db86 merged: addons-fw branch
elupus authored
292 }
293
4029b9f fixed: Show disabled addons in the Disabled Add-ons node, allowing th…
jmarshallnz authored
294 bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabled /*= true*/, bool allowRepos /* = false */)
074db86 merged: addons-fw branch
elupus authored
295 {
816cf12 fixed: Get weather, subtitles, lyrics and library scripts to show up …
jmarshallnz authored
296 for (int i = ADDON_UNKNOWN+1; i < ADDON_VIZ_LIBRARY; ++i)
297 {
4029b9f fixed: Show disabled addons in the Disabled Add-ons node, allowing th…
jmarshallnz authored
298 if (!allowRepos && ADDON_REPOSITORY == (TYPE)i)
816cf12 fixed: Get weather, subtitles, lyrics and library scripts to show up …
jmarshallnz authored
299 continue;
300 VECADDONS temp;
56aa69b added: Support for addons to be disabled while still being installed.
jmarshallnz authored
301 if (CAddonMgr::Get().GetAddons((TYPE)i, temp, enabled))
816cf12 fixed: Get weather, subtitles, lyrics and library scripts to show up …
jmarshallnz authored
302 addons.insert(addons.end(), temp.begin(), temp.end());
303 }
af8cb2a Revert "wip"
alcoheca authored
304 return !addons.empty();
074db86 merged: addons-fw branch
elupus authored
305 }
306
0c2e7a9 @Memphiz [fix] - make changed settings visible to python addons
Memphiz authored
307 void CAddonMgr::AddToUpdateableAddons(AddonPtr &pAddon)
308 {
309 CSingleLock lock(m_critSection);
310 m_updateableAddons.push_back(pAddon);
311 }
312
313 void CAddonMgr::RemoveFromUpdateableAddons(AddonPtr &pAddon)
314 {
315 CSingleLock lock(m_critSection);
316 VECADDONS::iterator it = std::find(m_updateableAddons.begin(), m_updateableAddons.end(), pAddon);
317
318 if(it != m_updateableAddons.end())
319 {
320 m_updateableAddons.erase(it);
321 }
322 }
323
324 struct AddonIdFinder
325 {
326 AddonIdFinder(const CStdString& id)
327 : m_id(id)
328 {}
329
330 bool operator()(const AddonPtr& addon)
331 {
332 return m_id.Equals(addon->ID());
333 }
334 private:
335 CStdString m_id;
336 };
337
338 bool CAddonMgr::ReloadSettings(const CStdString &id)
339 {
340 CSingleLock lock(m_critSection);
341 VECADDONS::iterator it = std::find_if(m_updateableAddons.begin(), m_updateableAddons.end(), AddonIdFinder(id));
342
343 if( it != m_updateableAddons.end())
344 {
345 return (*it)->ReloadSettings();
346 }
347 return false;
348 }
349
e21982b added: ticket #9633 - "addons://outdated/" for listing all Add-ons wi…
spiff_ authored
350 bool CAddonMgr::GetAllOutdatedAddons(VECADDONS &addons, bool enabled /*= true*/)
351 {
352 CSingleLock lock(m_critSection);
353 for (int i = ADDON_UNKNOWN+1; i < ADDON_VIZ_LIBRARY; ++i)
354 {
355 VECADDONS temp;
356 if (CAddonMgr::Get().GetAddons((TYPE)i, temp, enabled))
357 {
358 AddonPtr repoAddon;
359 for (unsigned int j = 0; j < temp.size(); j++)
360 {
361 if (!m_database.GetAddon(temp[j]->ID(), repoAddon))
362 continue;
363
577b784 added: rollback support in the add-on installer
spiff authored
364 if (temp[j]->Version() < repoAddon->Version() &&
365 !m_database.IsAddonBlacklisted(temp[j]->ID(),
366 repoAddon->Version().c_str()))
e21982b added: ticket #9633 - "addons://outdated/" for listing all Add-ons wi…
spiff_ authored
367 addons.push_back(repoAddon);
368 }
369 }
370 }
371 return !addons.empty();
372 }
373
374 bool CAddonMgr::HasOutdatedAddons(bool enabled /*= true*/)
375 {
376 VECADDONS dummy;
377 return GetAllOutdatedAddons(dummy,enabled);
378 }
379
56aa69b added: Support for addons to be disabled while still being installed.
jmarshallnz authored
380 bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, bool enabled /* = true */)
074db86 merged: addons-fw branch
elupus authored
381 {
4e5b98a added: locks to addon manager
spiff_ authored
382 CSingleLock lock(m_critSection);
af8cb2a Revert "wip"
alcoheca authored
383 addons.clear();
8c86aee cleanup: Get rid of some more old non-cpluff stuff. Should also fix …
jmarshallnz authored
384 cp_status_t status;
385 int num;
386 CStdString ext_point(TranslateType(type));
387 cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
388 for(int i=0; i <num; i++)
af8cb2a Revert "wip"
alcoheca authored
389 {
8c86aee cleanup: Get rid of some more old non-cpluff stuff. Should also fix …
jmarshallnz authored
390 AddonPtr addon(Factory(exts[i]));
b700e3f changed: Hold the addons database as a member in the AddonManager. S…
jmarshallnz authored
391 if (addon && m_database.IsAddonDisabled(addon->ID()) != enabled)
8c86aee cleanup: Get rid of some more old non-cpluff stuff. Should also fix …
jmarshallnz authored
392 addons.push_back(addon);
af8cb2a Revert "wip"
alcoheca authored
393 }
8c86aee cleanup: Get rid of some more old non-cpluff stuff. Should also fix …
jmarshallnz authored
394 m_cpluff->release_info(m_cp_context, exts);
395 return addons.size() > 0;
074db86 merged: addons-fw branch
elupus authored
396 }
397
a317756 alternate method of allowing install of plugins that are currently no…
Jonathan Marshall authored
398 bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly /*= true*/)
074db86 merged: addons-fw branch
elupus authored
399 {
4e5b98a added: locks to addon manager
spiff_ authored
400 CSingleLock lock(m_critSection);
074db86 merged: addons-fw branch
elupus authored
401
c22f535 cosmetics
alcoheca authored
402 cp_status_t status;
84824e3 cosmetics
spiff_ authored
403 cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
404 if (status == CP_OK && cpaddon)
c22f535 cosmetics
alcoheca authored
405 {
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
406 addon = GetAddonFromDescriptor(cpaddon);
c22f535 cosmetics
alcoheca authored
407 m_cpluff->release_info(m_cp_context, cpaddon);
bfb0ba2 @opdenkamp Revert "Merge remote branch 'upstream/master'"
authored
408 if (addon.get() && enabledOnly && m_database.IsAddonDisabled(addon->ID()))
409 return false;
83a5edb fixed: Ensure the context menu in the addon manager is consistent (no…
jmarshallnz authored
410 return NULL != addon.get();
c22f535 cosmetics
alcoheca authored
411 }
412 if (cpaddon)
413 m_cpluff->release_info(m_cp_context, cpaddon);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
414
074db86 merged: addons-fw branch
elupus authored
415 return false;
416 }
417
418 //TODO handle all 'default' cases here, not just scrapers & vizs
257d969 changed: Move Addon constructors to take the extension point they're …
jmarshallnz authored
419 bool CAddonMgr::GetDefault(const TYPE &type, AddonPtr &addon)
074db86 merged: addons-fw branch
elupus authored
420 {
421 CStdString setting;
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
422 switch (type)
074db86 merged: addons-fw branch
elupus authored
423 {
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
424 case ADDON_VIZ:
425 setting = g_guiSettings.GetString("musicplayer.visualisation");
426 break;
730b6da added: addon.set.default built-in to set the default for a particular…
jmarshallnz authored
427 case ADDON_SCREENSAVER:
428 setting = g_guiSettings.GetString("screensaver.mode");
429 break;
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
430 case ADDON_SCRAPER_ALBUMS:
92be514 changed: rename these settings. type changed. update sad
spiff_ authored
431 setting = g_guiSettings.GetString("musiclibrary.albumsscraper");
c077443 changed: Split the music scraping into separate album and artist scra…
jmarshallnz authored
432 break;
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
433 case ADDON_SCRAPER_ARTISTS:
92be514 changed: rename these settings. type changed. update sad
spiff_ authored
434 setting = g_guiSettings.GetString("musiclibrary.artistsscraper");
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
435 break;
436 case ADDON_SCRAPER_MOVIES:
92be514 changed: rename these settings. type changed. update sad
spiff_ authored
437 setting = g_guiSettings.GetString("scrapers.moviesdefault");
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
438 break;
439 case ADDON_SCRAPER_MUSICVIDEOS:
92be514 changed: rename these settings. type changed. update sad
spiff_ authored
440 setting = g_guiSettings.GetString("scrapers.musicvideosdefault");
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
441 break;
442 case ADDON_SCRAPER_TVSHOWS:
92be514 changed: rename these settings. type changed. update sad
spiff_ authored
443 setting = g_guiSettings.GetString("scrapers.tvshowsdefault");
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
444 break;
113777a merged: r33383,r33386 from webinterface branch
jmarshallnz authored
445 case ADDON_WEB_INTERFACE:
446 setting = g_guiSettings.GetString("services.webskin");
447 break;
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
448 default:
449 return false;
074db86 merged: addons-fw branch
elupus authored
450 }
2ca76f9 changed: all addons should be store below either special://home/addon…
alcoheca authored
451 return GetAddon(setting, addon, type);
074db86 merged: addons-fw branch
elupus authored
452 }
453
730b6da added: addon.set.default built-in to set the default for a particular…
jmarshallnz authored
454 bool CAddonMgr::SetDefault(const TYPE &type, const CStdString &addonID)
455 {
456 switch (type)
457 {
458 case ADDON_VIZ:
459 g_guiSettings.SetString("musicplayer.visualisation",addonID);
460 break;
461 case ADDON_SCREENSAVER:
462 g_guiSettings.SetString("screensaver.mode",addonID);
463 break;
464 case ADDON_SCRAPER_ALBUMS:
465 g_guiSettings.SetString("musiclibrary.albumsscraper",addonID);
466 break;
467 case ADDON_SCRAPER_ARTISTS:
468 g_guiSettings.SetString("musiclibrary.artistsscraper",addonID);
469 break;
470 case ADDON_SCRAPER_MOVIES:
471 g_guiSettings.SetString("scrapers.moviesdefault",addonID);
472 break;
473 case ADDON_SCRAPER_MUSICVIDEOS:
474 g_guiSettings.SetString("scrapers.musicvideosdefault",addonID);
475 break;
476 case ADDON_SCRAPER_TVSHOWS:
477 g_guiSettings.SetString("scrapers.tvshowsdefault",addonID);
478 break;
479 default:
480 return false;
481 }
482
483 return true;
484 }
485
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored
486 CStdString CAddonMgr::GetString(const CStdString &id, const int number)
074db86 merged: addons-fw branch
elupus authored
487 {
8c86aee cleanup: Get rid of some more old non-cpluff stuff. Should also fix …
jmarshallnz authored
488 AddonPtr addon;
489 if (GetAddon(id, addon))
074db86 merged: addons-fw branch
elupus authored
490 return addon->GetString(number);
491
492 return "";
493 }
494
af8cb2a Revert "wip"
alcoheca authored
495 void CAddonMgr::FindAddons()
496 {
4e5b98a added: locks to addon manager
spiff_ authored
497 CSingleLock lock(m_critSection);
f0b69e1 changed: move the cpluff plugin scanner call to findaddons
spiff_ authored
498 if (m_cpluff && m_cp_context)
d8d145c fixed: update addon information after upgrade
ametovic authored
499 m_cpluff->scan_plugins(m_cp_context, CP_SP_UPGRADE);
535b4e7 changed: load addons from user directory first, then load from system…
elupus authored
500 }
501
f1031c4 fixed: disabling addons
spiff_ authored
502 void CAddonMgr::RemoveAddon(const CStdString& ID)
503 {
504 if (m_cpluff && m_cp_context)
505 m_cpluff->uninstall_plugin(m_cp_context,ID.c_str());
506 }
507
096e8a3 changed: Move description information into addon.xml via the xbmc.add…
jmarshallnz authored
508 const char *CAddonMgr::GetTranslatedString(const cp_cfg_element_t *root, const char *tag)
509 {
510 if (!root)
511 return NULL;
512
513 const cp_cfg_element_t *eng = NULL;
514 for (unsigned int i = 0; i < root->num_children; i++)
515 {
516 const cp_cfg_element_t &child = root->children[i];
517 if (strcmp(tag, child.name) == 0)
518 { // see if we have a "lang" attribute
519 const char *lang = m_cpluff->lookup_cfg_value((cp_cfg_element_t*)&child, "@lang");
520 if (lang && 0 == strcmp(lang,g_langInfo.GetDVDAudioLanguage().c_str()))
521 return child.value;
522 if (!lang || 0 == strcmp(lang, "en"))
523 eng = &child;
524 }
525 }
526 return (eng) ? eng->value : NULL;
527 }
528
eca3c5b changed: refactor
spiff_ authored
529 AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
530 {
531 switch (addonProps.type)
af8cb2a Revert "wip"
alcoheca authored
532 {
533 case ADDON_PLUGIN:
534 case ADDON_SCRIPT:
15de189 fixed: Make sure ADDON_SCRIPT uses CPluginSource so that Provides works
jmarshallnz authored
535 return AddonPtr(new CPluginSource(addonProps));
35cf15f changed: get rid of the content types added earlier, favouring extens…
jmarshallnz authored
536 case ADDON_SCRIPT_LIBRARY:
537 case ADDON_SCRIPT_LYRICS:
538 case ADDON_SCRIPT_WEATHER:
539 case ADDON_SCRIPT_SUBTITLES:
9d4264e added: Initial support for python module addons.
jmarshallnz authored
540 case ADDON_SCRIPT_MODULE:
21dd418 fixed: Webinterface section wasn't shown in Repositories
jmarshallnz authored
541 case ADDON_WEB_INTERFACE:
eca3c5b changed: refactor
spiff_ authored
542 return AddonPtr(new CAddon(addonProps));
b55ac44 added: service addons.
blinkseb authored
543 case ADDON_SERVICE:
544 return AddonPtr(new CService(addonProps));
6a9704f changed: Split scrapers into separate extension points per content ty…
jmarshallnz authored
545 case ADDON_SCRAPER_ALBUMS:
546 case ADDON_SCRAPER_ARTISTS:
547 case ADDON_SCRAPER_MOVIES:
548 case ADDON_SCRAPER_MUSICVIDEOS:
549 case ADDON_SCRAPER_TVSHOWS:
550 case ADDON_SCRAPER_LIBRARY:
eca3c5b changed: refactor
spiff_ authored
551 return AddonPtr(new CScraper(addonProps));
553d213 changed: finished moving skins to addon framework
alcoheca authored
552 case ADDON_SKIN:
553 return AddonPtr(new CSkinInfo(addonProps));
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored
554 #if defined(HAS_VISUALISATION)
af8cb2a Revert "wip"
alcoheca authored
555 case ADDON_VIZ:
eca3c5b changed: refactor
spiff_ authored
556 return AddonPtr(new CVisualisation(addonProps));
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored
557 #endif
af8cb2a Revert "wip"
alcoheca authored
558 case ADDON_SCREENSAVER:
eca3c5b changed: refactor
spiff_ authored
559 return AddonPtr(new CScreenSaver(addonProps));
af8cb2a Revert "wip"
alcoheca authored
560 case ADDON_VIZ_LIBRARY:
eca3c5b changed: refactor
spiff_ authored
561 return AddonPtr(new CAddonLibrary(addonProps));
606248f added: addon repository class
spiff_ authored
562 case ADDON_REPOSITORY:
563 return AddonPtr(new CRepository(addonProps));
af8cb2a Revert "wip"
alcoheca authored
564 default:
eca3c5b changed: refactor
spiff_ authored
565 break;
af8cb2a Revert "wip"
alcoheca authored
566 }
eca3c5b changed: refactor
spiff_ authored
567 return AddonPtr();
af8cb2a Revert "wip"
alcoheca authored
568 }
569
1b2781c added: basic cpluff support
alcoheca authored
570 /*
571 * libcpluff interaction
572 */
573
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
574 bool CAddonMgr::PlatformSupportsAddon(const cp_plugin_info_t *plugin) const
575 {
576 if (!plugin || !plugin->num_extensions)
577 return false;
578 const cp_extension_t *metadata = GetExtension(plugin, "xbmc.addon.metadata");
9d9704e cleanup: Make <supportedcontent> and <platform> use the same xs:list …
jmarshallnz authored
579 if (!metadata)
580 return false;
a388e47 added: function to parse an addon descriptor from memory
Jonathan Marshall authored
581
9d9704e cleanup: Make <supportedcontent> and <platform> use the same xs:list …
jmarshallnz authored
582 vector<CStdString> platforms;
583 if (CAddonMgr::Get().GetExtList(metadata->configuration, "platform", platforms))
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
584 {
585 for (unsigned int i = 0; i < platforms.size(); ++i)
586 {
587 if (platforms[i] == "all")
588 return true;
3afe96a @Memphiz [osx/ios/atv2] - replace all __APPLE__ (even in conjunction with __ar…
Memphiz authored
589 #if defined(_LINUX) && !defined(TARGET_DARWIN)
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
590 if (platforms[i] == "linux")
591 #elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
592 if (platforms[i] == "wingl")
593 #elif defined(_WIN32) && defined(HAS_DX)
594 if (platforms[i] == "windx")
892aeda @Memphiz [add/change] - new addon platform "ios" - this will "break" addons wh…
Memphiz authored
595 #elif defined(TARGET_DARWIN_OSX)
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
596 if (platforms[i] == "osx")
892aeda @Memphiz [add/change] - new addon platform "ios" - this will "break" addons wh…
Memphiz authored
597 #elif defined(TARGET_DARWIN_IOS)
598 if (platforms[i] == "ios")
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
599 #endif
600 return true;
601 }
9d9704e cleanup: Make <supportedcontent> and <platform> use the same xs:list …
jmarshallnz authored
602 return false; // no <platform> works for us
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
603 }
9d9704e cleanup: Make <supportedcontent> and <platform> use the same xs:list …
jmarshallnz authored
604 return true; // assume no <platform> is equivalent to <platform>all</platform>
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
605 }
606
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
607 const cp_cfg_element_t *CAddonMgr::GetExtElement(cp_cfg_element_t *base, const char *path)
608 {
609 const cp_cfg_element_t *element = NULL;
610 if (base)
611 element = m_cpluff->lookup_cfg_element(base, path);
612 return element;
613 }
614
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
615 bool CAddonMgr::GetExtElements(cp_cfg_element_t *base, const char *path, ELEMENTS &elements)
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
616 {
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
617 if (!base || !path)
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
618 return false;
619
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
620 for (unsigned int i = 0; i < base->num_children; i++)
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
621 {
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
622 CStdString temp = base->children[i].name;
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
623 if (!temp.compare(path))
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
624 elements.push_back(&base->children[i]);
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
625 }
626
6cc382e cleaned up GetExtElements and make available outside the addon manager
Jonathan Marshall authored
627 return !elements.empty();
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored
628 }
629
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
630 const cp_extension_t *CAddonMgr::GetExtension(const cp_plugin_info_t *props, const char *extension) const
096e8a3 changed: Move description information into addon.xml via the xbmc.add…
jmarshallnz authored
631 {
632 if (!props)
633 return NULL;
634 for (unsigned int i = 0; i < props->num_extensions; ++i)
635 {
636 if (0 == strcmp(props->extensions[i].ext_point_id, extension))
637 return &props->extensions[i];
638 }
639 return NULL;
640 }
641
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
642 CStdString CAddonMgr::GetExtValue(cp_cfg_element_t *base, const char *path)
643 {
644 const char *value = NULL;
645 if (base && (value = m_cpluff->lookup_cfg_value(base, path)))
646 return CStdString(value);
647 else return CStdString();
648 }
649
9d9704e cleanup: Make <supportedcontent> and <platform> use the same xs:list …
jmarshallnz authored
650 bool CAddonMgr::GetExtList(cp_cfg_element_t *base, const char *path, vector<CStdString> &result) const
a16721e changed: move scraper libraries to cpluff
spiff_ authored
651 {
9d9704e cleanup: Make <supportedcontent> and <platform> use the same xs:list …
jmarshallnz authored
652 if (!base || !path)
653 return false;
654 CStdString all = m_cpluff->lookup_cfg_value(base, path);
655 if (all.IsEmpty())
656 return false;
657 StringUtils::SplitString(all, " ", result);
658 return true;
a16721e changed: move scraper libraries to cpluff
spiff_ authored
659 }
660
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
661 AddonPtr CAddonMgr::GetAddonFromDescriptor(const cp_plugin_info_t *info)
662 {
46bdb17 allow addons with no extensions to be returned for dependency checking
Jonathan Marshall authored
663 if (!info)
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
664 return AddonPtr();
665
46bdb17 allow addons with no extensions to be returned for dependency checking
Jonathan Marshall authored
666 if (!info->extensions)
667 { // no extensions, so we need only the dep information
668 return AddonPtr(new CAddon(info));
669 }
670
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
671 // FIXME: If we want to support multiple extension points per addon, we'll need to extend this to not just take
672 // the first extension point (eg use the TYPE information we pass in)
673
674 // grab a relevant extension point, ignoring our xbmc.addon.metadata extension point
28cd382 fixed: sanity is not just a state of mind...
jmarshallnz authored
675 for (unsigned int i = 0; i < info->num_extensions; ++i)
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
676 {
677 if (0 != strcmp("xbmc.addon.metadata", info->extensions[i].ext_point_id))
678 { // note that Factory takes care of whether or not we have platform support
679 return Factory(&info->extensions[i]);
680 }
681 }
682 return AddonPtr();
683 }
684
685 // FIXME: This function may not be required
5bca9c0 cleanup: Rename and document the cpluff versions of loading addon des…
jmarshallnz authored
686 bool CAddonMgr::LoadAddonDescription(const CStdString &path, AddonPtr &addon)
92afa2e fixed: Addons weren't installed correctly
jmarshallnz authored
687 {
688 cp_status_t status;
8ccc965 @davilla cosmetics, remove _P define, leading underscore for var names is rese…
davilla authored
689 cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor(m_cp_context, CSpecialProtocol::TranslatePath(path).c_str(), &status);
92afa2e fixed: Addons weren't installed correctly
jmarshallnz authored
690 if (info)
691 {
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
692 addon = GetAddonFromDescriptor(info);
92afa2e fixed: Addons weren't installed correctly
jmarshallnz authored
693 m_cpluff->release_info(m_cp_context, info);
9785be9 cleanup: Got rid of ADDON_SCRIPT_LIBRARY, compile warnings, and cosme…
jmarshallnz authored
694 return NULL != addon.get();
92afa2e fixed: Addons weren't installed correctly
jmarshallnz authored
695 }
696 return false;
697 }
698
5bca9c0 cleanup: Rename and document the cpluff versions of loading addon des…
jmarshallnz authored
699 bool CAddonMgr::AddonsFromRepoXML(const TiXmlElement *root, VECADDONS &addons)
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored
700 {
701 // create a context for these addons
702 cp_status_t status;
703 cp_context_t *context = m_cpluff->create_context(&status);
704 if (!root || !context)
705 return false;
706
cfe53d3 fixed: Put the UTF-8 descriptor on the XML before feeding it to c-pluff
jmarshallnz authored
707 // each addon XML should have a UTF-8 declaration
708 TiXmlDeclaration decl("1.0", "UTF-8", "");
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored
709 const TiXmlElement *element = root->FirstChildElement("addon");
710 while (element)
711 {
cfe53d3 fixed: Put the UTF-8 descriptor on the XML before feeding it to c-pluff
jmarshallnz authored
712 // dump the XML back to text
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored
713 std::string xml;
cfe53d3 fixed: Put the UTF-8 descriptor on the XML before feeding it to c-pluff
jmarshallnz authored
714 xml << decl;
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored
715 xml << *element;
716 cp_status_t status;
cd2be2f added: Expose cp_load_plugin_descriptor and separate out the from_mem…
jmarshallnz authored
717 cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor_from_memory(context, xml.c_str(), xml.size(), &status);
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored
718 if (info)
719 {
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
720 AddonPtr addon = GetAddonFromDescriptor(info);
ed51e37 fixed: check for NULL before adding the addon in AddonsFromInfoXML
jmarshallnz authored
721 if (addon.get())
722 addons.push_back(addon);
2bf2640 added: Functions for sanity checking addons (platform checks and igno…
jmarshallnz authored
723 m_cpluff->release_info(context, info);
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored
724 }
725 element = element->NextSiblingElement("addon");
726 }
727 m_cpluff->destroy_context(context);
728 return true;
729 }
730
a388e47 added: function to parse an addon descriptor from memory
Jonathan Marshall authored
731 bool CAddonMgr::LoadAddonDescriptionFromMemory(const TiXmlElement *root, AddonPtr &addon)
732 {
733 // create a context for these addons
734 cp_status_t status;
735 cp_context_t *context = m_cpluff->create_context(&status);
736 if (!root || !context)
737 return false;
738
739 // dump the XML back to text
740 std::string xml;
741 xml << TiXmlDeclaration("1.0", "UTF-8", "");
742 xml << *root;
743 cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor_from_memory(context, xml.c_str(), xml.size(), &status);
744 if (info)
745 {
746 addon = GetAddonFromDescriptor(info);
747 m_cpluff->release_info(context, info);
748 }
749 m_cpluff->destroy_context(context);
750 return addon != NULL;
751 }
752
17c01c2 @blinkseb changed: allow service addon to specify when it wants to start: at st…
blinkseb authored
753 bool CAddonMgr::StartServices(const bool beforelogin)
b55ac44 added: service addons.
blinkseb authored
754 {
755 CLog::Log(LOGDEBUG, "ADDON: Starting service addons.");
756
757 VECADDONS services;
758 if (!GetAddons(ADDON_SERVICE, services))
759 return false;
760
761 bool ret = true;
762 for (IVECADDONS it = services.begin(); it != services.end(); ++it)
763 {
764 boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(*it);
765 if (service)
17c01c2 @blinkseb changed: allow service addon to specify when it wants to start: at st…
blinkseb authored
766 {
767 if ( (beforelogin && service->GetStartOption() == CService::STARTUP)
977eab0 @wsoltys finally fixed: start service addons using login after the user has lo…
wsoltys authored
768 || (!beforelogin && service->GetStartOption() == CService::LOGIN) )
17c01c2 @blinkseb changed: allow service addon to specify when it wants to start: at st…
blinkseb authored
769 ret &= service->Start();
770 }
b55ac44 added: service addons.
blinkseb authored
771 }
772
773 return ret;
774 }
775
17c01c2 @blinkseb changed: allow service addon to specify when it wants to start: at st…
blinkseb authored
776 void CAddonMgr::StopServices(const bool onlylogin)
b55ac44 added: service addons.
blinkseb authored
777 {
778 CLog::Log(LOGDEBUG, "ADDON: Stopping service addons.");
779
780 VECADDONS services;
781 if (!GetAddons(ADDON_SERVICE, services))
782 return;
783
784 for (IVECADDONS it = services.begin(); it != services.end(); ++it)
785 {
786 boost::shared_ptr<CService> service = boost::dynamic_pointer_cast<CService>(*it);
787 if (service)
17c01c2 @blinkseb changed: allow service addon to specify when it wants to start: at st…
blinkseb authored
788 {
789 if ( (onlylogin && service->GetStartOption() == CService::LOGIN)
790 || (!onlylogin) )
791 service->Stop();
792 }
b55ac44 added: service addons.
blinkseb authored
793 }
794 }
795
1b2781c added: basic cpluff support
alcoheca authored
796 int cp_to_clog(cp_log_severity_t lvl)
797 {
dec0bfe changed: sanitize the cpluff logging levels
jmarshallnz authored
798 if (lvl >= CP_LOG_ERROR)
799 return LOGINFO;
800 return LOGDEBUG;
1b2781c added: basic cpluff support
alcoheca authored
801 }
802
803 cp_log_severity_t clog_to_cp(int lvl)
804 {
dec0bfe changed: sanitize the cpluff logging levels
jmarshallnz authored
805 if (lvl >= LOG_LEVEL_DEBUG)
1b2781c added: basic cpluff support
alcoheca authored
806 return CP_LOG_INFO;
dec0bfe changed: sanitize the cpluff logging levels
jmarshallnz authored
807 return CP_LOG_ERROR;
1b2781c added: basic cpluff support
alcoheca authored
808 }
809
b6f0f59 cleanup: Don't expose the AddonManager's privates when not required.
jmarshallnz authored
810 void cp_fatalErrorHandler(const char *msg)
811 {
812 CLog::Log(LOGERROR, "ADDONS: CPluffFatalError(%s)", msg);
813 }
814
815 void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data)
1b2781c added: basic cpluff support
alcoheca authored
816 {
817 if(!apid)
5b793b6 added: missing change from r29798
alcoheca authored
818 CLog::Log(cp_to_clog(level), "ADDON: cpluff: '%s'", msg);
1b2781c added: basic cpluff support
alcoheca authored
819 else
5b793b6 added: missing change from r29798
alcoheca authored
820 CLog::Log(cp_to_clog(level), "ADDON: cpluff: '%s' reports '%s'", apid, msg);
1b2781c added: basic cpluff support
alcoheca authored
821 }
822
074db86 merged: addons-fw branch
elupus authored
823 } /* namespace ADDON */
824
Something went wrong with that request. Please try again.