예제 #1
0
void MainWindow::on_pid_yawn_i_2_valueChanged(double arg1)
{
    output.clear();

    output.append("SP2 2 ");             //1. Pitc 2. Roll 3. Yaw   //1. P 2. I 3.D
    output.append(QString::number((float)arg1));
    output.append("\r\n");

    writeSerial(output);
}
예제 #2
0
/**
 * Hashes the given string using the HMAC-SHA1 algorithm.
 *
 * http://stackoverflow.com/questions/3341167/how-to-implement-hmac-sha1-algorithm-in-qt/3594062#3594062
 * 
 * \param key The string to be hashed
 * \param secret The string that contains secret word
 * \return The hashed string
 */
static QString hmac_sha1(const QString &key, const QString &secret)
{
    int text_length; // Length of the text, that will be hashed
    unsigned char* K; //For secret word.
    int K_length; //Length of secret word

    K_length = secret.size();
    text_length = key.size();

    //Need to do for XOR operation. Transforms QString to unsigned char
    std::string tempString = secret.toStdString();
    K = (unsigned char*)tempString.c_str();

    unsigned char ipad[65]; // Inner pad
    unsigned char opad[65]; // Outer pad

    //unsigned char L[20]; //TODO if key > 64 bytes use this to obtain sha1 key

    // Fills ipad and opad with zeros
    memset( ipad, 0, sizeof ipad);
    memset( opad, 0, sizeof opad);

    // Copies Secret to ipad and opad
    memcpy( ipad, K, K_length);
    memcpy( opad, K, K_length);

    // XOR operation for inner and outer pad
    for (int i=0; i<64; i++) {
        ipad[i] ^= 0x36;
        opad[i] ^= 0x5c;
    }

    QByteArray context; // Stores hashed content

    context.append((const char*) ipad,64); // Appends XOR:ed ipad to context
    context.append(key); //Appends key to context

    //Hashes Inner pad
    QByteArray Sha1 = QCryptographicHash::hash(context,
                QCryptographicHash::Sha1);

    context.clear();
    context.append((const char*) opad,64); //Appends opad to context
    context.append(Sha1); //Appends hashed inner pad to context

    Sha1.clear();

    // Hashes outerpad
    Sha1 = QCryptographicHash::hash(context, QCryptographicHash::Sha1);

    // String to return hashed stuff in Base64 format
    QByteArray str(Sha1.toBase64());

    return str;
}
예제 #3
0
void ArtNetPacketizer::setupArtNetPollReply(QByteArray &data, QHostAddress ipAddr, QString MACaddr)
{
    int i = 0;
    data.clear();
    data.append(m_commonHeader);
    data.remove(9, 2);
    const char opCodeMSB = (ARTNET_POLLREPLY >> 8);
    data[9] = opCodeMSB;
    QString ipStr = ipAddr.toString();
    QStringList ipAddrList = ipStr.split(".");
    foreach (QString val, ipAddrList)
        data.append((char)val.toInt()); // IP address[4]
    data.append((char)0x36);     // Port LSB
    data.append((char)0x19);     // Port MSB
    data.append((char)0x04);     // Version MSB
    data.append((char)0x20);     // Version LSB
    data.append((char)0x00);     // Sub Switch MSB
    data.append((char)0x00);     // Sub Switch LSB
    data.append((char)0xFF);     // OEM Value MSB
    data.append((char)0xFF);     // OEM Value LSB
    data.append((char)0x00);     // UBEA version
    data.append((char)0xF0);     // Status1 - Ready and booted
    data.append((char)0xFF);     // ESTA Manufacturer MSB
    data.append((char)0xFF);     // ESTA Manufacturer LSB
    data.append("QLC+");   // Short Name
    for (i = 0; i < 14; i++)
        data.append((char)0x00); // 14 bytes of stuffing
    data.resize(data.length() + 14);
    data.append("Q Light Controller Plus - ArtNet interface"); // Long Name
    for (i = 0; i < 22; i++) // 64-42 bytes of stuffing. 42 is the lenght of the long name
        data.append((char)0x00);
    for (i = 0; i < 64; i++)
        data.append((char)0x00); // Node report
    data.append((char)0x00);     // NumPort MSB
    // FIXME: this should reflect the actual state of QLC+ output ports !
    data.append((char)0x01);     // NumPort LSB
    data.append((char)0x80);     // Port 1 type: can output DMX512 data
    data.append((char)0x80);     // Port 2 type: can output DMX512 data
    data.append((char)0x80);     // Port 3 type: can output DMX512 data
    data.append((char)0x80);     // Port 4 type: can output DMX512 data
    // FIXME: this should reflect the actual state of QLC+ output ports !
    for (i = 0; i < 12; i++)
        data.append((char)0x00); // Set GoodInput[4], GoodOutput[4] and SwIn[4] all to unknown state
    data.append((char)0x00);     // SwOut0 - output 0
    data.append((char)0x01);     // SwOut1 - output 1
    data.append((char)0x02);     // SwOut2 - output 2
    data.append((char)0x03);     // SwOut3 - output 3
    for (i = 0; i < 7; i++)
        data.append((char)0x00);  // SwVideo, SwMacro, SwRemote and 4 spare bytes
    QStringList MAC = MACaddr.split(":");
    foreach (QString couple, MAC)
    {
        bool ok;
        data.append((char)couple.toInt(&ok, 16));
    }
예제 #4
0
QByteArray gdbQuoteTypes(const QByteArray &type)
{
    // gdb does not understand sizeof(Core::IDocument*).
    // "sizeof('Core::IDocument*')" is also not acceptable,
    // it needs to be "sizeof('Core::IDocument'*)"
    //
    // We never will have a perfect solution here (even if we had a full blown
    // C++ parser as we do not have information on what is a type and what is
    // a variable name. So "a<b>::c" could either be two comparisons of values
    // 'a', 'b' and '::c', or a nested type 'c' in a template 'a<b>'. We
    // assume here it is the latter.
    //return type;

    // (*('myns::QPointer<myns::QObject>*'*)0x684060)" is not acceptable
    // (*('myns::QPointer<myns::QObject>'**)0x684060)" is acceptable
    if (isPointerType(type))
        return gdbQuoteTypes(stripPointerType(type)) + '*';

    QByteArray accu;
    QByteArray result;
    int templateLevel = 0;

    const char colon = ':';
    const char singleQuote = '\'';
    const char lessThan = '<';
    const char greaterThan = '>';
    for (int i = 0; i != type.size(); ++i) {
        const char c = type.at(i);
        if (isLetterOrNumber(c) || c == '_' || c == colon || c == ' ') {
            accu += c;
        } else if (c == lessThan) {
            ++templateLevel;
            accu += c;
        } else if (c == greaterThan) {
            --templateLevel;
            accu += c;
        } else if (templateLevel > 0) {
            accu += c;
        } else {
            if (accu.contains(colon) || accu.contains(lessThan))
                result += singleQuote + accu + singleQuote;
            else
                result += accu;
            accu.clear();
            result += c;
        }
    }
    if (accu.contains(colon) || accu.contains(lessThan))
        result += singleQuote + accu + singleQuote;
    else
        result += accu;
    //qDebug() << "GDB_QUOTING" << type << " TO " << result;

    return result;
}
예제 #5
0
qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
    QByteArray message;
    while (true) {
        while (!stack.empty() && (data.empty() || stack.top() <= data.front().start)) {
            if (stack.top() > until) {
                qint64 memory_next = appendMemoryEvents(until, messages);
                return memory_next == -1 ? stack.top() : qMin(stack.top(), memory_next);
            }
            appendMemoryEvents(stack.top(), messages);
            QQmlDebugStream d(&message, QIODevice::WriteOnly);
            d << stack.pop() << RangeEnd << Javascript;
            messages.append(message);
        }
        while (!data.empty() && (stack.empty() || data.front().start < stack.top())) {
            const QV4::Profiling::FunctionCallProperties &props = data.front();
            if (props.start > until) {
                qint64 memory_next = appendMemoryEvents(until, messages);
                return memory_next == -1 ? props.start : qMin(props.start, memory_next);
            }
            appendMemoryEvents(props.start, messages);

            QQmlDebugStream d_start(&message, QIODevice::WriteOnly);
            d_start << props.start << RangeStart << Javascript;
            messages.push_back(message);
            message.clear();
            QQmlDebugStream d_location(&message, QIODevice::WriteOnly);
            d_location << props.start << RangeLocation << Javascript << props.file << props.line
                       << props.column;
            messages.push_back(message);
            message.clear();
            QQmlDebugStream d_data(&message, QIODevice::WriteOnly);
            d_data << props.start << RangeData << Javascript << props.name;
            messages.push_back(message);
            message.clear();
            stack.push(props.end);
            data.pop_front();
        }
        if (stack.empty() && data.empty())
            return appendMemoryEvents(until, messages);
    }
}
예제 #6
0
void WifiAPItem::setProfile(WifiProfile & profile)
{
    if (!(profile_ == profile))
    {
        profile_ = profile;
        updateByProfile(profile_);
    }
    selected_item_ = 0;
    previous_selected_item_ = 0;
    selected_bssid.clear();
}
예제 #7
0
// ------------------------------------------------------------------------ //
void RunModule::checkLinkStatus()
{
    if(dbg()) msg()("Checking link status...","RunModule::checkLinkStatus");

    bool ok;
    QByteArray datagram;

    // send call to vmmapp port
    int send_to_port = config().commSettings().vmmapp_port;

    // header
    QString cmd = "BBAAFFFF";
    QString msbCounter = "0x80000000"; 

    for(const auto& ip : socket().ipList()) {
        datagram.clear();
        QDataStream out (&datagram, QIODevice::WriteOnly);
        out.device()->seek(0); //rewind

        socket().updateCommandCounter();

        ////////////////////////////
        // header
        ////////////////////////////
        out << (quint32)(socket().commandCounter() + msbCounter.toUInt(&ok,16)) //[0,3]
            << (quint32) config().getHDMIChannelMap() //[4,7]
            << (quint32) cmd.toUInt(&ok,16); //[8,11]

        ////////////////////////////
        // command
        ////////////////////////////
        out << (quint32) 0 //[12,15]
            << (quint32) 16; //[16,19]

        socket().SendDatagram(datagram, ip, send_to_port, "fec",
                                                "RunModule::checkLinkStatus");

        bool readOK = true;
        readOK = socket().waitForReadyRead("fec");
        if(readOK) {
            emit checkLinks();
            //if(dbg()) msg()("Processing replies...","RunModule::checkLinkStatus");
            //socket().processReply("fec", ip);
        } else {
            msg()("Timeout while waiting for replies from VMM",
                    "RunModule::checkLinkStatus", true);
            socket().closeAndDisconnect("fec", "RunModule::checkLinkStatus");
            exit(1);
        }
    } // ip

    socket().closeAndDisconnect("fec", "RunModule::checkLinkStatus");

}
예제 #8
0
// ------------------------------------------------------------------------ //
void RunModule::configTP(int tpskew, int tpwidth, int tppolarity)
{
    if(dbg()) msg()("Configuring the pulser...","RunModule::configTP");

    bool ok;
    QByteArray datagram;

    // send call to s6 port
    int send_to_port = config().commSettings().s6_port;

    QString cmd, msbCounter;
    cmd = "AAAAFFFF";
    msbCounter = "0x80000000"; 

    for(const auto& ip : socket().ipList()) {
        datagram.clear();
        QDataStream out (&datagram, QIODevice::WriteOnly);
        out.device()->seek(0); //rewind

        socket().updateCommandCounter();

        ////////////////////////////
        // header
        ////////////////////////////
        out << (quint32)(socket().commandCounter() + msbCounter.toUInt(&ok,16)) //[0,3]
            << (quint32) config().getHDMIChannelMap() //[4,7]
            << (quint32) cmd.toUInt(&ok,16); //[8,11]

        ////////////////////////////
        // command
        ////////////////////////////
        out << (quint32) 0 //[12,15]
            << (quint32) 2 //[16,19]
            << (quint32) (tpskew + (tpwidth*16) + (tppolarity*128)); //[20,23]

        socket().SendDatagram(datagram, ip, send_to_port, "fec",
                                                "RunModule::configTP");

        bool readOK = true;
        readOK = socket().waitForReadyRead("fec");
        if(readOK) {
            if(dbg()) msg()("Processing replies...","RunModule::configTP");
            socket().processReply("fec",ip);
        } else {
            msg()("Timeout while waiting for replies from VMM",
                    "RunModule::configTP", true);
            socket().closeAndDisconnect("fec","RunModule::configTP");
            exit(1);
        }
    } // ip

    socket().closeAndDisconnect("fec","RunModule::configTP");

}
예제 #9
0
//Заполнить пакет нулями
//Размер цифрового моноаудиофайла измеряется по формуле: A = D*T*i,
QByteArray JitterBuffer::getGarbagePacket()
{
    QByteArray retBA;
    retBA.clear();

    int a = SAMPLING_FREQUENCY * packetSize_ / 1000 * BIT_REGISTER / 8;

    for (int i = 0; i < a; i++) retBA.append('0');

    return retBA;
}
예제 #10
0
// sends the result of the task to the client
void Client::taskResult(Request *response){
	if((response->getCode() == 1) && (response->getSuccess()))
		username = response->getSender()->getName();

	QByteArray buffer;
	buffer.clear();
	buffer.append(response->toQString());

	socket->write(buffer);
	socket->flush();
}
예제 #11
0
void TreeItemProtocol::serializeImages(const types::Images & src, QByteArray & dest)
{
	dest.clear();
	QDataStream stream(&dest, QIODevice::WriteOnly);
	foreach (const QString & imageurl, src) {
		stream << imageurl;
	}

	//dest = qCompress(dest);

}
예제 #12
0
void TreeItemProtocol::serializeProposals(const types::Proposals & src, QByteArray & dest)
{
	dest.clear();
	QDataStream stream(&dest, QIODevice::WriteOnly);
	foreach (const k::Proposal & p, src) {
		stream << p.id << p.text;
	}

	//dest = qCompress(dest);

}
예제 #13
0
void TreeItemProtocol::serializeProperties(const types::Properties & src, QByteArray & dest)
{
	dest.clear();
	QDataStream stream(&dest, QIODevice::WriteOnly);
	foreach (const k::Property & p, src) {
		stream << p.key << p.value << p.description;
	}

	//dest = dest);

}
void threadCercle::run()
{
    QByteArray baReception;
    sockClient.connectToHost(m_IPServeur, 55415);
    int posX, posY, rayon;
    m_bEtat=true;
    if (sockClient.waitForConnected(5000))
    {
        emit(siConnecte("Cliquez!"));
        while (m_bEtat)
        {
            sockClient.waitForReadyRead(100);
            if(sockClient.bytesAvailable() > 0)
            {
                baReception.append(sockClient.read(sockClient.bytesAvailable()));
            }
            else
            {
                m_bEtat = false;
            }
            if(baReception[0] ==1)
            {
                posX = (baReception[1] << 8) + uchar(baReception[2]);
                posY = (baReception[3] << 8) + uchar(baReception[4]);
                rayon= uchar(baReception[5]);
                emit (siNouvCercle(posX,posY,rayon));
            }
            else
            {
                if(baReception[0]==2)
                {
                    emit(siConnecte("Vous gagnez!"));
                }
                else
                {
                    if(baReception[0]==3)
                    {
                        emit(siConnecte("Vous avez perdu..."));
                    }
                }
            }
            baReception.clear();
            sockClient.write("#");
        }
        emit(siConnecte("Fin."));
    }
    else
    {
        emit(siConnecte("Une erreur s'est produite."));
    }

    sockClient.disconnectFromHost();
    sockClient.close();
}
예제 #15
0
void BinTreeNodeReader::fillArray(QByteArray& buffer, quint32 len, QDataStream &in)
{
    buffer.clear();

    for (quint32 count=0; count < len; count ++)
    {
        quint8 byte;
        in >> byte;
        buffer.append(byte);
    }
}
예제 #16
0
void tst_qbytearray::append()
{
    QFETCH(int, size);

    QByteArray ba;
    QBENCHMARK {
        QByteArray ba2(size, 'x');
        ba.append(ba2);
        ba.clear();
    }
}
void CodeDataLoggerDockWidget::on_exportData_clicked()
{
   QString fileName = QFileDialog::getSaveFileName(NULL,"Export Code/Data Log",QDir::currentPath(),"Code+Data Log File (*.cdl)");
   int addr;
   int size = nesGetPRGROMSize();
   int byte;
   QByteArray cdls;

   if ( !fileName.isEmpty() )
   {
      QFile file(fileName);

      if ( file.open(QIODevice::ReadWrite|QIODevice::Truncate) )
      {
         for ( addr = 0; addr < size; addr += MEM_8KB )
         {
            CCodeDataLogger* pLogger = nesGetPhysicalPRGROMCodeDataLoggerDatabase(addr);
            LoggerInfo* pEntry;
            unsigned char cdl;

            cdls.clear();
            for ( byte = 0; byte < MEM_8KB; byte++ )
            {
               cdl = 0x00;
               pEntry = pLogger->GetLogEntry(byte);
               if ( pEntry->count )
               {
                  if ( (pEntry->type == eLogger_InstructionFetch) ||
                       (pEntry->type == eLogger_OperandFetch) )
                  {
                     cdl |= 0x01;
                  }
                  else if ( (pEntry->type == eLogger_DataRead) ||
                            (pEntry->type == eLogger_DataWrite) ||
                            (pEntry->type == eLogger_DMA) )
                  {
                     cdl |= 0x02;
                  }
                  cdl |= ((pEntry->cpuAddr>>SHIFT_64KB_8KB)&0x3)<<2;
                  // No information available (yet) to fill in the indirect code use bit.
                  // No information available (yet) to fill in the indirect data use bit.
                  if ( (pEntry->type == eLogger_DMA) &&
                       (pEntry->source == eNESSource_APU) )
                  {
                     cdl |= 0x40;
                  }
               }
               cdls.append(cdl);
            }
            file.write(cdls);
         }
         file.close();
      }
   }
예제 #18
0
void puertoSerie::receive(){

    QByteArray dataReceived;
    QByteArray dataR;
    char data[1024];
    dataReceived.clear();
    dataR.clear();
    qint64 bytesRead = port->bytesAvailable();
    if (bytesRead>1024) bytesRead=1024;

    port->read(data, 128);
    dataReceived=QByteArray::fromRawData(data,128);

    int indiceCR=dataReceived.indexOf("\r");
    dataR=dataReceived.left(indiceCR-1);

    if (indiceCR>6)  emit mensajeModbusRecibido(dataR);

    //emit mensajeModbusRecibido();
}
예제 #19
0
파일: KoPattern.cpp 프로젝트: KDE/calligra
bool KoPattern::savePatToDevice(QIODevice* dev) const
{
    // Header: header_size (24+name length),version,width,height,colordepth of brush,magic,name
    // depth: 1 = greyscale, 2 = greyscale + A, 3 = RGB, 4 = RGBA
    // magic = "GPAT", as a single uint32, the docs are wrong here!
    // name is UTF-8 (\0-terminated! The docs say nothing about this!)
    // _All_ data in network order, it seems! (not mentioned in gimp-2.2.8/devel-docs/pat.txt!!)
    // We only save RGBA at the moment
    // Version is 1 for now...

    GimpPatternHeader ph;
    QByteArray utf8Name = name().toUtf8();
    char const* name = utf8Name.data();
    int nameLength = qstrlen(name);

    ph.header_size = qToBigEndian((quint32)sizeof(GimpPatternHeader) + nameLength + 1); // trailing 0
    ph.version = qToBigEndian((quint32)1);
    ph.width = qToBigEndian((quint32)width());
    ph.height = qToBigEndian((quint32)height());
    ph.bytes = qToBigEndian((quint32)4);
    ph.magic_number = qToBigEndian((quint32)GimpPatternMagic);

    QByteArray bytes = QByteArray::fromRawData(reinterpret_cast<char*>(&ph), sizeof(GimpPatternHeader));
    int wrote = dev->write(bytes);
    bytes.clear();

    if (wrote == -1)
        return false;

    wrote = dev->write(name, nameLength + 1); // Trailing 0 apparantly!
    if (wrote == -1)
        return false;

    int k = 0;
    bytes.resize(width() * height() * 4);
    for (qint32 y = 0; y < height(); ++y) {
        for (qint32 x = 0; x < width(); ++x) {
            // RGBA only
            QRgb pixel = m_pattern.pixel(x, y);
            bytes[k++] = static_cast<char>(qRed(pixel));
            bytes[k++] = static_cast<char>(qGreen(pixel));
            bytes[k++] = static_cast<char>(qBlue(pixel));
            bytes[k++] = static_cast<char>(qAlpha(pixel));
        }
    }

    wrote = dev->write(bytes);
    if (wrote == -1)
        return false;

    KoResource::saveToDevice(dev);

    return true;
}
/*
 * XXX - the routine pointed to by "print_line_fcn_p" doesn't get handed lines,
 * it gets handed bufferfuls.  That's fine for "follow_write_raw()"
 * and "follow_add_to_gtk_text()", but, as "follow_print_text()" calls
 * the "print_line()" routine from "print.c", and as that routine might
 * genuinely expect to be handed a line (if, for example, it's using
 * some OS or desktop environment's printing API, and that API expects
 * to be handed lines), "follow_print_text()" should probably accumulate
 * lines in a buffer and hand them "print_line()".  (If there's a
 * complete line in a buffer - i.e., there's nothing of the line in
 * the previous buffer or the next buffer - it can just hand that to
 * "print_line()" after filtering out non-printables, as an
 * optimization.)
 *
 * This might or might not be the reason why C arrays display
 * correctly but get extra blank lines very other line when printed.
 */
frs_return_t
FollowStreamDialog::readFollowStream()
{
    guint32 global_client_pos = 0, global_server_pos = 0;
    guint32 *global_pos;
    gboolean skip;
    GList* cur;
    frs_return_t frs_return;
    follow_record_t *follow_record;
    QElapsedTimer elapsed_timer;

    elapsed_timer.start();

    for (cur = follow_info_.payload; cur; cur = g_list_next(cur)) {
        if (dialogClosed()) break;

        follow_record = (follow_record_t *)cur->data;
        skip = FALSE;
        if (!follow_record->is_server) {
            global_pos = &global_client_pos;
            if(follow_info_.show_stream == FROM_SERVER) {
                skip = TRUE;
            }
        } else {
            global_pos = &global_server_pos;
            if (follow_info_.show_stream == FROM_CLIENT) {
                skip = TRUE;
            }
        }

        QByteArray buffer;
        if (!skip) {
            // We want a deep copy.
            buffer.clear();
            buffer.append((const char *) follow_record->data->data,
                                     follow_record->data->len);
            frs_return = showBuffer(
                        buffer.data(),
                        follow_record->data->len,
                        follow_record->is_server,
                        follow_record->packet_num,
                        global_pos);
            if(frs_return == FRS_PRINT_ERROR)
                return frs_return;
            if (elapsed_timer.elapsed() > info_update_freq_) {
                fillHintLabel(ui->teStreamContent->textCursor().position());
                wsApp->processEvents();
                elapsed_timer.start();
            }
        }
    }

    return FRS_OK;
}
예제 #21
0
파일: record.cpp 프로젝트: PetrosW/pDub
void Record::createWaveFormPic(Ffmpeg_t *ffmpeg, QString recortPath) {

    std::pair<std::vector<double>, std::vector<double> > dataWaveForm = ffmpeg->getSamplesForWaveformPlotting(recortPath + "/" + m_Name);
    QCustomPlot Plotter;
    Plotter.setBackground(QBrush(Qt::transparent) );
    Plotter.xAxis->setVisible(false);
    Plotter.yAxis->setVisible(false);
    Plotter.axisRect()->setAutoMargins(QCP::msNone);
    Plotter.axisRect()->setMargins(QMargins(0, 5, 0, 5));
    QCPGraph *Waveform = Plotter.addGraph();
    Waveform->setPen(QPen(Qt::green) );

    if (!Waveform)
    {
        qDebug("addGraph failed\n");
    }

    QVector<double> Amplitudes(QVector<double>::fromStdVector(dataWaveForm.first) );
    QVector<double> Time;

    double CurrentTime = 0;
    auto TimeSlotCount = Amplitudes.size();

    for (int64_t i = 1; i < TimeSlotCount; i++)
    {
        Time.append(CurrentTime);
        CurrentTime += 0.5;
    }

    Waveform->setData(Time, Amplitudes);
    Plotter.xAxis->setRange(0, Time.back() );
    Plotter.yAxis->setRange(SHRT_MIN, SHRT_MAX);

    QByteArray ByteArray;
    QBuffer Buffer(&ByteArray);
    Buffer.open(QBuffer::WriteOnly);
    uint32_t time = m_EndTime - m_StartTime;
    for (int i = 1; i < 10000; i*=10) {
        Plotter.toPixmap(time/(i), this->height()).save(&Buffer, "PNG", 0);
        //Plotter.saveJpg(recortPath + "/plot" + QString::number(m_Id) + QString::number(i) + ".jpg", time/(i), this->height());

        QPixmap Pixmap;
        Pixmap.loadFromData(ByteArray, "PNG");
        v_PixWaves.append(Pixmap);

        ByteArray.clear();
        Buffer.reset();
    }
    Buffer.close();
    qDebug() << m_WavePic->margin();
    // místo 2 podle toho jaký zoom
    m_WavePic->setPixmap(v_PixWaves[2]);

}
예제 #22
0
qint64 QV4ProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
{
    QByteArray message;
    while (true) {
        while (!stack.isEmpty() && (dataPos == data.length() ||
                                    stack.top() <= data[dataPos].start)) {
            if (stack.top() > until)
                return finalizeMessages(until, messages, stack.top());

            appendMemoryEvents(stack.top(), messages);
            QQmlDebugStream d(&message, QIODevice::WriteOnly);
            d << stack.pop() << RangeEnd << Javascript;
            messages.append(message);
        }
        while (dataPos != data.length() && (stack.empty() || data[dataPos].start < stack.top())) {
            const QV4::Profiling::FunctionCallProperties &props = data[dataPos];
            if (props.start > until)
                return finalizeMessages(until, messages, props.start);

            appendMemoryEvents(props.start, messages);

            QQmlDebugStream d_start(&message, QIODevice::WriteOnly);
            d_start << props.start << RangeStart << Javascript;
            messages.push_back(message);
            message.clear();
            QQmlDebugStream d_location(&message, QIODevice::WriteOnly);
            d_location << props.start << RangeLocation << Javascript << props.file << props.line
                       << props.column;
            messages.push_back(message);
            message.clear();
            QQmlDebugStream d_data(&message, QIODevice::WriteOnly);
            d_data << props.start << RangeData << Javascript << props.name;
            messages.push_back(message);
            message.clear();
            stack.push(props.end);
            ++dataPos;
        }
        if (stack.empty() && dataPos == data.length())
            return finalizeMessages(until, messages, -1);
    }
}
예제 #23
0
void QgsRequestHandler::setupParameters()
{
  const QgsServerRequest::Parameters parameters = mRequest.parameters();

  // SLD

  QString value = parameters.value( QStringLiteral( "SLD" ) );
  if ( !value.isEmpty() )
  {
    // XXX Why keeping this ????
#if QT_VERSION < 0x050000
    QByteArray fileContents;
    if ( value.startsWith( "http", Qt::CaseInsensitive ) )
    {
      QgsHttpTransaction http( value );
      if ( !http.getSynchronously( fileContents ) )
      {
        fileContents.clear();
      }
    }
    else if ( value.startsWith( "ftp", Qt::CaseInsensitive ) )
    {
      Q_NOWARN_DEPRECATED_PUSH;
      QgsFtpTransaction ftp;
      if ( !ftp.get( value, fileContents ) )
      {
        fileContents.clear();
      }
      value = QUrl::fromPercentEncoding( fileContents );
      Q_NOWARN_DEPRECATED_POP;
    }

    if fileContents.size() > 0 )
    {
      mRequest.setParameter( QStringLiteral( "SLD" ),  QUrl::fromPercentEncoding( fileContents ) );
    }
#else
    QgsMessageLog::logMessage( QStringLiteral( "http and ftp methods not supported with Qt5." ) );
#endif

  }
예제 #24
0
// write message to client-side client
void Client::writeMessage(Request *request){
	QByteArray buffer;
	buffer.clear();
	buffer.append(request->toQString());

//	qDebug() << "Client ----- writing message -----";
	qDebug() << "Client: " << buffer << endl;
	request->print();

	socket->write(buffer);
	socket->flush();
}
예제 #25
0
파일: pki_base.cpp 프로젝트: jbfavre/xca
uint32_t pki_base::intFromData(QByteArray &ba)
{
	/* For import "oldFromData" use the endian dependent version */
	uint32_t ret;
	if ((unsigned)(ba.count()) < sizeof(uint32_t)) {
		ba.clear();
		return 0;
	}
	memcpy(&ret, ba.constData(), sizeof(uint32_t));
	ba = ba.mid(sizeof(uint32_t));
	return ret;
}
예제 #26
0
void HttpInterface::post(QUrl url, QByteArray data, HttpInterface *interface)
{
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QByteArray *buffer = new QByteArray();
    buffer->clear();
    QNetworkRequest request;
    request.setHeader(QNetworkRequest::ContentTypeHeader, QString("text/xml"));
    request.setUrl(url);
    QNetworkReply *reply = manager->post(request,data);
    connect(reply,&QNetworkReply::readyRead,[=](){buffer->append(reply->readAll());});
    connect(reply,&QNetworkReply::finished,[=](){finished(*buffer, interface);});
}
static void writeFromBuffer(int fd, QByteArray& buffer)
{
    int n = ::write(fd, buffer.data(), buffer.size());
    if (n == -1) {
        qDebug() << "Failed to write to " << fd;
        exit(-1);
    }
    if (n < buffer.size())
        buffer = buffer.mid(n);
    else
        buffer.clear();
}
void resetXPropertyStubData()
{
    gStatusBarPixmapPropertyType = 0;
    gStatusBarPixmapPropertyFormat = 0;
    gStatusBarPixmapPropertyData.clear();
    gStatusBarPixmapPropertyReturnStatus = 0;

    gStatusBarPropertyWindowPropertyType = 0;
    gStatusBarPropertyWindowPropertyFormat = 0;
    gStatusBarPropertyWindowPropertyData = 0;
    gStatusBarPropertyWindowPropertyReturnStatus = 0;
}
예제 #29
0
void TerminalEmulator::update()
{
    QByteArray text;

    unsigned char startColumn = 0;
    unsigned char startRow = 0;

    int bufferWidth = displayBuffer->size().width();
    int bufferHeight = displayBuffer->size().height();

    terminalDisplay->clear();

    for (int row = 0; row < bufferHeight; ++row) {
        for (int column = 0; column < bufferWidth; ++column) {
            unsigned char character = displayBuffer->characterAt(column+1, row+1);
            if (character >= 0x20 && character <= 0x3f) {
                if (text.length() > 0) {
                    terminalDisplay->displayText(startColumn, startRow, codec->toUnicode(text));
                    text.clear();
                }
                terminalDisplay->displayAttribute(character);
            } else {
                if (text.isEmpty()) {
                    startColumn = column+1;
                    startRow = row+1;
                }
                text += (character == '\0' ? '\x40': character);
            }
        }

        if (text.length() > 0) {
            terminalDisplay->displayText(startColumn, startRow, codec->toUnicode(text));
            text.clear();
        }
    }

    terminalDisplay->displayCursor(cursor.column(), cursor.row());

    emit updateFinished();
}
예제 #30
0
QByteArray StandardSerialPortBackend::readRawFrame(uint size, bool verbose)
{
//    qDebug() << "!d" << tr("DBG -- Serial Port readRawFrame...");

    QByteArray data;
    DWORD result;
    OVERLAPPED ov;

    memset(&ov, 0, sizeof(ov));
    ov.hEvent = CreateEvent(0, true, false, 0);

    if (ov.hEvent == INVALID_HANDLE_VALUE) {
        qCritical() << "!e" << tr("Cannot create event: %1").arg(lastErrorMessage());
        return data;
    }

    data.resize(size);
    if (!ReadFile(mHandle, data.data(), size, &result, &ov)) {
        if (GetLastError() == ERROR_IO_PENDING) {
            if (!GetOverlappedResult(mHandle, &ov, &result, true)) {
                qCritical() << "!e" << tr("Cannot read from serial port: %1").arg(lastErrorMessage());
                data.clear();
                CloseHandle(ov.hEvent);
                return data;
            }
        } else {
            qCritical() << "!e" << tr("Cannot read from serial port: %1").arg(lastErrorMessage());
            data.clear();
            CloseHandle(ov.hEvent);
            return data;
        }
    }
    CloseHandle(ov.hEvent);
    if (verbose && result != (DWORD)size) {
        qCritical() << "!e" << tr("Serial port read timeout.");
        data.clear();
        return data;
    }
    return data;
}