Changeset 170608c0


Ignore:
Timestamp:
12/04/13 01:09:09 (12 months ago)
Author:
yurkis <yurkis@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
95e2015
Parents:
4e3271f
git-author:
yurkis <yurkis@…> (12/04/13 01:07:40)
git-committer:
yurkis <yurkis@…> (12/04/13 01:09:09)
Message:

Fix information order in download progress message; Some code cleanup

Location:
src-qt4/pc-updatecenter
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-updatecenter/pbicontroller.cpp

    r08b1b75 r170608c0  
    2929#include <QDebug> 
    3030 
    31 _STRING_CONSTANT PBU_UPDATE_CMD= "pbi_update"; 
    32 _STRING_CONSTANT AVAIL= "Available:"; 
    33 _STRING_CONSTANT DOWNLOAD_INDICATOR = "DOWNLOADED:"; 
    34 _STRING_CONSTANT FETCHDONE= "FETCHDONE"; 
    35 _STRING_CONSTANT FETCH_WORLD= "FETCH"; 
    36 _STRING_CONSTANT DOWNLOADING_ERROR= "ERROR: "; 
     31__string_constant PBU_UPDATE_CMD= "pbi_update"; 
     32__string_constant AVAIL= "Available:"; 
     33//__string_constant DOWNLOAD_INDICATOR = "DOWNLOADED:"; 
     34__string_constant FETCHDONE= "FETCHDONE"; 
     35__string_constant FETCH_WORLD= "FETCH"; 
     36__string_constant DOWNLOADING_ERROR= "ERROR: "; 
    3737 
    3838/////////////////////////////////////////////////////////////////////////////// 
     
    104104{ 
    105105    SProgress progress; 
     106    long dl_size; 
     107    long dl_complete; 
     108    QString dl_speed; 
    106109    line= line.trimmed(); 
    107110    QString log_message= line; 
    108     qDebug()<<line; 
    109     progress.mLogMessages = QStringList()<<line; 
     111 
     112    //progress.mLogMessages = QStringList()<<line; 
    110113    progress.mItemNo= mCurrentUpdate; 
    111114    progress.mItemsCount= mAppsToUpdate.size(); 
     
    115118    current_app= current_app.left(current_app.lastIndexOf("-")); // remove ver 
    116119 
    117     if (line.contains(DOWNLOAD_INDICATOR)) 
    118     { 
    119         // parse download 
     120    if (parseFetchOutput(line,dl_size, dl_complete, dl_speed)) 
     121    { 
    120122        progress.misCanCancel=true; 
    121  
    122         //Example: 
    123         // SIZE: 215710 DOWNLOADED: 3973 SPEED: 233 KB/s 
    124         // ^0    ^1     ^2          ^3   ^4     ^5  ^6 
    125  
    126         QStringList dl_list = line.split(" "); 
    127         progress.mProgressMax= dl_list[1].toInt(); 
    128         progress.mProgressCurr= dl_list[3].toInt(); 
    129         QString speed= dl_list[5] + QString(" ") + dl_list[6]; 
    130         long size= dl_list[3].toInt() * 1024; 
    131         long downloaded= dl_list[1].toInt() * 1024; 
     123        log_message.clear(); 
    132124        progress.mMessage= tr("[%1/%2] Downloading update for %3 (%4/%5 at %6)").arg(QString::number(progress.mItemNo+1), 
    133125                                                                             QString::number(progress.mItemsCount), 
    134126                                                                             current_app, 
    135                                                                              pcbsd::Utils::bytesToHumanReadable(size), 
    136                                                                              pcbsd::Utils::bytesToHumanReadable(downloaded), 
    137                                                                              speed); 
    138         log_message.clear(); 
     127                                                                             pcbsd::Utils::bytesToHumanReadable(dl_complete), 
     128                                                                             pcbsd::Utils::bytesToHumanReadable(dl_size), 
     129                                                                             dl_speed); 
    139130        reportProgress(progress); 
    140131        return; 
  • src-qt4/pc-updatecenter/pkgcontroller.cpp

    r08b1b75 r170608c0  
    2626 
    2727#include "pcbsd-utils.h" 
     28#include "utils.h" 
    2829 
    2930#include <QDebug> 
    3031#include <QFile> 
    3132 
    32 static const char* const FULLY_UPDATED_MESSAGE = "All packages are up to date!"; 
    33 static const char* const UPDATES_AVAIL_STRING = "Upgrades have been requested for the following"; 
    34 static const char* const UPDATES_AVAIL_SIZE_STRING = "The upgrade will require "; 
    35 static const char* const UPDATES_AVAIL_SIZE_FREE_STR= "The upgrade will free "; 
    36 static const char* const UPDATES_AVAIL_DL_SIZE_STRING = " to be downloaded"; 
    37 static const char* const UPDATES_AVAIL_END_STRING = "To start the upgrade run"; 
    38  
    39 static const char* const INSTALLING  = "Installing"; 
    40 static const char* const UPGRADING   = "Upgrading"; 
    41 static const char* const REINSTALLING = "Reinstalling"; 
    42  
    43 static const char* const FETCH = "FETCH:"; 
    44 static const char* const FETCH_DONE = "FETCHDONE"; 
    45 static const char* const SIZE_DL_MARKER = "SIZE:"; 
    46 static const char* const DOWNLOADED_DL_MARKER = "DOWNLOADED:"; 
    47 static const char* const DL_FETCH_START = "FETCH:"; 
    48 static const char* const DL_RESUME_DOWNLOAD= "Resuming download of:"; 
    49 static const char* const PKG_CONFLICTS_LIST= "PKGCONFLICTS: "; 
    50 static const char* const PKG_CONFLICTS_REPLY= "PKGREPLY: "; 
    51 static const char* const PKG_INSTALL_START_MARKER= "Upgrades have been requested for the following"; 
    52 static const char* const PKG_INSTALL_DONE = "... done"; 
    53  
    54 static const char* const PKG_NETWORK_ERROR = ": No address record"; 
     33__string_constant FULLY_UPDATED_MESSAGE = "All packages are up to date!"; 
     34__string_constant UPDATES_AVAIL_STRING = "Upgrades have been requested for the following"; 
     35__string_constant UPDATES_AVAIL_SIZE_STRING = "The upgrade will require "; 
     36__string_constant UPDATES_AVAIL_SIZE_FREE_STR= "The upgrade will free "; 
     37__string_constant UPDATES_AVAIL_DL_SIZE_STRING = " to be downloaded"; 
     38__string_constant UPDATES_AVAIL_END_STRING = "To start the upgrade run"; 
     39 
     40__string_constant INSTALLING  = "Installing"; 
     41__string_constant UPGRADING   = "Upgrading"; 
     42__string_constant REINSTALLING = "Reinstalling"; 
     43 
     44__string_constant FETCH = "FETCH:"; 
     45__string_constant FETCH_DONE = "FETCHDONE"; 
     46__string_constant SIZE_DL_MARKER = "SIZE:"; 
     47__string_constant DOWNLOADED_DL_MARKER = "DOWNLOADED:"; 
     48__string_constant DL_FETCH_START = "FETCH:"; 
     49__string_constant DL_RESUME_DOWNLOAD= "Resuming download of:"; 
     50__string_constant PKG_CONFLICTS_LIST= "PKGCONFLICTS: "; 
     51__string_constant PKG_CONFLICTS_REPLY= "PKGREPLY: "; 
     52__string_constant PKG_INSTALL_START_MARKER= "Upgrades have been requested for the following"; 
     53__string_constant PKG_INSTALL_DONE = "... done"; 
     54 
     55__string_constant PKG_NETWORK_ERROR = ": No address record"; 
    5556 
    5657 
     
    247248    SProgress progress; 
    248249    QString log_line; 
     250    long dl_size; 
     251    long dl_complete; 
     252    QString dl_speed; 
    249253 
    250254    progress.mItemNo = mCurrentPkgNo; 
     
    282286    } 
    283287    else 
    284     if ( line.contains(SIZE_DL_MARKER) && line.contains(DOWNLOADED_DL_MARKER)) 
    285     { 
    286         //downloading progress parsing 
     288    if (parseFetchOutput(line, dl_size, dl_complete, dl_speed)) 
     289    { 
    287290        log_line.clear(); 
    288291        progress.misCanCancel= true; 
    289  
    290         //Example: 
    291         // SIZE: 215710 DOWNLOADED: 3973 SPEED: 233 KB/s 
    292         // ^0    ^1     ^2          ^3   ^4     ^5  ^6 
    293  
    294         //TODO: as eparate function (code duplication) 
    295         QStringList dl_list = line.split(" "); 
    296         progress.mProgressMax= dl_list[1].toInt(); 
    297         progress.mProgressCurr= dl_list[3].toInt(); 
    298         QString speed= dl_list[5] + QString(" ") + dl_list[6]; 
    299         long size= dl_list[1].toInt() * 1024; 
    300         long downloaded= dl_list[3].toInt() * 1024; 
    301  
    302292        progress.mMessage= tr("[%1/%2] Downloading %3 (%4/%5 at %6)").arg(QString::number(progress.mItemNo+1), 
    303293                                                                                  QString::number(progress.mItemsCount), 
    304294                                                                                  mCurrentPkgName, 
    305                                                                                   pcbsd::Utils::bytesToHumanReadable(size), 
    306                                                                                   pcbsd::Utils::bytesToHumanReadable(downloaded), 
    307                                                                                   speed); 
     295                                                                                  pcbsd::Utils::bytesToHumanReadable(dl_complete), 
     296                                                                                  pcbsd::Utils::bytesToHumanReadable(dl_size), 
     297                                                                                  dl_speed); 
    308298    } 
    309299    else 
  • src-qt4/pc-updatecenter/syscontroller.cpp

    r08b1b75 r170608c0  
    2828#include <QDebug> 
    2929 
    30 _STRING_CONSTANT PC_UPDATE_COMMAND = "pc-updatemanager"; 
     30__string_constant PC_UPDATE_COMMAND = "pc-updatemanager"; 
    3131//_STRING_CONSTANT FBSD_UPDATE_COMMAND = "cat"; 
    32 _STRING_CONSTANT FBSD_UPDATE_COMMAND = "pc-fbsdupdatecheck"; 
     32__string_constant FBSD_UPDATE_COMMAND = "pc-fbsdupdatecheck"; 
    3333static const QStringList PC_UPDATE_ARGS(QStringList()<<"check"); 
    3434static const QStringList FBSD_UPDATE_ARGS (QStringList()<<"update"); 
    3535//static const QStringList FBSD_UPDATE_ARGS (QStringList()<<"/home/yurkis/_sysbasesys_check.txt"); 
    3636 
    37 _STRING_CONSTANT NAME_TAG = "NAME:"; 
    38 _STRING_CONSTANT TYPE_TAG = "TYPE:"; 
    39 _STRING_CONSTANT TAG_TAG = "TAG:"; 
    40 _STRING_CONSTANT VERSION_TAG = "VERSION:"; 
    41 _STRING_CONSTANT DEATILS_TAG = "DETAILS:"; 
    42 _STRING_CONSTANT DATE_TAG = "DATE:"; 
    43 _STRING_CONSTANT SIZE_TAG = "SIZE:"; 
    44 _STRING_CONSTANT CU_END_MARKER = "To install:"; 
    45 _STRING_CONSTANT PATCH_TYPE = "PATCH"; 
    46 _STRING_CONSTANT SYSUPDATE_TYPE = "SYSUPDATE"; 
    47 _STRING_CONSTANT STANDALONE_TAG = "STANDALONE:"; 
    48 _STRING_CONSTANT REQUIRESREBOOT_TAG = "REQUIRESREBOOT:"; 
    49  
    50 _STRING_CONSTANT FILES_MODIFYED_LOCALLY = "been downloaded because the files have been modified locally:"; 
    51 _STRING_CONSTANT FILES_TO_DELETE = "The following files will be removed as part of updating to"; 
    52 _STRING_CONSTANT FILES_TO_UPDATE = "The following files will be updated as part of updating to"; 
    53  
    54 _STRING_CONSTANT NETWORKING_PROBLEM= "No mirrors remaining, giving up."; 
    55  
    56 _STRING_CONSTANT SYS_PATCH_DOWNLOADING_WORD= "DOWNLOADING:"; 
    57 _STRING_CONSTANT SYS_PATCH_FETCH= "FETCH"; 
    58 _STRING_CONSTANT SYS_PATCH_DL_FINISHED= "DOWNLOADFINISHED:"; 
    59 _STRING_CONSTANT SYS_PATCH_TOTAL_STEPS= "TOTALSTEPS:"; 
    60 _STRING_CONSTANT SYS_PATCH_SETSTEPS= "SETSTEPS:"; 
    61 _STRING_CONSTANT SYS_PATCH_MSG= "MSG:"; 
    62 _STRING_CONSTANT SYS_PATCH_FINISHED= "INSTALLFINISHED:"; 
     37__string_constant NAME_TAG = "NAME:"; 
     38__string_constant TYPE_TAG = "TYPE:"; 
     39__string_constant TAG_TAG = "TAG:"; 
     40__string_constant VERSION_TAG = "VERSION:"; 
     41__string_constant DEATILS_TAG = "DETAILS:"; 
     42__string_constant DATE_TAG = "DATE:"; 
     43__string_constant SIZE_TAG = "SIZE:"; 
     44__string_constant CU_END_MARKER = "To install:"; 
     45__string_constant PATCH_TYPE = "PATCH"; 
     46__string_constant SYSUPDATE_TYPE = "SYSUPDATE"; 
     47__string_constant STANDALONE_TAG = "STANDALONE:"; 
     48__string_constant REQUIRESREBOOT_TAG = "REQUIRESREBOOT:"; 
     49 
     50__string_constant FILES_MODIFYED_LOCALLY = "been downloaded because the files have been modified locally:"; 
     51__string_constant FILES_TO_DELETE = "The following files will be removed as part of updating to"; 
     52__string_constant FILES_TO_UPDATE = "The following files will be updated as part of updating to"; 
     53 
     54__string_constant NETWORKING_PROBLEM= "No mirrors remaining, giving up."; 
     55 
     56__string_constant SYS_PATCH_DOWNLOADING_WORD= "DOWNLOADING:"; 
     57__string_constant SYS_PATCH_FETCH= "FETCH"; 
     58__string_constant SYS_PATCH_DL_FINISHED= "DOWNLOADFINISHED:"; 
     59__string_constant SYS_PATCH_TOTAL_STEPS= "TOTALSTEPS:"; 
     60__string_constant SYS_PATCH_SETSTEPS= "SETSTEPS:"; 
     61__string_constant SYS_PATCH_MSG= "MSG:"; 
     62__string_constant SYS_PATCH_FINISHED= "INSTALLFINISHED:"; 
    6363 
    6464/////////////////////////////////////////////////////////////////////////////// 
  • src-qt4/pc-updatecenter/utils.h

    r08b1b75 r170608c0  
    2929#include <QStringList> 
    3030 
    31 #define _STRING_CONSTANT static const char* const 
     31#define __string_constant static const char* const 
    3232 
    3333 
     
    3535inline bool parseFetchOutput(QString line, long& size, long& downloaded, QString& speed) 
    3636{ 
    37     static const char* const SIZE_DL_MARKER = "SIZE:"; 
    38     static const char* const DOWNLOADED_DL_MARKER = "DOWNLOADED:"; 
     37    __string_constant SIZE_DL_MARKER = "SIZE:"; 
     38    __string_constant DOWNLOADED_DL_MARKER = "DOWNLOADED:"; 
    3939 
    4040    //Example: 
Note: See TracChangeset for help on using the changeset viewer.