Beispiel #1
0
ScanFoldersModel::PathStatus ScanFoldersModel::addPath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath, bool addToFSWatcher)
{
    QDir watchDir(watchPath);
    if (!watchDir.exists()) return DoesNotExist;
    if (!watchDir.isReadable()) return CannotRead;

    const QString &canonicalWatchPath = watchDir.canonicalPath();
    if (findPathData(canonicalWatchPath) != -1) return AlreadyInList;

    QDir downloadDir(downloadPath);
    const QString &canonicalDownloadPath = downloadDir.canonicalPath();

    if (!m_fsWatcher) {
        m_fsWatcher = new FileSystemWatcher(this);
        connect(m_fsWatcher, &FileSystemWatcher::torrentsAdded, this, &ScanFoldersModel::addTorrentsToSession);
    }

    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    m_pathList << new PathData(Utils::Fs::toNativePath(canonicalWatchPath), downloadType, Utils::Fs::toNativePath(canonicalDownloadPath));
    endInsertRows();

    // Start scanning
    if (addToFSWatcher)
        m_fsWatcher->addPath(canonicalWatchPath);
    return Ok;
}
Beispiel #2
0
Settings::Settings()
 : m_settingsMain( new QSettings(QSettings::IniFormat, QSettings::UserScope, "KDE", "Installer") )

