Ejemplo n.º 1
0
void ComputerPlayer::play(bool black, const QString& stateFileName, int nbMovesLeft)
{
  if (!isActive_)
    return; // So that human user can play

  while (true)
    {
      const QFileInfo fi(programFileName());
      
      if (fi.exists())
	if (fi.isExecutable())
	  {
#if QT_VERSION < 0x040000
	    process_ = new QProcess(programFileName());
	    process_->addArgument(stateFileName);
	    process_->addArgument(QString::number(black?allowedTime():-allowedTime()));
	    process_->addArgument(QString::number(nbMovesLeft));
	    connect(process_, SIGNAL(processExited()), this, SLOT(readFromStdout()));
	    if (process_->start())
#else
	    process_ = new QProcess();
	    connect(process_, SIGNAL(finished(int)), this, SLOT(readFromStdout()));
		process_->start(programFileName(), QStringList() << stateFileName << QString::number(black?allowedTime():-allowedTime()) << QString::number(nbMovesLeft));
	    if (process_->waitForStarted())
#endif
	      {
		Clock.start();
		break;
	      }
	    else
	      QMessageBox::warning(NULL ,"Unable to start process",
				   "Unable to start process.\nSelect another program or update permissions");
	  }
	else
Ejemplo n.º 2
0
/* /////////////////////////////////////////////////////////////////////////////
 * MPlayer interface
 *
 * start mplayer playing file <fileName>
 */
bool TTMplayerWidget::playMplayer(QString videoFile)
{
  QString     str_cmd;
  QStringList mplayer_cmd;

  if (!ttAssigned(mplayerProc))
    return false;

  //FIXME:
  //if (isPlaying)
  //  return false;

  // Setup interface with MPlayer
  mplayer_cmd.clear();

  // ----------------------------------------------------------------------
  // slave-mode
  // ----------------------------------------------------------------------
  // Switches on slave mode, in which MPlayer works as a backend for other
  // programs. Instead of intercepting keyboard events, MPlayer will read
  // commands from stdin.
  // NOTE: See -input cmdlist for a list of slave commands and
  // DOCS/tech/slave.txt for their description.
  // ----------------------------------------------------------------------

  // Every argument must have it's own addArgument
  mplayer_cmd << "-slave"
              << "-identify"
              << "-quiet"
              << "-wid";
  str_cmd.sprintf( "%ld",(long)winId() );
  mplayer_cmd << str_cmd
              << "-geometry";
  str_cmd.sprintf( "%dx%d+0+0", movieSize.width(), movieSize.height());
  mplayer_cmd << str_cmd
              << videoFile;

  log->infoMsg(cName, "mplayer command: %s", mplayer_cmd.join(" ").toLatin1().data());

  if (mplayerProc->state() == QProcess::Running)
  {
      log->errorMsg(cName, "error starting mplayer (!)");
      return false;
  }

  // start the mplayer process
  mplayerProc->start( "mplayer", mplayer_cmd );

  // signal and slot connection for the mplayer process
  // detect when mplayer has information ready for us
  connect(mplayerProc, SIGNAL(started()),                           this, SLOT( mplayerStarted()));
  connect(mplayerProc, SIGNAL(readyRead()),                         this, SLOT( readFromStdout()));
  connect(mplayerProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT( exitMplayer(int, QProcess::ExitStatus) ) );
  connect(mplayerProc, SIGNAL(error(QProcess::ProcessError)),       this, SLOT( errorMplayer(QProcess::ProcessError) ) );
  connect(mplayerProc, SIGNAL(stateChanged(QProcess::ProcessState)),this, SLOT( stateChangedMplayer(QProcess::ProcessState) ) );

  isPlaying = true;
  emit isPlayingEvent(isPlaying);
  return true;
}
Ejemplo n.º 3
0
void ChildForm::runProcess()
{
    RunProcessDialog rpd(this);
    // If the process failed to start, then it
    // cannot be deleted from the processError call
    // because it may be called from within the call to
    // _proc->start()... so _proc cannot be deleted...
    if ((_proc != nullptr) && (_procError == true))
    {
        deleteProcess();
    }
    if (_proc == nullptr)
    {
        if (rpd.exec() == RunProcessDialog::Accepted)
        {
            _procError = false;
            _redirectStdout = rpd.isStdoutRedirected();
            _redirectStderr = rpd.isStderrRedirected();

            _proc = new QProcess(this);
            connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
            connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()));
            connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
            connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this,
                    SLOT(processDone(int,QProcess::ExitStatus)));
            _proc->setWorkingDirectory(rpd.getWorkingDirectory());
            QStringList args = rpd.getArguments();
            suppressOutput(rpd.isOutputSuppressed());
            MainWindow::getMainWindow()->swapProcessIcon(true);
            _proc->start(rpd.getProgram(), args);
        }
    }
