Diffstat (limited to 'noncore/tools/formatter/formatter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index e869317..77e1790 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -67,195 +67,195 @@ FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool | |||
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( 3); | 74 | tabLayout->setSpacing( 3); |
75 | tabLayout->setMargin( 2); | 75 | tabLayout->setMargin( 2); |
76 | 76 | ||
77 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); | 77 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); |
78 | storageComboBox->setMaximumWidth(220); | 78 | storageComboBox->setMaximumWidth(220); |
79 | 79 | ||
80 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1); | 80 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1); |
81 | 81 | ||
82 | TextLabel4 = new QLabel( tab, "TextLabel4" ); | 82 | TextLabel4 = new QLabel( tab, "TextLabel4" ); |
83 | TextLabel4->setText( tr( "Storage Type" ) ); | 83 | TextLabel4->setText( tr( "Storage Type" ) ); |
84 | 84 | ||
85 | tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1); | 85 | tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1); |
86 | 86 | ||
87 | TextLabel2 = new QLabel( tab, "TextLabel2" ); | 87 | TextLabel2 = new QLabel( tab, "TextLabel2" ); |
88 | TextLabel2->setText( tr( "File Systems" ) ); | 88 | TextLabel2->setText( tr( "File Systems" ) ); |
89 | 89 | ||
90 | tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1); | 90 | tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1); |
91 | 91 | ||
92 | fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); | 92 | fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); |
93 | fileSystemsCombo->setMaximumWidth(220); | 93 | fileSystemsCombo->setMaximumWidth(220); |
94 | 94 | ||
95 | tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1); | 95 | tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1); |
96 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); | 96 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); |
97 | tabLayout->addItem( spacer, 2, 0 ); | 97 | tabLayout->addItem( spacer, 2, 0 ); |
98 | 98 | ||
99 | formatPushButton = new QPushButton( tab, "formatPushButton" ); | 99 | formatPushButton = new QPushButton( tab, "formatPushButton" ); |
100 | formatPushButton->setText( tr( "Format" ) ); | 100 | formatPushButton->setText( tr( "Format" ) ); |
101 | formatPushButton->setMaximumWidth(170); | 101 | formatPushButton->setMaximumWidth(170); |
102 | 102 | ||
103 | tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1); | 103 | tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1); |
104 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); | 104 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); |
105 | tabLayout->addItem( spacer_2, 5, 0 ); | 105 | tabLayout->addItem( spacer_2, 5, 0 ); |
106 | 106 | ||
107 | TabWidget->insertTab( tab, tr( "Main" ) ); | 107 | TabWidget->insertTab( tab, tr( "Main" ) ); |
108 | 108 | ||
109 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 109 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
110 | tabLayout_2 = new QGridLayout( tab_2 ); | 110 | tabLayout_2 = new QGridLayout( tab_2 ); |
111 | tabLayout_2->setSpacing(3); | 111 | tabLayout_2->setSpacing(3); |
112 | tabLayout_2->setMargin(2); | 112 | tabLayout_2->setMargin(2); |
113 | 113 | ||
114 | mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); | 114 | mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); |
115 | 115 | ||
116 | tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1); | 116 | tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1); |
117 | 117 | ||
118 | deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); | 118 | deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); |
119 | 119 | ||
120 | tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1); | 120 | tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1); |
121 | 121 | ||
122 | TextLabel5 = new QLabel( tab_2, "TextLabel5" ); | 122 | TextLabel5 = new QLabel( tab_2, "TextLabel5" ); |
123 | TextLabel5->setText( tr( "CAUTION:\n" | 123 | TextLabel5->setText( tr( "CAUTION:\n" |
124 | "Changing parameters on this\n" | 124 | "Changing parameters on this\n" |
125 | "page may cause your system\n" | 125 | "page may cause your system\n" |
126 | "to stop functioning properly!" ) );//idiot message | 126 | "to stop functioning properly!" ) );//idiot message |
127 | 127 | ||
128 | tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1); | 128 | tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1); |
129 | 129 | ||
130 | editPushButton = new QPushButton( tab_2, "editPushButton" ); | 130 | editPushButton = new QPushButton( tab_2, "editPushButton" ); |
131 | editPushButton->setText( tr( "Edit fstab" ) ); | 131 | editPushButton->setText( tr( "Edit fstab" ) ); |
132 | editPushButton->setMaximumWidth(100); | 132 | editPushButton->setMaximumWidth(100); |
133 | 133 | ||
134 | tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); | 134 | tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); |
135 | 135 | ||
136 | fsckButton = new QPushButton( tab_2, "fsckPushButton" ); | 136 | fsckButton = new QPushButton( tab_2, "fsckPushButton" ); |
137 | fsckButton->setText( tr( "Check Disk" ) ); | 137 | fsckButton->setText( tr( "Check Disk" ) ); |
138 | fsckButton->setMaximumWidth(100); | 138 | fsckButton->setMaximumWidth(100); |
139 | 139 | ||
140 | tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1); | 140 | tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1); |
141 | 141 | ||
142 | TextLabel3 = new QLabel( tab_2, "TextLabel3" ); | 142 | TextLabel3 = new QLabel( tab_2, "TextLabel3" ); |
143 | TextLabel3->setText( tr( "Device" ) ); | 143 | TextLabel3->setText( tr( "Device" ) ); |
144 | 144 | ||
145 | tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); | 145 | tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); |
146 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 146 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
147 | tabLayout_2->addItem( spacer_3, 5, 0 ); | 147 | tabLayout_2->addItem( spacer_3, 5, 0 ); |
148 | 148 | ||
149 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); | 149 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); |
150 | TextLabel1->setText( tr( "Mount Point" ) ); | 150 | TextLabel1->setText( tr( "Mount Point" ) ); |
151 | 151 | ||
152 | tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); | 152 | tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); |
153 | QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 153 | QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
154 | tabLayout_2->addItem( spacer_4, 2, 1 ); | 154 | tabLayout_2->addItem( spacer_4, 2, 1 ); |
155 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); | 155 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); |
156 | 156 | ||
157 | FormatterAppLayout->addWidget( TabWidget, 0, 1 ); | 157 | FormatterAppLayout->addWidget( TabWidget, 0, 1 ); |
158 | 158 | ||
159 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); | 159 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); |
160 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); | 160 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); |
161 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); | 161 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); |
162 | 162 | ||
163 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); | 163 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int) )); |
164 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); | 164 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int) )); |
165 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); | 165 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int) )); |
166 | 166 | ||
167 | 167 | ||
168 | fillCombos(); | 168 | fillCombos(); |
169 | } | 169 | } |
170 | 170 | ||
171 | FormatterApp::~FormatterApp() | 171 | FormatterApp::~FormatterApp() |
172 | {} | 172 | {} |
173 | 173 | ||
174 | void FormatterApp::doFormat() | 174 | void FormatterApp::doFormat() |
175 | { | 175 | { |
176 | int err=0; | 176 | int err=0; |
177 | Output *outDlg; | 177 | Output *outDlg; |
178 | QString umountS, remountS; | 178 | QString umountS, remountS; |
179 | QString text = storageComboBox->currentText(); | 179 | QString text = storageComboBox->currentText(); |
180 | QString currentText = storageComboBox->currentText(); | 180 | QString currentText = storageComboBox->currentText(); |
181 | QString cmd; | 181 | QString cmd; |
182 | QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 182 | QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); |
183 | QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); | 183 | QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); |
184 | QString fs = fileSystemsCombo->currentText(); | 184 | QString fs = fileSystemsCombo->currentText(); |
185 | 185 | ||
186 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // lets test on something cheap | 186 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // lets test on something cheap |
187 | #else | 187 | #else |
188 | currentText = diskDevice = "/dev/fd0"; | 188 | currentText = diskDevice = "/dev/fd0"; |
189 | umountS = "umount -v /floppy 2>&1"; | 189 | umountS = "umount -v /floppy 2>&1"; |
190 | remountS = "mount -v /floppy 2>&1"; | 190 | remountS = "mount -v /floppy 2>&1"; |
191 | #endif | 191 | #endif |
192 | 192 | ||
193 | if( currentText.find("CF",0,TRUE) != -1) | 193 | if( currentText.find("CF",0,TRUE) != -1) |
194 | { | 194 | { |
195 | umountS = "umount "; | 195 | umountS = "umount "; |
196 | remountS = "mount "; | 196 | remountS = "mount "; |
197 | 197 | ||
198 | // umountS = "/sbin/cardctl eject"; | 198 | // umountS = "/sbin/cardctl eject"; |
199 | // remountS = "/sbin/cardctl insert"; | 199 | // remountS = "/sbin/cardctl insert"; |
200 | } | 200 | } |
201 | if( currentText.find("SD",0,TRUE) != -1) | 201 | if( currentText.find("SD",0,TRUE) != -1) |
202 | { | 202 | { |
203 | umountS = "umount "; | 203 | umountS = "umount "; |
204 | remountS = "mount "; | 204 | remountS = "mount "; |
205 | // umountS = "/etc/sdcontrol compeject"; | 205 | // umountS = "/etc/sdcontrol compeject"; |
206 | // remountS = "/etc/sdcontrol insert"; | 206 | // remountS = "/etc/sdcontrol insert"; |
207 | } | 207 | } |
208 | 208 | ||
209 | switch ( QMessageBox::warning(this,tr("Format?") | 209 | switch ( QMessageBox::warning(this,tr("Format?") |
210 | , tr("Really format\n") +diskName+" "+ currentText + | 210 | , tr("Really format\n") +diskName+" "+ currentText + |
211 | tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs ) | 211 | tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs ) |
212 | ,tr("Yes") | 212 | ,tr("Yes") |
213 | ,tr("No") | 213 | ,tr("No") |
214 | ,0 | 214 | ,0 |
215 | ,1 | 215 | ,1 |
216 | ,1) ) | 216 | ,1) ) |
217 | { | 217 | { |
218 | case 0: | 218 | case 0: |
219 | { | 219 | { |
220 | if(fs == "vfat") | 220 | if(fs == "vfat") |
221 | cmd = "mkdosfs -v " + diskDevice+" 2>&1"; | 221 | cmd = "mkdosfs -v " + diskDevice+" 2>&1"; |
222 | else if(fs == "ext2") | 222 | else if(fs == "ext2") |
223 | cmd = "mke2fs -v " + diskDevice+" 2>&1"; | 223 | cmd = "mke2fs -v " + diskDevice+" 2>&1"; |
224 | else | 224 | else |
225 | { | 225 | { |
226 | QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); | 226 | QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | // cmd = "ls -l"; | 229 | // cmd = "ls -l"; |
230 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | 230 | outDlg = new Output(this, tr("Formatter Output"),FALSE); |
231 | QPEApplication::showDialog( outDlg); | 231 | QPEApplication::showDialog( outDlg); |
232 | qApp->processEvents(); | 232 | qApp->processEvents(); |
233 | FILE *fp; | 233 | FILE *fp; |
234 | char line[130]; | 234 | char line[130]; |
235 | 235 | ||
236 | 236 | ||
237 | outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); | 237 | outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); |
238 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 238 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
239 | 239 | ||
240 | sleep(1); | 240 | sleep(1); |
241 | qDebug("Command is "+umountS); | 241 | qDebug("Command is "+umountS); |
242 | fp = popen( (const char *) umountS, "r"); | 242 | fp = popen( (const char *) umountS, "r"); |
243 | // qDebug("%d", fp); | 243 | // qDebug("%d", fp); |
244 | if ( !fp ) | 244 | if ( !fp ) |
245 | { | 245 | { |
246 | qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); | 246 | qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); |
247 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); | 247 | QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); |
248 | pclose(fp); | 248 | pclose(fp); |
249 | return; | 249 | return; |
250 | } | 250 | } |
251 | else | 251 | else |
252 | { | 252 | { |
253 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); | 253 | // outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); |
254 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 254 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
255 | while ( fgets( line, sizeof line, fp)) | 255 | while ( fgets( line, sizeof line, fp)) |
256 | { | 256 | { |
257 | if( ((QString)line).find("busy",0,TRUE) != -1) | 257 | if( ((QString)line).find("busy",0,TRUE) != -1) |
258 | { | 258 | { |
259 | qDebug("Could not find '" + umountS); | 259 | qDebug("Could not find '" + umountS); |
260 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); | 260 | QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); |
261 | pclose(fp); | 261 | pclose(fp); |