[PVR][Estuary] Timer settings dialog: Show client name in timer type selection dialog...
[xbmc.git] / xbmc / interfaces / legacy / ModuleXbmcplugin.cpp
blob0af97b71ac854949585204abea66ecb2a0fa025f
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "ModuleXbmcplugin.h"
11 #include "FileItem.h"
12 #include "filesystem/PluginDirectory.h"
14 namespace XBMCAddon
17 namespace xbmcplugin
19 bool addDirectoryItem(int handle, const String& url, const xbmcgui::ListItem* listItem,
20 bool isFolder, int totalItems)
22 if (listItem == nullptr)
23 throw new XBMCAddon::WrongTypeException("None not allowed as argument for listitem");
24 AddonClass::Ref<xbmcgui::ListItem> pListItem(listItem);
25 pListItem->item->SetPath(url);
26 pListItem->item->m_bIsFolder = isFolder;
28 // call the directory class to add our item
29 return XFILE::CPluginDirectory::AddItem(handle, pListItem->item.get(), totalItems);
32 bool addDirectoryItems(int handle,
33 const std::vector<Tuple<String,const XBMCAddon::xbmcgui::ListItem*,bool> >& items,
34 int totalItems)
36 CFileItemList fitems;
37 for (const auto& item : items)
39 const String& url = item.first();
40 const XBMCAddon::xbmcgui::ListItem* pListItem = item.second();
41 bool bIsFolder = item.GetNumValuesSet() > 2 ? item.third() : false;
42 pListItem->item->SetPath(url);
43 pListItem->item->m_bIsFolder = bIsFolder;
44 fitems.Add(pListItem->item);
47 // call the directory class to add our items
48 return XFILE::CPluginDirectory::AddItems(handle, &fitems, totalItems);
51 void endOfDirectory(int handle, bool succeeded, bool updateListing,
52 bool cacheToDisc)
54 // tell the directory class that we're done
55 XFILE::CPluginDirectory::EndOfDirectory(handle, succeeded, updateListing, cacheToDisc);
58 void setResolvedUrl(int handle, bool succeeded, const xbmcgui::ListItem* listItem)
60 if (listItem == nullptr)
61 throw new XBMCAddon::WrongTypeException("None not allowed as argument for listitem");
62 AddonClass::Ref<xbmcgui::ListItem> pListItem(listItem);
63 XFILE::CPluginDirectory::SetResolvedUrl(handle, succeeded, pListItem->item.get());
66 void addSortMethod(int handle, int sortMethod, const String& clabelMask, const String& clabel2Mask)
68 String labelMask;
69 if (sortMethod == SORT_METHOD_TRACKNUM)
70 labelMask = (clabelMask.empty() ? "[%N. ]%T" : clabelMask.c_str());
71 else if (sortMethod == SORT_METHOD_EPISODE || sortMethod == SORT_METHOD_PRODUCTIONCODE)
72 labelMask = (clabelMask.empty() ? "%H. %T" : clabelMask.c_str());
73 else
74 labelMask = (clabelMask.empty() ? "%T" : clabelMask.c_str());
76 String label2Mask;
77 label2Mask = (clabel2Mask.empty() ? "%D" : clabel2Mask.c_str());
79 // call the directory class to add the sort method.
80 if (sortMethod >= SORT_METHOD_NONE && sortMethod < SORT_METHOD_MAX)
81 XFILE::CPluginDirectory::AddSortMethod(handle, (SORT_METHOD)sortMethod, labelMask, label2Mask);
84 String getSetting(int handle, const char* id)
86 return XFILE::CPluginDirectory::GetSetting(handle, id);
89 void setSetting(int handle, const String& id, const String& value)
91 XFILE::CPluginDirectory::SetSetting(handle, id, value);
94 void setContent(int handle, const char* content)
96 XFILE::CPluginDirectory::SetContent(handle, content);
99 void setPluginCategory(int handle, const String& category)
101 XFILE::CPluginDirectory::SetProperty(handle, "plugincategory", category);
104 void setPluginFanart(int handle, const char* image,
105 const char* color1,
106 const char* color2,
107 const char* color3)
109 if (image)
110 XFILE::CPluginDirectory::SetProperty(handle, "fanart_image", image);
111 if (color1)
112 XFILE::CPluginDirectory::SetProperty(handle, "fanart_color1", color1);
113 if (color2)
114 XFILE::CPluginDirectory::SetProperty(handle, "fanart_color2", color2);
115 if (color3)
116 XFILE::CPluginDirectory::SetProperty(handle, "fanart_color3", color3);
119 void setProperty(int handle, const char* key, const String& value)
121 XFILE::CPluginDirectory::SetProperty(handle, key, value);