Changeset 03aedf0


Ignore:
Timestamp:
08/07/13 09:48:13 (17 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
84cc3f1
Parents:
de1ea77
Message:

Setup the pc-mounttray to allow for mounting a *.iso file via memory disk. This option is available under the "Load ISO File" option in the menu. Once the ISO file is unmounted, the memory disk is also detached from the system.

Location:
src-qt4/pc-mounttray
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-mounttray/devCheck.cpp

    r1620346 r03aedf0  
    55DevCheck::DevCheck(){ 
    66  //Initialize the lists of valid device types 
    7   validDevs << "da" << "ad" << "mmcsd" << "cd" << "acd"; 
    8   validDevTypes << "USB" << "SATA" << "SD" << "CD9660" << "CD9660"; 
     7  validDevs << "da" << "ad" << "mmcsd" << "cd" << "acd" << "md"; 
     8  validDevTypes << "USB" << "SATA" << "SD" << "CD9660" << "CD9660" << "ISO"; 
    99  for(int i=0; i<validDevs.length(); i++){ 
    1010    devFilter << validDevs[i]+"*"; 
     
    3030  bool ok = FALSE; 
    3131  for(int i=0; i<validDevs.length(); i++){ 
    32     if(node.startsWith(validDevs[i])){  
     32    if(node.startsWith(validDevs[i]) && node!="mdctl"){  
    3333        ok = TRUE;  
    3434        break;  
     
    9797  QString detType; 
    9898  for(int i=0; i<validDevs.length(); i++){ 
    99     if(node.startsWith(validDevs[i])){  
     99    if(node.startsWith(validDevs[i]) && node != "mdctl"){  
    100100        detType = validDevTypes[i];  
    101101        break;  
     
    107107  else{type->append(detType);} 
    108108  bool isCD=FALSE; 
    109   if(detType == "CD9660"){ isCD=TRUE; } 
     109  if(detType == "CD9660" || detType == "ISO"){ isCD=TRUE; } 
    110110   
    111111  //Read the Device Info using "file -s <device>" 
     
    154154    if( !output.contains("ERROR:") ){ 
    155155      dlabel = output.section("'",-2).remove("'").simplified(); 
    156       //qDebug() << dlabel; 
    157       //while( dlabel.endsWith(" ") || dlabel.endsWith("\n") ){ dlabel.chop(1); } 
    158       //qDebug() << dlabel; 
     156      if(dlabel.contains("(")){ dlabel = dlabel.left(dlabel.indexOf("(")+1).trimmed();} 
    159157    } 
    160158  }else{ 
     
    190188    //Assign a device label 
    191189    if(isCD){ 
    192       dlabel = "Optical_Disk"; 
     190      if(detType == "ISO"){ 
     191        dlabel = "ISO_File"; 
     192      }else{ 
     193        dlabel = "Optical_Disk"; 
     194      } 
    193195    }else{ 
    194196      dlabel = detType+"-Device"; //this is not a "detected" label 
    195197    } 
    196198  } 
    197    
     199  //make sure that a device label does not contain "(" or ")" 
     200  if(dlabel.contains("(")){ dlabel.remove("(").simplified(); } 
     201  if(dlabel.contains(")")){ dlabel.remove(")").simplified(); } 
     202  dlabel = dlabel.simplified(); 
    198203  //Now perform the final checks to see if it is a good device 
    199204  bool good = FALSE; 
  • src-qt4/pc-mounttray/fsWatcher.cpp

    r6edfd8a r03aedf0  
    5555      dfout[i].replace("\t"," "); 
    5656      QString fs = dfout[i].section("  ",1,1,QString::SectionSkipEmpty).simplified(); 
    57       if(fs != "zfs"){  //ignore zfs filesystems (already taken care of) 
     57      if(fs != "zfs" && fs!="cd9660"){  //ignore zfs filesystems (already taken care of) 
    5858        QString name = dfout[i].section("  ",6,6,QString::SectionSkipEmpty).simplified(); 
    5959        QString total = dfout[i].section("  ",2,2,QString::SectionSkipEmpty).simplified(); 
  • src-qt4/pc-mounttray/menuItem.cpp

    r940aaf0 r03aedf0  
    4747  else if(devType == "SATA"){ devIcon->setPixmap(QPixmap(":icons/harddrive.png")); } 
    4848  else if(devType == "SD"){ devIcon->setPixmap(QPixmap(":icons/sdcard.png")); } 
    49   if(devType == "CD9660"){ devIcon->setPixmap(QPixmap(":icons/dvd.png")); } 
     49  else if(devType == "CD9660"){ devIcon->setPixmap(QPixmap(":icons/dvd.png")); } 
     50  else if(devType == "ISO"){devIcon->setPixmap(QPixmap(":icons/dvd.png")); } 
    5051  //Start the automount procedure if necessary 
    51   if(checkAutomount->isChecked()){ 
     52  if(checkAutomount->isChecked() || devType=="ISO"){ 
    5253    QTimer::singleShot(500,this,SLOT( slotMountClicked() )); 
    5354  } 
     
    7778      pushMount->setText(tr("Eject")); 
    7879      pushMount->setIcon(QIcon(":icons/eject.png")); 
    79       checkAutomount->setVisible(TRUE); 
     80      if(devType != "ISO"){ checkAutomount->setVisible(TRUE); } 
     81      else{ checkAutomount->setVisible(FALSE); } 
    8082    }else{         
    8183      devIcon->setEnabled(FALSE); //Grey out the icon if not mounted 
     
    117119  } 
    118120  return mounted; 
    119   /* 
    120   QString chk = pcbsd::Utils::runShellCommandSearch("mount",device);   
    121   if(chk.isEmpty() ){ chk = pcbsd::Utils::runShellCommandSearch("mount",devLabel->text().replace(" ","-")); }  
    122   if(chk.isEmpty() ){ return FALSE; } 
    123   else{ return TRUE; } 
    124   */ 
    125121} 
    126122 
     
    286282    ok = TRUE; 
    287283    title = QString( tr("%1 has been successfully unmounted.") ).arg(devLabel->text()); 
    288     result = tr("It is now safe to remove the device"); 
     284    if(devType == "ISO"){ 
     285      result = tr("The ISO file has been completely detached from the system."); 
     286    }else{ 
     287      result = tr("It is now safe to remove the device"); 
     288    } 
    289289  }else{ 
    290290    qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint; 
     
    295295  //emit the proper signals 
    296296  if(ok){ 
     297    mountpoint.clear(); 
     298    if(devType=="ISO" && device.section("/",-1).startsWith("md") ){ 
     299      //Get the md number 
     300      QString num = device.section("/md",-1).simplified(); 
     301      //also remove the MD device from the system using "mdconfig" 
     302      qDebug() << "Detaching Memory Disk:" << num; 
     303      QString cmd = "mdconfig -d -u "+num; 
     304      system(cmd.toUtf8()); 
     305    } 
    297306    emit itemUnmounted(device); 
    298     mountpoint.clear(); 
    299307  } 
    300308  emit newMessage(title, result); 
  • src-qt4/pc-mounttray/mountTray.cpp

    rd5ff236 r03aedf0  
    3434    //Add the setting dialog option seperately 
    3535    sysMenu->addSeparator(); 
     36    sysMenu->addAction( QIcon(":icons/dvd.png"), tr("Load ISO File"), this, SLOT(slotOpenISO()) ); 
    3637    sysMenu->addAction( QIcon(":icons/config.png"), tr("Change Settings"), this, SLOT(slotOpenSettings()) ); 
    3738    //Add the Close button seperately 
     
    357358} 
    358359 
     360void MountTray::slotOpenISO(){ 
     361  //prompt for the user to select a file 
     362  QString file = QFileDialog::getOpenFileName( this, tr("Select ISO File"), QDir::homePath(), tr("ISO Files (*.iso)") ); 
     363  if(file.isEmpty()){ return; } //cancelled 
     364  //check for available device node number /dev/md<number> 
     365  int num = 1; 
     366  while( QFile::exists("/dev/md"+QString::number(num)) ){ num++; } 
     367  //add it to the device tree (will automatically get picked up by the device detection method) 
     368  QString cmd = "mdconfig -a -f "+file+" -u "+QString::number(num); 
     369  system(cmd.toUtf8()); 
     370} 
     371 
    359372void MountTray::slotSingleInstance() 
    360373{ 
  • src-qt4/pc-mounttray/mountTray.h

    rfd5dfb8 r03aedf0  
    1414#include <QFile> 
    1515#include <QTextStream> 
     16#include <QFileDialog> 
    1617 
    1718#include "menuItem.h" 
     
    5354  void slotOpenFSDialog(); 
    5455  void slotOpenSettings(); 
     56  void slotOpenISO(); 
    5557   
    5658private: 
Note: See TracChangeset for help on using the changeset viewer.