Example #1
0
FileDownloader::FileDownloader(QUrl imageUrl, QObject *parent, QString filePath) :
    QObject(parent)
{
    shouldSave = false;
    connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
                SLOT(fileDownloaded(QNetworkReply*)));

    if(filePath != "")
    {

        if (QFile::exists(filePath)) {
                QFile::remove(filePath);

        }
        else
        {
            QFileInfo fileInf(filePath);
            QDir dir("");
            dir.mkpath(fileInf.absolutePath());
        }

        this->writeToFile = new QFile(filePath);
        this->writeToFile->open(QIODevice::ReadWrite);
        this->shouldSave = true;
    }

    QNetworkRequest request(imageUrl);
   this->reply =  m_WebCtrl.get(request);
    connect(this->reply, SIGNAL(downloadProgress(qint64,qint64)),
                SLOT(downloadProgress(qint64,qint64)));
    connect(this->reply, SIGNAL(readyRead()),
                this, SLOT(readyRead()));
}
Example #2
0
void QHexEdit::dragEnterEvent(QDragEnterEvent *event)
{
    if (!event->mimeData()->hasUrls())
    {
        return;
    }
    QString path = event->mimeData()->urls().at(0).toLocalFile();
    QFileInfo fileInf(path);
    event->setAccepted(fileInf.isFile());
}
void QQmlNetwork::startNextDownload()
{
    if (downloadQueue.isEmpty()) {
//        qDebug() << downloadedCount << " " << totalCount << "files downloaded successfully\n";
        emit finished();
        return;
    }
    QUrl url = downloadQueue.dequeue();
    QFileInfo fileInf(url.toString());
    QString fileName = QString("%1%2").arg(m_path).arg(fileInf.fileName());




    setSavedFileName(fileName);
//    qDebug() << fileName;
    output.setFileName(fileName);

    if (output.exists()){
        if(output.remove())
        {
            qDebug() << "removed the old file";
        }
    }



    if (!output.open(QIODevice::WriteOnly)) {
        error("Problem opening save file for download");
        startNextDownload();
        return;
    }

    qDebug() << "GOING TO TRY AND DOWNLOAD " << url;

    QNetworkRequest request(url);
    currentDownload = manager.get(request);

    // FIX ME check for redirection
    connect(&manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(checkRedirection(QNetworkReply*)));

    connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)), SLOT(downloadProgress(qint64,qint64)));
    connect(currentDownload, SIGNAL(finished()), SLOT(downloadFinished()));
    connect(currentDownload, SIGNAL(readyRead()), SLOT(downloadReadyRead()));
    connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(setNetworkError(QNetworkReply::NetworkError)));


    downloadTime.start();

}
Example #4
0
/*!
 * \qmlsignal Downloader::startNextDownload()
 * Used if you want to download multiple files
 */
