Changeset fa2ad6e


Ignore:
Timestamp:
12/12/13 07:34:17 (11 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
ad9186e, 009d9db
Parents:
6bfd3ae
Message:

Add some initial JSON parsing to pc-pkgmanager for reading the new
PKGNG status updates from EVENT_PIPE

Location:
src-qt4/pc-pkgmanager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-pkgmanager/mainWin.cpp

    r1211b75 rfa2ad6e  
    356356 
    357357  qDebug() << cmd + " " + flags.join(" "); 
     358 
     359  // Create the EVENT_PIPE 
     360  if ( wDir.isEmpty() ) 
     361    system("mkfifo /tmp/pkg-fifo"); 
     362  else 
     363    system("mkfifo " + wDir.toLatin1() + "/tmp/pkg-fifo"); 
     364 
     365  // Open and connect the EVENT_PIPE 
     366  eP = new QProcess(); 
     367  connect( eP, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadEventPipe()) ); 
     368  eP->start(QString("tail"), QStringList() << "-f" << wDir + "/tmp/pkg-fifo"); 
     369  qDebug() << "Starting EVENT_PIPE" << wDir + "/tmp/pkg-fifo"; 
    358370   
    359371  // Setup the first process 
     
    361373  QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); 
    362374  env.insert("PCFETCHGUI", "YES"); 
     375  env.insert("EVENT_PIPE", "/tmp/pkg-fifo"); 
    363376  uProc->setProcessEnvironment(env); 
    364377  uProc->setProcessChannelMode(QProcess::MergedChannels); 
     
    531544    pkgHasFailed=true; 
    532545 
     546  // Close the event pipe 
     547  eP->kill(); 
     548  qDebug() << "Stopping EVENT_PIPE"; 
     549  system("rm " + wDir.toLatin1() + "/tmp/pkg-fifo"); 
     550 
    533551  // Run the next command on the stack if necessary 
    534552  if (  pkgCmdList.size() > 1 ) { 
     
    14781496} 
    14791497 
     1498 
     1499void mainWin::slotReadEventPipe() 
     1500{ 
     1501   QString line; 
     1502 
     1503   while (eP->canReadLine()) { 
     1504     line = eP->readLine().simplified(); 
     1505     qDebug() << line; 
     1506 
     1507     // No JSON in Qt4, once we move to Qt5, replace this 
     1508     // with the new JSON parser 
     1509     if ( line.indexOf("\"msg") != -1 ) { 
     1510          line.remove(0, line.indexOf("\"msg") + 8); 
     1511          line.truncate(line.lastIndexOf("\"")); 
     1512          qDebug() << line; 
     1513          textStatus->setText(line); 
     1514     } 
     1515   } 
     1516} 
  • src-qt4/pc-pkgmanager/mainWin.h

    r426313b rfa2ad6e  
    7878    void slotNGReadInfo(); 
    7979 
     80    void slotReadEventPipe(); 
     81 
    8082private: 
    8183    // Generic pkg process handlers 
     
    156158    QActionGroup *viewGroup; 
    157159 
     160    // Event pipe process 
     161    QProcess *eP; 
     162 
    158163signals: 
    159164 
Note: See TracChangeset for help on using the changeset viewer.