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