~ubuntu-branches/ubuntu/saucy/acetoneiso/saucy

« back to all changes in this revision

Viewing changes to acetoneiso/sources/gmount.h

  • Committer: Bazaar Package Importer
  • Author(s): Nick Andrik
  • Date: 2010-01-19 20:16:15 UTC
  • Revision ID: james.westby@ubuntu.com-20100119201615-bdokwbbqhn1fo1iq
Tags: upstream-2.2.1
Import upstream version 2.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//This file is part of AcetoneISO. Copyright 2006,2007,2008,2009 Marco Di Antonio and Fabrizio Di Marco (acetoneiso@gmail.com)
 
2
//
 
3
//    AcetoneISO is free software: you can redistribute it and/or modify
 
4
//    it under the terms of the GNU General Public License as published by
 
5
//    the Free Software Foundation, either version 3 of the License, or
 
6
//    (at your option) any later version.
 
7
//
 
8
//    AcetoneISO is distributed in the hope that it will be useful,
 
9
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
//    GNU General Public License for more details.
 
12
//
 
13
//    You should have received a copy of the GNU General Public License
 
14
//    along with AcetoneISO.  If not, see <http://www.gnu.org/licenses/>.
 
15
void acetoneiso::gmount()
 
16
{
 
17
QMessageBox::warning(this, "AcetoneISO::Warning!",tr("NOTE: If you want to mount an image in a root folder like /media/cdrom, please launch AcetoneISO as root user. "));
 
18
QDir Home = QDir::home();
 
19
QFile file(Home.path() + "/.acetoneiso/acetoneiso.conf");
 
20
   file.open(QIODevice::ReadOnly);//lo apro in sola lettura
 
21
   QTextStream in(&file);
 
22
   QString stra = in.readLine();
 
23
   QString strb = in.readLine();
 
24
   QString strc = in.readLine();
 
25
 
 
26
   QFile Mtab("/etc/mtab");//dichiaro un file Mtab che sarebbe /etc/mtab
 
27
   Mtab.open(QIODevice::ReadOnly);//lo apro in sola lettura
 
28
   QString str1 = (Mtab.readAll());//leggo il contenuto del file mtab
 
29
QString isodamontare;
 
30
 
 
31
isodamontare = QFileDialog::getOpenFileName(this,tr("Open Image"), Home.path() , tr("Image Files (*.iso *.daa *.bin *.mdf *.ashdisc *.bwi *.b5i *.lcd *.img *.cdi *.cif *.p01 *.pdi *.nrg *.ncd *.pxi *.gi *.fcd *.vcd *.c2d)"));
 
32
 
 
33
if ( !isodamontare.isNull() ) {
 
34
//mi ricavo l'estensione dell'immagine
 
35
   QFileInfo getinfo(isodamontare);
 
36
   QString ext = getinfo.suffix();  // ext = "iso?mdf?xyz?"
 
37
        if (((ext != "iso") && (ext != "nrg")) && ((ext != "bin") && (ext != "img")) && (ext != "mdf")) {
 
38
           QMessageBox msgBox;
 
39
           msgBox.setText(tr("The image ") + isodamontare + tr(" can't be mounted. You must convert it to ISO or extract content to a folder.\nPlease choose what to do:") );
 
40
           QPushButton *connectButton = msgBox.addButton(tr(" Convert to ISO "), QMessageBox::ActionRole);
 
41
           QPushButton *connectButton2 = msgBox.addButton(tr(" Extract image to a folder "), QMessageBox::ActionRole);
 
42
//msgBox.setStandardButtons(QMessageBox::("ISO File") | QMessageBox::("CD/DVD"));
 
43
           msgBox.exec();
 
44
              if (msgBox.clickedButton() == connectButton) {
 
45
                 converter();
 
46
                 }
 
47
              else if (msgBox.clickedButton() == connectButton2) {
 
48
                 extract();
 
49
                 }
 
50
         }
 
51
         else {
 
52
            QString folder = QFileDialog::getExistingDirectory( this, tr("AcetoneISO::Select where to mount image"), Home.path() );
 
53
            if (!folder.isNull()) {
 
54
               folder.chop(1);//casini del qt...il chop serve per togliere l'ultimo slash (/) dal percorso altrimenti in mtab non troverà mai il percorso con lo slash finale..
 
55
               if(!str1.contains( folder ) ) {
 
56
                   FUse.start("fuseiso",QStringList()  << isodamontare << folder << "-o" << "nonempty"  );
 
57
                   if(strc.contains("kde", Qt::CaseInsensitive)) {
 
58
                      BRowser.startDetached("kfmclient",QStringList() << "exec" << folder );
 
59
                    }
 
60
                else {
 
61
                BRowser.startDetached("nautilus",QStringList() << folder );
 
62
                }
 
63
               }
 
64
              else
 
65
               QMessageBox::warning(this, "AcetoneISO::Warning!",tr("The folder ") + folder + tr(" can't be mounted"));
 
66
             }
 
67
           }
 
68
   }
 
69
   file.close();
 
70
   Mtab.close();
 
71
}
 
72
 
 
73
void acetoneiso::gumount()
 
74
{
 
75
QDir Home = QDir::home();
 
76
QFile Mtab("/etc/mtab");//dichiaro un file Mtab che sarebbe /etc/mtab
 
77
Mtab.open(QIODevice::ReadOnly);//lo apro in sola lettura
 
78
QString str1 = (Mtab.readAll());//leggo il contenuto del file mtab
 
79
QString folder = QFileDialog::getExistingDirectory( this, tr("AcetoneISO::Select folder to unmount"), Home.path() );
 
80
folder.chop(1);
 
81
if(str1.contains( folder ) ) {
 
82
   FUsermount.start("fusermount",QStringList() << "-u" << "-z" << folder );
 
83
 }
 
84
else {
 
85
   QMessageBox::warning(this, "AcetoneISO::Warning!",tr("The folder ") + folder + tr(" is not mounted!"));
 
86
 }
 
87
 Mtab.close();
 
88
}
 
89