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