bool CFileUtils::DeleteItem(const CFileItemPtr &item, bool force) { if (!item || item->IsParentFolder()) return false; CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!force && pDialog) { pDialog->SetHeading(122); pDialog->SetLine(0, 125); pDialog->SetLine(1, URIUtils::GetFileName(item->m_strPath)); pDialog->SetLine(2, ""); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return false; } // Create a temporary item list containing the file/folder for deletion CFileItemPtr pItemTemp(new CFileItem(*item)); pItemTemp->Select(true); CFileItemList items; items.Add(pItemTemp); // grab the real filemanager window, set up the progress bar, // and process the delete action CFileOperationJob op(CFileOperationJob::ActionDelete, items, ""); return op.DoWork(); }
bool CGUIWindowPVRChannels::OnContextButtonUpdateEpg(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn = false; if (button == CONTEXT_BUTTON_UPDATE_EPG) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; CPVRChannelPtr channel(item->GetPVRChannelInfoTag()); pDialog->SetHeading(19251); pDialog->SetLine(0, g_localizeStrings.Get(19252)); pDialog->SetLine(1, channel->ChannelName()); pDialog->SetLine(2, ""); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return bReturn; bReturn = UpdateEpgForChannel(item); std::string strMessage = StringUtils::Format("%s: '%s'", g_localizeStrings.Get(bReturn ? 19253 : 19254).c_str(), channel->ChannelName().c_str()); CGUIDialogKaiToast::QueueNotification(bReturn ? CGUIDialogKaiToast::Info : CGUIDialogKaiToast::Error, g_localizeStrings.Get(19166), strMessage); } return bReturn; }
bool CGUIWindowPVRCommon::StartRecordFile(CFileItem *item) { if (!item->HasEPGInfoTag()) return false; CEpgInfoTag *tag = item->GetEPGInfoTag(); if (!tag || !tag->ChannelTag() || tag->ChannelTag()->ChannelNumber() <= 0) return false; CPVRTimerInfoTag *timer = g_PVRTimers->GetMatch(item); if (timer) { CGUIDialogOK::ShowAndGetInput(19033,19034,0,0); return false; } CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(264); pDialog->SetLine(0, tag->ChannelTag()->ChannelName()); pDialog->SetLine(1, ""); pDialog->SetLine(2, tag->Title()); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return false; CPVRTimerInfoTag *newtimer = CPVRTimerInfoTag::CreateFromEpg(*tag); CFileItem *newTimerItem = new CFileItem(*newtimer); return g_PVRTimers->AddTimer(*newTimerItem); }
bool CGUIDialogPVRGroupManager::ActionButtonDeleteGroup(CGUIMessage &message) { bool bReturn = false; unsigned int iControl = message.GetSenderId(); if (iControl == BUTTON_DELGROUP) { if (!m_selectedGroup) return bReturn; CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(117); pDialog->SetLine(0, ""); pDialog->SetLine(1, m_selectedGroup->GroupName()); pDialog->SetLine(2, ""); pDialog->DoModal(); if (pDialog->IsConfirmed()) { if (((CPVRChannelGroups *) g_PVRChannelGroups->Get(m_bIsRadio))->DeleteGroup(*m_selectedGroup)) Update(); } bReturn = true; } return bReturn; }
bool CGUIDialogPVRGuideInfo::ActionCancelTimer(CFileItemPtr timer) { bool bReturn = false; if (!timer || !timer->HasPVRTimerInfoTag()) { return bReturn; } // prompt user for confirmation of timer deletion CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (pDialog) { pDialog->SetHeading(265); pDialog->SetLine(0, ""); pDialog->SetLine(1, timer->GetPVRTimerInfoTag()->m_strTitle); pDialog->SetLine(2, ""); pDialog->DoModal(); if (pDialog->IsConfirmed()) { Close(); bReturn = CPVRTimers::DeleteTimer(*timer); } } return bReturn; }
bool CGUIWindowPVRCommon::ActionDeleteRecording(CFileItem *item) { bool bReturn = false; /* check if the recording tag is valid */ CPVRRecording *recTag = (CPVRRecording *) item->GetPVRRecordingInfoTag(); if (!recTag || recTag->m_strRecordingId.IsEmpty()) return bReturn; /* show a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(122); pDialog->SetLine(0, 19043); pDialog->SetLine(1, ""); pDialog->SetLine(2, recTag->m_strTitle); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return bReturn; /* delete the recording */ if (g_PVRRecordings->DeleteRecording(*item)) { g_PVRManager.TriggerRecordingsUpdate(); bReturn = true; } return bReturn; }
bool CGUIWindowPVRChannels::OnContextButtonHide(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn = false; if (button == CONTEXT_BUTTON_HIDE) { CPVRChannel *channel = item->GetPVRChannelInfoTag(); if (!channel || channel->IsRadio() != m_bRadio) return bReturn; CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(19039); pDialog->SetLine(0, ""); pDialog->SetLine(1, channel->ChannelName()); pDialog->SetLine(2, ""); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return bReturn; g_PVRManager.GetPlayingGroup(m_bRadio)->RemoveFromGroup(*channel); UpdateData(); bReturn = true; } return bReturn; }
bool CGUIWindowPVRBase::ActionDeleteRecording(CFileItem *item) { bool bReturn = false; /* check if the recording tag is valid */ CPVRRecording *recTag = (CPVRRecording *) item->GetPVRRecordingInfoTag(); if (!recTag || recTag->m_strRecordingId.empty()) return bReturn; /* show a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(122); // Confirm delete pDialog->SetLine(0, item->m_bIsFolder ? 19113 : 19112); // Are you sure? pDialog->SetLine(1, ""); pDialog->SetLine(2, item->GetLabel()); pDialog->SetChoice(1, 117); // Delete /* prompt for the user's confirmation */ pDialog->DoModal(); if (!pDialog->IsConfirmed()) return bReturn; /* delete the recording */ if (g_PVRRecordings->Delete(*item)) { g_PVRManager.TriggerRecordingsUpdate(); bReturn = true; } return bReturn; }
bool CGUIDialogPVRChannelManager::OnClickButtonDeleteChannel(CGUIMessage &message) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (!pItem) return false; CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return true; pDialog->SetHeading(19211); pDialog->SetLine(0, ""); pDialog->SetLine(1, 750); pDialog->SetLine(2, ""); pDialog->DoModal(); if (pDialog->IsConfirmed()) { if (pItem->GetProperty("Virtual").asBoolean()) { pItem->GetPVRChannelInfoTag()->SetVirtual(true); m_channelItems->Remove(m_iSelected); m_viewControl.SetItems(*m_channelItems); Renumber(); return true; } CGUIDialogOK::ShowAndGetInput(19033,19038,0,0); } return true; }
bool CGUIDialogPVRChannelManager::OnClickButtonRadioTV(CGUIMessage &message) { if (m_bContainsChanges) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return true; pDialog->SetHeading(20052); pDialog->SetLine(0, ""); pDialog->SetLine(1, 19212); pDialog->SetLine(2, 20103); pDialog->DoModal(); if (pDialog->IsConfirmed()) SaveList(); } m_iSelected = 0; m_bMovingMode = false; m_bContainsChanges = false; m_bIsRadio = !m_bIsRadio; SetProperty("IsRadio", m_bIsRadio ? "true" : ""); Update(); SetData(m_iSelected); return true; }
bool CGUIWindowPVRCommon::ActionDeleteRecording(CFileItem *item) { bool bReturn = false; /* check if the recording tag is valid */ CPVRRecordingInfoTag *recTag = (CPVRRecordingInfoTag *) item->GetPVRRecordingInfoTag(); if (!recTag || recTag->ClientIndex() < 0) return bReturn; /* show a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(122); pDialog->SetLine(0, 19043); pDialog->SetLine(1, ""); pDialog->SetLine(2, recTag->Title()); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return bReturn; /* delete the recording */ if (CPVRRecordings::DeleteRecording(*item)) { CPVRManager::GetRecordings()->Update(true); UpdateData(); bReturn = true; } return bReturn; }
bool CGUIWindowPVRCommon::ActionDeleteTimer(CFileItem *item) { bool bReturn = false; /* check if the timer tag is valid */ CPVRTimerInfoTag *timerTag = item->GetPVRTimerInfoTag(); if (!timerTag || timerTag->ClientIndex() < 0) return bReturn; /* show a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(122); pDialog->SetLine(0, 19040); pDialog->SetLine(1, ""); pDialog->SetLine(2, timerTag->Title()); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return bReturn; /* delete the timer */ if (CPVRManager::GetTimers()->DeleteTimer(*item)) { UpdateData(); bReturn = true; } return bReturn; }
bool CGUIWindowPVRCommon::ActionDeleteChannel(CFileItem *item) { CPVRChannel *channel = item->GetPVRChannelInfoTag(); /* check if the channel tag is valid */ if (!channel || channel->ChannelNumber() <= 0) return false; /* show a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*) g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(19039); pDialog->SetLine(0, ""); pDialog->SetLine(1, channel->ChannelName()); pDialog->SetLine(2, ""); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return false; g_PVRChannelGroups->GetGroupAll(channel->IsRadio())->RemoveFromGroup(*channel); UpdateData(); return true; }
bool CGUIWindowPVRRecordings::OnContextButtonDelete(CFileItem *item, CONTEXT_BUTTON button) { bool bReturn = false; if (button == CONTEXT_BUTTON_DELETE) { bReturn = false; CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(122); pDialog->SetLine(0, 19043); pDialog->SetLine(1, ""); pDialog->SetLine(2, item->GetPVRRecordingInfoTag()->m_strTitle); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return bReturn; bReturn = g_PVRRecordings->DeleteRecording(*item); } return bReturn; }
bool CPVRChannels::HideChannel(CPVRChannel *channel, bool bShowDialog /* = true */) { if (!channel) return false; /* check if there are active timers on this channel if we are hiding it */ if (!channel->IsHidden() && PVRTimers.ChannelHasTimers(*channel)) { if (bShowDialog) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(19098); pDialog->SetLine(0, 19099); pDialog->SetLine(1, ""); pDialog->SetLine(2, 19100); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return false; } /* delete the timers */ PVRTimers.DeleteTimersOnChannel(*channel, true); } /* check if this channel is currently playing if we are hiding it */ if (!channel->IsHidden() && (g_PVRManager.IsPlayingTV() || g_PVRManager.IsPlayingRadio()) && (g_PVRManager.GetCurrentPlayingItem()->GetPVRChannelInfoTag() == channel)) { CGUIDialogOK::ShowAndGetInput(19098,19101,0,19102); return false; } /* switch the hidden flag */ channel->SetHidden(!channel->IsHidden()); /* update the hidden channel counter */ if (channel->IsHidden()) ++m_iHiddenChannels; else --m_iHiddenChannels; /* update the database entry */ channel->Persist(); /* move the channel to the end of the list */ MoveChannel(channel->ChannelNumber(), size()); return true; }
void CAutorun::ExecuteXBE(const CStdString &xbeFile) { #ifdef HAS_XBOX_HARDWARE int iRegion; if (g_guiSettings.GetBool("myprograms.gameautoregion")) { CXBE xbe; iRegion = xbe.ExtractGameRegion(xbeFile); if (iRegion < 1 || iRegion > 7) iRegion = 0; iRegion = xbe.FilterRegion(iRegion); } else iRegion = 0; #ifdef HAS_TRAINER CProgramDatabase database; database.Open(); DWORD dwTitleId = CUtil::GetXbeID(xbeFile); CStdString strTrainer = database.GetActiveTrainer(dwTitleId); if (strTrainer != "") { bool bContinue=false; if (CKaiClient::GetInstance()->IsEngineConnected()) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)m_gWindowManager.GetWindow(WINDOW_DIALOG_YES_NO); pDialog->SetHeading(714); pDialog->SetLine(0,"Use trainer or KAI?"); pDialog->SetLine(1, "Yes for trainer"); pDialog->SetLine(2, "No for KAI"); pDialog->DoModal(); if (pDialog->IsConfirmed()) { while (CKaiClient::GetInstance()->GetCurrentVector().size() > 1) CKaiClient::GetInstance()->ExitVector(); } else bContinue = true; } if (!bContinue) { CTrainer trainer; if (trainer.Load(strTrainer)) { database.GetTrainerOptions(strTrainer,dwTitleId,trainer.GetOptions(),trainer.GetNumberOfOptions()); CUtil::InstallTrainer(trainer); } } } database.Close(); #endif CUtil::RunXBE(xbeFile.c_str(), NULL,F_VIDEO(iRegion)); #endif }
bool CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { /* Check file item is in list range and get his pointer */ if (itemNumber < 0 || itemNumber >= (int)m_channelItems->Size()) return false; CFileItemPtr pItem = m_channelItems->Get(itemNumber); if (!pItem) return false; if (button == CONTEXT_BUTTON_MOVE) { m_bMovingMode = true; pItem->Select(true); } else if (button == CONTEXT_BUTTON_SETTINGS) { if (!g_PVRClients->OpenDialogChannelSettings(pItem->GetPVRChannelInfoTag())) CGUIDialogOK::ShowAndGetInput(2103, 0, 16029, 0); // Add-on error;Check the log file for details. } else if (button == CONTEXT_BUTTON_DELETE) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return true; pDialog->SetHeading(19211); // Delete channel pDialog->SetText(750); // Are you sure? pDialog->DoModal(); if (pDialog->IsConfirmed()) { CPVRChannelPtr channel = pItem->GetPVRChannelInfoTag(); if (g_PVRClients->DeleteChannel(channel)) { g_PVRChannelGroups->GetGroupAll(channel->IsRadio())->RemoveFromGroup(channel); m_channelItems->Remove(m_iSelected); m_viewControl.SetItems(*m_channelItems); Renumber(); } else CGUIDialogOK::ShowAndGetInput(2103, 0, 16029, 0); // Add-on error;Check the log file for details. } } else if (button == CONTEXT_BUTTON_EDIT_SOURCE) { std::string strURL = pItem->GetProperty("StreamURL").asString(); if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false)) pItem->SetProperty("StreamURL", strURL); } return true; }
bool CGUIWindowSettingsScreenCalibration::OnAction(const CAction &action) { switch (action.wID) { case ACTION_PREVIOUS_MENU: { m_gWindowManager.PreviousWindow(); return true; } break; case ACTION_CALIBRATE_SWAP_ARROWS: { NextControl(); return true; } break; case ACTION_CALIBRATE_RESET: { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)m_gWindowManager.GetWindow(WINDOW_DIALOG_YES_NO); pDialog->SetHeading(20325); CStdString strText; strText.Format(g_localizeStrings.Get(20326).c_str(), g_settings.m_ResInfo[m_Res[m_iCurRes]].strMode); pDialog->SetLine(0, strText); pDialog->SetLine(1, 20327); pDialog->SetChoice(0, 222); pDialog->SetChoice(1, 186); pDialog->DoModal(); if (pDialog->IsConfirmed()) { g_graphicsContext.ResetScreenParameters(m_Res[m_iCurRes]); ResetControls(); } return true; } break; case ACTION_CHANGE_RESOLUTION: // choose the next resolution in our list { m_iCurRes = (m_iCurRes+1) % m_Res.size(); g_graphicsContext.SetVideoResolution(m_Res[m_iCurRes], TRUE); ResetControls(); return true; } break; } return CGUIWindow::OnAction(action); // base class to handle basic movement etc. }
bool CGUIWindowPVRBase::ActionRecord(CFileItem *item) { bool bReturn = false; CEpgInfoTagPtr epgTag(item->GetEPGInfoTag()); if (!epgTag) return bReturn; CPVRChannelPtr channel = epgTag->ChannelTag(); if (!channel || !g_PVRManager.CheckParentalLock(*channel)) return bReturn; if (epgTag->Timer() == NULL) { /* create a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*) g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(264); pDialog->SetLine(0, ""); pDialog->SetLine(1, epgTag->Title()); pDialog->SetLine(2, ""); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return bReturn; CPVRTimerInfoTag *newTimer = CPVRTimerInfoTag::CreateFromEpg(*epgTag); if (newTimer) { bReturn = g_PVRTimers->AddTimer(*newTimer); delete newTimer; } else { bReturn = false; } } else { CGUIDialogOK::ShowAndGetInput(19033,19034,0,0); bReturn = true; } return bReturn; }
bool CProfilesManager::DeleteProfile(size_t index) { CSingleLock lock(m_critical); const CProfile *profile = GetProfile(index); if (profile == NULL) return false; CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (dlgYesNo == NULL) return false; string message; string str = g_localizeStrings.Get(13201); message = StringUtils::Format(str.c_str(), profile->getName().c_str()); dlgYesNo->SetHeading(13200); dlgYesNo->SetLine(0, message); dlgYesNo->SetLine(1, ""); dlgYesNo->SetLine(2, ""); dlgYesNo->DoModal(); if (!dlgYesNo->IsConfirmed()) return false; // fall back to master profile if necessary if ((int)index == m_autoLoginProfile) m_autoLoginProfile = 0; // delete profile string strDirectory = profile->getDirectory(); m_profiles.erase(m_profiles.begin() + index); // fall back to master profile if necessary if (index == m_currentProfile) { LoadProfile(0); CSettings::Get().Save(); } CFileItemPtr item = CFileItemPtr(new CFileItem(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory))); item->SetPath(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory + "/")); item->m_bIsFolder = true; item->Select(true); CFileUtils::DeleteItem(item); return Save(); }
bool CGUIWindowPVRCommon::ActionRecord(CFileItem *item) { bool bReturn = false; CPVREpgInfoTag *epgTag = (CPVREpgInfoTag *) item->GetEPGInfoTag(); if (!epgTag) return bReturn; const CPVRChannel *channel = epgTag->ChannelTag(); if (!channel || channel->ChannelNumber() > 0) return bReturn; if (epgTag->Timer() == NULL) { /* create a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*) g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(264); pDialog->SetLine(0, ""); pDialog->SetLine(1, epgTag->Title()); pDialog->SetLine(2, ""); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return bReturn; CPVRTimerInfoTag *newtimer = CPVRTimerInfoTag::CreateFromEpg(*epgTag); CFileItem *item = new CFileItem(*newtimer); if (CPVRManager::GetTimers()->AddTimer(*item)) CPVRManager::GetTimers()->Update(); bReturn = true; } else { CGUIDialogOK::ShowAndGetInput(19033,19034,0,0); bReturn = true; } return bReturn; }
bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant text, bool &bCanceled, CVariant noLabel /* = "" */, CVariant yesLabel /* = "" */, unsigned int autoCloseTime /* = 0 */) { CGUIDialogYesNo *dialog = (CGUIDialogYesNo *)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!dialog) return false; dialog->SetHeading(heading); dialog->SetText(text); if (autoCloseTime) dialog->SetAutoClose(autoCloseTime); dialog->m_bCanceled = false; dialog->SetChoice(0, !noLabel.empty() ? noLabel : 106); dialog->SetChoice(1, !yesLabel.empty() ? yesLabel : 107); dialog->DoModal(); bCanceled = dialog->m_bCanceled; return (dialog->IsConfirmed()) ? true : false; }
bool CGUIDialogYesNo::ShowAndGetInput(const std::string& heading, const std::string& text, bool& bCanceled, const std::string& noLabel, const std::string& yesLabel) { CGUIDialogYesNo *dialog = (CGUIDialogYesNo *)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!dialog) return false; dialog->SetHeading(heading); dialog->SetText(text); dialog->m_bCanceled = false; if (!noLabel.empty()) dialog->SetChoice(0,noLabel); else dialog->SetChoice(0,106); if (!yesLabel.empty()) dialog->SetChoice(1,yesLabel); else dialog->SetChoice(1,107); dialog->DoModal(); bCanceled = dialog->m_bCanceled; return (dialog->IsConfirmed()) ? true : false; }
bool CSettings::DeleteProfile(unsigned int index) { const CProfile *profile = GetProfile(index); if (!profile) return false; CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (dlgYesNo) { CStdString message; CStdString str = g_localizeStrings.Get(13201); message.Format(str.c_str(), profile->getName()); dlgYesNo->SetHeading(13200); dlgYesNo->SetLine(0, message); dlgYesNo->SetLine(1, ""); dlgYesNo->SetLine(2, ""); dlgYesNo->DoModal(); if (dlgYesNo->IsConfirmed()) { //delete profile CStdString strDirectory = profile->getDirectory(); m_vecProfiles.erase(m_vecProfiles.begin()+index); if (index == m_currentProfile) { LoadProfile(0); Save(); } CFileItemPtr item = CFileItemPtr(new CFileItem(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory))); item->SetPath(URIUtils::AddFileToFolder(GetUserDataFolder(), strDirectory + "/")); item->m_bIsFolder = true; item->Select(true); CFileUtils::DeleteItem(item); } else return false; } SaveProfiles( PROFILES_FILE ); return true; }
bool CGUIWindowPVRBase::StartRecordFile(const CFileItem &item) { if (!item.HasEPGInfoTag()) return false; const CEpgInfoTag *tag = item.GetEPGInfoTag(); CPVRChannelPtr channel; if (tag) channel = tag->ChannelTag(); if (!channel || !g_PVRManager.CheckParentalLock(*channel)) return false; CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(&item); if (timer && timer->HasPVRTimerInfoTag()) { CGUIDialogOK::ShowAndGetInput(19033,19034,0,0); return false; } // ask for confirmation before starting a timer CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(264); pDialog->SetLine(0, tag->PVRChannelName()); pDialog->SetLine(1, ""); pDialog->SetLine(2, tag->Title()); pDialog->DoModal(); if (!pDialog->IsConfirmed()) return false; CPVRTimerInfoTag *newTimer = CPVRTimerInfoTag::CreateFromEpg(*tag); bool bReturn(false); if (newTimer) { bReturn = g_PVRTimers->AddTimer(*newTimer); delete newTimer; } return bReturn; }
bool CGUIDialogPVRGuideInfo::ActionStartTimer(const CEpgInfoTag *tag) { bool bReturn = false; if (!tag) return false; CPVRChannelPtr channel = tag->ChannelTag(); if (!channel || !g_PVRManager.CheckParentalLock(*channel)) return false; // prompt user for confirmation of channel record CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (pDialog) { pDialog->SetHeading(264); pDialog->SetLine(0, ""); pDialog->SetLine(1, tag->Title()); pDialog->SetLine(2, ""); pDialog->DoModal(); if (pDialog->IsConfirmed()) { Close(); CPVRTimerInfoTag *newTimer = CPVRTimerInfoTag::CreateFromEpg(*tag); if (newTimer) { bReturn = CPVRTimers::AddTimer(*newTimer); delete newTimer; } else { bReturn = false; } } } return bReturn; }
bool CGUIWindowPVRRecordings::ActionDeleteRecording(CFileItem *item) { bool bReturn = false; if (!item->IsPVRRecording() && !item->m_bIsFolder) return bReturn; /* show a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return bReturn; pDialog->SetHeading(122); // Confirm delete pDialog->SetLine(0, item->m_bIsFolder ? 19113 : 19112); // Are you sure? pDialog->SetLine(1, ""); pDialog->SetLine(2, item->GetLabel()); pDialog->SetChoice(1, 117); // Delete /* prompt for the user's confirmation */ pDialog->DoModal(); if (!pDialog->IsConfirmed()) return bReturn; /* delete the recording */ if (g_PVRRecordings->Delete(*item)) { g_PVRManager.TriggerRecordingsUpdate(); bReturn = true; /* remove the item from the list immediately, otherwise the item count further down may be wrong */ m_vecItems->Remove(item); /* go to the parent folder if we're in a subdirectory and just deleted the last item */ if (m_vecItems->GetPath() != "pvr://recordings/" && m_vecItems->GetObjectCount() == 0) GoParentFolder(); } return bReturn; }
bool CGUIDialogYesNo::ShowAndGetInput(int heading, int line0, int line1, int line2, int iNoLabel, int iYesLabel, bool& bCanceled, unsigned int autoCloseTime) { CGUIDialogYesNo *dialog = (CGUIDialogYesNo *)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!dialog) return false; dialog->SetHeading(heading); dialog->SetLine(0, line0); dialog->SetLine(1, line1); dialog->SetLine(2, line2); if (autoCloseTime) dialog->SetAutoClose(autoCloseTime); if (iNoLabel != -1) dialog->SetChoice(0,iNoLabel); else dialog->SetChoice(0,106); if (iYesLabel != -1) dialog->SetChoice(1,iYesLabel); else dialog->SetChoice(1,107); dialog->m_bCanceled = false; dialog->DoModal(); bCanceled = dialog->m_bCanceled; return (dialog->IsConfirmed()) ? true : false; }
bool CGUIWindowPVRCommon::ActionDeleteTimer(CFileItem *item) { /* check if the timer tag is valid */ CPVRTimerInfoTag *timerTag = item->GetPVRTimerInfoTag(); if (!timerTag || timerTag->m_iClientIndex < 0) return false; /* show a confirmation dialog */ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return false; pDialog->SetHeading(122); pDialog->SetLine(0, 19040); pDialog->SetLine(1, ""); pDialog->SetLine(2, timerTag->m_strTitle); pDialog->DoModal(); /* prompt for the user's confirmation */ if (!pDialog->IsConfirmed()) return false; /* delete the timer */ return g_PVRTimers->DeleteTimer(*item); }
bool CGUIDialogPVRChannelManager::OnMessage(CGUIMessage& message) { unsigned int iControl = 0; unsigned int iMessage = message.GetMessage(); switch (iMessage) { case GUI_MSG_WINDOW_DEINIT: { Clear(); } break; case GUI_MSG_WINDOW_INIT: { CGUIWindow::OnMessage(message); m_iSelected = 0; m_bIsRadio = false; m_bMovingMode = false; m_bContainsChanges = false; SetProperty("IsRadio", ""); Update(); SetData(m_iSelected); return true; } break; case GUI_MSG_CLICKED: { iControl = message.GetSenderId(); if (iControl == CONTROL_LIST_CHANNELS) { if (!m_bMovingMode) { int iAction = message.GetParam1(); int iItem = m_viewControl.GetSelectedItem(); /* Check file item is in list range and get his pointer */ if (iItem < 0 || iItem >= (int)m_channelItems->Size()) return true; /* Process actions */ if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK) { /* Show Contextmenu */ OnPopupMenu(iItem); } } else { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (pItem) { pItem->SetProperty("Changed", true); pItem->Select(false); m_bMovingMode = false; m_bContainsChanges = true; return true; } else return false; } } else if (iControl == BUTTON_OK) { SaveList(); Close(); return true; } else if (iControl == BUTTON_APPLY) { SaveList(); return true; } else if (iControl == BUTTON_CANCEL) { Close(); return true; } else if (iControl == BUTTON_RADIO_TV) { if (m_bContainsChanges) { // prompt user for confirmation of channel record CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return true; pDialog->SetHeading(20052); pDialog->SetLine(0, ""); pDialog->SetLine(1, 19212); pDialog->SetLine(2, 20103); pDialog->DoModal(); if (pDialog->IsConfirmed()) SaveList(); } m_iSelected = 0; m_bMovingMode = false; m_bContainsChanges = false; m_bIsRadio = !m_bIsRadio; SetProperty("IsRadio", m_bIsRadio ? "true" : ""); Update(); SetData(m_iSelected); return true; } else if (iControl == RADIOBUTTON_ACTIVE) { CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_ACTIVE); if (pRadioButton) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (pItem) { pItem->SetProperty("Changed", true); pItem->SetProperty("ActiveChannel", pRadioButton->IsSelected()); m_bContainsChanges = true; Renumber(); } } } else if (iControl == EDIT_NAME) { CGUIEditControl *pEdit = (CGUIEditControl *)GetControl(EDIT_NAME); if (pEdit) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (pItem) { pItem->SetProperty("Changed", true); pItem->SetProperty("Name", pEdit->GetLabel2()); m_bContainsChanges = true; } } } else if (iControl == BUTTON_CHANNEL_LOGO) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (!pItem) return false; if (g_settings.GetCurrentProfile().canWriteSources() && !g_passwordManager.IsProfileLockUnlocked()) return false; else if (!g_passwordManager.IsMasterLockUnlocked(true)) return false; // setup our thumb list CFileItemList items; // add the current thumb, if available if (!pItem->GetProperty("Icon").IsEmpty()) { CFileItemPtr current(new CFileItem("thumb://Current", false)); current->SetThumbnailImage(pItem->GetPVRChannelInfoTag()->IconPath()); current->SetLabel(g_localizeStrings.Get(20016)); items.Add(current); } else if (pItem->HasThumbnail()) { // already have a thumb that the share doesn't know about - must be a local one, so we mayaswell reuse it. CFileItemPtr current(new CFileItem("thumb://Current", false)); current->SetThumbnailImage(pItem->GetThumbnailImage()); current->SetLabel(g_localizeStrings.Get(20016)); items.Add(current); } // and add a "no thumb" entry as well CFileItemPtr nothumb(new CFileItem("thumb://None", false)); nothumb->SetIconImage(pItem->GetIconImage()); nothumb->SetLabel(g_localizeStrings.Get(20018)); items.Add(nothumb); CStdString strThumb; VECSOURCES shares; if (g_guiSettings.GetString("pvrmenu.iconpath") != "") { CMediaSource share1; share1.strPath = g_guiSettings.GetString("pvrmenu.iconpath"); share1.strName = g_localizeStrings.Get(19018); shares.push_back(share1); } g_mediaManager.GetLocalDrives(shares); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, shares, g_localizeStrings.Get(1030), strThumb)) return false; if (strThumb == "thumb://Current") return true; if (strThumb == "thumb://None") strThumb = ""; pItem->SetProperty("Icon", strThumb); pItem->SetProperty("Changed", true); m_bContainsChanges = true; return true; } else if (iControl == RADIOBUTTON_USEEPG) { CGUIRadioButtonControl *pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_USEEPG); if (pRadioButton) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (pItem) { pItem->SetProperty("Changed", true); pItem->SetProperty("UseEPG", pRadioButton->IsSelected()); m_bContainsChanges = true; } } } else if (iControl == SPIN_EPGSOURCE_SELECTION) { /// TODO: Add EPG scraper support return true; CGUISpinControlEx *pSpin = (CGUISpinControlEx *)GetControl(SPIN_EPGSOURCE_SELECTION); if (pSpin) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (pItem) { pItem->SetProperty("EPGSource", (int)0); pItem->SetProperty("Changed", true); m_bContainsChanges = true; return true; } } } else if (iControl == BUTTON_GROUP_MANAGER) { /* Load group manager dialog */ CGUIDialogPVRGroupManager* pDlgInfo = (CGUIDialogPVRGroupManager*)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_GROUP_MANAGER); if (!pDlgInfo) return false; pDlgInfo->SetRadio(m_bIsRadio); /* Open dialog window */ pDlgInfo->DoModal(); return true; } else if (iControl == BUTTON_EDIT_CHANNEL) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (!pItem) return false; if (pItem->GetPropertyBOOL("Virtual")) { CStdString strURL = pItem->GetProperty("StreamURL"); if (CGUIDialogKeyboard::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false)) pItem->SetProperty("StreamURL", strURL); return true; } CGUIDialogOK::ShowAndGetInput(19033,19038,0,0); return true; } else if (iControl == BUTTON_DELETE_CHANNEL) { CFileItemPtr pItem = m_channelItems->Get(m_iSelected); if (!pItem) return false; // prompt user for confirmation of channel record CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return true; pDialog->SetHeading(19211); pDialog->SetLine(0, ""); pDialog->SetLine(1, 750); pDialog->SetLine(2, ""); pDialog->DoModal(); if (pDialog->IsConfirmed()) { if (pItem->GetPropertyBOOL("Virtual")) { CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); database->Open(); database->Delete(*pItem->GetPVRChannelInfoTag()); database->Close(); m_channelItems->Remove(m_iSelected); m_viewControl.SetItems(*m_channelItems); Renumber(); return true; } CGUIDialogOK::ShowAndGetInput(19033,19038,0,0); } return true; } else if (iControl == BUTTON_NEW_CHANNEL) { std::vector<long> clients; CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (!pDlgSelect) return false; pDlgSelect->SetHeading(19213); // Select Client pDlgSelect->Add(g_localizeStrings.Get(19209)); clients.push_back(XBMC_VIRTUAL_CLIENTID); std::map<long, CStdString> clientMap; if (CPVRManager::GetClients()->GetClients(&clientMap) > 0) { std::map<long,CStdString>::iterator itr; for (itr = clientMap.begin() ; itr != clientMap.end(); itr++) { clients.push_back((*itr).first); pDlgSelect->Add(clientMap[(*itr).first]); } } pDlgSelect->DoModal(); int selection = pDlgSelect->GetSelectedLabel(); if (selection >= 0 && selection <= (int) clients.size()) { int clientID = clients[selection]; if (clientID == XBMC_VIRTUAL_CLIENTID) { CStdString strURL = ""; if (CGUIDialogKeyboard::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false)) { if (!strURL.IsEmpty()) { CPVRChannel newchannel(m_bIsRadio); newchannel.SetChannelName(g_localizeStrings.Get(19204)); newchannel.SetEPGEnabled(false); newchannel.SetVirtual(true); newchannel.SetStreamURL(strURL); newchannel.SetClientID(XBMC_VIRTUAL_CLIENTID); CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); database->Open(); database->Persist(newchannel); database->Close(); CFileItemPtr channel(new CFileItem(newchannel)); if (channel) { channel->SetProperty("ActiveChannel", true); channel->SetProperty("Name", g_localizeStrings.Get(19204)); channel->SetProperty("UseEPG", false); channel->SetProperty("Icon", newchannel.IconPath()); channel->SetProperty("EPGSource", (int)0); channel->SetProperty("ClientName", g_localizeStrings.Get(19209)); m_channelItems->AddFront(channel, m_iSelected); m_viewControl.SetItems(*m_channelItems); Renumber(); } } } } else { CGUIDialogOK::ShowAndGetInput(19033,19038,0,0); } } return true; } } break; } return CGUIDialog::OnMessage(message); }