本文整理汇总了C++中CGUIDialogProgress::SetLine方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIDialogProgress::SetLine方法的具体用法?C++ CGUIDialogProgress::SetLine怎么用?C++ CGUIDialogProgress::SetLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIDialogProgress
的用法示例。
在下文中一共展示了CGUIDialogProgress::SetLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pItem
//.........这里部分代码省略.........
} else if (!audio && video && !image) {
// video
object_id = "2";
} else if (!audio && !video && image) {
// pictures
object_id = "3";
}
}
#ifdef DISABLE_SPECIALCASE
// same thing but special case for XBMC
if (object_id == "0" && (((*device)->m_ModelName.Find("XBMC", 0, true) >= 0) ||
((*device)->m_ModelName.Find("Xbox Media Center", 0, true) >= 0))) {
// look for a specific type to differentiate which folder we want
if (audio && !video && !image) {
// music
object_id = "virtualpath://upnpmusic";
} else if (!audio && video && !image) {
// video
object_id = "virtualpath://upnpvideo";
} else if (!audio && !video && image) {
// pictures
object_id = "virtualpath://upnppictures";
}
}
#endif
// bring up dialog if object is not cached
if (!upnp->m_MediaBrowser->IsCached(uuid, object_id)) {
dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlgProgress) {
dlgProgress->ShowProgressBar(false);
dlgProgress->SetCanCancel(false);
dlgProgress->SetHeading(20334);
dlgProgress->SetLine(0, 194);
dlgProgress->SetLine(1, "");
dlgProgress->SetLine(2, "");
dlgProgress->StartModal();
}
}
// if error, return now, the device could have gone away
// this will make us go back to the sources list
PLT_MediaObjectListReference list;
NPT_Result res = upnp->m_MediaBrowser->Browse(*device, object_id, list);
if (NPT_FAILED(res)) goto failure;
// empty list is ok
if (list.IsNull()) goto cleanup;
PLT_MediaObjectList::Iterator entry = list->GetFirstItem();
while (entry) {
// disregard items with wrong class/type
if( (!video && (*entry)->m_ObjectClass.type.CompareN("object.item.videoitem", 21,true) == 0)
|| (!audio && (*entry)->m_ObjectClass.type.CompareN("object.item.audioitem", 21,true) == 0)
|| (!image && (*entry)->m_ObjectClass.type.CompareN("object.item.imageitem", 21,true) == 0) )
{
++entry;
continue;
}
// never show empty containers in media views
if((*entry)->IsContainer()) {
if( (audio || video || image)
&& ((PLT_MediaContainer*)(*entry))->m_ChildrenCount == 0) {
++entry;
continue;
示例2: OnPopupMenu
//.........这里部分代码省略.........
choices.Add(2, XFILE::CFavouritesDirectory::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
if (vecCores.size() > 1)
choices.Add(3, 15213); // Play Using...
if (CanRename(list) && !pItem->IsParentFolder())
choices.Add(4, 118); // Rename
if (CanDelete(list) && showEntry)
choices.Add(5, 117); // Delete
if (CanCopy(list) && showEntry)
choices.Add(6, 115); // Copy
if (CanMove(list) && showEntry)
choices.Add(7, 116); // Move
}
if (CanNewFolder(list))
choices.Add(8, 20309); // New Folder
if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder())
choices.Add(9, 13393); // Calculate Size
choices.Add(11, 20128); // Go To Root
choices.Add(12, 523); // switch media
if (CJobManager::GetInstance().IsProcessing("filemanager"))
choices.Add(13, 167);
int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices);
if (btnid == 1)
{
OnSelectAll(list);
bDeselect=false;
}
if (btnid == 2)
{
XFILE::CFavouritesDirectory::AddOrRemove(pItem.get(), GetID());
return;
}
if (btnid == 3)
{
VECPLAYERCORES vecCores;
CPlayerCoreFactory::Get().GetPlayers(*pItem, vecCores);
g_application.m_eForcedNextPlayer = CPlayerCoreFactory::Get().SelectPlayerDialog(vecCores);
if (g_application.m_eForcedNextPlayer != EPC_NONE)
OnStart(pItem.get());
}
if (btnid == 4)
OnRename(list);
if (btnid == 5)
OnDelete(list);
if (btnid == 6)
OnCopy(list);
if (btnid == 7)
OnMove(list);
if (btnid == 8)
OnNewFolder(list);
if (btnid == 9)
{
// setup the progress dialog, and show it
CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (progress)
{
progress->SetHeading(CVariant{13394});
for (int i=0; i < 3; i++)
progress->SetLine(i, CVariant{""});
progress->Open();
}
// Calculate folder size for each selected item
for (int i=0; i<m_vecItems[list]->Size(); ++i)
{
CFileItemPtr pItem2=m_vecItems[list]->Get(i);
if (pItem2->m_bIsFolder && pItem2->IsSelected())
{
int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress);
if (folderSize >= 0)
{
pItem2->m_dwSize = folderSize;
if (folderSize == 0)
pItem2->SetLabel2(StringUtils::SizeToString(folderSize));
else
pItem2->SetFileSizeLabel();
}
}
}
if (progress)
progress->Close();
}
if (btnid == 11)
{
Update(list,"");
return;
}
if (btnid == 12)
{
CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath());
return;
}
if (btnid == 13)
CancelJobs();
if (bDeselect && item >= 0 && item < m_vecItems[list]->Size())
{ // deselect item as we didn't do anything
pItem->Select(false);
}
}
示例3: ResetDatabase
void CPVRManager::ResetDatabase(bool bResetEPGOnly /* = false */)
{
CLog::Log(LOGNOTICE,"PVRManager - %s - clearing the PVR database", __FUNCTION__);
g_EpgContainer.Stop();
CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
pDlgProgress->SetLine(0, StringUtils::EmptyString);
pDlgProgress->SetLine(1, g_localizeStrings.Get(19186)); // All data in the PVR database is being erased
pDlgProgress->SetLine(2, StringUtils::EmptyString);
pDlgProgress->StartModal();
pDlgProgress->Progress();
if (m_addons && m_addons->IsPlaying())
{
CLog::Log(LOGNOTICE,"PVRManager - %s - stopping playback", __FUNCTION__);
CApplicationMessenger::Get().MediaStop();
}
pDlgProgress->SetPercentage(10);
pDlgProgress->Progress();
/* reset the EPG pointers */
m_database->ResetEPG();
/* stop the thread */
Stop();
pDlgProgress->SetPercentage(20);
pDlgProgress->Progress();
if (!m_database)
m_database = new CPVRDatabase;
if (m_database && m_database->Open())
{
/* clean the EPG database */
g_EpgContainer.Reset();
pDlgProgress->SetPercentage(30);
pDlgProgress->Progress();
if (!bResetEPGOnly)
{
m_database->DeleteChannelGroups();
pDlgProgress->SetPercentage(50);
pDlgProgress->Progress();
/* delete all channels */
m_database->DeleteChannels();
pDlgProgress->SetPercentage(70);
pDlgProgress->Progress();
/* delete all channel settings */
m_database->DeleteChannelSettings();
pDlgProgress->SetPercentage(80);
pDlgProgress->Progress();
/* delete all client information */
m_database->DeleteClients();
pDlgProgress->SetPercentage(90);
pDlgProgress->Progress();
}
m_database->Close();
}
CLog::Log(LOGNOTICE,"PVRManager - %s - %s database cleared", __FUNCTION__, bResetEPGOnly ? "EPG" : "PVR and EPG");
if (g_guiSettings.GetBool("pvrmanager.enabled"))
{
CLog::Log(LOGNOTICE,"PVRManager - %s - restarting the PVRManager", __FUNCTION__);
m_database->Open();
Cleanup();
Start();
}
pDlgProgress->SetPercentage(100);
pDlgProgress->Close();
}
示例4: GetSearchResults
bool CWeather::GetSearchResults(const CStdString &strSearch, CStdString &strResult)
{
// Check to see if the user entered a weather.com code
if (strSearch.size() == 8)
{
strResult = "";
int i = 0;
for (i = 0; i < 4; ++i)
{
strResult += toupper(strSearch[i]);
if (!isalpha(strSearch[i]))
break;
}
if (i == 4)
{
for ( ; i < 8; ++i)
{
strResult += strSearch[i];
if (!isdigit(strSearch[i]))
break;
}
if (i == 8)
{
return true; // match
}
}
// no match, wipe string
strResult = "";
}
CGUIDialogSelect *pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
CGUIDialogProgress *pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
//do the download
CStdString strURL;
CStdString strXML;
XFILE::CFileCurl httpUtil;
if (pDlgProgress)
{
pDlgProgress->SetHeading(410); //"Accessing Weather.com"
pDlgProgress->SetLine(0, 194); //"Searching"
pDlgProgress->SetLine(1, strSearch);
pDlgProgress->SetLine(2, "");
pDlgProgress->StartModal();
pDlgProgress->Progress();
}
strURL.Format("http://xoap.weather.com/search/search?where=%s", strSearch);
if (!httpUtil.Get(strURL, strXML))
{
if (pDlgProgress)
pDlgProgress->Close();
return false;
}
//some select dialog init stuff
if (!pDlgSelect)
{
if (pDlgProgress)
pDlgProgress->Close();
return false;
}
pDlgSelect->SetHeading(396); //"Select Location"
pDlgSelect->Reset();
///////////////////////////////
// load the xml file
///////////////////////////////
TiXmlDocument xmlDoc;
xmlDoc.Parse(strXML.c_str());
if (xmlDoc.Error())
return false;
TiXmlElement *pRootElement = xmlDoc.RootElement();
if (pRootElement)
{
CStdString strItemTmp;
TiXmlElement *pElement = pRootElement->FirstChildElement("loc");
while (pElement)
{
if (!pElement->NoChildren())
{
strItemTmp.Format("%s - %s", pElement->Attribute("id"), pElement->FirstChild()->Value());
pDlgSelect->Add(strItemTmp);
}
pElement = pElement->NextSiblingElement("loc");
}
}
if (pDlgProgress)
pDlgProgress->Close();
pDlgSelect->EnableButton(true, 222); //'Cancel' button returns to weather settings
pDlgSelect->DoModal();
if (pDlgSelect->GetSelectedLabel() < 0)
{
//.........这里部分代码省略.........
示例5: ResetDatabase
void CPVRManager::ResetDatabase(bool bResetEPGOnly /* = false */)
{
CLog::Log(LOGNOTICE,"PVRManager - %s - clearing the PVR database", __FUNCTION__);
g_EpgContainer.Stop();
CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
pDlgProgress->SetHeading(CVariant{313});
pDlgProgress->SetLine(0, CVariant{g_localizeStrings.Get(19187)}); // All data in the PVR database is being erased
pDlgProgress->SetLine(1, CVariant{""});
pDlgProgress->SetLine(2, CVariant{""});
pDlgProgress->Open();
pDlgProgress->Progress();
if (m_addons->IsPlaying())
{
CLog::Log(LOGNOTICE,"PVRManager - %s - stopping playback", __FUNCTION__);
CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_STOP);
}
pDlgProgress->SetPercentage(10);
pDlgProgress->Progress();
/* reset the EPG pointers */
if (m_database)
m_database->ResetEPG();
/* stop the thread */
Stop();
pDlgProgress->SetPercentage(20);
pDlgProgress->Progress();
if (!m_database)
m_database = new CPVRDatabase;
if (m_database && m_database->Open())
{
/* clean the EPG database */
g_EpgContainer.Reset();
pDlgProgress->SetPercentage(30);
pDlgProgress->Progress();
if (!bResetEPGOnly)
{
m_database->DeleteChannelGroups();
pDlgProgress->SetPercentage(50);
pDlgProgress->Progress();
/* delete all channels */
m_database->DeleteChannels();
pDlgProgress->SetPercentage(70);
pDlgProgress->Progress();
/* delete all channel and recording settings */
CVideoDatabase videoDatabase;
if (videoDatabase.Open())
{
videoDatabase.EraseVideoSettings("pvr://channels/");
videoDatabase.EraseVideoSettings(CPVRRecordingsPath::PATH_RECORDINGS);
videoDatabase.Close();
}
pDlgProgress->SetPercentage(80);
pDlgProgress->Progress();
/* delete all client information */
pDlgProgress->SetPercentage(90);
pDlgProgress->Progress();
}
m_database->Close();
}
CLog::Log(LOGNOTICE,"PVRManager - %s - %s database cleared", __FUNCTION__, bResetEPGOnly ? "EPG" : "PVR and EPG");
CLog::Log(LOGNOTICE,"PVRManager - %s - restarting the PVRManager", __FUNCTION__);
m_database->Open();
Cleanup();
Start();
pDlgProgress->SetPercentage(100);
pDlgProgress->Close();
}
示例6: ShowWirelessNetworks
void CGUIWindowBoxeeWizardNetwork::ShowWirelessNetworks(CNetworkInterface* interface)
{
// Clear the list first
{
CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_WIRELESS);
OnMessage(msgReset);
}
m_networkItems.clear();
m_aps.clear();
CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
pDlgProgress->SetHeading("");
pDlgProgress->SetLine(0, "Searching for wireless networks...");
pDlgProgress->SetLine(1, "");
pDlgProgress->SetLine(2, "");
pDlgProgress->StartModal();
pDlgProgress->Progress();
// Get the list of access points. Try this 3 times if you get an empty list
int retryCount = 0;
while (m_aps.size() == 0 && retryCount < 3)
{
m_aps = interface->GetAccessPoints();
retryCount++;
}
pDlgProgress->Close();
CStdString currentEssId = interface->GetCurrentWirelessEssId();
int iSelectedItem = -1;
for (unsigned int i = 0; i < m_aps.size(); i++)
{
CFileItemPtr item ( new CFileItem(m_aps[i].getEssId()) );
int q = m_aps[i].getQuality();
if (q <= 25) item->SetIconImage("wizard_wireless_icon_1.png");
else if (q <= 50) item->SetIconImage("wizard_wireless_icon_2.png");
else if (q <= 75) item->SetIconImage("wizard_wireless_icon_3.png");
else if (q <= 100) item->SetIconImage("wizard_wireless_icon_4.png");
if (m_aps[i].getEncryptionMode() != ENC_NONE)
item->SetThumbnailImage("wizard_lock_icon.png");
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_WIRELESS, 0, 0, item);
OnMessage(msg);
m_networkItems.push_back(item);
if (m_aps[i].getEssId() == currentEssId)
iSelectedItem = i;
}
// If the current essid was not found in the scanned list, add it as "Other"
if (iSelectedItem == -1 && currentEssId != "")
{
CFileItemPtr item ( new CFileItem(currentEssId) );
item->SetIconImage("button_keyboard_off.png");
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_WIRELESS, 0, 0, item);
OnMessage(msg);
m_networkItems.push_back(item);
iSelectedItem = m_aps.size();
}
else
{
CFileItemPtr item ( new CFileItem("Other...") );
item->SetIconImage("button_keyboard_off.png");
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_WIRELESS, 0, 0, item);
OnMessage(msg);
m_networkItems.push_back(item);
if (iSelectedItem == -1)
iSelectedItem = 0;
}
{
CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), CONTROL_WIRELESS, iSelectedItem);
OnMessage(msg);
}
CONTROL_DISABLE(CONTROL_NEXT);
}
示例7: Open
bool CFileShoutcast::Open(const CURL& url, bool bBinary)
{
m_dwLastTime = timeGetTime();
int ret;
CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
set_rip_manager_options_defaults(&m_opt);
strcpy(m_opt.output_directory, "./");
m_opt.proxyurl[0] = '\0';
// Use a proxy, if the GUI was configured as such
bool bProxyEnabled = g_guiSettings.GetBool("network.usehttpproxy");
if (bProxyEnabled)
{
const CStdString &strProxyServer = g_guiSettings.GetString("network.httpproxyserver");
const CStdString &strProxyPort = g_guiSettings.GetString("network.httpproxyport");
// Should we check for valid strings here
#ifndef _LINUX
_snprintf( m_opt.proxyurl, MAX_URL_LEN, "http://%s:%s", strProxyServer.c_str(), strProxyPort.c_str() );
#else
snprintf( m_opt.proxyurl, MAX_URL_LEN, "http://%s:%s", strProxyServer.c_str(), strProxyPort.c_str() );
#endif
}
CStdString strUrl;
url.GetURL(strUrl);
strUrl.Replace("shout://", "http://");
printf("Opening url: %s\n", strUrl.c_str());
strncpy(m_opt.url, strUrl.c_str(), MAX_URL_LEN);
sprintf(m_opt.useragent, "x%s", url.GetFileName().c_str());
if (dlgProgress)
{
dlgProgress->SetHeading(260);
dlgProgress->SetLine(0, 259);
dlgProgress->SetLine(1, strUrl);
dlgProgress->SetLine(2, "");
if (!dlgProgress->IsDialogRunning())
dlgProgress->StartModal();
dlgProgress->Progress();
}
if ((ret = rip_manager_start(rip_callback, &m_opt)) != SR_SUCCESS)
{
if (dlgProgress) dlgProgress->Close();
return false;
}
int iShoutcastTimeout = 10 * SHOUTCASTTIMEOUT; //i.e: 10 * 10 = 100 * 100ms = 10s
int iCount = 0;
while (!m_fileState.bRipDone && !m_fileState.bRipStarted && !m_fileState.bRipError && (!dlgProgress || !dlgProgress->IsCanceled()))
{
if (iCount <= iShoutcastTimeout) //Normally, this isn't the problem,
//because if RIP_MANAGER fails, this would be here
//with m_fileState.bRipError
{
Sleep(100);
}
else
{
if (dlgProgress)
{
dlgProgress->SetLine(1, 257);
dlgProgress->SetLine(2, "Connection timed out...");
Sleep(1500);
dlgProgress->Close();
}
return false;
}
iCount++;
}
if (dlgProgress && dlgProgress->IsCanceled())
{
Close();
dlgProgress->Close();
return false;
}
/* store content type of stream */
m_contenttype = rip_manager_get_content_type();
//CHANGED CODE: Don't reset timer anymore.
while (!m_fileState.bRipDone && !m_fileState.bRipError && m_fileState.bBuffering && (!dlgProgress || !dlgProgress->IsCanceled()))
{
if (iCount <= iShoutcastTimeout) //Here is the real problem: Sometimes the buffer fills just to
//slowly, thus the quality of the stream will be bad, and should be
//aborted...
{
Sleep(100);
char szTmp[1024];
//g_dialog.SetCaption(0, "Shoutcast" );
sprintf(szTmp, "Buffering %i bytes", m_ringbuf.GetMaxReadSize());
if (dlgProgress)
{
dlgProgress->SetLine(2, szTmp );
dlgProgress->Progress();
}
//.........这里部分代码省略.........
示例8: DoWork
bool CCDDARipJob::DoWork()
{
CLog::Log(LOGINFO, "Start ripping track %s to %s", m_input.c_str(),
m_output.c_str());
// if we are ripping to a samba share, rip it to hd first and then copy it it the share
CFileItem file(m_output, false);
if (file.IsRemote())
m_output = SetupTempFile();
if (m_output.IsEmpty())
{
CLog::Log(LOGERROR, "CCDDARipper: Error opening file");
return false;
}
// init ripper
CFile reader;
CEncoder* encoder;
if (!reader.Open(m_input,READ_CACHED) || !(encoder=SetupEncoder(reader)))
{
CLog::Log(LOGERROR, "Error: CCDDARipper::Init failed");
return false;
}
// setup the progress dialog
CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
CStdString strLine0, strLine1;
int iTrack = atoi(m_input.substr(13, m_input.size() - 13 - 5).c_str());
strLine0.Format("%s %i", g_localizeStrings.Get(606).c_str(), iTrack); // Track Number: %i
strLine1.Format("%s %s", g_localizeStrings.Get(607).c_str(), m_output.c_str()); // To: %s
pDlgProgress->SetHeading(605); // Ripping
pDlgProgress->SetLine(0, strLine0);
pDlgProgress->SetLine(1, strLine1);
pDlgProgress->SetLine(2, "");
pDlgProgress->StartModal();
pDlgProgress->ShowProgressBar(true);
// show progress dialog
pDlgProgress->Progress();
// start ripping
int percent=0;
int oldpercent=0;
bool cancelled(false);
int result;
while (!cancelled && (result=RipChunk(reader, encoder, percent)) == 0)
{
cancelled = ShouldCancel(percent,100);
cancelled |= pDlgProgress->IsCanceled();
if (percent > oldpercent)
{
oldpercent = percent;
pDlgProgress->SetPercentage(percent);
pDlgProgress->Progress();
}
}
pDlgProgress->Close();
// close encoder ripper
encoder->Close();
delete encoder;
reader.Close();
if (file.IsRemote() && !cancelled && result == 2)
{
// copy the ripped track to the share
if (!CFile::Cache(m_output, file.GetPath()))
{
CLog::Log(LOGERROR, "CDDARipper: Error copying file from %s to %s",
m_output.c_str(), file.GetPath().c_str());
CFile::Delete(m_output);
return false;
}
// delete cached file
CFile::Delete(m_output);
}
if (cancelled)
{
CLog::Log(LOGWARNING, "User Cancelled CDDA Rip");
CFile::Delete(m_output);
}
else if (result == 1)
CLog::Log(LOGERROR, "CDDARipper: Error ripping %s", m_input.c_str());
else if (result < 0)
CLog::Log(LOGERROR, "CDDARipper: Error encoding %s", m_input.c_str());
else
{
CLog::Log(LOGINFO, "Finished ripping %s", m_input.c_str());
if (m_eject)
{
CLog::Log(LOGINFO, "Ejecting CD");
g_mediaManager.EjectTray();
}
}
return !cancelled && result == 2;
}
示例9: WaitOnScriptResult
bool CPluginDirectory::WaitOnScriptResult(const std::string &scriptPath, int scriptId, const std::string &scriptName, bool retrievingDir)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
unsigned int startTime = XbmcThreads::SystemClockMillis();
CGUIDialogProgress *progressBar = NULL;
bool cancelled = false;
bool inMainAppThread = g_application.IsCurrentThread();
CLog::Log(LOGDEBUG, "%s - waiting on the %s (id=%d) plugin...", __FUNCTION__, scriptName.c_str(), scriptId);
while (true)
{
{
CSingleExit ex(g_graphicsContext);
// check if the python script is finished
if (m_fetchComplete.WaitMSec(20))
{ // python has returned
CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure");
break;
}
}
// check our script is still running
if (!CScriptInvocationManager::Get().IsRunning(scriptId))
{ // check whether we exited normally
if (!m_fetchComplete.WaitMSec(0))
{ // python didn't return correctly
CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__);
m_success = false;
}
break;
}
// check whether we should pop up the progress dialog
if (!retrievingDir && !progressBar && XbmcThreads::SystemClockMillis() - startTime > timeBeforeProgressBar)
{ // loading takes more then 1.5 secs, show a progress dialog
progressBar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
// if script has shown progressbar don't override it
if (progressBar && progressBar->IsActive())
{
startTime = XbmcThreads::SystemClockMillis();
progressBar = NULL;
}
if (progressBar)
{
progressBar->SetHeading(CVariant{scriptName});
progressBar->SetLine(0, CVariant{10214});
progressBar->SetLine(1, CVariant{""});
progressBar->SetLine(2, CVariant{""});
progressBar->ShowProgressBar(false);
progressBar->Open();
}
}
if (progressBar)
{ // update the progress bar and check for user cancel
progressBar->Progress();
if (progressBar->IsCanceled())
{ // user has cancelled our process - cancel our process
m_cancelled = true;
}
}
else // if the progressBar exists and we call StartModal or Progress we get the
// ProcessRenderLoop call anyway.
if (inMainAppThread)
g_windowManager.ProcessRenderLoop();
if (!cancelled && m_cancelled)
{
cancelled = true;
startTime = XbmcThreads::SystemClockMillis();
}
if ((cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript) || g_application.m_bStop)
{ // cancel our script
if (scriptId != -1 && CScriptInvocationManager::Get().IsRunning(scriptId))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s (id=%d)", __FUNCTION__, scriptName.c_str(), scriptId);
CScriptInvocationManager::Get().Stop(scriptId);
break;
}
}
}
if (progressBar)
CApplicationMessenger::Get().PostMsg(TMSG_GUI_WINDOW_CLOSE, -1, 0, static_cast<void*>(progressBar));
return !cancelled && m_success;
}
示例10: WaitOnScriptResult
bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CStdString &scriptName, bool retrievingDir)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
unsigned int startTime = CTimeUtils::GetTimeMS();
CGUIDialogProgress *progressBar = NULL;
CLog::Log(LOGDEBUG, "%s - waiting on the %s plugin...", __FUNCTION__, scriptName.c_str());
while (true)
{
CSingleExit ex(g_graphicsContext);
// check if the python script is finished
if (WaitForSingleObject(m_fetchComplete, 20) == WAIT_OBJECT_0)
{ // python has returned
CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure");
break;
}
ex.Restore();
// check our script is still running
#ifdef HAS_PYTHON
if (!g_pythonParser.isRunning(g_pythonParser.getScriptId(scriptPath.c_str())))
#endif
{ // check whether we exited normally
if (WaitForSingleObject(m_fetchComplete, 0) == WAIT_TIMEOUT)
{ // python didn't return correctly
CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__);
m_success = false;
}
break;
}
// check whether we should pop up the progress dialog
if (!progressBar && CTimeUtils::GetTimeMS() - startTime > timeBeforeProgressBar)
{ // loading takes more then 1.5 secs, show a progress dialog
progressBar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
// if script has shown progressbar don't override it
if (progressBar && progressBar->IsActive())
{
startTime = CTimeUtils::GetTimeMS();
progressBar = NULL;
}
if (progressBar)
{
progressBar->SetHeading(scriptName);
progressBar->SetLine(0, retrievingDir ? 1040 : 10214);
progressBar->SetLine(1, "");
progressBar->SetLine(2, "");
progressBar->ShowProgressBar(retrievingDir);
progressBar->StartModal();
}
}
if (progressBar)
{ // update the progress bar and check for user cancel
if (retrievingDir)
{
CStdString label;
if (m_totalItems > 0)
{
label.Format(g_localizeStrings.Get(1042).c_str(), m_listItems->Size(), m_totalItems);
progressBar->SetPercentage((int)((m_listItems->Size() * 100 ) / m_totalItems));
progressBar->ShowProgressBar(true);
}
else
label.Format(g_localizeStrings.Get(1041).c_str(), m_listItems->Size());
progressBar->SetLine(2, label);
}
progressBar->Progress();
if (progressBar->IsCanceled())
{ // user has cancelled our process - cancel our process
if (!m_cancelled)
{
m_cancelled = true;
startTime = CTimeUtils::GetTimeMS();
}
if (m_cancelled && CTimeUtils::GetTimeMS() - startTime > timeToKillScript)
{ // cancel our script
#ifdef HAS_PYTHON
int id = g_pythonParser.getScriptId(scriptPath.c_str());
if (id != -1 && g_pythonParser.isRunning(id))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s", __FUNCTION__, scriptName.c_str());
g_pythonParser.stopScript(id);
break;
}
#endif
}
}
}
}
if (progressBar)
g_application.getApplicationMessenger().Close(progressBar, false, false);
return !m_cancelled && m_success;
}
示例11: OnPopupMenu
//.........这里部分代码省略.........
if (!pItem->IsParentFolder())
choices.Add(CONTROL_BTNFAVOURITES, CServiceBroker::GetFavouritesService().IsFavourited(*pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
if (players.size() > 1)
choices.Add(CONTROL_BTNPLAYWITH, 15213);
if (CanRename(list) && !pItem->IsParentFolder())
choices.Add(CONTROL_BTNRENAME, 118);
if (CanDelete(list) && showEntry)
choices.Add(CONTROL_BTNDELETE, 117);
if (CanCopy(list) && showEntry)
choices.Add(CONTROL_BTNCOPY, 115);
if (CanMove(list) && showEntry)
choices.Add(CONTROL_BTNMOVE, 116);
}
if (CanNewFolder(list))
choices.Add(CONTROL_BTNNEWFOLDER, 20309);
if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder())
choices.Add(CONTROL_BTNCALCSIZE, 13393);
choices.Add(CONTROL_BTNSWITCHMEDIA, 523);
if (CJobManager::GetInstance().IsProcessing("filemanager"))
choices.Add(CONTROL_BTNCANCELJOB, 167);
if (!pItem->m_bIsFolder)
choices.Add(CONTROL_BTNVIEW, 39104);
int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices);
if (btnid == CONTROL_BTNSELECTALL)
{
OnSelectAll(list);
bDeselect=false;
}
if (btnid == CONTROL_BTNFAVOURITES)
{
CServiceBroker::GetFavouritesService().AddOrRemove(*pItem.get(), GetID());
return;
}
if (btnid == CONTROL_BTNPLAYWITH)
{
std::vector<std::string>players;
CPlayerCoreFactory::GetInstance().GetPlayers(*pItem, players);
std::string player = CPlayerCoreFactory::GetInstance().SelectPlayerDialog(players);
if (!player.empty())
OnStart(pItem.get(), player);
}
if (btnid == CONTROL_BTNRENAME)
OnRename(list);
if (btnid == CONTROL_BTNDELETE)
OnDelete(list);
if (btnid == CONTROL_BTNCOPY)
OnCopy(list);
if (btnid == CONTROL_BTNMOVE)
OnMove(list);
if (btnid == CONTROL_BTNNEWFOLDER)
OnNewFolder(list);
if (btnid == CONTROL_BTNCALCSIZE)
{
// setup the progress dialog, and show it
CGUIDialogProgress *progress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
if (progress)
{
progress->SetHeading(CVariant{13394});
for (int i=0; i < 3; i++)
progress->SetLine(i, CVariant{""});
progress->Open();
}
// Calculate folder size for each selected item
for (int i=0; i<m_vecItems[list]->Size(); ++i)
{
CFileItemPtr pItem2=m_vecItems[list]->Get(i);
if (pItem2->m_bIsFolder && pItem2->IsSelected())
{
int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress);
if (folderSize >= 0)
{
pItem2->m_dwSize = folderSize;
if (folderSize == 0)
pItem2->SetLabel2(StringUtils::SizeToString(folderSize));
else
pItem2->SetFileSizeLabel();
}
}
}
if (progress)
progress->Close();
}
if (btnid == CONTROL_BTNSWITCHMEDIA)
{
CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath());
return;
}
if (btnid == CONTROL_BTNCANCELJOB)
CancelJobs();
if (btnid == CONTROL_BTNVIEW)
CGUIDialogTextViewer::ShowForFile(pItem->GetPath(), true);
if (bDeselect && item >= 0 && item < m_vecItems[list]->Size())
{ // deselect item as we didn't do anything
pItem->Select(false);
}
}
示例12: GetDirectory
bool CShoutcastDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CStdString strRoot = strPath;
if (CUtil::HasSlashAtEnd(strRoot) && strRoot != "shout://")
strRoot.Delete(strRoot.size() - 1);
/* keep backward competability (for users who already have this source defined) */
if( strRoot.Equals("shout://www.shoutcast.com") || strRoot.Equals("shout://") || strRoot.Equals("shout://classic.shoutcast.com") ||
strRoot.Equals("shout://www.shoutcast.com/sbin/newxml.phtml") )
strRoot = SHOUTCAST_MASTER_LINK;
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 )
result = ParseStations(root, items, url);
else
{
//.........这里部分代码省略.........
示例13: GetDirectory
bool CMultiPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", strPath.c_str());
vector<CStdString> vecPaths;
if (!GetPaths(strPath, vecPaths))
return false;
XbmcThreads::EndTime progressTime(3000); // 3 seconds before showing progress bar
CGUIDialogProgress* dlgProgress = NULL;
unsigned int iFailures = 0;
for (unsigned int i = 0; i < vecPaths.size(); ++i)
{
// show the progress dialog if we have passed our time limit
if (progressTime.IsTimePast() && !dlgProgress)
{
dlgProgress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlgProgress)
{
dlgProgress->SetHeading(15310);
dlgProgress->SetLine(0, 15311);
dlgProgress->SetLine(1, "");
dlgProgress->SetLine(2, "");
dlgProgress->StartModal();
dlgProgress->ShowProgressBar(true);
dlgProgress->SetProgressMax((int)vecPaths.size()*2);
dlgProgress->Progress();
}
}
if (dlgProgress)
{
CURL url(vecPaths[i]);
dlgProgress->SetLine(1, url.GetWithoutUserDetails());
dlgProgress->SetProgressAdvance();
dlgProgress->Progress();
}
CFileItemList tempItems;
CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str());
if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_flags))
items.Append(tempItems);
else
{
CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str());
iFailures++;
}
if (dlgProgress)
{
dlgProgress->SetProgressAdvance();
dlgProgress->Progress();
}
}
if (dlgProgress)
dlgProgress->Close();
if (iFailures == vecPaths.size())
return false;
// merge like-named folders into a sub multipath:// style url
MergeItems(items);
return true;
}
示例14: WaitOnScriptResult
bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CStdString &scriptName, bool retrievingDir)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
unsigned int startTime = XbmcThreads::SystemClockMillis();
CGUIDialogProgress *progressBar = NULL;
bool cancelled = false;
CLog::Log(LOGDEBUG, "%s - waiting on the %s plugin...", __FUNCTION__, scriptName.c_str());
while (true)
{
{
CSingleExit ex(g_graphicsContext);
// check if the python script is finished
if (m_fetchComplete.WaitMSec(20))
{ // python has returned
CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure");
break;
}
}
// check our script is still running
#ifdef HAS_PYTHON
if (!g_pythonParser.isRunning(g_pythonParser.getScriptId(scriptPath.c_str())))
#endif
{ // check whether we exited normally
if (!m_fetchComplete.WaitMSec(0))
{ // python didn't return correctly
CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__);
m_success = false;
}
break;
}
// check whether we should pop up the progress dialog
if (!retrievingDir && !progressBar && XbmcThreads::SystemClockMillis() - startTime > timeBeforeProgressBar)
{ // loading takes more then 1.5 secs, show a progress dialog
progressBar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
// if script has shown progressbar don't override it
if (progressBar && progressBar->IsActive())
{
startTime = XbmcThreads::SystemClockMillis();
progressBar = NULL;
}
if (progressBar)
{
progressBar->SetHeading(scriptName);
progressBar->SetLine(0, retrievingDir ? 1040 : 10214);
progressBar->SetLine(1, "");
progressBar->SetLine(2, "");
progressBar->ShowProgressBar(retrievingDir);
progressBar->StartModal();
}
}
if (progressBar)
{ // update the progress bar and check for user cancel
progressBar->Progress();
if (progressBar->IsCanceled())
{ // user has cancelled our process - cancel our process
m_cancelled = true;
}
}
if (!cancelled && m_cancelled)
{
cancelled = true;
startTime = XbmcThreads::SystemClockMillis();
}
if (cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)
{ // cancel our script
#ifdef HAS_PYTHON
int id = g_pythonParser.getScriptId(scriptPath.c_str());
if (id != -1 && g_pythonParser.isRunning(id))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s", __FUNCTION__, scriptName.c_str());
g_pythonParser.stopScript(id);
break;
}
#endif
}
}
if (progressBar)
CApplicationMessenger::Get().Close(progressBar, false, false);
return !cancelled && m_success;
}
示例15: WaitOnScriptResult
bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CStdString &scriptName)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
DWORD startTime = timeGetTime();
CGUIDialogProgress *progressBar = NULL;
CLog::Log(LOGDEBUG, "%s - waiting on the %s plugin...", __FUNCTION__, scriptName.c_str());
while (true)
{
// check if the python script is finished
if (WaitForSingleObject(m_directoryFetched, 20) == WAIT_OBJECT_0)
{ // python has returned
CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure");
break;
}
// check our script is still running
int id = g_pythonParser.getScriptId(scriptPath.c_str());
if (id == -1)
{ // nope - bail
CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__);
m_success = false;
break;
}
// check whether we should pop up the progress dialog
if (!progressBar && timeGetTime() - startTime > timeBeforeProgressBar)
{ // loading takes more then 1.5 secs, show a progress dialog
progressBar = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (progressBar)
{
progressBar->SetHeading(scriptName);
progressBar->SetLine(0, 1040);
progressBar->SetLine(1, "");
progressBar->SetLine(2, "");
progressBar->StartModal();
}
}
if (progressBar)
{ // update the progress bar and check for user cancel
CStdString label;
if (m_totalItems > 0)
{
label.Format(g_localizeStrings.Get(1042).c_str(), m_listItems->Size(), m_totalItems);
progressBar->SetPercentage((int)((m_listItems->Size() * 100 ) / m_totalItems));
progressBar->ShowProgressBar(true);
}
else
label.Format(g_localizeStrings.Get(1041).c_str(), m_listItems->Size());
progressBar->SetLine(2, label);
progressBar->Progress();
if (progressBar->IsCanceled())
{ // user has cancelled our process - cancel our process
if (!m_cancelled)
{
m_cancelled = true;
startTime = timeGetTime();
}
if (m_cancelled && timeGetTime() - startTime > timeToKillScript)
{ // cancel our script
int id = g_pythonParser.getScriptId(scriptPath.c_str());
if (id != -1 && g_pythonParser.isRunning(id))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s", __FUNCTION__, scriptName.c_str());
g_pythonParser.stopScript(id);
break;
}
}
}
}
}
if (progressBar)
progressBar->Close();
return !m_cancelled && m_success;
}