bool PolylineAnnotation::dealWithHovering( QMouseEvent *mouseEvent )
{
    const PolylineNode::PolyNodeFlag flag = state() == SceneGraphicsItem::Editing ?
                                                       PolylineNode::NodeIsEditingHighlighted :
                                                       PolylineNode::NodeIsMergingHighlighted;

    const int index = nodeContains( mouseEvent->pos() );
    if ( index != -1 ) {
        if ( !m_nodesList.at(index).isEditingHighlighted() &&
             !m_nodesList.at(index).isMergingHighlighted() ) {
            // Deal with the case when two nodes are very close to each other.
            if ( m_hoveredNodeIndex != -1 ) {
                m_nodesList[m_hoveredNodeIndex].setFlag( flag, false );
            }

            m_hoveredNodeIndex = index;
            m_nodesList[index].setFlag( flag );
            setRequest( ChangeCursorPolylineNodeHover );
        }

        return true;
    } else if ( m_hoveredNodeIndex != -1 ) {
        m_nodesList[m_hoveredNodeIndex].setFlag( flag, false );
        m_hoveredNodeIndex = -1;

        return true;
    }

    // This means that the interior of the polyline has been hovered so we catch this event too.
    setRequest( ChangeCursorPolylineLineHover );
    return true;
}
Exemple #2
0
void DocumentLoader::startLoadingMainResource()
{
    m_mainDocumentError = ResourceError();
    timing()->markNavigationStart();
    ASSERT(!m_mainResource);
    ASSERT(!m_loadingMainResource);
    m_loadingMainResource = true;

    if (maybeLoadEmpty())
        return;

    ASSERT(timing()->navigationStart());
    ASSERT(!timing()->fetchStart());
    timing()->markFetchStart();
    willSendRequest(m_request, ResourceResponse());

    // willSendRequest() may lead to our Frame being detached or cancelling the load via nulling the ResourceRequest.
    if (!m_frame || m_request.isNull())
        return;

    m_applicationCacheHost->willStartLoadingMainResource(m_request);
    prepareSubframeArchiveLoadIfNeeded();

    if (m_substituteData.isValid()) {
        m_identifierForLoadWithoutResourceLoader = createUniqueIdentifier();
        frameLoader()->notifier()->dispatchWillSendRequest(this, m_identifierForLoadWithoutResourceLoader, m_request, ResourceResponse());
        handleSubstituteDataLoadSoon();
        return;
    }

    ResourceRequest request(m_request);
    DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
        (SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, AskClientForCrossOriginCredentials, SkipSecurityCheck, CheckContentSecurityPolicy, UseDefaultOriginRestrictionsForType));
    CachedResourceRequest cachedResourceRequest(request, cachedResourceRequestInitiators().document, mainResourceLoadOptions);
    m_mainResource = m_cachedResourceLoader->requestMainResource(cachedResourceRequest);
    if (!m_mainResource) {
        setRequest(ResourceRequest());
        // If the load was aborted by clearing m_request, it's possible the ApplicationCacheHost
        // is now in a state where starting an empty load will be inconsistent. Replace it with
        // a new ApplicationCacheHost.
        m_applicationCacheHost = adoptPtr(new ApplicationCacheHost(this));
        maybeLoadEmpty();
        return;
    }
    m_mainResource->addClient(this);

    // A bunch of headers are set when the underlying ResourceLoader is created, and m_request needs to include those.
    if (mainResourceLoader())
        request = mainResourceLoader()->originalRequest();
    // If there was a fragment identifier on m_request, the cache will have stripped it. m_request should include
    // the fragment identifier, so add that back in.
    if (equalIgnoringFragmentIdentifier(m_request.url(), request.url()))
        request.setURL(m_request.url());
    setRequest(request);
}
Exemple #3
0
bool PlacemarkTextAnnotation::mousePressEvent( QMouseEvent *event )
{
    setRequest( SceneGraphicsItem::NoRequest );

    if ( state() == SceneGraphicsItem::Editing ) {
        if ( event->button() == Qt::LeftButton ) {
            m_movingPlacemark = true;
        } else if ( event->button() == Qt::RightButton ) {
            setRequest( SceneGraphicsItem::ShowPlacemarkRmbMenu );
        }

        return true;
    }

    return false;
}
QBluetoothTransferReplyBluez::QBluetoothTransferReplyBluez(QIODevice *input, const QBluetoothTransferRequest &request,
                                                           QBluetoothTransferManager *parent)
