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


C++ CFileCurl类代码示例

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


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

示例1: DownloadThumbnail

bool CGUIDialogSongInfo::DownloadThumbnail(const CStdString &thumbFile)
{
  // TODO: Obtain the source...
  CStdString source;
  CFileCurl http;
  http.Download(source, thumbFile);
  return true;
}
开发者ID:Bobbin007,项目名称:xbmc,代码行数:8,代码来源:GUIDialogSongInfo.cpp

示例2: url

bool CDVDInputStreamFile::Open(const char* strFile, const std::string& content)
{
    CStdString stdFile = strFile;

    CURI url(stdFile);
    if (!CDVDInputStream::Open(strFile, content)) return false;

    m_pFile = new CFile();
    if (!m_pFile) return false;

    unsigned int flags = READ_TRUNCATED;

    if( CFileItem(stdFile, false).IsInternetStream() )
        flags |= READ_CACHED;

    bool bOpen = false;

    // This is a workaround for HTML5 video content. we need to pass a user agent string from
    // the file item into the resulting file, but can only do this if we open ourselves
    if( m_item.m_strPath.Left(7).Equals("http://") ||
            m_item.m_strPath.Left(8).Equals("https://"))
    {
        CStdString extraInfo = m_item.GetExtraInfo();
        if( extraInfo && extraInfo.Left(11).Equals("User-Agent:") )
        {
            CFileCurl* curl = new CFileCurl();
            curl->SetUserAgent(extraInfo);
            if( !curl->Open(stdFile) )
            {
                delete m_pFile;
                m_pFile = NULL;
                return false;
            }

            // success - atttach to m_pfile
            m_pFile->Attach( curl, flags );
            curl = NULL;
            bOpen = true;
        }
    }


    // open file in binary mode
    if( !bOpen && !m_pFile->Open(stdFile, flags))
    {
        delete m_pFile;
        m_pFile = NULL;
        return false;
    }

    if (m_pFile->GetImplemenation() && (content.empty() || content == "application/octet-stream"))
        m_content = m_pFile->GetImplemenation()->GetContent();

    m_eof = true;
    return true;
}
开发者ID:marksuman,项目名称:boxee,代码行数:56,代码来源:DVDInputStreamFile.cpp

示例3: RadioHandShake

bool CLastFmManager::RadioHandShake()
{
  if (!m_RadioSession.IsEmpty()) return true; //already signed in

  if (dlgProgress)
  {
    dlgProgress->SetLine(2, 15251);//Connecting to Last.fm..
    dlgProgress->Progress();
  }

  m_RadioSession = "";

  CFileCurl http;
  CStdString html;

  CStdString strPassword = g_guiSettings.GetString("scrobbler.lastfmpass");
  CStdString strUserName = g_guiSettings.GetString("scrobbler.lastfmusername");
  if (strUserName.IsEmpty() || strPassword.IsEmpty())
  {
    CLog::Log(LOGERROR, "Last.fm stream selected but no username or password set.");
    return false;
  }

  CStdString passwordmd5(strPassword);
  passwordmd5.ToLower();

  CStdString url;
  CURL::Encode(strUserName);
  url.Format("http://ws.audioscrobbler.com/radio/handshake.php?version=%s&platform=%s&username=%s&passwordmd5=%s&debug=%i&partner=%s", XBMC_LASTFM_VERSION, XBMC_LASTFM_ID, strUserName, passwordmd5, 0, "");
  if (!http.Get(url, html))
  {
    CLog::Log(LOGERROR, "Connect to Last.fm radio failed.");
    return false;
  }
  //CLog::Log(LOGDEBUG, "Handshake: %s", html.c_str());

  Parameter("session",    html, m_RadioSession);
  Parameter("base_url",   html, m_RadioBaseUrl);
  Parameter("base_path",  html, m_RadioBasePath);
  Parameter("subscriber", html, m_RadioSubscriber);
  Parameter("banned",     html, m_RadioBanned);

  if (m_RadioSession.CompareNoCase("failed") == 0)
  {
    CLog::Log(LOGERROR, "Last.fm return failed response, possible bad username or password?");
    m_RadioSession = "";
  }
  return !m_RadioSession.IsEmpty();
}
开发者ID:Openivo,项目名称:xbmc,代码行数:49,代码来源:LastFmManager.cpp

示例4: lock

