Beispiel #1
0
bool Request::handleIQ(boost::shared_ptr<IQ> iq) {
	bool handled = false;
	if (iq->getType() == IQ::Result || iq->getType() == IQ::Error) {
		if (sent_ && iq->getID() == id_) {
			if (isCorrectSender(iq->getFrom())) {
				if (iq->getType() == IQ::Result) {
					boost::shared_ptr<Payload> payload = iq->getPayloadOfSameType(payload_);
					if (!payload && boost::dynamic_pointer_cast<RawXMLPayload>(payload_) && !iq->getPayloads().empty()) {
						payload = iq->getPayloads().front();
					}
					handleResponse(payload, ErrorPayload::ref());
				}
				else {
					ErrorPayload::ref errorPayload = iq->getPayload<ErrorPayload>();
					if (errorPayload) {
						handleResponse(boost::shared_ptr<Payload>(), errorPayload);
					}
					else {
						handleResponse(boost::shared_ptr<Payload>(), ErrorPayload::ref(new ErrorPayload(ErrorPayload::UndefinedCondition)));
					}
				}
				router_->removeHandler(this);
				handled = true;
			}
		}
	}
	return handled;
}
int YourPayProcessor::doChargePreauthorized(const int pccardid, const int pcvv, const double pamount, const int pcurrid, QString &pneworder, QString &preforder, int &pccpayid, ParameterList &pparams)
{
  if (DEBUG)
    qDebug("YP:doChargePreauthorized(%d, %d, %f, %d, %s, %s, %d)",
	   pccardid, pcvv, pamount, pcurrid,
	   pneworder.toAscii().data(), preforder.toAscii().data(), pccpayid);

  int returnValue = 0;
  double amount = currToCurr(pcurrid, _ypcurrid, pamount, &returnValue);
  if (returnValue < 0)
    return returnValue;

  QDomDocument request;

  returnValue = buildCommon(pccardid, pcvv, amount, request, "POSTAUTH");
  if (returnValue !=  0)
    return returnValue;

  QDomElement elem = request.createElement("transactiondetails");
  request.documentElement().appendChild(elem);
  CREATECHILDTEXTNODE(elem, "oid",          preforder);
  CREATECHILDTEXTNODE(elem, "terminaltype", "UNSPECIFIED");

  QString response;
  returnValue = sendViaHTTP(request.toString(), response);
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "CP", pamount, pcurrid,
			       pneworder, preforder, pccpayid, pparams);

  return returnValue;
}
Beispiel #3
0
void ApiRequest::readResponse()
{
    response = reply->readAll();

    qDebug() << "R: " << response;

    // this can only happen on a failed request.
    if (response.length() == 0) {
        status = 1;
        done();
        return;
    }

    if (response.length() < 4) { // assume we've got a number back.
        status = response.toInt();
    } else {
        status = 0;
    }

    qDebug() << "status == " << status;

    // anything that gets parsed to a 0 is the result of a successful command. (excluding an empty case that is handled above)
    if (status != 0) {
        status = abs(status); // convert from negative to a positive non-zero error index
        qDebug() << "status now " << status;
        done();
        return;
    }

    handleResponse();
    done();
}
Beispiel #4
0
int PaymentechProcessor::doChargePreauthorized(const int pccardid, const int pcvv, const double pamount, const int pcurrid, QString &pneworder, QString &preforder, int &pccpayid, ParameterList &pparams)
{
    if (DEBUG)
        qDebug("Paymentech:doChargePreauthorized(%d, %d, %f, %d, %s, %s, %d)",
               pccardid, pcvv, pamount,  pcurrid,
               pneworder.toAscii().data(), preforder.toAscii().data(), pccpayid);

    int    returnValue = 0;
    double amount  = pamount;
    int    currid  = pcurrid;

    QString request;

    returnValue = buildCommon(pneworder, pccardid, pcvv, amount, currid, request, "AU");
    if (returnValue !=  0)
        return returnValue;

    QString response;

    returnValue = sendViaHTTP(request, response);
    if (returnValue < 0)
        return returnValue;

    returnValue = handleResponse(response, pccardid, "CP", amount, currid,
                                 pneworder, preforder, pccpayid, pparams);

    return returnValue;
}
int AuthorizeDotNetProcessor::doChargePreauthorized(const int pccardid, const QString &pcvv, const double pamount, const int pcurrid, QString &pneworder, QString &preforder, int &pccpayid, ParameterList &pparams)
{
  Q_UNUSED(pcvv);
  if (DEBUG)
    qDebug("AN:doChargePreauthorized(%d, pcvv, %f, %d, %s, %s, %d)",
	   pccardid, pamount,  pcurrid,
	   pneworder.toLatin1().data(), preforder.toLatin1().data(), pccpayid);

  int    returnValue = 0;
  double amount  = pamount;
  int    currid  = pcurrid;

  QString request;
  returnValue = buildFollowup(pccpayid, preforder, amount, currid, request, "PRIOR_AUTH_CAPTURE");
  if (returnValue != 0)
    return returnValue;

  QString response;
  returnValue = sendViaHTTP(request, response);
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "CP", amount, currid,
			       pneworder, preforder, pccpayid, pparams);

  return returnValue;
}
Beispiel #6
0
int PaymentechProcessor::doVoidPrevious(const int pccardid, const int pcvv, const double pamount, const int pcurrid, QString &pneworder, QString &preforder, QString &papproval, int &pccpayid, ParameterList &pparams)
{
    if (DEBUG)
        qDebug("Paymentech:doVoidPrevious(%d, %d, %f, %d, %s, %s, %s, %d)",
               pccardid, pcvv, pamount, pcurrid,
               pneworder.toAscii().data(), preforder.toAscii().data(),
               papproval.toAscii().data(), pccpayid);

    QString tmpErrorMsg = _errorMsg;

    int    returnValue = 0;
    double amount = pamount;
    int    currid = pcurrid;

    QString request;

    returnValue = buildCommon(pneworder, pccardid, pcvv, amount, currid, request, "AR");
    if (returnValue != 0)
        return returnValue;

    QString response;

    returnValue = sendViaHTTP(request, response);
    _errorMsg = tmpErrorMsg;
    if (returnValue < 0)
        return returnValue;

    returnValue = handleResponse(response, pccardid, "V", amount, currid,
                                 pneworder, preforder, pccpayid, pparams);
    if (! tmpErrorMsg.isEmpty())
        _errorMsg = tmpErrorMsg;
    return returnValue;
}
Beispiel #7
0
bool AdResponseBox::listen(BaseScriptHolder *param1, uint32 param2) {
    UIObject *obj = (UIObject *)param1;

    switch (obj->_type) {
    case UI_BUTTON:
        if (scumm_stricmp(obj->getName(), "prev") == 0) {
            _scrollOffset--;
        } else if (scumm_stricmp(obj->getName(), "next") == 0) {
            _scrollOffset++;
        } else if (scumm_stricmp(obj->getName(), "response") == 0) {
            if (_waitingScript) {
                _waitingScript->_stack->pushInt(_responses[param2]->getID());
            }
            handleResponse(_responses[param2]);
            _waitingScript = nullptr;
            _gameRef->_state = GAME_RUNNING;
            ((AdGame *)_gameRef)->_stateEx = GAME_NORMAL;
            _ready = true;
            invalidateButtons();
            clearResponses();
        } else {
            return BaseObject::listen(param1, param2);
        }
        break;
    default:
        error("AdResponseBox::Listen - Unhandled enum");
    }

    return STATUS_OK;
}
int AuthorizeDotNetProcessor::doVoidPrevious(const int pccardid, const QString &pcvv, const double pamount, const int pcurrid, QString &pneworder, QString &preforder, QString &papproval, int &pccpayid, ParameterList &pparams)
{
  Q_UNUSED(pcvv);
  if (DEBUG)
    qDebug("AN:doVoidPrevious(%d, pcvv, %f, %d, %s, %s, %s, %d)",
	   pccardid, pamount, pcurrid,
	   pneworder.toLatin1().data(), preforder.toLatin1().data(),
	   papproval.toLatin1().data(), pccpayid);

  QString tmpErrorMsg = _errorMsg;

  int     returnValue = 0;
  double  amount = pamount;
  int     currid = pcurrid;
  QString request;

  returnValue = buildFollowup(pccpayid, preforder, amount, currid, request, "VOID");

  QString response;
  returnValue = sendViaHTTP(request, response);
  _errorMsg = tmpErrorMsg;
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "V", amount, currid,
			       pneworder, preforder, pccpayid, pparams);
  if (! tmpErrorMsg.isEmpty())
    _errorMsg = tmpErrorMsg;
  return returnValue;
}
int  PaymentechProcessor::doAuthorize(const int pccardid, const int pcvv, double &pamount, const double ptax, const bool ptaxexempt, const double pfreight, const double pduty, const int pcurrid, QString& pneworder, QString& preforder, int &pccpayid, ParameterList &pparams)
{
  if (DEBUG)
    qDebug("Paymentech:doAuthorize(%d, %d, %f, %f, %d, %f, %f, %d, %s, %s, %d)",
	   pccardid, pcvv, pamount, ptax, ptaxexempt,  pfreight,  pduty, pcurrid,
	   pneworder.toAscii().data(), preforder.toAscii().data(), pccpayid);

  int    returnValue = 0;
  double amount  = pamount;
  //double tax     = ptax;
  //double freight = pfreight;
  //double duty    = pduty;
  int    currid  = pcurrid;

  QString request;
  returnValue = buildCommon(pneworder, pccardid, pcvv, amount, currid, request, "AU");
  if (returnValue != 0)
    return returnValue;

  QString response;

  returnValue = sendViaHTTP(request, response);
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "A", amount, currid,
			       pneworder, preforder, pccpayid, pparams);

  return returnValue;
}
WSMessageRequest TembooMessaging::poll() {
	startMessaging();
	long int now = millis();
	WSMessageRequest rc = WS_NO_MESSAGE;
	while (millis() - now < POLL_TIMEOUT) {
		if (millis() - m_lastPingTime >= MCU_PING_PERIOD_MS) {
            m_lastPingTime = millis();
            sendPing();
        }
    	if (Mailbox.messageAvailable()) {
    		uint8_t msg[MAX_MAILBOX_MESSAGE_SIZE] = {0};
    		int recvLen = Mailbox.readMessage(msg, MAX_MAILBOX_MESSAGE_SIZE);
    		if (recvLen > 0) {
	    		rc = handleResponse(msg, m_sensorTable, m_sensorTableDepth, m_connectionStatus);
	    		if (rc == WS_UPDATE_CONNECTED) {
	    			//logTembooDebug("Connected to Temboo");
	    			m_connectionStatus = true;
	    		} else if (rc == WS_UPDATE_DISCONNECTED) {
	    			//logTembooDebug("Disconnected from Temboo");
	    			m_connectionStatus = false;
	    		} else if (rc == WS_REQUEST_ERROR) {
	    			// disconnect
	    			sendError("Message request error");
	    		}
	    	}
    	}
    }
    return rc;
}
Beispiel #11
0
void handleMessage(mqd_t queue_mqd)
{
    queueMessageType msg;
    message_type_t type;

    while(mq_receive(queue_mqd, msg.bytes, SIZE+15, NULL) >= 0) {
        type = (message_type_t) msg.message.type;
        
        if(type == NEW_CLIENT) {
            printf("New client: [%s]\n", msg.message.queueName);
            openConnection(msg.message.queueName);
        }
        if(type == CLIENT_READY) {
            sendNumber(msg.message.clientID);
        }
        
        if(type == CLIENT_RESPONSE) {
            handleResponse(msg.message.clientID, msg.message.number, (int)msg.message.isPrime);
        }
        
        if(type == CLOSE_QUEUE) {
            closeConnection(msg.message.clientID);
        }    
    }
    printf("Error while receiving message!\n");
}
void SpecialConfigRequest::appFinished() {
	if (!_appReply) {
		return;
	}
	auto result = _appReply->readAll();
	_appReply.release()->deleteLater();
	handleResponse(result);
}
Beispiel #13
0
void QPubNub::onTimeFinished() {
  QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
  QJsonArray result;
  if (handleResponse(reply, result)) {
    return;
  }
  emit timeResponse((quint64)(result[0].toDouble()));
}
SsuRegClient::SsuRegClient(): QObject(),
                              _state(Idle),
                              _option(OP_Register)
{
  connect(this, SIGNAL(done()), QCoreApplication::instance(),
          SLOT(quit()), Qt::DirectConnection);
  connect(&_ssu, SIGNAL(done()), this, SLOT(handleResponse()));
}
Beispiel #15
0
int  AuthorizeDotNetProcessor::doCharge(const int pccardid, const int pcvv, const double pamount, const double ptax, const bool ptaxexempt, const double pfreight, const double pduty, const int pcurrid, QString& pneworder, QString& preforder, int &pccpayid, ParameterList &pparams)
{
  if (DEBUG)
    qDebug("AN:doCharge(%d, %d, %f, %f, %d, %f, %f, %d, %s, %s, %d)",
	   pccardid, pcvv, pamount,  ptax, ptaxexempt,  pfreight,  pduty, pcurrid,
	   pneworder.toAscii().data(), preforder.toAscii().data(), pccpayid);

  int    returnValue = 0;
  double amount  = pamount;
  double tax     = ptax;
  double freight = pfreight;
  double duty    = pduty;
  int    currid  = pcurrid;

  if (_metrics->value("CCANCurrency") != "TRANS")
  {
    currid = _metrics->value("CCANCurrency").toInt();
    amount = currToCurr(pcurrid, currid, pamount,   &returnValue);
    if (returnValue < 0)
      return returnValue;
    tax     = currToCurr(pcurrid, currid, ptax,     &returnValue);
    if (returnValue < 0)
      return returnValue;
    freight = currToCurr(pcurrid, currid, pfreight, &returnValue);
    if (returnValue < 0)
      return returnValue;
    duty    = currToCurr(pcurrid, currid, pduty,    &returnValue);
    if (returnValue < 0)
      return returnValue;
  }

  QString request;

  returnValue = buildCommon(pccardid, pcvv, amount, currid, request, "AUTH_CAPTURE");
  if (returnValue !=  0)
    return returnValue;

  APPENDFIELD(request, "x_tax",        QString::number(tax));
  APPENDFIELD(request, "x_tax_exempt", ptaxexempt ? "TRUE" : "FALSE");
  APPENDFIELD(request, "x_freight",    QString::number(freight));
  APPENDFIELD(request, "x_duty",       QString::number(duty));

  if (! preforder.isEmpty())
    APPENDFIELD(request, "x_po_num",   preforder);

  QString response;

  returnValue = sendViaHTTP(request, response);
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "C", amount, currid,
			       pneworder, preforder, pccpayid, pparams);

  return returnValue;
}
Beispiel #16
0
void WsmProcessor::handleEnqueue(Message* message)
{
    if (!message)
    {
        return;
    }

    PEGASUS_ASSERT(dynamic_cast<CIMResponseMessage*>(message) != 0);
    handleResponse(dynamic_cast<CIMResponseMessage*>(message));
}
Beispiel #17
0
void 
BoffinRqlRequest::onReqFinished()
{
    QNetworkReply *reply = (QNetworkReply*) sender();
    if (reply->error() == QNetworkReply::NoError) {
        QByteArray ba( reply->readAll() );
        handleResponse(ba.constData(), ba.size());
    }
    fail("");
}
void DocumentThreadableLoader::responseReceived(Resource* resource, const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle)
{
    ASSERT_UNUSED(resource, resource == this->resource());
    ASSERT(m_async);

    if (handle)
        m_isUsingDataConsumerHandle = true;

    handleResponse(resource->identifier(), response, handle);
    // |this| may be dead here.
}
int PaymentechProcessor::doVoidPrevious(const int pccardid, const int pcvv, const double pamount, const int pcurrid, QString &pneworder, QString &preforder, QString &papproval, int &pccpayid, ParameterList &pparams)
{
  if (DEBUG)
    qDebug("Paymentech:doVoidPrevious(%d, %d, %f, %d, %s, %s, %s, %d)",
	   pccardid, pcvv, pamount, pcurrid,
	   pneworder.toAscii().data(), preforder.toAscii().data(),
	   papproval.toAscii().data(), pccpayid);

  QString tmpErrorMsg = _errorMsg;

  int    returnValue = 0;
  double amount = pamount;
  int    currid = pcurrid;
  QString authcode;
  QString respdate;

  XSqlQuery ccq;
  ccq.prepare("SELECT ccpay_status, ccpay_r_approved, ccpay_r_code, ccpay_yp_r_tdate FROM ccpay WHERE (ccpay_id=:ccpayid);");
  ccq.bindValue(":ccpayid", pccpayid);
  ccq.exec();
  if(!ccq.first())
  {
    return -1;
  }

  if(ccq.value("ccpay_status").toString() == "C"
  && ccq.value("ccpay_r_approved").toString() != "SUBMITTED")
  {
    return -60; // we can not void a processed charge.
  }

  authcode = ccq.value("ccpay_r_code").toString();
  respdate = ccq.value("ccpay_yp_r_tdate").toString();

  QString request;

  returnValue = buildCommon(pneworder, pccardid, pcvv, amount, currid, request, "AR", authcode, respdate); // TODO: This may need to be different if it was charged already
  if (returnValue != 0)
    return returnValue;

  QString response;

  returnValue = sendViaHTTP(request, response);
  _errorMsg = tmpErrorMsg;
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "V", amount, currid,
			       pneworder, preforder, pccpayid, pparams);
  if (! tmpErrorMsg.isEmpty())
    _errorMsg = tmpErrorMsg;
  return returnValue;
}
Beispiel #20
0
SsuCli::SsuCli(): QObject(){
  connect(this,SIGNAL(done()),
          QCoreApplication::instance(),SLOT(quit()), Qt::DirectConnection);
  connect(&ssu, SIGNAL(done()),
          this, SLOT(handleResponse()));

  ssuProxy = new SsuProxy("org.nemo.ssu", "/org/nemo/ssu", QDBusConnection::systemBus(), 0);

  connect(ssuProxy, SIGNAL(done()),
          this, SLOT(handleDBusResponse()));

  state = Idle;
}
Beispiel #21
0
int
probeBrailleDisplay (
  BrailleDisplay *brl, unsigned int retryLimit,
  GioEndpoint *endpoint, int inputTimeout,
  BrailleRequestWriter *writeRequest,
  BraillePacketReader *readPacket, void *responsePacket, size_t responseSize,
  BrailleResponseHandler *handleResponse
) {
  unsigned int retryCount = 0;

  if (!endpoint) endpoint = brl->gioEndpoint;

  while (writeRequest(brl)) {
    drainBrailleOutput(brl, 0);

    while (gioAwaitInput(endpoint, inputTimeout)) {
      size_t size = readPacket(brl, responsePacket, responseSize);
      if (!size) break;

      {
        BrailleResponseResult result = handleResponse(brl, responsePacket, size);

        switch (result) {
          case BRL_RSP_DONE:
            return 1;

          case BRL_RSP_UNEXPECTED:
            logUnexpectedPacket(responsePacket, size);
          case BRL_RSP_CONTINUE:
            break;

          default:
            logMessage(LOG_WARNING, "unimplemented braille response result: %u", result);
          case BRL_RSP_FAIL:
            return 0;
        }
      }
    }

    if (errno != EAGAIN)
#ifdef ETIMEDOUT
      if (errno != ETIMEDOUT)
#endif /* ETIMEDOUT */
        break;

    if (retryCount == retryLimit) break;
    retryCount += 1;
  }

  return 0;
}
Beispiel #22
0
void DocumentThreadableLoader::responseReceived(
    Resource* resource,
    const ResourceResponse& response,
    std::unique_ptr<WebDataConsumerHandle> handle) {
  DCHECK_EQ(resource, this->resource());
  DCHECK(m_async);

  m_checker.responseReceived();

  if (handle)
    m_isUsingDataConsumerHandle = true;

  handleResponse(resource->identifier(), response, std::move(handle));
}
Beispiel #23
0
void QPubNub::onSubscribeReadyRead() {
  QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
  QJsonArray response;
  if (handleResponse(reply, response)) {
    return;
  }
  QJsonValue firstElement(response.at(0));
  if (!firstElement.isArray()) {
    emit error("First element of response is not an JSON array", 0);
    subscribe();
  }
  
  QJsonValue timeTokenElement = response.at(1);
  if (!timeTokenElement.isString()) {
    emit error("Second element of response is not a string", 0);
    subscribe();
  }
  m_timeToken = timeTokenElement.toString();
  QJsonValue channelListString = response.at(2);
  QStringList channels;
  QJsonArray messages = firstElement.toArray();
  if (channelListString.isString()) {
    channels = channelListString.toString().split(',');
  } else {
    int len = messages.isEmpty() ? 0 : messages.size();
    for (int i = 0; i < len; i++)
    {
        channels << m_channelUrlPart;
    }
  }
  if (messages.isEmpty()) {
    emit connected();
  } else {
#ifdef Q_PUBNUB_CRYPT
    if (m_cipherKey.isEmpty()) {
      for (int i=0,len=messages.size();i<len;++i) {
        emit message(messages[i], m_timeToken, channels[i]);
      }
    } else {
      decrypt(messages, channels);
    }
  #else
    for (int i=0,len=messages.size();i<len;++i) {
      emit message(messages[i], m_timeToken, channels[i]);
    }
#endif // Q_PUBNUB_CRYPT
  }
  subscribe();
}
void ContactRequestClient::socketReadable()
{
    switch (state)
    {
    case WaitConnect:
        {
            uchar version;
            if (socket->read(reinterpret_cast<char*>(&version), 1) < 1)
                return;

            if (version != Protocol::ProtocolVersion)
            {
                emit rejected(Protocol::RequestVersionError);
                close();
                return;
            }

            state = WaitCookie;

            /* Deliberately omitted break; cookie may arrive instantly */
        }

    case WaitCookie:
        if (socket->bytesAvailable() < Protocol::RequestCookieSize)
            return;

        if (!buildRequestData(socket->read(Protocol::RequestCookieSize)))
        {
            socket->close();
            return;
        }

        state = WaitAck;
        break;

    case WaitAck:
    case WaitResponse:
        if (!handleResponse() && socket)
        {
            socket->close();
            return;
        }

        break;

    default:
        break;
    }
}
Beispiel #25
0
bool RpcChannel:: handleMessage(rpc::Message *messageEnvelope)
{
  bool rc = false;
  if (messageEnvelope->has_request()) {
    rc = handleRequest(messageEnvelope);
  }
  else if (messageEnvelope->has_response()) {
    rc = handleResponse(messageEnvelope);
  }
  else {
    this->setErrorString("Invalid message format");
  }

  return rc;
}
Beispiel #26
0
    void didReceiveData(ResourceHandle*, const char* data, unsigned length, int /*encodedDataLength*/)
    {
        if (m_handleResponseLaterID) {
            g_source_remove(m_handleResponseLaterID);
            handleResponse();
        }

        gsize bytesWritten;
        GOwnPtr<GError> error;
        g_output_stream_write_all(G_OUTPUT_STREAM(m_outputStream.get()), data, length, &bytesWritten, 0, &error.outPtr());
        if (error) {
            downloadFailed(platformDownloadDestinationError(m_response, error->message));
            return;
        }
        m_download->didReceiveData(bytesWritten);
    }
