2 * Copyright (C) 2005-2013 Team XBMC
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)
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.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
20 #include "PluginSource.h"
21 #include "AddonManager.h"
22 #include "utils/StringUtils.h"
29 CPluginSource::CPluginSource(const AddonProps &props)
33 InfoMap::const_iterator i = Props().extrainfo.find("provides");
34 if (i != Props().extrainfo.end())
36 SetProvides(provides);
39 CPluginSource::CPluginSource(const cp_extension_t *ext)
45 provides = CAddonMgr::Get().GetExtValue(ext->configuration, "provides");
46 if (!provides.empty())
47 Props().extrainfo.insert(make_pair("provides", provides));
49 SetProvides(provides);
52 AddonPtr CPluginSource::Clone() const
54 return AddonPtr(new CPluginSource(*this));
57 void CPluginSource::SetProvides(const CStdString &content)
59 vector<CStdString> provides;
62 StringUtils::SplitString(content, " ", provides);
63 for (unsigned int i = 0; i < provides.size(); ++i)
65 Content content = Translate(provides[i]);
66 if (content != UNKNOWN)
67 m_providedContent.insert(content);
70 if (Type() == ADDON_SCRIPT && m_providedContent.empty())
71 m_providedContent.insert(EXECUTABLE);
74 CPluginSource::Content CPluginSource::Translate(const CStdString &content)
76 if (content.Equals("audio"))
77 return CPluginSource::AUDIO;
78 else if (content.Equals("image"))
79 return CPluginSource::IMAGE;
80 else if (content.Equals("executable"))
81 return CPluginSource::EXECUTABLE;
82 else if (content.Equals("video"))
83 return CPluginSource::VIDEO;
85 return CPluginSource::UNKNOWN;
88 bool CPluginSource::IsType(TYPE type) const
90 return ((type == ADDON_VIDEO && Provides(VIDEO))
91 || (type == ADDON_AUDIO && Provides(AUDIO))
92 || (type == ADDON_IMAGE && Provides(IMAGE))
93 || (type == ADDON_EXECUTABLE && Provides(EXECUTABLE)));