Exemple #1
0
void Player::start() {
    //Make sure we don't re-start a running process.
    if (this->isRunning()) {
        this->logError("Attempting to start a running process.");
        return;
    }

    //Launch a new bot process.
    m_process = new QProcess(this);
    QString launchCommand(m_launchCommand.c_str());
    m_process->start(launchCommand);

    if (m_process->waitForStarted(1000)) {
        this->logMessage("Bot process started.");

        //Make some signal/slot connections.
        QObject::connect(m_process, SIGNAL(readyReadStandardOutput()),
                         this, SLOT(readStdOut()));
        QObject::connect(m_process, SIGNAL(readyReadStandardError()),
                         this, SLOT(readStdErr()));
        QObject::connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)),
                         this, SLOT(onProcessFinished(int,QProcess::ExitStatus)));

    } else {
void TaskProcess::run() {
    started = true;
    if((document.metadata) && (document.type == TaskProcessTypeMetadata)) {
        document.metadata->status = DocumentStatusProcessing;
        emit(updateList(this, FeedItemBaseTypeProcessingStart));
        emit(updateList(this, tr("<span style='font-family: Calibri, Arial; font-size: 11px; color: #A1A5A7'>Starting analysis of <span style='color: #F5F8FA'>%1</span></span>").arg(name)));
        QDir().mkpath(Global::pathCurrent.absoluteFilePath() + "/rekall_cache");
        bool shouldSendFinishedSignal = true;

        if((document.metadata) && (document.needCompleteScan) && (document.metadata->getType(document.version) == DocumentTypeWeb)) {
            thumbFilepath = Global::cacheFile("thumb", QCryptographicHash::hash(qPrintable(document.metadata->getMetadata("Rekall", "URL", document.version).toString()), QCryptographicHash::Sha1).toHex().toUpper());
            thumbFilename = thumbFilepath + ".jpg";
            if(!QFile(thumbFilename).exists()) {
                emit(updateList(this, tr("<span style='font-family: Calibri, Arial; font-size: 11px; color: #A1A5A7'>Loading web page <span style='color: #F5F8FA'>%1</span></span>").arg(name)));
                emit(analyseWebContent(this));
                shouldSendFinishedSignal = false;
            }
        }
        else {
            if((document.metadata) && (document.needCompleteScan) && (document.metadata->getType(document.version) == DocumentTypePeople)) {
                //People
                QList<Person*> persons = Person::fromFile(file.absoluteFilePath());
                foreach(Person *person, persons)
                    Global::currentProject->addPerson(person);
            }

            thumbFilepath = Global::cacheFile("thumb", file);
            thumbFilename = thumbFilepath + ".jpg";

            //Hash
            if(file.exists()) {
                emit(updateList(this, tr("<span style='font-family: Calibri, Arial; font-size: 11px; color: #A1A5A7'>Calculating hash of <span style='color: #F5F8FA'>%1</span></span>").arg(name)));
                QString documentHash = Global::getFileHash(file);
                if((document.metadata) && (documentHash != document.metadata->getMetadata("File", "Hash", document.version).toString())) {
                    document.metadata->setMetadata("File", "Hash", documentHash, document.version);
                    document.needCompleteScan = true;
                }
            }

            //Extract meta with ExifTool
            if(document.needCompleteScan) {
                qreal durationInSamples = 0;
                emit(updateList(this, tr("<span style='font-family: Calibri, Arial; font-size: 11px; color: #A1A5A7'>Extracting metadatas of <span style='color: #F5F8FA'>%1</span></span>").arg(name)));
                QStringList exifDatas = launchCommand(TaskProcessData(Global::pathApplication.absoluteFilePath() + "/tools/exiftool", Global::pathApplication.absoluteFilePath() + "/tools", QStringList() << "−c" << "%+.6f" << "-d" << "%Y:%m:%d %H:%M:%S" << "-G" << file.absoluteFilePath())).second.split("\n");
                foreach(const QString &exifData, exifDatas) {
                    QPair<QString, QPair<QString,QString> > meta = Global::seperateMetadataAndGroup(exifData);
                    if((!meta.first.isEmpty()) && (!meta.second.first.isEmpty()) && (!meta.second.second.isEmpty())) {
                        if(document.metadata) {
                            if(meta.second.first == "File Type")
                                document.metadata->setMetadata(meta.first, meta.second.first, meta.second.second.toUpper(), document.version);
                            else if((meta.second.first == "File Inode Change Date/Time") || (meta.second.first == "File Modification Date/Time") || (meta.second.first == "File Creation Date/Time") || (meta.second.first == "File Access Date/Time")) {}
                            else if((meta.first != "ExifTool") && (!meta.second.second.contains("use -b option to extract"))) {
                                QString metaTitle = meta.second.first;
                                if(metaTitle == "GPS Position")
                                    metaTitle = "GPS Coordinates";
                                document.metadata->setMetadata(meta.first, metaTitle, meta.second.second, document.version);
                            }
                            if((meta.second.first.toLower().contains("duration")) && (!(meta.second.first.toLower().contains("value")))) {
                                qreal duration = Global::getDurationFromString(meta.second.second);
                                if(duration)
                                    document.metadata->setMetadata("Rekall", "Media Duration", duration, document.version);
                            }
                            if(meta.second.first.toLower().contains("num sample frames"))
                                durationInSamples = meta.second.second.toDouble();
                            if((meta.second.first.toLower().contains("sample rate")) && (durationInSamples > 0))
                                document.metadata->setMetadata("Rekall", "Media Duration", durationInSamples / meta.second.second.toDouble(), document.version);
                            if(meta.second.first.toLower().contains("author"))
                                document.metadata->setMetadata("Rekall", "Author", meta.second.second, document.version);
                            if(meta.second.first.toLower().contains("file size"))
                                document.metadata->setMetadata("Rekall", "Size",   meta.second.second, document.version);
                            if(meta.second.first.toLower().contains("keywords"))
                                document.metadata->addKeyword(meta.second.second, document.version);
                        }
                    }
                }
            }