void CLastFmManager::CacheTrackThumb(const int nrInitialTracksToAdd)
{
  unsigned int start = CTimeUtils::GetTimeMS();
  CSingleLock lock(m_lockCache);
  int iNrCachedTracks = m_RadioTrackQueue->size();
  CFileCurl http;
  for (int i = 0; i < nrInitialTracksToAdd && i < iNrCachedTracks; i++)
  {
    CFileItemPtr item = (*m_RadioTrackQueue)[i];
    if (!item->GetMusicInfoTag()->Loaded())
    {
      //cache albumthumb, GetThumbnailImage contains the url to cache
      if (item->HasThumbnail())
      {
        CStdString coverUrl = item->GetThumbnailImage();
        CStdString crcFile;
        CStdString cachedFile;
        CStdString thumbFile;

        Crc32 crc;
        crc.ComputeFromLowerCase(coverUrl);
        crcFile.Format("%08x.tbn", (__int32)crc);
        URIUtils::AddFileToFolder(g_advancedSettings.m_cachePath, crcFile, cachedFile);
        URIUtils::AddFileToFolder(g_settings.GetLastFMThumbFolder(), crcFile, thumbFile);
        item->SetThumbnailImage("");
        try
        {
          //download to temp, then make a thumb
          if (CFile::Exists(thumbFile) || (http.Download(coverUrl, cachedFile) && CPicture::CreateThumbnail(cachedFile, thumbFile)))
          {
            if (CFile::Exists(cachedFile))
              CFile::Delete(cachedFile);
            item->SetThumbnailImage(thumbFile);
          }
        }
        catch(...)
        {
          CLog::Log(LOGERROR, "LastFmManager: exception while caching %s to %s.", coverUrl.c_str(), thumbFile.c_str());
        }
      }
      if (!item->HasThumbnail())
      {
        item->SetThumbnailImage("DefaultAlbumCover.png");
      }
      item->GetMusicInfoTag()->SetLoaded();
    }
  }
  CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(CTimeUtils::GetTimeMS() - start));
}
开发者ID:Openivo,项目名称:xbmc,代码行数:49,代码来源:LastFmManager.cpp

示例5: GetHttpHeader

/* STATIC FUNCTIONS */
bool CFileCurl::GetHttpHeader(const CURI &url, CHttpHeader &headers)
{
  try
  {
    CFileCurl file;
    if(file.Stat(url, NULL) == 0)
    {
      headers = file.GetHttpHeader();
      return true;
    }
    return false;
  }
  catch(...)
  {
    CStdString path;
    path = url.Get();
    CLog::Log(LOGERROR, "%s - Exception thrown while trying to retrieve header url: %s", __FUNCTION__, path.c_str());
    return false;
  }
}
开发者ID:Kr0nZ,项目名称:boxee,代码行数:21,代码来源:FileCurl.cpp

示例6: open

bool MythXml::open(CStdString hostname, int port, CStdString user, CStdString pass, int pin, long timeout) {
    hostname_ = hostname;
    port_ = port;
    timeout_ = timeout;
    pin_ = pin;
    CStdString strUrl;
    strUrl.Format("http://%s:%i/Myth/GetConnectionInfo?Pin=%i", hostname.c_str(), port, pin);
    CStdString strXML;

    CFileCurl http;

    http.SetTimeout(timeout);
    if(!http.Get(strUrl, strXML)) {
        CLog::Log(LOGDEBUG, "MythXml - Could not open connection to mythtv backend.");
        http.Cancel();
        return false;
    }
    http.Cancel();
    return true;
}
开发者ID:mbolhuis,项目名称:xbmc-antiquated,代码行数:20,代码来源:MythXml.cpp

示例7: GetMimeType

bool CFileCurl::GetMimeType(const CURL &url, CStdString &content, CStdString useragent)
{
  CFileCurl file;
  if (!useragent.IsEmpty())
    file.SetUserAgent(useragent);

  struct __stat64 buffer;
  if( file.Stat(url, &buffer) == 0 )
  {
    if (buffer.st_mode == _S_IFDIR)
      content = "x-directory/normal";
    else
      content = file.GetMimeType();
    CLog::Log(LOGDEBUG, "CFileCurl::GetMimeType - %s -> %s", url.Get().c_str(), content.c_str());
    return true;
  }
  CLog::Log(LOGDEBUG, "CFileCurl::GetMimeType - %s -> failed", url.Get().c_str());
  content = "";
  return false;
}
开发者ID:nonspin,项目名称:spotyxbmc2,代码行数:20,代码来源:FileCurl.cpp

示例8: GetContent

bool CFileCurl::GetContent(const CURI &url, CStdString &content, CStdString useragent)
{
   CFileCurl file;
   if (!useragent.IsEmpty())
     file.SetUserAgent(useragent);

   if( file.Stat(url, NULL) == 0 )
   {
     content = file.GetContent();
     return true;
   }
   
   if (file.GetLastRetCode() > 400 )
   {
	 content = "text/html";
   }
   else
   {
   content = "";
   }

   return false;
}
开发者ID:Kr0nZ,项目名称:boxee,代码行数:23,代码来源:FileCurl.cpp

