author | llornkcor <llornkcor> | 2002-04-25 00:11:44 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-25 00:11:44 (UTC) |
commit | fd9fe8316525d3d7dac85d8d71dd8267b5abbd8f (patch) (unidiff) | |
tree | faf04b23270a222baae30e5ea29c77f308f0328e /noncore | |
parent | 5d3d95245768f7949208d367db1b5dc1d7f5e314 (diff) | |
download | opie-fd9fe8316525d3d7dac85d8d71dd8267b5abbd8f.zip opie-fd9fe8316525d3d7dac85d8d71dd8267b5abbd8f.tar.gz opie-fd9fe8316525d3d7dac85d8d71dd8267b5abbd8f.tar.bz2 |
initial commit
-rw-r--r-- | noncore/tools/formatter/formatter.control | 10 | ||||
-rw-r--r-- | noncore/tools/formatter/formatter.cpp | 419 | ||||
-rw-r--r-- | noncore/tools/formatter/formatter.h | 59 | ||||
-rw-r--r-- | noncore/tools/formatter/formatter.pro | 10 | ||||
-rw-r--r-- | noncore/tools/formatter/formatter.ui | 286 | ||||
-rw-r--r-- | noncore/tools/formatter/inputDialog.cpp | 44 | ||||
-rw-r--r-- | noncore/tools/formatter/inputDialog.h | 34 | ||||
-rw-r--r-- | noncore/tools/formatter/main.cpp | 25 | ||||
-rw-r--r-- | noncore/tools/formatter/output.cpp | 38 | ||||
-rw-r--r-- | noncore/tools/formatter/output.h | 33 | ||||
-rw-r--r-- | noncore/tools/formatter/outputEdit.ui | 40 |
11 files changed, 998 insertions, 0 deletions
diff --git a/noncore/tools/formatter/formatter.control b/noncore/tools/formatter/formatter.control new file mode 100644 index 0000000..ba3ccf1 --- a/dev/null +++ b/noncore/tools/formatter/formatter.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Files: $PKG_DIR/bin/formatter $PKG_DIR/pics/formatter/* $PKG_DIR/apps/Applications/formatter.desktop | ||
2 | Priority: optional | ||
3 | Package: formatter | ||
4 | Section: opie/applications | ||
5 | Maintainer: L.J. Potter <ljp@llornkcor.com> | ||
6 | Architecture: arm | ||
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: opie-base ($QPE_VERSION) | ||
9 | Description: Formatter | ||
10 | The filesystem formatting and mountpoint app for the Opie environment. | ||
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp new file mode 100644 index 0000000..8c8ef2a --- a/dev/null +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -0,0 +1,419 @@ | |||
1 | /**************************************************************************** | ||
2 | ** formatter.cpp | ||
3 | ** | ||
4 | ** Copyright: Thu Apr 11 11:01:13 2002 | ||
5 | ** by: L. J. Potter | ||
6 | ** | ||
7 | ****************************************************************************/ | ||
8 | |||
9 | #include "formatter.h" | ||
10 | #include "inputDialog.h" | ||
11 | #include "output.h" | ||
12 | |||
13 | #include <qpe/qpemenubar.h> | ||
14 | #include <qpe/qpetoolbar.h> | ||
15 | #include <qpe/qpeapplication.h> | ||
16 | #include <qpe/resource.h> | ||
17 | #include <qpe/config.h> | ||
18 | #include <qpe/mimetype.h> | ||
19 | #include <qpe/qcopenvelope_qws.h> | ||
20 | #include <qpe/storage.h> | ||
21 | |||
22 | #include <qmultilineedit.h> | ||
23 | #include <qstring.h> | ||
24 | #include <qlist.h> | ||
25 | #include <qstringlist.h> | ||
26 | #include <qdir.h> | ||
27 | #include <qfile.h> | ||
28 | |||
29 | #include <qtstream.h> | ||
30 | |||
31 | #include <qcombobox.h> | ||
32 | #include <qpopupmenu.h> | ||
33 | #include <qmessagebox.h> | ||
34 | #include <qregexp.h> | ||
35 | |||
36 | #include <qlabel.h> | ||
37 | #include <qlineedit.h> | ||
38 | #include <qpushbutton.h> | ||
39 | #include <qtabwidget.h> | ||
40 | #include <qwidget.h> | ||
41 | #include <qlayout.h> | ||
42 | #include <qvariant.h> | ||
43 | |||
44 | #include <unistd.h> | ||
45 | #include <stdio.h> | ||
46 | #include <stdlib.h> | ||
47 | #include <sys/vfs.h> | ||
48 | #include <mntent.h> | ||
49 | |||
50 | #define BLANK ' ' | ||
51 | #define DELIMITER '#' | ||
52 | |||
53 | /* | ||
54 | Blah blah blah blah */ | ||
55 | FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
56 | : QMainWindow( parent, name, fl ) | ||
57 | // : QDialog( parent, name, modal, fl ) | ||
58 | { | ||
59 | if ( !name ) | ||
60 | setName( "FormatterApp" ); | ||
61 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | ||
62 | |||
63 | setCaption( tr( "Formatter" ) ); | ||
64 | FormatterAppLayout = new QGridLayout( this ); | ||
65 | FormatterAppLayout->setSpacing( 2); | ||
66 | FormatterAppLayout->setMargin( 2 ); | ||
67 | |||
68 | TabWidget = new QTabWidget( this, "TabWidget" ); | ||
69 | |||
70 | tab = new QWidget( TabWidget, "tab" ); | ||
71 | tabLayout = new QGridLayout( tab ); | ||
72 | tabLayout->setSpacing( 6); | ||
73 | tabLayout->setMargin( 11); | ||
74 | |||
75 | storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); | ||
76 | |||
77 | tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1 ); | ||
78 | |||
79 | TextLabel4 = new QLabel( tab, "TextLabel4" ); | ||
80 | TextLabel4->setText( tr( "Storage Type" ) ); | ||
81 | |||
82 | tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1 ); | ||
83 | |||
84 | TextLabel2 = new QLabel( tab, "TextLabel2" ); | ||
85 | TextLabel2->setText( tr( "File Systems" ) ); | ||
86 | |||
87 | tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1 ); | ||
88 | |||
89 | fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); | ||
90 | |||
91 | tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1 ); | ||
92 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
93 | tabLayout->addItem( spacer, 2, 1 ); | ||
94 | |||
95 | formatPushButton = new QPushButton( tab, "formatPushButton" ); | ||
96 | formatPushButton->setText( tr( "Format" ) ); | ||
97 | |||
98 | tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1 ); | ||
99 | QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
100 | tabLayout->addItem( spacer_2, 5, 0 ); | ||
101 | TabWidget->insertTab( tab, tr( "Main" ) ); | ||
102 | |||
103 | tab_2 = new QWidget( TabWidget, "tab_2" ); | ||
104 | tabLayout_2 = new QGridLayout( tab_2 ); | ||
105 | tabLayout_2->setSpacing( 6); | ||
106 | tabLayout_2->setMargin( 11); | ||
107 | |||
108 | mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); | ||
109 | |||
110 | tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1 ); | ||
111 | |||
112 | deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); | ||
113 | |||
114 | tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1 ); | ||
115 | |||
116 | TextLabel5 = new QLabel( tab_2, "TextLabel5" ); | ||
117 | TextLabel5->setText( tr( "CAUTION:\n" | ||
118 | "Changing parameters on this \n" | ||
119 | "page may cause your system \n" | ||
120 | "to stop functioning properly!!" ) );//idiot message | ||
121 | |||
122 | tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1 ); | ||
123 | |||
124 | editPushButton = new QPushButton( tab_2, "editPushButton" ); | ||
125 | editPushButton->setText( tr( "Edit fstab" ) ); | ||
126 | |||
127 | tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); | ||
128 | |||
129 | fsckButton = new QPushButton( tab_2, "fsckPushButton" ); | ||
130 | fsckButton->setText( tr( "Check Disk" ) ); | ||
131 | |||
132 | tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1 ); | ||
133 | |||
134 | TextLabel3 = new QLabel( tab_2, "TextLabel3" ); | ||
135 | TextLabel3->setText( tr( "Device" ) ); | ||
136 | |||
137 | tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); | ||
138 | QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
139 | tabLayout_2->addItem( spacer_3, 5, 0 ); | ||
140 | |||
141 | TextLabel1 = new QLabel( tab_2, "TextLabel1" ); | ||
142 | TextLabel1->setText( tr( "Mount Point" ) ); | ||
143 | |||
144 | tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); | ||
145 | QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
146 | tabLayout_2->addItem( spacer_4, 2, 1 ); | ||
147 | TabWidget->insertTab( tab_2, tr( "Advanced" ) ); | ||
148 | |||
149 | FormatterAppLayout->addWidget( TabWidget, 0, 0 ); | ||
150 | |||
151 | connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); | ||
152 | connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); | ||
153 | connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); | ||
154 | |||
155 | connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); | ||
156 | connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); | ||
157 | connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); | ||
158 | |||
159 | |||
160 | fillCombos(); | ||
161 | } | ||
162 | |||
163 | /* | ||
164 | * Destroys the object and frees any allocated resources | ||
165 | frickin no duh?!? | ||
166 | */ | ||
167 | FormatterApp::~FormatterApp() | ||
168 | { | ||
169 | |||
170 | } | ||
171 | |||
172 | void FormatterApp::doFormat() { | ||
173 | int err=0; | ||
174 | Output *outDlg; | ||
175 | QString umountS, remountS; | ||
176 | QString text = storageComboBox->currentText(); | ||
177 | QString currentText = storageComboBox->currentText(); | ||
178 | QString cmd = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | ||
179 | QString fs = fileSystemsCombo->currentText(); | ||
180 | |||
181 | if( currentText.find("CF",0,TRUE) != -1) { | ||
182 | umountS = "/sbin/cardctl eject"; | ||
183 | remountS = "/sbin/cardctl insert"; | ||
184 | } | ||
185 | if( currentText.find("SD",0,TRUE) != -1) { | ||
186 | umountS = "/etc/sdcontrol compeject"; | ||
187 | remountS = "/etc/sdcontrol insert"; | ||
188 | } | ||
189 | |||
190 | switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") + currentText + | ||
191 | tr("\nwith ") + fs + tr(" filesystem?!?"),tr("Yes"),tr("No"),0,1,1) ) { | ||
192 | case 0: { | ||
193 | if(fs == "vfat") | ||
194 | cmd = "mkdosfs " + cmd; | ||
195 | else if(fs == "ext2") | ||
196 | cmd = "mke2fs " + cmd; | ||
197 | else { | ||
198 | QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); | ||
199 | break; | ||
200 | } | ||
201 | // cmd = "ls -l"; | ||
202 | outDlg = new Output(this, tr("Formatter Output"),FALSE); | ||
203 | outDlg->showMaximized(); | ||
204 | outDlg->show(); | ||
205 | qApp->processEvents(); | ||
206 | FILE *fp; | ||
207 | char line[130]; | ||
208 | outDlg->OutputEdit->append( tr("Trying to eject.") + currentText ); | ||
209 | sleep(1); | ||
210 | fp = popen( (const char *) umountS, "r"); | ||
211 | if ( !fp ) { | ||
212 | qDebug("Could not execute '" + umountS + "'! err=%d", fp); | ||
213 | QMessageBox::warning( this, tr("CardMonitor"), tr("Card eject failed!"), tr("&OK") ); | ||
214 | pclose(fp); | ||
215 | return; | ||
216 | } else { | ||
217 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully ejected.")); | ||
218 | |||
219 | while ( fgets( line, sizeof line, fp)) { | ||
220 | outDlg->OutputEdit->append(line); | ||
221 | } | ||
222 | } | ||
223 | pclose(fp); | ||
224 | // err = system( (const char *) umountS); | ||
225 | |||
226 | qDebug("Command would be: "+cmd); | ||
227 | outDlg->OutputEdit->append( tr("Trying to format.") ); | ||
228 | |||
229 | fp = popen( (const char *) cmd, "r"); | ||
230 | while ( fgets( line, sizeof line, fp)) { | ||
231 | outDlg->OutputEdit->append(line); | ||
232 | } | ||
233 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); | ||
234 | pclose(fp); | ||
235 | |||
236 | outDlg->OutputEdit->append( tr("Trying to insert.") + currentText ); | ||
237 | fp = popen( (const char *) remountS, "r"); | ||
238 | if ( !fp) { | ||
239 | qDebug("Could not execute '" + remountS + "'! err=%d", err); | ||
240 | QMessageBox::warning( this, tr("Formatter"), tr("Card insert failed!"), tr("&OK") ); | ||
241 | |||
242 | } else { | ||
243 | outDlg->OutputEdit->append( currentText + tr("\nhas been successfully inserted.")); | ||
244 | while ( fgets( line, sizeof line, fp)) { | ||
245 | outDlg->OutputEdit->append(line); | ||
246 | } | ||
247 | } | ||
248 | pclose(fp); | ||
249 | sleep(1); | ||
250 | |||
251 | outDlg->OutputEdit->append(tr("You can now close the output window.")); | ||
252 | outDlg->close(); | ||
253 | if(outDlg) | ||
254 | delete outDlg; | ||
255 | } | ||
256 | break; | ||
257 | }; | ||
258 | } | ||
259 | |||
260 | void FormatterApp::fillCombos() { | ||
261 | |||
262 | StorageInfo storageInfo; | ||
263 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
264 | QListIterator<FileSystem> it ( fs ); | ||
265 | QString storage; | ||
266 | for( ; it.current(); ++it ){ | ||
267 | const QString name = (*it)->name(); | ||
268 | const QString path = (*it)->path(); | ||
269 | const QString disk = (*it)->disk(); | ||
270 | const QString options = (*it)->options(); | ||
271 | if( name.find( tr("Internal"),0,TRUE) == -1) { | ||
272 | storageComboBox->insertItem(name +" -> "+disk); | ||
273 | } | ||
274 | deviceComboBox->insertItem(disk); | ||
275 | } | ||
276 | parsetab(); | ||
277 | fileSystemsCombo->insertStringList( fsList,-1); | ||
278 | // for(int i = 0; i < fileSystemsCombo->count(); i++) { | ||
279 | // if( fsType == fileSystemsCombo->text(i)) | ||
280 | // fileSystemsCombo->setCurrentItem(i); | ||
281 | // } | ||
282 | storageComboSelected(0); | ||
283 | deviceComboSelected(0); | ||
284 | } | ||
285 | |||
286 | |||
287 | void FormatterApp::fsComboSelected(int index) { | ||
288 | |||
289 | } | ||
290 | |||
291 | void FormatterApp::storageComboSelected(int index ) { | ||
292 | |||
293 | QString currentText = storageComboBox->text(index); | ||
294 | QString nameS = currentText.left( currentText.find("->",0,TRUE)); | ||
295 | |||
296 | TextLabel4->setText( tr( "Storage Type : ") + nameS ); | ||
297 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | ||
298 | |||
299 | QString fsType = getFileSystemType((const QString &) currentText); | ||
300 | // qDebug(fsType); | ||
301 | for(int i = 0; i < fileSystemsCombo->count(); i++) { | ||
302 | if( fsType == fileSystemsCombo->text(i)) | ||
303 | fileSystemsCombo->setCurrentItem(i); | ||
304 | } | ||
305 | // deviceComboSelected(index); | ||
306 | } | ||
307 | |||
308 | void FormatterApp::deviceComboSelected(int index) { | ||
309 | |||
310 | StorageInfo storageInfo; | ||
311 | QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; | ||
312 | |||
313 | selectedText = deviceComboBox->text(index); | ||
314 | |||
315 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | ||
316 | QListIterator<FileSystem> it ( fs ); | ||
317 | QString storage; | ||
318 | for( ; it.current(); ++it ){ | ||
319 | const QString name = (*it)->name(); | ||
320 | const QString path = (*it)->path(); | ||
321 | const QString disk = (*it)->disk(); | ||
322 | // const QString options = (*it)->options(); | ||
323 | if( selectedText == disk) { | ||
324 | diskS = disk; nameS= name; | ||
325 | mountPointLineEdit->setText(path); | ||
326 | long mult = (*it)->blockSize() / 1024; | ||
327 | long div = 1024 / (*it)->blockSize(); | ||
328 | if ( !mult ) mult = 1; | ||
329 | if ( !div ) div = 1; | ||
330 | long total = (*it)->totalBlocks() * mult / div; | ||
331 | long totalMb = total/1024; | ||
332 | long avail = (*it)->availBlocks() * mult / div; | ||
333 | long availMb = avail/1024; | ||
334 | long used = total - avail; | ||
335 | long usedMb = used/1024; | ||
336 | totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); | ||
337 | usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); | ||
338 | avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); | ||
339 | } | ||
340 | } | ||
341 | fsType = getFileSystemType((const QString &)selectedText); | ||
342 | |||
343 | TextLabel5->setText("Type: "+ nameS+" Formatted with "+ fsType + " \n" + totalS + usedS + avS); | ||
344 | // storageComboSelected(0); | ||
345 | } | ||
346 | |||
347 | void FormatterApp::cleanUp() { | ||
348 | |||
349 | } | ||
350 | |||
351 | |||
352 | void FormatterApp::editFstab() { | ||
353 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); | ||
354 | e << (const QString &)"/etc/fstab"; | ||
355 | } | ||
356 | |||
357 | void FormatterApp::parsetab() { | ||
358 | |||
359 | fileSystemTypeList.clear(); | ||
360 | fsList.clear(); | ||
361 | struct mntent *me; | ||
362 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | ||
363 | if ( mntfp ) { | ||
364 | while ( (me = getmntent( mntfp )) != 0 ) { | ||
365 | QString deviceName = me->mnt_fsname; | ||
366 | QString filesystemType = me->mnt_type; | ||
367 | if(deviceName != "none") { | ||
368 | if( fsList.contains(filesystemType) == 0 | ||
369 | & filesystemType.find("proc",0,TRUE) == -1 | ||
370 | & filesystemType.find("cramfs",0,TRUE) == -1) | ||
371 | fsList << filesystemType; | ||
372 | fileSystemTypeList << deviceName+"::"+filesystemType; | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | endmntent( mntfp ); | ||
377 | |||
378 | // QFile f("/etc/fstab"); | ||
379 | // if ( f.open(IO_ReadOnly) ) { | ||
380 | // QTextStream t (&f); | ||
381 | // QString s; | ||
382 | // while (! t.eof()) { | ||
383 | // s=t.readLine(); | ||
384 | // s=s.simplifyWhiteSpace(); | ||
385 | // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { | ||
386 | // s=s.remove(0,s.find(BLANK)+1 ); // devicename | ||
387 | // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint | ||
388 | // s=s.remove(0,s.find(BLANK)+1 ); // fs | ||
389 | // } | ||
390 | // } | ||
391 | // } | ||
392 | // f.close(); | ||
393 | } | ||
394 | |||
395 | QString FormatterApp::getFileSystemType(const QString ¤tText) { | ||
396 | |||
397 | parsetab(); //why did TT forget filesystem type? | ||
398 | |||
399 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | ||
400 | QString temp = (*it); | ||
401 | if( temp.find( currentText,0,TRUE) != -1) { | ||
402 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | ||
403 | // qDebug(fsType); | ||
404 | } | ||
405 | } | ||
406 | return ""; | ||
407 | } | ||
408 | |||
409 | void FormatterApp::doFsck() { | ||
410 | |||
411 | QString selectedDevice = deviceComboBox->currentText(); | ||
412 | QString fsType = getFileSystemType((const QString &)selectedDevice); | ||
413 | QString cmd; | ||
414 | qDebug( selectedDevice +" "+ fsType); | ||
415 | if(fsType == "vfat") cmd = "dosfsck -vy "; | ||
416 | if(fsType == "ext2") cmd = "e2fsck -cpvy "; | ||
417 | cmd += selectedDevice; | ||
418 | |||
419 | } | ||
diff --git a/noncore/tools/formatter/formatter.h b/noncore/tools/formatter/formatter.h new file mode 100644 index 0000000..a566ec0 --- a/dev/null +++ b/noncore/tools/formatter/formatter.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /**************************************************************************** | ||
2 | ** formatter.h | ||
3 | ** | ||
4 | ** Copyright: Thu Apr 11 11:01:01 2002 | ||
5 | ** by: L.J. Potter | ||
6 | ** | ||
7 | ****************************************************************************/ | ||
8 | |||
9 | #ifndef FORMATTERAPP_H | ||
10 | #define FORMATTERAPP_H | ||
11 | |||
12 | #include <qvariant.h> | ||
13 | //#include <qdialog.h> | ||
14 | #include <qmainwindow.h> | ||
15 | |||
16 | class QVBoxLayout; | ||
17 | class QHBoxLayout; | ||
18 | class QGridLayout; | ||
19 | class QComboBox; | ||
20 | class QLabel; | ||
21 | class QLineEdit; | ||
22 | class QPushButton; | ||
23 | class QTabWidget; | ||
24 | class QWidget; | ||
25 | class QStringList; | ||
26 | |||
27 | class FormatterApp : public QMainWindow | ||
28 | //public QDialog | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | |||
32 | public: | ||
33 | FormatterApp( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | ||
34 | ~FormatterApp(); | ||
35 | |||
36 | QTabWidget *TabWidget; | ||
37 | QWidget *tab, *tab_2;; | ||
38 | QLabel *TextLabel1, *TextLabel2, *TextLabel3, *TextLabel4, *TextLabel5; | ||
39 | QComboBox *storageComboBox, *fileSystemsCombo, *deviceComboBox; | ||
40 | QPushButton *formatPushButton, *editPushButton, *fsckButton; | ||
41 | QLineEdit* mountPointLineEdit; | ||
42 | QStringList fileSystemTypeList, fsList; | ||
43 | protected: | ||
44 | QGridLayout *FormatterAppLayout, *tabLayout, *tabLayout_2; | ||
45 | QString getFileSystemType(const QString &); | ||
46 | |||
47 | protected slots: | ||
48 | void doFormat(); | ||
49 | void fillCombos(); | ||
50 | void cleanUp(); | ||
51 | void fsComboSelected(int); | ||
52 | void storageComboSelected(int ); | ||
53 | void deviceComboSelected(int ); | ||
54 | void editFstab(); | ||
55 | void parsetab(); | ||
56 | void doFsck(); | ||
57 | }; | ||
58 | |||
59 | #endif // FORMATTERAPP_H | ||
diff --git a/noncore/tools/formatter/formatter.pro b/noncore/tools/formatter/formatter.pro new file mode 100644 index 0000000..b69da44 --- a/dev/null +++ b/noncore/tools/formatter/formatter.pro | |||
@@ -0,0 +1,10 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG += qt warn_on release | ||
3 | HEADERS = formatter.h inputDialog.h output.h | ||
4 | SOURCES = formatter.cpp inputDialog.cpp output.cpp main.cpp | ||
5 | TARGET = formatter | ||
6 | REQUIRES = medium-config | ||
7 | DESTDIR = $(OPIEDIR)/bin | ||
8 | INCLUDEPATH += $(OPIEDIR)/include | ||
9 | DEPENDPATH += $(OPIEDIR)/include | ||
10 | LIBS += -lqpe | ||
diff --git a/noncore/tools/formatter/formatter.ui b/noncore/tools/formatter/formatter.ui new file mode 100644 index 0000000..6b7462c --- a/dev/null +++ b/noncore/tools/formatter/formatter.ui | |||
@@ -0,0 +1,286 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>FormatterApp</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>FormatterApp</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>237</width> | ||
15 | <height>359</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Formatter</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>11</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>6</number> | ||
30 | </property> | ||
31 | <widget row="0" column="0" > | ||
32 | <class>QTabWidget</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>TabWidget</cstring> | ||
36 | </property> | ||
37 | <widget> | ||
38 | <class>QWidget</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>tab</cstring> | ||
42 | </property> | ||
43 | <attribute> | ||
44 | <name>title</name> | ||
45 | <string>Main</string> | ||
46 | </attribute> | ||
47 | <grid> | ||
48 | <property stdset="1"> | ||
49 | <name>margin</name> | ||
50 | <number>11</number> | ||
51 | </property> | ||
52 | <property stdset="1"> | ||
53 | <name>spacing</name> | ||
54 | <number>6</number> | ||
55 | </property> | ||
56 | <widget row="0" column="0" rowspan="1" colspan="2" > | ||
57 | <class>QComboBox</class> | ||
58 | <property stdset="1"> | ||
59 | <name>name</name> | ||
60 | <cstring>storageComboBox</cstring> | ||
61 | </property> | ||
62 | </widget> | ||
63 | <widget row="1" column="0" rowspan="1" colspan="2" > | ||
64 | <class>QLabel</class> | ||
65 | <property stdset="1"> | ||
66 | <name>name</name> | ||
67 | <cstring>TextLabel4</cstring> | ||
68 | </property> | ||
69 | <property stdset="1"> | ||
70 | <name>text</name> | ||
71 | <string>Storage Type</string> | ||
72 | </property> | ||
73 | </widget> | ||
74 | <widget row="4" column="0" rowspan="1" colspan="2" > | ||
75 | <class>QLabel</class> | ||
76 | <property stdset="1"> | ||
77 | <name>name</name> | ||
78 | <cstring>TextLabel2</cstring> | ||
79 | </property> | ||
80 | <property stdset="1"> | ||
81 | <name>text</name> | ||
82 | <string>File Systems</string> | ||
83 | </property> | ||
84 | </widget> | ||
85 | <widget row="3" column="0" rowspan="1" colspan="2" > | ||
86 | <class>QComboBox</class> | ||
87 | <item> | ||
88 | <property> | ||
89 | <name>text</name> | ||
90 | <string>DOS </string> | ||
91 | </property> | ||
92 | </item> | ||
93 | <item> | ||
94 | <property> | ||
95 | <name>text</name> | ||
96 | <string>EXT2</string> | ||
97 | </property> | ||
98 | </item> | ||
99 | <property stdset="1"> | ||
100 | <name>name</name> | ||
101 | <cstring>fileSystemsCombo</cstring> | ||
102 | </property> | ||
103 | </widget> | ||
104 | <spacer row="2" column="1" > | ||
105 | <property> | ||
106 | <name>name</name> | ||
107 | <cstring>Spacer3</cstring> | ||
108 | </property> | ||
109 | <property stdset="1"> | ||
110 | <name>orientation</name> | ||
111 | <enum>Vertical</enum> | ||
112 | </property> | ||
113 | <property stdset="1"> | ||
114 | <name>sizeType</name> | ||
115 | <enum>Expanding</enum> | ||
116 | </property> | ||
117 | <property> | ||
118 | <name>sizeHint</name> | ||
119 | <size> | ||
120 | <width>20</width> | ||
121 | <height>20</height> | ||
122 | </size> | ||
123 | </property> | ||
124 | </spacer> | ||
125 | <widget row="6" column="0" rowspan="1" colspan="2" > | ||
126 | <class>QPushButton</class> | ||
127 | <property stdset="1"> | ||
128 | <name>name</name> | ||
129 | <cstring>formatPushButton</cstring> | ||
130 | </property> | ||
131 | <property stdset="1"> | ||
132 | <name>text</name> | ||
133 | <string>Format</string> | ||
134 | </property> | ||
135 | </widget> | ||
136 | <spacer row="5" column="0" > | ||
137 | <property> | ||
138 | <name>name</name> | ||
139 | <cstring>Spacer2</cstring> | ||
140 | </property> | ||
141 | <property stdset="1"> | ||
142 | <name>orientation</name> | ||
143 | <enum>Vertical</enum> | ||
144 | </property> | ||
145 | <property stdset="1"> | ||
146 | <name>sizeType</name> | ||
147 | <enum>Expanding</enum> | ||
148 | </property> | ||
149 | <property> | ||
150 | <name>sizeHint</name> | ||
151 | <size> | ||
152 | <width>20</width> | ||
153 | <height>20</height> | ||
154 | </size> | ||
155 | </property> | ||
156 | </spacer> | ||
157 | </grid> | ||
158 | </widget> | ||
159 | <widget> | ||
160 | <class>QWidget</class> | ||
161 | <property stdset="1"> | ||
162 | <name>name</name> | ||
163 | <cstring>tab</cstring> | ||
164 | </property> | ||
165 | <attribute> | ||
166 | <name>title</name> | ||
167 | <string>Advanced</string> | ||
168 | </attribute> | ||
169 | <grid> | ||
170 | <property stdset="1"> | ||
171 | <name>margin</name> | ||
172 | <number>11</number> | ||
173 | </property> | ||
174 | <property stdset="1"> | ||
175 | <name>spacing</name> | ||
176 | <number>6</number> | ||
177 | </property> | ||
178 | <widget row="0" column="0" rowspan="1" colspan="2" > | ||
179 | <class>QLineEdit</class> | ||
180 | <property stdset="1"> | ||
181 | <name>name</name> | ||
182 | <cstring>mountPointLineEdit</cstring> | ||
183 | </property> | ||
184 | </widget> | ||
185 | <widget row="3" column="0" rowspan="1" colspan="2" > | ||
186 | <class>QComboBox</class> | ||
187 | <property stdset="1"> | ||
188 | <name>name</name> | ||
189 | <cstring>deviceComboBox</cstring> | ||
190 | </property> | ||
191 | </widget> | ||
192 | <widget row="6" column="0" rowspan="1" colspan="2" > | ||
193 | <class>QLabel</class> | ||
194 | <property stdset="1"> | ||
195 | <name>name</name> | ||
196 | <cstring>TextLabel5</cstring> | ||
197 | </property> | ||
198 | <property stdset="1"> | ||
199 | <name>text</name> | ||
200 | <string>CAUTION: | ||
201 | Changing perimeters on this | ||
202 | page may cause your system | ||
203 | to stop functioning properly!!</string> | ||
204 | </property> | ||
205 | </widget> | ||
206 | <widget row="7" column="0" rowspan="1" colspan="2" > | ||
207 | <class>QPushButton</class> | ||
208 | <property stdset="1"> | ||
209 | <name>name</name> | ||
210 | <cstring>editPushButton</cstring> | ||
211 | </property> | ||
212 | <property stdset="1"> | ||
213 | <name>text</name> | ||
214 | <string>Edit fstab</string> | ||
215 | </property> | ||
216 | </widget> | ||
217 | <widget row="4" column="0" rowspan="1" colspan="2" > | ||
218 | <class>QLabel</class> | ||
219 | <property stdset="1"> | ||
220 | <name>name</name> | ||
221 | <cstring>TextLabel3</cstring> | ||
222 | </property> | ||
223 | <property stdset="1"> | ||
224 | <name>text</name> | ||
225 | <string>Device</string> | ||
226 | </property> | ||
227 | </widget> | ||
228 | <spacer row="5" column="0" > | ||
229 | <property> | ||
230 | <name>name</name> | ||
231 | <cstring>Spacer4</cstring> | ||
232 | </property> | ||
233 | <property stdset="1"> | ||
234 | <name>orientation</name> | ||
235 | <enum>Vertical</enum> | ||
236 | </property> | ||
237 | <property stdset="1"> | ||
238 | <name>sizeType</name> | ||
239 | <enum>Expanding</enum> | ||
240 | </property> | ||
241 | <property> | ||
242 | <name>sizeHint</name> | ||
243 | <size> | ||
244 | <width>20</width> | ||
245 | <height>20</height> | ||
246 | </size> | ||
247 | </property> | ||
248 | </spacer> | ||
249 | <widget row="1" column="0" rowspan="1" colspan="2" > | ||
250 | <class>QLabel</class> | ||
251 | <property stdset="1"> | ||
252 | <name>name</name> | ||
253 | <cstring>TextLabel1</cstring> | ||
254 | </property> | ||
255 | <property stdset="1"> | ||
256 | <name>text</name> | ||
257 | <string>Mount Point</string> | ||
258 | </property> | ||
259 | </widget> | ||
260 | <spacer row="2" column="1" > | ||
261 | <property> | ||
262 | <name>name</name> | ||
263 | <cstring>Spacer5</cstring> | ||
264 | </property> | ||
265 | <property stdset="1"> | ||
266 | <name>orientation</name> | ||
267 | <enum>Vertical</enum> | ||
268 | </property> | ||
269 | <property stdset="1"> | ||
270 | <name>sizeType</name> | ||
271 | <enum>Expanding</enum> | ||
272 | </property> | ||
273 | <property> | ||
274 | <name>sizeHint</name> | ||
275 | <size> | ||
276 | <width>20</width> | ||
277 | <height>20</height> | ||
278 | </size> | ||
279 | </property> | ||
280 | </spacer> | ||
281 | </grid> | ||
282 | </widget> | ||
283 | </widget> | ||
284 | </grid> | ||
285 | </widget> | ||
286 | </UI> | ||
diff --git a/noncore/tools/formatter/inputDialog.cpp b/noncore/tools/formatter/inputDialog.cpp new file mode 100644 index 0000000..373db3b --- a/dev/null +++ b/noncore/tools/formatter/inputDialog.cpp | |||
@@ -0,0 +1,44 @@ | |||
1 | /**************************************************************************** | ||
2 | inputDialog.cpp | ||
3 | ------------------- | ||
4 | ** Created: Sat Mar 9 23:33:09 2002 | ||
5 | copyright : (C) 2002 by ljp | ||
6 | email : ljp@llornkcor.com | ||
7 | * This program is free software; you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | ***************************************************************************/ | ||
12 | |||
13 | #include "inputDialog.h" | ||
14 | |||
15 | #include <qlineedit.h> | ||
16 | #include <qlayout.h> | ||
17 | #include <qvariant.h> | ||
18 | #include <qtooltip.h> | ||
19 | #include <qwhatsthis.h> | ||
20 | |||
21 | |||
22 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
23 | : QDialog( parent, name, modal, fl ) | ||
24 | { | ||
25 | if ( !name ) | ||
26 | setName( "InputDialog" ); | ||
27 | resize( 234, 50 ); | ||
28 | setMaximumSize( QSize( 240, 50 ) ); | ||
29 | setCaption( tr(name ) ); | ||
30 | |||
31 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | ||
32 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); | ||
33 | } | ||
34 | |||
35 | InputDialog::~InputDialog() | ||
36 | { | ||
37 | inputText= LineEdit1->text(); | ||
38 | |||
39 | } | ||
40 | |||
41 | void InputDialog::setTextEdit(const QString &string) | ||
42 | { | ||
43 | LineEdit1->setText(string); | ||
44 | } | ||
diff --git a/noncore/tools/formatter/inputDialog.h b/noncore/tools/formatter/inputDialog.h new file mode 100644 index 0000000..dfe0e8a --- a/dev/null +++ b/noncore/tools/formatter/inputDialog.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /*************************************************************************** | ||
2 | inputDialog.h | ||
3 | ------------------- | ||
4 | ** Created: Sat Mar 9 23:33:09 2002 | ||
5 | copyright : (C) 2002 by ljp | ||
6 | email : ljp@llornkcor.com | ||
7 | * This program is free software; you can redistribute it and/or modify * | ||
8 | * it under the terms of the GNU General Public License as published by * | ||
9 | * the Free Software Foundation; either version 2 of the License, or * | ||
10 | * (at your option) any later version. * | ||
11 | ***************************************************************************/ | ||
12 | #ifndef INPUTDIALOG_H | ||
13 | #define INPUTDIALOG_H | ||
14 | |||
15 | #include <qvariant.h> | ||
16 | #include <qdialog.h> | ||
17 | class QVBoxLayout; | ||
18 | class QHBoxLayout; | ||
19 | class QGridLayout; | ||
20 | class QLineEdit; | ||
21 | |||
22 | class InputDialog : public QDialog | ||
23 | { | ||
24 | Q_OBJECT | ||
25 | |||
26 | public: | ||
27 | InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | ||
28 | ~InputDialog(); | ||
29 | QString inputText; | ||
30 | QLineEdit* LineEdit1; | ||
31 | void setTextEdit(const QString &); | ||
32 | }; | ||
33 | |||
34 | #endif // INPUTDIALOG_H | ||
diff --git a/noncore/tools/formatter/main.cpp b/noncore/tools/formatter/main.cpp new file mode 100644 index 0000000..f67c9f2 --- a/dev/null +++ b/noncore/tools/formatter/main.cpp | |||
@@ -0,0 +1,25 @@ | |||
1 | |||
2 | /*************************************************************************** | ||
3 | main.cpp - description | ||
4 | ------------------- | ||
5 | begin : March 10, 2002 | ||
6 | copyright : (C) 2002 by llornkcor | ||
7 | email : ljp@llornkcor.com | ||
8 | * This program is free software; you can redistribute it and/or modify * | ||
9 | * it under the terms of the GNU General Public License as published by * | ||
10 | * the Free Software Foundation; either version 2 of the License, or * | ||
11 | * (at your option) any later version. * | ||
12 | ***************************************************************************/ | ||
13 | #include <qpe/qpeapplication.h> | ||
14 | |||
15 | #include "formatter.h" | ||
16 | |||
17 | int main(int argc, char *argv[]) | ||
18 | { | ||
19 | QPEApplication a(argc, argv); | ||
20 | |||
21 | FormatterApp formatterApp; | ||
22 | a.showMainWidget( &formatterApp); | ||
23 | return a.exec(); | ||
24 | } | ||
25 | |||
diff --git a/noncore/tools/formatter/output.cpp b/noncore/tools/formatter/output.cpp new file mode 100644 index 0000000..6970f58 --- a/dev/null +++ b/noncore/tools/formatter/output.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | /**************************************************************************** | ||
2 | ** outputEdit.cpp | ||
3 | ** | ||
4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> | ||
5 | ****************************************************************************/ | ||
6 | #include "output.h" | ||
7 | |||
8 | #include <qmultilineedit.h> | ||
9 | #include <qpushbutton.h> | ||
10 | #include <qlayout.h> | ||
11 | #include <qvariant.h> | ||
12 | #include <qtooltip.h> | ||
13 | #include <qwhatsthis.h> | ||
14 | |||
15 | Output::Output( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
16 | : QDialog( parent, name, modal, fl ) | ||
17 | { | ||
18 | if ( !name ) | ||
19 | setName( "Output" ); | ||
20 | resize( 196, 269 ); | ||
21 | setCaption( name ); | ||
22 | OutputLayout = new QGridLayout( this ); | ||
23 | OutputLayout->setSpacing( 6 ); | ||
24 | OutputLayout->setMargin( 11 ); | ||
25 | |||
26 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); | ||
27 | |||
28 | OutputLayout->addWidget( OutputEdit, 0, 0 ); | ||
29 | } | ||
30 | |||
31 | /* | ||
32 | * Destroys the object and frees any allocated resources | ||
33 | */ | ||
34 | Output::~Output() | ||
35 | { | ||
36 | // no need to delete child widgets, Qt does it all for us | ||
37 | } | ||
38 | |||
diff --git a/noncore/tools/formatter/output.h b/noncore/tools/formatter/output.h new file mode 100644 index 0000000..84adccd --- a/dev/null +++ b/noncore/tools/formatter/output.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form interface generated from reading ui file 'outputEdit.ui' | ||
3 | ** | ||
4 | ** Created: Fri Apr 12 15:12:44 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #ifndef OUTPUT_H | ||
10 | #define OUTPUT_H | ||
11 | |||
12 | #include <qvariant.h> | ||
13 | #include <qdialog.h> | ||
14 | class QVBoxLayout; | ||
15 | class QHBoxLayout; | ||
16 | class QGridLayout; | ||
17 | class QMultiLineEdit; | ||
18 | |||
19 | class Output : public QDialog | ||
20 | { | ||
21 | Q_OBJECT | ||
22 | |||
23 | public: | ||
24 | Output( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | ||
25 | ~Output(); | ||
26 | |||
27 | QMultiLineEdit* OutputEdit; | ||
28 | |||
29 | protected: | ||
30 | QGridLayout* OutputLayout; | ||
31 | }; | ||
32 | |||
33 | #endif // OUTPUT_H | ||
diff --git a/noncore/tools/formatter/outputEdit.ui b/noncore/tools/formatter/outputEdit.ui new file mode 100644 index 0000000..ab89d4c --- a/dev/null +++ b/noncore/tools/formatter/outputEdit.ui | |||
@@ -0,0 +1,40 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>Output</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>Output</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>196</width> | ||
15 | <height>269</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Output</string> | ||
21 | </property> | ||
22 | <grid> | ||
23 | <property stdset="1"> | ||
24 | <name>margin</name> | ||
25 | <number>11</number> | ||
26 | </property> | ||
27 | <property stdset="1"> | ||
28 | <name>spacing</name> | ||
29 | <number>6</number> | ||
30 | </property> | ||
31 | <widget row="0" column="0" > | ||
32 | <class>QMultiLineEdit</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>OutputEdit</cstring> | ||
36 | </property> | ||
37 | </widget> | ||
38 | </grid> | ||
39 | </widget> | ||
40 | </UI> | ||