Changeset e0c368d


Ignore:
Timestamp:
09/27/13 11:52:17 (10 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
eb70a80
Parents:
565dbe4
Message:

Create a new "LPMessages" dialog class and integrate it into the tray application. This will show the full messages that are available, as well as display the contents of any known log/error files that the watcher is aware of.

Location:
src-qt4/life-preserver
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/life-preserver/LPTray.cpp

    r8c6a630 re0c368d  
    99  //Setup the context menu 
    1010  menu = new QMenu; 
    11         menu->addAction(new QAction(QIcon(":/images/application-exit.png"),tr("Close Life Preserver Tray"),this) ); 
    12         connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(slotClose()) ); 
     11        menu->addAction(QIcon(":/images/backup-failed.png"),tr("View Messages"),this,SLOT(startMessageDialog()) ); 
     12        menu->addAction(QIcon(":/images/tray-icon-idle.png"),tr("Start Application UI"),this,SLOT(startGUI()) ); 
     13        menu->addSeparator(); 
     14        menu->addAction(QIcon(":/images/application-exit.png"),tr("Close Life Preserver Tray"),this,SLOT(slotClose()) ); 
    1315  this->setContextMenu(menu); 
    1416  //Setup initial icon for the tray 
     
    1618  //Create the configuration GUI 
    1719  GUI = new mainUI(); 
     20  msgdlg = new LPMessages(); 
    1821  //connect other signals/slots 
    1922  connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)) ); 
     
    2730  watcher->stop(); 
    2831  delete watcher; 
     32  delete GUI; 
     33  delete msgdlg; 
    2934} 
    3035 
     
    137142    GUI->show(); 
    138143} 
     144 
     145void LPTray::startMessageDialog(){ 
     146  //Get all the available messages from the watcher 
     147  QStringList msgs, errs, logs; //message variables to fill 
     148  //Cycle through the watcher types and get any messages 
     149  QStringList types; types << "message" << "replication" << "critical" << "mirror" << "resilver" << "scrub"; 
     150  QStringList infoL; infoL << "id" << "timestamp" << "device" << "message" << "files"; 
     151  for(int i=0; i<types.length(); i++){ 
     152    QStringList info = watcher->getMessages(types[i], infoL); 
     153    if(info.isEmpty()){continue;} 
     154    if(info[0] == "ERROR"){ 
     155      errs << info[1] + " (" + info[2] + "): " + info[3]; 
     156    }else if(!info[0].isEmpty()){ 
     157      msgs << info[1] + " (" + info[2] + "): " + info[3]; 
     158    } 
     159    if(!info[4].isEmpty()){ 
     160      logs << info[4]; // In format:  "example logfile </var/logs/example.log>" 
     161    } 
     162  } 
     163  //Now start up the dialog 
     164  msgdlg->setMessages( msgs.join("\n") ); 
     165  msgdlg->setErrors( errs.join("\n") ); 
     166  msgdlg->setLogFiles(logs); 
     167  msgdlg->raise(); 
     168  msgdlg->show(); 
     169} 
  • src-qt4/life-preserver/LPTray.h

    re9760d0 re0c368d  
    99#include "mainUI.h" 
    1010#include "LPWatcher.h" 
     11#include "LPMessages.h" 
    1112 
    1213class LPTray : public QSystemTrayIcon{ 
     
    1819private: 
    1920        LPWatcher *watcher; 
     21        LPMessages *msgdlg; 
    2022        QMenu *menu; 
    2123        mainUI *GUI; 
    22  
    2324 
    2425        void updateTrayIcon(); 
     
    3233        void slotSingleInstance(); 
    3334        void startGUI(); 
     35        void startMessageDialog(); 
    3436 
    3537}; 
  • src-qt4/life-preserver/LPWatcher.cpp

    r565dbe4 re0c368d  
    1616    *4 = timestamp (full date/time timestamp in readable format) 
    1717    *5 = short timestamp (just time in readable format) 
     18    *6 = description and path of a log file (FORMAT: "example file </path/to/file.log>") 
    1819 
    1920  Valid Internal ID's: 
     
    101102    else if(msgList[i]=="timestamp" && LOGS.contains(base+4)){ output << LOGS[base+4]; } 
    102103    else if(msgList[i]=="time" && LOGS.contains(base+5)){ output << LOGS[base+5]; } 
     104    else if(msgList[i]=="files" && LOGS.contains(base+6)){ output << LOGS[base+6]; } 
    103105    else{ output << ""; } 
    104106  } 
     
    167169      LOGS.insert(24, timestamp); //full timestamp 
    168170      LOGS.insert(25, time); // time only 
     171      LOGS.insert(26,tr("Replication Log")+" <"+FILE_REPLICATION+">"); //log file 
    169172      if(!quiet){ emit MessageAvailable("replication"); } 
    170173    }else if(message.contains("finished replication")){ 
     
    177180      LOGS.insert(23, QString(tr("Finished replication for %1")).arg(dev) ); 
    178181      LOGS.insert(24, timestamp); //full timestamp 
    179       LOGS.insert(25, time); // time only       
     182      LOGS.insert(25, time); // time only 
     183      LOGS.insert(26, ""); //clear the log file entry 
    180184      if(!quiet){ emit MessageAvailable("replication"); } 
    181185    }else if( message.contains("failed replication") ){ 
     
    191195      LOGS.insert(24, timestamp); //full timestamp 
    192196      LOGS.insert(25, time); // time only       
     197      LOGS.insert(26, tr("Replication Error Log")+" <"+file+">" ); 
    193198      if(!quiet){ emit MessageAvailable("replication"); } 
    194199    } 
     
    313318    QString pool, state, timestamp; 
    314319    QStringList cDev, cStat, cMsg, cSummary; 
    315     //qDebug() << "-----zpool status------"; 
     320    qDebug() << "-----zpool status------\n" << zstat.join("\n"); 
    316321    bool newresilver = false; bool newscrub = false; bool newerror = false; 
    317322    for(int i=0; i<zstat.length(); i++){ 
  • src-qt4/life-preserver/life-preserver.pro

    r559e01f re0c368d  
    1111                LPContainers.h \ 
    1212                LPConfig.h \ 
    13                 LPWatcher.h 
     13                LPWatcher.h \ 
     14                LPMessages.h 
    1415                 
    1516SOURCES += main.cpp \ 
     
    1920                LPWizard.cpp \ 
    2021                LPConfig.cpp \ 
    21                 LPWatcher.cpp 
     22                LPWatcher.cpp \ 
     23                LPMessages.cpp 
    2224 
    2325RESOURCES += lPreserve.qrc 
     
    2527FORMS   = mainUI.ui \ 
    2628        LPWizard.ui \ 
    27         LPConfig.ui 
     29        LPConfig.ui \ 
     30        LPMessages.ui 
    2831 
    2932TARGET=life-preserver 
Note: See TracChangeset for help on using the changeset viewer.