Esempio n. 1
4
void SignalProxy::SignalRelay::attachSignal(QObject *sender, int signalId, const QByteArray &funcName)
{
    // we ride without safetybelts here... all checking for valid method etc pp has to be done by the caller
    // all connected methodIds are offset by the standard methodCount of QObject
    int slotId;
    for (int i = 0;; i++) {
        if (!_slots.contains(i)) {
            slotId = i;
            break;
        }
    }

    QByteArray fn;
    if (!funcName.isEmpty()) {
        fn = QMetaObject::normalizedSignature(funcName);
    }
    else {
        fn = SIGNAL(fakeMethodSignature());
#if QT_VERSION >= 0x050000
        fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).methodSignature());
#else
        fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).signature());
#endif
    }

    _slots[slotId] = Signal(sender, signalId, fn);

    QMetaObject::connect(sender, signalId, this, QObject::staticMetaObject.methodCount() + slotId);
}
Esempio n. 2
2
QByteArray Dialog::digest(const QString s)
{
    QByteArray c = s.toLatin1();
    int index;

    index = 0;

    while ((index = c.indexOf("\\n", index)) != -1) {
        c.replace(index, 2, "\n");
        index += 1;
    }

    index = 0;

    while ((index = c.indexOf("\\t", index)) != -1) {
        c.replace(index, 2, "\t");
        index += 1;
    }

    index = 0;

    while ((index = c.indexOf("\r", index)) != -1) {
        c.remove(index, 1);
    }

    return c;
}
Esempio n. 3
1
void MainWindow::translate()
{
    Language *srcLn = mLangageModel->language(ui->sourceComboBox->currentIndex());
    Language *targetLn = mLangageModel->language(ui->targetComboBox->currentIndex());

    QByteArray sourceText = ui->sourceTextEdit->toPlainText().toUtf8();
    sourceText.replace("&", "&");
    sourceText.replace("<", "&lt;");
    sourceText.replace(">", "&gt;");
    sourceText.replace("\n", "<br>");


    QByteArray postData;
    QString source = srcLn->id.toUtf8().toPercentEncoding();
    QString dest = targetLn->id.toUtf8().toPercentEncoding();
    QString texte=ui->sourceTextEdit->toPlainText().toUtf8().toPercentEncoding();
    QString st = "text="+texte+"&client=t&sl=" + source + "&tl=" + dest;

    postData = st.toUtf8();

    QNetworkRequest request(QString(GOOGLE_URL));

    request.setRawHeader("Content-Type","application/x-www-form-urlencoded");
    request.setRawHeader("Host","www.google.com");
    request.setRawHeader("User-Agent","Mozilla/5.0");
    request.setRawHeader("Accept-Encoding","deflate");
    request.setRawHeader("Connection","Close");


    QNetworkReply * reply = mNetManager->post(QNetworkRequest(request),postData);
    qDebug()<<reply->url();
    connect(reply,SIGNAL(finished()),this,SLOT(parseResult()));
}
Esempio n. 4
0
void DBLPFetcher::parseData(QByteArray& data_) {
    // weird XML
    // remove the CDATA and the dblp:: namespace
    data_.replace("<![CDATA[", ""); // krazy:exclude=doublequote_chars
    data_.replace("]]", ""); // krazy:exclude=doublequote_chars
    data_.replace("dblp:", ""); // krazy:exclude=doublequote_chars
}
SearchEnginesManager::SearchResult SearchEnginesManager::searchResult(const Engine &engine, const QString &string)
{
    ENSURE_LOADED;

    SearchResult result;

    if (engine.postData.isEmpty()) {
        QByteArray url = engine.url.toUtf8();
        url.replace(QLatin1String("%s"), QUrl::toPercentEncoding(string));

        result.request = QNetworkRequest(QUrl::fromEncoded(url));
        result.operation = QNetworkAccessManager::GetOperation;
    }
    else {
        QByteArray data = engine.postData;
        data.replace("%s", QUrl::toPercentEncoding(string));

        result.request = QNetworkRequest(QUrl::fromEncoded(engine.url.toUtf8()));
        result.request.setHeader(QNetworkRequest::ContentTypeHeader, QByteArray("application/x-www-form-urlencoded"));
        result.operation = QNetworkAccessManager::PostOperation;
        result.data = data;
    }

    return result;
}
Esempio n. 6
0
QByteArray MCodecs::quotedPrintableDecode(const QByteArray & in) {
    QByteArray out;
    QByteArray chunk = in;
    chunk.replace(QByteArray("=\n\r"),QByteArray());
    chunk.replace(QByteArray("=\n"),QByteArray());
    quotedPrintableDecode(chunk, out);
    return out;
}
Esempio n. 7
0
static void removeEscapes( QByteArray &str )
{
  str.replace( (char *)"\\n", "\n" );
  str.replace( (char *)"\\N", "\n" );
  str.replace( (char *)"\\r", "\r" );
  str.replace( (char *)"\\,", "," );
  str.replace( (char *)"\\\\", "\\" );
}
Esempio n. 8
0
static void addEscapes( QByteArray &str, bool excludeEscapteComma )
{
  str.replace( '\\', (char *)"\\\\" );
  if ( !excludeEscapteComma ) {
    str.replace( ',', (char *)"\\," );
  }
  str.replace( '\r', (char *)"\\r" );
  str.replace( '\n', (char *)"\\n" );
}
Esempio n. 9
0
bool TestHTTPServer::wait(const QUrl &expect, const QUrl &reply, const QUrl &body)
{
    m_state = AwaitingHeader;
    m_data.clear();

    QFile expectFile(expect.toLocalFile());
    if (!expectFile.open(QIODevice::ReadOnly)) return false;

    QFile replyFile(reply.toLocalFile());
    if (!replyFile.open(QIODevice::ReadOnly)) return false;

    bodyData = QByteArray();
    if (body.isValid()) {
        QFile bodyFile(body.toLocalFile());
        if (!bodyFile.open(QIODevice::ReadOnly)) return false;
        bodyData = bodyFile.readAll();
    }

    const QByteArray serverHostUrl = QByteArrayLiteral("127.0.0.1:") + QByteArray::number(server.serverPort());

    QByteArray line;
    bool headers_done = false;
    while (!(line = expectFile.readLine()).isEmpty()) {
        line.replace('\r', "");
        if (line.at(0) == '\n') {
            headers_done = true;
            continue;
        }
        if (headers_done) {
            waitData.body.append(line);
        } else {
            line.replace("{{ServerHostUrl}}", serverHostUrl);
            waitData.headers.append(line);
        }
    }
    /*
    while (waitData.endsWith('\n'))
        waitData = waitData.left(waitData.count() - 1);
        */

    replyData = replyFile.readAll();

    if (!replyData.endsWith('\n'))
        replyData.append("\n");
    replyData.append("Content-length: " + QByteArray::number(bodyData.length()));
    replyData .append("\n\n");

    for (int ii = 0; ii < replyData.count(); ++ii) {
        if (replyData.at(ii) == '\n' && (!ii || replyData.at(ii - 1) != '\r')) {
            replyData.insert(ii, '\r');
            ++ii;
        }
    }
    replyData.append(bodyData);

    return true;
}
Esempio n. 10
0
QString KQOAuthUtils::hmac_sha1(const QString &message, const QString &key)
{
    QByteArray keyBytes = key.toAscii();
    int keyLength;              // Lenght of key word
    const int blockSize = 64;   // Both MD5 and SHA-1 have a block size of 64.

    keyLength = keyBytes.size();
    // If key is longer than block size, we need to hash the key
    if (keyLength > blockSize) {
        QCryptographicHash hash(QCryptographicHash::Sha1);
        hash.addData(keyBytes);
        keyBytes = hash.result();
    }

    /* http://tools.ietf.org/html/rfc2104  - (1) */
    // Create the opad and ipad for the hash function.
    QByteArray ipad;
    QByteArray opad;

    ipad.fill( 0, blockSize);
    opad.fill( 0, blockSize);

    ipad.replace(0, keyBytes.length(), keyBytes);
    opad.replace(0, keyBytes.length(), keyBytes);

    /* http://tools.ietf.org/html/rfc2104 - (2) & (5) */
    for (int i=0; i<64; i++) {
        ipad[i] = ipad[i] ^ 0x36;
        opad[i] = opad[i] ^ 0x5c;
    }

    QByteArray workArray;
    workArray.clear();

    workArray.append(ipad, 64);
    /* http://tools.ietf.org/html/rfc2104 - (3) */
    workArray.append(message.toAscii());


    /* http://tools.ietf.org/html/rfc2104 - (4) */
    QByteArray sha1 = QCryptographicHash::hash(workArray, QCryptographicHash::Sha1);

    /* http://tools.ietf.org/html/rfc2104 - (6) */
    workArray.clear();
    workArray.append(opad, 64);
    workArray.append(sha1);

    sha1.clear();

    /* http://tools.ietf.org/html/rfc2104 - (7) */
    sha1 = QCryptographicHash::hash(workArray, QCryptographicHash::Sha1);
    return QString(sha1.toBase64());
}
Esempio n. 11
0
void SetMetaDataJob::handleResponse(const Message &response)
{
    Q_D(SetMetaDataJob);

    //TODO: Test if a server can really return more then one untagged NO response. If not, no need to OR the error codes
    if (!response.content.isEmpty() &&
        d->tags.contains(response.content.first().toString())) {
        if (response.content[1].toString() == "NO") {
            setError(UserDefinedError);
            setErrorText(i18n("%1 failed, server replied: %2", d->m_name, QLatin1String(response.toString().constData())));
            if (response.content[2].toString() == "[ANNOTATEMORE TOOMANY]" ||
                    response.content[2].toString() == "[METADATA TOOMANY]") {
                d->metaDataErrors |= TooMany;
            } else if (response.content[2].toString() == "[ANNOTATEMORE TOOBIG]" ||
                       response.content[2].toString().startsWith("[METADATA MAXSIZE")) {    //krazy:exclude=strings
                d->metaDataErrors |= TooBig;
                d->maxAcceptedSize = -1;
                if (response.content[2].toString().startsWith("[METADATA MAXSIZE")) {     //krazy:exclude=strings
                    QByteArray max = response.content[2].toString();
                    max.replace("[METADATA MAXSIZE", "");   //krazy:exclude=doublequote_chars
                    max.replace("]", "");                   //krazy:exclude=doublequote_chars
                    d->maxAcceptedSize = max.toLongLong();
                }
            } else if (response.content[2].toString() == "[METADATA NOPRIVATE]") {
                d->metaDataErrors |= NoPrivate;
            }
        } else if (response.content.size() < 2) {
            setErrorText(i18n("%1 failed, malformed reply from the server.", d->m_name));
        } else if (response.content[1].toString() != "OK") {
            setError(UserDefinedError);
            setErrorText(i18n("%1 failed, server replied: %2", d->m_name, QLatin1String(response.toString().constData())));
        }
        emitResult();
    } else if (d->serverCapability == Metadata && response.content[0].toString() == "+") {
        QByteArray content = "";
        if (d->entriesIt.value().isEmpty()) {
            content += "NIL";
        } else {
            content +=  d->entriesIt.value();
        }
        ++d->entriesIt;
        if (d->entriesIt == d->entries.constEnd()) {
            content += ')';
        } else {
            content += " \"" + d->entriesIt.key() + '\"';
            int size = d->entriesIt.value().size();
            content += " {" + QByteArray::number( size==0 ? 3 : size ) + '}';
        }
//      qCDebug(KIMAP_LOG) << "SENT: " << content;
        d->sessionInternal()->sendData(content);
    }
}
Esempio n. 12
0
QByteArray HtmlReporter::toQByteArray() const{
	collector.flush();
	linkCollector.flush();
	if(collected.size() == 0) return QByteArray();
	QByteArray filecontent = loadFile(":/template.html");
	filecontent.replace("$title", title.toUtf8());
	filecontent.replace("$content", collected);
	filecontent.replace("$show", tr("show").toUtf8());
	filecontent.replace("$hide", tr("hide").toUtf8());
	filecontent.replace("$links", linkCollected + "</ul>");
	filecontent.replace("$version", "readesm " VERSION " (" VERSION_DATE ")");
	return filecontent;
}
void tst_QCommandLineParser::testHelpOption()
{
#ifdef QT_NO_PROCESS
    QSKIP("This test requires QProcess support");
#else
#ifdef Q_OS_WINCE
    QSKIP("Reading and writing to a process is not supported on Qt/CE");
#endif
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
    QSKIP("Deploying executable applications to file system on Android not supported.");
#endif

    QFETCH(QCommandLineParser::SingleDashWordOptionMode, parsingMode);
    QFETCH(QString, expectedHelpOutput);
    QCoreApplication app(empty_argc, empty_argv);
    QProcess process;
    process.start("testhelper/qcommandlineparser_test_helper", QStringList() << QString::number(parsingMode) << "--help");
    QVERIFY(process.waitForFinished(5000));
    QCOMPARE(process.exitStatus(), QProcess::NormalExit);
    QString output = process.readAll();
#ifdef Q_OS_WIN
    output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
    QCOMPARE(output.split('\n'), expectedHelpOutput.split('\n')); // easier to debug than the next line, on failure
    QCOMPARE(output, expectedHelpOutput);

    process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "resize" << "--help");
    QVERIFY(process.waitForFinished(5000));
    QCOMPARE(process.exitStatus(), QProcess::NormalExit);
    output = process.readAll();
