void CGUIDialogAddonInfo::OnJobComplete(unsigned int jobID, bool success, CJob* job) { if (!m_changelog) return; CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER); m_jobid = 0; if (!success) { pDlgInfo->SetText(g_localizeStrings.Get(195)); } else { CFile file; XFILE::auto_buffer buf; if (file.LoadFile("special://temp/" + URIUtils::GetFileName(((CFileOperationJob*)job)->GetItems()[0]->GetPath()), buf) > 0) { std::string str(buf.get(), buf.length()); m_item->SetProperty("Addon.Changelog", str); pDlgInfo->SetText(str); } } CGUIMessage msg(GUI_MSG_NOTIFY_ALL, WINDOW_DIALOG_TEXT_VIEWER, 0, GUI_MSG_UPDATE); g_windowManager.SendThreadMessage(msg); }
std::string CSysInfo::GetPrivacyPolicy() { if (m_privacyPolicy.empty()) { CFile file; XFILE::auto_buffer buf; if (file.LoadFile("special://xbmc/privacy-policy.txt", buf) > 0) { std::string strBuf(buf.get(), buf.length()); m_privacyPolicy = strBuf; } else m_privacyPolicy = g_localizeStrings.Get(19055); } return m_privacyPolicy; }
IGfxTexture2D* COGLDevice::LoadTexture( const char* szFilename ) { COGLTexture2D* pTexture = new COGLTexture2D; glGenTextures( 1, (GLuint*)&pTexture->m_nTexture ); // TODO: read in the texture file contents CFile fTextureFile; fTextureFile.LoadFile( szFilename, "rb" ); GLbyte* pTextureBits; // uint nTotalRead = fTextureFile.ReadBytes( pTextureBits, <#uint nNumBytes#>); sint nTexWidth; sint nTexHeight; glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nTexWidth, nTexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTextureBits ); return pTexture; }
void CRssReader::Process() { while (GetQueueSize()) { CSingleLock lock(m_critical); int iFeed = m_vecQueue.front(); m_vecQueue.erase(m_vecQueue.begin()); m_strFeed[iFeed].clear(); m_strColors[iFeed].clear(); CCurlFile http; http.SetUserAgent(g_advancedSettings.m_userAgent); http.SetTimeout(2); std::string strXML; std::string strUrl = m_vecUrls[iFeed]; lock.Leave(); int nRetries = 3; CURL url(strUrl); std::string fileCharset; // we wait for the network to come up if ((url.IsProtocol("http") || url.IsProtocol("https")) && !g_application.getNetwork().IsAvailable()) { CLog::Log(LOGWARNING, "RSS: No network connection"); strXML = "<rss><item><title>"+g_localizeStrings.Get(15301)+"</title></item></rss>"; } else { XbmcThreads::EndTime timeout(15000); while (!m_bStop && nRetries > 0) { if (timeout.IsTimePast()) { CLog::Log(LOGERROR, "Timeout while retrieving rss feed: %s", strUrl.c_str()); break; } nRetries--; if (!url.IsProtocol("http") && !url.IsProtocol("https")) { CFile file; auto_buffer buffer; if (file.LoadFile(strUrl, buffer) > 0) { strXML.assign(buffer.get(), buffer.length()); break; } } else { if (http.Get(strUrl, strXML)) { fileCharset = http.GetServerReportedCharset(); CLog::Log(LOGDEBUG, "Got rss feed: %s", strUrl.c_str()); break; } else if (nRetries > 0) Sleep(5000); // Network problems? Retry, but not immediately. else CLog::Log(LOGERROR, "Unable to obtain rss feed: %s", strUrl.c_str()); } } http.Cancel(); } if (!strXML.empty() && m_pObserver) { // erase any <content:encoded> tags (also unsupported by tinyxml) size_t iStart = strXML.find("<content:encoded>"); size_t iEnd = 0; while (iStart != std::string::npos) { // get <content:encoded> end position iEnd = strXML.find("</content:encoded>", iStart) + 18; // erase the section strXML = strXML.erase(iStart, iEnd - iStart); iStart = strXML.find("<content:encoded>"); } if (Parse(strXML, iFeed, fileCharset)) CLog::Log(LOGDEBUG, "Parsed rss feed: %s", strUrl.c_str()); } } UpdateObserver(); }