Ejemplo n.º 4
0
CommandManager::CommandManager(QWidget * parent, const char * name, int width, int height, const QStringList & args )
	: QDialog( parent )
{
    EndMessage = "\n\n EXECUTION COMPLETED ! ! ! "; // default
    // Layout
    setFixedSize ( width, height ) ;
    setWindowTitle( name );
    //qt3to4 -- BW
    //output = new Q3TextEdit( this );
    output = new QTextEdit( this );
    output->setReadOnly( true );
    output->setGeometry( QRect( 20, 20, width - 40, height - 100 ) );

    quitButton = new QPushButton( tr("Hide"), this );
    quitButton->move(width - 160, height - 75);
    connect( quitButton, SIGNAL(clicked()),
            this, SLOT(close()) );

    // QProcess related code
    //qt3to4 -- BW
    //proc = new Q3Process( this );
    proc = new QProcess( this );

    // Set up the command and arguments.
    //qt3to4 -- BW
    //proc->setArguments ( args );

   connect( proc, SIGNAL(readyReadStandardOutput()),
            this, SLOT(readFromStdout()) );
   connect( proc, SIGNAL(finished(int,QProcess::ExitStatus)),
            this, SLOT(scrollToTop()) );

    //qt3to4 -- BW
    QString prog = args.first();
    QStringList args2 = args.mid(1);
    proc->start(prog,args2);

    //qt3to4 -- BW
    //if ( !proc->start() ) {
    if(proc->error()==QProcess::FailedToStart) {
        // error handling
        QString errorM = args.join( "\n" );
        QMessageBox::critical( 0,
                tr("Fatal error"),
	  tr("Could not start the command: \n %1").arg(errorM),
                tr("Quit") );
        //exit( -1 );
    }
}
Ejemplo n.º 5
0
void TgtProcessIntf::tgtMakeConnection()
{
    std::shared_ptr<const TgtConnectionConfig> connectionConfig = std::dynamic_pointer_cast<const TgtConnectionConfig>(
        _connectionConfig);
    _proc = new QProcess(this);
    connect(_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()));
    connect(_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr()));
    connect(_proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
    connect(_proc, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processDone(int,QProcess::ExitStatus)));
    _proc->setWorkingDirectory(connectionConfig->_workingDir.c_str());
    QStringList args(connectionConfig->_args.c_str());

    QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
    env.insert("TERM", "xterm");
    env.insert("COLORTERM", "gnome-terminal");
    _proc->setProcessEnvironment(env);

    _proc->start(connectionConfig->_program.c_str(), args);
    _processWriterThread = TgtThread::create(boost::protect(std::bind(&TgtProcessIntf::writerThread, this)));
}
Ejemplo n.º 6
0
/*! \internal
*/
bool QProcessPrivate::canReadStandardOutput()
{
    Q_Q(QProcess);
    qint64 available = bytesAvailableFromStdout();
    if (available == 0) {
        if (standardReadSocketNotifier)
            standardReadSocketNotifier->setEnabled(false);
        destroyPipe(standardReadPipe);
        return false;
    }

    char *ptr = outputReadBuffer.reserve(available);
    qint64 readBytes = readFromStdout(ptr, available);
    if (readBytes == -1) {
        processError = QProcess::ReadError;
        q->setErrorString(QT_TRANSLATE_NOOP(QProcess, QLatin1String("Error reading from process")));
        emit q->error(processError);
        return false;
    }
    if (standardOutputClosed) {
        outputReadBuffer.truncate(readBytes);
        return false;
    }

    outputReadBuffer.truncate(available - readBytes);

    bool didRead = false;
    if (readBytes == 0) {
        if (standardReadSocketNotifier)
            standardReadSocketNotifier->setEnabled(false);
    } else if (processChannel == QProcess::StandardOutput) {
        didRead = true;
        if (!emittedReadyRead) {
            emittedReadyRead = true;
            emit q->readyRead();
            emittedReadyRead = false;
        }
    }
    emit q->readyReadStandardOutput();
    return didRead;
}
Ejemplo n.º 7
0
/*!
 * \brief Constructor.
 */
