Logo Search packages:      
Sourcecode: earth3d version File versions  Download package

bool ConnectNetworkService::requestData ( ConnectNetworkServiceRequestQueueObject request  )  [protected, virtual]

Receive URL data Starts the request of request.

Returns:
true if the request has been completed immediately (agent requests) or false, if it is delayed

Definition at line 207 of file connectNetworkService.cpp.

References ConnectNetworkServiceRequestQueueObject::getAllowCache(), ConnectNetworkServiceRequestQueueObject::getDataReceivedListener(), ConnectNetworkServiceRequestQueueObject::getMessageID(), getReceiver(), getURL(), ConnectNetworkServiceRequestQueueObject::getUserData(), ConnectNetworkServiceRequestQueueObject::getxmlconnection(), send(), and ConnectNetworkServiceRequestQueueObject::setAllowCache().

                                                                                        {
  int currentMessageID = request->getMessageID();

  // check the tag if it must be send to the agent system or if it is an URL
  bool isAgent = false;
  bool isURL = false;
  QString result;
  QString url;
  QDomDocument doc;
  if (doc.setContent(QString(request->getxmlconnection()))) {
    /* search for agent tag */
    QDomNode n = doc.documentElement();
    while( !n.isNull() ) {
      QDomElement e = n.toElement(); // try to convert the node to an element.
      // logNetwork->debug(e.tagName());
      if( !e.isNull() && e.tagName() == QString("agent")) {
      isAgent = true;
      }
      if( !e.isNull() && e.tagName() == QString("url")) {
      isURL = true;
      url = e.attribute("address");
      if (e.hasAttribute("allowCache")) {
        request->setAllowCache(e.attribute("allowCache") == "true");
      }
      }
      n = n.nextSibling();
    }
  }

  /* agent request */
  if (isAgent) {
    QString xmlrequest = QString("<?xml version=\"1.0\"?><get msgid=\"") + QString::number(currentMessageID) + "\">";
    xmlrequest += request->getxmlconnection();
    xmlrequest += "</get>";

    /* the data goes to the receiver, without using the RequestQueue */
    TimedDataReceivedListener *listener = getMapHandler(currentMessageID);
    listener->userdata = request->getUserData();
    listener->drl = request->getDataReceivedListener();

    send(getReceiver(request->getxmlconnection()), xmlrequest.latin1());
    return(true); // needs to be dequeued immediately
  }
  if (isURL) {
    getURL(url.latin1(), currentMessageID, request->getAllowCache());
    return(false); // needs to stay in queue
  }

  return(true);
}


Generated by  Doxygen 1.6.0   Back to index