void Downloader::startNextDownload()
{
    if (downloadQueue.isEmpty()) {
        qDebug() << downloadedCount << " " << totalCount << "files downloaded successfully\n";
        emit started(false);
        emit finished();
        return;
    }

    QUrl url = downloadQueue.dequeue();
    QFileInfo fileInf(url.toString());
    QString fileName = QString("%1%2").arg(mPath).arg("UbuntuCodeofConduct.txt");


//    QString filename = saveFileName(fileName);

    setSavedFileName(fileName);



    qDebug() << fileName;

    output.setFileName(fileName);
    if (!output.open(QIODevice::WriteOnly)) {
        qDebug() <<  "Problem opening save file for download";
        startNextDownload();
        return;
    }

    QNetworkRequest request(url);
    currentDownload = manager.get(request);
    connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)),
            SLOT(downloadProgress(qint64,qint64)));
    connect(currentDownload, SIGNAL(finished()),
            SLOT(downloadFinished()));
    connect(currentDownload, SIGNAL(readyRead()),
            SLOT(downloadReadyRead()));

    // prepare the output
    qDebug () << "Downloading " <<  url.toEncoded() << "........";
    downloadTime.start();
}
void ChaserTargetInteractWidget::loadTargetTrajectory() {
  
  QString fileName = QFileDialog::getOpenFileName(
    this, 
    tr("Open Target Trajectory..."),
    last_used_path,
    tr("SE(3) Trajectories (*.rkx *.rkb *.pbuf)"));
  
  if( fileName == tr("") )
    return;
  
  QFileInfo fileInf(fileName);
  
  last_used_path = fileInf.absolutePath();
  
  emit onLoadTargetTrajectory(fileName);
  
  this->traj_filename_edit->setText(fileInf.baseName());
  
};
Example #6
0
//--------------------------------------------------------------------------------------------------
/// Read JSON or ascii file containing well path data
//--------------------------------------------------------------------------------------------------
bool RimWellPath::readWellPathFile(QString* errorMessage, RifWellPathAsciiFileReader* asciiReader)
{
    QFileInfo fileInf(filepath());

    if (fileInf.isFile() && fileInf.exists())
    {
        if (fileInf.suffix().compare("json") == 0)
        {
            this->readJsonWellPathFile();
        }
        else
        {
            this->readAsciiWellPathFile(asciiReader);
        }

        return true;
    }
    else
    {
        if (errorMessage) (*errorMessage) = "Could not find the well path file: " + filepath();

        return false;
    }
}
Example #7
0
void QHexEdit::loadFromFile(const QString &path)
{
    QFileInfo fileInf(path);
    if (fileInf.size() > MAX_BINARY_FILE_SIZE)
    {
        QMessageBox::warning(this, ERROR_TOO_LARGE_BINARY_FILE_TITLE,
                             ERROR_TOO_LARGE_BINARY_FILE_MSG.arg(
                                 QString::number(fileInf.size())),
                             QMessageBox::Ok);
        return;
    }
    if (fileInf.size() > SCROLLED_BINARY_FILE_MAX_SIZE)
    {
        QMessageBox::warning(this, WARNING_LARGE_BINARY_FILE_TITLE,
                             WARNING_LARGE_BINARY_FILE_TEXT);
    }
    //Check if the file has already been opened
    //or it is not file at all
    if (getCurrentPath() == fileInf.filePath()
            || !fileInf.isFile())
    {
        return;
    }

    FileLoader *fLoader = new FileLoader();

    fLoader->openFile(fileInf.filePath());

    QByteArray arr;
    fLoader->loadToByteArray(arr);
    setCursorPosition(0);
    clearSelection();
    setData(arr);
    setCurrentPath(fileInf.filePath());
    fLoader->deleteLater();
}
Example #8
0
int oLaucher::Crack(QSqlQuery qry)
{            

    
    pathFileName = qry.value(0).toString();
    pathDictName = qry.value(1).toString();
    AplicarDict = qry.value(2).toBool();
    hashFileName = qry.value(5).toString();
    hashDictName = qry.value(4).toString();
    int ret = 0;    

    //qDebug() << "[!] ATTACK:: " << qry.value(0).toString() << "DICT " << qry.value(1).toString();

    if(QFile::exists(pathFileName)==false)
    {
        return -1;
    }

    if(QFile::exists(pathDictName)==false)
    {
        return -2;
    }

    QFileInfo fileInf(pathFileName);
    QString extension = fileInf.suffix();
    oPrograms dats;    
    QString fileTmpPass;    

    connect(proc, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(launchingError(QProcess::ProcessError)));
    //connect(proc, SIGNAL(finished(int)), this, SLOT(ProcCerrado(int)));
    connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readStdOut()));
    connect(proc, SIGNAL(readyReadStandardError()), this, SLOT(readStdErr()));
    connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(launchingError(QProcess::ProcessError)));


    fileTmpPass = fileTmpPass + "/tmp/filePwd" + QString::number(qrand() % 1000);    

    #ifdef Q_OS_WIN32
        fileTmpPass = getenv("TMP");
        fileTmpPass = fileTmpPass + "\\filePwd" + QString::number(qrand() % 1000);
    #endif

    QFile::remove(fileTmpPass);




    if(extension.compare("cap", Qt::CaseInsensitive)==0)
    {

        // Crackea con Pyrit

        qDebug() << "[!] Es un CAP";

        crackerProgram = 3;

        //QString strTmp = "attack_cowpatty";
        oSqlite db;
        QSqlQuery qry;

        GetPathUtils(crackerProgram, &dats);

        if(db.GetInfWpa(&qry, hashFileName)>=0)
        {
            //GetParamPyrit(pathFileName, qry.value(0).toString(), qry.value(1).toString(), pathDictName, &dats.args);
        }
    }




    if(extension.compare("hccap", Qt::CaseInsensitive)==0)
    {
        // Crackea con oclHashcat

        crackerProgram = 2;

        qDebug() << "[!] Es un HCCAP";

        GetParamHascat(pathFileName, AplicarDict, "QVariant::String", pathDictName, &dats.args);

        GetPathUtils(crackerProgram, &dats);

    }





    if(extension.compare("pdf", Qt::CaseInsensitive)==0)
    {
        qDebug() << "[+] Es un PDF";

        GetPathUtils(1, &dats);
        dats.args << pathDictName;

        if(AplicarDict)
            dats.args << pathDictName;

            else
            {
                //Aplicar fuerza bruta
            }

        proc->start(dats.pathExec, dats.args);



        while(proc->isOpen())
        {
            //qDebug() << "IS OPEN xD";


	#ifdef Q_OS_WIN
            CheckIdleUser();
            Sleep(1000);
	#endif

        }

    }





    if(extension.compare("rar", Qt::CaseInsensitive)==0)
    {
        //qDebug() << "[+] Es un rar";

        GetPathUtils(1, &dats);
        dats.args << pathDictName;

        if(AplicarDict)
            dats.args << pathDictName;

            else
            {
                //Aplicar fuerza bruta
            }


        proc->start(dats.pathExec, dats.args);
        //proc->waitForFinished(-1);
    }





    if(extension.compare("docx", Qt::CaseInsensitive)==0)
    {
        //qDebug() << "[+] Es un MS DOCX";

        GetPathUtils(1, &dats);
        dats.args << pathDictName;

        if(AplicarDict)
            dats.args << pathDictName;

            else
            {
                //Aplicar fuerza bruta
            }

        proc->start(dats.pathExec, dats.args);
        //proc->waitForFinished(-1);
    }


    qDebug() << "[+] Launching .. " << dats.pathExec << dats.args;
    proc->start(dats.pathExec, dats.args);
    proc->waitForFinished(-1);
    AnalyzeOutput(fileTmpPass, crackerProgram);

    delete proc;
    return ret;
}