Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 945 lines (848 sloc) 26.969 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"
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored
23 #include "AddonDatabase.h"
1b2781c added: basic cpluff support
alcoheca authored
24 #include "DllLibCPluff.h"
074db86 merged: addons-fw branch
elupus authored
25 #include "StringUtils.h"
26 #include "RegExp.h"
27 #include "XMLUtils.h"
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored
28 #include "utils/JobManager.h"
29 #include "utils/SingleLock.h"
074db86 merged: addons-fw branch
elupus authored
30 #include "FileItem.h"
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer> i...
spiff_ authored
31 #include "LangInfo.h"
074db86 merged: addons-fw branch
elupus authored
32 #include "Settings.h"
33 #include "GUISettings.h"
34 #include "DownloadQueueManager.h"
1b2781c added: basic cpluff support
alcoheca authored
35 #include "AdvancedSettings.h"
dacdca0 changed: moved CAddonStatusHandler to separate files
alcoheca authored
36 #include "log.h"
074db86 merged: addons-fw branch
elupus authored
37
38 #ifdef HAS_VISUALISATION
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored
39 #include "DllVisualisation.h"
40 #include "Visualisation.h"
074db86 merged: addons-fw branch
elupus authored
41 #endif
42 #ifdef HAS_SCREENSAVER
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored
43 #include "DllScreenSaver.h"
44 #include "ScreenSaver.h"
074db86 merged: addons-fw branch
elupus authored
45 #endif
46 //#ifdef HAS_SCRAPERS
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored
47 #include "Scraper.h"
074db86 merged: addons-fw branch
elupus authored
48 //#endif
606248f added: addon repository class
spiff_ authored
49 #include "Repository.h"
553d213 changed: finished moving skins to addon framework
alcoheca authored
50 #include "Skin.h"
af8cb2a Revert "wip"
alcoheca authored
51
88e9b6f changed: expand std namespace
spiff_ authored
52 using namespace std;
53
074db86 merged: addons-fw branch
elupus authored
54 namespace ADDON
55 {
56
185686a added: even more missing from r29798
alcoheca authored
57 int cp_to_clog(cp_log_severity_t);
58 cp_log_severity_t clog_to_cp(int);
074db86 merged: addons-fw branch
elupus authored
59
60 /**********************************************************
61 * CAddonMgr
62 *
63 */
64
88e9b6f changed: expand std namespace
spiff_ authored
65 map<TYPE, IAddonMgrCallback*> CAddonMgr::m_managers;
074db86 merged: addons-fw branch
elupus authored
66
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
67 AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
1b2781c added: basic cpluff support
alcoheca authored
68 {
69 const TYPE type = TranslateType(props->ext_point_id);
70 switch (type)
71 {
72 case ADDON_PLUGIN:
73 case ADDON_SCRIPT:
74 return AddonPtr(new CAddon(props->plugin));
75 case ADDON_SCRAPER:
76 return AddonPtr(new CScraper(props->plugin));
77 case ADDON_VIZ:
78 case ADDON_SCREENSAVER:
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
79 { // begin temporary platform handling for Dlls
80 // ideally platforms issues will be handled by C-Pluff
81 // this is not an attempt at a solution
82 CStdString value;
83 #if defined(_LINUX) && !defined(__APPLE__)
84 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_linux")) && value.empty())
85 break;
86 #elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
87 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_wingl")) && value.empty())
88 break;
89 #elif defined(_WIN32) && defined(HAS_DX)
90 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_windx")) && value.empty())
91 break;
92 #elif defined(__APPLE__)
93 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_osx")) && value.empty())
94 break;
95 #elif defined(_XBOX)
96 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_xbox")) && value.empty())
97 break;
98 #endif
99 if (type == ADDON_VIZ)
100 return AddonPtr(new CVisualisation(props->plugin));
101 else
102 return AddonPtr(new CScreenSaver(props->plugin));
103 }
5ff028a added: skin support via cpluff
alcoheca authored
104 case ADDON_SKIN:
105 return AddonPtr(new CSkinInfo(props->plugin));
1b2781c added: basic cpluff support
alcoheca authored
106 case ADDON_SCRAPER_LIBRARY:
107 case ADDON_VIZ_LIBRARY:
108 return AddonPtr(new CAddonLibrary(props->plugin));
109 default:
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
110 break;
1b2781c added: basic cpluff support
alcoheca authored
111 }
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
112 return AddonPtr();
1b2781c added: basic cpluff support
alcoheca authored
113 }
114
074db86 merged: addons-fw branch
elupus authored
115 CAddonMgr::CAddonMgr()
116 {
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored
117 FindAddons();
118 m_watch.StartZero();
074db86 merged: addons-fw branch
elupus authored
119 }
120
121 CAddonMgr::~CAddonMgr()
122 {
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior to ...
jmarshallnz authored
123 DeInit();
074db86 merged: addons-fw branch
elupus authored
124 }
125
47a8196 changed: matched other singelton calls
alcoheca authored
126 CAddonMgr &CAddonMgr::Get()
074db86 merged: addons-fw branch
elupus authored
127 {
47a8196 changed: matched other singelton calls
alcoheca authored
128 static CAddonMgr sAddonMgr;
129 return sAddonMgr;
074db86 merged: addons-fw branch
elupus authored
130 }
131
132 IAddonMgrCallback* CAddonMgr::GetCallbackForType(TYPE type)
133 {
134 if (m_managers.find(type) == m_managers.end())
135 return NULL;
136 else
137 return m_managers[type];
138 }
139
140 bool CAddonMgr::RegisterAddonMgrCallback(const TYPE type, IAddonMgrCallback* cb)
141 {
142 if (cb == NULL)
143 return false;
144
145 m_managers.erase(type);
146 m_managers[type] = cb;
147
148 return true;
149 }
150
151 void CAddonMgr::UnregisterAddonMgrCallback(TYPE type)
152 {
153 m_managers.erase(type);
154 }
155
1b2781c added: basic cpluff support
alcoheca authored
156 bool CAddonMgr::Init()
157 {
158 m_cpluff = new DllLibCPluff;
159 m_cpluff->Load();
160
161 if (!m_cpluff->IsLoaded())
162 {
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
163 CLog::Log(LOGERROR, "ADDONS: Fatal Error, could not load libcpluff");
164 return false;
1b2781c added: basic cpluff support
alcoheca authored
165 }
166
167 m_cpluff->set_fatal_error_handler(cp_fatalErrorHandler);
168
169 cp_status_t status;
170 status = m_cpluff->init();
171 if (status != CP_OK)
172 {
173 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_init() returned status: %i", status);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
174 return false;
1b2781c added: basic cpluff support
alcoheca authored
175 }
176
177 //TODO could separate addons into different contexts
178 // would allow partial unloading of addon framework
179 m_cp_context = m_cpluff->create_context(&status);
180 assert(m_cp_context);
181 if (!CSpecialProtocol::XBMCIsHome())
182 {
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
183 status = m_cpluff->register_pcollection(m_cp_context, _P("special://home/addons"));
184 }
185 status = m_cpluff->register_pcollection(m_cp_context, _P("special://xbmc/addons"));
186 if (status != CP_OK)
187 {
188 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_pcollection() returned status: %i", status);
189 return false;
1b2781c added: basic cpluff support
alcoheca authored
190 }
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
191
185686a added: even more missing from r29798
alcoheca authored
192 status = m_cpluff->register_logger(m_cp_context, cp_logger,
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
193 &CAddonMgr::Get(), clog_to_cp(g_advancedSettings.m_logLevel));
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
194 if (status != CP_OK)
195 {
196 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_logger() returned status: %i", status);
197 return false;
198 }
1b2781c added: basic cpluff support
alcoheca authored
199
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
200 status = m_cpluff->scan_plugins(m_cp_context, 0);
201 return true;
1b2781c added: basic cpluff support
alcoheca authored
202 }
203
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior to ...
jmarshallnz authored
204 void CAddonMgr::DeInit()
205 {
206 if (m_cpluff)
207 m_cpluff->destroy();
208 m_cpluff = NULL;
209 }
210
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored
211 bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
074db86 merged: addons-fw branch
elupus authored
212 {
5ff028a added: skin support via cpluff
alcoheca authored
213 if (type == ADDON_SCREENSAVER || type == ADDON_SKIN)
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
214 {
215 cp_status_t status;
216 int num;
217 CStdString ext_point(TranslateType(type));
218 cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
219 if (status == CP_OK)
220 return (num > 0);
221 }
222
af8cb2a Revert "wip"
alcoheca authored
223 if (m_addons.empty())
224 {
225 VECADDONS add;
226 GetAllAddons(add,false);
227 }
228
229 if (content == CONTENT_NONE)
230 return (m_addons.find(type) != m_addons.end());
074db86 merged: addons-fw branch
elupus authored
231
232 VECADDONS addons;
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored
233 return GetAddons(type, addons, content, enabledOnly);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
234
074db86 merged: addons-fw branch
elupus authored
235 }
236
237 bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabledOnly/*= true*/)
238 {
af8cb2a Revert "wip"
alcoheca authored
239 VECADDONS temp;
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
240 if (CAddonMgr::Get().GetAddons(ADDON_PLUGIN, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored
241 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
242 if (CAddonMgr::Get().GetAddons(ADDON_SCRAPER, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored
243 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
244 if (CAddonMgr::Get().GetAddons(ADDON_SCREENSAVER, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored
245 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
246 if (CAddonMgr::Get().GetAddons(ADDON_SCRIPT, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored
247 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
248 if (CAddonMgr::Get().GetAddons(ADDON_SKIN, temp, CONTENT_NONE, enabledOnly))
553d213 changed: finished moving skins to addon framework
alcoheca authored
249 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored
250 if (CAddonMgr::Get().GetAddons(ADDON_VIZ, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored
251 addons.insert(addons.end(), temp.begin(), temp.end());
252 return !addons.empty();
074db86 merged: addons-fw branch
elupus authored
253 }
254
255 bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
256 {
4e5b98a added: locks to addon manager
spiff_ authored
257 CSingleLock lock(m_critSection);
af8cb2a Revert "wip"
alcoheca authored
258 addons.clear();
5ff028a added: skin support via cpluff
alcoheca authored
259 if (type == ADDON_SCREENSAVER || type == ADDON_SKIN)
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
260 {
261 cp_status_t status;
262 int num;
263 CStdString ext_point(TranslateType(type));
264 cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
265 for(int i=0; i <num; i++)
266 {
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
267 AddonPtr addon(Factory(exts[i]));
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
268 if (addon)
269 addons.push_back(addon);
270 }
271 m_cpluff->release_info(m_cp_context, exts);
6933a8d fixed: compile warning
jmarshallnz authored
272 return addons.size() > 0;
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
273 }
274
af8cb2a Revert "wip"
alcoheca authored
275 if (m_addons.find(type) != m_addons.end())
276 {
277 IVECADDONS itr = m_addons[type].begin();
278 while (itr != m_addons[type].end())
279 { // filter out what we're not looking for
dea84cb changed: Disabled() -> Enabled() - more intuitive
spiff_ authored
280 if ((enabledOnly && !(*itr)->Enabled())
af8cb2a Revert "wip"
alcoheca authored
281 || (content != CONTENT_NONE && !(*itr)->Supports(content)))
282 {
283 ++itr;
284 continue;
285 }
286 addons.push_back(*itr);
287 ++itr;
288 }
289 }
290 return !addons.empty();
074db86 merged: addons-fw branch
elupus authored
291 }
292
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored
293 bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly/*= true*/)
074db86 merged: addons-fw branch
elupus authored
294 {
4e5b98a added: locks to addon manager
spiff_ authored
295 CSingleLock lock(m_critSection);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
296 if (type != ADDON_UNKNOWN
297 && type != ADDON_SCREENSAVER
5ff028a added: skin support via cpluff
alcoheca authored
298 && type != ADDON_SKIN
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
299 && m_addons.find(type) == m_addons.end())
074db86 merged: addons-fw branch
elupus authored
300 return false;
301
5ddd934 fixed: only check cpluff for certain types right now
alcoheca authored
302 if (type == ADDON_SCREENSAVER || type == ADDON_SKIN)
303 {
304 cp_status_t status;
305 cp_plugin_info_t *cpaddon = NULL;
306 cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
307 if (status == CP_OK && cpaddon->extensions)
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored
308 return (addon = Factory(cpaddon->extensions));
5ddd934 fixed: only check cpluff for certain types right now
alcoheca authored
309 else
310 return false;
311 }
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
312
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored
313 if (m_idMap[str])
314 {
315 addon = m_idMap[str];
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored
316 if(enabledOnly)
dea84cb changed: Disabled() -> Enabled() - more intuitive
spiff_ authored
317 return addon->Enabled();
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored
318 else
319 return true;
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored
320 }
074db86 merged: addons-fw branch
elupus authored
321
322 VECADDONS &addons = m_addons[type];
323 IVECADDONS adnItr = addons.begin();
324 while (adnItr != addons.end())
325 {
326 //FIXME scrapers were previously registered by filename
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored
327 if ((*adnItr)->Name() == str || (type == ADDON_SCRAPER && (*adnItr)->LibName() == str))
074db86 merged: addons-fw branch
elupus authored
328 {
329 addon = (*adnItr);
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored
330 if(enabledOnly)
dea84cb changed: Disabled() -> Enabled() - more intuitive
spiff_ authored
331 return addon->Enabled();
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored
332 else
333 return true;
074db86 merged: addons-fw branch
elupus authored
334 }
335 adnItr++;
336 }
337
338 return false;
339 }
340
341 //TODO handle all 'default' cases here, not just scrapers & vizs
342 bool CAddonMgr::GetDefault(const TYPE &type, AddonPtr &addon, const CONTENT_TYPE &content)
343 {
344 if (type != ADDON_SCRAPER && type != ADDON_VIZ)
345 return false;
346
347 CStdString setting;
348 if (type == ADDON_VIZ)
349 setting = g_guiSettings.GetString("musicplayer.visualisation");
350 else
351 {
352 switch (content)
353 {
354 case CONTENT_MOVIES:
355 {
356 setting = g_guiSettings.GetString("scrapers.moviedefault");
357 break;
358 }
359 case CONTENT_TVSHOWS:
360 {
361 setting = g_guiSettings.GetString("scrapers.tvshowdefault");
362 break;
363 }
364 case CONTENT_MUSICVIDEOS:
365 {
366 setting = g_guiSettings.GetString("scrapers.musicvideodefault");
367 break;
368 }
369 case CONTENT_ALBUMS:
370 case CONTENT_ARTISTS:
371 {
372 setting = g_guiSettings.GetString("musiclibrary.scraper");
373 break;
374 }
375 default:
376 return false;
377 }
378 }
2ca76f9 changed: all addons should be store below either special://home/addons o...
alcoheca authored
379 return GetAddon(setting, addon, type);
074db86 merged: addons-fw branch
elupus authored
380 }
381
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored
382 CStdString CAddonMgr::GetString(const CStdString &id, const int number)
074db86 merged: addons-fw branch
elupus authored
383 {
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored
384 AddonPtr addon = m_idMap[id];
074db86 merged: addons-fw branch
elupus authored
385 if (addon)
386 return addon->GetString(number);
387
388 return "";
389 }
390
af8cb2a Revert "wip"
alcoheca authored
391 void CAddonMgr::FindAddons()
392 {
4e5b98a added: locks to addon manager
spiff_ authored
393 CSingleLock lock(m_critSection);
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored
394 m_addons.clear();
395 m_idMap.clear();
c8f3bba fixed: dependency resolving
spiff_ authored
396
397 // store any addons with unresolved deps, then recheck at the end
398 map<CStdString, AddonPtr> unresolved;
399
28831ed fixed: don't check special://xbmc/addons twice when running with -p
alcoheca authored
400 if (!CSpecialProtocol::XBMCIsHome())
c8f3bba fixed: dependency resolving
spiff_ authored
401 LoadAddons("special://home/addons",unresolved);
402 LoadAddons("special://xbmc/addons",unresolved);
403
404 for (map<CStdString,AddonPtr>::iterator it = unresolved.begin();
405 it != unresolved.end(); ++it)
406 {
407 if (DependenciesMet(it->second))
408 {
409 if (!UpdateIfKnown(it->second))
410 {
411 m_addons[it->second->Type()].push_back(it->second);
412 m_idMap.insert(make_pair(it->first,it->second));
413 }
414 }
415 }
535b4e7 changed: load addons from user directory first, then load from system di...
elupus authored
416 }
417
c8f3bba fixed: dependency resolving
spiff_ authored
418 void CAddonMgr::LoadAddons(const CStdString &path,
419 map<CStdString, AddonPtr>& unresolved)
535b4e7 changed: load addons from user directory first, then load from system di...
elupus authored
420 {
af8cb2a Revert "wip"
alcoheca authored
421 // parse the user & system dirs for addons of the requested type
422 CFileItemList items;
535b4e7 changed: load addons from user directory first, then load from system di...
elupus authored
423 CDirectory::GetDirectory(path, items);
af8cb2a Revert "wip"
alcoheca authored
424
425 // for all folders found
426 for (int i = 0; i < items.Size(); ++i)
427 {
428 CFileItemPtr item = items[i];
429
430 if(!item->m_bIsFolder)
431 continue;
432
433 // read description.xml and populate the addon
434 AddonPtr addon;
435 if (!AddonFromInfoXML(item->m_strPath, addon))
436 continue;
437
535b4e7 changed: load addons from user directory first, then load from system di...
elupus authored
438 // only load if addon with same id isn't already loaded
c8f3bba fixed: dependency resolving
spiff_ authored
439 if(m_idMap.find(addon->ID()) != m_idMap.end() ||
440 unresolved.find(addon->ID()) != unresolved.end())
535b4e7 changed: load addons from user directory first, then load from system di...
elupus authored
441 {
442 CLog::Log(LOGDEBUG, "ADDON: already loaded id %s, bypassing package", addon->ID().c_str());
443 continue;
444 }
445
af8cb2a Revert "wip"
alcoheca authored
446 // refuse to store addons with missing library
447 CStdString library(CUtil::AddFileToFolder(addon->Path(), addon->LibName()));
448 if (!CFile::Exists(library))
449 {
450 CLog::Log(LOGDEBUG, "ADDON: Missing library file %s, bypassing package", library.c_str());
451 continue;
452 }
453
454 if (!DependenciesMet(addon))
455 {
c8f3bba fixed: dependency resolving
spiff_ authored
456 unresolved.insert(make_pair(addon->ID(),addon));
af8cb2a Revert "wip"
alcoheca authored
457 continue;
458 }
459 else
460 { // everything ok, add to available addons if new
461 if (UpdateIfKnown(addon))
462 continue;
463 else
464 {
465 m_addons[addon->Type()].push_back(addon);
88e9b6f changed: expand std namespace
spiff_ authored
466 m_idMap.insert(make_pair(addon->ID(), addon));
af8cb2a Revert "wip"
alcoheca authored
467 }
468 }
469 }
470 }
471
472 bool CAddonMgr::UpdateIfKnown(AddonPtr &addon)
473 {
474 if (m_addons.find(addon->Type()) != m_addons.end())
475 {
476 for (unsigned i = 0; i < m_addons[addon->Type()].size(); i++)
477 {
478 if (m_addons[addon->Type()][i]->ID() == addon->ID())
479 {
480 //TODO inform any manager first, and request removal
481 //TODO choose most recent version if varying
482 m_addons[addon->Type()][i] = addon;
483 CStdString id = addon->ID();
484 m_idMap.erase(id);
88e9b6f changed: expand std namespace
spiff_ authored
485 m_idMap.insert(make_pair(addon->ID(), addon));
af8cb2a Revert "wip"
alcoheca authored
486 return true;
487 }
488 }
489 }
490 return false;
491 }
492
493 bool CAddonMgr::DependenciesMet(AddonPtr &addon)
494 {
495 if (!addon)
496 return false;
497
4e5b98a added: locks to addon manager
spiff_ authored
498 CSingleLock lock(m_critSection);
af8cb2a Revert "wip"
alcoheca authored
499 ADDONDEPS deps = addon->GetDeps();
500 ADDONDEPS::iterator itr = deps.begin();
501 while (itr != deps.end())
502 {
503 CStdString id;
504 id = (*itr).first;
505 AddonVersion min = (*itr).second.first;
506 AddonVersion max = (*itr).second.second;
507 if (m_idMap.count(id))
508 {
509 AddonPtr dep = m_idMap[id];
510 // we're guaranteed to have at least max OR min here
511 if (!min.str.IsEmpty() && !max.str.IsEmpty())
c8f3bba fixed: dependency resolving
spiff_ authored
512 {
513 if (dep->Version() < min || dep->Version() > max)
514 return false;
515 }
af8cb2a Revert "wip"
alcoheca authored
516 else if (!min.str.IsEmpty())
c8f3bba fixed: dependency resolving
spiff_ authored
517 {
518 if (dep->Version() < min)
519 return false;
520 }
af8cb2a Revert "wip"
alcoheca authored
521 else
c8f3bba fixed: dependency resolving
spiff_ authored
522 {
523 if (dep->Version() > max)
524 return false;
525 }
af8cb2a Revert "wip"
alcoheca authored
526 }
527 itr++;
528 }
c8f3bba fixed: dependency resolving
spiff_ authored
529 return true;
af8cb2a Revert "wip"
alcoheca authored
530 }
531
532 bool CAddonMgr::AddonFromInfoXML(const CStdString &path, AddonPtr &addon)
533 {
534 // First check that we can load description.xml
535 CStdString strPath(CUtil::AddFileToFolder(path, ADDON_METAFILE));
536 if(!CFile::Exists(strPath))
537 return false;
538
539 TiXmlDocument xmlDoc;
540 if (!xmlDoc.LoadFile(strPath))
541 {
542 CLog::Log(LOGERROR, "Unable to load: %s, Line %d\n%s", strPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
543 return false;
544 }
545
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
546 const TiXmlElement *element = xmlDoc.RootElement();
af8cb2a Revert "wip"
alcoheca authored
547 if (!element || strcmpi(element->Value(), "addoninfo") != 0)
548 {
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
549 CLog::Log(LOGERROR, "ADDON: Error loading %s: cannot find <addon> root element", xmlDoc.Value());
af8cb2a Revert "wip"
alcoheca authored
550 return false;
551 }
552
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
553 return AddonFromInfoXML(element, addon, strPath);
554 }
555
556 bool CAddonMgr::AddonFromInfoXML(const TiXmlElement *rootElement,
557 AddonPtr &addon, const CStdString &strPath)
558 {
af8cb2a Revert "wip"
alcoheca authored
559 /* Steps required to meet package requirements
560 * 1. id exists and is valid
561 * 2. type exists and is valid
562 * 3. version exists
563 * 4. a license is specified
564 * 5. operating system matches ours
565 * 6. summary exists
566 * 7. for scrapers & plugins, support at least one type of content
567 *
568 * NOTE: addon dependencies are handled in ::FindAddons()
569 */
570
571 /* Validate id */
572 CStdString id;
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
573 const TiXmlElement *element = rootElement->FirstChildElement("id");
af8cb2a Revert "wip"
alcoheca authored
574 if (!element)
575 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
576 CLog::Log(LOGERROR, "ADDON: %s missing <id> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
577 return false;
578 }
579 id = element->GetText();
580 //FIXME since we no longer required uuids, should we bother validating anything?
581 if (id.IsEmpty())
582 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
583 CLog::Log(LOGERROR, "ADDON: %s has invalid <id> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
584 return false;
585 }
586
587 /* Validate type */
588 TYPE type;
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
589 element = rootElement->FirstChildElement("type");
af8cb2a Revert "wip"
alcoheca authored
590 if (!element)
591 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
592 CLog::Log(LOGERROR, "ADDON: %s missing <type> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
593 return false;
594 }
595 type = TranslateType(element->GetText());
596 if (type == ADDON_UNKNOWN)
597 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
598 CLog::Log(LOGERROR, "ADDON: %s has invalid type identifier: '%d'", rootElement->GetDocument()->Value(), type);
af8cb2a Revert "wip"
alcoheca authored
599 return false;
600 }
601
602 /* Retrieve Name */
603 CStdString name;
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer> i...
spiff_ authored
604 if (!GetTranslatedString(rootElement,"title",name))
af8cb2a Revert "wip"
alcoheca authored
605 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
606 CLog::Log(LOGERROR, "ADDON: %s missing <title> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
607 return false;
608 }
609
610 /* Retrieve version */
611 CStdString version;
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
612 element = rootElement->FirstChildElement("version");
af8cb2a Revert "wip"
alcoheca authored
613 if (!element)
614 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
615 CLog::Log(LOGERROR, "ADDON: %s missing <version> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
616 return false;
617 }
618 /* Validate version */
619 version = element->GetText();
620 CRegExp versionRE;
621 versionRE.RegComp(ADDON_VERSION_RE.c_str());
622 if (versionRE.RegFind(version.c_str()) != 0)
623 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
624 CLog::Log(LOGERROR, "ADDON: %s has invalid <version> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
625 return false;
626 }
627
628 /* Path, ID & Version are valid */
629 AddonProps addonProps(id, type, version);
630 addonProps.name = name;
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
631 CUtil::GetDirectory(strPath,addonProps.path);
a594abe changed: move addon thumbs back to a fixed image (icon.png). We still h...
jmarshallnz authored
632 /* Set Icon */
633 addonProps.icon = "icon.png";
e90479d added: addon changelog support
spiff_ authored
634 /* Set Changelog */
635 addonProps.changelog = CUtil::AddFileToFolder(addonProps.path,"changelog.txt");
d9e6ddf added: fanart support for addons
spiff_ authored
636 /* Set Fanart */
d3c62cd fixed: Addon changelogs weren't being read.
jmarshallnz authored
637 addonProps.fanart = CUtil::AddFileToFolder(addonProps.path,"fanart.jpg");
af8cb2a Revert "wip"
alcoheca authored
638
639 /* Retrieve license */
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
640 element = rootElement->FirstChildElement("license");
af8cb2a Revert "wip"
alcoheca authored
641 /* if (!element)
642 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
643 CLog::Log(LOGERROR, "ADDON: %s missing <license> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
644 return false;
645 }
646 addonProps.license = element->GetText();*/
647
648 /* Retrieve platforms which this addon supports */
649 CStdString platform;
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
650 element = rootElement->FirstChildElement("platforms")->FirstChildElement("platform");
af8cb2a Revert "wip"
alcoheca authored
651 if (!element)
652 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
653 CLog::Log(LOGERROR, "ADDON: %s missing <platforms> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
654 return false;
655 }
656
657 bool all(false);
88e9b6f changed: expand std namespace
spiff_ authored
658 set<CStdString> platforms;
af8cb2a Revert "wip"
alcoheca authored
659 do
660 {
661 CStdString platform = element->GetText();
662 if (platform == "all")
663 {
664 all = true;
665 break;
666 }
667 platforms.insert(platform);
668 element = element->NextSiblingElement("platform");
669 } while (element != NULL);
670
671 if (!all)
672 {
673 #if defined(_LINUX) && !defined(__APPLE__)
674 if (!platforms.count("linux"))
675 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
676 CLog::Log(LOGNOTICE, "ADDON: %s is not supported under Linux, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
677 return false;
678 }
78d5324 added: separate addon platforms for windows+dx and windows+opengl
spiff_ authored
679 #elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
680 if (!platforms.count("windows-gl") && !platforms.count("windows"))
af8cb2a Revert "wip"
alcoheca authored
681 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
682 CLog::Log(LOGNOTICE, "ADDON: %s is not supported under Windows/OpenGL, ignoring", rootElement->GetDocument()->Value());
78d5324 added: separate addon platforms for windows+dx and windows+opengl
spiff_ authored
683 return false;
684 }
685 #elif defined(_WIN32) && defined(HAS_DX)
686 if (!platforms.count("windows-dx") && !platforms.count("windows"))
687 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
688 CLog::Log(LOGNOTICE, "ADDON: %s is not supported under Windows/DirectX, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
689 return false;
690 }
691 #elif defined(__APPLE__)
692 if (!platforms.count("osx"))
693 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
694 CLog::Log(LOGNOTICE, "ADDON: %s is not supported under OSX, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
695 return false;
696 }
697 #elif defined(_XBOX)
698 if (!platforms.count("xbox"))
699 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
700 CLog::Log(LOGNOTICE, "ADDON: %s is not supported under XBOX, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
701 return false;
702 }
703 #endif
704 }
705
706 /* Retrieve summary */
d10c108 fixed: missing addon summary.
jmarshallnz authored
707 if (!GetTranslatedString(rootElement,"summary",addonProps.summary))
af8cb2a Revert "wip"
alcoheca authored
708 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
709 CLog::Log(LOGERROR, "ADDON: %s missing <summary> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
710 return false;
711 }
712
713 if (addonProps.type == ADDON_SCRAPER || addonProps.type == ADDON_PLUGIN)
714 {
715 /* Retrieve content types that this addon supports */
716 CStdString platform;
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
717 if (rootElement->FirstChildElement("supportedcontent"))
af8cb2a Revert "wip"
alcoheca authored
718 {
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
719 element = rootElement->FirstChildElement("supportedcontent")->FirstChildElement("content");
af8cb2a Revert "wip"
alcoheca authored
720 }
721 if (!element)
722 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
723 CLog::Log(LOGERROR, "ADDON: %s missing <supportedcontent> element, ignoring", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
724 return false;
725 }
726
88e9b6f changed: expand std namespace
spiff_ authored
727 set<CONTENT_TYPE> contents;
af8cb2a Revert "wip"
alcoheca authored
728 do
729 {
730 CONTENT_TYPE content = TranslateContent(element->GetText());
731 if (content != CONTENT_NONE)
732 {
733 contents.insert(content);
734 }
735 element = element->NextSiblingElement("content");
736 } while (element != NULL);
737
738 if (contents.empty())
739 {
740 CLog::Log(LOGERROR, "ADDON: %s %s supports no available content-types, ignoring", TranslateType(addonProps.type).c_str(), addonProps.name.c_str());
741 return false;
742 }
743 else
744 {
745 addonProps.contents = contents;
746 }
747 }
748
749 /*** Beginning of optional fields ***/
309adab changed: Read addon icon from the <icon> tag rather than assuming defaul...
jmarshallnz authored
750 /* Retrieve icon */
751 element = rootElement->FirstChildElement("icon");
752 if (element)
753 addonProps.icon = element->GetText();
754
af8cb2a Revert "wip"
alcoheca authored
755 /* Retrieve description */
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
756 element = rootElement->FirstChildElement("description");
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer> i...
spiff_ authored
757 GetTranslatedString(rootElement,"description",addonProps.description);
af8cb2a Revert "wip"
alcoheca authored
758
759 /* Retrieve author */
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
760 element = rootElement->FirstChildElement("author");
af8cb2a Revert "wip"
alcoheca authored
761 if (element)
762 addonProps.author = element->GetText();
763
764 /* Retrieve disclaimer */
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
765 element = rootElement->FirstChildElement("disclaimer");
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer> i...
spiff_ authored
766 GetTranslatedString(rootElement,"disclaimer",addonProps.disclaimer);
af8cb2a Revert "wip"
alcoheca authored
767
768 /* Retrieve library file name */
769 // will be replaced with default library name if unspecified
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
770 element = rootElement->FirstChildElement("library");
af8cb2a Revert "wip"
alcoheca authored
771 if (element)
772 addonProps.libname = element->GetText();
773
774 //TODO move this to addon specific class, if it's needed at all..
775 #ifdef _WIN32
776 /* Retrieve WIN32 library file name in case it is present
777 * This is required for no overwrite to the fixed WIN32 add-on's
778 * during compile time
779 */
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
780 element = rootElement->FirstChildElement("librarywin32");
af8cb2a Revert "wip"
alcoheca authored
781 if (element) // If it is found overwrite standard library name
782 addonProps.libname = element->GetText();
783 #endif
784
785 /* Retrieve dependencies that this addon requires */
4ccec44 changed: refactor addon info loading to make it reusable elsewhere
spiff_ authored
786 element = rootElement->FirstChildElement("dependencies");
af8cb2a Revert "wip"
alcoheca authored
787 if (element)
788 {
789 element = element->FirstChildElement("dependency");
790 if (!element)
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
791 CLog::Log(LOGDEBUG, "ADDON: %s missing at least one <dependency> element, will ignore this dependency", rootElement->GetDocument()->Value());
af8cb2a Revert "wip"
alcoheca authored
792 else
793 {
794 do
795 {
8a457f5 fixed: somebody must have had a blond moment - you can't check a stdstri...
spiff_ authored
796 const char* min = element->Attribute("minversion");
797 const char* max = element->Attribute("maxversion");
798 const char* id = element->GetText();
799 if (!id || (!min && !max))
af8cb2a Revert "wip"
alcoheca authored
800 {
349765e cleanup: Removed unnecessary code and changed logging code in addons to ...
jmarshallnz authored
801 CLog::Log(LOGDEBUG, "ADDON: %s malformed <dependency> element, will ignore this dependency", rootElement->GetDocument()->Value());
8a457f5 fixed: somebody must have had a blond moment - you can't check a stdstri...
spiff_ authored
802 element = element->NextSiblingElement("dependency");
af8cb2a Revert "wip"
alcoheca authored
803 continue;
804 }
8a457f5 fixed: somebody must have had a blond moment - you can't check a stdstri...
spiff_ authored
805 addonProps.dependencies.insert(make_pair(CStdString(id), make_pair(AddonVersion(min?min:""), AddonVersion(max?max:""))));
af8cb2a Revert "wip"
alcoheca authored
806 element = element->NextSiblingElement("dependency");
807 } while (element != NULL);
808 }
809 }
810
811 /*** end of optional fields ***/
812
813 /* Create an addon object and store in a shared_ptr */
eca3c5b changed: refactor
spiff_ authored
814 addon = AddonFromProps(addonProps);
815
816 return addon.get() != NULL;
817 }
818
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer> i...
spiff_ authored
819 bool CAddonMgr::GetTranslatedString(const TiXmlElement *xmldoc, const char *tag, CStdString& data)
820 {
821 const TiXmlElement *element = xmldoc->FirstChildElement(tag);
822 const TiXmlElement *enelement = NULL;
823 while (element)
824 {
825 const char* lang = element->Attribute("lang");
826 if (lang && strcmp(lang,g_langInfo.GetDVDAudioLanguage().c_str()) == 0)
827 break;
828 if (!lang || strcmp(lang,"en") == 0)
829 enelement = element;
830 element = element->NextSiblingElement(tag);
831 }
832 if (!element)
833 element = enelement;
834 if (element)
835 data = element->GetText();
836
837 return element != NULL;
838 }
839
eca3c5b changed: refactor
spiff_ authored
840 AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
841 {
842 switch (addonProps.type)
af8cb2a Revert "wip"
alcoheca authored
843 {
844 case ADDON_PLUGIN:
845 case ADDON_SCRIPT:
eca3c5b changed: refactor
spiff_ authored
846 return AddonPtr(new CAddon(addonProps));
af8cb2a Revert "wip"
alcoheca authored
847 case ADDON_SCRAPER:
eca3c5b changed: refactor
spiff_ authored
848 return AddonPtr(new CScraper(addonProps));
553d213 changed: finished moving skins to addon framework
alcoheca authored
849 case ADDON_SKIN:
850 return AddonPtr(new CSkinInfo(addonProps));
af8cb2a Revert "wip"
alcoheca authored
851 case ADDON_VIZ:
eca3c5b changed: refactor
spiff_ authored
852 return AddonPtr(new CVisualisation(addonProps));
af8cb2a Revert "wip"
alcoheca authored
853 case ADDON_SCREENSAVER:
eca3c5b changed: refactor
spiff_ authored
854 return AddonPtr(new CScreenSaver(addonProps));
af8cb2a Revert "wip"
alcoheca authored
855 case ADDON_SCRAPER_LIBRARY:
856 case ADDON_VIZ_LIBRARY:
6433385 added: script-library addon-type
spiff_ authored
857 case ADDON_SCRIPT_LIBRARY:
eca3c5b changed: refactor
spiff_ authored
858 return AddonPtr(new CAddonLibrary(addonProps));
606248f added: addon repository class
spiff_ authored
859 case ADDON_REPOSITORY:
860 return AddonPtr(new CRepository(addonProps));
af8cb2a Revert "wip"
alcoheca authored
861 default:
eca3c5b changed: refactor
spiff_ authored
862 break;
af8cb2a Revert "wip"
alcoheca authored
863 }
eca3c5b changed: refactor
spiff_ authored
864 return AddonPtr();
af8cb2a Revert "wip"
alcoheca authored
865 }
866
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored
867 void CAddonMgr::UpdateRepos()
868 {
869 CSingleLock lock(m_critSection);
870 if (m_watch.GetElapsedSeconds() < 600)
871 return;
872 m_watch.StartZero();
873 VECADDONS addons;
874 GetAddons(ADDON_REPOSITORY,addons);
875 for (unsigned int i=0;i<addons.size();++i)
876 {
877 RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(addons[i]);
878 if (repo->LastUpdate()+CDateTimeSpan(0,6,0,0) < CDateTime::GetCurrentDateTime())
879 {
880 CLog::Log(LOGDEBUG,"Checking repository %s for updates",repo->Name().c_str());
9617e5e cosmetics
spiff_ authored
881 CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(repo),this);
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored
882 }
883 }
884 }
885
886 void CAddonMgr::OnJobComplete(unsigned int jobID, bool success, CJob* job)
887 {
888 if (!success)
889 return;
890
891 ((CRepositoryUpdateJob*)job)->m_repo->SetUpdated(CDateTime::GetCurrentDateTime());
892 }
893
1b2781c added: basic cpluff support
alcoheca authored
894 /*
895 * libcpluff interaction
896 */
897
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored
898 CStdString CAddonMgr::GetExtValue(cp_cfg_element_t *base, const char *path)
899 {
900 const char *value = NULL;
901 if (base && (value = m_cpluff->lookup_cfg_value(base, path)))
902 return CStdString(value);
903 else return CStdString();
904 }
905
1b2781c added: basic cpluff support
alcoheca authored
906 void CAddonMgr::CPluffFatalError(const char *msg)
907 {
908 CLog::Log(LOGERROR, "ADDONS: CPluffFatalError(%s)", msg);
909 }
910
911 int cp_to_clog(cp_log_severity_t lvl)
912 {
913 if( lvl == CP_LOG_DEBUG )
914 return 0;
915 else if (lvl == CP_LOG_INFO)
916 return 1;
917 else if (lvl == CP_LOG_WARNING)
918 return 3;
919 else
920 return 4;
921 }
922
923 cp_log_severity_t clog_to_cp(int lvl)
924 {
925 if (lvl >= 4)
926 return CP_LOG_ERROR;
927 else if (lvl == 3)
928 return CP_LOG_WARNING;
929 else if (lvl >= 1)
930 return CP_LOG_INFO;
931 else
932 return CP_LOG_DEBUG;
933 }
934
935 void CAddonMgr::CPluffLog(cp_log_severity_t level, const char *msg, const char *apid, void *user_data)
936 {
937 if(!apid)
5b793b6 added: missing change from r29798
alcoheca authored
938 CLog::Log(cp_to_clog(level), "ADDON: cpluff: '%s'", msg);
1b2781c added: basic cpluff support
alcoheca authored
939 else
5b793b6 added: missing change from r29798
alcoheca authored
940 CLog::Log(cp_to_clog(level), "ADDON: cpluff: '%s' reports '%s'", apid, msg);
1b2781c added: basic cpluff support
alcoheca authored
941 }
942
074db86 merged: addons-fw branch
elupus authored
943 } /* namespace ADDON */
944
Something went wrong with that request. Please try again.