Beispiel #27
0
void QPubNub::publishFinished() {
  QNetworkReply * reply = qobject_cast<QNetworkReply*>(sender());
  QJsonArray response;
  if (handleResponse(reply, response)) {
    return;
  }
  if (response.size() >= 2) {
    const QJsonValue statusCode(response[0]);
    if ((int)statusCode.toDouble() == 0) {
      emit error(response[1].toString(), 0);
    } else {
      emit published(response[2].toString());
    }
  } else {
    emit error("Response array is too small", 0);
  }
}
Beispiel #28
0
int AuthorizeDotNetProcessor::doVoidPrevious(const int pccardid, const int pcvv, const double pamount, const int pcurrid, QString &pneworder, QString &preforder, QString &papproval, int &pccpayid, ParameterList &pparams)
{
  if (DEBUG)
    qDebug("AN:doVoidPrevious(%d, %d, %f, %d, %s, %s, %s, %d)",
	   pccardid, pcvv, pamount, pcurrid,
	   pneworder.toAscii().data(), preforder.toAscii().data(),
	   papproval.toAscii().data(), pccpayid);

  QString tmpErrorMsg = _errorMsg;

  int    returnValue = 0;
  double amount = pamount;
  int    currid = pcurrid;

  if (_metrics->value("CCANCurrency") != "TRANS")
  {
    currid = _metrics->value("CCANCurrency").toInt();
    amount = currToCurr(pcurrid, currid, pamount, &returnValue);
    if (returnValue < 0)
    {
      _errorMsg = tmpErrorMsg;
      return returnValue;
    }
  }

  QString request;

  returnValue = buildCommon(pccardid, pcvv, amount, currid, request, "VOID");
  if (returnValue != 0)
    return returnValue;

  APPENDFIELD(request, "x_trans_id", preforder);

  QString response;

  returnValue = sendViaHTTP(request, response);
  _errorMsg = tmpErrorMsg;
  if (returnValue < 0)
    return returnValue;

  returnValue = handleResponse(response, pccardid, "V", amount, currid,
			       pneworder, preforder, pccpayid, pparams);
  if (! tmpErrorMsg.isEmpty())
    _errorMsg = tmpErrorMsg;
  return returnValue;
}
void SpecialConfigRequest::dnsFinished() {
	if (!_dnsReply) {
		return;
	}
	auto result = _dnsReply->readAll();
	_dnsReply.release()->deleteLater();

	// Read and store to "entries" map all the data bytes from this response:
	// { .., "Answer": [ { .., "data": "bytes1", .. }, { .., "data": "bytes2", .. } ], .. }
	auto entries = QMap<int, QString>();
	auto error = QJsonParseError { 0, QJsonParseError::NoError };
	auto document = QJsonDocument::fromJson(result, &error);
	if (error.error != QJsonParseError::NoError) {
		LOG(("Config Error: Failed to parse dns response JSON, error: %1").arg(error.errorString()));
	} else if (!document.isObject()) {
		LOG(("Config Error: Not an object received in dns response JSON."));
	} else {
		auto response = document.object();
		auto answerIt = response.find(qsl("Answer"));
		if (answerIt == response.constEnd()) {
			LOG(("Config Error: Could not find Answer in dns response JSON."));
		} else if (!(*answerIt).isArray()) {
			LOG(("Config Error: Not an array received in Answer in dns response JSON."));
		} else {
			for (auto elem : (*answerIt).toArray()) {
				if (!elem.isObject()) {
					LOG(("Config Error: Not an object found in Answer array in dns response JSON."));
				} else {
					auto object = elem.toObject();
					auto dataIt = object.find(qsl("data"));
					if (dataIt == object.constEnd()) {
						LOG(("Config Error: Could not find data in Answer array entry in dns response JSON."));
					} else if (!(*dataIt).isString()) {
						LOG(("Config Error: Not a string data found in Answer array entry in dns response JSON."));
					} else {
						auto data = (*dataIt).toString();
						entries.insertMulti(INT_MAX - data.size(), data);
					}
				}
			}
		}
	}
	auto text = QStringList(entries.values()).join(QString());
	handleResponse(text.toLatin1());
}
KVNetworkReply::KVNetworkReply(QObject *parent, QNetworkReply *toCopy, QNetworkAccessManager *mgr, bool translate) :
	QNetworkReply(parent) {
	d = new KVNetworkReplyPrivate;
	d->finished = false;
	d->copied = toCopy;
	d->manager = mgr;
	d->translate = translate;

	setOperation(d->copied->operation());
	setRequest(d->copied->request());
	setUrl(d->copied->url());

	// Translate reply when it's complete
	connect(d->copied, SIGNAL(finished()), SLOT(handleResponse()));

	connect(d->copied, SIGNAL(encrypted()), SIGNAL(encrypted()));
	connect(d->copied, SIGNAL(metaDataChanged()), SIGNAL(metaDataChanged()));
}