author | llornkcor <llornkcor> | 2002-04-25 18:34:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-25 18:34:01 (UTC) |
commit | c06667cd62b945a05edce621aab34358ee0e964f (patch) (unidiff) | |
tree | 4de8f106fa0cc376e211d213d8f674b4ea0a3353 | |
parent | a4e419f939f4f4237b56e117edaa7dc0d93dd396 (diff) | |
download | opie-c06667cd62b945a05edce621aab34358ee0e964f.zip opie-c06667cd62b945a05edce621aab34358ee0e964f.tar.gz opie-c06667cd62b945a05edce621aab34358ee0e964f.tar.bz2 |
hook up fsck
-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 131 | ||||
-rw-r--r-- | noncore/tools/formatter/formatter.h | 4 |
2 files changed, 108 insertions, 27 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index 0dd42c8..983459c 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -1,488 +1,569 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** formatter.cpp | 2 | ** formatter.cpp |
3 | ** | 3 | ** |
4 | ** Copyright: Thu Apr 11 11:01:13 2002 | 4 | ** Copyright: Thu Apr 11 11:01:13 2002 |
5 | ** by: L. J. Potter | 5 | ** by: L. J. Potter |
6 | ** | 6 | ** |
7 | ****************************************************************************/ | 7 | ****************************************************************************/ |
8 | 8 | ||
9 | #include "formatter.h" | 9 | #include "formatter.h" |
10 | #include "inputDialog.h" | 10 | #include "inputDialog.h" |
11 | #include "output.h" | 11 | #include "output.h" |
12 | 12 | ||
13 | #include <qpe/qpemenubar.h> | 13 | #include <qpe/qpemenubar.h> |
14 | #include <qpe/qpetoolbar.h> | 14 | #include <qpe/qpetoolbar.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
18 | #include <qpe/mimetype.h> | 18 | #include <qpe/mimetype.h> |
19 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
20 | #include <qpe/storage.h> | 20 | #include <qpe/storage.h> |
21 | 21 | ||
22 | #include <qmultilineedit.h> | 22 | #include <qmultilineedit.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qlist.h> | 24 | #include <qlist.h> |
25 | #include <qstringlist.h> | 25 | #include <qstringlist.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | 28 | ||
29 | #include <qtstream.h> | 29 | #include <qtstream.h> |
30 | 30 | ||
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qpopupmenu.h> | 32 | #include <qpopupmenu.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qwidget.h> | 40 | #include <qwidget.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qvariant.h> | 42 | #include <qvariant.h> |
43 | 43 | ||
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <sys/vfs.h> | 47 | #include <sys/vfs.h> |
48 | #include <mntent.h> | 48 | #include <mntent.h> |
49 | #include <string.h> | 49 | #include <string.h> |
50 | #include <errno.h> | 50 | #include <errno.h> |
51 | 51 | ||
52 | #define BLANK ' ' | 52 | #define BLANK ' ' |
53 | #define DELIMITER '#' | 53 | #define DELIMITER '#' |
54 | 54 | ||
55 | /* | 55 | /* |
56 | Blah blah blah blah */ | 56 | Blah blah blah blah */ |
57 | FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) | 57 | FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) |
58 | : QMainWindow( parent, name, fl ) | 58 | : QMainWindow( parent, name, fl ) |
59 | // : QDialog( parent, name, modal, fl ) | 59 | // : QDialog( parent, name, modal, fl ) |
60 | { | 60 | { |
61 | if ( !name ) | 61 | if ( !name ) |
62 | setName( "FormatterApp" ); | 62 | setName( "FormatterApp" ); |
63 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 63 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
64 | 64 | ||
65 | setCaption( tr( "Formatter" ) ); | 65 | setCaption( tr( "Formatter" ) ); |
66 | FormatterAppLayout = new QGridLayout( this ); | 66 | FormatterAppLayout = new QGridLayout( this ); |
67 | FormatterAppLayout->setSpacing( 2); | 67 | FormatterAppLayout->setSpacing( 2); |
68 | FormatterAppLayout->setMargin( 2 ); | 68 | FormatterAppLayout->setMargin( 2 ); |
69 | 69 | ||
70 | TabWidget = new QTabWidget( this, "TabWidget" ); | 70 | TabWidget = new QTabWidget( this, "TabWidget" ); |
71 | 71 | ||
72 | tab = new QWidget( TabWidget, "tab" ); | 72 | tab = new QWidget( TabWidget, "tab" ); |
73 | tabLayout = new QGridLayout( tab ); | 73 | tabLayout = new QGridLayout( tab ); |
74 | tabLayout->setSpacing( 6); | 74 | tabLayout->setSpacing( 6); |
75 | tabLayout->setMargin( 11); | 75 | tabLayout->setMargin( 11); |
76 | 76 | ||
77 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); | 77 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); |
78 | 78 | ||
79 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1 ); | 79 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1 ); |
80 | 80 | ||
81 | TextLabel4 = new QLabel( tab, "TextLabel4" ); | 81 | TextLabel4 = new QLabel( tab, "TextLabel4" ); |
82 | TextLabel4->setText( tr( "Storage Type" ) ); | 82 | TextLabel4->setText( tr( "Storage Type" ) ); |
83 | 83 | ||
84 | tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1 ); | 84 | tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1 ); |
85 | 85 | ||
86 | TextLabel2 = new QLabel( tab, "TextLabel2" ); | 86 | TextLabel2 = new QLabel( tab, "TextLabel2" ); |
87 | TextLabel2->setText( tr( "File Systems" ) ); | 87 | TextLabel2->setText( tr( "File Systems" ) ); |
88 | 88 | ||
89 | tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1 ); | 89 | tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1 ); |
90 | 90 | ||
91 | fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); | 91 | fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); |
92 | 92 | ||
93 | tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1 ); | 93 | tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1 ); |
94 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 94 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
95 | tabLayout->addItem( spacer, 2, 1 ); | 95 | tabLayout->addItem( spacer, 2, 1 ); |
96 | 96 | ||
97 | formatPushButton = new QPushButton( tab, "formatPushButton" ); | 97 | formatPushButton = new QPushButton( tab, "formatPushButton" ); |
98 | formatPushButton->setText( tr( "Format" ) ); | 98 | formatPushButton->setText( tr( "Format" ) ); |
99 | 99 | ||
100 | tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1 ); | 100 | tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1 ); |
101 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 101 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
102 | tabLayout->addItem( spacer_2, 5, 0 ); | 102 | tabLayout->addItem( spacer_2, 5, 0 ); |
103 | TabWidget->insertTab( tab, tr( "Main" ) ); | 103 | TabWidget->insertTab( tab, tr( "Main" ) ); |
104 | 104 | ||
105 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 105 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
106 | tabLayout_2 = new QGridLayout( tab_2 ); | 106 | tabLayout_2 = new QGridLayout( tab_2 ); |
107 | tabLayout_2->setSpacing( 6); | 107 | tabLayout_2->setSpacing( 6); |
108 | tabLayout_2->setMargin( 11); | 108 | tabLayout_2->setMargin( 11); |
109 | 109 | ||
110 | mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); | 110 | mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); |
111 | 111 | ||
112 | tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1 ); | 112 | tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1 ); |
113 | 113 | ||
114 | deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); | 114 | deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); |
115 | 115 | ||
116 | tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1 ); | 116 | tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1 ); |
117 | 117 | ||
118 | TextLabel5 = new QLabel( tab_2, "TextLabel5" ); | 118 | TextLabel5 = new QLabel( tab_2, "TextLabel5" ); |
119 | TextLabel5->setText( tr( "CAUTION:\n" | 119 | TextLabel5->setText( tr( "CAUTION:\n" |
120 | "Changing parameters on this \n" | 120 | "Changing parameters on this \n" |
121 | "page may cause your system \n" | 121 | "page may cause your system \n" |
122 | "to stop functioning properly!!" ) );//idiot message | 122 | "to stop functioning properly!!" ) );//idiot message |
123 | 123 | ||
124 | tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1 ); | 124 | tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1 ); |
125 | 125 | ||
126 | editPushButton = new QPushButton( tab_2, "editPushButton" ); | 126 | editPushButton = new QPushButton( tab_2, "editPushButton" ); |
127 | editPushButton->setText( tr( "Edit fstab" ) ); | 127 | editPushButton->setText( tr( "Edit fstab" ) ); |
128 | 128 | ||
129 | tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); | 129 | tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); |
130 | 130 | ||
131 | fsckButton = new QPushButton( tab_2, "fsckPushButton" ); | 131 | fsckButton = new QPushButton( tab_2, "fsckPushButton" ); |
132 | fsckButton->setText( tr( "Check Disk" ) ); | 132 | fsckButton->setText( tr( "Check Disk" ) ); |
133 | 133 | ||
134 | tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1 ); | 134 | tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1 ); |
135 | 135 | ||
136 | TextLabel3 = new QLabel( tab_2, "TextLabel3" ); | 136 | TextLabel3 = new QLabel( tab_2, "TextLabel3" ); |
137 | TextLabel3->setText( tr( "Device" ) ); | 137 | TextLabel3->setText( tr( "Device" ) ); |
138 | 138 | ||
139 | tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); | 139 | tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); |
140 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 140 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
141 | tabLayout_2->addItem( spacer_3, 5, 0 ); | 141 | tabLayout_2->addItem( spacer_3, 5, 0 ); |
142 | 142 | ||
143 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); | 143 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); |
144 | TextLabel1->setText( tr( "Mount Point" ) ); | 144 | TextLabel1->setText( tr( "Mount Point" ) ); |
145 | 145 | ||
146 | tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); | 146 | tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); |
147 | QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 147 | QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
148 | tabLayout_2->addItem( spacer_4, 2, 1 ); | 148 | tabLayout_2->addItem( spacer_4, 2, 1 ); |
149 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); | 149 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); |
150 | 150 | ||
151 | FormatterAppLayout->addWidget( TabWidget, 0, 0 ); | 151 | FormatterAppLayout->addWidget( TabWidget, 0, 0 ); |
152 | 152 | ||
153 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); | 153 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); |
154 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); | 154 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); |
155 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); | 155 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); |
156 | 156 | ||
157 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); | 157 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); |
158 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); | 158 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); |
159 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); | 159 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); |
160 | 160 | ||
161 | 161 | ||
162 | fillCombos(); | 162 | fillCombos(); |
163 | } | 163 | } |
164 | 164 | ||
165 | /* | 165 | /* |
166 | * Destroys the object and frees any allocated resources | 166 | * Destroys the object and frees any allocated resources |
167 | frickin no duh?!? | 167 | frickin no duh?!? |
168 | */ | 168 | */ |
169 | FormatterApp::~FormatterApp() | 169 | FormatterApp::~FormatterApp() |
170 | { | 170 | { |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | void FormatterApp::doFormat() { | 174 | void FormatterApp::doFormat() { |
175 | int err=0; | 175 | int err=0; |
176 | Output *outDlg; | 176 | Output *outDlg; |
177 | QString umountS, remountS; | 177 | QString umountS, remountS; |
178 | QString text = storageComboBox->currentText(); | 178 | QString text = storageComboBox->currentText(); |
179 | QString currentText = storageComboBox->currentText(); | 179 | QString currentText = storageComboBox->currentText(); |
180 | QString cmd; | 180 | QString cmd; |
181 | QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 181 | QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); |
182 | QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); | 182 | QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); |
183 | QString fs = fileSystemsCombo->currentText(); | 183 | QString fs = fileSystemsCombo->currentText(); |
184 | 184 | ||
185 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap | 185 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap |
186 | #else | 186 | #else |
187 | currentText = diskDevice = "/dev/fd0"; | 187 | currentText = diskDevice = "/dev/fd0"; |
188 | umountS = "umount -v /floppy 2>&1"; | 188 | umountS = "umount -v /floppy 2>&1"; |
189 | remountS = "mount -v /floppy 2>&1"; | 189 | remountS = "mount -v /floppy 2>&1"; |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | if( currentText.find("CF",0,TRUE) != -1) { | 192 | if( currentText.find("CF",0,TRUE) != -1) { |
193 | umountS = "umount "; | 193 | umountS = "umount "; |
194 | remountS = "mount "; | 194 | remountS = "mount "; |
195 | 195 | ||
196 | // umountS = "/sbin/cardctl eject"; | 196 | // umountS = "/sbin/cardctl eject"; |
197 | // remountS = "/sbin/cardctl insert"; | 197 | // remountS = "/sbin/cardctl insert"; |
198 | } | 198 | } |
199 | if( currentText.find("SD",0,TRUE) != -1) { | 199 | if( currentText.find("SD",0,TRUE) != -1) { |
200 | umountS = "umount "; | 200 | umountS = "umount "; |
201 | remountS = "mount "; | 201 | remountS = "mount "; |
202 | // umountS = "/etc/sdcontrol compeject"; | 202 | // umountS = "/etc/sdcontrol compeject"; |
203 | // remountS = "/etc/sdcontrol insert"; | 203 | // remountS = "/etc/sdcontrol insert"; |
204 | } | 204 | } |
205 | 205 | ||
206 | switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") +diskName+" "+ currentText + | 206 | switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") +diskName+" "+ currentText + |
207 | tr("\nwith ") + fs + tr(" filesystem?!?\nYou will loose all data!!"),tr("Yes"),tr("No"),0,1,1) ) { | 207 | tr("\nwith ") + fs + tr(" filesystem?!?\nYou will loose all data!!"),tr("Yes"),tr("No"),0,1,1) ) { |
208 | case 0: { | 208 | case 0: { |
209 | if(fs == "vfat") | 209 | if(fs == "vfat") |
210 | cmd = "mkdosfs -v " + diskDevice+" 2>&1"; | 210 | cmd = "mkdosfs -v " + diskDevice+" 2>&1"; |
211 | else if(fs == "ext2") | 211 | else if(fs == "ext2") |
212 | cmd = "mke2fs -v " + diskDevice+" 2>&1"; | 212 | cmd = "mke2fs -v " + diskDevice+" 2>&1"; |
213 | else { | 213 | else { |
214 | QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); | 214 | QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); |
215 | break; | 215 | break; |
216 | } | 216 | } |
217 | // cmd = "ls -l"; | 217 | // cmd = "ls -l"; |
218 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | 218 | outDlg = new Output(this, tr("Formatter Output"),FALSE); |
219 | outDlg->showMaximized(); | 219 | outDlg->showMaximized(); |
220 | outDlg->show(); | 220 | outDlg->show(); |
221 | qApp->processEvents(); | 221 | qApp->processEvents(); |
222 | FILE *fp; | 222 | FILE *fp; |
223 | char line[130]; | 223 | char line[130]; |
224 | outDlg->OutputEdit->append( tr("Trying to umount.") + currentText ); | 224 | outDlg->OutputEdit->append( tr("Trying to umount.") + currentText ); |
225 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 225 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
226 | 226 | ||
227 | sleep(1); | 227 | sleep(1); |
228 | qDebug("Command is "+umountS); | 228 | qDebug("Command is "+umountS); |
229 | fp = popen( (const char *) umountS, "r"); | 229 | fp = popen( (const char *) umountS, "r"); |
230 | qDebug("%d", fp); | 230 | qDebug("%d", fp); |
231 | if ( !fp ) { | 231 | if ( !fp ) { |
232 | qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); | 232 | qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); |
233 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); | 233 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); |
234 | pclose(fp); | 234 | pclose(fp); |
235 | return; | 235 | return; |
236 | } else { | 236 | } else { |
237 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); | 237 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); |
238 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 238 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
239 | while ( fgets( line, sizeof line, fp)) { | 239 | while ( fgets( line, sizeof line, fp)) { |
240 | if( ((QString)line).find("busy",0,TRUE) != -1) { | 240 | if( ((QString)line).find("busy",0,TRUE) != -1) { |
241 | qDebug("Could not find '" + umountS); | 241 | qDebug("Could not find '" + umountS); |
242 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); | 242 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); |
243 | pclose(fp); | 243 | pclose(fp); |
244 | return; | 244 | return; |
245 | } else { | 245 | } else { |
246 | QString lineStr = line; | 246 | QString lineStr = line; |
247 | lineStr=lineStr.left(lineStr.length()-1); | 247 | lineStr=lineStr.left(lineStr.length()-1); |
248 | outDlg->OutputEdit->append(lineStr); | 248 | outDlg->OutputEdit->append(lineStr); |
249 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 249 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | } | 252 | } |
253 | pclose(fp); | 253 | pclose(fp); |
254 | 254 | ||
255 | qDebug("Command would be: "+cmd); | 255 | qDebug("Command would be: "+cmd); |
256 | outDlg->OutputEdit->append( tr("Trying to format.") ); | 256 | outDlg->OutputEdit->append( tr("Trying to format.") ); |
257 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 257 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
258 | 258 | ||
259 | fp = popen( (const char *) cmd, "r"); | 259 | fp = popen( (const char *) cmd, "r"); |
260 | while ( fgets( line, sizeof line, fp)) { | 260 | while ( fgets( line, sizeof line, fp)) { |
261 | if( ((QString)line).find("No such device",0,TRUE) != -1) { | 261 | if( ((QString)line).find("No such device",0,TRUE) != -1) { |
262 | qDebug("No such device '" + umountS); | 262 | qDebug("No such device '" + umountS); |
263 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); | 263 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); |
264 | pclose(fp); | 264 | pclose(fp); |
265 | // outDlg->OutputEdit->append("No such device"); | 265 | // outDlg->OutputEdit->append("No such device"); |
266 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 266 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
267 | return; | 267 | return; |
268 | } else { | 268 | } else { |
269 | QString lineStr = line; | 269 | QString lineStr = line; |
270 | lineStr=lineStr.left(lineStr.length()-1); | 270 | lineStr=lineStr.left(lineStr.length()-1); |
271 | outDlg->OutputEdit->append(lineStr); | 271 | outDlg->OutputEdit->append(lineStr); |
272 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 272 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); | 275 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); |
276 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 276 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
277 | pclose(fp); | 277 | pclose(fp); |
278 | 278 | ||
279 | outDlg->OutputEdit->append( tr("Trying to mount.") + currentText ); | 279 | outDlg->OutputEdit->append( tr("Trying to mount.") + currentText ); |
280 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 280 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
281 | fp = popen( (const char *) remountS, "r"); | 281 | fp = popen( (const char *) remountS, "r"); |
282 | if ( !fp) { | 282 | if ( !fp) { |
283 | qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); | 283 | qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); |
284 | QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); | 284 | QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); |
285 | 285 | ||
286 | } else { | 286 | } else { |
287 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully mounted.")); | 287 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully mounted.")); |
288 | while ( fgets( line, sizeof line, fp)) { | 288 | while ( fgets( line, sizeof line, fp)) { |
289 | QString lineStr = line; | 289 | QString lineStr = line; |
290 | lineStr=lineStr.left(lineStr.length()-1); | 290 | lineStr=lineStr.left(lineStr.length()-1); |
291 | outDlg->OutputEdit->append(lineStr); | 291 | outDlg->OutputEdit->append(lineStr); |
292 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 292 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | pclose(fp); | 295 | pclose(fp); |
296 | sleep(1); | 296 | sleep(1); |
297 | 297 | ||
298 | outDlg->OutputEdit->append(tr("You can now close the output window.")); | 298 | outDlg->OutputEdit->append(tr("You can now close the output window.")); |
299 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 299 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
300 | // outDlg->close(); | 300 | // outDlg->close(); |
301 | // if(outDlg) | 301 | // if(outDlg) |
302 | // delete outDlg; | 302 | // delete outDlg; |
303 | } | 303 | } |
304 | break; | 304 | break; |
305 | }; | 305 | }; |
306 | } | 306 | } |
307 | 307 | ||
308 | bool FormatterApp::doFdisk() { | 308 | bool FormatterApp::doFdisk() { |
309 | return FALSE; | 309 | return FALSE; |
310 | 310 | ||
311 | } | 311 | } |
312 | 312 | ||
313 | void FormatterApp::fillCombos() { | 313 | void FormatterApp::fillCombos() { |
314 | 314 | ||
315 | StorageInfo storageInfo; | 315 | StorageInfo storageInfo; |
316 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 316 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
317 | QListIterator<FileSystem> it ( fs ); | 317 | QListIterator<FileSystem> it ( fs ); |
318 | QString storage; | 318 | QString storage; |
319 | for( ; it.current(); ++it ){ | 319 | for( ; it.current(); ++it ){ |
320 | const QString name = (*it)->name(); | 320 | const QString name = (*it)->name(); |
321 | const QString path = (*it)->path(); | 321 | const QString path = (*it)->path(); |
322 | const QString disk = (*it)->disk(); | 322 | const QString disk = (*it)->disk(); |
323 | const QString options = (*it)->options(); | 323 | const QString options = (*it)->options(); |
324 | if( name.find( tr("Internal"),0,TRUE) == -1) { | 324 | if( name.find( tr("Internal"),0,TRUE) == -1) { |
325 | storageComboBox->insertItem(name +" -> "+disk); | 325 | storageComboBox->insertItem(name +" -> "+disk); |
326 | } | 326 | } |
327 | deviceComboBox->insertItem(disk); | 327 | // deviceComboBox->insertItem(disk); |
328 | } | 328 | } |
329 | parsetab(); | 329 | parsetab("/etc/mtab"); |
330 | // parsetab("/etc/fstab"); | ||
330 | fileSystemsCombo->insertStringList( fsList,-1); | 331 | fileSystemsCombo->insertStringList( fsList,-1); |
331 | // for(int i = 0; i < fileSystemsCombo->count(); i++) { | 332 | deviceComboBox->insertStringList( deviceList,-1); |
332 | // if( fsType == fileSystemsCombo->text(i)) | ||
333 | // fileSystemsCombo->setCurrentItem(i); | ||
334 | // } | ||
335 | storageComboSelected(0); | 333 | storageComboSelected(0); |
336 | deviceComboSelected(0); | 334 | deviceComboSelected(0); |
337 | } | 335 | } |
338 | 336 | ||
339 | 337 | ||
340 | void FormatterApp::fsComboSelected(int index) { | 338 | void FormatterApp::fsComboSelected(int index) { |
341 | 339 | ||
342 | } | 340 | } |
343 | 341 | ||
344 | void FormatterApp::storageComboSelected(int index ) { | 342 | void FormatterApp::storageComboSelected(int index ) { |
345 | 343 | ||
346 | QString currentText = storageComboBox->text(index); | 344 | QString currentText = storageComboBox->text(index); |
347 | QString nameS = currentText.left( currentText.find("->",0,TRUE)); | 345 | QString nameS = currentText.left( currentText.find("->",0,TRUE)); |
348 | 346 | ||
349 | TextLabel4->setText( tr( "Storage Type : ") + nameS ); | 347 | TextLabel4->setText( tr( "Storage Type : ") + nameS ); |
350 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 348 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); |
351 | 349 | ||
352 | QString fsType = getFileSystemType((const QString &) currentText); | 350 | QString fsType = getFileSystemType((const QString &) currentText); |
353 | // qDebug(fsType); | 351 | // qDebug(fsType); |
354 | for(int i = 0; i < fileSystemsCombo->count(); i++) { | 352 | for(int i = 0; i < fileSystemsCombo->count(); i++) { |
355 | if( fsType == fileSystemsCombo->text(i)) | 353 | if( fsType == fileSystemsCombo->text(i)) |
356 | fileSystemsCombo->setCurrentItem(i); | 354 | fileSystemsCombo->setCurrentItem(i); |
357 | } | 355 | } |
358 | // deviceComboSelected(index); | 356 | // deviceComboSelected(index); |
359 | } | 357 | } |
360 | 358 | ||
361 | void FormatterApp::deviceComboSelected(int index) { | 359 | void FormatterApp::deviceComboSelected(int index) { |
362 | 360 | ||
363 | StorageInfo storageInfo; | 361 | StorageInfo storageInfo; |
364 | QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; | 362 | QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; |
365 | 363 | ||
366 | selectedText = deviceComboBox->text(index); | 364 | selectedText = deviceComboBox->text(index); |
367 | 365 | ||
368 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 366 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
369 | QListIterator<FileSystem> it ( fs ); | 367 | QListIterator<FileSystem> it ( fs ); |
370 | QString storage; | 368 | QString storage; |
371 | for( ; it.current(); ++it ){ | 369 | for( ; it.current(); ++it ){ |
372 | const QString name = (*it)->name(); | 370 | const QString name = (*it)->name(); |
373 | const QString path = (*it)->path(); | 371 | const QString path = (*it)->path(); |
374 | const QString disk = (*it)->disk(); | 372 | const QString disk = (*it)->disk(); |
375 | // const QString options = (*it)->options(); | 373 | // const QString options = (*it)->options(); |
376 | if( selectedText == disk) { | 374 | if( selectedText == disk) { |
377 | diskS = disk; nameS= name; | 375 | diskS = disk; nameS= name; |
378 | mountPointLineEdit->setText(path); | 376 | mountPointLineEdit->setText(path); |
379 | long mult = (*it)->blockSize() / 1024; | 377 | long mult = (*it)->blockSize() / 1024; |
380 | long div = 1024 / (*it)->blockSize(); | 378 | long div = 1024 / (*it)->blockSize(); |
381 | if ( !mult ) mult = 1; | 379 | if ( !mult ) mult = 1; |
382 | if ( !div ) div = 1; | 380 | if ( !div ) div = 1; |
383 | long total = (*it)->totalBlocks() * mult / div; | 381 | long total = (*it)->totalBlocks() * mult / div; |
384 | long totalMb = total/1024; | 382 | long totalMb = total/1024; |
385 | long avail = (*it)->availBlocks() * mult / div; | 383 | long avail = (*it)->availBlocks() * mult / div; |
386 | long availMb = avail/1024; | 384 | long availMb = avail/1024; |
387 | long used = total - avail; | 385 | long used = total - avail; |
388 | long usedMb = used/1024; | 386 | long usedMb = used/1024; |
389 | totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); | 387 | totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); |
390 | usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); | 388 | usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); |
391 | avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); | 389 | avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); |
392 | } | 390 | } |
393 | } | 391 | } |
394 | fsType = getFileSystemType((const QString &)selectedText); | 392 | fsType = getFileSystemType((const QString &)selectedText); |
395 | 393 | ||
396 | TextLabel5->setText("Type: "+ nameS+" Formatted with "+ fsType + " \n" + totalS + usedS + avS); | 394 | TextLabel5->setText("Type: "+ nameS+" Formatted with "+ fsType + " \n" + totalS + usedS + avS); |
397 | // storageComboSelected(0); | 395 | // storageComboSelected(0); |
398 | } | 396 | } |
399 | 397 | ||
400 | void FormatterApp::cleanUp() { | 398 | void FormatterApp::cleanUp() { |
401 | 399 | ||
402 | } | 400 | } |
403 | 401 | ||
404 | 402 | ||
405 | void FormatterApp::editFstab() { | 403 | void FormatterApp::editFstab() { |
406 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); | 404 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); |
407 | e << (const QString &)"/etc/fstab"; | 405 | e << (const QString &)"/etc/fstab"; |
408 | } | 406 | } |
409 | 407 | ||
410 | void FormatterApp::parsetab() { | 408 | void FormatterApp::parsetab(const QString &fileName) { |
411 | 409 | ||
412 | fileSystemTypeList.clear(); | 410 | fileSystemTypeList.clear(); |
413 | fsList.clear(); | 411 | fsList.clear(); |
414 | struct mntent *me; | 412 | struct mntent *me; |
415 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 413 | // if(fileName == "/etc/mtab") { |
414 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | ||
416 | if ( mntfp ) { | 415 | if ( mntfp ) { |
417 | while ( (me = getmntent( mntfp )) != 0 ) { | 416 | while ( (me = getmntent( mntfp )) != 0 ) { |
418 | QString deviceName = me->mnt_fsname; | 417 | QString deviceName = me->mnt_fsname; |
419 | QString filesystemType = me->mnt_type; | 418 | QString filesystemType = me->mnt_type; |
420 | if(deviceName != "none") { | 419 | if(deviceName != "none") { |
421 | if( fsList.contains(filesystemType) == 0 | 420 | if( fsList.contains(filesystemType) == 0 |
422 | & filesystemType.find("proc",0,TRUE) == -1 | 421 | & filesystemType.find("proc",0,TRUE) == -1 |
423 | & filesystemType.find("cramfs",0,TRUE) == -1) | 422 | & filesystemType.find("cramfs",0,TRUE) == -1 |
423 | & filesystemType.find("auto",0,TRUE) == -1) | ||
424 | fsList << filesystemType; | 424 | fsList << filesystemType; |
425 | deviceList << deviceName; | ||
426 | qDebug(deviceName+"::"+filesystemType); | ||
425 | fileSystemTypeList << deviceName+"::"+filesystemType; | 427 | fileSystemTypeList << deviceName+"::"+filesystemType; |
426 | } | 428 | } |
427 | } | 429 | } |
428 | } | 430 | } |
429 | endmntent( mntfp ); | 431 | endmntent( mntfp ); |
430 | 432 | // } else if(fileName == "/etc/fstab") { | |
431 | // QFile f("/etc/fstab"); | 433 | // QFile f("/etc/fstab"); |
432 | // if ( f.open(IO_ReadOnly) ) { | 434 | // if ( f.open(IO_ReadOnly) ) { |
433 | // QTextStream t (&f); | 435 | // QTextStream t (&f); |
434 | // QString s; | 436 | // QString s; |
435 | // while (! t.eof()) { | 437 | // while (! t.eof()) { |
436 | // s=t.readLine(); | 438 | // s=t.readLine(); |
437 | // s=s.simplifyWhiteSpace(); | 439 | // s=s.simplifyWhiteSpace(); |
438 | // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { | 440 | // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { |
439 | // s=s.remove(0,s.find(BLANK)+1 ); // devicename | 441 | // // = me->mnt_fsname; |
440 | // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint | 442 | // QString filesystemType = me->mnt_type; |
441 | // s=s.remove(0,s.find(BLANK)+1 ); // fs | 443 | // QString deviceName = s.left(0,s.find(BLANK) ); |
442 | // } | 444 | // s=s.remove(0,s.find(BLANK)+1 ); // devicename |
445 | |||
446 | // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint | ||
447 | // QStringt mountPoint= s.left(0,s.find(BLANK) ); | ||
448 | // s=s.remove(0,s.find(BLANK)+1 ); // fs | ||
449 | // QString filesystemType= s.left(0,s.find(BLANK) ); | ||
450 | // } | ||
443 | // } | 451 | // } |
444 | // } | 452 | // } |
445 | // f.close(); | 453 | // f.close(); |
454 | // } | ||
446 | } | 455 | } |
447 | 456 | ||
448 | QString FormatterApp::getFileSystemType(const QString ¤tText) { | 457 | QString FormatterApp::getFileSystemType(const QString ¤tText) { |
449 | 458 | ||
450 | parsetab(); //why did TT forget filesystem type? | 459 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
451 | 460 | ||
452 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 461 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
453 | QString temp = (*it); | 462 | QString temp = (*it); |
454 | if( temp.find( currentText,0,TRUE) != -1) { | 463 | if( temp.find( currentText,0,TRUE) != -1) { |
455 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 464 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
456 | // qDebug(fsType); | 465 | // qDebug(fsType); |
457 | } | 466 | } |
458 | } | 467 | } |
459 | return ""; | 468 | return ""; |
460 | } | 469 | } |
461 | 470 | ||
462 | bool FormatterApp::doFsck() { | 471 | bool FormatterApp::doFsck() { |
463 | 472 | ||
464 | QString selectedDevice = deviceComboBox->currentText(); | 473 | Output *outDlg; |
474 | QString selectedDevice; | ||
475 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap | ||
476 | selectedDevice = deviceComboBox->currentText(); | ||
477 | #else | ||
478 | // currentText = diskDevice = "/dev/fd0"; | ||
479 | QString umountS = "umount -v /floppy 2>&1"; | ||
480 | QString remountS = "mount -v /floppy 2>&1"; | ||
481 | selectedDevice ="/dev/fd0"; | ||
482 | |||
483 | #endif | ||
484 | |||
465 | QString fsType = getFileSystemType((const QString &)selectedDevice); | 485 | QString fsType = getFileSystemType((const QString &)selectedDevice); |
466 | QString cmd; | 486 | QString cmd; |
467 | qDebug( selectedDevice +" "+ fsType); | 487 | qDebug( selectedDevice +" "+ fsType); |
468 | if(fsType == "vfat") cmd = "dosfsck -vy "; | 488 | if(fsType == "vfat") cmd = "dosfsck -vy "; |
469 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; | 489 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; |
470 | cmd += selectedDevice; | 490 | cmd += selectedDevice + " 2>&1"; |
471 | 491 | ||
492 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | ||
493 | outDlg->showMaximized(); | ||
494 | outDlg->show(); | ||
495 | qApp->processEvents(); | ||
496 | FILE *fp; | ||
497 | char line[130]; | ||
498 | outDlg->OutputEdit->append( tr("Trying to umount.")); | ||
499 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
472 | 500 | ||
473 | return FALSE; | 501 | sleep(1); |
502 | // qDebug("Command is "+umountS); | ||
503 | fp = popen( (const char *) umountS, "r"); | ||
504 | // qDebug("%d", fp); | ||
505 | if ( !fp ) { | ||
506 | qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); | ||
507 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); | ||
508 | pclose(fp); | ||
509 | return false; | ||
510 | } else { | ||
511 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); | ||
512 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
513 | while ( fgets( line, sizeof line, fp)) { | ||
514 | if( ((QString)line).find("busy",0,TRUE) != -1) { | ||
515 | qDebug("Could not find '" + umountS); | ||
516 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); | ||
517 | pclose(fp); | ||
518 | return false; | ||
519 | } else { | ||
520 | QString lineStr = line; | ||
521 | lineStr=lineStr.left(lineStr.length()-1); | ||
522 | outDlg->OutputEdit->append(lineStr); | ||
523 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
524 | } | ||
525 | } | ||
526 | } | ||
527 | pclose(fp); | ||
528 | ///////////////////////////////////// | ||
529 | fp = popen( (const char *) cmd, "r"); | ||
530 | while ( fgets( line, sizeof line, fp)) { | ||
531 | if( ((QString)line).find("No such device",0,TRUE) != -1) { | ||
532 | qDebug("No such device '" + umountS); | ||
533 | QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); | ||
534 | pclose(fp); | ||
535 | // outDlg->OutputEdit->append("No such device"); | ||
536 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
537 | return false; | ||
538 | } else { | ||
539 | QString lineStr = line; | ||
540 | lineStr=lineStr.left(lineStr.length()-1); | ||
541 | outDlg->OutputEdit->append(lineStr); | ||
542 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
543 | } | ||
544 | } | ||
545 | outDlg->OutputEdit->append(tr("You can now close the output window.")); | ||
546 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
547 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); | ||
548 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
549 | pclose(fp); | ||
550 | |||
551 | ///////////////////////////////////////// | ||
552 | |||
553 | return true; | ||
474 | } | 554 | } |
475 | 555 | ||
476 | bool FormatterApp::doFsckCheck() { | 556 | bool FormatterApp::doFsckCheck() { |
557 | |||
477 | return FALSE; | 558 | return FALSE; |
478 | } | 559 | } |
479 | 560 | ||
480 | int FormatterApp::formatCheck(const QString &deviceStr) { | 561 | int FormatterApp::formatCheck(const QString &deviceStr) { |
481 | 562 | ||
482 | return -1; | 563 | return -1; |
483 | } | 564 | } |
484 | 565 | ||
485 | int FormatterApp::runCommand(const QString &command) { | 566 | int FormatterApp::runCommand(const QString &command) { |
486 | 567 | ||
487 | return -1; | 568 | return -1; |
488 | } | 569 | } |
diff --git a/noncore/tools/formatter/formatter.h b/noncore/tools/formatter/formatter.h index 871054d..960a68a 100644 --- a/noncore/tools/formatter/formatter.h +++ b/noncore/tools/formatter/formatter.h | |||
@@ -1,65 +1,65 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** formatter.h | 2 | ** formatter.h |
3 | ** | 3 | ** |
4 | ** Copyright: Thu Apr 11 11:01:01 2002 | 4 | ** Copyright: Thu Apr 11 11:01:01 2002 |
5 | ** by: L.J. Potter | 5 | ** by: L.J. Potter |
6 | ** | 6 | ** |
7 | ****************************************************************************/ | 7 | ****************************************************************************/ |
8 | 8 | ||
9 | #ifndef FORMATTERAPP_H | 9 | #ifndef FORMATTERAPP_H |
10 | #define FORMATTERAPP_H | 10 | #define FORMATTERAPP_H |
11 | 11 | ||
12 | #include <qvariant.h> | 12 | #include <qvariant.h> |
13 | //#include <qdialog.h> | 13 | //#include <qdialog.h> |
14 | #include <qmainwindow.h> | 14 | #include <qmainwindow.h> |
15 | 15 | ||
16 | class QVBoxLayout; | 16 | class QVBoxLayout; |
17 | class QHBoxLayout; | 17 | class QHBoxLayout; |
18 | class QGridLayout; | 18 | class QGridLayout; |
19 | class QComboBox; | 19 | class QComboBox; |
20 | class QLabel; | 20 | class QLabel; |
21 | class QLineEdit; | 21 | class QLineEdit; |
22 | class QPushButton; | 22 | class QPushButton; |
23 | class QTabWidget; | 23 | class QTabWidget; |
24 | class QWidget; | 24 | class QWidget; |
25 | class QStringList; | 25 | class QStringList; |
26 | 26 | ||
27 | class FormatterApp : public QMainWindow | 27 | class FormatterApp : public QMainWindow |
28 | //public QDialog | 28 | //public QDialog |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | FormatterApp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 33 | FormatterApp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
34 | ~FormatterApp(); | 34 | ~FormatterApp(); |
35 | 35 | ||
36 | QTabWidget *TabWidget; | 36 | QTabWidget *TabWidget; |
37 | QWidget *tab, *tab_2;; | 37 | QWidget *tab, *tab_2;; |
38 | QLabel *TextLabel1, *TextLabel2, *TextLabel3, *TextLabel4, *TextLabel5; | 38 | QLabel *TextLabel1, *TextLabel2, *TextLabel3, *TextLabel4, *TextLabel5; |
39 | QComboBox *storageComboBox, *fileSystemsCombo, *deviceComboBox; | 39 | QComboBox *storageComboBox, *fileSystemsCombo, *deviceComboBox; |
40 | QPushButton *formatPushButton, *editPushButton, *fsckButton; | 40 | QPushButton *formatPushButton, *editPushButton, *fsckButton; |
41 | QLineEdit* mountPointLineEdit; | 41 | QLineEdit* mountPointLineEdit; |
42 | QStringList fileSystemTypeList, fsList; | 42 | QStringList fileSystemTypeList, fsList, deviceList; |
43 | protected: | 43 | protected: |
44 | QGridLayout *FormatterAppLayout, *tabLayout, *tabLayout_2; | 44 | QGridLayout *FormatterAppLayout, *tabLayout, *tabLayout_2; |
45 | QString getFileSystemType(const QString &); | 45 | QString getFileSystemType(const QString &); |
46 | 46 | ||
47 | void fillCombos(); | 47 | void fillCombos(); |
48 | void parsetab(); | 48 | void parsetab(const QString &); |
49 | bool doFdisk(); | 49 | bool doFdisk(); |
50 | int formatCheck(const QString &); | 50 | int formatCheck(const QString &); |
51 | int runCommand(const QString &); | 51 | int runCommand(const QString &); |
52 | 52 | ||
53 | protected slots: | 53 | protected slots: |
54 | void cleanUp(); | 54 | void cleanUp(); |
55 | void doFormat(); | 55 | void doFormat(); |
56 | void editFstab(); | 56 | void editFstab(); |
57 | bool doFsck(); | 57 | bool doFsck(); |
58 | bool doFsckCheck(); | 58 | bool doFsckCheck(); |
59 | 59 | ||
60 | void fsComboSelected(int); | 60 | void fsComboSelected(int); |
61 | void storageComboSelected(int ); | 61 | void storageComboSelected(int ); |
62 | void deviceComboSelected(int ); | 62 | void deviceComboSelected(int ); |
63 | }; | 63 | }; |
64 | 64 | ||
65 | #endif // FORMATTERAPP_H | 65 | #endif // FORMATTERAPP_H |