Esempio n. 1
0
void OnlineDevice::copySongTo(const Song &s, const QString &musicPath, bool overwrite, bool copyCover)
{
    Q_UNUSED(copyCover)

    jobAbortRequested=false;
    QString baseDir=MPDConnection::self()->getDetails().dir;
    QString dest(baseDir+musicPath);
    if (!overwrite && (QFile::exists(dest) || MpdLibraryModel::self()->songExists(s))) {
        emit actionStatus(SongExists);
        return;
    }

    overWrite=overwrite;
    lastProg=-1;
    currentDestFile=baseDir+musicPath;
    currentSong=s;

    QDir dir(Utils::getDir(dest));
    if (!dir.exists() && !Utils::createWorldReadableDir(dir.absolutePath(), baseDir)) {
        emit actionStatus(DirCreationFaild);
        return;
    }

    job=NetworkAccessManager::self()->get(QUrl(s.file));
    connect(job, SIGNAL(finished()), SLOT(downloadFinished()));
    connect(job, SIGNAL(downloadProgress(qint64,qint64)), SLOT(downloadProgress(qint64,qint64)));
}
Esempio n. 2
0
void StatusMenu::setStatus(XMPP::Status::Type status)
{
	if (currentStatus_ == status)
		return;

	currentStatus_ = status;
	foreach(QAction* action, actions())
		action->setChecked(actionStatus(action) == status);
}
Esempio n. 3
0
void OnlineDevice::downloadFinished()
{
    NetworkJob *reply=qobject_cast<NetworkJob *>(sender());
    if (!reply) {
        return;
    }

    reply->deleteLater();

    if (reply!=job) {
        return;
    }

    if (reply->ok()) {
        if (overWrite && QFile::exists(currentDestFile)) {
            QFile::remove(currentDestFile);
        }

        QFile f(currentDestFile);
        if (f.open(QIODevice::WriteOnly)) {
            f.write(reply->readAll());

            currentSong.file=currentDestFile.mid(MPDConnection::self()->getDetails().dir.length());
            QString origPath;
            if (MPDConnection::self()->isMopdidy()) {
                origPath=currentSong.file;
                currentSong.file=Song::encodePath(currentSong.file);
            }
            Utils::setFilePerms(currentDestFile);
//            MusicLibraryModel::self()->addSongToList(currentSong);
//            DirViewModel::self()->addFileToList(origPath.isEmpty() ? currentSong.file : origPath,
//                                                origPath.isEmpty() ? QString() : currentSong.file);
            emit actionStatus(Ok);
        } else {
            emit actionStatus(WriteFailed);
        }
    } else {
        emit actionStatus(DownloadFailed);
    }
}
Esempio n. 4
0
void StatusMenu::actionActivated()
{
	QAction* action = static_cast<QAction*>(sender());
	setStatus(actionStatus(action));
	emit statusChanged(currentStatus_);
}