#ifdef Q_OS_WIN
    output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
    QByteArray expectedResizeHelp = QByteArrayLiteral(
                                        "Usage: testhelper/qcommandlineparser_test_helper [options] resize [resize_options]\n"
                                        "Test helper\n"
                                        "\n")
                                    + expectedOptionsHelp +
                                    "  --size <size>               New size.\n"
                                    "\n"
                                    "Arguments:\n"
                                    "  resize                      Resize the object to a new size.\n";
#ifdef Q_OS_WIN
    expectedResizeHelp.replace("  -h, --help                  Displays this help.\n",
                               "  -?, -h, --help              Displays this help.\n");
    expectedResizeHelp.replace("testhelper/", "testhelper\\");
#endif
    QCOMPARE(output, QString(expectedResizeHelp));
#endif // !QT_NO_PROCESS
}
Esempio n. 14
0
void TcfEngine::executeDebuggerCommand(const QString &command)
{
    QByteArray cmd = command.toUtf8();
    cmd = cmd.mid(cmd.indexOf(' ') + 1);
    QByteArray null;
    null.append('\0');
    // FIXME: works for single-digit escapes only
    cmd.replace("\\0", null);
    cmd.replace("\\1", "\1");
    cmd.replace("\\3", "\3");
    TcfCommand tcf;
    tcf.command = cmd;
    enqueueCommand(tcf);
}
void EnergyPlotter::replaceTokens(QByteArray& commands)
{
	QString limbName;
	switch (m_limb)
	{
		case 0: limbName = "Left thigh";      break;
		case 1: limbName = "Right thigh";     break;
		case 2: limbName = "Left lower leg";  break;
		case 3: limbName = "Right lower leg"; break;
	}
	
	commands.replace("__LIMB__", limbName.toAscii());
	commands.replace("__VOXEL_FILENAME__", QFileInfo(frameInfo()->fileName()).fileName().toAscii());
}
Esempio n. 16
0
QByteArray CtcpHandler::lowLevelQuote(const QByteArray &message) {
  QByteArray quotedMessage = message;

  QHash<QByteArray, QByteArray> quoteHash = ctcpMDequoteHash;
  QByteArray MQUOTE = QByteArray("\020");
  quoteHash.remove(MQUOTE + MQUOTE);
  quotedMessage.replace(MQUOTE, MQUOTE + MQUOTE);

  QHash<QByteArray, QByteArray>::const_iterator quoteIter = quoteHash.constBegin();
  while(quoteIter != quoteHash.constEnd()) {
    quotedMessage.replace(quoteIter.value(), quoteIter.key());
    quoteIter++;
  }
  return quotedMessage;
}
Esempio n. 17
0
QByteArray AbstractMobileApp::generateDesktopFile(QString *errorMessage, int fileType) const
{
    QByteArray desktopFileContent;
    if (!readTemplate(DesktopOrigin, &desktopFileContent, errorMessage))
        return QByteArray();
    if (fileType == AbstractGeneratedFileInfo::DesktopFileFremantle) {
        desktopFileContent.replace("Icon=thisApp",
            "Icon=" + projectName().toUtf8() + "64");
    } else if (fileType == AbstractGeneratedFileInfo::DesktopFileHarmattan) {
        desktopFileContent.replace("Icon=thisApp",
            "Icon=/usr/share/icons/hicolor/80x80/apps/" + projectName().toUtf8() + "80.png");
        desktopFileContent.replace("Exec=", "Exec=/usr/bin/single-instance ");
    }
    return desktopFileContent.replace("thisApp", projectName().toUtf8());
}
bool BlackBerryCreatePackageStep::prepareAppDescriptorFile(const QString &appDescriptorPath, QTemporaryFile *preparedFile)
{
    BlackBerryQtVersion *qtVersion = dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtProfileInformation::qtVersion(target()->profile()));
    if (!qtVersion) {
        raiseError(tr("Error preparing application descriptor file"));
        return false;
    }

    QFile file(appDescriptorPath);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        raiseError(tr("Could not open '%1' for reading").arg(appDescriptorPath));
        return false;
    }

    QByteArray fileContent = file.readAll();

    // Replace Qt path placeholders
    if (fileContent.contains(QT_INSTALL_LIBS_VAR))
        fileContent.replace(QT_INSTALL_LIBS_VAR, qtVersion->versionInfo().value(QLatin1String(QT_INSTALL_LIBS)).toLatin1());
    if (fileContent.contains(QT_INSTALL_PLUGINS_VAR))
        fileContent.replace(QT_INSTALL_PLUGINS_VAR, qtVersion->versionInfo().value(QLatin1String(QT_INSTALL_PLUGINS)).toLatin1());
    if (fileContent.contains(QT_INSTALL_IMPORTS_VAR))
        fileContent.replace(QT_INSTALL_IMPORTS_VAR, qtVersion->versionInfo().value(QLatin1String(QT_INSTALL_IMPORTS)).toLatin1());

    //Replace Source path placeholder
    if (fileContent.contains(SRC_DIR_VAR))
        fileContent.replace(SRC_DIR_VAR, QDir::toNativeSeparators(target()->project()->projectDirectory()).toLatin1());

    // Add parameter for QML debugging (if enabled)
    if (target()->activeRunConfiguration()->debuggerAspect()->useQmlDebugger()) {
        if (!fileContent.contains("-qmljsdebugger")) {
            const QString argString = QString::fromLatin1("<arg>-qmljsdebugger=port:%1</arg>\n</qnx>")
                    .arg(target()->activeRunConfiguration()->debuggerAspect()->qmlDebugServerPort());
            fileContent.replace("</qnx>", argString.toLatin1());
        }
    }

    const QString buildDir = target()->activeBuildConfiguration()->buildDirectory();
    if (!preparedFile->open()) {
        raiseError(tr("Could not create prepared application descriptor file in '%1'").arg(buildDir));
        return false;
    }

    preparedFile->write(fileContent);
    preparedFile->close();

    return true;
}
Esempio n. 19
0
void AutoFillManager::editPass()
{
    QTreeWidgetItem* curItem = ui->treePass->currentItem();
    if (!curItem) {
        return;
    }
    bool ok;
    QString text = QInputDialog::getText(this, tr("Edit password"), tr("Change password:"******"SELECT data, password FROM autofill WHERE id=?");
        query.addBindValue(curItem->data(0, Qt::UserRole + 10).toString());
        query.exec();
        query.next();

        QByteArray data = query.value(0).toByteArray();
        QByteArray oldPass = "******" + QUrl::toPercentEncoding(query.value(1).toByteArray());
        data.replace(oldPass, "=" + QUrl::toPercentEncoding(text.toUtf8()));

        query.prepare("UPDATE autofill SET data=?, password=? WHERE id=?");
        query.bindValue(0, data);
        query.bindValue(1, text);
        query.bindValue(2, curItem->data(0, Qt::UserRole + 10).toString());
        query.exec();

        if (m_passwordsShown) {
            curItem->setText(2, text);
        }

        curItem->setData(0, Qt::UserRole + 11, text);
    }
}
Esempio n. 20
0
QByteArray QXmppSaslDigestMd5::serializeMessage(const QMap<QByteArray, QByteArray> &map)
{
    QByteArray ba;
    foreach (const QByteArray &key, map.keys())
    {
        if (!ba.isEmpty())
            ba.append(',');
        ba.append(key + "=");
        QByteArray value = map[key];
        const char *separators = "()<>@,;:\\\"/[]?={} \t";
        bool quote = false;
        for (const char *c = separators; *c; c++)
        {
            if (value.contains(*c))
            {
                quote = true;
                break;
            }
        }
        if (quote)
        {
            value.replace("\\", "\\\\");
            value.replace("\"", "\\\"");
            ba.append("\"" + value + "\"");
        }
        else
            ba.append(value);
    }
    return ba;
}
Esempio n. 21
0
QVariant ClientsModel::data(const QModelIndex &index, int role) const
{
    auto client = m_clients.at(index.row());

    switch (index.column()) {
        case PidColumn:
            if (role == Qt::DisplayRole)
                return client->processId();
            if (role == ObjectIdRole)
                return QVariant::fromValue(ObjectId(client));
	    break;
        case CommandColumn: {
            if (role != Qt::DisplayRole)
                return QVariant();
            auto pid = client->processId();
            QByteArray path;
            QTextStream(&path) << "/proc/" << pid << "/cmdline";
            QFile file(path);
            if (!file.open(QIODevice::ReadOnly)) {
                return QStringLiteral("Not available :/");
            }

            QByteArray data = file.readAll();
            data.replace('\0', ' ');
            return data;
        }
    }
    return QVariant();
}
Esempio n. 22
0
QByteArray DashboardApplet::dataFor(const QString &str)
{
    QFile f(str);
    f.open(QIODevice::ReadOnly);
    QByteArray data = f.readAll();
    f.close();

    //replace the apple javascript imports with the kde ones
    QString jsBaseDir = KGlobal::dirs()->findResourceDir("data","plasma/dashboard/button/genericButton.js") 
                            + "plasma/dashboard";

    data.replace("file:///System/Library/WidgetResources", jsBaseDir.toUtf8());
    data.replace("/System/Library/WidgetResources", jsBaseDir.toUtf8());

    return data;
}
Esempio n. 23
0
void BuildManager::procReadyRead()
{
    QByteArray bytes = proc->readAllStandardOutput();
    if(bytes.length() == 0)
        return;

    bytes = bytes.replace("\r\n","\n");
    compileResult = QString(bytes);
    QStringList lines = QString(bytes).split("\n",QString::SkipEmptyParts);

    QTextCharFormat tf = consoleEdit->currentCharFormat();

    foreach (QString line, lines)
    {
        if (line.contains("Program size is") || line.contains("Bit fe") || line.contains("DOWNLOAD COMPLETE"))
        {
            tf.setForeground(Qt::darkGreen);
            consoleEdit->setCurrentCharFormat(tf);
        }
        else if (line.contains("error", Qt::CaseInsensitive))
        {
            tf.setForeground(Qt::red);
            consoleEdit->setCurrentCharFormat(tf);
        }

        consoleEdit->appendPlainText(line);
    }

    QScrollBar *sb = consoleEdit->verticalScrollBar();
    sb->setValue(sb->maximum());
}
Esempio n. 24
0
    /** Get hash of SQL statement using Oracles' internal algorithm
     * @param sql statement
     * @return sql_id
     */
    QString toSQLToSql_Id(const QString &sql)
    {
    	// based on
    	// http://www.slaviks-blog.com/2010/03/30/oracle-sql_id-and-hash-value/
    	// Note: 11gR2 also has dbms_sqltune_util0.sqltext_to_sqlid - but who cares
    	QByteArray ba = sql.toLocal8Bit();
    	ba.replace("\r", 1, "", 0); // Convert CR/LF => LF
    	ba.append('\0');
    	QByteArray baHash = QCryptographicHash::hash(ba, QCryptographicHash::Md5);

    	QString sql_id;
    	//consider only last/most significant 64 bits of regular 128bit MD5 hash
    	quint32 *msb = (quint32*)(&(baHash.constData()[8]));
    	quint32 *lsb = (quint32*)(&(baHash.constData()[12])); // these bits are the traditional 32 bit hash value
    	quint64 value = (quint64)(*msb) * 4294967296ULL + (quint64)(*lsb);
    	static const char* base32 = "0123456789abcdfghjkmnpqrstuvwxyz";
    	if (value == 0)
    	{
    		sql_id = "0";
    	}
    	else
    	{
    		while (value )
    		{
    			sql_id = base32[value % 32] + sql_id;
    			value /= 32;
    		}
    		sql_id = sql_id.rightJustified(13, '0');
    	}
    	quint32 *hash_value = (quint32*)(&(baHash.constData()[12]));
    	//return QString("%1:%2").arg(*hash_value).arg(sql_id);
    	return sql_id;
    }