:   QBluetoothTransferReply(parent), tempfile(0), source(input),
    m_running(false), m_finished(false), m_size(0),
    m_error(QBluetoothTransferReply::NoError), m_errorStr(), m_transfer_path()
{
    setRequest(request);
    setManager(parent);
    client = new OrgOpenobexClientInterface(QLatin1String("org.openobex.client"), QLatin1String("/"),
                                           QDBusConnection::sessionBus());

    qsrand(QTime::currentTime().msec());
    m_agent_path = agentPath;
    m_agent_path.append(QString::fromLatin1("/%1").arg(qrand()));

    agent = new AgentAdaptor(this);

    bool res = QDBusConnection::sessionBus().registerObject(m_agent_path, this);
    if(!res)
        qCWarning(QT_BT_BLUEZ) << "Failed Creating dbus objects";

    qRegisterMetaType<QBluetoothTransferReply*>("QBluetoothTransferReply*");
    QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection);
    m_running = true;
}
Exemple #5
0
QTAWS_BEGIN_NAMESPACE

/**
 * @class  SqsChangeMessageVisibilityBatchResponse
 *
 * @brief  Handles SQS ChangeMessageVisibilityBatch responses.
 *
 * @see    http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_ChangeMessageVisibilityBatch.html
 */

/**
 * @brief  Constructs a new SqsResponse object.
 *
 * @param  request  Original AWS request.
 * @param  reply    AWS network response to observe.
 * @param  parent   This object's parent.
 */
SqsChangeMessageVisibilityBatchResponse::SqsChangeMessageVisibilityBatchResponse(const SqsChangeMessageVisibilityBatchRequest &request,
                                               QNetworkReply * const reply,
                                               QObject * const parent)
    : SqsResponse(new SqsChangeMessageVisibilityBatchResponsePrivate(this), parent)
{
    setRequest(new SqsChangeMessageVisibilityBatchRequest(request));
    setReply(reply);
}
void MainResourceLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
{
    // Note that there are no asserts here as there are for the other callbacks. This is due to the
    // fact that this "callback" is sent when starting every load, and the state of callback
    // deferrals plays less of a part in this function in preventing the bad behavior deferring 
    // callbacks is meant to prevent.
    ASSERT(!newRequest.isNull());
    
    // The additional processing can do anything including possibly removing the last
    // reference to this object; one example of this is 3266216.
    RefPtr<MainResourceLoader> protect(this);
    
    // Update cookie policy base URL as URL changes, except for subframes, which use the
    // URL of the main frame which doesn't change when we redirect.
    if (frameLoader()->isLoadingMainFrame())
        newRequest.setMainDocumentURL(newRequest.url());
    
    // If we're fielding a redirect in response to a POST, force a load from origin, since
    // this is a common site technique to return to a page viewing some data that the POST
    // just modified.
    // Also, POST requests always load from origin, but this does not affect subresources.
    if (newRequest.cachePolicy() == UseProtocolCachePolicy && isPostOrRedirectAfterPost(newRequest, redirectResponse))
        newRequest.setCachePolicy(ReloadIgnoringCacheData);

    if (!newRequest.isNull()) {
        ResourceLoader::willSendRequest(newRequest, redirectResponse);
        setRequest(newRequest);
    }
    
    // Don't set this on the first request. It is set when the main load was started.
    frameLoader()->setRequest(newRequest);
    
    ref(); // balanced by deref in continueAfterNavigationPolicy
    frameLoader()->checkNavigationPolicy(newRequest, callContinueAfterNavigationPolicy, this);
}
Exemple #7
0
void EWASiteRoutePoint::initStore( const QNetworkRequest& rec, QNetworkAccessManager::Operation op,
    const QByteArray& data )
{
    setRequest( rec );
    setData( data );
    setOperation( op );
}
Exemple #8
0
ByteArrayReply::ByteArrayReply(const QNetworkRequest &request,
                               const QByteArray &ba, const QString& mimeType,
                               QObject *parent) :
    QNetworkReply(parent),
    origLen(ba.size()),
    data(ba),
    buffer(&data)
{
    setRequest(request);
    setOpenMode(QIODevice::ReadOnly);
    buffer.open(QIODevice::ReadOnly);

    if (ba.isNull()) {
        setError(QNetworkReply::ContentNotFoundError, "Not found");
        QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
        QTimer::singleShot(0, this, SLOT(signalError()));
        QTimer::singleShot(0, this, SIGNAL(finished()));
    } else {
        if (mimeType.isEmpty()) {
            setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream");
        } else {
            setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
        }
        setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
        QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
        QTimer::singleShot(0, this, SIGNAL(readyRead()));
    }
}
internal_img_network_reply::internal_img_network_reply(const QNetworkRequest& req, const QString& encoded_img, int type, QObject* parent) : QNetworkReply(parent)
{
  /* internal_img_network_reply is modeled after:
     http://qt.gitorious.org/qt-labs/graphics-dojo/blobs/master/url-rendering/main.cpp
  */
  setRequest(req);
  if (type==1) { // Face
    m_buffer = QByteArray::fromBase64(encoded_img.toAscii().constData());
  }
  else { // X-Face
    QImage qi;
    QString s;
    xface_to_xpm(encoded_img.toAscii().constData(), s);
    
    if (qi.loadFromData((const uchar*)s.toAscii().constData(), s.length(), "XPM")) {
      QBuffer b(&m_buffer);
      qi.save(&b, "PNG");
    }
  }
  setOperation(QNetworkAccessManager::GetOperation);
  setHeader(QNetworkRequest::ContentTypeHeader, "image/png");
  open(ReadOnly|Unbuffered);
  setUrl(req.url());
  QTimer::singleShot(0, this, SLOT(go()));
}
Exemple #10
0
bool PlacemarkTextAnnotation::mouseReleaseEvent( QMouseEvent *event )
{
    Q_UNUSED( event );
    setRequest( SceneGraphicsItem::NoRequest );

    m_movingPlacemark = false;
    return true;
}
Exemple #11
0
    HelpRedirectNetworkReply(const QNetworkRequest &request, const QUrl &newUrl)
    {
        setRequest(request);
        setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 301);
        setAttribute(QNetworkRequest::RedirectionTargetAttribute, newUrl);

        QTimer::singleShot(0, this, SIGNAL(finished()));
    }
