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