示例9: url

bool CPluginSettings::SaveToPlexMediaServer(const CStdString& path)
{
  // Build up URL parameters with id and value.
  TiXmlElement* root = m_userXmlDoc.RootElement();
  string params = "?";
  
  for (TiXmlElement* setting = root->FirstChildElement("setting"); setting; setting = setting->NextSiblingElement("setting"))
  {
    const char* id = setting->Attribute("id");
    const char* value = setting->Attribute("value");
    
    if (id)
    {
      CStdString strName = id;
      CStdString strValue = value;
      
      CUtil::URLEncode(strName);
      CUtil::URLEncode(strValue);
      params += strName + "=" + strValue + "&";
    }
  }

  // Compute the new path.
  string strPath = path;
  strPath += "set" + params.substr(0, params.size()-1);
  
  // Send the parameters back to the Plex Media Server.
  CURL url(strPath);
  CStdString protocol = url.GetProtocol();
  url.SetProtocol("http");
  url.SetPort(32400);  

  // Make the request.
  CFileCurl http;
  return http.Open(url, false);
}
开发者ID:aaronjb,项目名称:plex,代码行数:36,代码来源:PluginSettings.cpp

示例10: url

bool CShoutcastDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{

  CStdString strRoot = strPath;
  if (CUtil::HasSlashAtEnd(strRoot))
    strRoot.Delete(strRoot.size() - 1);

  /* for old users wich doesn't have the full url */
  if( strRoot.Equals("shout://www.shoutcast.com") )
    strRoot = "shout://www.shoutcast.com/sbin/newxml.phtml";

  if (g_directoryCache.GetDirectory(strRoot, items))
    return true;

  CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  if (dlgProgress)
  {
    dlgProgress->ShowProgressBar(false);
    dlgProgress->SetHeading(260);
    dlgProgress->SetLine(0, 14003);
    dlgProgress->SetLine(1, "");
    dlgProgress->SetLine(2, "");
    dlgProgress->StartModal();
  }

  CURL url(strRoot);
  CStdString protocol = url.GetProtocol();
  url.SetProtocol("http");

  CFileCurl http;

  //CURL doesn't seem to understand that data is encoded.. odd
  // opening as text for now
  //http.SetContentEncoding("deflate");

  if( !http.Open(url, false) ) 
  {
    CLog::Log(LOGERROR, "%s - Unable to get shoutcast dir", __FUNCTION__);
    if (dlgProgress) dlgProgress->Close();
    return false;
  }

  /* restore protocol */
  url.SetProtocol(protocol);

  CStdString content = http.GetContent();
  if( !(content.Equals("text/html") || content.Equals("text/xml") 
	  || content.Equals("text/html;charset=utf-8") || content.Equals("text/xml;charset=utf-8") ))
  {
    CLog::Log(LOGERROR, "%s - Invalid content type %s", __FUNCTION__, content.c_str());
    if (dlgProgress) dlgProgress->Close();
    return false;
  }
  
  
  int size_read = 0;  
  int size_total = (int)http.GetLength();
  int data_size = 0;

  CStdString data;
  data.reserve(size_total);
  
  /* read response from server into string buffer */
  char buffer[16384];
  while( (size_read = http.Read(buffer, sizeof(buffer)-1)) > 0 )
  {
    buffer[size_read] = 0;
    data += buffer;
    data_size += size_read;

    dlgProgress->Progress();

    if (dlgProgress->IsCanceled())
    {
      dlgProgress->Close();
      return false;
    }
  }

  /* parse returned xml */
  TiXmlDocument doc;
  doc.Parse(data.c_str());

  TiXmlElement *root = doc.RootElement();
  if(root == NULL)
  {
    CLog::Log(LOGERROR, "%s - Unable to parse xml", __FUNCTION__);
    CLog::Log(LOGDEBUG, "%s - Sample follows...\n%s", __FUNCTION__, data.c_str());

    dlgProgress->Close();
    return false;
  }

  /* clear data to keep memusage down, not needed anymore */
  data.Empty();

  bool result = false;
  if( strcmp(root->Value(), "genrelist") == 0 )
    result = ParseGenres(root, items, url);
  else if( strcmp(root->Value(), "stationlist") == 0 )
//.........这里部分代码省略.........
开发者ID:Avoidnf8,项目名称:xbmc-fork,代码行数:101,代码来源:ShoutcastDirectory.cpp

示例11: time


//.........这里部分代码省略.........
  }
  if (title.IsEmpty())
  {
    CLog::Log(LOGERROR, "Last.fm CallXmlRpc no tracktitle provided.");
    return false;
  }

  char ti[20];
  time_t rawtime;
  time ( &rawtime );
  struct tm *now = gmtime(&rawtime);
  strftime(ti, sizeof(ti), "%Y-%m-%d %H:%M:%S", now);
  CStdString strChallenge = ti;

  CStdString strAuth(strPassword);
  strAuth.ToLower();
  strAuth.append(strChallenge);
  CreateMD5Hash(strAuth, strAuth);

  //create request xml
  TiXmlDocument doc;
  TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "UTF-8", "" );
  doc.LinkEndChild( decl );

  TiXmlElement * elMethodCall = new TiXmlElement( "methodCall" );
  doc.LinkEndChild( elMethodCall );

  TiXmlElement * elMethodName = new TiXmlElement( "methodName" );
  elMethodCall->LinkEndChild( elMethodName );
  TiXmlText * txtAction = new TiXmlText( action );
  elMethodName->LinkEndChild( txtAction );

  TiXmlElement * elParams = new TiXmlElement( "params" );
  elMethodCall->LinkEndChild( elParams );

  TiXmlElement * elParam = new TiXmlElement( "param" );
  elParams->LinkEndChild( elParam );
  TiXmlElement * elValue = new TiXmlElement( "value" );
  elParam->LinkEndChild( elValue );
  TiXmlElement * elString = new TiXmlElement( "string" );
  elValue->LinkEndChild( elString );
  TiXmlText * txtParam = new TiXmlText( strUserName );
  elString->LinkEndChild( txtParam );

  elParam = new TiXmlElement( "param" );
  elParams->LinkEndChild( elParam );
  elValue = new TiXmlElement( "value" );
  elParam->LinkEndChild( elValue );
  elString = new TiXmlElement( "string" );
  elValue->LinkEndChild( elString );
  txtParam = new TiXmlText( strChallenge );
  elString->LinkEndChild( txtParam );

  elParam = new TiXmlElement( "param" );
  elParams->LinkEndChild( elParam );
  elValue = new TiXmlElement( "value" );
  elParam->LinkEndChild( elValue );
  elString = new TiXmlElement( "string" );
  elValue->LinkEndChild( elString );
  txtParam = new TiXmlText( strAuth );
  elString->LinkEndChild( txtParam );

  elParam = new TiXmlElement( "param" );
  elParams->LinkEndChild( elParam );
  elValue = new TiXmlElement( "value" );
  elParam->LinkEndChild( elValue );
  elString = new TiXmlElement( "string" );
  elValue->LinkEndChild( elString );
  txtParam = new TiXmlText( artist );
  elString->LinkEndChild( txtParam );

  elParam = new TiXmlElement( "param" );
  elParams->LinkEndChild( elParam );
  elValue = new TiXmlElement( "value" );
  elParam->LinkEndChild( elValue );
  elString = new TiXmlElement( "string" );
  elValue->LinkEndChild( elString );
  txtParam = new TiXmlText( title );
  elString->LinkEndChild( txtParam );

  CStdString strBody;
  strBody << doc;

  CFileCurl http;
  CStdString html;
  CStdString url = "http://ws.audioscrobbler.com/1.0/rw/xmlrpc.php";
  http.SetMimeType("text/xml");
  if (!http.Post(url, strBody, html))
  {
    CLog::Log(LOGERROR, "Last.fm action %s failed.", action.c_str());
    return false;
  }

  if (html.Find("fault") >= 0)
  {
    CLog::Log(LOGERROR, "Last.fm return failed response: %s", html.c_str());
    return false;
  }
  return true;
}
开发者ID:Openivo,项目名称:xbmc,代码行数:101,代码来源:LastFmManager.cpp