Exemple #12
0
HttpRequest::HttpRequest(const std::string& method,const std::string& url)
:_is_multipart(false),
_port_number(80),
_only_download_header(false),
_save_as_file(false)
{
	initDefaultValue();
	setRequest(method,url);
}
Exemple #13
0
AdBlockNetworkReply::AdBlockNetworkReply(const QNetworkRequest &request, const QString &urlString, QObject *parent)
        : QNetworkReply(parent)
{
    setOperation(QNetworkAccessManager::GetOperation);
    setRequest(request);
    setUrl(request.url());
    setError(QNetworkReply::ContentAccessDenied, i18n("Blocked by AdBlockRule: %1", urlString));
    QTimer::singleShot(0, this, SLOT(delayedFinished()));
}
internal_style_network_reply::internal_style_network_reply(const QNetworkRequest& req, const QString& style, QObject* parent) : QNetworkReply(parent)
{
  setRequest(req);
  setOperation(QNetworkAccessManager::GetOperation);
  m_buf.setData(style.toLocal8Bit());
  open(QIODevice::ReadOnly);
  m_buf.open(QIODevice::ReadOnly);
  QTimer::singleShot(0, this, SLOT(go()));
}
RobocupClient::RobocupClient(RoboPlayer &p) : player(p) {
	client = new UdpClient(SELF_IP, PORT);
	recieverThread = 0;
	requesterThread = 0;
	nextRequest = string();
	brain = player.getBrain();
	setRequest(player.newPlayer());
	startRequesting();
	startRecieving();
}
bool PolylineAnnotation::processMergingOnPress( QMouseEvent *mouseEvent )
{
    if ( mouseEvent->button() != Qt::LeftButton ) {
        return false;
    }

    GeoDataLineString line = static_cast<GeoDataLineString>( *placemark()->geometry() );

    const int index = nodeContains( mouseEvent->pos() );
    if ( index == -1 ) {
        return false;
    }

    // If this is the first node selected to be merged.
    if ( m_firstMergedNode == -1 ) {
        m_firstMergedNode = index;
        m_nodesList[index].setFlag( PolylineNode::NodeIsMerged );
   } else {
        Q_ASSERT( m_firstMergedNode != -1 );

        // Clicking two times the same node results in unmarking it for merging.
        if ( m_firstMergedNode == index ) {
            m_nodesList[index].setFlag( PolylineNode::NodeIsMerged, false );
            m_firstMergedNode = -1;
            return true;
        }

        // If these two nodes are the last ones remained as part of the polyline, remove
        // the whole polyline.
        if ( line.size() <= 2 ) {
            setRequest( SceneGraphicsItem::RemovePolylineRequest );
            return true;
        }
        m_nodesList[index].setFlag( PolylineNode::NodeIsMerged );
        m_secondMergedNode = index;

        delete m_animation;
        m_animation = new MergingPolylineNodesAnimation( this );
        setRequest( SceneGraphicsItem::StartPolylineAnimation );
    }

    return true;
}
Exemple #17
0
void DocumentLoader::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
{
    // Note that there are no asserts here as there are for the other callbacks. This is due to the
    // fact that this "callback" is sent when starting every load, and the state of callback
    // deferrals plays less of a part in this function in preventing the bad behavior deferring 
    // callbacks is meant to prevent.
    ASSERT(!newRequest.isNull());

    if (!frameLoader()->checkIfFormActionAllowedByCSP(newRequest.url())) {
        cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
        return;
    }

    ASSERT(timing()->fetchStart());
    if (!redirectResponse.isNull()) {
        // If the redirecting url is not allowed to display content from the target origin,
        // then block the redirect.
        RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectResponse.url());
        if (!redirectingOrigin->canDisplay(newRequest.url())) {
            FrameLoader::reportLocalLoadFailed(m_frame, newRequest.url().string());
            cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
            return;
        }
        timing()->addRedirect(redirectResponse.url(), newRequest.url());
    }

    // Update cookie policy base URL as URL changes, except for subframes, which use the
    // URL of the main frame which doesn't change when we redirect.
    if (frameLoader()->isLoadingMainFrame())
        newRequest.setFirstPartyForCookies(newRequest.url());

    // If we're fielding a redirect in response to a POST, force a load from origin, since
    // this is a common site technique to return to a page viewing some data that the POST
    // just modified.
    // Also, POST requests always load from origin, but this does not affect subresources.
    if (newRequest.cachePolicy() == UseProtocolCachePolicy && isPostOrRedirectAfterPost(newRequest, redirectResponse))
        newRequest.setCachePolicy(ReloadIgnoringCacheData);

    Frame* top = m_frame->tree()->top();
    if (top) {
        if (!top->loader()->mixedContentChecker()->canDisplayInsecureContent(top->document()->securityOrigin(), newRequest.url())) {
            cancelMainResourceLoad(frameLoader()->cancelledError(newRequest));
            return;
        }
    }

    setRequest(newRequest);

    if (redirectResponse.isNull())
        return;

    frameLoader()->client()->dispatchDidReceiveServerRedirectForProvisionalLoad();
    if (!shouldContinueForNavigationPolicy(newRequest))
        stopLoadingForPolicyChange();
}
Exemple #18
0
bool PlacemarkTextAnnotation::mouseMoveEvent( QMouseEvent *event )
{
    setRequest( SceneGraphicsItem::NoRequest );

    qreal lon, lat;
    m_viewport->geoCoordinates( event->pos().x(),
                                event->pos().y(),
                                lon, lat,
                                GeoDataCoordinates::Radian );

    if ( m_movingPlacemark ) {
        placemark()->setCoordinate( lon, lat );
        return true;
    } else {
        setRequest( SceneGraphicsItem::ChangeCursorPlacemarkHover );
        return true;
    }

    return false;
}
bool PolylineAnnotation::processEditingOnPress( QMouseEvent *mouseEvent )
{
    if ( mouseEvent->button() != Qt::LeftButton && mouseEvent->button() != Qt::RightButton ) {
        return false;
    }

    qreal lat, lon;
    m_viewport->geoCoordinates( mouseEvent->pos().x(),
                                mouseEvent->pos().y(),
                                lon, lat,
                                GeoDataCoordinates::Radian );
    m_movedPointCoords.set( lon, lat );

    // First check if one of the nodes has been clicked.
    m_clickedNodeIndex = nodeContains( mouseEvent->pos() );
    if ( m_clickedNodeIndex != -1 ) {
        if ( mouseEvent->button() == Qt::RightButton ) {
            setRequest( SceneGraphicsItem::ShowNodeRmbMenu );
        } else {
            Q_ASSERT( mouseEvent->button() == Qt::LeftButton );
            m_interactingObj = InteractingNode;
        }

        return true;
    }

    // Then check if the 'interior' of the polyline has been clicked (by interior
    // I mean its lines excepting its nodes).
    if ( polylineContains( mouseEvent->pos() ) ) {
        if ( mouseEvent->button() == Qt::RightButton ) {
            setRequest( SceneGraphicsItem::ShowPolylineRmbMenu );
        } else {
            Q_ASSERT( mouseEvent->button() == Qt::LeftButton );
            m_interactingObj = InteractingPolyline;
        }

        return true;
    }

    return false;
}
KNetworkReply::KNetworkReply(const QNetworkRequest &request, KIO::Job *kioJob, QObject *parent)
    : QNetworkReply(parent), d(new KNetworkReply::KNetworkReplyPrivate())

