Logo Search packages:      
Sourcecode: bangarang version File versions  Download package

void MediaIndexer::updatePlaybackInfo ( const QString &  url,
bool  incrementPlayCount,
const QDateTime &  playDateTime 
)

Update the playback time and/or play count for the specified url.

Parameters:
url url of media item to updateInfo
incrementPlayCount if true, the play count will be incremented
playDateTime DateTime of playback

Definition at line 133 of file mediaindexer.cpp.

References finished(), percentComplete(), and started().

{
    if (m_nepomukInited && !url.isEmpty()) {
        QString filename = QString("bangarang/%1.jb")
        .arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz"));
        QString path = KStandardDirs::locateLocal("data", filename, true);
        QFile file(path);
        if (!file.open(QIODevice::WriteOnly)) {
            return;
        }
        QTextStream out(&file);
        out << "[" << url << "]\n";
        out << "lastPlayed = " << playDateTime.toString("yyyyMMddhhmmss") << "\n";
        if (incrementPlayCount) {
            int playCount = 0;
            Nepomuk::Resource res(url);
            if (res.exists()) {
                playCount = res.property(MediaVocabulary().playCount()).toInt();
            }   
            playCount = playCount + 1;
            out << "playCount = " << playCount << "\n";
        }
        out << "\n" << "\n";
        KProcess * writer = new KProcess();
        writer->setProgram("bangarangnepomukwriter", QStringList(path));
        writer->setWorkingDirectory(KStandardDirs::locateLocal("data", "bangarang/", true));
        writer->setOutputChannelMode(KProcess::OnlyStdoutChannel);
        connect(writer, SIGNAL(started()), this, SIGNAL(started()));
        connect(writer, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
        connect(writer, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
        m_writers.append(writer);
        writer->start();
        m_state = Running;
        emit percentComplete(0);
    }
}


Generated by  Doxygen 1.6.0   Back to index