Skip to content

HTTPS clone URL

Subversion checkout URL

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