{
    d->m_kioJob = kioJob;
    setRequest(request);
    setOpenMode(QIODevice::ReadOnly);

    if (!kioJob) { // a blocked request
        QTimer::singleShot(0, this, SIGNAL(finished()));
    }
}
Exemple #21
0
HelpNetworkReply::HelpNetworkReply(const QNetworkRequest &request,
        const QByteArray &fileData, const QString& mimeType)
    : data(fileData), origLen(fileData.length())
{
    setRequest(request);
    setOpenMode(QIODevice::ReadOnly);

    setHeader(QNetworkRequest::ContentTypeHeader, mimeType);
    setHeader(QNetworkRequest::ContentLengthHeader, QByteArray::number(origLen));
    QTimer::singleShot(0, this, SIGNAL(metaDataChanged()));
    QTimer::singleShot(0, this, SIGNAL(readyRead()));
}
    SimpleHttpResult* SimpleHttpClient::request (int method,
            const string& location,
            const char* body,
            size_t bodyLength,
            const map<string, string>& headerFields) {
      
      _result = new SimpleHttpResult;
      _errorMessage = "";

      // set body to all connections
      setRequest(method, location, body, bodyLength, headerFields);

      double endTime = now() + _requestTimeout;
      double remainingTime = _requestTimeout;

      while (isWorking() && remainingTime > 0.0) {
        switch (_state) {
          case (IN_CONNECT):
            handleConnect();
            break;

          case (IN_WRITE):
            handleWrite(remainingTime);
            break;

          case (IN_READ_HEADER):
          case (IN_READ_BODY):
          case (IN_READ_CHUNKED_HEADER):
          case (IN_READ_CHUNKED_BODY):
            handleRead(remainingTime);
            break;
          default:
            break;
        }

        remainingTime = endTime - now();
      }
      
      if (isWorking() && _errorMessage=="" ) {
        if (_warn) {
          LOGGER_WARNING << "Request timeout reached.";
        }
        _errorMessage = "Request timeout reached.";
      }
      
      // set result type in getResult()
      SimpleHttpResult* result = getResult();
      
      _result = 0;
      
      return result;
    }
