Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 07, 2013
@beanpole135 beanpole135 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.
03aedf0
@beanpole135 beanpole135 Merge branch 'master' of github.com:pcbsd/pcbsd 84cc3f1
View
25 src-qt4/pc-mounttray/devCheck.cpp
@@ -4,8 +4,8 @@
DevCheck::DevCheck(){
//Initialize the lists of valid device types
- validDevs << "da" << "ad" << "mmcsd" << "cd" << "acd";
- validDevTypes << "USB" << "SATA" << "SD" << "CD9660" << "CD9660";
+ validDevs << "da" << "ad" << "mmcsd" << "cd" << "acd" << "md";
+ validDevTypes << "USB" << "SATA" << "SD" << "CD9660" << "CD9660" << "ISO";
for(int i=0; i<validDevs.length(); i++){
devFilter << validDevs[i]+"*";
}
@@ -29,7 +29,7 @@ DevCheck::~DevCheck(){
bool DevCheck::isValid(QString node){
bool ok = FALSE;
for(int i=0; i<validDevs.length(); i++){
- if(node.startsWith(validDevs[i])){
+ if(node.startsWith(validDevs[i]) && node!="mdctl"){
ok = TRUE;
break;
}
@@ -96,7 +96,7 @@ bool DevCheck::devInfo(QString dev, QString* type, QString* label, QString* file
//Double check for valid device types (just in case)
QString detType;
for(int i=0; i<validDevs.length(); i++){
- if(node.startsWith(validDevs[i])){
+ if(node.startsWith(validDevs[i]) && node != "mdctl"){
detType = validDevTypes[i];
break;
}
@@ -106,7 +106,7 @@ bool DevCheck::devInfo(QString dev, QString* type, QString* label, QString* file
if(detType.isEmpty() || !QFile::exists(fullDev) ){return FALSE;}
else{type->append(detType);}
bool isCD=FALSE;
- if(detType == "CD9660"){ isCD=TRUE; }
+ if(detType == "CD9660" || detType == "ISO"){ isCD=TRUE; }
//Read the Device Info using "file -s <device>"
QString cmd = "file -s "+fullDev;
@@ -153,9 +153,7 @@ bool DevCheck::devInfo(QString dev, QString* type, QString* label, QString* file
if(isCD){
if( !output.contains("ERROR:") ){
dlabel = output.section("'",-2).remove("'").simplified();
- //qDebug() << dlabel;
- //while( dlabel.endsWith(" ") || dlabel.endsWith("\n") ){ dlabel.chop(1); }
- //qDebug() << dlabel;
+ if(dlabel.contains("(")){ dlabel = dlabel.left(dlabel.indexOf("(")+1).trimmed();}
}
}else{
dlabel = output.section("label: \"",1,1).section("\"",0,0).simplified(); //device name
@@ -189,12 +187,19 @@ bool DevCheck::devInfo(QString dev, QString* type, QString* label, QString* file
else{
//Assign a device label
if(isCD){
- dlabel = "Optical_Disk";
+ if(detType == "ISO"){
+ dlabel = "ISO_File";
+ }else{
+ dlabel = "Optical_Disk";
+ }
}else{
dlabel = detType+"-Device"; //this is not a "detected" label
}
}
-
+ //make sure that a device label does not contain "(" or ")"
+ if(dlabel.contains("(")){ dlabel.remove("(").simplified(); }
+ if(dlabel.contains(")")){ dlabel.remove(")").simplified(); }
+ dlabel = dlabel.simplified();
//Now perform the final checks to see if it is a good device
bool good = FALSE;
if( isMounted ){}//Always ignore this device (local FreeBSD installation that is being used)
View
2  src-qt4/pc-mounttray/fsWatcher.cpp
@@ -54,7 +54,7 @@ QStringList FSWatcher::getFSmountpoints(){
//Now parse out the info
dfout[i].replace("\t"," ");
QString fs = dfout[i].section(" ",1,1,QString::SectionSkipEmpty).simplified();
- if(fs != "zfs"){ //ignore zfs filesystems (already taken care of)
+ if(fs != "zfs" && fs!="cd9660"){ //ignore zfs filesystems (already taken care of)
QString name = dfout[i].section(" ",6,6,QString::SectionSkipEmpty).simplified();
QString total = dfout[i].section(" ",2,2,QString::SectionSkipEmpty).simplified();
QString used = dfout[i].section(" ",3,3,QString::SectionSkipEmpty).simplified();
View
30 src-qt4/pc-mounttray/menuItem.cpp
@@ -46,9 +46,10 @@ MenuItem::MenuItem(QWidget* parent, QString newdevice, QString newlabel, QString
if(devType == "USB"){ devIcon->setPixmap(QPixmap(":icons/usb.png")); }
else if(devType == "SATA"){ devIcon->setPixmap(QPixmap(":icons/harddrive.png")); }
else if(devType == "SD"){ devIcon->setPixmap(QPixmap(":icons/sdcard.png")); }
- if(devType == "CD9660"){ devIcon->setPixmap(QPixmap(":icons/dvd.png")); }
+ else if(devType == "CD9660"){ devIcon->setPixmap(QPixmap(":icons/dvd.png")); }
+ else if(devType == "ISO"){devIcon->setPixmap(QPixmap(":icons/dvd.png")); }
//Start the automount procedure if necessary
- if(checkAutomount->isChecked()){
+ if(checkAutomount->isChecked() || devType=="ISO"){
QTimer::singleShot(500,this,SLOT( slotMountClicked() ));
}
//Update the Item based upon current device status
@@ -76,7 +77,8 @@ void MenuItem::updateItem(){
devIcon->setToolTip(device+"\n"+QString(tr("Mounted at %1")).arg(mountpoint));
pushMount->setText(tr("Eject"));
pushMount->setIcon(QIcon(":icons/eject.png"));
- checkAutomount->setVisible(TRUE);
+ if(devType != "ISO"){ checkAutomount->setVisible(TRUE); }
+ else{ checkAutomount->setVisible(FALSE); }
}else{
devIcon->setEnabled(FALSE); //Grey out the icon if not mounted
devIcon->setToolTip(device);
@@ -116,12 +118,6 @@ bool MenuItem::isMounted(){
}
}
return mounted;
- /*
- QString chk = pcbsd::Utils::runShellCommandSearch("mount",device);
- if(chk.isEmpty() ){ chk = pcbsd::Utils::runShellCommandSearch("mount",devLabel->text().replace(" ","-")); }
- if(chk.isEmpty() ){ return FALSE; }
- else{ return TRUE; }
- */
}
//Cleanup function
@@ -285,7 +281,11 @@ void MenuItem::unmountItem(){
}
ok = TRUE;
title = QString( tr("%1 has been successfully unmounted.") ).arg(devLabel->text());
- result = tr("It is now safe to remove the device");
+ if(devType == "ISO"){
+ result = tr("The ISO file has been completely detached from the system.");
+ }else{
+ result = tr("It is now safe to remove the device");
+ }
}else{
qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint;
qDebug() << " - Error message:" << output;
@@ -294,8 +294,16 @@ void MenuItem::unmountItem(){
}
//emit the proper signals
if(ok){
- emit itemUnmounted(device);
mountpoint.clear();
+ if(devType=="ISO" && device.section("/",-1).startsWith("md") ){
+ //Get the md number
+ QString num = device.section("/md",-1).simplified();
+ //also remove the MD device from the system using "mdconfig"
+ qDebug() << "Detaching Memory Disk:" << num;
+ QString cmd = "mdconfig -d -u "+num;
+ system(cmd.toUtf8());
+ }
+ emit itemUnmounted(device);
}
emit newMessage(title, result);
}
View
13 src-qt4/pc-mounttray/mountTray.cpp
@@ -33,6 +33,7 @@ void MountTray::programInit()
sysMenu->addAction( QIcon(":icons/refresh.png"),tr("Rescan Devices"), this, SLOT(slotRescan()) );
//Add the setting dialog option seperately
sysMenu->addSeparator();
+ sysMenu->addAction( QIcon(":icons/dvd.png"), tr("Load ISO File"), this, SLOT(slotOpenISO()) );
sysMenu->addAction( QIcon(":icons/config.png"), tr("Change Settings"), this, SLOT(slotOpenSettings()) );
//Add the Close button seperately
sysMenu->addSeparator();
@@ -356,6 +357,18 @@ void MountTray::slotOpenSettings(){
if(useDiskWatcher){ diskWatcher->start(diskTimerMaxMS); }
}
+void MountTray::slotOpenISO(){
+ //prompt for the user to select a file
+ QString file = QFileDialog::getOpenFileName( this, tr("Select ISO File"), QDir::homePath(), tr("ISO Files (*.iso)") );
+ if(file.isEmpty()){ return; } //cancelled
+ //check for available device node number /dev/md<number>
+ int num = 1;
+ while( QFile::exists("/dev/md"+QString::number(num)) ){ num++; }
+ //add it to the device tree (will automatically get picked up by the device detection method)
+ QString cmd = "mdconfig -a -f "+file+" -u "+QString::number(num);
+ system(cmd.toUtf8());
+}
+
void MountTray::slotSingleInstance()
{
trayIcon->show();
View
2  src-qt4/pc-mounttray/mountTray.h
@@ -13,6 +13,7 @@
#include <QDir>
#include <QFile>
#include <QTextStream>
+#include <QFileDialog>
#include "menuItem.h"
#include "devCheck.h"
@@ -52,6 +53,7 @@ private slots:
void slotRescan();
void slotOpenFSDialog();
void slotOpenSettings();
+ void slotOpenISO();
private:
DevCheck *DCheck;

No commit comments for this range

Something went wrong with that request. Please try again.