本文整理汇总了C++中CVariant类的典型用法代码示例。如果您正苦于以下问题:C++ CVariant类的具体用法?C++ CVariant怎么用?C++ CVariant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CVariant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Reset
void CGUIDialogMediaFilter::InitializeSettings()
{
CGUIDialogSettingsManualBase::InitializeSettings();
if (m_filter == NULL)
return;
Reset(true);
int handledRules = 0;
CSettingCategory *category = AddCategory("filter", -1);
if (category == NULL)
{
CLog::Log(LOGERROR, "CGUIDialogMediaFilter: unable to setup filters");
return;
}
CSettingGroup *group = AddGroup(category);
if (group == NULL)
{
CLog::Log(LOGERROR, "CGUIDialogMediaFilter: unable to setup filters");
return;
}
for (unsigned int index = 0; index < NUM_FILTERS; index++)
{
if (filterList[index].mediaType != m_mediaType)
continue;
Filter filter = filterList[index];
// check the smartplaylist if it contains a matching rule
for (CDatabaseQueryRules::iterator rule = m_filter->m_ruleCombination.m_rules.begin(); rule != m_filter->m_ruleCombination.m_rules.end(); rule++)
{
if ((*rule)->m_field == filter.field)
{
filter.rule = (CSmartPlaylistRule *)rule->get();
handledRules++;
break;
}
}
std::string settingId = StringUtils::Format("filter.%s.%d", filter.mediaType.c_str(), filter.field);
if (filter.controlType == "edit")
{
CVariant data;
if (filter.rule != NULL && filter.rule->m_parameter.size() == 1)
data = filter.rule->m_parameter.at(0);
if (filter.settingType == SettingTypeString)
filter.setting = AddEdit(group, settingId, filter.label, 0, data.asString(), true, false, filter.label, true);
else if (filter.settingType == SettingTypeInteger)
filter.setting = AddEdit(group, settingId, filter.label, 0, static_cast<int>(data.asInteger()), 0, 1, 0, false, static_cast<int>(filter.label), true);
else if (filter.settingType == SettingTypeNumber)
filter.setting = AddEdit(group, settingId, filter.label, 0, data.asFloat(), 0.0f, 1.0f, 0.0f, false, filter.label, true);
}
else if (filter.controlType == "toggle")
{
int value = CHECK_ALL;
if (filter.rule != NULL)
value = filter.rule->m_operator == CDatabaseQueryRule::OPERATOR_TRUE ? CHECK_YES : CHECK_NO;
StaticIntegerSettingOptions entries;
entries.push_back(std::pair<int, int>(CHECK_LABEL_ALL, CHECK_ALL));
entries.push_back(std::pair<int, int>(CHECK_LABEL_NO, CHECK_NO));
entries.push_back(std::pair<int, int>(CHECK_LABEL_YES, CHECK_YES));
filter.setting = AddSpinner(group, settingId, filter.label, 0, value, entries, true);
}
else if (filter.controlType == "list")
{
std::vector<std::string> values;
if (filter.rule != NULL && !filter.rule->m_parameter.empty())
{
values = StringUtils::Split(filter.rule->GetParameter(), DATABASEQUERY_RULE_VALUE_SEPARATOR);
if (values.size() == 1 && values.at(0).empty())
values.erase(values.begin());
}
filter.setting = AddList(group, settingId, filter.label, 0, values, GetStringListOptions, filter.label);
}
else if (filter.controlType == "range")
{
CVariant valueLower, valueUpper;
if (filter.rule != NULL)
{
if (filter.rule->m_parameter.size() == 2)
{
valueLower = filter.rule->m_parameter.at(0);
valueUpper = filter.rule->m_parameter.at(1);
}
else
{
DeleteRule(filter.field);
filter.rule = NULL;
}
}
if (filter.settingType == SettingTypeInteger)
//.........这里部分代码省略.........
示例2: FillDetails
void CFileItemHandler::FillDetails(ISerializable* info, CFileItemPtr item, const CVariant& fields, CVariant &result)
{
if (info == NULL || fields.size() == 0)
return;
CVariant serialization;
info->Serialize(serialization);
for (unsigned int i = 0; i < fields.size(); i++)
{
CStdString field = fields[i].asString();
if (item)
{
if (item->IsAlbum() && field.Equals("albumlabel"))
field = "label";
if (item->IsAlbum())
{
if (field == "label")
{
result["albumlabel"] = item->GetProperty("album_label");
continue;
}
/* This would break backwards compatibility to JSON-RPC API v4
if (item->HasProperty("album_" + field + "_array"))
{
result[field] = item->GetProperty("album_" + field + "_array");
continue;
}*/
if (item->HasProperty("album_" + field))
{
result[field] = item->GetProperty("album_" + field);
continue;
}
}
/* This would break backwards compatibility to JSON-RPC API v4
if (item->HasProperty("artist_" + field + "_array"))
{
result[field] = item->GetProperty("artist_" + field + "_array");
continue;
}*/
if (item->HasProperty("artist_" + field))
{
result[field] = item->GetProperty("artist_" + field);
continue;
}
if (field == "fanart" && !item->HasPictureInfoTag())
{
CStdString fanart;
if (item->HasProperty("fanart_image"))
fanart = item->GetProperty("fanart_image").asString();
if (fanart.empty())
fanart = item->GetCachedFanart();
if (!fanart.empty())
result["fanart"] = fanart.c_str();
continue;
}
if (item->HasVideoInfoTag() && item->GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS)
{
if (item->GetVideoInfoTag()->m_iSeason < 0 && field == "season")
{
result[field] = (int)item->GetProperty("totalseasons").asInteger();
continue;
}
if (field == "watchedepisodes")
{
result[field] = (int)item->GetProperty("watchedepisodes").asInteger();
continue;
}
}
if (field == "lastmodified" && item->m_dateTime.IsValid())
{
result[field] = item->m_dateTime.GetAsLocalizedDateTime();
continue;
}
}
if (serialization.isMember(field) && (!result.isMember(field) || result[field].empty()))
result[field] = serialization[field];
}
}
示例3: SetShuffle
JSONRPC_STATUS CPlayerOperations::SetShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CGUIWindowSlideShow *slideshow = NULL;
CVariant shuffle = parameterObject["shuffle"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
{
if (IsPVRChannel())
return FailedToExecute;
int playlistid = GetPlaylist(GetPlayer(parameterObject["playerid"]));
if (g_playlistPlayer.IsShuffled(playlistid))
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, false);
OnPlaylistChanged();
}
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, true);
OnPlaylistChanged();
}
}
break;
}
case Picture:
slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (slideshow == NULL)
return FailedToExecute;
if (slideshow->IsShuffled())
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
return FailedToExecute;
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
slideshow->Shuffle();
}
break;
default:
return FailedToExecute;
}
return ACK;
}
示例4: dbus_message_iter_get_arg_type
CVariant CDBusUtil::ParseType(DBusMessageIter *itr)
{
CVariant value;
const char * string = NULL;
dbus_int32_t int32 = 0;
dbus_uint32_t uint32 = 0;
dbus_int64_t int64 = 0;
dbus_uint64_t uint64 = 0;
dbus_bool_t boolean = false;
double doublev = 0;
int type = dbus_message_iter_get_arg_type(itr);
switch (type)
{
case DBUS_TYPE_OBJECT_PATH:
case DBUS_TYPE_STRING:
dbus_message_iter_get_basic(itr, &string);
value = string;
break;
case DBUS_TYPE_UINT32:
dbus_message_iter_get_basic(itr, &uint32);
value = (uint64_t)uint32;
break;
case DBUS_TYPE_BYTE:
case DBUS_TYPE_INT32:
dbus_message_iter_get_basic(itr, &int32);
value = (int64_t)int32;
break;
case DBUS_TYPE_UINT64:
dbus_message_iter_get_basic(itr, &uint64);
value = (uint64_t)uint64;
break;
case DBUS_TYPE_INT64:
dbus_message_iter_get_basic(itr, &int64);
value = (int64_t)int64;
break;
case DBUS_TYPE_BOOLEAN:
dbus_message_iter_get_basic(itr, &boolean);
value = (bool)boolean;
break;
case DBUS_TYPE_DOUBLE:
dbus_message_iter_get_basic(itr, &doublev);
value = (double)doublev;
break;
case DBUS_TYPE_ARRAY:
DBusMessageIter array;
dbus_message_iter_recurse(itr, &array);
value = CVariant::VariantTypeArray;
do
{
CVariant item = ParseType(&array);
if (!item.isNull())
value.push_back(item);
} while (dbus_message_iter_next(&array));
break;
}
return value;
}
示例5: artObj
bool CFileItemHandler::GetField(const std::string &field, const CVariant &info, const CFileItemPtr &item, CVariant &result, bool &fetchedArt, CThumbLoader *thumbLoader /* = NULL */)
{
if (result.isMember(field) && !result[field].empty())
return true;
if (info.isMember(field) && !info[field].isNull())
{
result[field] = info[field];
return true;
}
if (item)
{
if (item->IsAlbum())
{
if (field == "albumlabel")
{
result[field] = item->GetProperty("album_label");
return true;
}
if (item->HasProperty("album_" + field + "_array"))
{
result[field] = item->GetProperty("album_" + field + "_array");
return true;
}
if (item->HasProperty("album_" + field))
{
result[field] = item->GetProperty("album_" + field);
return true;
}
}
if (item->HasProperty("artist_" + field + "_array"))
{
result[field] = item->GetProperty("artist_" + field + "_array");
return true;
}
if (item->HasProperty("artist_" + field))
{
result[field] = item->GetProperty("artist_" + field);
return true;
}
if (field == "art")
{
if (thumbLoader != NULL && item->GetArt().size() <= 0 && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
CGUIListItem::ArtMap artMap = item->GetArt();
CVariant artObj(CVariant::VariantTypeObject);
for (CGUIListItem::ArtMap::const_iterator artIt = artMap.begin(); artIt != artMap.end(); artIt++)
artObj[artIt->first] = CTextureCache::GetWrappedImageURL(artIt->second);
result["art"] = artObj;
return true;
}
if (field == "thumbnail")
{
if (thumbLoader != NULL && !item->HasArt("thumb") && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
else if (item->HasPictureInfoTag() && !item->HasArt("thumb"))
item->SetArt("thumb", CTextureCache::GetWrappedThumbURL(item->GetPath()));
if (item->HasArt("thumb"))
result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetArt("thumb"));
else
result["thumbnail"] = "";
return true;
}
if (field == "fanart")
{
if (thumbLoader != NULL && !item->HasArt("fanart") && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
if (item->HasArt("fanart"))
result["fanart"] = CTextureCache::GetWrappedImageURL(item->GetArt("fanart"));
else
result["fanart"] = "";
return true;
}
if (item->HasVideoInfoTag() && item->GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS)
{
if (item->GetVideoInfoTag()->m_iSeason < 0 && field == "season")
//.........这里部分代码省略.........
示例6: CVariant
inline bool CJSONRPC::IsProperJSONRPC(const CVariant& inputroot)
{
return inputroot.isObject() && inputroot.isMember("jsonrpc") && inputroot["jsonrpc"].isString() && inputroot["jsonrpc"] == CVariant("2.0") && inputroot.isMember("method") && inputroot["method"].isString() && (!inputroot.isMember("params") || inputroot["params"].isArray() || inputroot["params"].isObject());
}
示例7: Open
JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant options = parameterObject["options"];
CVariant optionShuffled = options["shuffled"];
CVariant optionRepeat = options["repeat"];
CVariant optionResume = options["resume"];
CVariant optionPlayer = options["playercoreid"];
if (parameterObject["item"].isObject() && parameterObject["item"].isMember("playlistid"))
{
int playlistid = (int)parameterObject["item"]["playlistid"].asInteger();
if (playlistid < PLAYLIST_PICTURE)
{
// Apply the "shuffled" option if available
if (optionShuffled.isBoolean())
g_playlistPlayer.SetShuffle(playlistid, optionShuffled.asBoolean(), false);
// Apply the "repeat" option if available
if (!optionRepeat.isNull())
g_playlistPlayer.SetRepeat(playlistid, (REPEAT_STATE)ParseRepeatState(optionRepeat), false);
}
int playlistStartPosition = (int)parameterObject["item"]["position"].asInteger();
switch (playlistid)
{
case PLAYLIST_MUSIC:
case PLAYLIST_VIDEO:
CApplicationMessenger::Get().MediaPlay(playlistid, playlistStartPosition);
OnPlaylistChanged();
break;
case PLAYLIST_PICTURE:
{
std::string firstPicturePath;
if (playlistStartPosition > 0)
{
CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (slideshow != NULL)
{
CFileItemList list;
slideshow->GetSlideShowContents(list);
if (playlistStartPosition < list.Size())
firstPicturePath = list.Get(playlistStartPosition)->GetPath();
}
}
return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean(), firstPicturePath);
break;
}
}
return ACK;
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("path"))
{
bool random = (optionShuffled.isBoolean() && optionShuffled.asBoolean()) ||
(!optionShuffled.isBoolean() && parameterObject["item"]["random"].asBoolean());
return StartSlideshow(parameterObject["item"]["path"].asString(), parameterObject["item"]["recursive"].asBoolean(), random);
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("partymode"))
{
if (g_partyModeManager.IsEnabled())
g_partyModeManager.Disable();
CApplicationMessenger::Get().ExecBuiltIn("playercontrol(partymode(" + parameterObject["item"]["partymode"].asString() + "))");
return ACK;
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("channelid"))
{
if (!g_PVRManager.IsStarted())
return FailedToExecute;
CPVRChannelGroupsContainer *channelGroupContainer = g_PVRChannelGroups;
if (channelGroupContainer == NULL)
return FailedToExecute;
CPVRChannelPtr channel = channelGroupContainer->GetChannelById((int)parameterObject["item"]["channelid"].asInteger());
if (channel == NULL)
return InvalidParams;
if ((g_PVRManager.IsPlayingRadio() && channel->IsRadio()) ||
(g_PVRManager.IsPlayingTV() && !channel->IsRadio()))
g_application.m_pPlayer->SwitchChannel(channel);
else
CApplicationMessenger::Get().MediaPlay(CFileItem(channel));
return ACK;
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("recordingid"))
{
if (!g_PVRManager.IsStarted())
return FailedToExecute;
CPVRRecordings *recordingsContainer = g_PVRRecordings;
if (recordingsContainer == NULL)
return FailedToExecute;
CFileItemPtr fileItem = recordingsContainer->GetById((int)parameterObject["item"]["recordingid"].asInteger());
if (fileItem == NULL)
return InvalidParams;
//.........这里部分代码省略.........
示例8: DoAnnounce
void CAnnouncementManager::DoAnnounce(AnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, const CVariant &data)
{
if (item == nullptr)
{
DoAnnounce(flag, sender, message, data);
return;
}
// Extract db id of item
CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
std::string type;
int id = 0;
if(item->HasPVRChannelInfoTag())
{
const PVR::CPVRChannelPtr channel(item->GetPVRChannelInfoTag());
id = channel->ChannelID();
type = "channel";
object["item"]["title"] = channel->ChannelName();
object["item"]["channeltype"] = channel->IsRadio() ? "radio" : "tv";
if (data.isMember("player") && data["player"].isMember("playerid"))
object["player"]["playerid"] = channel->IsRadio() ? PLAYLIST_MUSIC : PLAYLIST_VIDEO;
}
else if (item->HasVideoInfoTag())
{
id = item->GetVideoInfoTag()->m_iDbId;
// TODO: Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item->GetPath().empty() &&
(!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
{
CVideoDatabase videodatabase;
if (videodatabase.Open())
{
std::string path = item->GetPath();
std::string videoInfoTagPath(item->GetVideoInfoTag()->m_strFileNameAndPath);
if (StringUtils::StartsWith(videoInfoTagPath, "removable://"))
path = videoInfoTagPath;
if (videodatabase.LoadVideoInfo(path, *item->GetVideoInfoTag(), VideoDbDetailsNone))
id = item->GetVideoInfoTag()->m_iDbId;
videodatabase.Close();
}
}
if (!item->GetVideoInfoTag()->m_type.empty())
type = item->GetVideoInfoTag()->m_type;
else
CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);
if (id <= 0)
{
// TODO: Can be removed once this is properly handled when starting playback of a file
item->SetProperty(LOOKUP_PROPERTY, false);
std::string title = item->GetVideoInfoTag()->m_strTitle;
if (title.empty())
title = item->GetLabel();
object["item"]["title"] = title;
switch (item->GetVideoContentType())
{
case VIDEODB_CONTENT_MOVIES:
if (item->GetVideoInfoTag()->m_iYear > 0)
object["item"]["year"] = item->GetVideoInfoTag()->m_iYear;
break;
case VIDEODB_CONTENT_EPISODES:
if (item->GetVideoInfoTag()->m_iEpisode >= 0)
object["item"]["episode"] = item->GetVideoInfoTag()->m_iEpisode;
if (item->GetVideoInfoTag()->m_iSeason >= 0)
object["item"]["season"] = item->GetVideoInfoTag()->m_iSeason;
if (!item->GetVideoInfoTag()->m_strShowTitle.empty())
object["item"]["showtitle"] = item->GetVideoInfoTag()->m_strShowTitle;
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
if (!item->GetVideoInfoTag()->m_strAlbum.empty())
object["item"]["album"] = item->GetVideoInfoTag()->m_strAlbum;
if (!item->GetVideoInfoTag()->m_artist.empty())
object["item"]["artist"] = StringUtils::Join(item->GetVideoInfoTag()->m_artist, " / ");
break;
}
}
}
else if (item->HasMusicInfoTag())
{
id = item->GetMusicInfoTag()->GetDatabaseId();
type = MediaTypeSong;
// TODO: Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item->GetPath().empty() &&
(!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
{
CMusicDatabase musicdatabase;
if (musicdatabase.Open())
{
CSong song;
if (musicdatabase.GetSongByFileName(item->GetPath(), song, item->m_lStartOffset))
{
//.........这里部分代码省略.........
示例9: TEST
TEST(TestUrlOptions, AddOptions)
{
std::string ref = "foo=bar&key=value";
CUrlOptions urlOptions(ref);
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("foo", value));
EXPECT_TRUE(value.isString());
EXPECT_STREQ("bar", value.asString().c_str());
}
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("key", value));
EXPECT_TRUE(value.isString());
EXPECT_STREQ("value", value.asString().c_str());
}
ref = "foo=bar&key";
urlOptions.Clear();
urlOptions.AddOptions(ref);
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("foo", value));
EXPECT_TRUE(value.isString());
EXPECT_STREQ("bar", value.asString().c_str());
}
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("key", value));
EXPECT_TRUE(value.isString());
EXPECT_TRUE(value.empty());
}
}
示例10: if
JSON_STATUS CFileOperations::GetDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CStdString media = parameterObject["media"].asString();
media = media.ToLower();
CDirectory directory;
CFileItemList items;
CStdString strPath = parameterObject["directory"].asString();
// Check if this directory is part of a source and whether it's locked
VECSOURCES *sources;
bool isSource;
for (unsigned int index = 0; index < SourcesSize; index++)
{
sources = g_settings.GetSourcesFromType(SourceNames[index]);
int sourceIndex = CUtil::GetMatchingSource(strPath, *sources, isSource);
if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock == 2)
return InvalidParams;
}
CStdStringArray regexps;
CStdString extensions = "";
if (media.Equals("video"))
{
regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
extensions = g_settings.m_videoExtensions;
}
else if (media.Equals("music"))
{
regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
extensions = g_settings.m_musicExtensions;
}
else if (media.Equals("pictures"))
{
regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
extensions = g_settings.m_pictureExtensions;
}
if (directory.GetDirectory(strPath, items, extensions))
{
CFileItemList filteredDirectories, filteredFiles;
for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
{
if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
continue;
if (items[i]->IsSmb())
{
CURL url(items[i]->GetPath());
items[i]->SetPath(url.GetWithoutUserDetails());
}
if ((media == "video" && items[i]->HasVideoInfoTag()) ||
(media == "music" && items[i]->HasMusicInfoTag()))
{
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else
filteredFiles.Add(items[i]);
}
else
{
CFileItem fileItem;
if (FillFileItem(items[i], fileItem, media))
{
if (items[i]->m_bIsFolder)
filteredDirectories.Add(CFileItemPtr(new CFileItem(fileItem)));
else
filteredFiles.Add(CFileItemPtr(new CFileItem(fileItem)));
}
else
{
if (items[i]->m_bIsFolder)
filteredDirectories.Add(items[i]);
else
filteredFiles.Add(items[i]);
}
}
}
// Check if the "properties" list exists
// and make sure it contains the "file"
// field
CVariant param = parameterObject;
if (!param.isMember("properties"))
param["properties"] = CVariant(CVariant::VariantTypeArray);
bool hasFileField = false;
for (CVariant::const_iterator_array itr = param["properties"].begin_array(); itr != param["properties"].end_array(); itr++)
{
if (*itr == CVariant("file"))
{
hasFileField = true;
break;
}
}
if (!hasFileField)
param["properties"].append("file");
//.........这里部分代码省略.........
示例11: TranslateType
JSONRPC_STATUS CAddonsOperations::GetAddons(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
vector<TYPE> addonTypes;
TYPE addonType = TranslateType(parameterObject["type"].asString());
CPluginSource::Content content = CPluginSource::Translate(parameterObject["content"].asString());
CVariant enabled = parameterObject["enabled"];
// ignore the "content" parameter if the type is specified but not a plugin or script
if (addonType != ADDON_UNKNOWN && addonType != ADDON_PLUGIN && addonType != ADDON_SCRIPT)
content = CPluginSource::UNKNOWN;
if (addonType >= ADDON_VIDEO && addonType <= ADDON_EXECUTABLE)
{
addonTypes.push_back(ADDON_PLUGIN);
addonTypes.push_back(ADDON_SCRIPT);
switch (addonType)
{
case ADDON_VIDEO:
content = CPluginSource::VIDEO;
break;
case ADDON_AUDIO:
content = CPluginSource::AUDIO;
break;
case ADDON_IMAGE:
content = CPluginSource::IMAGE;
break;
case ADDON_EXECUTABLE:
content = CPluginSource::EXECUTABLE;
break;
default:
break;
}
}
else
addonTypes.push_back(addonType);
VECADDONS addons;
for (vector<TYPE>::const_iterator typeIt = addonTypes.begin(); typeIt != addonTypes.end(); ++typeIt)
{
VECADDONS typeAddons;
if (*typeIt == ADDON_UNKNOWN)
{
if (!enabled.isBoolean())
{
CAddonMgr::Get().GetAllAddons(typeAddons, false);
CAddonMgr::Get().GetAllAddons(typeAddons, true);
}
else
CAddonMgr::Get().GetAllAddons(typeAddons, enabled.asBoolean());
}
else
{
if (!enabled.isBoolean())
{
CAddonMgr::Get().GetAddons(*typeIt, typeAddons, false);
VECADDONS enabledAddons;
CAddonMgr::Get().GetAddons(*typeIt, enabledAddons, true);
typeAddons.insert(typeAddons.end(), enabledAddons.begin(), enabledAddons.end());
}
else
CAddonMgr::Get().GetAddons(*typeIt, typeAddons, enabled.asBoolean());
}
addons.insert(addons.end(), typeAddons.begin(), typeAddons.end());
}
// remove library addons
for (int index = 0; index < (int)addons.size(); index++)
{
PluginPtr plugin;
if (content != CPluginSource::UNKNOWN)
plugin = boost::dynamic_pointer_cast<CPluginSource>(addons.at(index));
if ((addons.at(index)->Type() <= ADDON_UNKNOWN || addons.at(index)->Type() >= ADDON_MAX) ||
((content != CPluginSource::UNKNOWN && plugin == NULL) || (plugin != NULL && !plugin->Provides(content))))
{
addons.erase(addons.begin() + index);
index--;
}
}
int start, end;
HandleLimits(parameterObject, result, addons.size(), start, end);
CAddonDatabase addondb;
for (int index = start; index < end; index++)
FillDetails(addons.at(index), parameterObject["properties"], result["addons"], addondb, true);
return OK;
}
示例12: director
void CVideoLibrary::UpdateVideoTag(const CVariant ¶meterObject, CVideoInfoTag& details, std::map<std::string, std::string> &artwork, std::set<std::string> &removedArtwork, std::set<std::string> &updatedDetails)
{
if (ParameterNotNull(parameterObject, "title"))
details.SetTitle(parameterObject["title"].asString());
if (ParameterNotNull(parameterObject, "playcount"))
details.SetPlayCount(static_cast<int>(parameterObject["playcount"].asInteger()));
if (ParameterNotNull(parameterObject, "runtime"))
details.SetDuration(static_cast<int>(parameterObject["runtime"].asInteger()));
std::vector<std::string> director(details.m_director);
UpdateVideoTagField(parameterObject, "director", director, updatedDetails);
details.SetDirector(director);
std::vector<std::string> studio(details.m_studio);
UpdateVideoTagField(parameterObject, "studio", studio, updatedDetails);
details.SetStudio(studio);
if (ParameterNotNull(parameterObject, "plot"))
details.SetPlot(parameterObject["plot"].asString());
if (ParameterNotNull(parameterObject, "album"))
details.SetAlbum(parameterObject["album"].asString());
std::vector<std::string> artist(details.m_artist);
UpdateVideoTagField(parameterObject, "artist", artist, updatedDetails);
details.SetArtist(artist);
std::vector<std::string> genre(details.m_genre);
UpdateVideoTagField(parameterObject, "genre", genre, updatedDetails);
details.SetGenre(genre);
if (ParameterNotNull(parameterObject, "track"))
details.m_iTrack = (int)parameterObject["track"].asInteger();
if (ParameterNotNull(parameterObject, "rating"))
{
details.SetRating(parameterObject["rating"].asFloat());
updatedDetails.insert("ratings");
}
if (ParameterNotNull(parameterObject, "votes"))
{
details.SetVotes(StringUtils::ReturnDigits(parameterObject["votes"].asString()));
updatedDetails.insert("ratings"); //Votes and ratings both need updates now, this will trigger those
}
if (ParameterNotNull(parameterObject, "ratings"))
{
CVariant ratings = parameterObject["ratings"];
for (CVariant::const_iterator_map rIt = ratings.begin_map(); rIt != ratings.end_map(); rIt++)
{
if (rIt->second.isObject() && ParameterNotNull(rIt->second, "rating"))
{
const auto& rating = rIt->second;
if (ParameterNotNull(rating, "votes"))
{
details.SetRating(rating["rating"].asFloat(),
static_cast<int>(rating["votes"].asInteger()),
rIt->first,
(ParameterNotNull(rating, "default") && rating["default"].asBoolean()));
}
else
details.SetRating(rating["rating"].asFloat(), rIt->first, (ParameterNotNull(rating, "default") && rating["default"].asBoolean()));
updatedDetails.insert("ratings");
}
else if (rIt->second.isNull())
{
details.RemoveRating(rIt->first);
updatedDetails.insert("ratings");
}
}
}
if (ParameterNotNull(parameterObject, "userrating"))
details.m_iUserRating = static_cast<int>(parameterObject["userrating"].asInteger());
if (ParameterNotNull(parameterObject, "mpaa"))
details.SetMPAARating(parameterObject["mpaa"].asString());
if (ParameterNotNull(parameterObject, "imdbnumber"))
{
details.SetUniqueID(parameterObject["imdbnumber"].asString());
updatedDetails.insert("uniqueid");
}
if (ParameterNotNull(parameterObject, "uniqueid"))
{
CVariant uniqueids = parameterObject["uniqueid"];
for (CVariant::const_iterator_map idIt = uniqueids.begin_map(); idIt != uniqueids.end_map(); idIt++)
{
if (idIt->second.isString() && !idIt->second.asString().empty())
{
details.SetUniqueID(idIt->second.asString(), idIt->first);
updatedDetails.insert("uniqueid");
}
else if (idIt->second.isNull() && idIt->first != details.GetDefaultUniqueID())
{
details.RemoveUniqueID(idIt->first);
updatedDetails.insert("uniqueid");
}
}
}
if (ParameterNotNull(parameterObject, "premiered"))
{
CDateTime premiered;
SetFromDBDate(parameterObject["premiered"], premiered);
details.SetPremiered(premiered);
//.........这里部分代码省略.........
示例13: Open
JSONRPC_STATUS CPlayerOperations::Open(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant optionShuffled = parameterObject["options"]["shuffled"];
CVariant optionRepeat = parameterObject["options"]["repeat"];
CVariant optionResume = parameterObject["options"]["resume"];
if (parameterObject["item"].isObject() && parameterObject["item"].isMember("playlistid"))
{
int playlistid = (int)parameterObject["item"]["playlistid"].asInteger();
if (playlistid < PLAYLIST_PICTURE)
{
// Apply the "shuffled" option if available
if (optionShuffled.isBoolean())
g_playlistPlayer.SetShuffle(playlistid, optionShuffled.asBoolean(), false);
// Apply the "repeat" option if available
if (!optionRepeat.isNull())
g_playlistPlayer.SetRepeat(playlistid, (REPEAT_STATE)ParseRepeatState(optionRepeat), false);
}
switch (playlistid)
{
case PLAYLIST_MUSIC:
case PLAYLIST_VIDEO:
g_application.getApplicationMessenger().MediaPlay(playlistid, (int)parameterObject["item"]["position"].asInteger());
OnPlaylistChanged();
break;
case PLAYLIST_PICTURE:
return StartSlideshow();
break;
}
return ACK;
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("path"))
{
CStdString exec = "slideShow(";
exec += parameterObject["item"]["path"].asString();
if ((optionShuffled.isBoolean() && optionShuffled.asBoolean()) ||
(!optionShuffled.isBoolean() && parameterObject["item"]["random"].asBoolean()))
exec += ", random";
else
exec += ", notrandom";
if (parameterObject["item"]["recursive"].asBoolean())
exec += ", recursive";
exec += ")";
ThreadMessage msg = { TMSG_EXECUTE_BUILT_IN, (DWORD)0, (DWORD)0, exec };
g_application.getApplicationMessenger().SendMessage(msg);
return ACK;
}
else
{
CFileItemList list;
if (FillFileItemList(parameterObject["item"], list) && list.Size() > 0)
{
bool slideshow = true;
for (int index = 0; index < list.Size(); index++)
{
if (!list[index]->IsPicture())
{
slideshow = false;
break;
}
}
if (slideshow)
{
CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (!slideshow)
return FailedToExecute;
SendSlideshowAction(ACTION_STOP);
slideshow->Reset();
for (int index = 0; index < list.Size(); index++)
slideshow->Add(list[index].get());
if (optionShuffled.isBoolean() && optionShuffled.asBoolean())
slideshow->Shuffle();
return StartSlideshow();
}
else
{
// Handle "shuffled" option
if (optionShuffled.isBoolean())
list.SetProperty("shuffled", optionShuffled);
// Handle "repeat" option
if (!optionRepeat.isNull())
list.SetProperty("repeat", ParseRepeatState(optionRepeat));
// Handle "resume" option
if (list.Size() == 1)
{
if (optionResume.isBoolean() && optionResume.asBoolean())
list[0]->m_lStartOffset = STARTOFFSET_RESUME;
//.........这里部分代码省略.........
示例14: clear
int CParamArray::from_stream(int len, uint8_t *buf)
{
int n, i;
int l1, l2, p;
char *str_name;
int pi;
int *arr_len;
CVariant *v;
// name string
str_name = new char[PARAM_ARRAY_ITEM_MAXLEN];
// clear old data
clear();
// stream position index
p = 0;
// stream total length
p += sizeof(int);
// get item number
memcpy(&n, buf+p, sizeof(int));
p += sizeof(int);
// alloc length array
arr_len = new int[n];
// get each item's length
for(i=0; i<n; i++) {
memcpy(&pi, buf+p, sizeof(int));
arr_len[i] = pi;
p += sizeof(int);
}
// for each item
for(i=0; i<n; i++) {
// name length
memcpy(&pi, buf+p, sizeof(int));
l1 = pi;
p += sizeof(int);
// name
memcpy(str_name, buf+p, l1);
p += l1;
// value
l2 = arr_len[i] - sizeof(int) - l1;
v = new CVariant();
v->from_stream(l2, buf+p);
p += l2;
// add name/value to array
na.push_back(str_name);
va.push_back(v);
}
// parse items
parse();
// free temp variables
delete str_name;
delete arr_len;
return 0;
}
示例15: switch
bool CGUIDialogSettingsBase::OnMessage(CGUIMessage &message)
{
switch (message.GetMessage())
{
case GUI_MSG_WINDOW_INIT:
{
m_delayedSetting.reset();
if (message.GetParam1() != WINDOW_INVALID)
{ // coming to this window first time (ie not returning back from some other window)
// so we reset our section and control states
m_iCategory = 0;
ResetControlStates();
}
if (AllowResettingSettings())
{
m_resetSetting = new CSettingAction(SETTINGS_RESET_SETTING_ID);
m_resetSetting->SetLabel(10041);
m_resetSetting->SetHelp(10045);
m_resetSetting->SetControl(CreateControl("button"));
}
m_dummyCategory = new CSettingCategory(SETTINGS_EMPTY_CATEGORY_ID);
m_dummyCategory->SetLabel(10046);
m_dummyCategory->SetHelp(10047);
break;
}
case GUI_MSG_WINDOW_DEINIT:
{
// cancel any delayed changes
if (m_delayedSetting != NULL)
{
m_delayedTimer.Stop();
CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID());
OnMessage(message);
}
CGUIDialog::OnMessage(message);
FreeControls();
return true;
}
case GUI_MSG_FOCUSED:
{
CGUIDialog::OnMessage(message);
int focusedControl = GetFocusedControlID();
// cancel any delayed changes
if (m_delayedSetting != NULL && m_delayedSetting->GetID() != focusedControl)
{
m_delayedTimer.Stop();
CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID(), 1); // param1 = 1 for "reset the control if it's invalid"
g_windowManager.SendThreadMessage(message, GetID());
}
// update the value of the previous setting (in case it was invalid)
else if (m_iSetting >= CONTROL_SETTINGS_START_CONTROL && m_iSetting < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
{
BaseSettingControlPtr control = GetSettingControl(m_iSetting);
if (control != NULL && control->GetSetting() != NULL && !control->IsValid())
{
CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_iSetting, 1); // param1 = 1 for "reset the control if it's invalid"
g_windowManager.SendThreadMessage(message, GetID());
}
}
CVariant description;
// check if we have changed the category and need to create new setting controls
if (focusedControl >= CONTROL_SETTINGS_START_BUTTONS && focusedControl < (int)(CONTROL_SETTINGS_START_BUTTONS + m_categories.size()))
{
int categoryIndex = focusedControl - CONTROL_SETTINGS_START_BUTTONS;
const CSettingCategory* category = m_categories.at(categoryIndex);
if (categoryIndex != m_iCategory)
{
if (!category->CanAccess())
{
// unable to go to this category - focus the previous one
SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + m_iCategory, 0);
return false;
}
m_iCategory = categoryIndex;
CreateSettings();
}
description = category->GetHelp();
}
else if (focusedControl >= CONTROL_SETTINGS_START_CONTROL && focusedControl < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
{
m_iSetting = focusedControl;
CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
if (setting != NULL)
description = setting->GetHelp();
}
// set the description of the currently focused category/setting
if (description.isInteger() ||
(description.isString() && !description.empty()))
SetDescription(description);
//.........这里部分代码省略.........