Server::Server(QString name, QTabWidget *parent, QString yarpVersion) : ui(new Ui::Server)
{
    ui->setupUi(this);
    parent->addTab(this, name);
    gpuInfo.append("GPU devices will appear once any modules are running on this server.");
    minimumYarpVersion = yarpVersion;
    portName = name;
    initialised = false;
    timeStep = 0;

    timer = new QTimer(this);
    timer->setInterval(1000);
    QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updateInformation()));

    systemInfo = new QProcess(this);
    QObject::connect(systemInfo, SIGNAL(readyRead()), this, SLOT(readFromStdout()));
    QObject::connect(systemInfo, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(closeProcess()));

    QFont plotFont("Times", 10, QFont::Bold);
    ui->cpuPlot->setTitle("CPU Load");
    ui->cpuPlot->setTitleFont(plotFont);
    ui->cpuPlot->xAxis->setTickLabels(false);
    ui->cpuPlot->yAxis->setTickLabels(false);
    ui->cpuPlot->yAxis->setRange(0, 100);
    ui->cpuPlot->addGraph();
    ui->cpuPlot->graph()->setLineStyle(QCPGraph::lsLine);
    ui->cpuPlot->graph()->setPen(QPen(Qt::black));
    ui->cpuPlot->graph()->clearData();

    ui->memoryPlot->setTitle("Memory");
    ui->memoryPlot->setTitleFont(plotFont);
    ui->memoryPlot->xAxis->setTickLabels(false);
    ui->memoryPlot->yAxis->setTickLabels(false);
    ui->memoryPlot->addGraph();
    ui->memoryPlot->graph()->setLineStyle(QCPGraph::lsLine);
    ui->memoryPlot->graph()->setPen(QPen(Qt::black));
    ui->memoryPlot->graph()->clearData();
}
Ejemplo n.º 8
0
PlotLine * ExScript::doScript ()
{
  if (proc)
  {
    delete proc;
    proc = 0;
  }

  PlotLine *line = new PlotLine();

  if (! scriptPath.length())
  {
    qDebug("ExScript::calculate: no script path");
    return line;
  }

  proc = new QProcess(this);
  connect(proc, SIGNAL(readyReadStdout()), this, SLOT(readFromStdout()));
  proc->setCommunication(QProcess::Stdin|QProcess::Stdout|QProcess::Stderr);
  proc->addArgument(scriptPath);

  QStringList l = QStringList::split(" ", comlineParms, FALSE);
  int loop;
  for (loop = 0; loop < (int) l.count(); loop++)
    proc->addArgument(l[loop]);

  buffer.truncate(0);

  QString s;
  if (dateFlag || openFlag || highFlag || lowFlag || closeFlag || volumeFlag || oiFlag)
    getInput(s);

  QByteArray ba(s.length());
  if (s.length())
  {
    for (loop = 0; loop < (int) s.length(); loop++)
      ba[loop] = s.at(loop).latin1();
  }

  if (! proc->launch(ba, NULL))
  {
    qDebug("ExScript::calculate: error starting script");
    delete proc;
    proc = 0;
    return line;
  }

  timer->start(seconds * 1000, FALSE);

  wakeup();

  while (proc->isRunning())
  {
    usleep(100);
    wakeup();
  }

  timer->stop();

  if (proc)
  {
    delete proc;
    proc = 0;
  }

  if (! buffer.length())
  {
    qDebug("ExScript::createOutput: output buffer empty");
    return line;
  }

  l = QStringList::split(",", buffer, FALSE);
  for (loop = 0; loop < (int) l.count(); loop++)
    line->append(l[loop].toDouble());

  line->setColor(color);
  line->setType(lineType);
  line->setLabel(label);
  return line;
}
Ejemplo n.º 9
0
CommandManager::CommandManager(QWidget * parent, const char * name, const QStringList & args )
	: QDialog( parent)
{

    EndMessage = "\n\n EXECUTION COMPLETED ! ! ! "; // default

    // Layout
    setFixedSize ( 550, 500 ) ;
    //setCaption( name );
    setWindowTitle(name);
    //qt3to4 -- BW
    //output = new Q3TextEdit( this );
    output = new QTextEdit( this );
    output->setReadOnly( true );
    output->setGeometry( QRect( 20, 20, 510, 430 ) );
    //qt3to4 -- BW
    //output->setHScrollBarMode ( Q3ScrollView::Auto );
    output->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    //output->setWordWrap( Q3TextEdit::NoWrap );
    output->setWordWrapMode(QTextOption::NoWrap);
//    output->setTextFormat( Qt::RichText );

    quitButton = new QPushButton( tr("&Close"), this );
    quitButton->move(390, 465);
    connect( quitButton, SIGNAL(clicked()),
            this, SLOT(close()) );
    quitButton->setEnabled( false );

    killButton = new QPushButton( tr("&Kill"), this );
    killButton->move(270, 465);
    connect( killButton, SIGNAL(clicked()),
            this, SLOT(killProcess()) );

    // QProcess related code
    //qt3to4 -- BW
    //proc = new Q3Process( this );
    proc = new QProcess( this );

    //proc->clearArguments();
    // Set up the command and arguments.
    //qt3to4 -- BW
    //proc->setArguments ( args );

   //proc->setCommunication(QProcess::Stdout | QProcess::Stderr | QProcess::DupStderr);
   connect( proc, SIGNAL(readyReadStandardOutput()),
            this, SLOT(readFromStdout()) );
   connect( proc, SIGNAL(readyReadStandardError()),
            this, SLOT(readFromStderr()) );
    connect( proc, SIGNAL(finished(int, QProcess::ExitStatus)),
            this, SLOT(scrollToTop()) );

//    output->setText( (QString)"<u>EXECUTING  :</u>"+args.join( " " )  );
    //qt3to4 -- BW
    //output->insert( (QString)"EXECUTING  : "+args.join( " " ) +(QString)"\n",
    //		       (uint)Q3TextEdit::CheckNewLines | Q3TextEdit::RemoveSelected  );
    output->insertPlainText( (QString)"EXECUTING  : "+args.join( " " ) +(QString)"\n");

   //qt3to4 -- BW
    QString prog = args.first();
    QStringList args2 = args.mid(1);
    proc->start(prog,args2);

    //qt3to4 -- BW
    //if ( !proc->start() ) {
    if(proc->error()==QProcess::FailedToStart) {
        // error handling
        //QString errorM = "Could not start the command: \n" +args.join( "\n" );
        QString errorM = args.join( "\n" );
        QMessageBox::critical( 0,
                tr("Fatal error"),
	  tr("Could not start the command: \ni %1").arg(errorM),
                tr("Quit") );
        //exit( -1 );
    }
}
Ejemplo n.º 10
0
// for multicurrency implementation see comments marked ##### in salesOrder.ui.h
void arWorkBench::processYourPay()
{
  QDomDocument odoc;
  // Build the order
  QDomElement root = odoc.createElement("order");
  odoc.appendChild(root);
  QDomElement elem, sub;
  
  // add the 'credit card'
  elem = odoc.createElement("creditcard");

  QString work_month;
  work_month.setNum(_ccard_month_expired);
  if (work_month.length() == 1)
    work_month = "0" + work_month;
  sub = odoc.createElement("cardexpmonth");
  sub.appendChild(odoc.createTextNode(work_month));
  elem.appendChild(sub);

  QString work_year;
  work_year.setNum(_ccard_year_expired);
  work_year = work_year.right(2);
  sub = odoc.createElement("cardexpyear");
  sub.appendChild(odoc.createTextNode(work_year));
  elem.appendChild(sub);

  sub = odoc.createElement("cardnumber");
  sub.appendChild(odoc.createTextNode(_ccard_number));
  elem.appendChild(sub);

  root.appendChild(elem);
  
  // Build 'merchantinfo'
  elem = odoc.createElement("merchantinfo");

  sub = odoc.createElement("configfile");
  sub.appendChild(odoc.createTextNode(configfile));
  elem.appendChild(sub);
  
  root.appendChild(elem);
  
  // Build 'orderoptions'
  elem = odoc.createElement("orderoptions");

  sub = odoc.createElement("ordertype");
  sub.appendChild(odoc.createTextNode("POSTAUTH"));
  elem.appendChild(sub);
  
  sub = odoc.createElement("result");
  sub.appendChild(odoc.createTextNode("LIVE"));
  elem.appendChild(sub);
  
  root.appendChild(elem);
  
  // Build 'payment'
  elem = odoc.createElement("payment");

  QString tmp;
  sub = odoc.createElement("chargetotal");
  sub.appendChild(odoc.createTextNode(tmp.setNum(_CCAmount->baseValue(), 'f', 2))); // ##### localValue()?
  elem.appendChild(sub);

  root.appendChild(elem);
  
  // Build 'transaction details'
  elem = odoc.createElement("transactiondetails");

  sub = odoc.createElement("oid");
  sub.appendChild(odoc.createTextNode(_backrefnum));
  elem.appendChild(sub);

  root.appendChild(elem);
  
  // Process the order
  saved_order = odoc.toString();
  
  if (_metrics->boolean("CCTest"))
  {
    _metrics->set("CCOrder", saved_order);
  }
  
  proc = new QProcess( this );
  QString curl_path;
#ifdef Q_WS_WIN
  curl_path = qApp->applicationDirPath() + "\\curl";
#elif defined Q_WS_MACX
  curl_path = "/usr/bin/curl";
#elif defined Q_WS_X11
  curl_path = "/usr/bin/curl";
#endif
  
  QStringList curl_args;
  curl_args.append( "-k" );
  curl_args.append( "-d" );
  curl_args.append( saved_order );
  curl_args.append( "-E" );
  curl_args.append( pemfile );
  
  _port.setNum(port);
  doServer = "https://" + _metrics->value("CCServer") + ":" + _port;
  
  curl_args.append( doServer );
  
  QString proxy_login;
  QString proxy_server;
  
  if(_metrics->boolean("CCUseProxyServer"))
  {
    proxy_login =  _metricsenc->value("CCProxyLogin") + ":" + _metricsenc->value("CCPassword") ;
    proxy_server = _metrics->value("CCProxyServer") + ":" + _metrics->value("CCProxyPort");
    curl_args.append( "-x" );
    curl_args.append( proxy_server );
    curl_args.append( "-U" );
    curl_args.append( proxy_login );
  }
  
  _response = "";
  
  connect( proc, SIGNAL(readyReadStandardOutput()),
           this, SLOT(readFromStdout()) );
  
  QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
  _editPreauth->setEnabled(FALSE);
  
  proc->start(curl_path, curl_args);
  if ( !proc->waitForStarted() ) 
  {
    QMessageBox::critical( 0,
                  tr("Fatal error"),
                  tr("Could not start the %1 command.").arg(curl_path),
                  tr("Quit") );
    return;
  }
  
  while (proc->state() == QProcess::Running)
    qApp->processEvents();
  
  _editPreauth->setEnabled(TRUE);
  QApplication::restoreOverrideCursor();
  
  _response =  "<myroot>" + _response + "</myroot>";
  
  QString whyMe;
  
  if (_metrics->boolean("CCTest"))
  {
    whyMe = _ccard_number + "  " + _response;
    _metrics->set("CCTestMe", whyMe);
    _metrics->set("CCOrder", saved_order);
  }
  
  /*if (_metrics->boolean("CCTest"))
  {
    QMessageBox::information(this, tr("YourPay"), tr("The return code was ") + _response, QMessageBox::Ok);
  }*/
  QDomDocument doc;
  doc.setContent(_response);
  QDomNode node;
  root = doc.documentElement();
  
  QString _r_avs;
  QString _r_ordernum;
  QString _r_error;
  QString _r_approved;
  QString _r_code;
  QString _r_score;
  QString _r_shipping;
  QString _r_tax;
  QString _r_tdate;
  QString _r_ref;
  QString _r_message;
  QString _r_time;
  
  node = root.firstChild();
  while ( !node.isNull() ) {
    if ( node.isElement() && node.nodeName() == "r_avs" ) {
      QDomElement r_avs = node.toElement();
      _r_avs = r_avs.text();
    }
    if ( node.isElement() && node.nodeName() == "r_ordernum" ) {
      QDomElement r_ordernum = node.toElement();
      _r_ordernum = r_ordernum.text();
    }
    if ( node.isElement() && node.nodeName() == "r_error" ) {
      QDomElement r_error = node.toElement();
      _r_error = r_error.text();
    }
    if ( node.isElement() && node.nodeName() == "r_approved" ) {
      QDomElement r_approved = node.toElement();
      _r_approved = r_approved.text();
    }
    if ( node.isElement() && node.nodeName() == "r_code" ) {
      QDomElement r_code = node.toElement();
      _r_code = r_code.text();
    }
    if ( node.isElement() && node.nodeName() == "r_message" ) {
      QDomElement r_message = node.toElement();
      _r_message = r_message.text();
    }
    if ( node.isElement() && node.nodeName() == "r_time" ) {
      QDomElement r_time = node.toElement();
      _r_time = r_time.text();
    }
    if ( node.isElement() && node.nodeName() == "r_ref" ) {
      QDomElement r_ref = node.toElement();
      _r_ref = r_ref.text();
    }
    if ( node.isElement() && node.nodeName() == "r_tdate" ) {
      QDomElement r_tdate = node.toElement();
      _r_tdate = r_tdate.text();
    }
    if ( node.isElement() && node.nodeName() == "r_tax" ) {
      QDomElement r_tax = node.toElement();
      _r_tax = r_tax.text();
    }
    if ( node.isElement() && node.nodeName() == "r_shipping" ) {
      QDomElement r_shipping = node.toElement();
      _r_shipping = r_shipping.text();
    }
    if ( node.isElement() && node.nodeName() == "r_score") {
      QDomElement r_score = node.toElement();
      _r_score = r_score.text();
    }
    node = node.nextSibling();
  }
  
  q.prepare( "UPDATE ccpay"
             "   SET ccpay_amount = :ccpay_amount, "
             "       ccpay_auth = FALSE, "
             "       ccpay_status = :ccpay_status, "
             "       ccpay_curr_id = :ccpay_curr_id "
             " WHERE ccpay_id = :ccpay_id;" );
  q.bindValue(":ccpay_id", _preauth->id());
  q.bindValue(":ccpay_amount",_CCAmount->baseValue());    // ##### localValue()?
  q.bindValue(":ccpay_curr_id",_CCAmount->baseId());      // ##### id()?
  
  doDollars = 0;
  
  if (_r_approved == "APPROVED")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction was approved\n") + _r_ref, QMessageBox::Ok);  q.bindValue(":ccpay_status","C");
    doDollars = _CCAmount->baseValue();                   // ##### localValue()?
  }
  
  if (_r_approved == "DENIED")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction was denied\n") + _r_message, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved == "DUPLICATE")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction is a duplicate\n") + _r_message, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved == "DECLINED")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction is a declined\n") + _r_error, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved == "FRAUD")
  {
    QMessageBox::information(this, tr("YourPay"), tr("This transaction is denied because of possible fraud\n") + _r_error, QMessageBox::Ok);
    q.bindValue(":ccpay_status","D");
  }
  
  if (_r_approved.length() == 0 || _r_approved.isNull() || _r_approved.isEmpty())
  {
    QMessageBox::information(this, tr("YourPay"),
                             tr("<p>No Approval Code<br>%1<br>%2<br>%3")
                               .arg(_r_error).arg(_r_message).arg(_response),
                               QMessageBox::Ok);
    q.bindValue(":ccpay_status","X");
  }
  
  q.exec();
  
  //We need to a charge here to do a cash receipt
  //  We need some logic for a successful charge and for a non-successful charge
  if (doDollars > 0)
  {
// This is a sucessful charge
    q.prepare("INSERT INTO cashrcpt (cashrcpt_id,"
              " cashrcpt_cust_id,"
              " cashrcpt_amount,"
              " cashrcpt_curr_id,"
              " cashrcpt_fundstype, "
              " cashrcpt_docnumber,"
              " cashrcpt_bankaccnt_id,"
              " cashrcpt_notes,"
              "  cashrcpt_distdate) "
              "VALUES (nextval('cashrcpt_cashrcpt_id_seq'), :cashrcpt_cust_id,"
              "       :cashrcpt_amount, :cashrcpt_curr_id, :cashrcpt_fundstype,"
              "       :cashrcpt_docnumber, :cashrcpt_bankaccnt_id,"
              "       :cashrcpt_notes, current_date);");
    q.bindValue(":cashrcpt_cust_id",_cust->id());
    q.bindValue(":cashrcpt_amount",doDollars);
    q.bindValue(":cashrcpt_curr_id", _CCAmount->baseId());      // ##### id()?
    q.bindValue(":cashrcpt_fundstype",_ccard_type);
    q.bindValue(":cashrcpt_docnumber",_backrefnum);
    q.bindValue(":cashrcpt_bankaccnt_id",_metrics->value("CCDefaultBank").toInt());
    q.bindValue(":cashrcpt_notes","Converted Pre-auth");
    q.exec();
  }
  
  //Clean up
  sFillCashrcptList();
  sFillAropenCMList();
  sFillAropenList();
  sFillPreauthList();
  _CCAmount->clear();
    
}