1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "ModuleXbmcplugin.h"
#include "FileItem.h"
#include "filesystem/PluginDirectory.h"
namespace XBMCAddon
{
namespace xbmcplugin
{
bool addDirectoryItem(int handle, const String& url, const xbmcgui::ListItem* listItem,
bool isFolder, int totalItems)
{
if (listItem == nullptr)
throw new XBMCAddon::WrongTypeException("None not allowed as argument for listitem");
AddonClass::Ref<xbmcgui::ListItem> pListItem(listItem);
pListItem->item->SetPath(url);
pListItem->item->m_bIsFolder = isFolder;
// call the directory class to add our item
return XFILE::CPluginDirectory::AddItem(handle, pListItem->item.get(), totalItems);
}
bool addDirectoryItems(int handle,
const std::vector<Tuple<String,const XBMCAddon::xbmcgui::ListItem*,bool> >& items,
int totalItems)
{
CFileItemList fitems;
for (const auto& item : items)
{
const String& url = item.first();
const XBMCAddon::xbmcgui::ListItem* pListItem = item.second();
bool bIsFolder = item.GetNumValuesSet() > 2 ? item.third() : false;
pListItem->item->SetPath(url);
pListItem->item->m_bIsFolder = bIsFolder;
fitems.Add(pListItem->item);
}
// call the directory class to add our items
return XFILE::CPluginDirectory::AddItems(handle, &fitems, totalItems);
}
void endOfDirectory(int handle, bool succeeded, bool updateListing,
bool cacheToDisc)
{
// tell the directory class that we're done
XFILE::CPluginDirectory::EndOfDirectory(handle, succeeded, updateListing, cacheToDisc);
}
void setResolvedUrl(int handle, bool succeeded, const xbmcgui::ListItem* listItem)
{
if (listItem == nullptr)
throw new XBMCAddon::WrongTypeException("None not allowed as argument for listitem");
AddonClass::Ref<xbmcgui::ListItem> pListItem(listItem);
XFILE::CPluginDirectory::SetResolvedUrl(handle, succeeded, pListItem->item.get());
}
void addSortMethod(int handle, int sortMethod, const String& clabelMask, const String& clabel2Mask)
{
String labelMask;
if (sortMethod == SORT_METHOD_TRACKNUM)
labelMask = (clabelMask.empty() ? "[%N. ]%T" : clabelMask.c_str());
else if (sortMethod == SORT_METHOD_EPISODE || sortMethod == SORT_METHOD_PRODUCTIONCODE)
labelMask = (clabelMask.empty() ? "%H. %T" : clabelMask.c_str());
else
labelMask = (clabelMask.empty() ? "%T" : clabelMask.c_str());
String label2Mask;
label2Mask = (clabel2Mask.empty() ? "%D" : clabel2Mask.c_str());
// call the directory class to add the sort method.
if (sortMethod >= SORT_METHOD_NONE && sortMethod < SORT_METHOD_MAX)
XFILE::CPluginDirectory::AddSortMethod(handle, (SORT_METHOD)sortMethod, labelMask, label2Mask);
}
String getSetting(int handle, const char* id)
{
return XFILE::CPluginDirectory::GetSetting(handle, id);
}
void setSetting(int handle, const String& id, const String& value)
{
XFILE::CPluginDirectory::SetSetting(handle, id, value);
}
void setContent(int handle, const char* content)
{
XFILE::CPluginDirectory::SetContent(handle, content);
}
void setPluginCategory(int handle, const String& category)
{
XFILE::CPluginDirectory::SetProperty(handle, "plugincategory", category);
}
void setPluginFanart(int handle, const char* image,
const char* color1,
const char* color2,
const char* color3)
{
if (image)
XFILE::CPluginDirectory::SetProperty(handle, "fanart_image", image);
if (color1)
XFILE::CPluginDirectory::SetProperty(handle, "fanart_color1", color1);
if (color2)
XFILE::CPluginDirectory::SetProperty(handle, "fanart_color2", color2);
if (color3)
XFILE::CPluginDirectory::SetProperty(handle, "fanart_color3", color3);
}
void setProperty(int handle, const char* key, const String& value)
{
XFILE::CPluginDirectory::SetProperty(handle, key, value);
}
}
}
|