当前位置: 首页>>代码示例>>C++>>正文


C++ CVariant::isBoolean方法代码示例

本文整理汇总了C++中CVariant::isBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::isBoolean方法的具体用法?C++ CVariant::isBoolean怎么用?C++ CVariant::isBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVariant的用法示例。


在下文中一共展示了CVariant::isBoolean方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetShuffle

JSONRPC_STATUS CPlayerOperations::SetShuffle(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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 (CServiceBroker::GetPlaylistPlayer().IsShuffled(playlistid))
      {
        if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
            (shuffle.isString() && shuffle.asString() == "toggle"))
        {
          CApplicationMessenger::GetInstance().SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 0);
          OnPlaylistChanged();
        }
      }
      else
      {
        if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
            (shuffle.isString() && shuffle.asString() == "toggle"))
        {
          CApplicationMessenger::GetInstance().SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 1);
          OnPlaylistChanged();
        }
      }
      break;
    }

    case Picture:
      slideshow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(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;
}
开发者ID:,项目名称:,代码行数:57,代码来源:

示例2: SetShuffle

JSONRPC_STATUS CPlayerOperations::SetShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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;
}
开发者ID:AnXi-TieGuanYin-Tea,项目名称:plex-home-theatre,代码行数:57,代码来源:PlayerOperations.cpp

示例3: GetAddons

JSONRPC_STATUS CAddonsOperations::GetAddons(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
    vector<TYPE> addonTypes;
    TYPE addonType = TranslateType(parameterObject["type"].asString());
    CVariant enabled = parameterObject["enabled"];

    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::GetInstance().GetAllAddons(typeAddons, false);
                CAddonMgr::GetInstance().GetAllAddons(typeAddons, true);
            }
            else
                CAddonMgr::GetInstance().GetAllAddons(typeAddons, enabled.asBoolean());
        }
        else
        {
            if (!enabled.isBoolean())
            {
                CAddonMgr::GetInstance().GetAddons(*typeIt, typeAddons, false);
                VECADDONS enabledAddons;
                CAddonMgr::GetInstance().GetAddons(*typeIt, enabledAddons, true);
                typeAddons.insert(typeAddons.end(), enabledAddons.begin(), enabledAddons.end());
            }
            else
                CAddonMgr::GetInstance().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++)
    {
        if ((addons.at(index)->Type() <= ADDON_UNKNOWN || addons.at(index)->Type() >= ADDON_MAX))
        {
            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;
}
开发者ID:sandalsoft,项目名称:mrmc,代码行数:57,代码来源:AddonsOperations.cpp

示例4: Record

JSONRPC_STATUS CPVROperations::Record(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  if (!g_PVRManager.IsStarted())
    return FailedToExecute;

  CPVRChannelPtr pChannel;
  CVariant channel = parameterObject["channel"];
  if (channel.isString() && channel.asString() == "current")
  {
    pChannel = g_PVRManager.GetCurrentChannel();
    if (!pChannel)
      return InternalError;
  }
  else if (channel.isInteger())
  {
    CPVRChannelGroupsContainer *channelGroupContainer = g_PVRManager.ChannelGroups();
    if (channelGroupContainer == NULL)
      return FailedToExecute;

    pChannel = channelGroupContainer->GetChannelById((int)channel.asInteger());
  }
  else
    return InvalidParams;

  if (pChannel == NULL)
    return InvalidParams;
  else if (!pChannel->CanRecord())
    return FailedToExecute;

  CVariant record = parameterObject["record"];
  bool toggle = true;
  if (record.isBoolean() && record.asBoolean() == pChannel->IsRecording())
    toggle = false;

  if (toggle)
  {
    if (!g_PVRManager.ToggleRecordingOnChannel(pChannel->ChannelID()))
      return FailedToExecute;
  }

  return ACK;
}
开发者ID:Distrotech,项目名称:xbmc,代码行数:42,代码来源:PVROperations.cpp

示例5: Open

JSONRPC_STATUS CPlayerOperations::Open(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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:
        CApplicationMessenger::Get().MediaPlay(playlistid, (int)parameterObject["item"]["position"].asInteger());
        OnPlaylistChanged();
        break;

      case PLAYLIST_PICTURE:
        return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean());
        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;

    CApplicationMessenger::Get().MediaPlay(CFileItem(*channel.get()));
    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());

        return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean());
      }
      else
      {
        // Handle "shuffled" option
        if (optionShuffled.isBoolean())
          list.SetProperty("shuffled", optionShuffled);
        // Handle "repeat" option
        if (!optionRepeat.isNull())
          list.SetProperty("repeat", ParseRepeatState(optionRepeat));
//.........这里部分代码省略.........
开发者ID:AnXi-TieGuanYin-Tea,项目名称:plex-home-theatre,代码行数:101,代码来源:PlayerOperations.cpp

示例6: Open

JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  CVariant options = parameterObject["options"];
  CVariant optionShuffled = options["shuffled"];
  CVariant optionRepeat = options["repeat"];
  CVariant optionResume = options["resume"];
  CVariant optionPlayer = options["playername"];

  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::GetInstance().SendMsg(TMSG_MEDIA_PLAY, 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::GetInstance().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, "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
    {
      CFileItemList *l = new CFileItemList; //don't delete,
      l->Add(std::make_shared<CFileItem>(channel));
      CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l));
    }

    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;
