QString SCPageLayout::saveOdf(KoPASavingContext &context) const { KOdfGenericStyle style(KOdfGenericStyle::PresentationPageLayoutStyle); style.addAttribute("style:display-name", m_name); QBuffer buffer; buffer.open(QIODevice::WriteOnly); KXmlWriter elementWriter(&buffer); QList<SCPlaceholder *>::const_iterator it(m_placeholders.begin()); for (; it != m_placeholders.end(); ++it) { (*it)->saveOdf(elementWriter); } QString placeholders = QString::fromUtf8(buffer.buffer(), buffer.buffer().size()); style.addChildElement("placeholders", placeholders); // return the style name so we can save the ptr -> style in the saving context so the pages can use it during saving return context.mainStyles().insert(style, "pl"); }
// Example how to get json using shared memory. Not tested :-D std::pair<bool, QString> json() { QSharedMemory sharedMemory; if (!sharedMemory.attach()) { return std::make_pair<bool, QString>(false, QString()); } QBuffer buffer; QDataStream in(&buffer); QString json; sharedMemory.lock(); buffer.setData((char*)sharedMemory.constData(), sharedMemory.size()); buffer.open(QBuffer::ReadOnly); in >> json; sharedMemory.unlock(); sharedMemory.detach(); return std::make_pair<bool, QString>(false, QString()); }
void Dialog::loadFromMemory() { if (!sharedMemory.attach()) { ui->label->setText(tr("无法连接到共享内存段,\n" "请先加载一张图片!")); return; } QBuffer buffer; QDataStream in(&buffer); QImage image; sharedMemory.lock(); buffer.setData((char*)sharedMemory.constData(), sharedMemory.size()); buffer.open(QBuffer::ReadOnly); in >> image; sharedMemory.unlock(); sharedMemory.detach(); ui->label->setPixmap(QPixmap::fromImage(image)); }
void FSTReader::writeVariant(QBuffer& buffer, QVariantHash::const_iterator& it) { QByteArray key = it.key().toUtf8() + " = "; QVariantHash hashValue = it.value().toHash(); if (hashValue.isEmpty()) { buffer.write(key + it.value().toByteArray() + "\n"); return; } for (QVariantHash::const_iterator second = hashValue.constBegin(); second != hashValue.constEnd(); second++) { QByteArray extendedKey = key + second.key().toUtf8(); QVariantList listValue = second.value().toList(); if (listValue.isEmpty()) { buffer.write(extendedKey + " = " + second.value().toByteArray() + "\n"); continue; } buffer.write(extendedKey); for (QVariantList::const_iterator third = listValue.constBegin(); third != listValue.constEnd(); third++) { buffer.write(" = " + third->toByteArray()); } buffer.write("\n"); } }
//! [3] void Dialog::loadFromMemory() { if (!sharedMemory.attach()) { ui.label->setText(tr("Unable to attach to shared memory segment.\n" \ "Load an image first.")); return; } QBuffer buffer; QDataStream in(&buffer); QImage image; sharedMemory.lock(); buffer.setData((char*)sharedMemory.constData(), sharedMemory.size()); buffer.open(QBuffer::ReadOnly); in >> image; sharedMemory.unlock(); sharedMemory.detach(); ui.label->setPixmap(QPixmap::fromImage(image)); }
void XMLHttpRequest::send(const QString &body) { Logger::log("XMLHttpRequest::send(): Body: " + body); switch (readyState()) { case HEADERS_RECEIVED: case LOADING: return; default: break; } m_redirects = 0; QBuffer *buffer = new QBuffer; buffer->setData(body.toUtf8()); buffer->open(QBuffer::ReadOnly); m_reply = networkAccessManager()->sendCustomRequest(m_request, m_method, buffer); buffer->setParent(m_reply); connect(m_reply, SIGNAL(metaDataChanged()), this, SLOT(onReplyMetaDataChanged())); connect(m_reply, SIGNAL(readyRead()), this, SLOT(onReplyReadyRead())); connect(m_reply, SIGNAL(finished()), this, SLOT(onReplyFinished())); }
void CollectionScanner::ScanningState::readFull() { if( !isValid() ) return; QBuffer buffer; QDataStream in(&buffer); m_sharedMemory->lock(); buffer.setData((char*)m_sharedMemory->constData(), m_sharedMemory->size()); buffer.open(QBuffer::ReadOnly); in >> m_lastDirectory; in >> m_directories; in >> m_badFiles; m_lastFilePos = buffer.pos(); in >> m_lastFile; m_sharedMemory->unlock(); }
void tst_QNetworkCacheMetaData::stream() { QNetworkCacheMetaData data; data.setUrl(QUrl(EXAMPLE_URL)); QNetworkCacheMetaData::RawHeaderList headers; headers.append(QNetworkCacheMetaData::RawHeader("foo", "Bar")); data.setRawHeaders(headers); data.setLastModified(QDateTime::currentDateTime()); data.setExpirationDate(QDateTime::currentDateTime()); data.setSaveToDisk(false); QBuffer buffer; buffer.open(QIODevice::ReadWrite); QDataStream stream(&buffer); stream << data; buffer.seek(0); QNetworkCacheMetaData data2; stream >> data2; QCOMPARE(data2, data); }
/** * \warning The caller has to delete the archive's underlying device */ KTar* ModelManager::archiveFromBuffer(const QByteArray& input) { // safely remove the const qualifier as the buffer is only opened read-only QBuffer buffer(const_cast<QByteArray*>(&input)); if (!buffer.open(QIODevice::ReadOnly)) return 0; QIODevice *uncompressed = KFilterDev::device(&buffer, "application/x-gzip", false); if (!uncompressed || !uncompressed->open(QIODevice::ReadOnly)) return 0; //seeking doesn't work properly in kfilterdevs, which trips up KTar. Instead, decompress //completely before passing it on to KTar QBuffer *uncompressedBuffer = new QBuffer; if (!uncompressedBuffer->open(QIODevice::ReadWrite)) return 0; uncompressedBuffer->write(uncompressed->readAll()); uncompressedBuffer->seek(0); delete uncompressed; return new KTar(uncompressedBuffer); }
static HeadersMap parseHeaders(const QByteArray& headerData) { HeadersMap headersMap; QBuffer sourceBuffer; sourceBuffer.setData(headerData); sourceBuffer.open(QIODevice::ReadOnly); // The first line is special, it's the GET or POST line const QList<QByteArray> firstLine = sourceBuffer.readLine().split(' '); if (firstLine.count() < 3) { qDebug() << "Malformed HTTP request:" << firstLine; return headersMap; } const QByteArray requestType = firstLine.at(0); const QByteArray path = QDir::cleanPath(QString::fromLatin1(firstLine.at(1).constData())).toLatin1(); const QByteArray httpVersion = firstLine.at(2); headersMap.insert("_requestType", requestType); headersMap.insert("_path", path); headersMap.insert("_httpVersion", httpVersion); while (!sourceBuffer.atEnd()) { const QByteArray line = sourceBuffer.readLine(); const int pos = line.indexOf(':'); if (pos == -1) qDebug() << "Malformed HTTP header:" << line; const QByteArray header = line.left(pos).toLower(); // RFC2616 section 4.2 "Field names are case-insensitive" const QByteArray value = line.mid(pos+1).trimmed(); // remove space before and \r\n after //qDebug() << "HEADER" << header << "VALUE" << value; headersMap.insert(header, value); } return headersMap; }
/*! * Store contact */ CArrayFixFlat<TUid>* CNsmlContactsDataStoreExtensionPrivate::ImportContactsL( const TDesC8 &contactbufbase ) { _DBG_FILE("CNsmlContactsDataStoreExtensionPrivate::ImportContactsL: BEGIN"); DBG_DUMP((void*)contactbufbase.Ptr(), contactbufbase.Length(), _S8("CNsmlContactsDataStoreExtensionPrivate::ImportContactsL: To DB :")); TBool ret( ETrue ); CArrayFixFlat<TUid>* contactItems = new(ELeave) CArrayFixFlat<TUid>(4); QBuffer contactsbuf; contactsbuf.open(QBuffer::ReadWrite); QByteArray bytearray((char*)contactbufbase.Ptr()); contactsbuf.write(bytearray); contactsbuf.seek(0); mReader->setDevice(&contactsbuf); if (mReader->startReading() && mReader->waitForFinished()) { DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Buffer Count: %d"), mReader->results().count() ); QList<QContact> contacts; if ( mImporter->importDocuments( mReader->results() ) ) { contacts = mImporter->contacts(); QMap<int, QContactManager::Error> errorMap; ret = mContactManager->saveContacts( &contacts, &errorMap ); DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Import Status: %d"), ret ); } if( ret ) { foreach (QContact contact, contacts ) { TUint contactid = contact.id().localId(); DBG_ARGS(_S("CNsmlContactsDataStoreExtensionPrivate::Contact ID: %d"), contactid ); contactItems->AppendL( TUid::Uid( contactid ) ); } }
bool FileExporterXSLT::save(QIODevice *iodevice, const QSharedPointer<const Element> element, const File *bibtexfile, QStringList *errorLog) { if (!iodevice->isWritable() && !iodevice->open(QIODevice::WriteOnly)) { qCWarning(LOG_KBIBTEX_IO) << "Output device not writable"; return false; } m_cancelFlag = false; XSLTransform xsltransformer(m_xsltFilename); FileExporterXML xmlExporter; QBuffer buffer; buffer.open(QIODevice::WriteOnly); if (xmlExporter.save(&buffer, element, bibtexfile, errorLog)) { buffer.close(); buffer.open(QIODevice::ReadOnly); const QString xml = QString::fromUtf8(buffer.readAll().constData()); buffer.close(); const QString html = xsltransformer.transform(xml); if (!html.isEmpty()) { iodevice->write(html.toUtf8()); iodevice->close(); return !m_cancelFlag; } } iodevice->close(); return false; }
void StationsPluginSimple::saveDiskCache() { QDomDocument doc; QFile file(diskCache()); QBuffer buffer; buffer.open(QIODevice::ReadWrite); buffer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); buffer.write("<cache>\n"); buffer.write(" <stations>\n"); foreach (Station *station, stations) { QString data = " <station id=\"%1\">\n" " <name>%2</name>\n" " <description>%3</description>\n" " <latitude>%4</latitude>\n" " <longitude>%5</longitude>\n" " </station>\n"; buffer.write(data.arg(station->id()) .arg(station->name()) .arg(station->description()) .arg(station->pos().x()) .arg(station->pos().y()) .toUtf8()); }
void Usage::registerUsage() { if (! g.s.bUsage || g.s.bFirstTime) return; QDomDocument doc; QDomElement root=doc.createElement(QLatin1String("usage")); doc.appendChild(root); QDomElement tag; QDomText t; OSInfo::fillXml(doc, root); tag=doc.createElement(QLatin1String("in")); root.appendChild(tag); t=doc.createTextNode(g.s.qsAudioInput); tag.appendChild(t); tag=doc.createElement(QLatin1String("out")); root.appendChild(tag); t=doc.createTextNode(g.s.qsAudioOutput); tag.appendChild(t); tag=doc.createElement(QLatin1String("lcd")); root.appendChild(tag); t=doc.createTextNode(QString::number(g.lcd->hasDevices() ? 1 : 0)); tag.appendChild(t); QBuffer *qb = new QBuffer(); qb->setData(doc.toString().toUtf8()); qb->open(QIODevice::ReadOnly); QNetworkRequest req(QUrl(QLatin1String("http://mumble.info/usage.cgi"))); req.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml")); QNetworkReply *rep = g.nam->post(req, qb); qb->setParent(rep); connect(rep, SIGNAL(finished()), rep, SLOT(deleteLater())); }
static HeadersMap parseHeaders(const QByteArray& headerData) { HeadersMap headersMap; QBuffer sourceBuffer; sourceBuffer.setData(headerData); sourceBuffer.open(QIODevice::ReadOnly); // The first line is special, it's the GET or POST line const QList<QByteArray> firstLine = sourceBuffer.readLine().split(' '); if (firstLine.count() < 3) { qDebug() << "Malformed HTTP request:" << firstLine; return headersMap; } const QByteArray request = firstLine[0]; const QByteArray path = firstLine[1]; const QByteArray httpVersion = firstLine[2]; if (request != "GET" && request != "POST") { qDebug() << "Unknown HTTP request:" << firstLine; return headersMap; } headersMap.insert("_path", path); headersMap.insert("_httpVersion", httpVersion); while (!sourceBuffer.atEnd()) { const QByteArray line = sourceBuffer.readLine(); const int pos = line.indexOf(':'); if (pos == -1) qDebug() << "Malformed HTTP header:" << line; const QByteArray header = line.left(pos); const QByteArray value = line.mid(pos+1).trimmed(); // remove space before and \r\n after //qDebug() << "HEADER" << header << "VALUE" << value; headersMap.insert(header, value); } return headersMap; }
void KdbxXmlWriter::writeBinaries() { m_xml.writeStartElement("Binaries"); QHash<QByteArray, int>::const_iterator i; for (i = m_idMap.constBegin(); i != m_idMap.constEnd(); ++i) { m_xml.writeStartElement("Binary"); m_xml.writeAttribute("ID", QString::number(i.value())); QByteArray data; if (m_db->compressionAlgorithm() == Database::CompressionGZip) { m_xml.writeAttribute("Compressed", "True"); QBuffer buffer; buffer.open(QIODevice::ReadWrite); QtIOCompressor compressor(&buffer); compressor.setStreamFormat(QtIOCompressor::GzipFormat); compressor.open(QIODevice::WriteOnly); qint64 bytesWritten = compressor.write(i.key()); Q_ASSERT(bytesWritten == i.key().size()); Q_UNUSED(bytesWritten); compressor.close(); buffer.seek(0); data = buffer.readAll(); } else { data = i.key(); } if (!data.isEmpty()) { m_xml.writeCharacters(QString::fromLatin1(data.toBase64())); } m_xml.writeEndElement(); } m_xml.writeEndElement(); }
void TestKeys::testCreateFileKey() { const QString dbName("testCreateFileKey database"); QBuffer keyBuffer; keyBuffer.open(QBuffer::ReadWrite); FileKey::create(&keyBuffer); keyBuffer.reset(); FileKey fileKey; QVERIFY(fileKey.load(&keyBuffer)); CompositeKey compositeKey; compositeKey.addKey(fileKey); Database* dbOrg = new Database(); dbOrg->setKey(compositeKey); dbOrg->metadata()->setName(dbName); QBuffer dbBuffer; dbBuffer.open(QBuffer::ReadWrite); KeePass2Writer writer; writer.writeDatabase(&dbBuffer, dbOrg); dbBuffer.reset(); delete dbOrg; KeePass2Reader reader; Database* dbRead = reader.readDatabase(&dbBuffer, compositeKey); QVERIFY(dbRead); QVERIFY(!reader.hasError()); QCOMPARE(dbRead->metadata()->name(), dbName); delete dbRead; }
void LsColJob::start() { QList<QByteArray> properties = _properties; if (properties.isEmpty()) { qWarning() << "Propfind with no properties!"; } QByteArray propStr; foreach (const QByteArray &prop, properties) { if (prop.contains(':')) { int colIdx = prop.lastIndexOf(":"); auto ns = prop.left(colIdx); if (ns == "http://owncloud.org/ns") { propStr += " <oc:" + prop.mid(colIdx+1) + " />\n"; } else { propStr += " <" + prop.mid(colIdx+1) + " xmlns=\"" + ns + "\" />\n"; } } else { propStr += " <d:" + prop + " />\n"; } } QNetworkRequest req; req.setRawHeader("Depth", "1"); QByteArray xml("<?xml version=\"1.0\" ?>\n" "<d:propfind xmlns:d=\"DAV:\" xmlns:oc=\"http://owncloud.org/ns\">\n" " <d:prop>\n" + propStr + " </d:prop>\n" "</d:propfind>\n"); QBuffer *buf = new QBuffer(this); buf->setData(xml); buf->open(QIODevice::ReadOnly); QNetworkReply *reply = davRequest("PROPFIND", path(), req, buf); buf->setParent(reply); setReply(reply); setupConnections(reply); AbstractNetworkJob::start(); }
void TestCsvExporter::testExport() { Group* groupRoot = m_db->rootGroup(); Group* group = new Group(); group->setName("Test Group Name"); group->setParent(groupRoot); Entry* entry = new Entry(); entry->setGroup(group); entry->setTitle("Test Entry Title"); entry->setUsername("Test Username"); entry->setPassword("Test Password"); entry->setUrl("http://test.url"); entry->setNotes("Test Notes"); QBuffer buffer; QVERIFY(buffer.open(QIODevice::ReadWrite)); m_csvExporter->exportDatabase(&buffer, m_db); QString expectedResult = QString().append(ExpectedHeaderLine).append("\"Test Group Name\",\"Test Entry Title\",\"Test Username\",\"Test Password\",\"http://test.url\",\"Test Notes\"\n"); QCOMPARE(QString::fromUtf8(buffer.buffer().constData()), expectedResult); }
void TMultiplexingServer::setSendRequest(int fd, const THttpHeader *header, QIODevice *body, bool autoRemove, const TAccessLogger &accessLogger) { SendData *sd = new SendData; sd->method = SendData::Send; sd->fd = fd; sd->buffer = 0; QByteArray response = header->toByteArray(); QFileInfo fi; if (body) { QBuffer *buffer = qobject_cast<QBuffer *>(body); if (buffer) { response += buffer->data(); } else { fi.setFile(*qobject_cast<QFile *>(body)); } } sd->buffer = new THttpSendBuffer(response, fi, autoRemove, accessLogger); sendRequests.enqueue(sd); }
void ScreenPacket::setImage(const QImage& image){ /* QPainter painter; painter.begin(&image); painter.fillRect(0, 0, 30, image.height()-10, Qt::white); painter.setPen(Qt::red); painter.setFont(QFont("Courier new", 12)); painter.drawText(5, 10, QString::number(QTime::currentTime().second())); painter.end(); */ QBuffer buffer; buffer.setBuffer(&_buffer); buffer.open(QBuffer::WriteOnly); buffer.seek(0); QImageWriter writer(&buffer, "JPEG"); writer.setQuality(32); writer.setCompression(1); _pixmapGenerated = writer.write(image); _buffer = qCompress(_buffer, 9); //_pixmap = pixmap; _pixmap = QPixmap::fromImage(image); }
static void checkVariant(const QVariant &value, const QByteArray &xml) { // serialise QBuffer buffer; buffer.open(QIODevice::ReadWrite); QXmlStreamWriter writer(&buffer); XMLRPC::marshall(&writer, value); qDebug() << "expect " << xml; qDebug() << "writing" << buffer.data(); QCOMPARE(buffer.data(), xml); // parse QDomDocument doc; QCOMPARE(doc.setContent(xml, true), true); QDomElement element = doc.documentElement(); QStringList errors; QVariant test = XMLRPC::demarshall(element, errors); if (!errors.isEmpty()) qDebug() << errors; QCOMPARE(errors, QStringList()); QCOMPARE(test, value); }
void tst_QBitArray::datastream() { QFETCH(QString, bitField); QFETCH(int, numBits); QFETCH(int, onBits); QBuffer buffer; QVERIFY(buffer.open(QBuffer::ReadWrite)); QDataStream stream(&buffer); QBitArray bits(bitField.size()); for (int i = 0; i < bitField.size(); ++i) { if (bitField.at(i) == QLatin1Char('1')) bits.setBit(i); } QCOMPARE(bits.count(), numBits); QCOMPARE(bits.count(true), onBits); QCOMPARE(bits.count(false), numBits - onBits); stream << bits << bits << bits; buffer.close(); QCOMPARE(stream.status(), QDataStream::Ok); QVERIFY(buffer.open(QBuffer::ReadWrite)); QDataStream stream2(&buffer); QBitArray array1, array2, array3; stream2 >> array1 >> array2 >> array3; QCOMPARE(array1.count(), numBits); QCOMPARE(array1.count(true), onBits); QCOMPARE(array1.count(false), numBits - onBits); QCOMPARE(array1, bits); QCOMPARE(array2, bits); QCOMPARE(array3, bits); }
void ErrorHandler::handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, const QSourceLocation &) { /* Don't use pDebug() in this function, it results in infinite * recursion. Talking from experience.. */ Message msg; msg.setType(type); msg.setIdentifier(identifier); /* Let's remove all the XHTML markup. */ QBuffer buffer; buffer.setData(description.toLatin1()); buffer.open(QIODevice::ReadOnly); QXmlQuery query; query.bindVariable(QLatin1String("desc"), &buffer); query.setQuery(QLatin1String("string(doc($desc))")); QStringList result; const bool success = query.evaluateTo(&result); if(!description.startsWith(QLatin1String("\"Test-suite harness error:"))) { const QString msg(QString::fromLatin1("Invalid description: %1").arg(description)); QVERIFY2(success, qPrintable(msg)); if(!success) QTextStream(stderr) << msg; } if(!result.isEmpty()) msg.setDescription(result.first()); m_messages.append(msg); }
void ScreenShotSaveDialog::render () { RenderScheduled_ = false; if (!Ui_.PreviewBox_->isChecked ()) { Ui_.FileSizeLabel_->setText (tr ("File size unknown")); PixmapHolder_->setPixmap (QPixmap ()); PixmapHolder_->resize (1, 1); return; } QString format = Ui_.FormatCombobox_->currentText (); int quality = Ui_.QualitySlider_->value (); QBuffer renderBuffer; Source_.save (&renderBuffer, qPrintable (format), quality); QByteArray renderData = renderBuffer.data (); Rendered_.loadFromData (renderData); Ui_.FileSizeLabel_->setText (Util::MakePrettySize (renderData.size ())); PixmapHolder_->setPixmap (Rendered_); PixmapHolder_->resize (Rendered_.size ()); }
void ProppatchJob::start() { if (_properties.isEmpty()) { qCWarning(lcProppatchJob) << "Proppatch with no properties!"; } QNetworkRequest req; QByteArray propStr; QMapIterator<QByteArray, QByteArray> it(_properties); while (it.hasNext()) { it.next(); QByteArray keyName = it.key(); QByteArray keyNs; if (keyName.contains(':')) { int colIdx = keyName.lastIndexOf(":"); keyNs = keyName.left(colIdx); keyName = keyName.mid(colIdx + 1); } propStr += " <" + keyName; if (!keyNs.isEmpty()) { propStr += " xmlns=\"" + keyNs + "\" "; } propStr += ">"; propStr += it.value(); propStr += "</" + keyName + ">\n"; } QByteArray xml = "<?xml version=\"1.0\" ?>\n" "<d:propertyupdate xmlns:d=\"DAV:\">\n" " <d:set><d:prop>\n" + propStr + " </d:prop></d:set>\n" "</d:propertyupdate>\n"; QBuffer *buf = new QBuffer(this); buf->setData(xml); buf->open(QIODevice::ReadOnly); sendRequest("PROPPATCH", makeDavUrl(path()), req, buf); AbstractNetworkJob::start(); }
QDataStream &operator<<(QDataStream &rStream, const LogError &rLogError) { QBuffer buffer; buffer.open(QIODevice::WriteOnly); QDataStream stream(&buffer); // version quint16 version = 0; stream << version; // version 0 data stream << rLogError.mCode << rLogError.mContext << rLogError.mMessage << rLogError.mSymbol << rLogError.mArgs << rLogError.mCausingErrors; buffer.close(); rStream << buffer.buffer(); return rStream; }
void tst_qquicktextdocument::textDocumentWriter() { QQmlEngine e; QQmlComponent c(&e, testFileUrl("text.qml")); QObject* o = c.create(); QVERIFY(o); QQuickTextEdit *edit = qobject_cast<QQuickTextEdit*>(o); QVERIFY(edit); QQuickTextDocument* quickDocument = qobject_cast<QQuickTextDocument*>(edit->property("textDocument").value<QObject*>()); QVERIFY(quickDocument->textDocument() != 0); QBuffer output; output.open(QBuffer::ReadWrite); QVERIFY(output.buffer().isEmpty()); edit->setProperty("text", QVariant(text)); QTextDocumentWriter writer(&output, "plaintext"); QVERIFY(writer.write(quickDocument->textDocument())); QCOMPARE(output.buffer(), text.toLatin1()); delete o; }
bool KoOdfPaste::paste(KoOdf::DocumentType documentType, const QByteArray &bytes) { if (bytes.isEmpty()) return false; QBuffer buffer; buffer.setData(bytes); KoStore * store = KoStore::createStore(&buffer, KoStore::Read); store->disallowNameExpansion(); KoOdfReadStore odfStore(store); // KoOdfReadStore does not delete the store on destruction QString errorMessage; if (! odfStore.loadAndParse(errorMessage)) { kWarning(30002) << "loading and parsing failed:" << errorMessage; delete store; return false; } KoXmlElement content = odfStore.contentDoc().documentElement(); KoXmlElement realBody(KoXml::namedItemNS(content, KoXmlNS::office, "body")); if (realBody.isNull()) { kWarning(30002) << "No body tag found"; delete store; return false; } KoXmlElement body = KoXml::namedItemNS(realBody, KoXmlNS::office, KoOdf::bodyContentElement(documentType, false)); if (body.isNull()) { kWarning(30002) << "No" << KoOdf::bodyContentElement(documentType, true) << "tag found"; delete store; return false; } bool retval = process(body, odfStore); delete store; return retval; }
void RequestEtagJob::start() { QNetworkRequest req; req.setRawHeader("Depth", "0"); QByteArray xml("<?xml version=\"1.0\" ?>\n" "<d:propfind xmlns:d=\"DAV:\">\n" " <d:prop>\n" " <d:getetag/>\n" " </d:prop>\n" "</d:propfind>\n"); QBuffer *buf = new QBuffer(this); buf->setData(xml); buf->open(QIODevice::ReadOnly); // assumes ownership sendRequest("PROPFIND", makeDavUrl(path()), req, buf); if (reply()->error() != QNetworkReply::NoError) { qCWarning(lcEtagJob) << "request network error: " << reply()->errorString(); } AbstractNetworkJob::start(); }