void CGUIDialogPVRChannelManager::SetData(int iItem) { CGUIEditControl *pEdit; CGUIRadioButtonControl *pRadioButton; /* Check file item is in list range and get his pointer */ if (iItem < 0 || iItem >= (int)m_channelItems->Size()) return; CFileItemPtr pItem = m_channelItems->Get(iItem); if (!pItem) return; // CPVRChannel *infotag = pItem->GetPVRChannelInfoTag(); pEdit = (CGUIEditControl *)GetControl(EDIT_NAME); if (pEdit) { pEdit->SetLabel2(pItem->GetProperty("Name")); pEdit->SetInputType(CGUIEditControl::INPUT_TYPE_TEXT, 19208); } pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_ACTIVE); if (pRadioButton) pRadioButton->SetSelected(pItem->GetPropertyBOOL("ActiveChannel")); pRadioButton = (CGUIRadioButtonControl *)GetControl(RADIOBUTTON_USEEPG); if (pRadioButton) pRadioButton->SetSelected(pItem->GetPropertyBOOL("UseEPG")); }
bool CGUIDialogPVRChannelManager::OnPopupMenu(int iItem) { // popup the context menu // grab our context menu CContextButtons buttons; // mark the item if (iItem >= 0 && iItem < m_channelItems->Size()) m_channelItems->Get(iItem)->Select(true); else return false; CFileItemPtr pItem = m_channelItems->Get(iItem); if (!pItem) return false; buttons.Add(CONTEXT_BUTTON_MOVE, 116); /* Move channel up or down */ if (pItem->GetPropertyBOOL("Virtual")) buttons.Add(CONTEXT_BUTTON_EDIT_SOURCE, 1027); /* Edit virtual channel URL */ int choice = CGUIDialogContextMenu::ShowAndGetChoice(buttons); // deselect our item if (iItem >= 0 && iItem < m_channelItems->Size()) m_channelItems->Get(iItem)->Select(false); if (choice < 0) return false; return OnContextButton(iItem, (CONTEXT_BUTTON)choice); }
void CGUIMediaWindow::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : CFileItemPtr(); if (!item) return; // user added buttons CStdString label; CStdString action; for (int i = CONTEXT_BUTTON_USER1; i <= CONTEXT_BUTTON_USER10; i++) { label.Format("contextmenulabel(%i)", i - CONTEXT_BUTTON_USER1); if (item->GetProperty(label).IsEmpty()) break; action.Format("contextmenuaction(%i)", i - CONTEXT_BUTTON_USER1); if (item->GetProperty(action).IsEmpty()) break; buttons.Add((CONTEXT_BUTTON)i, item->GetProperty(label)); } if (item->GetPropertyBOOL("pluginreplacecontextitems")) return; // TODO: FAVOURITES Conditions on masterlock and localisation if (!item->IsParentFolder() && !item->m_strPath.Equals("add") && !item->m_strPath.Equals("newplaylist://") && !item->m_strPath.Left(19).Equals("newsmartplaylist://")) { if (CFavourites::IsFavourite(item.get(), GetID())) buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14077); // Remove Favourite else buttons.Add(CONTEXT_BUTTON_ADD_FAVOURITE, 14076); // Add To Favourites; } }
void CGUIWindowPictures::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && !item->GetPropertyBOOL("pluginreplacecontextitems")) { if ( m_vecItems->IsVirtualDirectoryRoot() && item) { CGUIDialogContextMenu::GetContextButtons("pictures", item, buttons); } else { if (item) { if (!(item->m_bIsFolder || item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR())) buttons.Add(CONTEXT_BUTTON_INFO, 13406); // picture info buttons.Add(CONTEXT_BUTTON_VIEW_SLIDESHOW, item->m_bIsFolder ? 13317 : 13422); // View Slideshow if (item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_RECURSIVE_SLIDESHOW, 13318); // Recursive Slideshow if (!m_thumbLoader.IsLoading()) buttons.Add(CONTEXT_BUTTON_REFRESH_THUMBS, 13315); // Create Thumbnails if (g_guiSettings.GetBool("filelists.allowfiledeletion") && !item->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } if (item->IsPlugin() || item->m_strPath.Left(9).Equals("script://") || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); buttons.Add(CONTEXT_BUTTON_GOTO_ROOT, 20128); buttons.Add(CONTEXT_BUTTON_SWITCH_MEDIA, 523); } } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); if (item && !item->GetPropertyBOOL("pluginreplacecontextitems")) buttons.Add(CONTEXT_BUTTON_SETTINGS, 5); // Settings }
bool CBoxeeSocialUtilsManager::GetStatusFromServer() { int retCode; Job_Result jobResult = BoxeeUtils::GetShareServicesJson(m_jsonServiceList, retCode); CLog::Log(LOGDEBUG,"CBoxeeSocialUtilsManager::GetSocialServicesStatus - call to get SocialServices status from server returned [jobResult=%d] ",jobResult); if (jobResult != JOB_SUCCEEDED) { CLog::Log(LOGERROR,"CBoxeeSocialUtilsManager::GetSocialServicesStatus - FAILED to get SocialServices status from server. [jobResult=%d]",jobResult); return false; } m_servicesList.Clear(); m_serviceMap.clear(); BoxeeUtils::ParseJsonShareServicesToFileItems(m_jsonServiceList,m_servicesList); CLog::Log(LOGDEBUG,"CBoxeeSocialUtilsManager::GetSocialServicesStatus - after parse SocialServices to FIleItemList. [NumOfSocialServices=%d]",m_servicesList.Size()); for (int i = 0; i < m_servicesList.Size(); i++) { CFileItemPtr item = m_servicesList.Get(i); CStdString currentServiceId = item->GetProperty("serviceId"); if (currentServiceId == FACEBOOK_SERVICE_ID || currentServiceId == TWITTER_SERVICE_ID || currentServiceId == TUMBLR_SERVICE_ID) { m_serviceMap[currentServiceId].isConnected = item->GetPropertyBOOL("enable"); m_serviceMap[currentServiceId].requiresUpdate = item->GetPropertyBOOL("refresh"); m_serviceMap[currentServiceId].link = item->GetProperty("connect"); m_serviceMap[currentServiceId].disconnectLink = item->GetProperty("disconnect"); m_serviceMap[currentServiceId].externalLink = item->GetProperty("link"); } } return true; }
void CGUIWindowMusicBase::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && !item->GetPropertyBOOL("pluginreplacecontextitems")) { if (item && !item->IsParentFolder()) { if (item->GetExtraInfo().Equals("lastfmloved")) { buttons.Add(CONTEXT_BUTTON_LASTFM_UNLOVE_ITEM, 15295); //unlove } else if (item->GetExtraInfo().Equals("lastfmbanned")) { buttons.Add(CONTEXT_BUTTON_LASTFM_UNBAN_ITEM, 15296); //unban } else if (item->CanQueue()) { buttons.Add(CONTEXT_BUTTON_QUEUE_ITEM, 13347); //queue // allow a folder to be ad-hoc queued and played by the default player if (item->m_bIsFolder || (item->IsPlayList() && !g_advancedSettings.m_playlistAsFolders)) { buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 208); // Play } else { // check what players we have, if we have multiple display play with option VECPLAYERCORES vecCores; CPlayerCoreFactory::GetPlayers(*item, vecCores); if (vecCores.size() >= 1) buttons.Add(CONTEXT_BUTTON_PLAY_WITH, 15213); // Play With... } if (item->IsSmartPlayList()) { buttons.Add(CONTEXT_BUTTON_PLAY_PARTYMODE, 15216); // Play in Partymode } if (item->IsSmartPlayList() || m_vecItems->IsSmartPlayList()) buttons.Add(CONTEXT_BUTTON_EDIT_SMART_PLAYLIST, 586); else if (item->IsPlayList() || m_vecItems->IsPlayList()) buttons.Add(CONTEXT_BUTTON_EDIT, 586); } } } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); }
void CPlayList::SetUnPlayable(int iItem) { if (iItem < 0 || iItem >= size()) { CLog::Log(LOGWARNING, "Attempt to set unplayable index %d", iItem); return; } CFileItemPtr item = m_vecItems[iItem]; if (!item->GetPropertyBOOL("unplayable")) { item->SetProperty("unplayable", true); m_iPlayableItems--; } }
void CGUIDialogBoxeeShare::OnDeinitWindow(int nextWindowID) { CGUIWindowStateDatabase statedb; for (int i = 0 ; i < m_servicesList.Size() ; i++) { CFileItemPtr fileItemPtr = m_servicesList.Get(i); if (fileItemPtr.get()) { statedb.SetUserServiceState(fileItemPtr->GetProperty("id"),fileItemPtr->GetPropertyBOOL("isSelected")); } fileItemPtr.reset(); } CGUIDialog::OnDeinitWindow(nextWindowID); }
void CGUIDialogPVRChannelManager::Renumber() { int number = 1; CStdString strNumber; CFileItemPtr pItem; for (int i = 0; i < m_channelItems->Size(); i++) { pItem = m_channelItems->Get(i); if (pItem->GetPropertyBOOL("ActiveChannel")) { strNumber.Format("%i", number++); pItem->SetProperty("Number", strNumber); } else pItem->SetProperty("Number", "-"); } }
void CGUIDialogPVRChannelManager::SaveList() // XXX investigate: renumbering doesn't work { if (!m_bContainsChanges) return; CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase(); if (!database || !database->Open()) return; CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); pDlgProgress->SetHeading(190); pDlgProgress->SetLine(0, ""); pDlgProgress->SetLine(1, 328); pDlgProgress->SetLine(2, ""); pDlgProgress->StartModal(); pDlgProgress->Progress(); pDlgProgress->SetPercentage(0); int iActiveChannels = 0; for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++) { if (m_channelItems->Get(iListPtr)->GetPropertyBOOL("ActiveChannel")) ++iActiveChannels; } // int iNextChannelNumber = 1; // int iNextHiddenChannelNumber = iActiveChannels + 1; bool bHasChangedItems = false; for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++) { bool bChanged = false; CFileItemPtr pItem = m_channelItems->Get(iListPtr); if (!pItem) continue; CPVRChannel *channel = pItem->GetPVRChannelInfoTag(); if (!channel) { //TODO add new channel continue; } /* get values from the form */ bool bHidden = !pItem->GetPropertyBOOL("ActiveChannel"); bool bVirtual = pItem->GetPropertyBOOL("Virtual"); bool bEPGEnabled = pItem->GetPropertyBOOL("UseEPG"); int iEPGSource = pItem->GetPropertyInt("EPGSource"); CStdString strChannelName = pItem->GetProperty("Name"); CStdString strIconPath = pItem->GetProperty("Icon"); CStdString strStreamURL = pItem->GetProperty("StreamURL"); /* set new values in the channel tag */ // TODO // if (bHidden) // bChanged = channel->SetChannelNumber(iNextHiddenChannelNumber++) || bChanged; // else // bChanged = channel->SetChannelNumber(iNextChannelNumber++) || bChanged; bChanged = channel->SetChannelName(strChannelName) || bChanged; bChanged = channel->SetHidden(bHidden) || bChanged; bChanged = channel->SetIconPath(strIconPath) || bChanged; if (bVirtual) bChanged = channel->SetStreamURL(strStreamURL) || bChanged; if (iEPGSource == 0) bChanged = channel->SetEPGScraper("client") || bChanged; // TODO add other scrapers bChanged = channel->SetEPGEnabled(bEPGEnabled) || bChanged; if (bChanged) { bHasChangedItems = true; channel->Persist(true); } pItem->SetProperty("Changed", false); pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size()); } if (bHasChangedItems) { database->CommitInsertQueries(); CPVRManager::Get()->Start(); // XXX not a nice way to refresh the channels, but works for now } database->Close(); m_bContainsChanges = false; pDlgProgress->Close(); }
void CGUIWindowPrograms::GetContextButtons(int itemNumber, CContextButtons &buttons) { if (itemNumber < 0 || itemNumber >= m_vecItems->Size()) return; CFileItemPtr item = m_vecItems->Get(itemNumber); if (item && !item->GetPropertyBOOL("pluginreplacecontextitems")) { if ( m_vecItems->IsVirtualDirectoryRoot() ) { CGUIDialogContextMenu::GetContextButtons("programs", item, buttons); } else { if (item->IsXBE() || item->IsShortCut()) { if (CFile::Exists("special://xbmc/system/scripts/XBMC4Gamers Extras/Synopsis/default.py") || CFile::Exists("special://xbmc/system/scripts/Synopsis/default.py")) { buttons.Add(CONTEXT_BUTTON_SYNOPSIS, "Synopsis"); // Synopsis } CStdString strLaunch = g_localizeStrings.Get(518); // Launch if (g_guiSettings.GetBool("myprograms.gameautoregion")) { int iRegion = GetRegion(itemNumber); if (iRegion == VIDEO_NTSCM) strLaunch += " (NTSC-M)"; if (iRegion == VIDEO_NTSCJ) strLaunch += " (NTSC-J)"; if (iRegion == VIDEO_PAL50) strLaunch += " (PAL)"; if (iRegion == VIDEO_PAL60) strLaunch += " (PAL-60)"; } buttons.Add(CONTEXT_BUTTON_LAUNCH, strLaunch); DWORD dwTitleId = CUtil::GetXbeID(item->GetPath()); CStdString strTitleID; CStdString strGameSavepath; strTitleID.Format("%08X",dwTitleId); URIUtils::AddFileToFolder("E:\\udata\\",strTitleID,strGameSavepath); if (CDirectory::Exists(strGameSavepath)) buttons.Add(CONTEXT_BUTTON_GAMESAVES, 20322); // Goto GameSaves if (g_guiSettings.GetBool("myprograms.gameautoregion")) buttons.Add(CONTEXT_BUTTON_LAUNCH_IN, 519); // launch in video mode if (g_passwordManager.IsMasterLockUnlocked(false) || g_settings.GetCurrentProfile().canWriteDatabases()) { if (item->IsShortCut()) buttons.Add(CONTEXT_BUTTON_RENAME, 16105); // rename else buttons.Add(CONTEXT_BUTTON_RENAME, 520); // edit xbe title } if (m_database.ItemHasTrainer(dwTitleId)) buttons.Add(CONTEXT_BUTTON_TRAINER_OPTIONS, 12015); // trainer options } buttons.Add(CONTEXT_BUTTON_SCAN_TRAINERS, 12012); // scan trainers buttons.Add(CONTEXT_BUTTON_GOTO_ROOT, 20128); // Go to Root } } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); if (item && !item->GetPropertyBOOL("pluginreplacecontextitems")) buttons.Add(CONTEXT_BUTTON_SETTINGS, 5); // Settings }
bool CGUIDialogBoxeeCtx::HandleQualityList() { const CFileItemList* linksFileItemList = m_item.GetLinksList(); if (!linksFileItemList) { return true; } if (linksFileItemList->Size() == 1) { return true; } int FocusedItem = 0; m_pDlgVideoQuality = (CGUIDialogBoxeeVideoQuality*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_VIDEO_QUALITY); m_pDlgVideoQuality->Reset(); for (int i=0; i<linksFileItemList->Size(); i++) { CFileItemPtr linkFileItemToAdd = linksFileItemList->Get(i); m_pDlgVideoQuality->Add((*linkFileItemToAdd)); // if the user ask for a different quality - switch to a different link if (m_item.GetPropertyInt("quality") ==linkFileItemToAdd->GetPropertyInt("quality")) { FocusedItem = i; } } m_pDlgVideoQuality->ChangeDialogType(LIST_CVQ_DIALOG); m_pDlgVideoQuality->SetFocusedItem(FocusedItem); m_pDlgVideoQuality->DoModal(); if (m_pDlgVideoQuality->IsCanceled()) { return false; } int chosenItemPos = m_pDlgVideoQuality->GetSelectedItemPos(); CFileItemPtr chosenItem = linksFileItemList->Get(chosenItemPos); if(m_pDlgVideoQuality->GetSavePerference()) { BOXEE::Boxee::GetInstance().GetMetadataEngine().UpdateProviderPerf(chosenItem->GetProperty("link-provider"),chosenItem->GetPropertyInt("quality")); } // if the user ask for a different quality - switch to a different link if (m_item.GetPropertyInt("quality") !=chosenItem->GetPropertyInt("quality")) { CLog::Log(LOGDEBUG,"CGUIDialogBoxeeCtx::HandleQualityList change quality to %d", chosenItem->GetPropertyInt("quality")); if (chosenItem.get() == NULL) { CLog::Log(LOGERROR,"CGUIDialogBoxeeMediaAction::OnPlayMedia choose NULL item"); return false; } // copy the relevant properties from the chosen item m_item.m_strPath = chosenItem->m_strPath; m_item.SetProperty("link-boxeetype", chosenItem->GetProperty("link-boxeetype")); m_item.SetProperty("link-provider", chosenItem->GetProperty("link-provider")); m_item.SetProperty("link-providername", chosenItem->GetProperty("link-providername")); m_item.SetProperty("link-providerthumb", chosenItem->GetProperty("link-providerthumb")); m_item.SetProperty("link-countrycodes", chosenItem->GetProperty("link-countrycodes")); m_item.SetProperty("link-countryrel", chosenItem->GetPropertyBOOL("link-countryrel")); m_item.SetProperty("quality-lbl", chosenItem->GetProperty("quality-lbl")); m_item.SetProperty("quality", chosenItem->GetPropertyInt("quality")); OnPlay(); } return true; }
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); }
bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, CStdString strMask /*=""*/, bool bUseFileDirectories /* = true */, bool allowPrompting /* = false */, DIR_CACHE_TYPE cacheDirectory /* = DIR_CACHE_NEVER */, bool extFileInfo /* = true */) { try { auto_ptr<IDirectory> pDirectory(CFactoryDirectory::Create(strPath)); if (!pDirectory.get()) return false; // check our cache for this path if (g_directoryCache.GetDirectory(strPath, items, cacheDirectory == DIR_CACHE_ALWAYS)) items.m_strPath = strPath; else { // need to clear the cache (in case the directory fetch fails) // and (re)fetch the folder if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.ClearDirectory(strPath); pDirectory->SetAllowPrompting(allowPrompting); pDirectory->SetCacheDirectory(cacheDirectory); pDirectory->SetUseFileDirectories(bUseFileDirectories); pDirectory->SetExtFileInfo(extFileInfo); items.m_strPath = strPath; if (!pDirectory->GetDirectory(strPath, items)) { CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; } // cache the directory, if necessary if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.SetDirectory(strPath, items, pDirectory->GetCacheType(strPath)); } // now filter for allowed files pDirectory->SetMask(strMask); for (int i = 0; i < items.Size(); ++i) { CFileItemPtr item = items[i]; if ((!item->m_bIsFolder && !pDirectory->IsAllowed(item->m_strPath)) || (item->GetPropertyBOOL("file:hidden") && !g_guiSettings.GetBool("filelists.showhidden"))) { items.Remove(i); i--; // don't confuse loop } } // Should any of the files we read be treated as a directory? // Disable for database folders, as they already contain the extracted items if (bUseFileDirectories && !items.IsMusicDb() && !items.IsVideoDb() && !items.IsSmartPlayList()) { for (int i=0; i< items.Size(); ++i) { CFileItemPtr pItem=items[i]; if ((!pItem->m_bIsFolder) && (!pItem->IsInternetStream())) { auto_ptr<IFileDirectory> pDirectory(CFactoryFileDirectory::Create(pItem->m_strPath,pItem.get(),strMask)); if (pDirectory.get()) pItem->m_bIsFolder = true; else if (pItem->m_bIsFolder) { items.Remove(i); i--; // don't confuse loop } } } } return true; } #ifndef _LINUX catch (const win32_exception &e) { e.writelog(__FUNCTION__); } #endif catch (...) { CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__); } CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; }
bool CGUIDialogBoxeeShare::OnMessage(CGUIMessage &message) { if (message.GetMessage() == GUI_MSG_WINDOW_INIT) { //if (!LoadSocialServices(true)) int retCode; if (BoxeeUtils::GetShareServicesJson(m_jsonServiceList,retCode,true) != JOB_SUCCEEDED) { Close(); return true; } } else if (message.GetMessage() == GUI_MSG_WINDOW_DEINIT) { m_item.Reset(); } else if (message.GetMessage() == GUI_MSG_CLICKED) { switch(message.GetSenderId()) { case EDIT_CONTROL: { CGUIEditControl* editControl = (CGUIEditControl*)GetControl(EDIT_CONTROL); CGUIWindow* activeWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow()); if (editControl && activeWindow) { CStdString leftToInput = BOXEE::BXUtils::IntToString(editControl->GetMaxInputSize() - (int)editControl->GetLabel2().size()); activeWindow->SetProperty(LEFT_TO_INPUT_SIZE,leftToInput); } } break; case SHARE_BTN: { CGUIEditControl* editControl = (CGUIEditControl*)GetControl(EDIT_CONTROL); if (!editControl) { CGUIDialogOK2::ShowAndGetInput(257, 55195); return true; } m_strText = editControl->GetLabel2(); if (m_strText.IsEmpty()) { CGUIDialogOK2::ShowAndGetInput(54000, 54001); return true; } std::vector<BOXEE::BXFriend> recommendTo; // always empty at the moment - which means - "to all the world". BoxeeUtils::Share(&m_item, recommendTo, m_servicesList, false, m_strText); Close(); g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::ICON_HEART, "", g_localizeStrings.Get(51033), 3000, KAI_RED_COLOR, KAI_GREY_COLOR); } break; case SERVICE_LIST: { CGUIBaseContainer* serviceList = (CGUIBaseContainer*) GetControl(SERVICE_LIST); CGUIListItemPtr itemUI = serviceList->GetSelectedItemPtr(); int iItem = serviceList->GetSelectedItem(); if (iItem < m_servicesList.Size() && iItem >= 0 ) { CFileItemPtr fileItem = m_servicesList.Get(iItem); CFileItem* fItem = fileItem.get(); //fItem->Dump(); if (!fileItem->GetPropertyBOOL("enable")) { //open up the browser dialog with the link we got from the server #ifdef CANMORE if (!g_application.IsPlaying() || g_application.GetCurrentPlayer() != PCID_FLASHLAYER) { //browser reported success int retCode; if (CGUIWebDialog::ShowAndGetInput(fileItem->GetProperty("connect")) && BoxeeUtils::GetShareServicesJson(m_jsonServiceList,retCode,true) == JOB_SUCCEEDED) { UpdateShareDialog(); } } else #endif { CStdString text = g_localizeStrings.Get(80001); text += " " + fileItem->GetProperty("link"); CGUIDialogOK2::ShowAndGetInput(g_localizeStrings.Get(10014),text); } return true; } bool bSelection = itemUI->GetPropertyBOOL("isSelected"); fItem->SetProperty("isSelected", !bSelection); itemUI->SetProperty("isSelected", !bSelection); } } break; } } return CGUIDialog::OnMessage(message); }
void CGUIWindowVideoFiles::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)m_gWindowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (item) { // are we in the playlists location? if (m_vecItems->IsVirtualDirectoryRoot()) { // get the usual shares, and anything for all media windows CGUIDialogContextMenu::GetContextButtons("video", item, buttons); CGUIMediaWindow::GetContextButtons(itemNumber, buttons); // add scan button somewhere here if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning if (g_guiSettings.GetBool("videolibrary.enabled") && !item->IsDVD() && item->m_strPath != "add" && (g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() || g_passwordManager.bMasterUser)) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)m_gWindowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); CVideoDatabase database; database.Open(); SScraperInfo info; if (item && database.GetScraperForPath(item->m_strPath,info)) { if (!info.strPath.IsEmpty() && !info.strContent.IsEmpty()) if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } } else { CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (!item->GetPropertyBOOL("pluginreplacecontextitems")) { // Movie Info button if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); if (g_guiSettings.GetBool("videolibrary.enabled") && (g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() || g_passwordManager.bMasterUser)) { SScraperInfo info; VIDEO::SScanSettings settings; int iFound = GetScraperForItem(item.get(), info, settings); int infoString = 13346; if (info.strContent.Equals("tvshows")) infoString = item->m_bIsFolder ? 20351 : 20352; if (info.strContent.Equals("musicvideos")) infoString = 20393; if (item->m_bIsFolder) { if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) if (!item->IsPlayList()) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); if (iFound==0) { // scraper not set - allow movie information or set content CStdString strPath(item->m_strPath); CUtil::AddSlashAtEnd(strPath); if ((info.strContent.Equals("movies") && m_database.HasMovieInfo(strPath)) || (info.strContent.Equals("tvshows") && m_database.HasTvShowInfo(strPath))) buttons.Add(CONTEXT_BUTTON_INFO, infoString); } else { // scraper found - allow movie information, scan for new content, or set different type of content if (!info.strContent.Equals("musicvideos")) buttons.Add(CONTEXT_BUTTON_INFO, infoString); if (!info.strPath.IsEmpty() && !info.strContent.IsEmpty()) if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } else { // single file if ((info.strContent.Equals("movies") && (iFound > 0 || m_database.HasMovieInfo(item->m_strPath))) || m_database.HasEpisodeInfo(item->m_strPath) || info.strContent.Equals("musicvideos")) { buttons.Add(CONTEXT_BUTTON_INFO, infoString); } m_database.Open(); if (!item->IsParentFolder()) { if (!m_database.HasMovieInfo(item->m_strPath) && !m_database.HasEpisodeInfo(item->m_strPath)) buttons.Add(CONTEXT_BUTTON_ADD_TO_LIBRARY, 527); // Add to Database } m_database.Close(); } } } if (!item->IsParentFolder()) { if ((m_vecItems->m_strPath.Equals("special://videoplaylists/")) || g_guiSettings.GetBool("filelists.allowfiledeletion")) { // video playlists or file operations are allowed if (!item->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } } if (m_vecItems->IsPlugin() && item->HasVideoInfoTag() && !item->GetPropertyBOOL("pluginreplacecontextitems")) buttons.Add(CONTEXT_BUTTON_INFO,13346); // only movie information for now } } else { if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning } if(!(item && item->GetPropertyBOOL("pluginreplacecontextitems"))) { if (!m_vecItems->IsVirtualDirectoryRoot()) buttons.Add(CONTEXT_BUTTON_SWITCH_MEDIA, 523); CGUIWindowVideoBase::GetNonContextButtons(itemNumber, buttons); } }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetPropertyBOOL("pluginreplacecontextitems")) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->m_strPath); if (!item) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } else { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); if (info && info->Content() == CONTENT_TVSHOWS) buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352); else if (info && info->Content() == CONTENT_MUSICVIDEOS) buttons.Add(CONTEXT_BUTTON_INFO,20393); else if (!item->m_bIsFolder && !item->m_strPath.Left(19).Equals("newsmartplaylist://")) buttons.Add(CONTEXT_BUTTON_INFO, 13346); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strArtist.IsEmpty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(item->GetVideoInfoTag()->m_strArtist) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 && item->GetVideoInfoTag()->m_strArtist.size() > 0 && item->GetVideoInfoTag()->m_strTitle.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(item->GetVideoInfoTag()->m_strArtist, item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { // can we update the database? if (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (node == NODE_TYPE_TITLE_TVSHOWS) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_TVSHOW, 13349); } if ((info && info->Content() == CONTENT_TVSHOWS && item->m_bIsFolder) || (item->IsVideoDb() && item->HasVideoInfoTag() && !item->m_bIsFolder)) { if (item->m_bIsFolder || item->GetVideoInfoTag()->m_playCount > 0) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched if (item->m_bIsFolder || item->GetVideoInfoTag()->m_playCount == 0) buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if (node != NODE_TYPE_SEASONS) buttons.Add(CONTEXT_BUTTON_EDIT, 16105); //Edit Title } if (m_database.HasContent(VIDEODB_CONTENT_TVSHOWS) && item->HasVideoInfoTag() && !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode == -1 && item->GetVideoInfoTag()->m_strArtist.IsEmpty()) // movie entry { if (m_database.IsLinkedToTvshow(item->GetVideoInfoTag()->m_iDbId)) buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE,20385); buttons.Add(CONTEXT_BUTTON_LINK_MOVIE,20384); } if (node == NODE_TYPE_SEASONS && item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_SET_SEASON_THUMB, 20371); if (item->m_strPath.Left(14).Equals("videodb://1/7/") && item->m_strPath.size() > 14 && item->m_bIsFolder) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16105); buttons.Add(CONTEXT_BUTTON_SET_MOVIESET_THUMB, 20435); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder) { if (m_vecItems->m_strPath.Left(11).Equals("videodb://3")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } if (item->IsVideoDb() && item->HasVideoInfoTag() && (!item->m_bIsFolder || node == NODE_TYPE_TITLE_TVSHOWS)) { if (info && info->Content() == CONTENT_TVSHOWS) { if(item->GetVideoInfoTag()->m_iBookmarkId != -1 && item->GetVideoInfoTag()->m_iBookmarkId != 0) { buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405); } } buttons.Add(CONTEXT_BUTTON_DELETE, 646); } // this should ideally be non-contextual (though we need some context for non-tv show node I guess) CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) { if (node != NODE_TYPE_TITLE_TVSHOWS) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); } else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } //Set default and/or clear default NODE_TYPE nodetype = CVideoDatabaseDirectory::GetDirectoryType(item->m_strPath); if (!item->IsParentFolder() && !m_vecItems->m_strPath.Equals("special://videoplaylists/") && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TVSHOWS_OVERVIEW || nodetype == NODE_TYPE_MOVIES_OVERVIEW || nodetype == NODE_TYPE_MUSICVIDEOS_OVERVIEW)) { if (!item->m_strPath.Equals(g_settings.m_defaultVideoLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultVideoLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } if ((CVideoDatabaseDirectory::GetDirectoryChildType(item->m_strPath) == NODE_TYPE_TITLE_MOVIES || CVideoDatabaseDirectory::GetDirectoryChildType(item->m_strPath) == NODE_TYPE_TITLE_MUSICVIDEOS || item->m_strPath.Equals("videodb://1/") || item->m_strPath.Equals("videodb://4/") || item->m_strPath.Equals("videodb://6/")) && nodetype != NODE_TYPE_RECENTLY_ADDED_MOVIES) { buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched } if (m_vecItems->m_strPath.Equals("special://videoplaylists/")) { // video playlists, file operations are allowed if (!item->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } if (item->IsPlugin() || item->m_strPath.Left(9).Equals("script://") || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } } CGUIWindowVideoBase::GetNonContextButtons(itemNumber, buttons); }
void CGUIWindowMusicSongs::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item) { // are we in the playlists location? bool inPlaylists = m_vecItems->m_strPath.Equals(CUtil::MusicPlaylistsLocation()) || m_vecItems->m_strPath.Equals("special://musicplaylists/"); if (m_vecItems->IsVirtualDirectoryRoot()) { // get the usual music shares, and anything for all media windows CGUIDialogContextMenu::GetContextButtons("music", item, buttons); // enable Rip CD an audio disc if (CDetectDVDMedia::IsDiscInDrive() && item->IsCDDA()) { // those cds can also include Audio Tracks: CDExtra and MixedMode! CCdInfo *pCdInfo = CDetectDVDMedia::GetCdInfo(); if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)) buttons.Add(CONTEXT_BUTTON_RIP_CD, 600); } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); } else { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); if (item->GetPropertyBOOL("pluginreplacecontextitems")) return; if (!item->IsPlayList()) { if (item->IsAudio() && !item->IsLastFM() && !item->IsShoutCast()) buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); // Song Info else if (!item->IsParentFolder() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Left(3).Equals("new") && item->m_bIsFolder) { #if 0 if (m_musicdatabase.GetAlbumIdByPath(item->m_strPath) > -1) #endif buttons.Add(CONTEXT_BUTTON_INFO, 13351); // Album Info } } // enable Rip CD Audio or Track button if we have an audio disc if (CDetectDVDMedia::IsDiscInDrive() && m_vecItems->IsCDDA()) { // those cds can also include Audio Tracks: CDExtra and MixedMode! CCdInfo *pCdInfo = CDetectDVDMedia::GetCdInfo(); if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)) buttons.Add(CONTEXT_BUTTON_RIP_TRACK, 610); } // enable CDDB lookup if the current dir is CDDA if (CDetectDVDMedia::IsDiscInDrive() && m_vecItems->IsCDDA() && (g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_CDDB, 16002); } if (!item->IsParentFolder() && !item->IsReadOnly()) { // either we're at the playlist location or its been explicitly allowed if (inPlaylists || g_guiSettings.GetBool("filelists.allowfiledeletion")) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } } // Add the scan button(s) CGUIDialogMusicScan *pScanDlg = (CGUIDialogMusicScan *)m_gWindowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); if (g_guiSettings.GetBool("musiclibrary.enabled") && pScanDlg) { if (pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (!inPlaylists && !m_vecItems->IsInternetStream() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Equals("add") && !item->IsParentFolder() && (g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_SCAN, 13352); } } } if (!m_vecItems->IsVirtualDirectoryRoot()) buttons.Add(CONTEXT_BUTTON_SWITCH_MEDIA, 523); CGUIWindowMusicBase::GetNonContextButtons(buttons); }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetPropertyBOOL("pluginreplacecontextitems")) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->m_strPath); if (!item) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } else if (m_vecItems->m_strPath.Equals("sources://video/")) { // get the usual shares CGUIDialogContextMenu::GetContextButtons("video", item, buttons); // add scan button somewhere here CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning if (!item->IsDVD() && item->m_strPath != "add" && (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { CVideoDatabase database; database.Open(); ADDON::ScraperPtr info = database.GetScraperForPath(item->m_strPath); if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) { if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath()) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } if (info && (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning()))) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } else { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); if (info && info->Content() == CONTENT_TVSHOWS) buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352); else if (info && info->Content() == CONTENT_MUSICVIDEOS) buttons.Add(CONTEXT_BUTTON_INFO,20393); else if (!item->m_bIsFolder && !item->m_strPath.Left(19).Equals("newsmartplaylist://")) buttons.Add(CONTEXT_BUTTON_INFO, 13346); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strArtist.IsEmpty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(item->GetVideoInfoTag()->m_strArtist) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 && item->GetVideoInfoTag()->m_strArtist.size() > 0 && item->GetVideoInfoTag()->m_strTitle.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(item->GetVideoInfoTag()->m_strArtist, item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { // can we update the database? if (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (node == NODE_TYPE_TITLE_TVSHOWS) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_TVSHOW, 13349); } if (!item->IsPlugin() && !item->IsLiveTV() && !item->IsAddonsPath() && item->m_strPath != "sources://video/" && item->m_strPath != "special://videoplaylists/") { if (item->m_bIsFolder) { // Have both options for folders since we don't know whether all childs are watched/unwatched buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } else { if (item->GetOverlayImage().Equals("OverlayWatched.png")) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } } if ((node == NODE_TYPE_TITLE_TVSHOWS) || (item->IsVideoDb() && item->HasVideoInfoTag() && !item->m_bIsFolder)) { buttons.Add(CONTEXT_BUTTON_EDIT, 16105); //Edit Title } if (m_database.HasContent(VIDEODB_CONTENT_TVSHOWS) && item->HasVideoInfoTag() && !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode == -1 && item->GetVideoInfoTag()->m_strArtist.IsEmpty() && item->GetVideoInfoTag()->m_iDbId >= 0) // movie entry { if (m_database.IsLinkedToTvshow(item->GetVideoInfoTag()->m_iDbId)) buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE,20385); buttons.Add(CONTEXT_BUTTON_LINK_MOVIE,20384); } if (node == NODE_TYPE_SEASONS && item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_SET_SEASON_THUMB, 20371); if (item->m_strPath.Left(14).Equals("videodb://1/7/") && item->m_strPath.size() > 14 && item->m_bIsFolder) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16105); buttons.Add(CONTEXT_BUTTON_SET_MOVIESET_THUMB, 20435); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder) { if (m_vecItems->m_strPath.Left(11).Equals("videodb://3")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } if (item->IsVideoDb() && item->HasVideoInfoTag() && (!item->m_bIsFolder || node == NODE_TYPE_TITLE_TVSHOWS)) { if (info && info->Content() == CONTENT_TVSHOWS) { if(item->GetVideoInfoTag()->m_iBookmarkId != -1 && item->GetVideoInfoTag()->m_iBookmarkId != 0) { buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405); } } buttons.Add(CONTEXT_BUTTON_DELETE, 646); } // this should ideally be non-contextual (though we need some context for non-tv show node I guess) CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) { if (node != NODE_TYPE_TITLE_TVSHOWS) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); } else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) { // non-video db items, file operations are allowed if (g_guiSettings.GetBool("filelists.allowfiledeletion") && CUtil::SupportsFileOperations(item->m_strPath)) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders if (item->m_bIsFolder && !item->IsPlayList() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath()) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } } if (item->IsPlugin() || item->m_strPath.Left(9).Equals("script://") || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } } CGUIWindowVideoBase::GetNonContextButtons(itemNumber, buttons); }
bool CDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, CStdString strMask /*=""*/, bool bUseFileDirectories /* = true */, bool allowPrompting /* = false */, DIR_CACHE_TYPE cacheDirectory /* = DIR_CACHE_ONCE */, bool extFileInfo /* = true */, bool allowThreads /* = false */, bool getHidden /* = false */) { try { CStdString realPath = URIUtils::SubstitutePath(strPath); boost::shared_ptr<IDirectory> pDirectory(CFactoryDirectory::Create(realPath)); if (!pDirectory.get()) return false; // check our cache for this path if (g_directoryCache.GetDirectory(strPath, items, cacheDirectory == DIR_CACHE_ALWAYS)) items.SetPath(strPath); else { // need to clear the cache (in case the directory fetch fails) // and (re)fetch the folder if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.ClearDirectory(strPath); pDirectory->SetAllowPrompting(allowPrompting); pDirectory->SetCacheDirectory(cacheDirectory); pDirectory->SetUseFileDirectories(bUseFileDirectories); pDirectory->SetExtFileInfo(extFileInfo); bool result = false, cancel = false; while (!result && !cancel) { if (g_application.IsCurrentThread() && allowThreads && !URIUtils::IsSpecial(strPath)) { CSingleExit ex(g_graphicsContext); CGetDirectory get(pDirectory, realPath); if(!get.Wait(TIME_TO_BUSY_DIALOG)) { CGUIDialogBusy* dialog = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); dialog->Show(); while(!get.Wait(10)) { CSingleLock lock(g_graphicsContext); if(dialog->IsCanceled()) { cancel = true; break; } g_windowManager.ProcessRenderLoop(false); } if(dialog) dialog->Close(); } result = get.GetDirectory(items); } else { items.SetPath(strPath); result = pDirectory->GetDirectory(realPath, items); } if (!result) { if (!cancel && g_application.IsCurrentThread() && pDirectory->ProcessRequirements()) continue; CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; } } // cache the directory, if necessary if (cacheDirectory != DIR_CACHE_NEVER) g_directoryCache.SetDirectory(strPath, items, pDirectory->GetCacheType(strPath)); } // now filter for allowed files pDirectory->SetMask(strMask); for (int i = 0; i < items.Size(); ++i) { CFileItemPtr item = items[i]; // TODO: we shouldn't be checking the gui setting here; // callers should use getHidden instead if ((!item->m_bIsFolder && !pDirectory->IsAllowed(item->GetPath())) || (item->GetPropertyBOOL("file:hidden") && !getHidden && !g_guiSettings.GetBool("filelists.showhidden"))) { items.Remove(i); i--; // don't confuse loop } } // Should any of the files we read be treated as a directory? // Disable for database folders, as they already contain the extracted items if (bUseFileDirectories && !items.IsMusicDb() && !items.IsVideoDb() && !items.IsSmartPlayList()) FilterFileDirectories(items, strMask); return true; } #ifndef _LINUX catch (const win32_exception &e) { e.writelog(__FUNCTION__); } #endif catch (...) { CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__); } CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, strPath.c_str()); return false; }