本文整理汇总了C++中QBuffer::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QBuffer::setParent方法的具体用法?C++ QBuffer::setParent怎么用?C++ QBuffer::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBuffer
的用法示例。
在下文中一共展示了QBuffer::setParent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void RequestEtagJob::start()
{
QNetworkRequest req;
// Let's always request all entries inside a directory. There are/were bugs in the server
// where a root or root-folder ETag is not updated when its contents change. We work around
// this by concatenating the ETags of the root and its contents.
req.setRawHeader("Depth", "1");
// See https://github.com/owncloud/core/issues/5255 and others
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
setReply(davRequest("PROPFIND", path(), req, buf));
buf->setParent(reply());
setupConnections(reply());
if( reply()->error() != QNetworkReply::NoError ) {
qDebug() << "getting etag: request network error: " << reply()->errorString();
}
AbstractNetworkJob::start();
}
示例2: sendImpl
void YandexNarodUploadJob::sendImpl()
{
setState(Started);
setStateString(QT_TR_NOOP("Creating directory..."));
m_data = setCurrentIndex(0);
// We need only resourcetype to detect if it is a directory
QByteArray data = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
"<propfind xmlns=\"DAV:\">"
"<prop><resourcetype/></prop>"
"</propfind>";
QUrl url(WEBDAV_BASE_URL);
url.setPath(QLatin1String("/qutim-filetransfer/"));
YandexRequest request(url);
request.setRawHeader("Depth", "1");
request.setRawHeader("Content-Length", QByteArray::number(data.size()));
request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
QBuffer *buffer = new QBuffer;
buffer->setData(data);
buffer->open(QIODevice::ReadOnly);
QNetworkReply *reply = YandexNarodFactory::networkManager()
->sendCustomRequest(request, "PROPFIND", buffer);
buffer->setParent(reply);
connect(reply, SIGNAL(finished()), this, SLOT(onDirectoryChecked()));
}
示例3: start
void RequestEtagJob::start()
{
QNetworkRequest req;
if (path().isEmpty() || path() == QLatin1String("/")) {
/* For the root directory, we need to query the etags of all the sub directories
* because, at the time I am writing this comment (Owncloud 5.0.9), the etag of the
* root directory is not updated when the sub directories changes */
req.setRawHeader("Depth", "1");
} else {
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
setReply(davRequest("PROPFIND", path(), req, buf));
buf->setParent(reply());
setupConnections(reply());
if( reply()->error() != QNetworkReply::NoError ) {
qDebug() << "getting etag: request network error: " << reply()->errorString();
}
AbstractNetworkJob::start();
}
示例4: getDirectoryListing
QNetworkReply* ownCloudInfo::getDirectoryListing( const QString& dir )
{
QNetworkRequest req;
req.setUrl( QUrl( webdavUrl(_connection) + dir ) );
req.setRawHeader("Depth", "1");
QByteArray xml("<?xml version=\"1.0\" ?>\n"
"<d:propfind xmlns:d=\"DAV:\">\n"
" <d:prop>\n"
" <d:resourcetype/>\n"
" </d:prop>\n"
"</d:propfind>\n");
QBuffer *buf = new QBuffer;
buf->setData(xml);
buf->open(QIODevice::ReadOnly);
QNetworkReply *reply = davRequest("PROPFIND", req, buf);
buf->setParent(reply);
if( reply->error() != QNetworkReply::NoError ) {
qDebug() << "getting quota: request network error: " << reply->errorString();
}
connect( reply, SIGNAL( finished()), SLOT(slotGetDirectoryListingFinished()) );
connect( reply, SIGNAL( error(QNetworkReply::NetworkError)),
this, SLOT( slotError(QNetworkReply::NetworkError)));
return reply;
}
示例5: updateFileContents
void LYGithubManager::updateFileContents(const QString &path, const QString &commitMessage, const QString &contents, const QString &sha){
if(!isAuthenticated() || repository_.isEmpty() || updateFileContentsReply_)
return;
LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Starting updateFileContents request");
QNetworkRequest request;
QString updateFileContentsURL = QString("https://api.github.com/repos/%1/contents/%2").arg(repository_).arg(path);
request.setUrl(QUrl(updateFileContentsURL));
QString userInfo = userName_+":"+password_;
QByteArray userData = userInfo.toLocal8Bit().toBase64();
QString headerData = "Basic " + userData;
request.setRawHeader("Authorization", headerData.toLocal8Bit());
QVariantMap jdata;
jdata["message"] = commitMessage;
QByteArray encodedContent = contents.toLocal8Bit().toBase64();
jdata["content"] = encodedContent;
jdata["sha"] = sha;
QJson::Serializer jserializer;
QByteArray jsonData = jserializer.serialize(jdata);
QBuffer *buffer = new QBuffer;
buffer->setData(jsonData);
buffer->open(QIODevice::ReadOnly);
updateFileContentsReply_ = manager_->sendCustomRequest(request, "PUT", buffer);
buffer->setParent(updateFileContentsReply_);
connect(updateFileContentsReply_, SIGNAL(readyRead()), this, SLOT(onUpdateFileContentsReturned()));
}
示例6: closeIssue
void LYGithubManager::closeIssue(int issueNumber){
if(!isAuthenticated() || repository_.isEmpty() || closeIssueReply_)
return;
LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Starting closeIssue request");
QNetworkRequest request;
QString commentURL = QString("https://api.github.com/repos/%1/issues/%2").arg(repository_).arg(issueNumber);
request.setUrl(QUrl(commentURL));
QString userInfo = userName_+":"+password_;
QByteArray userData = userInfo.toLocal8Bit().toBase64();
QString headerData = "Basic " + userData;
request.setRawHeader("Authorization", headerData.toLocal8Bit());
QVariantMap jdata;
jdata["state"] = "closed";
QJson::Serializer jserializer;
QByteArray jsonData = jserializer.serialize(jdata);
QBuffer *buffer = new QBuffer;
buffer->setData(jsonData);
buffer->open(QIODevice::ReadOnly);
closeIssueReply_ = manager_->sendCustomRequest(request, "PATCH", buffer);
buffer->setParent(closeIssueReply_);
connect(closeIssueReply_, SIGNAL(readyRead()), this, SLOT(onCloseIssueReturned()));
}
示例7: send
void JSKitXMLHttpRequest::send(const QJSValue &data)
{
QByteArray byteData;
if (data.isUndefined() || data.isNull()) {
// Do nothing, byteData is empty.
} else if (data.isString()) {
byteData == data.toString().toUtf8();
} else if (data.isObject()) {
if (data.hasProperty("byteLength")) {
// Looks like an ArrayView or an ArrayBufferView!
QJSValue buffer = data.property("buffer");
if (buffer.isUndefined()) {
// We must assume we've been passed an ArrayBuffer directly
buffer = data;
}
QJSValue array = data.property("_bytes");
int byteLength = data.property("byteLength").toInt();
if (array.isArray()) {
byteData.reserve(byteLength);
for (int i = 0; i < byteLength; i++) {
byteData.append(array.property(i).toInt());
}
qCDebug(l) << "passed an ArrayBufferView of" << byteData.length() << "bytes";
} else {
qCWarning(l) << "passed an unknown/invalid ArrayBuffer" << data.toString();
}
} else {
qCWarning(l) << "passed an unknown object" << data.toString();
}
}
QBuffer *buffer;
if (!byteData.isEmpty()) {
buffer = new QBuffer;
buffer->setData(byteData);
} else {
buffer = 0;
}
qCDebug(l) << "sending" << _verb << "to" << _request.url() << "with" << QString::fromUtf8(byteData);
_reply = _net->sendCustomRequest(_request, _verb.toLatin1(), buffer);
connect(_reply, &QNetworkReply::finished,
this, &JSKitXMLHttpRequest::handleReplyFinished);
connect(_reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
this, &JSKitXMLHttpRequest::handleReplyError);
if (buffer) {
// So that it gets deleted alongside the reply object.
buffer->setParent(_reply);
}
}
示例8: QBuffer
QNetworkReply * Pillow::HttpHandlerProxy::createProxiedReply(Pillow::HttpConnection *request, QNetworkRequest proxiedRequest)
{
QBuffer* requestContentBuffer = NULL;
if (request->requestContent().size() > 0)
{
requestContentBuffer = new QBuffer(&(const_cast<QByteArray&>(request->requestContent())));
requestContentBuffer->open(QIODevice::ReadOnly);
}
QNetworkReply* proxiedReply = _networkAccessManager->sendCustomRequest(proxiedRequest, request->requestMethod(), requestContentBuffer);
if (requestContentBuffer) requestContentBuffer->setParent(proxiedReply);
return proxiedReply;
}
示例9: registerUsage
void Usage::registerUsage() {
if (! g.s.bUsage || g.s.uiUpdateCounter == 0) // Only register usage if allowed by the user and first wizard run has finished
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")));
Network::prepareRequest(req);
req.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml"));
QNetworkReply *rep = g.nam->post(req, qb);
qb->setParent(rep);
connect(rep, SIGNAL(finished()), rep, SLOT(deleteLater()));
}
示例10: send
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()));
}