Exemple #23
0
	SchemeReply::SchemeReply (const QNetworkRequest& req, QObject *parent)
	: QNetworkReply (parent)
	{
		setOperation (QNetworkAccessManager::GetOperation);
		setRequest (req);
		setUrl (req.url ());

		Buffer_.open (QIODevice::ReadWrite);
		setError (NoError, tr ("No error"));

		Util::ExecuteLater ([this] { List (); });
		open (QIODevice::ReadOnly);
	}
OgreNetworkReply::OgreNetworkReply(const QNetworkRequest &request)
{
    setOperation(QNetworkAccessManager::GetOperation);
    setRequest(request);
    setUrl(request.url());

    QString path = request.url().toString(QUrl::RemoveScheme);

    // Remote slashes at the beginning
    while (path.startsWith('/'))
        path = path.mid(1);

    qDebug() << "Opening" << path << "from ogre resource.";

    Ogre::ResourceGroupManager &resourceManager = Ogre::ResourceGroupManager::getSingleton();

    qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");

    /* Is it a directory? */
    Ogre::FileInfoListPtr fileInfo = resourceManager.findResourceFileInfo("General", path.toStdString(), true);
    if (fileInfo->size() > 0) {
        QString msg = QString("Cannot open %1: Path is a directory").arg(path);
        setError(ContentOperationNotPermittedError, msg);
        QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
                                  Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentOperationNotPermittedError));
        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
        return;
    }

    try {
        mDataStream = resourceManager.openResource(path.toStdString());
    } catch (Ogre::FileNotFoundException &e) {
        qWarning("Couldn't find %s: %s", qPrintable(path), e.getFullDescription().c_str());
        setError(ContentNotFoundError, "Couldn't find " + path);
        QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
                                  Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentNotFoundError));
        QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
        return;
    }

    open(QIODevice::ReadOnly);

    setHeader(QNetworkRequest::ContentLengthHeader, mDataStream->size());

    QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
    QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,
                              Q_ARG(qint64, mDataStream->size()), Q_ARG(qint64, mDataStream->size()));
    QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
    QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
