Skip to content
Newer
Older
100644 678 lines (602 sloc) 18.5 KB
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
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 Apr 13, 2010
23 #include "AddonDatabase.h"
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
24 #include "DllLibCPluff.h"
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
25 #include "StringUtils.h"
26 #include "RegExp.h"
27 #include "XMLUtils.h"
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored Apr 13, 2010
28 #include "utils/JobManager.h"
29 #include "utils/SingleLock.h"
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
30 #include "FileItem.h"
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer…
spiff_ authored Apr 26, 2010
31 #include "LangInfo.h"
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
32 #include "Settings.h"
33 #include "GUISettings.h"
34 #include "DownloadQueueManager.h"
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
35 #include "AdvancedSettings.h"
dacdca0 changed: moved CAddonStatusHandler to separate files
alcoheca authored Mar 25, 2010
36 #include "log.h"
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
37
38 #ifdef HAS_VISUALISATION
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored Mar 18, 2010
39 #include "DllVisualisation.h"
40 #include "Visualisation.h"
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
41 #endif
42 #ifdef HAS_SCREENSAVER
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored Mar 18, 2010
43 #include "DllScreenSaver.h"
44 #include "ScreenSaver.h"
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
45 #endif
46 //#ifdef HAS_SCRAPERS
055f806 cosmetic/tidyup move all addon classes to /xbmc/addons/
alcoheca authored Mar 18, 2010
47 #include "Scraper.h"
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
48 //#endif
606248f added: addon repository class
spiff_ authored Apr 13, 2010
49 #include "Repository.h"
553d213 changed: finished moving skins to addon framework
alcoheca authored Apr 27, 2010
50 #include "Skin.h"
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
51
88e9b6f changed: expand std namespace
spiff_ authored Apr 13, 2010
52 using namespace std;
53
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
54 namespace ADDON
55 {
56
b6f0f59 cleanup: Don't expose the AddonManager's privates when not required.
jmarshallnz authored May 19, 2010
57 cp_log_severity_t clog_to_cp(int lvl);
58 void cp_fatalErrorHandler(const char *msg);
59 void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data);
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
60
61 /**********************************************************
62 * CAddonMgr
63 *
64 */
65
88e9b6f changed: expand std namespace
spiff_ authored Apr 13, 2010
66 map<TYPE, IAddonMgrCallback*> CAddonMgr::m_managers;
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
67
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored May 7, 2010
68 AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
69 {
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored May 15, 2010
70 /* Check if user directories need to be created */
71 const cp_cfg_element_t *settings = GetExtElement(props->plugin->extensions->configuration, "settings");
72 if (settings)
73 CheckUserDirs(settings);
74
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
75 const TYPE type = TranslateType(props->ext_point_id);
76 switch (type)
77 {
78 case ADDON_PLUGIN:
79 case ADDON_SCRIPT:
80 return AddonPtr(new CAddon(props->plugin));
81 case ADDON_SCRAPER:
82 return AddonPtr(new CScraper(props->plugin));
83 case ADDON_VIZ:
84 case ADDON_SCREENSAVER:
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored May 7, 2010
85 { // begin temporary platform handling for Dlls
86 // ideally platforms issues will be handled by C-Pluff
87 // this is not an attempt at a solution
88 CStdString value;
89 #if defined(_LINUX) && !defined(__APPLE__)
90 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_linux")) && value.empty())
91 break;
92 #elif defined(_WIN32) && defined(HAS_SDL_OPENGL)
93 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_wingl")) && value.empty())
94 break;
95 #elif defined(_WIN32) && defined(HAS_DX)
96 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_windx")) && value.empty())
97 break;
98 #elif defined(__APPLE__)
99 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_osx")) && value.empty())
100 break;
101 #elif defined(_XBOX)
102 if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_xbox")) && value.empty())
103 break;
104 #endif
105 if (type == ADDON_VIZ)
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored May 18, 2010
106 {
107 #if defined(HAS_VISUALISATION)
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored May 7, 2010
108 return AddonPtr(new CVisualisation(props->plugin));
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored May 18, 2010
109 #endif
110 }
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored May 7, 2010
111 else
112 return AddonPtr(new CScreenSaver(props->plugin));
113 }
5ff028a added: skin support via cpluff
alcoheca authored May 5, 2010
114 case ADDON_SKIN:
115 return AddonPtr(new CSkinInfo(props->plugin));
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
116 case ADDON_SCRAPER_LIBRARY:
d289db4 fixed: script libraries weren't created in CAddonMgr::Factory
jmarshallnz authored May 22, 2010
117 case ADDON_SCRIPT_LIBRARY:
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
118 case ADDON_VIZ_LIBRARY:
119 return AddonPtr(new CAddonLibrary(props->plugin));
9ea9065 changed: Move repositories to cpluff
jmarshallnz authored May 20, 2010
120 case ADDON_REPOSITORY:
121 return AddonPtr(new CRepository(props->plugin));
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
122 default:
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored May 7, 2010
123 break;
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
124 }
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored May 7, 2010
125 return AddonPtr();
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
126 }
127
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored May 15, 2010
128 bool CAddonMgr::CheckUserDirs(const cp_cfg_element_t *settings)
129 {
130 if (!settings)
131 return false;
132
133 const cp_cfg_element_t *userdirs = GetExtElement((cp_cfg_element_t *)settings, "userdirs");
134 if (!userdirs)
135 return false;
136
137 DEQUEELEMENTS elements;
138 bool status = GetExtElementDeque(elements, (cp_cfg_element_t *)userdirs, "userdir");
139 if (!status)
140 return false;
141
142 IDEQUEELEMENTS itr = elements.begin();
143 while (itr != elements.end())
144 {
145 CStdString path = GetExtValue(*itr++, "@path");
146 if (!CFile::Exists(path))
147 {
148 if (!CUtil::CreateDirectoryEx(path))
149 {
150 CLog::Log(LOGERROR, "CAddonMgr::CheckUserDirs: Unable to create directory %s.", path.c_str());
151 return false;
152 }
153 }
154 }
155
156 return true;
157 }
158
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
159 CAddonMgr::CAddonMgr()
160 {
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored Apr 13, 2010
161 m_watch.StartZero();
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
162 }
163
164 CAddonMgr::~CAddonMgr()
165 {
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior …
jmarshallnz authored May 6, 2010
166 DeInit();
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
167 }
168
47a8196 changed: matched other singelton calls
alcoheca authored May 6, 2010
169 CAddonMgr &CAddonMgr::Get()
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
170 {
47a8196 changed: matched other singelton calls
alcoheca authored May 6, 2010
171 static CAddonMgr sAddonMgr;
172 return sAddonMgr;
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
173 }
174
175 IAddonMgrCallback* CAddonMgr::GetCallbackForType(TYPE type)
176 {
177 if (m_managers.find(type) == m_managers.end())
178 return NULL;
179 else
180 return m_managers[type];
181 }
182
183 bool CAddonMgr::RegisterAddonMgrCallback(const TYPE type, IAddonMgrCallback* cb)
184 {
185 if (cb == NULL)
186 return false;
187
188 m_managers.erase(type);
189 m_managers[type] = cb;
190
191 return true;
192 }
193
194 void CAddonMgr::UnregisterAddonMgrCallback(TYPE type)
195 {
196 m_managers.erase(type);
197 }
198
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
199 bool CAddonMgr::Init()
200 {
201 m_cpluff = new DllLibCPluff;
202 m_cpluff->Load();
203
204 if (!m_cpluff->IsLoaded())
205 {
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
206 CLog::Log(LOGERROR, "ADDONS: Fatal Error, could not load libcpluff");
207 return false;
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
208 }
209
210 m_cpluff->set_fatal_error_handler(cp_fatalErrorHandler);
211
212 cp_status_t status;
213 status = m_cpluff->init();
214 if (status != CP_OK)
215 {
216 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_init() returned status: %i", status);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
217 return false;
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
218 }
219
220 //TODO could separate addons into different contexts
221 // would allow partial unloading of addon framework
222 m_cp_context = m_cpluff->create_context(&status);
223 assert(m_cp_context);
7cef07e cleanup: remove unused XBMCIsHome function, now that they're no longe…
jmarshallnz authored May 22, 2010
224 status = m_cpluff->register_pcollection(m_cp_context, _P("special://home/addons"));
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
225 status = m_cpluff->register_pcollection(m_cp_context, _P("special://xbmc/addons"));
226 if (status != CP_OK)
227 {
228 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_pcollection() returned status: %i", status);
229 return false;
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
230 }
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
231
185686a added: even more missing from r29798
alcoheca authored May 6, 2010
232 status = m_cpluff->register_logger(m_cp_context, cp_logger,
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored May 6, 2010
233 &CAddonMgr::Get(), clog_to_cp(g_advancedSettings.m_logLevel));
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
234 if (status != CP_OK)
235 {
236 CLog::Log(LOGERROR, "ADDONS: Fatal Error, cp_register_logger() returned status: %i", status);
237 return false;
238 }
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
239
f0b69e1 changed: move the cpluff plugin scanner call to findaddons
spiff_ authored May 23, 2010
240 FindAddons();
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
241 return true;
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
242 }
243
37a994e added: Deinit to the addons manager to ensure we unload cpluff prior …
jmarshallnz authored May 6, 2010
244 void CAddonMgr::DeInit()
245 {
246 if (m_cpluff)
247 m_cpluff->destroy();
248 m_cpluff = NULL;
249 }
250
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored Mar 16, 2010
251 bool CAddonMgr::HasAddons(const TYPE &type, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
252 {
2c2e61e changed: initial move of scrapers to cpluff. since deps aren't handle…
spiff_ authored May 21, 2010
253 if (type == ADDON_SCREENSAVER || type == ADDON_SKIN || type == ADDON_VIZ || type == ADDON_SCRIPT || type == ADDON_REPOSITORY || type == ADDON_SCRAPER)
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
254 {
255 cp_status_t status;
256 int num;
257 CStdString ext_point(TranslateType(type));
2ff4a7d fixed: didn't release all ref counted objects returned from cpluff
alcoheca authored May 12, 2010
258 cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
259 m_cpluff->release_info(m_cp_context, exts);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
260 if (status == CP_OK)
261 return (num > 0);
262 }
263
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
264 if (m_addons.empty())
265 {
266 VECADDONS add;
267 GetAllAddons(add,false);
268 }
269
270 if (content == CONTENT_NONE)
271 return (m_addons.find(type) != m_addons.end());
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
272
273 VECADDONS addons;
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored Mar 16, 2010
274 return GetAddons(type, addons, content, enabledOnly);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
275
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
276 }
277
278 bool CAddonMgr::GetAllAddons(VECADDONS &addons, bool enabledOnly/*= true*/)
279 {
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
280 VECADDONS temp;
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored May 6, 2010
281 if (CAddonMgr::Get().GetAddons(ADDON_PLUGIN, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
282 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored May 6, 2010
283 if (CAddonMgr::Get().GetAddons(ADDON_SCRAPER, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
284 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored May 6, 2010
285 if (CAddonMgr::Get().GetAddons(ADDON_SCREENSAVER, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
286 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored May 6, 2010
287 if (CAddonMgr::Get().GetAddons(ADDON_SCRIPT, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
288 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored May 6, 2010
289 if (CAddonMgr::Get().GetAddons(ADDON_SKIN, temp, CONTENT_NONE, enabledOnly))
553d213 changed: finished moving skins to addon framework
alcoheca authored Apr 27, 2010
290 addons.insert(addons.end(), temp.begin(), temp.end());
7188808 changed: bail out immeditaly if CAddonMgr::Init returns false
alcoheca authored May 6, 2010
291 if (CAddonMgr::Get().GetAddons(ADDON_VIZ, temp, CONTENT_NONE, enabledOnly))
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
292 addons.insert(addons.end(), temp.begin(), temp.end());
293 return !addons.empty();
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
294 }
295
296 bool CAddonMgr::GetAddons(const TYPE &type, VECADDONS &addons, const CONTENT_TYPE &content/*= CONTENT_NONE*/, bool enabledOnly/*= true*/)
297 {
4e5b98a added: locks to addon manager
spiff_ authored Apr 13, 2010
298 CSingleLock lock(m_critSection);
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
299 addons.clear();
2c2e61e changed: initial move of scrapers to cpluff. since deps aren't handle…
spiff_ authored May 21, 2010
300 if (type == ADDON_SCREENSAVER || type == ADDON_SKIN || type == ADDON_VIZ || type == ADDON_REPOSITORY || type == ADDON_SCRIPT || type == ADDON_SCRAPER)
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
301 {
302 cp_status_t status;
303 int num;
304 CStdString ext_point(TranslateType(type));
305 cp_extension_t **exts = m_cpluff->get_extensions_info(m_cp_context, ext_point.c_str(), &status, &num);
306 for(int i=0; i <num; i++)
307 {
c14bf20 changed: moved addonptr factory to CAddonMgr.
alcoheca authored May 7, 2010
308 AddonPtr addon(Factory(exts[i]));
2c2e61e changed: initial move of scrapers to cpluff. since deps aren't handle…
spiff_ authored May 21, 2010
309 if (addon && (content == CONTENT_NONE || addon->Supports(content)))
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
310 addons.push_back(addon);
311 }
312 m_cpluff->release_info(m_cp_context, exts);
6933a8d fixed: compile warning
jmarshallnz authored May 6, 2010
313 return addons.size() > 0;
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
314 }
315
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
316 if (m_addons.find(type) != m_addons.end())
317 {
318 IVECADDONS itr = m_addons[type].begin();
319 while (itr != m_addons[type].end())
320 { // filter out what we're not looking for
dea84cb changed: Disabled() -> Enabled() - more intuitive
spiff_ authored Apr 13, 2010
321 if ((enabledOnly && !(*itr)->Enabled())
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
322 || (content != CONTENT_NONE && !(*itr)->Supports(content)))
323 {
324 ++itr;
325 continue;
326 }
327 addons.push_back(*itr);
328 ++itr;
329 }
330 }
331 return !addons.empty();
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
332 }
333
cc3b982 fixed: don't crash if an (visualization) addon is disabled
elupus authored Mar 16, 2010
334 bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &type/*=ADDON_UNKNOWN*/, bool enabledOnly/*= true*/)
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
335 {
4e5b98a added: locks to addon manager
spiff_ authored Apr 13, 2010
336 CSingleLock lock(m_critSection);
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
337
c22f535 cosmetics
alcoheca authored May 12, 2010
338 cp_status_t status;
84824e3 cosmetics
spiff_ authored May 23, 2010
339 cp_plugin_info_t *cpaddon = m_cpluff->get_plugin_info(m_cp_context, str.c_str(), &status);
c22f535 cosmetics
alcoheca authored May 12, 2010
340 if (status == CP_OK && cpaddon->extensions)
341 {
342 addon = Factory(cpaddon->extensions);
343 m_cpluff->release_info(m_cp_context, cpaddon);
344 return true;
345 }
346 if (cpaddon)
347 m_cpluff->release_info(m_cp_context, cpaddon);
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
348
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
349 return false;
350 }
351
352 //TODO handle all 'default' cases here, not just scrapers & vizs
353 bool CAddonMgr::GetDefault(const TYPE &type, AddonPtr &addon, const CONTENT_TYPE &content)
354 {
355 if (type != ADDON_SCRAPER && type != ADDON_VIZ)
356 return false;
357
358 CStdString setting;
359 if (type == ADDON_VIZ)
360 setting = g_guiSettings.GetString("musicplayer.visualisation");
361 else
362 {
363 switch (content)
364 {
365 case CONTENT_MOVIES:
366 {
367 setting = g_guiSettings.GetString("scrapers.moviedefault");
368 break;
369 }
370 case CONTENT_TVSHOWS:
371 {
372 setting = g_guiSettings.GetString("scrapers.tvshowdefault");
373 break;
374 }
375 case CONTENT_MUSICVIDEOS:
376 {
377 setting = g_guiSettings.GetString("scrapers.musicvideodefault");
378 break;
379 }
380 case CONTENT_ALBUMS:
381 case CONTENT_ARTISTS:
382 {
383 setting = g_guiSettings.GetString("musiclibrary.scraper");
384 break;
385 }
386 default:
387 return false;
388 }
389 }
2ca76f9 changed: all addons should be store below either special://home/addon…
alcoheca authored Mar 5, 2010
390 return GetAddon(setting, addon, type);
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
391 }
392
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored Mar 3, 2010
393 CStdString CAddonMgr::GetString(const CStdString &id, const int number)
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
394 {
7411555 changed: renamed UUID to ID. we now accept any string as an identifier,
alcoheca authored Mar 3, 2010
395 AddonPtr addon = m_idMap[id];
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
396 if (addon)
397 return addon->GetString(number);
398
399 return "";
400 }
401
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
402 void CAddonMgr::FindAddons()
403 {
4e5b98a added: locks to addon manager
spiff_ authored Apr 13, 2010
404 CSingleLock lock(m_critSection);
f0b69e1 changed: move the cpluff plugin scanner call to findaddons
spiff_ authored May 23, 2010
405 if (m_cpluff && m_cp_context)
406 m_cpluff->scan_plugins(m_cp_context, 0);
535b4e7 changed: load addons from user directory first, then load from system…
elupus authored Apr 22, 2010
407 }
408
f1031c4 fixed: disabling addons
spiff_ authored May 23, 2010
409 void CAddonMgr::RemoveAddon(const CStdString& ID)
410 {
411 if (m_cpluff && m_cp_context)
412 m_cpluff->uninstall_plugin(m_cp_context,ID.c_str());
413 }
414
822ca91 added: translatable <description>, <title>, <summary> and <disclaimer…
spiff_ authored Apr 26, 2010
415 bool CAddonMgr::GetTranslatedString(const TiXmlElement *xmldoc, const char *tag, CStdString& data)
416 {
417 const TiXmlElement *element = xmldoc->FirstChildElement(tag);
418 const TiXmlElement *enelement = NULL;
419 while (element)
420 {
421 const char* lang = element->Attribute("lang");
422 if (lang && strcmp(lang,g_langInfo.GetDVDAudioLanguage().c_str()) == 0)
423 break;
424 if (!lang || strcmp(lang,"en") == 0)
425 enelement = element;
426 element = element->NextSiblingElement(tag);
427 }
428 if (!element)
429 element = enelement;
430 if (element)
431 data = element->GetText();
432
433 return element != NULL;
434 }
435
096e8a3 changed: Move description information into addon.xml via the xbmc.add…
jmarshallnz authored May 20, 2010
436 const char *CAddonMgr::GetTranslatedString(const cp_cfg_element_t *root, const char *tag)
437 {
438 if (!root)
439 return NULL;
440
441 const cp_cfg_element_t *eng = NULL;
442 for (unsigned int i = 0; i < root->num_children; i++)
443 {
444 const cp_cfg_element_t &child = root->children[i];
445 if (strcmp(tag, child.name) == 0)
446 { // see if we have a "lang" attribute
447 const char *lang = m_cpluff->lookup_cfg_value((cp_cfg_element_t*)&child, "@lang");
448 if (lang && 0 == strcmp(lang,g_langInfo.GetDVDAudioLanguage().c_str()))
449 return child.value;
450 if (!lang || 0 == strcmp(lang, "en"))
451 eng = &child;
452 }
453 }
454 return (eng) ? eng->value : NULL;
455 }
456
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
457 AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
458 {
459 switch (addonProps.type)
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
460 {
461 case ADDON_PLUGIN:
462 case ADDON_SCRIPT:
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
463 return AddonPtr(new CAddon(addonProps));
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
464 case ADDON_SCRAPER:
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
465 return AddonPtr(new CScraper(addonProps));
553d213 changed: finished moving skins to addon framework
alcoheca authored Apr 27, 2010
466 case ADDON_SKIN:
467 return AddonPtr(new CSkinInfo(addonProps));
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored May 18, 2010
468 #if defined(HAS_VISUALISATION)
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
469 case ADDON_VIZ:
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
470 return AddonPtr(new CVisualisation(addonProps));
07e5742 [arm] merge arm-camelot into trunk, thanks to mcgeagh for all his har…
davilla authored May 18, 2010
471 #endif
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
472 case ADDON_SCREENSAVER:
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
473 return AddonPtr(new CScreenSaver(addonProps));
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
474 case ADDON_SCRAPER_LIBRARY:
475 case ADDON_VIZ_LIBRARY:
6433385 added: script-library addon-type
spiff_ authored Apr 26, 2010
476 case ADDON_SCRIPT_LIBRARY:
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
477 return AddonPtr(new CAddonLibrary(addonProps));
606248f added: addon repository class
spiff_ authored Apr 13, 2010
478 case ADDON_REPOSITORY:
479 return AddonPtr(new CRepository(addonProps));
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
480 default:
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
481 break;
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
482 }
eca3c5b changed: refactor
spiff_ authored Apr 13, 2010
483 return AddonPtr();
af8cb2a Revert "wip"
alcoheca authored Mar 26, 2010
484 }
485
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored Apr 13, 2010
486 void CAddonMgr::UpdateRepos()
487 {
488 CSingleLock lock(m_critSection);
489 if (m_watch.GetElapsedSeconds() < 600)
490 return;
491 m_watch.StartZero();
492 VECADDONS addons;
493 GetAddons(ADDON_REPOSITORY,addons);
494 for (unsigned int i=0;i<addons.size();++i)
495 {
496 RepositoryPtr repo = boost::dynamic_pointer_cast<CRepository>(addons[i]);
497 if (repo->LastUpdate()+CDateTimeSpan(0,6,0,0) < CDateTime::GetCurrentDateTime())
498 {
499 CLog::Log(LOGDEBUG,"Checking repository %s for updates",repo->Name().c_str());
9617e5e cosmetics
spiff_ authored Apr 24, 2010
500 CJobManager::GetInstance().AddJob(new CRepositoryUpdateJob(repo),this);
639b314 changed: move addonbrowser to a mediawindow derivate
spiff_ authored Apr 13, 2010
501 }
502 }
503 }
504
505 void CAddonMgr::OnJobComplete(unsigned int jobID, bool success, CJob* job)
506 {
507 if (!success)
508 return;
509
510 ((CRepositoryUpdateJob*)job)->m_repo->SetUpdated(CDateTime::GetCurrentDateTime());
511 }
512
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
513 /*
514 * libcpluff interaction
515 */
516
bb4e01c Support creating userdirs in addons. This also has the benefit of bei…
ceros7 authored May 15, 2010
517 const cp_cfg_element_t *CAddonMgr::GetExtElement(cp_cfg_element_t *base, const char *path)
518 {
519 const cp_cfg_element_t *element = NULL;
520 if (base)
521 element = m_cpluff->lookup_cfg_element(base, path);
522 return element;
523 }
524
525 /* Returns all duplicate elements from a base element */
526 bool CAddonMgr::GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path)
527 {
528 if (!base)
529 return false;
530
531 unsigned int i = 0;
532 while (true)
533 {
534 if (i >= base->num_children)
535 break;
536 CStdString temp = (base->children+i)->name;
537 if (!temp.compare(path))
538 elements.push_back(base->children+i);
539 i++;
540 }
541
542 if (elements.empty()) return false;
543 return true;
544 }
545
096e8a3 changed: Move description information into addon.xml via the xbmc.add…
jmarshallnz authored May 20, 2010
546 const cp_extension_t *CAddonMgr::GetExtension(const cp_plugin_info_t *props, const char *extension)
547 {
548 if (!props)
549 return NULL;
550 for (unsigned int i = 0; i < props->num_extensions; ++i)
551 {
552 if (0 == strcmp(props->extensions[i].ext_point_id, extension))
553 return &props->extensions[i];
554 }
555 return NULL;
556 }
557
a16721e changed: move scraper libraries to cpluff
spiff_ authored May 23, 2010
558 ADDONDEPS CAddonMgr::GetDeps(const CStdString &id)
559 {
560 ADDONDEPS result;
561 cp_status_t status;
562
563 cp_plugin_info_t *info = m_cpluff->get_plugin_info(m_cp_context,id.c_str(),&status);
564 if (info)
565 {
566 for (unsigned int i=0;i<info->num_imports;++i)
567 result.insert(make_pair(CStdString(info->imports[i].plugin_id),
568 make_pair(AddonVersion(info->version),
569 AddonVersion(info->version))));
570 }
571
572 return result;
573 }
574
b6076e5 changed: screensavers are now supported via cpluff schema
alcoheca authored May 5, 2010
575 CStdString CAddonMgr::GetExtValue(cp_cfg_element_t *base, const char *path)
576 {
577 const char *value = NULL;
578 if (base && (value = m_cpluff->lookup_cfg_value(base, path)))
579 return CStdString(value);
580 else return CStdString();
581 }
582
a16721e changed: move scraper libraries to cpluff
spiff_ authored May 23, 2010
583 vector<CStdString> CAddonMgr::GetExtValues(cp_cfg_element_t *base, const char *path)
584 {
585 vector<CStdString> result;
586 cp_cfg_element_t *parent = m_cpluff->lookup_cfg_element(base,path);
587 for (unsigned int i=0;parent && i<parent->num_children;++i)
588 result.push_back(parent->children[i].value);
589
590 return result;
591 }
592
5bca9c0 cleanup: Rename and document the cpluff versions of loading addon des…
jmarshallnz authored May 22, 2010
593 bool CAddonMgr::LoadAddonDescription(const CStdString &path, AddonPtr &addon)
92afa2e fixed: Addons weren't installed correctly
jmarshallnz authored May 22, 2010
594 {
595 cp_status_t status;
596 cp_plugin_info_t *info = m_cpluff->load_plugin_descriptor(m_cp_context, _P(path).c_str(), &status);
597 if (info)
598 {
599 addon = Factory(info->extensions);
600 m_cpluff->release_info(m_cp_context, info);
601 return addon.get();
602 }
603 return false;
604 }
605
5bca9c0 cleanup: Rename and document the cpluff versions of loading addon des…
jmarshallnz authored May 22, 2010
606 bool CAddonMgr::AddonsFromRepoXML(const TiXmlElement *root, VECADDONS &addons)
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored May 20, 2010
607 {
608 // create a context for these addons
609 cp_status_t status;
610 cp_context_t *context = m_cpluff->create_context(&status);
611 if (!root || !context)
612 return false;
613
cfe53d3 fixed: Put the UTF-8 descriptor on the XML before feeding it to c-pluff
jmarshallnz authored May 20, 2010
614 // each addon XML should have a UTF-8 declaration
615 TiXmlDeclaration decl("1.0", "UTF-8", "");
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored May 20, 2010
616 const TiXmlElement *element = root->FirstChildElement("addon");
617 while (element)
618 {
cfe53d3 fixed: Put the UTF-8 descriptor on the XML before feeding it to c-pluff
jmarshallnz authored May 20, 2010
619 // dump the XML back to text
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored May 20, 2010
620 std::string xml;
cfe53d3 fixed: Put the UTF-8 descriptor on the XML before feeding it to c-pluff
jmarshallnz authored May 20, 2010
621 xml << decl;
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored May 20, 2010
622 xml << *element;
623 cp_status_t status;
cd2be2f added: Expose cp_load_plugin_descriptor and separate out the from_mem…
jmarshallnz authored May 22, 2010
624 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 May 20, 2010
625 if (info)
626 {
627 AddonPtr addon = Factory(info->extensions);
628 m_cpluff->release_info(context, info);
629 // FIXME: sanity check here that the addon satisfies our requirements?
ed51e37 fixed: check for NULL before adding the addon in AddonsFromInfoXML
jmarshallnz authored May 22, 2010
630 if (addon.get())
631 addons.push_back(addon);
4488d3a changed: Allow repository to have c-pluff XML files
jmarshallnz authored May 20, 2010
632 }
633 element = element->NextSiblingElement("addon");
634 }
635 m_cpluff->destroy_context(context);
636 return true;
637 }
638
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
639 int cp_to_clog(cp_log_severity_t lvl)
640 {
641 if( lvl == CP_LOG_DEBUG )
642 return 0;
643 else if (lvl == CP_LOG_INFO)
644 return 1;
645 else if (lvl == CP_LOG_WARNING)
646 return 3;
647 else
648 return 4;
649 }
650
651 cp_log_severity_t clog_to_cp(int lvl)
652 {
653 if (lvl >= 4)
654 return CP_LOG_ERROR;
655 else if (lvl == 3)
656 return CP_LOG_WARNING;
657 else if (lvl >= 1)
658 return CP_LOG_INFO;
659 else
660 return CP_LOG_DEBUG;
661 }
662
b6f0f59 cleanup: Don't expose the AddonManager's privates when not required.
jmarshallnz authored May 19, 2010
663 void cp_fatalErrorHandler(const char *msg)
664 {
665 CLog::Log(LOGERROR, "ADDONS: CPluffFatalError(%s)", msg);
666 }
667
668 void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data)
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
669 {
670 if(!apid)
5b793b6 added: missing change from r29798
alcoheca authored May 6, 2010
671 CLog::Log(cp_to_clog(level), "ADDON: cpluff: '%s'", msg);
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
672 else
5b793b6 added: missing change from r29798
alcoheca authored May 6, 2010
673 CLog::Log(cp_to_clog(level), "ADDON: cpluff: '%s' reports '%s'", apid, msg);
1b2781c added: basic cpluff support
alcoheca authored May 5, 2010
674 }
675
074db86 merged: addons-fw branch
elupus authored Mar 2, 2010
676 } /* namespace ADDON */
677
Something went wrong with that request. Please try again.