{
    m_settings = new QSettings(installDir()+"/etc/installer.ini",QSettings::IniFormat);
    QString version = m_settings->value("version", "").toString();
    // update to current version
    if (version.isEmpty()) // version 1
    {
        m_settings->setValue("version", SETTINGS_VERSION);
        setPackageManagerMode(m_settings->value("DeveloperMode",false).toBool());
        m_settings->remove("DeveloperMode");
        m_settings->sync();
    }
    else if (version != SETTINGS_VERSION)
    {
        qCritical() << "unknown settings version" << version << "found"; 
    }

#ifdef DEBUG
    qDebug() << "installDir:" << installDir();
    qDebug() << "downloadDir:" << downloadDir();
    qDebug() << "showTitlePage:" << showTitlePage();
    qDebug() << "createStartMenuEntries:" << createStartMenuEntries();
    qDebug() << "isFirstRun" << isFirstRun();
    qDebug() << "proxyMode" << proxyMode();
    qDebug() << "proxyHost" << proxyHost();
    qDebug() << "proxyPort" << proxyPort();
#endif
#ifndef Q_OS_WIN
//     setProxyMode(Environment);
#endif
}
bool RepositoryProfile::deletePackageFromDisk ( const QString & rpmName, const bool recomputeStatus )
{
  bool success = packages[rpmName].deleteLocalFiles ( downloadDir() );

  if ( recomputeStatus )
    computeProfileStatus();

  return success;
}
void RepositoryProfile::packagesUpdated ( const bool removeOldVersions )
{
  QHash<QString, Package>::iterator packageIter;

  for ( packageIter = packages.begin(); packageIter != packages.end(); ++packageIter ) {
    if ( packageIter.value().packageStatus() == UPDATE || packageIter.value().packageStatus() == AVAILABLE )
      packageIter.value().packageUpdated ( downloadDir(), removeOldVersions );
  }

  computeProfileStatus();
}
Beispiel #5
0
QStringList FileManager::getISOFiles()
{
    QStringList ret;
    QDir downloadDir(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));

    QFileInfoList fileList = downloadDir.entryInfoList();
    for(int i = 0; i < fileList.count(); i++) {
        if (fileList[i].fileName().endsWith(".iso")) {
            ret.append(fileList[i].fileName());
        }
    }
    return ret;
}
Beispiel #6
0
ScanFoldersModel::PathStatus ScanFoldersModel::updatePath(const QString &watchPath, const PathType &downloadType, const QString &downloadPath)
{
    QDir watchDir(watchPath);
    const QString &canonicalWatchPath = watchDir.canonicalPath();
    int row = findPathData(canonicalWatchPath);
    if (row == -1) return DoesNotExist;

    QDir downloadDir(downloadPath);
    const QString &canonicalDownloadPath = downloadDir.canonicalPath();

    m_pathList.at(row)->downloadType = downloadType;
    m_pathList.at(row)->downloadPath = Utils::Fs::toNativePath(canonicalDownloadPath);

    return Ok;
}
void RepositoryProfile::refreshStatus()
{
  if ( lister->isRunning() ) // thread is running do nothing
    return;

  lister->setArchitectures ( PackageMetaData::archStringList ( architecures() ) );

  lister->setDatabasePath ( databaseFile() );

  lister->setRepoName ( profileName() );

  lister->setDownloadPath ( downloadDir() );

  lister->start();
}
Beispiel #8
0
void Settings::setDownloadDir(const QString &dir, bool persistent)
{
    QDir d(dir);

    if (d.absolutePath() != downloadDir())
    {
        if (!persistent)
            m_downloadDir = QDir::toNativeSeparators(d.absolutePath());
        else
        {
            m_settingsMain->setValue("tempdir", QDir::toNativeSeparators(d.absolutePath()));
            m_settingsMain->sync();
        }
    }
    emit downloadDirChanged(QDir::toNativeSeparators(d.absolutePath()));
}
Beispiel #9
0
FileDialog::FileDialog( QWidget *parent, const QString &caption,
					   const QString &directory, const QString &filter ) :
	QFileDialog( parent, caption, directory, filter )
{
#if (QT_VERSION >= 0x040806 && QT_VERSION < 0x050000) || QT_VERSION > 0x050200
	setOption( QFileDialog::DontUseCustomDirectoryIcons );
#endif

	// Add additional locations to the sidebar
	QList<QUrl> urls = sidebarUrls();
#if QT_VERSION >= 0x050000
	urls << QUrl::fromLocalFile( QStandardPaths::writableLocation( QStandardPaths::DesktopLocation ) );
#else
	urls << QUrl::fromLocalFile( QDesktopServices::storageLocation( QDesktopServices::DesktopLocation ) );
#endif
	// Find downloads directory
	QDir downloadDir( QDir::homePath() + "/Downloads" );
	if ( ! downloadDir.exists() )
#if QT_VERSION >= 0x050000
		downloadDir = QStandardPaths::writableLocation( QStandardPaths::DownloadLocation );
#else
		downloadDir = QDesktopServices::storageLocation( QDesktopServices::DocumentsLocation ) + "/Downloads";
#endif
	if ( downloadDir.exists() )
		urls << QUrl::fromLocalFile( downloadDir.absolutePath() );

#if QT_VERSION >= 0x050000
	urls << QUrl::fromLocalFile( QStandardPaths::writableLocation( QStandardPaths::MusicLocation ) );
#else
	urls << QUrl::fromLocalFile( QDesktopServices::storageLocation( QDesktopServices::MusicLocation ) );
#endif
	urls << QUrl::fromLocalFile( ConfigManager::inst()->workingDir() );

	// Add `/Volumes` directory on OS X systems, this allows the user to browse
	// external disk drives.
#ifdef LMMS_BUILD_APPLE
	QDir volumesDir( QDir("/Volumes") );
	if ( volumesDir.exists() )
		urls << QUrl::fromLocalFile( volumesDir.absolutePath() );
#endif

	setSidebarUrls(urls);
}
void GetSequenceByIdDialog::accept() {
    if(dir.isEmpty()) {
        return;
    }

    QDir downloadDir(dir);
    if (!downloadDir.exists()) {
        if (QMessageBox::Yes == QMessageBox::question(this,
            windowTitle(), tr("Directory doesn't exist. Do you want to create it?"),
            QMessageBox::Yes, QMessageBox::No))
        {
            downloadDir.mkpath(dir);
        } else {
            return;
        }
    }

    addToProject = addBox->isChecked();
    QDialog::accept();
}
Beispiel #11
0
bool CUpdateWizard::SetLocalFile()
{
	wxString filename = m_urlFile;
	int pos = filename.Find('/', true);
	if (pos != -1)
		filename = filename.Mid(pos + 1);

	const CLocalPath defaultDownloadDir = GetDownloadDir();
	CLocalPath downloadDir(COptions::Get()->GetOption(OPTION_UPDATECHECK_DOWNLOADDIR));
	if (downloadDir.empty() || !downloadDir.Exists())
		downloadDir = defaultDownloadDir;

	const int flags = wxFD_SAVE | wxFD_OVERWRITE_PROMPT;

	const wxString& ext = filename.Right(4);
	wxString type;
	if (ext == _T(".exe"))
		type = _("Executable");
	if (ext == _T(".bz2"))
		type = _("Archive");
	else
		type = _("Package");

	wxString filter = wxString::Format(_T("%s (*%s)|*%s"), type.c_str(), ext.c_str(), ext.c_str());

	wxFileDialog dialog(this, _("Select download location for package"), downloadDir.GetPath(), filename, filter, flags);
	if (dialog.ShowModal() != wxID_OK)
		return false;

	wxString targetFile;
	if (!downloadDir.SetPath(dialog.GetPath(), &targetFile))
	{
		wxMessageBox(_("Error, file name cannot be parsed."));
		return false;
	}

	if (downloadDir != defaultDownloadDir)
		COptions::Get()->SetOption(OPTION_UPDATECHECK_DOWNLOADDIR, downloadDir.GetPath());
	else
		COptions::Get()->SetOption(OPTION_UPDATECHECK_DOWNLOADDIR, _T(""));

	{
		wxLogNull log;
		wxRemoveFile(downloadDir.GetPath() + targetFile);
	}

	if (wxFileName::FileExists(downloadDir.GetPath() + targetFile))
	{
		wxMessageBox(_("Error, local file exists but cannot be removed"));
		return false;
	}

	const wxString file = downloadDir.GetPath() + targetFile + _T(".tmp");
	m_localFile = file;

	int i = 1;
	while (wxFileName::FileExists(m_localFile))
	{
		i++;
		m_localFile = file + wxString::Format(_T("%d"), i);
	}

	return true;
}