Ejemplo n.º 1
0
bool CFavouritesDirectory::Save(const CFileItemList &items)
{
  std::string favourites;
  CXBMCTinyXML doc;
  TiXmlElement xmlRootElement("favourites");
  TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
  if (!rootNode) return false;

  for (int i = 0; i < items.Size(); i++)
  {
    const CFileItemPtr item = items[i];
    TiXmlElement favNode("favourite");
    favNode.SetAttribute("name", item->GetLabel().c_str());
    if (item->HasArt("thumb"))
      favNode.SetAttribute("thumb", item->GetArt("thumb").c_str());
    TiXmlText execute(item->GetPath());
    favNode.InsertEndChild(execute);
    rootNode->InsertEndChild(favNode);
  }

  favourites = URIUtils::AddFileToFolder(CProfilesManager::GetInstance().GetProfileUserDataFolder(), "favourites.xml");
  return doc.SaveFile(favourites);
}
Ejemplo n.º 2
0
bool CFavourites::Save(const CFileItemList &items)
{
  CStdString favourites;
  CXBMCTinyXML doc;
  TiXmlElement xmlRootElement("favourites");
  TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
  if (!rootNode) return false;

  for (int i = 0; i < items.Size(); i++)
  {
    const CFileItemPtr item = items[i];
    TiXmlElement favNode("favourite");
    favNode.SetAttribute("name", item->GetLabel().c_str());
    if (item->HasThumbnail())
      favNode.SetAttribute("thumb", item->GetThumbnailImage().c_str());
    TiXmlText execute(item->GetPath());
    favNode.InsertEndChild(execute);
    rootNode->InsertEndChild(favNode);
  }

  URIUtils::AddFileToFolder(g_settings.GetProfileUserDataFolder(), "favourites.xml", favourites);
  return doc.SaveFile(favourites);
}
void CWebBrowserDownloadHandler::ResetHistory()
{
  {
    std::lock_guard<std::mutex> lock(m_mutex);
    m_finishedDownloads.clear();
  }

  TiXmlDocument xmlDoc;
  TiXmlElement xmlRootElement("downloadhistory");
  TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
  if (pRoot == nullptr)
    return;

  TiXmlElement xmlDownloadHistory("histories");
  pRoot->InsertEndChild(xmlDownloadHistory);

  std::string strSettingsFile = kodi::GetBaseUserPath("download_history.xml");
  if (!xmlDoc.SaveFile(strSettingsFile))
  {
    kodi::Log(ADDON_LOG_ERROR, "failed to write download history data");
    return;
  }
}
Ejemplo n.º 4
0
bool CFavouritesService::Persist()
{
  CXBMCTinyXML doc;
  TiXmlElement xmlRootElement("favourites");
  TiXmlNode *rootNode = doc.InsertEndChild(xmlRootElement);
  if (!rootNode)
    return false;

  for (const auto& item : m_favourites)
  {
    TiXmlElement favNode("favourite");
    favNode.SetAttribute("name", item->GetLabel().c_str());
    if (item->HasArt("thumb"))
      favNode.SetAttribute("thumb", item->GetArt("thumb").c_str());

    const CURL url(item->GetPath());
    TiXmlText execute(CURL::Decode(url.GetHostName()));
    favNode.InsertEndChild(execute);
    rootNode->InsertEndChild(favNode);
  }

  auto path = URIUtils::AddFileToFolder(m_userDataFolder, "favourites.xml");
  return doc.SaveFile(path);
}
Ejemplo n.º 5
0
bool CShortcut::Save(const CStdString& strFileName)
{
  // Make shortcut filename fatx compatible
  CStdString strTotalPath(strFileName);
  CUtil::GetFatXQualifiedPath(strTotalPath);

  // Remove old file
  ::DeleteFile(strTotalPath.c_str());

  // Create shortcut document:
  // <shortcut>
  //   <path>F:\App\default.xbe</path>
  // </shortcut>
  TiXmlDocument xmlDoc;
  TiXmlElement xmlRootElement("shortcut");
  TiXmlNode *pRootNode = xmlDoc.InsertEndChild(xmlRootElement);
  if (!pRootNode) return false;

  TiXmlElement newElement("path");
  TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
  if (!pNewNode) return false;

  TiXmlText value(m_strPath);
  pNewNode->InsertEndChild(value);

  if (!m_strThumb.IsEmpty())
  {
    TiXmlElement newElement("thumb");
    TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
    if (!pNewNode) return false;

    TiXmlText thumbValue(m_strThumb);
    pNewNode->InsertEndChild(thumbValue);
  }
  if (!m_strLabel.IsEmpty())
  {
    TiXmlElement newElement("label");
    TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
    if (!pNewNode) return false;

    TiXmlText labelValue(m_strLabel);
    pNewNode->InsertEndChild(labelValue);
  }
  if (!m_strVideo.IsEmpty())
  {
    TiXmlElement newElement("video");
    TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
    if (!pNewNode) return false;

    TiXmlText labelValue(m_strVideo);
    pNewNode->InsertEndChild(labelValue);
  }
  if (!m_strParameters.IsEmpty())
  {
    TiXmlElement newElement("parameters");
    TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement);
    if (!pNewNode) return false;

    TiXmlText labelValue(m_strParameters);
    pNewNode->InsertEndChild(labelValue);
  }
  if (!m_strCustomGame.IsEmpty())
  {
    TiXmlElement customElement("custom");
    TiXmlNode* pCustomNode = pRootNode->InsertEndChild(customElement);
    TiXmlText game(m_strCustomGame);
    TiXmlElement gameElement("game");
    TiXmlNode* pGameNode = pCustomNode->InsertEndChild(gameElement);
    pGameNode->InsertEndChild(game);
  }

  return xmlDoc.SaveFile(strTotalPath);
}
Ejemplo n.º 6
0
  PyObject* Control_SetAnimations(Control* self, PyObject* args)
  {
    PyObject *pList = NULL;
    if (!PyArg_ParseTuple(args, (char*)"O", &pList) || pList == NULL || !PyObject_TypeCheck(pList, &PyList_Type))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type List");
      return NULL;
    }

    TiXmlDocument xmlDoc;
    TiXmlElement xmlRootElement("control");
    TiXmlNode *pRoot = xmlDoc.InsertEndChild(xmlRootElement);
    if (!pRoot)
    {
      PyErr_SetString(PyExc_TypeError, "TiXmlNode creation error");
      return NULL;
    }
    vector<CAnimation> animations;
    for (int anim = 0; anim < PyList_Size(pList); anim++)
    {
      PyObject *pTuple = NULL;
      char *cEvent = NULL;
      char *cAttr = NULL;
      pTuple = PyList_GetItem(pList, anim);
      if (pTuple == NULL || !PyObject_TypeCheck(pTuple, &PyTuple_Type))
      {
        PyErr_SetString(PyExc_TypeError, "List must only contain tuples");
        return NULL;
      }
      if (!PyArg_ParseTuple(pTuple, (char*)"ss", &cEvent, &cAttr))
      {
        PyErr_SetString(PyExc_TypeError, "Error unpacking tuple found in list");
        return NULL;
      }

      if (NULL != cAttr && NULL != cEvent)
      {
        TiXmlElement pNode("animation");
        CStdStringArray attrs;
        StringUtils::SplitString(cAttr, " ", attrs);
        for (unsigned int i = 0; i < attrs.size(); i++)
        {
          CStdStringArray attrs2;
          StringUtils::SplitString(attrs[i], "=", attrs2);
          if (attrs2.size() == 2)
            pNode.SetAttribute(attrs2[0], attrs2[1]);
        }
        TiXmlText value(cEvent);
        pNode.InsertEndChild(value);
        pRoot->InsertEndChild(pNode);
      }
    }

    //bool ret = xmlDoc.SaveFile("special://profile/test.txt");

    const CRect animRect((float)self->dwPosX, (float)self->dwPosY, (float)self->dwPosX + self->dwWidth, (float)self->dwPosY + self->dwHeight);
    PyXBMCGUILock();
    if (self->pGUIControl)
    {
      CGUIControlFactory::GetAnimations(pRoot, animRect, animations);
      self->pGUIControl->SetAnimations(animations);
    }
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }