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)
}
// check whether we should pop up the progress dialog
- if (!progressBar && XbmcThreads::SystemClockMillis() - startTime > timeBeforeProgressBar)
+ 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 (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 = XbmcThreads::SystemClockMillis();
- }
- if (m_cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)
- { // cancel our script
+ 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
- }
+ 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 !m_cancelled && m_success;
+ return !cancelled && m_success;
}
void CPluginDirectory::SetResolvedUrl(int handle, bool success, const CFileItem *resultItem)
CPluginDirectory *dir = globalHandles[handle];
dir->m_listItems->SetProperty(strProperty, strValue);
}
+
+void CPluginDirectory::CancelDirectory()
+{
+ m_cancelled = true;
+}
+
+float CPluginDirectory::GetProgress() const
+{
+ if (m_totalItems > 0)
+ return (m_listItems->Size() * 100.0f) / m_totalItems;
+ return 0.0f;
+}