//.........这里部分代码省略.........
开发者ID:DaHenchmen,项目名称:DHMC,代码行数:101,代码来源:PlayerOperations.cpp

示例7: Open

JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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;
//.........这里部分代码省略.........
开发者ID:JamesLinus,项目名称:xbmc,代码行数:101,代码来源:PlayerOperations.cpp

示例8: GetAddons

JSONRPC_STATUS CAddonsOperations::GetAddons(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  std::vector<TYPE> addonTypes;
  TYPE addonType = CAddonInfo::TranslateType(parameterObject["type"].asString());
  CPluginSource::Content content = CPluginSource::Translate(parameterObject["content"].asString());
  CVariant enabled = parameterObject["enabled"];
  CVariant installed = parameterObject["installed"];

  // 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_GAME:
      content = CPluginSource::GAME;
      break;
    case ADDON_EXECUTABLE:
      content = CPluginSource::EXECUTABLE;
      break;

    default:
      break;
    }
  }
  else
    addonTypes.push_back(addonType);

  VECADDONS addons;
  for (std::vector<TYPE>::const_iterator typeIt = addonTypes.begin(); typeIt != addonTypes.end(); ++typeIt)
  {
    VECADDONS typeAddons;
    if (*typeIt == ADDON_UNKNOWN)
    {
      if (!enabled.isBoolean()) //All
      {
        if (!installed.isBoolean() || installed.asBoolean())
          CServiceBroker::GetAddonMgr().GetInstalledAddons(typeAddons);
        if (!installed.isBoolean() || (installed.isBoolean() && !installed.asBoolean()))
          CServiceBroker::GetAddonMgr().GetInstallableAddons(typeAddons);
      }
      else if (enabled.asBoolean() && (!installed.isBoolean() || installed.asBoolean())) //Enabled
        CServiceBroker::GetAddonMgr().GetAddons(typeAddons);
      else if (!installed.isBoolean() || installed.asBoolean())
        CServiceBroker::GetAddonMgr().GetDisabledAddons(typeAddons);
    }
    else
    {
      if (!enabled.isBoolean()) //All
      {
        if (!installed.isBoolean() || installed.asBoolean())
          CServiceBroker::GetAddonMgr().GetInstalledAddons(typeAddons, *typeIt);
        if (!installed.isBoolean() || (installed.isBoolean() && !installed.asBoolean()))
          CServiceBroker::GetAddonMgr().GetInstallableAddons(typeAddons, *typeIt);
      }
      else if (enabled.asBoolean() && (!installed.isBoolean() || installed.asBoolean())) //Enabled
        CServiceBroker::GetAddonMgr().GetAddons(typeAddons, *typeIt);
      else if (!installed.isBoolean() || installed.asBoolean())
        CServiceBroker::GetAddonMgr().GetDisabledAddons(typeAddons, *typeIt);
    }

    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 = std::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);

//.........这里部分代码省略.........
开发者ID:BigNoid,项目名称:xbmc,代码行数:101,代码来源:AddonsOperations.cpp

示例9: SetSettingValue

