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