本文整理汇总了C++中CFileItemList::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemList::Add方法的具体用法?C++ CFileItemList::Add怎么用?C++ CFileItemList::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemList
的用法示例。
在下文中一共展示了CFileItemList::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDirectory
bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
// We accept smb://[[[domain;]user[:[email protected]]]server[/share[/path[/file]]]]
/* samba isn't thread safe with old interface, always lock */
CSingleLock lock(smb);
smb.Init();
//Separate roots for the authentication and the containing items to allow browsing to work correctly
std::string strRoot = url.Get();
std::string strAuth;
lock.Leave(); // OpenDir is locked
int fd = OpenDir(url, strAuth);
if (fd < 0)
return false;
URIUtils::AddSlashAtEnd(strRoot);
URIUtils::AddSlashAtEnd(strAuth);
std::string strFile;
// need to keep the samba lock for as short as possible.
// so we first cache all directory entries and then go over them again asking for stat
// "stat" is locked each time. that way the lock is freed between stat requests
vector<CachedDirEntry> vecEntries;
struct smbc_dirent* dirEnt;
lock.Enter();
while ((dirEnt = smbc_readdir(fd)))
{
CachedDirEntry aDir;
aDir.type = dirEnt->smbc_type;
aDir.name = dirEnt->name;
vecEntries.push_back(aDir);
}
smbc_closedir(fd);
lock.Leave();
for (size_t i=0; i<vecEntries.size(); i++)
{
CachedDirEntry aDir = vecEntries[i];
// We use UTF-8 internally, as does SMB
strFile = aDir.name;
if (!strFile.empty() && strFile != "." && strFile != ".."
&& strFile != "lost+found"
&& aDir.type != SMBC_PRINTER_SHARE && aDir.type != SMBC_IPC_SHARE)
{
int64_t iSize = 0;
bool bIsDir = true;
int64_t lTimeDate = 0;
bool hidden = false;
if(StringUtils::EndsWith(strFile, "$") && aDir.type == SMBC_FILE_SHARE )
continue;
// only stat files that can give proper responses
if ( aDir.type == SMBC_FILE ||
aDir.type == SMBC_DIR )
{
// set this here to if the stat should fail
bIsDir = (aDir.type == SMBC_DIR);
struct stat info = {0};
if ((m_flags & DIR_FLAG_NO_FILE_INFO)==0 && g_advancedSettings.m_sambastatfiles)
{
// make sure we use the authenticated path wich contains any default username
const std::string strFullName = strAuth + smb.URLEncode(strFile);
lock.Enter();
if( smbc_stat(strFullName.c_str(), &info) == 0 )
{
char value[20];
// We poll for extended attributes which symbolizes bits but split up into a string. Where 0x02 is hidden and 0x12 is hidden directory.
// According to the libsmbclient.h it's supposed to return 0 if ok, or the length of the string. It seems always to return the length wich is 4
if (smbc_getxattr(strFullName.c_str(), "system.dos_attr.mode", value, sizeof(value)) > 0)
{
long longvalue = strtol(value, NULL, 16);
if (longvalue & SMBC_DOS_MODE_HIDDEN)
hidden = true;
}
else
CLog::Log(LOGERROR, "Getting extended attributes for the share: '%s'\nunix_err:'%x' error: '%s'", CURL::GetRedacted(strFullName).c_str(), errno, strerror(errno));
bIsDir = S_ISDIR(info.st_mode);
lTimeDate = info.st_mtime;
if(lTimeDate == 0) // if modification date is missing, use create date
lTimeDate = info.st_ctime;
iSize = info.st_size;
}
else
CLog::Log(LOGERROR, "%s - Failed to stat file %s", __FUNCTION__, CURL::GetRedacted(strFullName).c_str());
lock.Leave();
}
//.........这里部分代码省略.........
示例2: if
void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg)
{
switch (pMsg->dwMessage)
{
case TMSG_PLAYLISTPLAYER_PLAY:
if (pMsg->param1 != -1)
Play(pMsg->param1, "");
else
Play();
break;
case TMSG_PLAYLISTPLAYER_PLAY_SONG_ID:
if (pMsg->param1 != -1)
{
bool *result = (bool*)pMsg->lpVoid;
*result = PlaySongId(pMsg->param1);
}
else
Play();
break;
case TMSG_PLAYLISTPLAYER_NEXT:
PlayNext();
break;
case TMSG_PLAYLISTPLAYER_PREV:
PlayPrevious();
break;
case TMSG_PLAYLISTPLAYER_ADD:
if (pMsg->lpVoid)
{
CFileItemList *list = (CFileItemList *)pMsg->lpVoid;
Add(pMsg->param1, (*list));
delete list;
}
break;
case TMSG_PLAYLISTPLAYER_INSERT:
if (pMsg->lpVoid)
{
CFileItemList *list = (CFileItemList *)pMsg->lpVoid;
Insert(pMsg->param1, (*list), pMsg->param2);
delete list;
}
break;
case TMSG_PLAYLISTPLAYER_REMOVE:
if (pMsg->param1 != -1)
Remove(pMsg->param1, pMsg->param2);
break;
case TMSG_PLAYLISTPLAYER_CLEAR:
ClearPlaylist(pMsg->param1);
break;
case TMSG_PLAYLISTPLAYER_SHUFFLE:
SetShuffle(pMsg->param1, pMsg->param2 > 0);
break;
case TMSG_PLAYLISTPLAYER_REPEAT:
SetRepeat(pMsg->param1, (PLAYLIST::REPEAT_STATE)pMsg->param2);
break;
case TMSG_PLAYLISTPLAYER_GET_ITEMS:
if (pMsg->lpVoid)
{
PLAYLIST::CPlayList playlist = GetPlaylist(pMsg->param1);
CFileItemList *list = static_cast<CFileItemList*>(pMsg->lpVoid);
for (int i = 0; i < playlist.size(); i++)
list->Add(std::make_shared<CFileItem>(*playlist[i]));
}
break;
case TMSG_PLAYLISTPLAYER_SWAP:
if (pMsg->lpVoid)
{
auto indexes = static_cast<std::vector<int>*>(pMsg->lpVoid);
if (indexes->size() == 2)
Swap(pMsg->param1, indexes->at(0), indexes->at(1));
delete indexes;
}
break;
case TMSG_MEDIA_PLAY:
{
// first check if we were called from the PlayFile() function
if (pMsg->lpVoid && pMsg->param2 == 0)
{
CFileItem *item = (CFileItem *)pMsg->lpVoid;
g_application.PlayFile(*item, "", pMsg->param1 != 0);
delete item;
return;
}
// restore to previous window if needed
if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW ||
g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO ||
g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)
//.........这里部分代码省略.........
示例3: AddQueuingFolder
// Add an "* All ..." folder to the CFileItemList
// depending on the child node
void CDirectoryNode::AddQueuingFolder(CFileItemList& items) const
{
CFileItemPtr pItem;
// always hide "all" items
if (g_advancedSettings.m_bVideoLibraryHideAllItems)
return;
// no need for "all" item when only one item
if (items.GetObjectCount() <= 1)
return;
// hack - as the season node might return episodes
auto_ptr<CDirectoryNode> pNode(ParseURL(items.GetPath()));
switch (pNode->GetChildType())
{
case NODE_TYPE_SEASONS:
{
CStdString strLabel = g_localizeStrings.Get(20366);
pItem.reset(new CFileItem(strLabel)); // "All Seasons"
pItem->SetPath(BuildPath() + "-1/");
// set the number of watched and unwatched items accordingly
int watched = 0;
int unwatched = 0;
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
watched += (int)item->GetProperty("watchedepisodes").asInteger();
unwatched += (int)item->GetProperty("unwatchedepisodes").asInteger();
}
pItem->SetProperty("totalepisodes", watched + unwatched);
pItem->SetProperty("numepisodes", watched + unwatched); // will be changed later to reflect watchmode setting
pItem->SetProperty("watchedepisodes", watched);
pItem->SetProperty("unwatchedepisodes", unwatched);
if (items.Size() && items[0]->GetVideoInfoTag())
{
*pItem->GetVideoInfoTag() = *items[0]->GetVideoInfoTag();
pItem->GetVideoInfoTag()->m_iSeason = -1;
}
pItem->GetVideoInfoTag()->m_strTitle = strLabel;
pItem->GetVideoInfoTag()->m_iEpisode = watched + unwatched;
pItem->GetVideoInfoTag()->m_playCount = (unwatched == 0) ? 1 : 0;
CVideoDatabase db;
if (db.Open())
{
pItem->GetVideoInfoTag()->m_iDbId = db.GetSeasonId(pItem->GetVideoInfoTag()->m_iIdShow, -1);
db.Close();
}
pItem->GetVideoInfoTag()->m_type = "season";
}
break;
default:
break;
}
if (pItem)
{
pItem->m_bIsFolder = true;
pItem->SetSpecialSort(g_advancedSettings.m_bVideoLibraryAllItemsOnBottom ? SortSpecialOnBottom : SortSpecialOnTop);
pItem->SetCanQueue(false);
items.Add(pItem);
}
}
示例4: GetDirectory
//.........这里部分代码省略.........
CVideoInfoTag details;
m_database.GetTvShowInfo("", details, params.GetTvShowId());
map<string, string> art;
if (m_database.GetArtForItem(details.m_iDbId, details.m_type, art))
{
items.AppendArt(art, "tvshow");
items.SetArtFallback("fanart", "tvshow.fanart");
if (node == NODE_TYPE_SEASONS)
{ // set an art fallback for "thumb"
if (items.HasArt("tvshow.poster"))
items.SetArtFallback("thumb", "tvshow.poster");
else if (items.HasArt("tvshow.banner"))
items.SetArtFallback("thumb", "tvshow.banner");
}
}
// Grab fanart data
items.SetProperty("fanart_color1", details.m_fanart.GetColor(0));
items.SetProperty("fanart_color2", details.m_fanart.GetColor(1));
items.SetProperty("fanart_color3", details.m_fanart.GetColor(2));
// save the show description (showplot)
items.SetProperty("showplot", details.m_strPlot);
// the container folder thumb is the parent (i.e. season or show)
if (node == NODE_TYPE_EPISODES || node == NODE_TYPE_RECENTLY_ADDED_EPISODES)
{
items.SetContent("episodes");
// grab the season thumb as the folder thumb
int seasonID = m_database.GetSeasonId(details.m_iDbId, params.GetSeason());
CGUIListItem::ArtMap seasonArt;
if (m_database.GetArtForItem(seasonID, "season", seasonArt))
{
items.AppendArt(art, "season");
// set an art fallback for "thumb"
if (items.HasArt("season.poster"))
items.SetArtFallback("thumb", "season.poster");
else if (items.HasArt("season.banner"))
items.SetArtFallback("thumb", "season.banner");
}
}
else
items.SetContent("seasons");
}
else if (node == NODE_TYPE_TITLE_MOVIES ||
node == NODE_TYPE_RECENTLY_ADDED_MOVIES)
items.SetContent("movies");
else if (node == NODE_TYPE_TITLE_TVSHOWS)
items.SetContent("tvshows");
else if (node == NODE_TYPE_TITLE_MUSICVIDEOS ||
node == NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS)
items.SetContent("musicvideos");
else if (node == NODE_TYPE_GENRE)
items.SetContent("genres");
else if (node == NODE_TYPE_COUNTRY)
items.SetContent("countries");
else if (node == NODE_TYPE_ACTOR)
{
if (params.GetContentType() == VIDEODB_CONTENT_MUSICVIDEOS)
items.SetContent("artists");
else
items.SetContent("actors");
}
else if (node == NODE_TYPE_DIRECTOR)
items.SetContent("directors");
else if (node == NODE_TYPE_STUDIO)
items.SetContent("studios");
else if (node == NODE_TYPE_YEAR)
items.SetContent("years");
else if (node == NODE_TYPE_MUSICVIDEOS_ALBUM)
items.SetContent("albums");
else if (node == NODE_TYPE_SETS)
items.SetContent("sets");
else if (node == NODE_TYPE_TAGS)
items.SetContent("tags");
else
items.SetContent("");
}
else if (!items.IsVirtualDirectoryRoot())
{ // load info from the database
CStdString label;
if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::Get().GetSources("video"), &label))
items.SetLabel(label);
if (!items.IsSourcesPath())
LoadVideoInfo(items);
}
CVideoDbUrl videoUrl;
if (videoUrl.FromString(items.GetPath()) && items.GetContent() == "tags" &&
!items.Contains("newtag://" + videoUrl.GetType()))
{
CFileItemPtr newTag(new CFileItem("newtag://" + videoUrl.GetType(), false));
newTag->SetLabel(g_localizeStrings.Get(20462));
newTag->SetLabelPreformated(true);
newTag->SetSpecialSort(SortSpecialOnTop);
items.Add(newTag);
}
}
return bResult;
}
示例5: AddItemToPlayList
/// \brief Add unique file and folders and its subfolders to playlist
/// \param pItem The file item to add
void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItemList &queuedItems)
{
if (!pItem->CanQueue() || pItem->IsRAR() || pItem->IsZIP() || pItem->IsParentFolder()) // no zip/rar enques thank you!
return;
// fast lookup is needed here
queuedItems.SetFastLookup(true);
if (pItem->IsMusicDb() && pItem->m_bIsFolder && !pItem->IsParentFolder())
{ // we have a music database folder, just grab the "all" item underneath it
CMusicDatabaseDirectory dir;
if (!dir.ContainsSongs(pItem->GetPath()))
{ // grab the ALL item in this category
// Genres will still require 2 lookups, and queuing the entire Genre folder
// will require 3 lookups (genre, artist, album)
CMusicDbUrl musicUrl;
if (musicUrl.FromString(pItem->GetPath()))
{
musicUrl.AppendPath("-1/");
CFileItemPtr item(new CFileItem(musicUrl.ToString(), true));
item->SetCanQueue(true); // workaround for CanQueue() check above
AddItemToPlayList(item, queuedItems);
}
return;
}
}
if (pItem->m_bIsFolder || (g_windowManager.GetActiveWindow() == WINDOW_MUSIC_NAV && pItem->IsPlayList()))
{
// Check if we add a locked share
if ( pItem->m_bIsShareOrDrive )
{
CFileItem item = *pItem;
if ( !g_passwordManager.IsItemUnlocked( &item, "music" ) )
return ;
}
// recursive
CFileItemList items;
GetDirectory(pItem->GetPath(), items);
//OnRetrieveMusicInfo(items);
FormatAndSort(items);
for (int i = 0; i < items.Size(); ++i)
AddItemToPlayList(items[i], queuedItems);
}
else
{
if (pItem->IsPlayList())
{
std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(*pItem));
if (pPlayList.get())
{
// load it
if (!pPlayList->Load(pItem->GetPath()))
{
CGUIDialogOK::ShowAndGetInput(CVariant{6}, CVariant{477});
return; //hmmm unable to load playlist?
}
CPlayList playlist = *pPlayList;
for (int i = 0; i < (int)playlist.size(); ++i)
{
AddItemToPlayList(playlist[i], queuedItems);
}
return;
}
}
else if(pItem->IsInternetStream())
{ // just queue the internet stream, it will be expanded on play
queuedItems.Add(pItem);
}
else if (pItem->IsPlugin() && pItem->GetProperty("isplayable") == "true")
{
// python files can be played
queuedItems.Add(pItem);
}
else if (!pItem->IsNFO() && (pItem->IsAudio() || pItem->IsVideo()))
{
CFileItemPtr itemCheck = queuedItems.Get(pItem->GetPath());
if (!itemCheck || itemCheck->m_lStartOffset != pItem->m_lStartOffset)
{ // add item
CFileItemPtr item(new CFileItem(*pItem));
m_musicdatabase.SetPropertiesForFileItem(*item);
queuedItems.Add(item);
}
}
}
}
示例6: GetDirectory
bool CHTTPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CFileCurl http;
CURL url(strPath);
CStdString strName, strLink;
CStdString strBasePath = url.GetFileName();
if(!http.Open(url, false))
{
CLog::Log(LOGERROR, "%s - Unable to get http directory", __FUNCTION__);
return false;
}
CRegExp reItem;
reItem.RegComp("<a href=\"(.*)\">(.*)</a>");
/* read response from server into string buffer */
char buffer[MAX_PATH + 1024];
while(http.ReadString(buffer, sizeof(buffer)-1))
{
CStdString strBuffer = buffer;
StringUtils::RemoveCRLF(strBuffer);
if (reItem.RegFind(strBuffer.c_str()) >= 0)
{
strLink = reItem.GetReplaceString("\\1");
strName = reItem.GetReplaceString("\\2");
if(strLink[0] == '/')
strLink = strLink.Mid(1);
CStdString strNameTemp = strName.Trim();
CStdString strLinkTemp = strLink;
CUtil::RemoveSlashAtEnd(strLinkTemp);
CUtil::RemoveSlashAtEnd(strNameTemp);
CUtil::UrlDecode(strLinkTemp);
if (strNameTemp == strLinkTemp)
{
g_charsetConverter.stringCharsetToUtf8(strName);
CUtil::RemoveSlashAtEnd(strName);
CFileItemPtr pItem(new CFileItem(strName));
pItem->m_strPath = strBasePath + strLink;
if(CUtil::HasSlashAtEnd(pItem->m_strPath))
pItem->m_bIsFolder = true;
url.SetFileName(pItem->m_strPath);
url.GetURL(pItem->m_strPath);
if (!pItem->m_bIsFolder && g_advancedSettings.m_bHTTPDirectoryStatFilesize)
{
CFileCurl file;
file.Open(url, false);
pItem->m_dwSize= file.GetLength();
file.Close();
}
if (!pItem->m_bIsFolder && pItem->m_dwSize == 0)
{
CRegExp reSize;
reSize.RegComp(">([0-9.]+)(K|M|G)</td>");
if (reSize.RegFind(strBuffer.c_str()) >= 0)
{
double Size = atof(reSize.GetReplaceString("\\1"));
CStdString strUnit = reSize.GetReplaceString("\\2");
if (strUnit == "M")
Size = Size * 1024;
else if (strUnit == "G")
Size = Size * 1000 * 1024;
pItem->m_dwSize = (__int64)(Size * 1024);
}
}
items.Add(pItem);
}
}
}
http.Close();
return true;
}
示例7: GetDirectory
bool CDAVDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CFileCurl dav;
CURL url(strPath);
CStdString strRequest = "PROPFIND";
dav.SetCustomRequest(strRequest);
dav.SetMimeType("text/xml; charset=\"utf-8\"");
dav.SetRequestHeader("depth", 1);
dav.SetPostData(
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
" <D:propfind xmlns:D=\"DAV:\">"
" <D:prop>"
" <D:resourcetype/>"
" <D:getcontentlength/>"
" <D:getlastmodified/>"
" <D:creationdate/>"
" <D:displayname/>"
" </D:prop>"
" </D:propfind>");
if (!dav.Open(url))
{
CLog::Log(LOGERROR, "%s - Unable to get dav directory (%s)", __FUNCTION__, strPath.c_str());
return false;
}
char buffer[MAX_PATH + 1024];
CStdString strResponse;
CStdString strHeader;
while (dav.ReadString(buffer, sizeof(buffer)))
{
if (strstr(buffer, "<D:response") != NULL)
{
// The header should contain the xml version/utf encoding line
// followed by the <multistatus> tag
if (strHeader.IsEmpty())
strHeader = strResponse;
strResponse = strHeader;
}
strResponse.append(buffer, strlen(buffer));
if (strstr(buffer, "</D:response") != NULL)
{
// Close the multistatus tag from the header
if (strHeader.Find("<D:multistatus"))
strResponse+="</D:multistatus>\n";
TiXmlDocument davResponse;
if (!davResponse.Parse(strResponse))
{
CLog::Log(LOGERROR, "%s - Unable to process dav directory (%s)", __FUNCTION__, strPath.c_str());
dav.Close();
return false;
}
TiXmlNode *pChild;
// Iterate over all responses
for (pChild = davResponse.RootElement()->FirstChild(); pChild != 0; pChild = pChild->NextSibling())
{
if (ValueWithoutNamespace(pChild, "response"))
{
CFileItem item;
ParseResponse(pChild->ToElement(), item);
CURL url2(strPath);
CURL url3(item.m_strPath);
URIUtils::AddFileToFolder(url2.GetWithoutFilename(), url3.GetFileName(), item.m_strPath);
if (item.GetLabel().IsEmpty())
{
CStdString name(item.m_strPath);
URIUtils::RemoveSlashAtEnd(name);
CURL::Decode(name);
item.SetLabel(URIUtils::GetFileName(name));
}
if (item.m_bIsFolder)
URIUtils::AddSlashAtEnd(item.m_strPath);
// Add back protocol options
if (!url2.GetProtocolOptions().IsEmpty())
item.m_strPath += "|" + url2.GetProtocolOptions();
if (!item.m_strPath.Equals(strPath))
{
CFileItemPtr pItem(new CFileItem(item));
items.Add(pItem);
}
}
}
strResponse.clear();
}
}
dav.Close();
return true;
//.........这里部分代码省略.........
示例8: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, vector<string> &addonIDs, bool showNone /* = false */, bool showDetails /* = true */, bool multipleSelection /* = true */, bool showInstalled /* = true */, bool showInstallable /* = false */, bool showMore /* = true */)
{
// if we shouldn't show neither installed nor installable addons the list will be empty
if (!showInstalled && !showInstallable)
return 0;
// can't show the "Get More" button if we already show installable addons
if (showInstallable)
showMore = false;
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog)
return 0;
// get rid of any invalid addon types
vector<ADDON::TYPE> validTypes(types.size());
std::copy_if(types.begin(), types.end(), validTypes.begin(), [](ADDON::TYPE type) { return type != ADDON_UNKNOWN; });
if (validTypes.empty())
return 0;
// get all addons to show
VECADDONS addons;
if (showInstalled)
{
for (vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
{
VECADDONS typeAddons;
if (*type == ADDON_AUDIO)
CAddonsDirectory::GetScriptsAndPlugins("audio", typeAddons);
else if (*type == ADDON_EXECUTABLE)
CAddonsDirectory::GetScriptsAndPlugins("executable", typeAddons);
else if (*type == ADDON_IMAGE)
CAddonsDirectory::GetScriptsAndPlugins("image", typeAddons);
else if (*type == ADDON_VIDEO)
CAddonsDirectory::GetScriptsAndPlugins("video", typeAddons);
else
CAddonMgr::GetInstance().GetAddons(*type, typeAddons);
addons.insert(addons.end(), typeAddons.begin(), typeAddons.end());
}
}
if (showInstallable || showMore)
{
VECADDONS installableAddons;
CAddonDatabase database;
if (database.Open() && database.GetAddons(installableAddons))
{
for (ADDON::IVECADDONS addon = installableAddons.begin(); addon != installableAddons.end();)
{
AddonPtr pAddon = *addon;
// check if the addon matches one of the provided addon types
bool matchesType = false;
for (vector<ADDON::TYPE>::const_iterator type = validTypes.begin(); type != validTypes.end(); ++type)
{
if (pAddon->IsType(*type))
{
matchesType = true;
break;
}
}
// only show addons that match one of the provided addon types and that aren't disabled
if (matchesType && !CAddonMgr::GetInstance().IsAddonDisabled(pAddon->ID()))
{
// check if the addon is installed
bool isInstalled = CAddonMgr::GetInstance().IsAddonInstalled(pAddon->ID());
// check if the addon is installed or can be installed
if ((showInstallable || showMore) && !isInstalled && CAddonMgr::GetInstance().CanAddonBeInstalled(pAddon))
{
++addon;
continue;
}
}
addon = installableAddons.erase(addon);
}
if (showInstallable)
addons.insert(addons.end(), installableAddons.begin(), installableAddons.end());
else if (showMore)
showMore = !installableAddons.empty();
}
}
if (addons.empty() && !showNone)
return 0;
// turn the addons into items
std::map<std::string, AddonPtr> addonMap;
CFileItemList items;
for (ADDON::IVECADDONS addon = addons.begin(); addon != addons.end(); ++addon)
{
CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*addon, (*addon)->ID()));
if (!items.Contains(item->GetPath()))
{
items.Add(item);
//.........这里部分代码省略.........
示例9: GetIntegerItems
bool CGUIControlListSetting::GetIntegerItems(const CSetting *setting, CFileItemList &items)
{
const CSettingInt *pSettingInt = NULL;
std::set<int> values;
if (setting->GetType() == SettingTypeInteger)
{
pSettingInt = static_cast<const CSettingInt*>(setting);
values.insert(pSettingInt->GetValue());
}
else if (setting->GetType() == SettingTypeList)
{
const CSettingList *settingList = static_cast<const CSettingList*>(setting);
if (settingList->GetElementType() != SettingTypeInteger)
return false;
pSettingInt = static_cast<const CSettingInt*>(settingList->GetDefinition());
std::vector<CVariant> list = CSettingUtils::GetList(settingList);
for (std::vector<CVariant>::const_iterator itValue = list.begin(); itValue != list.end(); ++itValue)
{
if (!itValue->isInteger())
return false;
values.insert((int)itValue->asInteger());
}
}
else
return false;
switch (pSettingInt->GetOptionsType())
{
case SettingOptionsTypeStatic:
{
const StaticIntegerSettingOptions& options = pSettingInt->GetOptions();
for (StaticIntegerSettingOptions::const_iterator it = options.begin(); it != options.end(); ++it)
{
CFileItemPtr pItem = GetItem(g_localizeStrings.Get(it->first), it->second);
if (values.find(it->second) != values.end())
pItem->Select(true);
items.Add(pItem);
}
break;
}
case SettingOptionsTypeDynamic:
{
DynamicIntegerSettingOptions options = const_cast<CSettingInt*>(pSettingInt)->UpdateDynamicOptions();
for (DynamicIntegerSettingOptions::const_iterator option = options.begin(); option != options.end(); ++option)
{
CFileItemPtr pItem = GetItem(option->first, option->second);
if (values.find(option->second) != values.end())
pItem->Select(true);
items.Add(pItem);
}
break;
}
case SettingOptionsTypeNone:
default:
return false;
}
return true;
}
示例10: SelectAddonID
int CGUIWindowAddonBrowser::SelectAddonID(const vector<ADDON::TYPE> &types, CStdStringArray &addonIDs, bool showNone /*= false*/, bool multipleSelection /*= true*/)
{
CGUIDialogSelect *dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
if (!dialog)
return 0;
CFileItemList items;
CStdString heading;
int iTypes = 0;
for (vector<ADDON::TYPE>::const_iterator it = types.begin(); it != types.end(); ++it)
{
if (*it == ADDON_UNKNOWN)
continue;
ADDON::VECADDONS addons;
iTypes++;
if (*it == ADDON_AUDIO)
CAddonsDirectory::GetScriptsAndPlugins("audio",addons);
else if (*it == ADDON_EXECUTABLE)
CAddonsDirectory::GetScriptsAndPlugins("executable",addons);
else if (*it == ADDON_IMAGE)
CAddonsDirectory::GetScriptsAndPlugins("image",addons);
else if (*it == ADDON_VIDEO)
CAddonsDirectory::GetScriptsAndPlugins("video",addons);
else
CAddonMgr::Get().GetAddons(*it, addons);
for (ADDON::IVECADDONS it2 = addons.begin() ; it2 != addons.end() ; ++it2)
{
CFileItemPtr item(CAddonsDirectory::FileItemFromAddon(*it2, ""));
if (!items.Contains(item->GetPath()))
items.Add(item);
}
if (!heading.IsEmpty())
heading += ", ";
heading += TranslateType(*it, true);
}
if (iTypes == 0)
return 0;
dialog->SetHeading(heading);
dialog->Reset();
dialog->SetUseDetails(true);
if (multipleSelection)
showNone = false;
if (multipleSelection || iTypes > 1)
dialog->EnableButton(true, 186);
else
dialog->EnableButton(true, 21452);
if (showNone)
{
CFileItemPtr item(new CFileItem("", false));
item->SetLabel(g_localizeStrings.Get(231));
item->SetLabel2(g_localizeStrings.Get(24040));
item->SetIconImage("DefaultAddonNone.png");
item->SetSpecialSort(SortSpecialOnTop);
items.Add(item);
}
items.Sort(SORT_METHOD_LABEL, SortOrderAscending);
if (addonIDs.size() > 0)
{
for (CStdStringArray::const_iterator it = addonIDs.begin(); it != addonIDs.end() ; it++)
{
CFileItemPtr item = items.Get(*it);
if (item)
item->Select(true);
}
}
dialog->SetItems(&items);
dialog->SetMultiSelection(multipleSelection);
dialog->DoModal();
if (!multipleSelection && iTypes == 1 && dialog->IsButtonPressed())
{ // switch to the addons browser.
vector<CStdString> params;
params.push_back("addons://all/"+TranslateType(types[0],false)+"/");
params.push_back("return");
g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
return 2;
}
if (!dialog->IsConfirmed())
return 0;
addonIDs.clear();
const CFileItemList& list = dialog->GetSelectedItems();
for (int i = 0 ; i < list.Size() ; i++)
addonIDs.push_back(list.Get(i)->GetPath());
return 1;
}
示例11: GetDirectory
bool CGUIWindowAddonBrowser::GetDirectory(const std::string& strDirectory, CFileItemList& items)
{
bool result;
if (URIUtils::PathEquals(strDirectory, "addons://downloading/"))
{
VECADDONS addons;
CAddonInstaller::GetInstance().GetInstallList(addons);
CURL url(strDirectory);
CAddonsDirectory::GenerateAddonListing(url, addons, items, g_localizeStrings.Get(24067));
result = true;
items.SetPath(strDirectory);
if (m_guiState.get() && !m_guiState->HideParentDirItems())
{
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath(m_history.GetParentPath());
pItem->m_bIsFolder = true;
pItem->m_bIsShareOrDrive = false;
items.AddFront(pItem, 0);
}
}
else
{
result = CGUIMediaWindow::GetDirectory(strDirectory, items);
if (result && CAddonsDirectory::IsRepoDirectory(CURL(strDirectory)))
{
if (CSettings::GetInstance().GetBool(CSettings::SETTING_GENERAL_ADDONFOREIGNFILTER))
{
int i = 0;
while (i < items.Size())
{
auto prop = items[i]->GetProperty("Addon.Language");
if (!prop.isNull() && IsForeign(prop.asString()))
items.Remove(i);
else
++i;
}
}
if (CSettings::GetInstance().GetBool(CSettings::SETTING_GENERAL_ADDONBROKENFILTER))
{
for (int i = items.Size() - 1; i >= 0; i--)
{
if (!items[i]->GetProperty("Addon.Broken").empty())
{
//check if it's installed
AddonPtr addon;
if (!CAddonMgr::GetInstance().GetAddon(items[i]->GetProperty("Addon.ID").asString(), addon))
items.Remove(i);
}
}
}
}
}
if (strDirectory.empty() && CAddonInstaller::GetInstance().IsDownloading())
{
CFileItemPtr item(new CFileItem("addons://downloading/", true));
item->SetLabel(g_localizeStrings.Get(24067));
item->SetLabelPreformated(true);
item->SetIconImage("DefaultNetwork.png");
items.Add(item);
}
items.SetContent("addons");
for (int i = 0; i < items.Size(); ++i)
SetItemLabel2(items[i]);
return result;
}
示例12: GetDirectory
bool CGUIWindowAddonBrowser::GetDirectory(const CStdString& strDirectory,
CFileItemList& items)
{
bool result;
if (strDirectory.Equals("addons://downloading/"))
{
VECADDONS addons;
CAddonInstaller::Get().GetInstallList(addons);
CURL url(strDirectory);
CAddonsDirectory::GenerateListing(url,addons,items);
result = true;
items.SetProperty("reponame",g_localizeStrings.Get(24067));
items.SetPath(strDirectory);
if (m_guiState.get() && !m_guiState->HideParentDirItems())
{
CFileItemPtr pItem(new CFileItem(".."));
pItem->SetPath(m_history.GetParentPath());
pItem->m_bIsFolder = true;
pItem->m_bIsShareOrDrive = false;
items.AddFront(pItem, 0);
}
}
else
{
result = CGUIMediaWindow::GetDirectory(strDirectory,items);
if (CSettings::Get().GetBool("general.addonforeignfilter"))
{
int i=0;
while (i < items.Size())
{
if (!FilterVar(CSettings::Get().GetBool("general.addonforeignfilter"),
items[i]->GetProperty("Addon.Language"), "en") ||
!FilterVar(CSettings::Get().GetBool("general.addonforeignfilter"),
items[i]->GetProperty("Addon.Language"),
g_langInfo.GetLanguageLocale()))
{
i++;
}
else
items.Remove(i);
}
}
}
if (strDirectory.IsEmpty() && CAddonInstaller::Get().IsDownloading())
{
CFileItemPtr item(new CFileItem("addons://downloading/",true));
item->SetLabel(g_localizeStrings.Get(24067));
item->SetLabelPreformated(true);
item->SetIconImage("DefaultNetwork.png");
items.Add(item);
}
items.SetContent("addons");
for (int i=0;i<items.Size();++i)
SetItemLabel2(items[i]);
return result;
}
示例13: ChangeRecordingsPlayCount
bool CPVRRecordings::ChangeRecordingsPlayCount(const CFileItemPtr &item, int count)
{
bool bResult = false;
if (m_database.IsOpen())
{
bResult = true;
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - item path %s", __FUNCTION__, item->GetPath().c_str());
CFileItemList items;
if (item->m_bIsFolder)
{
XFILE::CDirectory::GetDirectory(item->GetPath(), items);
}
else
items.Add(item);
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - will set watched for %d items", __FUNCTION__, items.Size());
for (int i=0;i<items.Size();++i)
{
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - setting watched for item %d", __FUNCTION__, i);
CFileItemPtr pItem=items[i];
if (pItem->m_bIsFolder)
{
CLog::Log(LOGDEBUG, "CPVRRecordings - %s - path %s is a folder, will call recursively", __FUNCTION__, pItem->GetPath().c_str());
if (pItem->GetLabel() != "..")
{
ChangeRecordingsPlayCount(pItem, count);
}
continue;
}
if (!pItem->HasPVRRecordingInfoTag())
continue;
const CPVRRecordingPtr recording = pItem->GetPVRRecordingInfoTag();
if (recording)
{
if (count == INCREMENT_PLAY_COUNT)
recording->IncrementPlayCount();
else
recording->SetPlayCount(count);
// Clear resume bookmark
if (recording->m_playCount > 0)
{
m_database.ClearBookMarksOfFile(pItem->GetPath(), CBookmark::RESUME);
recording->SetLastPlayedPosition(0);
}
if (count == INCREMENT_PLAY_COUNT)
m_database.IncrementPlayCount(*pItem);
else
m_database.SetPlayCount(*pItem, count);
}
}
}
return bResult;
}
示例14: GetDirectory
bool CPVRRecordings::GetDirectory(const std::string& strPath, CFileItemList &items)
{
CSingleLock lock(m_critSection);
bool bGrouped = false;
const CURL url(strPath);
if (url.HasOption("view"))
{
const std::string view(url.GetOption("view"));
if (view == "grouped")
bGrouped = true;
else if (view == "flat")
bGrouped = false;
else
{
CLog::Log(LOGERROR, "CPVRRecordings - %s - unsupported value '%s' for url parameter 'view'", __FUNCTION__, view.c_str());
return false;
}
}
else
{
bGrouped = CSettings::GetInstance().GetBool(CSettings::SETTING_PVRRECORD_GROUPRECORDINGS);
}
CPVRRecordingsPath recPath(url.GetWithoutOptions());
if (recPath.IsValid())
{
// Get the directory structure if in non-flatten mode
// Deleted view is always flatten. So only for an active view
std::string strDirectory(recPath.GetDirectoryPath());
if (!recPath.IsDeleted() && bGrouped)
GetSubDirectories(recPath, &items);
// get all files of the currrent directory or recursively all files starting at the current directory if in flatten mode
for (const auto recording : m_recordings)
{
CPVRRecordingPtr current = recording.second;
// Omit recordings not matching criteria
if (!IsDirectoryMember(strDirectory, current->m_strDirectory, bGrouped) ||
current->IsDeleted() != recPath.IsDeleted() ||
current->IsRadio() != recPath.IsRadio())
continue;
if (m_database.IsOpen())
current->UpdateMetadata(m_database);
CFileItemPtr pFileItem(new CFileItem(current));
pFileItem->SetLabel2(current->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(true, false));
pFileItem->m_dateTime = current->RecordingTimeAsLocalTime();
pFileItem->SetPath(current->m_strFileNameAndPath);
// Set art
if (!current->m_strIconPath.empty())
{
pFileItem->SetIconImage(current->m_strIconPath);
pFileItem->SetArt("icon", current->m_strIconPath);
}
if (!current->m_strThumbnailPath.empty())
pFileItem->SetArt("thumb", current->m_strThumbnailPath);
if (!current->m_strFanartPath.empty())
pFileItem->SetArt("fanart", current->m_strFanartPath);
// Use the channel icon as a fallback when a thumbnail is not available
pFileItem->SetArtFallback("thumb", "icon");
pFileItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, pFileItem->GetPVRRecordingInfoTag()->m_playCount > 0);
items.Add(pFileItem);
}
}
if (items.IsEmpty())
{
// Note: Do not change the ".." label. It has very special meaning/logic.
// CFileItem::IsParentFolder() and and other code depends on this.
const CFileItemPtr item(new CFileItem(".."));
items.Add(item);
}
return recPath.IsValid();
}
示例15: OnInitWindow
void CGUIDialogBoxeeChannelFilter::OnInitWindow()
{
CGUIDialog::OnInitWindow();
CStdString sourcesUrl = "boxee://sources/";
int activeWindow = g_windowManager.GetActiveWindow();
if (activeWindow == WINDOW_BOXEE_BROWSE_MOVIES)
{
sourcesUrl += "movies";
}
else
{
sourcesUrl += "shows";
}
CLog::Log(LOGDEBUG,"CGUIDialogBoxeeChannelFilter::OnInitWindow - build source list for [url=%s] (cf)",sourcesUrl.c_str());
CFileItemList sourceList;
DIRECTORY::CDirectory::GetDirectory(sourcesUrl,sourceList);
if (sourceList.Size() < 1)
{
CLog::Log(LOGERROR,"CGUIDialogBoxeeChannelFilter::OnInitWindow - FAILED to get sources. [size=%d] (cf)",sourceList.Size());
Close();
return;
}
if (!LoadExcludedChannels())
{
CLog::Log(LOGERROR,"CGUIDialogBoxeeChannelFilter::OnInitWindow - FAILED to load excluded sources (cf)");
Close();
return;
}
CLog::Log(LOGDEBUG,"CGUIDialogBoxeeChannelFilter::OnInitWindow - [NumOfSources=%d][NumOfExcludedSources=%zu] (cf)",sourceList.Size(),m_excludedChannels.size());
CGUIMessage winmsgResetPremium(GUI_MSG_LABEL_RESET, GetID(), CHANNEL_LIST);
OnMessage(winmsgResetPremium);
CFileItemList channelItemList;
CFileItemList freeChannelItemList;
for (int i=0; i<sourceList.Size(); i++)
{
CFileItemPtr sourceItem = sourceList.Get(i);
std::string sourceId = sourceItem->GetProperty("sourceid");
std::string sourceOffer = sourceItem->GetProperty("sourceoffer");
if (sourceOffer.empty())
{
CLog::Log(LOGWARNING,"CGUIDialogBoxeeChannelFilter::OnInitWindow - [%d/%d] - for sources [id=%s] the attribute offer is EMPTY. [offer=%s] (cf)",i+1,sourceList.Size(),sourceId.c_str(),sourceOffer.c_str());
continue;
}
CFileItemPtr source(new CFileItem(*(sourceItem.get())));
source->SetProperty("channelthumb",source->GetProperty("sourcethumb"));
source->Select(m_excludedChannels.find(sourceId) == m_excludedChannels.end());
if (stricmp(sourceOffer.c_str(),FREE_OFFER_STRING))
{
if (channelItemList.IsEmpty())
{
// add PREMIUM separator
CFileItemPtr seperator(new CFileItem(g_localizeStrings.Get(53581)));
seperator->SetProperty("isseparator",true);
channelItemList.Add(seperator);
}
CLog::Log(LOGDEBUG,"CGUIDialogBoxeeChannelFilter::OnInitWindow - [%d/%d] - [sourceoffer=%s] -> adding PREMIUM source [id=%s] (cf)",i+1,sourceList.Size(),sourceOffer.c_str(),sourceId.c_str());
channelItemList.Add(source);
}
else
{
CLog::Log(LOGDEBUG,"CGUIDialogBoxeeChannelFilter::OnInitWindow - [%d/%d] - [sourceoffer=%s] -> adding FREE source [id=%s] (cf)",i+1,sourceList.Size(),sourceOffer.c_str(),sourceId.c_str());
freeChannelItemList.Add(source);
}
}
for (int i=0; i<freeChannelItemList.Size(); i++)
{
if (i == 0 && !channelItemList.IsEmpty())
{
// add FREE separator
CFileItemPtr seperator(new CFileItem(g_localizeStrings.Get(53582)));
seperator->SetProperty("isseparator",true);
channelItemList.Add(seperator);
}
CFileItemPtr source(new CFileItem(*(freeChannelItemList.Get(i))));
source->SetProperty("channelthumb",source->GetProperty("sourcethumb"));
channelItemList.Add(source);
}
CGUIMessage msgBindToChannelList(GUI_MSG_LABEL_BIND, GetID(), CHANNEL_LIST, 0, 0, &channelItemList);
OnMessage(msgBindToChannelList);
SET_CONTROL_FOCUS(CHANNEL_LIST, 0);
m_dirty = false;
//.........这里部分代码省略.........