예제 #1
0
파일: LPMain.cpp 프로젝트: cthunter01/pcbsd
// -----------------------------------------------
//   MENU SLOTS
// -----------------------------------------------
// ==== File Menu ====
void LPMain::menuAddPool(QAction *act){
  QString dataset = act->text();
  qDebug() << "Start Wizard for new managing pool:" << dataset;
  LPWizard wiz(this);
  wiz.setDataset(dataset);
  wiz.exec();
  //See if the wizard was cancelled or not
  if(!wiz.cancelled){
    ui->statusbar->showMessage(QString(tr("Enabling dataset management: %1")).arg(dataset),0);
    //run the proper commands to get the dataset enabled
    qDebug() << "Setup Snapshots:" << dataset << " Frequency:" << wiz.localTime;
    if( LPBackend::setupDataset(dataset, wiz.localTime, wiz.totalSnapshots) ){
      /*if(wiz.enableReplication){
      	 qDebug() << "Setting up replication:" << dataset << " Frequency:" << wiz.remoteTime;
	 LPBackend::setupReplication(dataset, wiz.remoteHost, wiz.remoteUser, wiz.remotePort, wiz.remoteDataset, wiz.remoteTime);     
	 QMessageBox::information(this,tr("Reminder"),tr("Don't forget to save your SSH key to a USB stick so that you can restore your system from the remote host later!!"));
      }*/
      if(wiz.enableScrub){
      qDebug() << "Settings up scrub:" << dataset << "Frequency:" << wiz.scrubSchedule << "Day:" << wiz.scrubDay << "Time:" << wiz.scrubTime;
      LPBackend::setupScrub(dataset, wiz.scrubTime, wiz.scrubDay, wiz.scrubSchedule);
      }
    }
    ui->statusbar->clearMessage();
    //Now update the list of pools
    updatePoolList();
    if(wiz.openAdvancedConfig){
      QTimer::singleShot(100,this, SLOT(openConfigGUI()) );
    }
  }	
}
예제 #2
0
파일: LPMain.cpp 프로젝트: cthunter01/pcbsd
void LPMain::menuRemovePool(QAction *act){
  QString ds = act->text();
  qDebug() << "Remove Pool:" << ds;
  if(!ds.isEmpty()){
    //Verify the removal of the dataset
    if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify Dataset Backup Removal"),tr("Are you sure that you wish to cancel automated snapshots and/or replication of the following dataset?")+"\n\n"+ds,QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){	    
      //verify the removal of all the snapshots for this dataset
      QStringList snapComments;
      QStringList snaps = LPBackend::listLPSnapshots(ds, snapComments);
      if(!snaps.isEmpty()){
        if( QMessageBox::Yes == QMessageBox::question(this,tr("Verify Snapshot Deletion"),tr("Do you wish to remove the local snapshots for this dataset?")+"\n"+tr("WARNING: This is a permanant change that cannot be reversed"),QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
	  //Remove all the snapshots
	  ui->statusbar->showMessage(QString(tr("%1: Removing snapshots")).arg(ds),0);
	  showWaitBox(tr("Removing snapshots"));
	  for(int i=0; i<snaps.length(); i++){
	    LPBackend::removeSnapshot(ds,snaps[i]);
	  }
	  ui->statusbar->clearMessage();
        }
      }
      //Remove the dataset from life-preserver management
      if(LPBackend::listReplicationTargets().contains(ds)){ 
        ui->statusbar->showMessage(QString(tr("%1: Disabling Replication")).arg(ds),0);
	showWaitBox(tr("Disabling Replication"));
	//Need the replication host(s)
	QList<LPRepHost> rhosts = LPBackend::replicationInfo(ds);
	for(int i=0; i<rhosts.length(); i++){
	  LPBackend::removeReplication(ds,rhosts[i].host()); 
	}
	ui->statusbar->clearMessage();      
      }
      if(LPBackend::listScrubs().contains(ds)){
        ui->statusbar->showMessage(QString(tr("%1: Disabling Scrubs")).arg(ds),0);
	showWaitBox(tr("Disabling Scrubs"));
	LPBackend::removeScrub(ds);
	ui->statusbar->clearMessage();
      }
      ui->statusbar->showMessage(QString(tr("%1: Disabling Life-Preserver Management")).arg(ds),0);
      showWaitBox(tr("Removing Life Preserver Schedules"));
      LPBackend::removeDataset(ds);
      ui->statusbar->clearMessage();
      updatePoolList();
      hideWaitBox();
    }
  } //end check for empty ds

}
예제 #3
0
파일: LPMain.cpp 프로젝트: Jheengut/pcbsd
LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
  ui->setupUi(this); //load the Qt-designer UI file
  //Initialize the auto-refresh timer
  timer = new QTimer(this);
	timer->setSingleShot(true);
	timer->setInterval(60000); // 1 minute timer
	connect(timer, SIGNAL(timeout()), this, SLOT(updateTabs()) );
  //Initialize the system watcher
  watcher = new QFileSystemWatcher(this);
    //Make sure the lpreserver log directory exists and watch it
    if(!QFile::exists("/var/log/lpreserver")){
      qDebug() << "Creating the lpreserver log directory (/var/log/lpreserver)";
      QDir dir;
      dir.mkpath("/var/log/lpreserver");
    }
    watcher->addPath("/var/log/lpreserver/");
  //Initialize the waitbox pointer
  waitBox = 0;
  //Initialize the classic dialog pointer
  classicDLG = 0;
  //Create the basic/advanced view options
  viewBasic = new QRadioButton(tr("Basic"), ui->menuView);
	QWidgetAction *WABasic = new QWidgetAction(this); WABasic->setDefaultWidget(viewBasic);
	ui->menuView->addAction(WABasic);
  viewAdvanced = new QRadioButton(tr("Advanced"), ui->menuView);
	QWidgetAction *WAAdv = new QWidgetAction(this); WAAdv->setDefaultWidget(viewAdvanced);
	ui->menuView->addAction(WAAdv);
  connect(viewBasic, SIGNAL(toggled(bool)), this, SLOT(viewChanged()) );
  //Now set the default view type
  settings = new QSettings(QSettings::UserScope, "PC-BSD", "Life-Preserver-GUI", this);
  bool basicMode = settings->value("viewmode", true).toBool(); //basic by default
  if(basicMode){ viewBasic->setChecked(true); } //will automatically call the "viewChanged" function
  else{ viewAdvanced->setChecked(true); } //will automatically call the "viewChanged" function
  //Create the filesystem model and tie it to the treewidget
  fsModel = new QFileSystemModel(this);
	fsModel->setReadOnly(true);
	ui->treeView->setModel(fsModel);
  //Connect the UI to all the functions
  connect(ui->tool_refresh, SIGNAL(clicked()), this, SLOT(updatePoolList()) );
  connect(ui->combo_pools, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTabs()) );
  connect(ui->combo_datasets, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDataset()) );
  connect(ui->slider_snapshots, SIGNAL(valueChanged(int)), this, SLOT(updateSnapshot()) );
  connect(ui->push_prevsnap, SIGNAL(clicked()), this, SLOT(prevSnapshot()) );
  connect(ui->push_nextsnap, SIGNAL(clicked()), this, SLOT(nextSnapshot()) );
  connect(ui->check_hidden, SIGNAL(stateChanged(int)), this, SLOT(setFileVisibility()) );
  connect(ui->push_restore, SIGNAL(clicked()), this, SLOT(restoreFiles()) );
  connect(ui->push_configure, SIGNAL(clicked()), this, SLOT(openConfigGUI()) );
  //Connect the Menu buttons
  connect(ui->menuManage_Pool, SIGNAL(triggered(QAction*)), this, SLOT(menuAddPool(QAction*)) );
  connect(ui->menuUnmanage_Pool, SIGNAL(triggered(QAction*)), this, SLOT(menuRemovePool(QAction*)) );
  connect(ui->action_SaveKeyToUSB, SIGNAL(triggered()), this, SLOT(menuSaveSSHKey()) );
  connect(ui->actionClose_Window, SIGNAL(triggered()), this, SLOT(menuCloseWindow()) );
  connect(ui->menuCompress_Home_Dir, SIGNAL(triggered(QAction*)), this, SLOT(menuCompressHomeDir(QAction*)) );
  connect(ui->actionExtract_Home_Dir, SIGNAL(triggered()), this, SLOT(menuExtractHomeDir()) );
  connect(ui->actionAdd_Disk, SIGNAL(triggered()), this, SLOT(menuAddDisk()) );
  connect(ui->menuRemove_Disk, SIGNAL(triggered(QAction*)), this, SLOT(menuRemoveDisk(QAction*)) );
  connect(ui->menuSet_Disk_Offline, SIGNAL(triggered(QAction*)), this, SLOT(menuOfflineDisk(QAction*)) );
  connect(ui->menuSet_Disk_Online, SIGNAL(triggered(QAction*)), this, SLOT(menuOnlineDisk(QAction*)) );
  connect(ui->action_startScrub, SIGNAL(triggered()), this, SLOT(menuStartScrub()) );
  connect(ui->action_stopScrub, SIGNAL(triggered()), this, SLOT(menuStopScrub()) );
  connect(ui->action_newSnapshot, SIGNAL(triggered()), this, SLOT(menuNewSnapshot()) );
  connect(ui->menuDelete_Snapshot, SIGNAL(triggered(QAction*)), this, SLOT(menuRemoveSnapshot(QAction*)) );
  //Update the interface
  QTimer::singleShot(0,this,SLOT(updatePoolList()) );
  
  //Make sure the status tab is shown initially
  ui->tabWidget->setCurrentWidget(ui->tab_status);
  //Now connect the watcher to the update slot
  connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(autoRefresh()) );
}