// \brief Show CGUIDialogMediaSource dialog and prompt for a new media source. // \return True if the media source is added, false otherwise. bool CGUIDialogMediaSource::ShowAndAddMediaSource(const CStdString &type) { CGUIDialogMediaSource *dialog = (CGUIDialogMediaSource *)g_windowManager.GetWindow(WINDOW_DIALOG_MEDIA_SOURCE); if (!dialog) return false; dialog->Initialize(); dialog->SetShare(CMediaSource()); dialog->SetTypeOfMedia(type); dialog->DoModal(); bool confirmed(dialog->IsConfirmed()); if (confirmed) { // yay, add this share CMediaSource share; unsigned int i,j=2; bool bConfirmed=false; VECSOURCES* pShares = g_settings.GetSourcesFromType(type); CStdString strName = dialog->m_name; while (!bConfirmed) { for (i=0; i<pShares->size(); ++i) { if ((*pShares)[i].strName.Equals(strName)) break; } if (i < pShares->size()) // found a match - try next strName.Format("%s (%i)",dialog->m_name,j++); else bConfirmed = true; } share.FromNameAndPaths(type, strName, dialog->GetPaths()); if (dialog->m_paths->Size() > 0) { share.m_strThumbnailImage = dialog->m_paths->Get(0)->GetThumbnailImage(); } g_settings.AddShare(type, share); if (type == "video") { if (dialog->m_bRunScan) { CGUIDialogVideoScan* scanner = (CGUIDialogVideoScan*)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (scanner) scanner->StartScanning(share.strPath, true); } } } dialog->m_paths->Clear(); return confirmed; }
// \brief Show CGUIDialogMediaSource dialog and prompt for a new media source. // \return True if the media source is added, false otherwise. bool CGUIDialogMediaSource::ShowAndAddMediaSource(const CStdString &type) { CGUIDialogMediaSource *dialog = (CGUIDialogMediaSource *)g_windowManager.GetWindow(WINDOW_DIALOG_MEDIA_SOURCE); if (!dialog) return false; dialog->Initialize(); dialog->SetShare(CMediaSource()); dialog->SetTypeOfMedia(type); dialog->DoModal(); bool confirmed(dialog->IsConfirmed()); if (confirmed) { // yay, add this share CMediaSource share; unsigned int i,j=2; bool bConfirmed=false; VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(type); CStdString strName = dialog->m_name; while (!bConfirmed) { for (i=0;i<pShares->size();++i) { if ((*pShares)[i].strName.Equals(strName)) break; } if (i < pShares->size()) // found a match - try next strName = StringUtils::Format("%s (%i)", dialog->m_name.c_str(), j++); else bConfirmed = true; } share.FromNameAndPaths(type, strName, dialog->GetPaths()); if (dialog->m_paths->Size() > 0) { share.m_strThumbnailImage = dialog->m_paths->Get(0)->GetArt("thumb"); } CMediaSourceSettings::Get().AddShare(type, share); } dialog->m_paths->Clear(); return confirmed; }
bool CGUIDialogMediaSource::ShowAndEditMediaSource(const CStdString &type, const CMediaSource &share) { CStdString strOldName = share.strName; CGUIDialogMediaSource *dialog = (CGUIDialogMediaSource *)g_windowManager.GetWindow(WINDOW_DIALOG_MEDIA_SOURCE); if (!dialog) return false; dialog->Initialize(); dialog->SetShare(share); dialog->SetTypeOfMedia(type, true); dialog->DoModal(); bool confirmed(dialog->IsConfirmed()); if (confirmed) { // yay, add this share unsigned int i,j=2; bool bConfirmed=false; VECSOURCES* pShares = g_settings.GetSourcesFromType(type); CStdString strName = dialog->m_name; while (!bConfirmed) { for (i=0; i<pShares->size(); ++i) { if ((*pShares)[i].strName.Equals(strName)) break; } if (i < pShares->size() && (*pShares)[i].strName != strOldName) // found a match - try next strName.Format("%s (%i)",dialog->m_name,j++); else bConfirmed = true; } CMediaSource newShare; newShare.FromNameAndPaths(type, strName, dialog->GetPaths()); g_settings.UpdateShare(type, strOldName, newShare); } dialog->m_paths->Clear(); return confirmed; }