Exemplo n.º 1
0
bool ContentBrowser::BrowseContent(unsigned startingIndex, unsigned count, Table::iterator position)
{
  DBG(DBG_PROTO, "%s: browse %u from %u\n", __FUNCTION__, count, startingIndex);
  ElementList vars;
  ElementList::const_iterator it;
  if (m_service.Browse(m_root, startingIndex, count, vars) && (it = vars.FindKey("Result")) != vars.end())
  {
    uint32_t updateID = 0;
    if (string_to_uint32(vars.GetValue("UpdateID").c_str(), &updateID) == 0)
      m_lastUpdateID = updateID; // set update ID for this chunk of data
    uint32_t totalcount = 0;
    if (string_to_uint32(vars.GetValue("TotalMatches").c_str(), &totalcount) == 0)
      m_totalCount = totalcount; // reset total count
    uint32_t count = 0;
    string_to_uint32(vars.GetValue("NumberReturned").c_str(), &count);
    DIDLParser didl((*it)->c_str(), count);
    if (didl.IsValid())
    {
      m_table.insert(position, didl.GetItems().begin(), didl.GetItems().end());
      DBG(DBG_PROTO, "%s: count %u\n", __FUNCTION__, didl.GetItems().size());
      return true;
    }
  }
  return false;
}
Exemplo n.º 2
0
DigitalItem::DigitalItem(const std::string& objectID, const std::string& parentID, bool restricted, const ElementList& vars)
    : m_type(Type_unknown)
    , m_subType(SubType_unknown)
    , m_restricted(restricted)
    , m_objectID(objectID)
    , m_parentID(parentID)
    , m_vars(vars)
{
    ElementList::const_iterator it;
    if ((it = vars.FindKey(DIDL_QNAME_UPNP "class")) != vars.end())
    {
        std::vector<std::string> tokens;
        __tokenize((*it)->c_str(), ".", tokens);
        if (tokens.size() >= 2 && tokens[0] == "object")
        {
            if (tokens[1] == TypeTable[Type_container])
                m_type = Type_container;
            else
                m_type = Type_item;
            if (tokens.size() >= 3)
            {
                for (unsigned i = 0; i < SubType_unknown; ++i)
                {
                    if (tokens[2] != SubTypeTable[i])
                        continue;
                    m_subType = (SubType_t)i;
                    break;
                }
            }
        }
    }
}
Exemplo n.º 3
0
bool RenderingControl::GetMute(uint8_t* value, const char* channel)
{
  ElementList args;
  args.push_back(ElementPtr(new Element("InstanceID", "0")));
  args.push_back(ElementPtr(new Element("Channel", channel)));
  ElementList vars = Request("GetMute", args);
  if (!vars.empty() && vars[0]->compare("GetMuteResponse") == 0)
  {
    ElementList::const_iterator it = vars.FindKey("CurrentMute");
    if (it != vars.end())
      return (string_to_uint8((*it)->c_str(), value) == 0);
  }
  return false;
}