JSONRPC_STATUS CSettingsOperations::SetSettingValue(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  std::string settingId = parameterObject["setting"].asString();
  CVariant value = parameterObject["value"];

  SettingPtr setting = CServiceBroker::GetSettings().GetSetting(settingId);
  if (setting == NULL ||
      !setting->IsVisible())
    return InvalidParams;

  switch (setting->GetType())
  {
  case SettingTypeBool:
    if (!value.isBoolean())
      return InvalidParams;

    result = std::static_pointer_cast<CSettingBool>(setting)->SetValue(value.asBoolean());
    break;

  case SettingTypeInteger:
    if (!value.isInteger() && !value.isUnsignedInteger())
      return InvalidParams;

    result = std::static_pointer_cast<CSettingInt>(setting)->SetValue((int)value.asInteger());
    break;

  case SettingTypeNumber:
    if (!value.isDouble())
      return InvalidParams;

    result = std::static_pointer_cast<CSettingNumber>(setting)->SetValue(value.asDouble());
    break;

  case SettingTypeString:
    if (!value.isString())
      return InvalidParams;

    result = std::static_pointer_cast<CSettingString>(setting)->SetValue(value.asString());
    break;

  case SettingTypeList:
  {
    if (!value.isArray())
      return InvalidParams;

    std::vector<CVariant> values;
    for (CVariant::const_iterator_array itValue = value.begin_array(); itValue != value.end_array(); ++itValue)
      values.push_back(*itValue);

    result = CServiceBroker::GetSettings().SetList(settingId, values);
    break;
  }

  case SettingTypeNone:
  case SettingTypeAction:
  default:
    return InvalidParams;
  }

  return OK;
}
开发者ID:micahg,项目名称:xbmc,代码行数:61,代码来源:SettingsOperations.cpp

示例10:

TEST(TestUrlOptions, AddOption)
{
  const char *keyChar = "char";
  const char *keyString = "string";
  const char *keyEmpty = "empty";
  const char *keyInt = "int";
  const char *keyFloat = "float";
  const char *keyDouble = "double";
  const char *keyBool = "bool";

  const char *valueChar = "valueChar";
  const std::string valueString = "valueString";
  const char *valueEmpty = "";
  int valueInt = 1;
  float valueFloat = 1.0f;
  double valueDouble = 1.0;
  bool valueBool = true;

  CVariant variantValue;

  CUrlOptions urlOptions;
  urlOptions.AddOption(keyChar, valueChar);
  {
    CVariant variantValue;
    EXPECT_TRUE(urlOptions.GetOption(keyChar, variantValue));
    EXPECT_TRUE(variantValue.isString());
    EXPECT_STREQ(valueChar, variantValue.asString().c_str());
  }

  urlOptions.AddOption(keyString, valueString);
  {
    CVariant variantValue;
    EXPECT_TRUE(urlOptions.GetOption(keyString, variantValue));
    EXPECT_TRUE(variantValue.isString());
    EXPECT_STREQ(valueString.c_str(), variantValue.asString().c_str());
  }

  urlOptions.AddOption(keyEmpty, valueEmpty);
  {
    CVariant variantValue;
    EXPECT_TRUE(urlOptions.GetOption(keyEmpty, variantValue));
    EXPECT_TRUE(variantValue.isString());
    EXPECT_STREQ(valueEmpty, variantValue.asString().c_str());
  }

  urlOptions.AddOption(keyInt, valueInt);
  {
    CVariant variantValue;
    EXPECT_TRUE(urlOptions.GetOption(keyInt, variantValue));
    EXPECT_TRUE(variantValue.isInteger());
    EXPECT_EQ(valueInt, (int)variantValue.asInteger());
  }

  urlOptions.AddOption(keyFloat, valueFloat);
  {
    CVariant variantValue;
    EXPECT_TRUE(urlOptions.GetOption(keyFloat, variantValue));
    EXPECT_TRUE(variantValue.isDouble());
    EXPECT_EQ(valueFloat, variantValue.asFloat());
  }

  urlOptions.AddOption(keyDouble, valueDouble);
  {
    CVariant variantValue;
    EXPECT_TRUE(urlOptions.GetOption(keyDouble, variantValue));
    EXPECT_TRUE(variantValue.isDouble());
    EXPECT_EQ(valueDouble, variantValue.asDouble());
  }

  urlOptions.AddOption(keyBool, valueBool);
  {
    CVariant variantValue;
    EXPECT_TRUE(urlOptions.GetOption(keyBool, variantValue));
    EXPECT_TRUE(variantValue.isBoolean());
    EXPECT_EQ(valueBool, variantValue.asBoolean());
  }
}
开发者ID:AFFLUENTSOCIETY,项目名称:SPMC,代码行数:77,代码来源:TestUrlOptions.cpp

示例11: Open

JSONRPC_STATUS CPlayerOperations::Open(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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;
//.........这里部分代码省略.........
开发者ID:RalfK,项目名称:spotyxbmc2-pvr,代码行数:101,代码来源:PlayerOperations.cpp


注:本文中的CVariant::isBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。