NetworkReplyReceipts::NetworkReplyReceipts(QNetworkAccessManager::Operation AOperation, const QNetworkRequest &ARequest, QIODevice *AOutgoingData, Receipts *AReceipts, const QByteArray *AImageData, QObject *parent):
    QNetworkReply(parent),
    FReceipts(AReceipts),
    FImageData(AImageData),
    ready(false)
{
	Q_UNUSED(AOutgoingData)

    setOperation(AOperation);
    setRequest(ARequest);
    setUrl(ARequest.url());
    open(ReadOnly); // Open the device as Read Only
    connect(FReceipts, SIGNAL(delivered(QString)), SLOT(onDelivered(QString)));
    QTimer::singleShot(0, this, SLOT(readDataChunk()));
}
void PolylineAnnotation::deleteClickedNode()
{
    if ( state() != SceneGraphicsItem::Editing ) {
        return;
    }

    GeoDataLineString *line = static_cast<GeoDataLineString*>( placemark()->geometry() );
    if ( m_nodesList.size() <= 2 ) {
        setRequest( SceneGraphicsItem::RemovePolylineRequest );
        return;
    }

    m_nodesList.removeAt( m_clickedNodeIndex );
    line->remove( m_clickedNodeIndex );
 }
KCHMNetworkReply::KCHMNetworkReply( const QNetworkRequest &request, const QUrl &url )
{
	setRequest( request );
	setOpenMode( QIODevice::ReadOnly );

	m_data = loadResource( url );
	m_length = m_data.length();

	setHeader( QNetworkRequest::ContentLengthHeader, QByteArray::number(m_data.length()) );
	QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);

	if ( m_length )
		QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);

	QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
NoFileAccessReply::NoFileAccessReply(QObject* parent, const QNetworkRequest& req, const QNetworkAccessManager::Operation op)
    : QNetworkReply(parent)
{
    setRequest(req);
    setUrl(req.url());
    setOperation(op);

    qRegisterMetaType<NetworkError>();
    QString msg = (QCoreApplication::translate("QNetworkReply", "Protocol \"%1\" is unknown")
                   .arg(req.url().scheme()));
    setError(ProtocolUnknownError, msg);

    QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
                              Q_ARG(QNetworkReply::NetworkError, ProtocolUnknownError));
    QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
bool ArgumentsCollector::collect(const QStringList &args)
{
    m_arguments = args;
    m_errorString.clear();
    m_inputFilePath.clear();
    m_protocol.clear();
    try {
        setRequest();
        if (m_requestType == RequestTypePaste)
            setPasteOptions();
        return true;
    } catch (const ArgumentErrorException &ex) {
        m_errorString = ex.error;
        return false;
    }
}
Exemple #30
0
RendererReply::RendererReply(QObject* object, const QNetworkRequest& request)
    : QNetworkReply(object)
      , m_position(0)
{
    setRequest(request);
    setOperation(QNetworkAccessManager::GetOperation);
    setHeader(QNetworkRequest::ContentTypeHeader,QVariant("image/png"));
    open(ReadOnly|Unbuffered);
    setUrl(request.url());

    QString fileName = request.url().host();
    g_mainWindow->loadImageFromDB(fileName, m_buffer);
    setHeader(QNetworkRequest::ContentTypeHeader, "image/png");
    m_position = 0;
    QTimer::singleShot(0, this, SIGNAL(readyRead()));
    QTimer::singleShot(0, this, SIGNAL(finished()));
}