Esempio n. 25
0
void MainWindow::on_actionRename_triggered(bool)
{
	if (images_.count()==0) return;

	QString folder = images_[0].folder();
	for (int i=0; i<images_.count(); ++i)
	{
		//get EXIF date
		QByteArray date;
		if (!getExifDate(images_[i].filename(), date))
		{
			QMessageBox::warning(this, "EXIF data not found!", "EXIF creation date not found for file:\n" + images_[i].filename() + "\nMessage: " + date + "\nAborting!");
			break;
		}

		//format '2004:04:23 13:05:04' to '20040423_130504'
		date.replace(":", "").replace(" ","_");

		//determine new file name
		QString file_o = images_[i].filename(false);
		QString ext = file_o.right(4);
		int number = 1;
		while (QFile::exists(folder + "\\" + date + "-" + QString::number(number) + ext))
		{
			++number;
		}

		//rename
		QFile::rename(images_[i].filename(), folder + "\\" + date + "-" + QString::number(number) + ext);
	}

	updateImageList(folder);
	updateImage(0);
}
Esempio n. 26
0
 QByteArray InterfaceProxy::GenerateNamespaceName() const
 {
     QByteArray namespaceName = m_class.qualified;
     namespaceName.replace(':', '_');
     namespaceName = "\nnamespace " + namespaceName;
     return namespaceName;
 }