示例12: Exists

bool CDAVDirectory::Exists(const char* strPath)
{
  CFileCurl dav;
  CURL url(strPath);
  return dav.Exists(url);
}
开发者ID:mbolhuis,项目名称:xbmc,代码行数:6,代码来源:DAVDirectory.cpp

示例13: RequestRadioTracks

bool CLastFmManager::RequestRadioTracks()
{
  unsigned int start = CTimeUtils::GetTimeMS();
  CStdString url;
  CStdString html;
  url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/xspf.php?sk=%s&discovery=0&desktop=", m_RadioSession);
  {
    CFileCurl http;
    if (!http.Get(url, html))
    {
      m_RadioSession.empty();
      CLog::Log(LOGERROR, "LastFmManager: Connect to Last.fm to request tracks failed.");
      return false;
    }
  }
  //CLog::Log(LOGDEBUG, "RequestRadioTracks: %s", html.c_str());

  //parse playlist
  TiXmlDocument xmlDoc;

  xmlDoc.Parse(html);
  if (xmlDoc.Error())
  {
    m_RadioSession.empty();
    CLog::Log(LOGERROR, "LastFmManager: Unable to parse tracklist Error: %s", xmlDoc.ErrorDesc());
    return false;
  }

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement )
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received");
    m_RadioSession.empty();
    return false;
  }

  TiXmlElement* pBodyElement = pRootElement->FirstChildElement("trackList");
  if (!pBodyElement )
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, no tracklist");
    m_RadioSession.empty();
    return false;
  }

  TiXmlElement* pTrackElement = pBodyElement->FirstChildElement("track");

  if (!pTrackElement)
  {
    CLog::Log(LOGWARNING, "LastFmManager: No more tracks received, empty tracklist");
    m_RadioSession.empty();
    return false;
  }
  while (pTrackElement)
  {
    CFileItemPtr newItem(new CFileItem);

    TiXmlElement* pElement = pTrackElement->FirstChildElement("location");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        CStdString url = child->Value();
        url.Replace("http:", "lastfm:");
        newItem->m_strPath = url;
      }
    }
    pElement = pTrackElement->FirstChildElement("title");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->SetLabel(child->Value());
        newItem->GetMusicInfoTag()->SetTitle(child->Value());
      }
    }
    pElement = pTrackElement->FirstChildElement("creator");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->GetMusicInfoTag()->SetArtist(child->Value());
      }
    }
    pElement = pTrackElement->FirstChildElement("album");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
      if (child)
      {
        newItem->GetMusicInfoTag()->SetAlbum(child->Value());
      }
    }

    pElement = pTrackElement->FirstChildElement("duration");
    if (pElement)
    {
      TiXmlNode* child = pElement->FirstChild();
//.........这里部分代码省略.........
开发者ID:Openivo,项目名称:xbmc,代码行数:101,代码来源:LastFmManager.cpp

示例14: InitProgressDialog

bool CLastFmManager::ChangeStation(const CURL& stationUrl)
{
  unsigned int start = CTimeUtils::GetTimeMS();

  InitProgressDialog(stationUrl.Get());

  StopRadio(false);
  if (!RadioHandShake())
  {
    CloseProgressDialog();
    CGUIDialogOK::ShowAndGetInput(15200, 15206, 0, 0);
    return false;
  }

  UpdateProgressDialog(15252); // Selecting station...

  CFileCurl http;
  CStdString url;
  CStdString html;

  url.Format("http://" + m_RadioBaseUrl + m_RadioBasePath + "/adjust.php?session=%s&url=%s&debug=%i", m_RadioSession, stationUrl.Get().c_str(), 0);
  if (!http.Get(url, html))
  {
    CLog::Log(LOGERROR, "Connect to Last.fm to change station failed.");
    CloseProgressDialog();
    return false;
  }
  //CLog::Log(LOGDEBUG, "ChangeStation: %s", html.c_str());

  CStdString strErrorCode;
  Parameter("error", html,  strErrorCode);
  if (strErrorCode != "")
  {
    CLog::Log(LOGERROR, "Last.fm returned an error (%s) response for change station request.", strErrorCode.c_str());
    CloseProgressDialog();
    return false;
  }

  UpdateProgressDialog(261); //Waiting for start....

  g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC);
  RequestRadioTracks();
  CacheTrackThumb(XBMC_LASTFM_MINTRACKS);
  AddToPlaylist(XBMC_LASTFM_MINTRACKS);
  Create(); //start thread
  m_hWorkerEvent.Set(); //kickstart the thread

  CSingleLock lock(m_lockPlaylist);
  CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
  if ((int)playlist.size())
  {
    g_application.m_strPlayListFile = stationUrl.Get(); //needed to highlight the playing item
    g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_MUSIC);
    g_playlistPlayer.Play(0);
    CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(CTimeUtils::GetTimeMS() - start));
    CloseProgressDialog();
    return true;
  }
  CloseProgressDialog();
  return false;
}
开发者ID:Openivo,项目名称:xbmc,代码行数:61,代码来源:LastFmManager.cpp

示例15: Exists

bool CRSSDirectory::Exists(const char* strPath)
{
  CFileCurl rss;
  CURL url(strPath);
  return rss.Exists(url);
}
开发者ID:tmacreturns,项目名称:XBMC_wireless_setup,代码行数:6,代码来源:RSSDirectory.cpp


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