QByteArray MarketSession::executeRawHttpsQuery(const QByteArray &request) { QByteArray data; QUrl url("https://android.clients.google.com/market/api/ApiRequest"); QNetworkAccessManager manager; QNetworkRequest req; req.setUrl(url); req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); req.setRawHeader("Cookie",QString("ANDROIDSECURE=%1").arg(authSubToken).toUtf8()); req.setRawHeader("User-Agent", "Android-Market/2 (sapphire PLAT-RC33); gzip"); req.setRawHeader("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"); QString requestData=QString("version=%1&request=%2") .arg(PROTOCOL_VERSION).arg(QString(request.toBase64())); QNetworkReply* http = manager.post(req,requestData.toUtf8()); QEventLoop eventLoop; connect(http,SIGNAL(finished()),&eventLoop, SLOT(quit())); eventLoop.exec(); data=gzipDecompress(http->read(http->header(QNetworkRequest::ContentLengthHeader).toUInt())); delete http; return data; }
void SwfToHtml5::parseJSON(QJsonObject jsonObject) { m_operationResult.append(jsonObject["result"].toObject()["response"].toObject()["status"].toString()); QByteArray jsonData; jsonData.append(jsonObject["result"].toObject()["response"].toObject()["output"].toString()); jsonData = jsonData.replace("-", "+"); jsonData = jsonData.replace("_", "/"); jsonData = QByteArray::fromBase64(jsonData); //decompress QByteArray decGzipBa; gzipDecompress(jsonData, decGzipBa); QFile html5File(m_nameOfFile); html5File.open(QIODevice::WriteOnly); html5File.write(decGzipBa); html5File.close(); m_nameOfFile.clear(); QListWidgetItem *lstItem = m_filesLstWgt->item(cnt); QString data; data = lstItem->text(); data += " " + m_operationResult; lstItem->setText(data); m_operationResult.clear(); }
void MainWindow::onItemDoubleClicked(QModelIndex topLeft){ RyPipeData_ptr data = sortFilterProxyModel->getItem(topLeft); if(data.isNull()){ qDebug()<<QString("isNull %1").arg(topLeft.row()); return; } ui->toolTabs->setCurrentWidget(ui->inspectorTab); ui->requestInspectorTabs->setCurrentWidget(ui->requestInspectorTextview); // TODO: test ui->requestTextEdit->setPlainText(data->requestHeaderRawData() +"\r\n\r\n"+data->requestBodyRawData() ); QByteArray encoding("UTF-8"); QString contentType = data->getResponseHeader("Content-Type"); int encodingIndex = contentType.indexOf("charset="); if(encodingIndex!=-1){ encoding.clear(); encoding.append(contentType.mid(encodingIndex + 8)); } bool isEncrypted = !data->getResponseHeader("Content-Encoding").isEmpty(); QByteArray decrypedData = (data->isResponseChunked()? data->responseBodyRawDataUnChunked() :data->responseBodyRawData()); if(isEncrypted){ decrypedData = gzipDecompress(decrypedData); } //TODO: gif //QMovie *movie = ui->label->movie(); //if(movie){ // delete movie; //} if(data->getResponseHeader("Content-Type").toLower().indexOf("image")!=-1){ if(!decrypedData.isEmpty()){ if(data->getResponseHeader("Content-Type").toLower().indexOf("gif")!=-1){ //QBuffer *data = new QBuffer(&decrypedData); //QMovie *movie = new QMovie(data); //ui->label->setMovie(movie); //TODO: start and delete movie.. }else{ QPixmap pixmap; pixmap.loadFromData(decrypedData); ui->label->setPixmap(pixmap); } ui->responseInspectorTabs->setCurrentWidget(ui->responseInspectorImageView); }else{ ui->responseInspectorTabs->setCurrentWidget(ui->responseInspectorTextView); ui->label->clear(); } }else{ ui->label->clear(); ui->responseInspectorTabs->setCurrentWidget(ui->responseInspectorTextView); } // show in textview QTextCodec* oldCodec = QTextCodec::codecForCStrings(); QTextCodec::setCodecForCStrings(QTextCodec::codecForName(encoding)); ui->responseTextEdit->setPlainText(QString(( data->responseHeaderRawData() +"\r\n\r\n" + decrypedData ).data()) ); QTextCodec::setCodecForCStrings(oldCodec); data.clear(); }
/** * Handles a file on the command line. * * @returns exit code. * @param pszFile The file to handle. * @param fStdOut Whether to output to standard output or not. * @param fForce Whether to output to or input from terminals. * @param phVfsStdOut Pointer to the standard out handle. * (input/output) */ static RTEXITCODE gzipDecompressFile(const char *pszFile, bool fStdOut, bool fForce, PRTVFSIOSTREAM phVfsStdOut) { /* * Open the specified input file. */ const char *pszError; RTVFSIOSTREAM hVfsIn; int rc = RTVfsChainOpenIoStream(pszFile, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsIn, &pszError); if (RT_FAILURE(rc)) { if (pszError && *pszError) return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsChainOpenIoStream failed with rc=%Rrc:\n" " '%s'\n", " %*s^\n", rc, pszFile, pszError - pszFile, ""); return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTVfsChainOpenIoStream failed with rc=%Rrc: '%s'", rc, pszFile); } /* * Output the output file. */ RTVFSIOSTREAM hVfsOut; char szFinal[RTPATH_MAX]; if (fStdOut) { if (*phVfsStdOut == NIL_RTVFSIOSTREAM) { rc = RTVfsIoStrmFromStdHandle(RTHANDLESTD_OUTPUT, 0 /*fOpen*/, true /*fLeaveOpen*/, phVfsStdOut); if (RT_FAILURE(rc)) return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to set up standard out: %Rrc", rc); } hVfsOut = *phVfsStdOut; szFinal[0] = '\0'; } else { rc = RTStrCopy(szFinal, sizeof(szFinal), pszFile); /** @todo remove the extension? Or are we supposed * to get the org name from the gzip stream? */ return RTMsgErrorExit(RTEXITCODE_FAILURE, "Decompressing to file is not implemented"); } /* * Do the decompressing, then flush and close the output stream (unless * it is stdout). */ RTEXITCODE rcExit = gzipDecompress(hVfsIn, hVfsOut); RTVfsIoStrmRelease(hVfsIn); rc = RTVfsIoStrmFlush(hVfsOut); if (RT_FAILURE(rc)) rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to flush the output file: %Rrc", rc); RTVfsIoStrmRelease(hVfsOut); /* * Remove the input file, if that's the desire of the caller, or * remove the output file on decompression failure. */ if (!fStdOut) { if (rcExit == RTEXITCODE_SUCCESS) { rc = RTFileDelete(pszFile); if (RT_FAILURE(rc)) rcExit = RTMsgErrorExit(RTEXITCODE_FAILURE, "RTFileDelete failed with %rc: '%s'", rc, pszFile); } else { /* should we do this? */ rc = RTFileDelete(szFinal); if (RT_FAILURE(rc)) RTMsgError("RTFileDelete failed with %rc: '%s'", rc, pszFile); } } return rcExit; }
void ParserHafasBinary::parseSearchJourney(QNetworkReply *networkReply) { lastJourneyResultList = new JourneyResultList(); journeyDetailInlineData.clear(); QByteArray tmpBuffer = networkReply->readAll(); QByteArray buffer = gzipDecompress(tmpBuffer); /* QFile file("f://out.txt"); file.open(QIODevice::WriteOnly); file.write(buffer); file.close(); */ QDataStream hafasData(buffer); hafasData.setByteOrder(QDataStream::LittleEndian); qint16 hafasVersion; hafasData >> hafasVersion; if (hafasVersion != 5 && hafasVersion != 6) { qWarning()<<"Wrong version of hafas binary data"; emit errorOccured(tr("An error ocurred with the backend")); return; } qDebug()<<"Binary-Data Version: "<<hafasVersion; //Basic data offsets qint32 serviceDaysTablePtr; qint32 stringTablePtr; qint32 stationTablePtr; qint32 commentTablePtr; qint32 extensionHeaderPtr; qint32 extensionHeaderLength; qint16 errorCode; hafasData.device()->seek(0x20); hafasData >> serviceDaysTablePtr; hafasData >> stringTablePtr; hafasData.device()->seek(0x36); hafasData >> stationTablePtr; hafasData >> commentTablePtr; hafasData.device()->seek(0x46); hafasData >> extensionHeaderPtr; hafasData.device()->seek(extensionHeaderPtr); hafasData >> extensionHeaderLength; hafasData.device()->seek(extensionHeaderPtr + 16); hafasData >> errorCode; //Debug data offsets qDebug()<<serviceDaysTablePtr<<stringTablePtr; qDebug()<<stationTablePtr<<commentTablePtr; qDebug()<<extensionHeaderPtr<<extensionHeaderLength; qDebug()<<errorCode; //Read strings hafasData.device()->seek(stringTablePtr); QMap<int, QString> strings; QString tmpString; for (int num = 0; num < (serviceDaysTablePtr - stringTablePtr); num++) { qint8 c; hafasData>>c; if (c == 0) { strings.insert((num - tmpString.length()), tmpString.trimmed()); tmpString.clear(); } else { tmpString.append((char)c); } } //Looks ok, parsing if (errorCode == 0) { hafasData.device()->seek(extensionHeaderPtr + 0x8); qint16 seqNr; qint16 requestIdPtr; qint16 encodingPtr; qint32 connectionDetailsPtr; qint32 attrsOffset; qint16 ldPtr; hafasData >> seqNr; hafasData >> requestIdPtr; hafasData >> connectionDetailsPtr; hafasData.device()->seek(hafasData.device()->pos() + 16); hafasData >> encodingPtr; hafasData >> ldPtr; hafasData >> attrsOffset; QString encoding = strings[encodingPtr]; QString requestId = strings[requestIdPtr]; QString ld = strings[ldPtr]; qint32 connectionAttrsPtr; if (extensionHeaderLength >= 0x30) { if (extensionHeaderLength < 0x32) { qWarning()<<"too short: " + extensionHeaderLength; return; } hafasData.device()->seek(extensionHeaderPtr + 0x2c); hafasData >> connectionAttrsPtr; } else {