Esempio n. 27
0
void UmlEntryPointPseudoState::html(QByteArray pfix, unsigned int rank, unsigned int level)
{
    define();

    UmlCom::message(name());

    QByteArray s = sKind();

    s.replace(0, 1, s.left(1).toUpper());
    UmlItem::html(s, (UmlDiagram *) 0);

    fw.write("<p>Defined in ");

    if (parent()->kind() == aRegion)
        parent()->parent()->write();
    else
        parent()->write();

    fw.write("</p>");

    if (reference() != 0) {
        fw.write("<p>References ");
        reference()->write();
        fw.write("</p>");
    }

    write_children(pfix, rank, level);

    unload(FALSE, FALSE);
}
Esempio n. 28
0
void AsteriskManager::onReadyRead()
{
	QRegExp keyValue("^([A-Za-z0-9\\-]+):\\s(.+)$");
	QByteArray line;

    qDebug("<ami>");

	while (canReadLine()) {
		line = readLine();

        qDebug() << line.trimmed();

		if (line != "\r\n") {
            if (keyValue.indexIn(line) > -1) {
				packetBuffer[keyValue.cap(1)] = stringValue(keyValue.cap(2).trimmed());
            } else if (line.startsWith("Asterisk Call Manager")) {
                version_ = line.replace("Asterisk Call Manager/", QByteArray()).trimmed();

                emit connected(version_);
            }
		} else if (!packetBuffer.isEmpty()) {
			dispatchPacket();
		}
	}

    qDebug("</ami>");
}
Esempio n. 29
0
bool TPlayerInfoMplayer::run(QString options) {
    logger()->debug("run: '" + options + "'");

	if (proc->state() == QProcess::Running) {
        logger()->warn("run: process already running");
		return false;
	}

	QStringList args = options.split(" ");

	proc->start(bin, args);
	if (!proc->waitForStarted()) {
        logger()->warn("run: process can't start!");
		return false;
	}

	//Wait until finish
	if (!proc->waitForFinished()) {
        logger()->warn("run: process didn't finish. Killing it...");
		proc->kill();
	}

    logger()->debug("run : terminating");

	QByteArray ba;
	while (proc->canReadLine()) {
		ba = proc->readLine();
		ba.replace("\n", "");
		ba.replace("\r", "");
		readLine(ba);
	}

	return true;
}
Esempio n. 30
0
bool InfoReader::run(QString options) {
    qDebug("InfoReader::run: '%s'", options.toUtf8().data());
    qDebug("InfoReader::run: using QProcess");

    if (proc->state() == QProcess::Running) {
        qWarning("InfoReader::run: process already running");
        return false;
    }

    QStringList args = options.split(" ");

    proc->start(mplayerbin, args);
    if (!proc->waitForStarted()) {
        qWarning("InfoReader::run: process can't start!");
        return false;
    }

    //Wait until finish
    if (!proc->waitForFinished()) {
        qWarning("InfoReader::run: process didn't finish. Killing it...");
        proc->kill();
    }

    qDebug("InfoReader::run : terminating");

    QByteArray ba;
    while (proc->canReadLine()) {
        ba = proc->readLine();
        ba.replace("\n", "");
        ba.replace("\r", "");
        readLine( ba );
    }

    return true;
}