Changeset 5cb32e6


Ignore:
Timestamp:
02/25/14 08:18:52 (5 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.1, releng/10.0.2
Children:
4588960
Parents:
dd91d89
Message:

Convert the AppCafe? backend to use the new DLProcess class within libpcbsd-utils for download parsing/notifications. Seems to work just fine.

Location:
src-qt4/pc-softwaremanager
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-softwaremanager/pc-softwaremanager.pro

    r1b89eeb r5cb32e6  
    44CONFIG  += qt warn_on release 
    55 
    6 LIBS    += -lQtSolutions_SingleApplication-head 
     6LIBS    += -lQtSolutions_SingleApplication-head -lpcbsd-utils 
    77 
    88//INCLUDEPATH+= ../libpcbsd/utils/ 
  • src-qt4/pc-softwaremanager/processManager.cpp

    r52fa6eb r5cb32e6  
    2727 
    2828ProcessManager::ProcessManager(){ 
    29   //Get the system environment for all the processes 
    30   QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); 
    31     env.insert("PBI_FETCH_PARSING","YES"); //For readable download notifications 
    3229    //Initialize the UPDATE Process 
    33     upProc = new QProcess; upProc->setProcessEnvironment(env); 
    34     upProc->setProcessChannelMode(QProcess::MergedChannels); 
    35     connect(upProc, SIGNAL(readyRead()),this,SLOT(slotUpProcMessage()) ); 
     30    upProc = new DLProcess(this); 
     31        upProc->setDLType("PBI"); 
     32    connect(upProc, SIGNAL(UpdateMessage(QString)), this, SLOT(slotUpProcMessage(QString)) ); 
     33    connect(upProc, SIGNAL(UpdatePercent(QString, QString, QString)), this, SLOT(slotUpProcStats(QString,QString, QString)) ); 
    3634    connect(upProc, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotUpProcFinished()) ); 
     35         
    3736    //Initialize the REMOVE Process 
    38     remProc = new QProcess; remProc->setProcessEnvironment(env); 
    39     remProc->setProcessChannelMode(QProcess::MergedChannels); 
    40     connect(remProc, SIGNAL(readyRead()),this,SLOT(slotRemProcMessage()) ); 
     37    remProc = new DLProcess(this); 
     38        //remProc->setDLType("PBI"); //Does not need download parsing - just use standard message output 
     39    connect(remProc, SIGNAL(UpdateMessage(QString)), this, SLOT(slotRemProcMessage(QString)) ); 
    4140    connect(remProc, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotRemProcFinished()) ); 
     41         
    4242    //Initialize the DOWNLOAD Process 
    43     dlProc = new QProcess; dlProc->setProcessEnvironment(env); 
    44     dlProc->setProcessChannelMode(QProcess::MergedChannels); 
    45     connect(dlProc, SIGNAL(readyRead()),this,SLOT(slotDlProcMessage()) ); 
     43    dlProc = new DLProcess(this); 
     44        dlProc->setDLType("PBI"); 
     45    connect(dlProc, SIGNAL(UpdateMessage(QString)), this, SLOT(slotDlProcMessage(QString)) ); 
     46    connect(dlProc, SIGNAL(UpdatePercent(QString, QString, QString)), this, SLOT(slotDlProcStats(QString,QString, QString)) ); 
    4647    connect(dlProc, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotDlProcFinished()) ); 
     48         
    4749    //Initialize the INSTALL Process 
    48     inProc = new QProcess; inProc->setProcessEnvironment(env); 
    49     inProc->setProcessChannelMode(QProcess::MergedChannels); 
    50     connect(inProc, SIGNAL(readyRead()),this,SLOT(slotInProcMessage()) ); 
     50    inProc = new DLProcess(this); 
     51        //inProc->setDLType("PBI"); //Does not need download parsing - just use standard message output 
     52    connect(inProc, SIGNAL(UpdateMessage(QString)), this, SLOT(slotInProcMessage(QString)) ); 
    5153    connect(inProc, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotInProcFinished()) ); 
     54     
    5255    //Initialize the OTHER Process 
    53     otProc = new QProcess; otProc->setProcessEnvironment(env); 
    54     connect(otProc, SIGNAL(readyReadStandardOutput()),this,SLOT(slotOtProcMessage()) ); 
     56    otProc = new DLProcess(this); 
     57        //otProc->setDLType("PBI"); //Does not need download parsing - just use standard message output 
     58    connect(otProc, SIGNAL(UpdateMessage(QString)), this, SLOT(slotOtProcMessage(QString)) ); 
    5559    connect(otProc, SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotOtProcFinished()) ); 
    5660} 
     
    131135// ===== PRIVATE SLOTS ===== 
    132136// ========================= 
    133 QString ProcessManager::parseDlLine(QString line){ 
     137//QString ProcessManager::parseDlLine(QString line){ 
    134138  /*DOWNLOAD NOTIFICATION CODES: 
    135139  Download complete: "DLDONE" 
     
    138142  Download starting: "DLSTART" 
    139143  */ 
     144/* 
    140145  QString out; 
    141146  if( line.startsWith("FETCH:") ){ return "DLSTART"; } 
     
    193198  return out; 
    194199} 
    195  
     200*/ 
    196201// == UPDATE PROCESS == 
    197 void ProcessManager::slotUpProcMessage(){ 
    198   while( upProc->canReadLine() ){ 
    199     QString line = upProc->readLine().simplified(); 
    200     if(line.isEmpty()){ continue; } 
    201     QString dl = parseDlLine(line); 
    202     if(!dl.isEmpty()){  
    203       emit ProcessMessage(UPDATE,dl); //Download status 
    204       if( !dl.startsWith("DLSTAT::") ){ 
    205         upLog << line; //not just a status update - add to the log (log download start/stop)     
    206       } 
    207     }else{  
    208       emit ProcessMessage(UPDATE,line);  
    209       upLog << line; //not a download line - add to the log 
    210     } 
    211   } 
     202void ProcessManager::slotUpProcMessage(QString msg){ 
     203  //Check for DL start/finish messages 
     204  if(msg.startsWith("FETCH:")){ msg = "DLSTART"; } 
     205  else if(msg.startsWith("FETCHDONE")){ msg = "DLDONE"; } 
     206  else{ 
     207    //Add the message to the log 
     208    upLog << msg; 
     209  } 
     210  //Now send it out 
     211  emit ProcessMessage(UPDATE, msg); 
     212} 
     213 
     214void ProcessManager::slotUpProcStats(QString percent, QString size, QString speed){ 
     215  //Format the display string for output 
     216  QString out = "DLSTAT::"+percent+"::"+size+"::"+speed; 
     217  emit ProcessMessage(UPDATE, out); 
    212218} 
    213219 
     
    224230 
    225231// == REMOVE PROCESS == 
    226 void ProcessManager::slotRemProcMessage(){ 
    227   while( remProc->canReadLine() ){ 
    228     QString line = remProc->readLine().simplified(); 
    229     if(!line.isEmpty()){  
    230       remLog << line;  
    231       emit ProcessMessage(REMOVE,line); 
    232     } 
    233   } 
     232void ProcessManager::slotRemProcMessage(QString msg){ 
     233  //Add the message to the log 
     234  remLog << msg; 
     235  //Now send it out 
     236  emit ProcessMessage(REMOVE, msg); 
    234237} 
    235238 
     
    245248 
    246249// == DOWNLOAD PROCESS == 
    247 void ProcessManager::slotDlProcMessage(){ 
    248   while( dlProc->canReadLine() ){ 
    249     QString line = dlProc->readLine().simplified(); 
    250     if(line.isEmpty()){ continue; } 
    251     QString dl = parseDlLine(line); 
    252     if(!dl.isEmpty()){  
    253       emit ProcessMessage(DOWNLOAD,dl); //Download status 
    254       if( !dl.startsWith("DLSTAT::") ){ 
    255         dlLog << line; //not just a status update - add to the log (log download start/stop)     
    256       } 
    257     }else{  
    258       emit ProcessMessage(DOWNLOAD,line);  
    259       dlLog << line; //not a download line - add to the log 
    260     } 
    261   } 
     250void ProcessManager::slotDlProcMessage(QString msg){ 
     251  //Check for DL start/finish messages 
     252  if(msg.startsWith("FETCH:")){ msg = "DLSTART"; } 
     253  else if(msg.startsWith("FETCHDONE")){ msg = "DLDONE"; } 
     254  else{ 
     255    //Add the message to the log 
     256    dlLog << msg; 
     257  } 
     258  //Now send it out 
     259  emit ProcessMessage(DOWNLOAD, msg); 
     260} 
     261 
     262void ProcessManager::slotDlProcStats(QString percent, QString size, QString speed){ 
     263  //Format the display string for output 
     264  QString out = "DLSTAT::"+percent+"::"+size+"::"+speed; 
     265  emit ProcessMessage(DOWNLOAD, out); 
    262266} 
    263267 
     
    273277 
    274278// == INSTALL PROCESS == 
    275 void ProcessManager::slotInProcMessage(){ 
    276   while( inProc->canReadLine() ){ 
    277     QString line = inProc->readLine().simplified(); 
    278     if(!line.isEmpty()){  
    279       inLog << line;  
    280       emit ProcessMessage(INSTALL,line); 
    281     } 
    282   } 
     279void ProcessManager::slotInProcMessage(QString msg){ 
     280  //Add the message to the log 
     281  inLog << msg; 
     282  //Now send it out 
     283  emit ProcessMessage(INSTALL, msg); 
    283284} 
    284285 
     
    294295 
    295296// == OTHER PROCESS == 
    296 void ProcessManager::slotOtProcMessage(){ 
    297   QString msg = otProc->readAllStandardOutput(); 
    298   emit ProcessMessage(OTHER,msg); 
     297void ProcessManager::slotOtProcMessage(QString msg){ 
     298  //send it out (no logging - this channel is for quick commands with almost no output) 
     299  emit ProcessMessage(OTHER, msg); 
    299300} 
    300301 
  • src-qt4/pc-softwaremanager/processManager.h

    r52fa6eb r5cb32e6  
    22#define _APPCAFE_PROCESS_MANAGER_H 
    33 
    4 #include <QProcess> 
    5 #include <QProcessEnvironment> 
    64#include <QString> 
    75#include <QStringList> 
    86#include <QObject> 
    97#include <QDebug> 
     8 
     9#include <pcbsd-DLProcess.h> 
    1010 
    1111#include "extras.h" 
     
    3232         
    3333private: 
    34         QProcess *upProc, *remProc, *dlProc, *inProc, *otProc; 
     34        DLProcess *upProc, *remProc, *dlProc, *inProc, *otProc; 
    3535        QStringList upLog, remLog, dlLog, inLog; 
    3636        bool remStrictErrChecking; 
    3737 
    3838private slots: 
    39         QString parseDlLine(QString); 
    40         void slotUpProcMessage(); 
     39        //QString parseDlLine(QString); 
     40        void slotUpProcMessage(QString); 
     41        void slotUpProcStats(QString,QString, QString); 
    4142        void slotUpProcFinished(); 
    42         void slotRemProcMessage(); 
     43 
     44        void slotRemProcMessage(QString); 
    4345        void slotRemProcFinished(); 
    44         void slotDlProcMessage(); 
     46 
     47        void slotDlProcMessage(QString); 
     48        void slotDlProcStats(QString,QString, QString); 
    4549        void slotDlProcFinished(); 
    46         void slotInProcMessage(); 
     50 
     51        void slotInProcMessage(QString); 
    4752        void slotInProcFinished(); 
    48         void slotOtProcMessage(); 
     53 
     54        void slotOtProcMessage(QString); 
    4955        void slotOtProcFinished(); 
    5056 
Note: See TracChangeset for help on using the changeset viewer.