summaryrefslogtreecommitdiff
authordrw <drw>2005-05-23 23:49:14 (UTC)
committer drw <drw>2005-05-23 23:49:14 (UTC)
commitf5d45036d2a444f9ee27311895c430babcf947e5 (patch) (unidiff)
tree69a1ba1227931cccce2d916c6e0fd7dcc6ccd003
parenta04b6cb80be1c2df466b69ed40450820056aff06 (diff)
downloadopie-f5d45036d2a444f9ee27311895c430babcf947e5.zip
opie-f5d45036d2a444f9ee27311895c430babcf947e5.tar.gz
opie-f5d45036d2a444f9ee27311895c430babcf947e5.tar.bz2
Remove unnecessary include and fix compiler warning
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/formatter/formatter.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index 642196e..2b8cca2 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -1,251 +1,250 @@
1/**************************************************************************** 1/****************************************************************************
2 ** formatter.cpp 2 ** formatter.cpp
3 ** 3 **
4 ** Copyright: Thu Apr 11 11:01:13 2002 4 ** Copyright: Thu Apr 11 11:01:13 2002
5 ** by: L. J. Potter 5 ** by: L. J. Potter
6 ** 6 **
7 ****************************************************************************/ 7 ****************************************************************************/
8 8
9#include "formatter.h" 9#include "formatter.h"
10#include "inputDialog.h" 10#include "inputDialog.h"
11#include "output.h" 11#include "output.h"
12 12
13/* OPIE */ 13/* OPIE */
14#include <opie2/odebug.h> 14#include <opie2/odebug.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <qpe/resource.h>
17#include <qpe/config.h> 16#include <qpe/config.h>
18#include <qpe/mimetype.h> 17#include <qpe/mimetype.h>
19#include <qpe/qcopenvelope_qws.h> 18#include <qpe/qcopenvelope_qws.h>
20#include <qpe/storage.h> 19#include <qpe/storage.h>
21using namespace Opie::Core; 20using namespace Opie::Core;
22 21
23/* QT */ 22/* QT */
24#include <qmenubar.h> 23#include <qmenubar.h>
25#include <qmultilineedit.h> 24#include <qmultilineedit.h>
26#include <qstring.h> 25#include <qstring.h>
27#include <qlist.h> 26#include <qlist.h>
28#include <qstringlist.h> 27#include <qstringlist.h>
29#include <qdir.h> 28#include <qdir.h>
30#include <qfile.h> 29#include <qfile.h>
31#include <qtstream.h> 30#include <qtstream.h>
32#include <qcombobox.h> 31#include <qcombobox.h>
33#include <qpopupmenu.h> 32#include <qpopupmenu.h>
34#include <qmessagebox.h> 33#include <qmessagebox.h>
35#include <qregexp.h> 34#include <qregexp.h>
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 <qtoolbar.h> 38#include <qtoolbar.h>
40#include <qtabwidget.h> 39#include <qtabwidget.h>
41#include <qwidget.h> 40#include <qwidget.h>
42#include <qlayout.h> 41#include <qlayout.h>
43#include <qvariant.h> 42#include <qvariant.h>
44 43
45/* STD */ 44/* STD */
46#include <unistd.h> 45#include <unistd.h>
47#include <stdio.h> 46#include <stdio.h>
48#include <stdlib.h> 47#include <stdlib.h>
49#include <sys/vfs.h> 48#include <sys/vfs.h>
50#include <mntent.h> 49#include <mntent.h>
51#include <string.h> 50#include <string.h>
52#include <errno.h> 51#include <errno.h>
53 52
54#define BLANK ' ' 53#define BLANK ' '
55#define DELIMITER '#' 54#define DELIMITER '#'
56 55
57/* 56/*
58 Blah blah blah blah */ 57 Blah blah blah blah */
59FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool modal ) 58FormatterApp::FormatterApp( QWidget* parent, const char* name, WFlags fl, bool /*modal*/ )
60 : QMainWindow( parent, name, fl ) 59 : QMainWindow( parent, name, fl )
61 // : QDialog( parent, name, modal, fl ) 60 // : QDialog( parent, name, modal, fl )
62{ 61{
63 if ( !name ) 62 if ( !name )
64 setName( "FormatterApp" ); 63 setName( "FormatterApp" );
65 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 64 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
66 65
67 setCaption( tr( "Formatter" ) ); 66 setCaption( tr( "Formatter" ) );
68 FormatterAppLayout = new QGridLayout( this ); 67 FormatterAppLayout = new QGridLayout( this );
69 FormatterAppLayout->setSpacing( 2); 68 FormatterAppLayout->setSpacing( 2);
70 FormatterAppLayout->setMargin( 2 ); 69 FormatterAppLayout->setMargin( 2 );
71 70
72 TabWidget = new QTabWidget( this, "TabWidget" ); 71 TabWidget = new QTabWidget( this, "TabWidget" );
73 72
74 tab = new QWidget( TabWidget, "tab" ); 73 tab = new QWidget( TabWidget, "tab" );
75 tabLayout = new QGridLayout( tab ); 74 tabLayout = new QGridLayout( tab );
76 tabLayout->setSpacing( 3); 75 tabLayout->setSpacing( 3);
77 tabLayout->setMargin( 2); 76 tabLayout->setMargin( 2);
78 77
79 storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); 78 storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" );
80 storageComboBox->setMaximumWidth(220); 79 storageComboBox->setMaximumWidth(220);
81 80
82 tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1); 81 tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1);
83 82
84 TextLabel4 = new QLabel( tab, "TextLabel4" ); 83 TextLabel4 = new QLabel( tab, "TextLabel4" );
85 TextLabel4->setText( tr( "Storage Type" ) ); 84 TextLabel4->setText( tr( "Storage Type" ) );
86 85
87 tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1); 86 tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1);
88 87
89 TextLabel2 = new QLabel( tab, "TextLabel2" ); 88 TextLabel2 = new QLabel( tab, "TextLabel2" );
90 TextLabel2->setText( tr( "File Systems" ) ); 89 TextLabel2->setText( tr( "File Systems" ) );
91 90
92 tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1); 91 tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1);
93 92
94 fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); 93 fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" );
95 fileSystemsCombo->setMaximumWidth(220); 94 fileSystemsCombo->setMaximumWidth(220);
96 95
97 tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1); 96 tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1);
98 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); 97 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
99 tabLayout->addItem( spacer, 2, 0 ); 98 tabLayout->addItem( spacer, 2, 0 );
100 99
101 formatPushButton = new QPushButton( tab, "formatPushButton" ); 100 formatPushButton = new QPushButton( tab, "formatPushButton" );
102 formatPushButton->setText( tr( "Format" ) ); 101 formatPushButton->setText( tr( "Format" ) );
103 formatPushButton->setMaximumWidth(170); 102 formatPushButton->setMaximumWidth(170);
104 103
105 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1); 104 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1);
106 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); 105 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
107 tabLayout->addItem( spacer_2, 5, 0 ); 106 tabLayout->addItem( spacer_2, 5, 0 );
108 107
109 TabWidget->insertTab( tab, tr( "Main" ) ); 108 TabWidget->insertTab( tab, tr( "Main" ) );
110 109
111 tab_2 = new QWidget( TabWidget, "tab_2" ); 110 tab_2 = new QWidget( TabWidget, "tab_2" );
112 tabLayout_2 = new QGridLayout( tab_2 ); 111 tabLayout_2 = new QGridLayout( tab_2 );
113 tabLayout_2->setSpacing(3); 112 tabLayout_2->setSpacing(3);
114 tabLayout_2->setMargin(2); 113 tabLayout_2->setMargin(2);
115 114
116 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); 115 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" );
117 116
118 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1); 117 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1);
119 118
120 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); 119 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" );
121 120
122 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1); 121 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1);
123 122
124 TextLabel5 = new QLabel( tab_2, "TextLabel5" ); 123 TextLabel5 = new QLabel( tab_2, "TextLabel5" );
125 TextLabel5->setText( tr( "CAUTION:\n" 124 TextLabel5->setText( tr( "CAUTION:\n"
126 "Changing parameters on this\n" 125 "Changing parameters on this\n"
127 "page may cause your system\n" 126 "page may cause your system\n"
128 "to stop functioning properly!" ) );//idiot message 127 "to stop functioning properly!" ) );//idiot message
129 128
130 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1); 129 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1);
131 130
132 editPushButton = new QPushButton( tab_2, "editPushButton" ); 131 editPushButton = new QPushButton( tab_2, "editPushButton" );
133 editPushButton->setText( tr( "Edit fstab" ) ); 132 editPushButton->setText( tr( "Edit fstab" ) );
134 editPushButton->setMaximumWidth(100); 133 editPushButton->setMaximumWidth(100);
135 134
136 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); 135 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 );
137 136
138 fsckButton = new QPushButton( tab_2, "fsckPushButton" ); 137 fsckButton = new QPushButton( tab_2, "fsckPushButton" );
139 fsckButton->setText( tr( "Check Disk" ) ); 138 fsckButton->setText( tr( "Check Disk" ) );
140 fsckButton->setMaximumWidth(100); 139 fsckButton->setMaximumWidth(100);
141 140
142 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1); 141 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1);
143 142
144 TextLabel3 = new QLabel( tab_2, "TextLabel3" ); 143 TextLabel3 = new QLabel( tab_2, "TextLabel3" );
145 TextLabel3->setText( tr( "Device" ) ); 144 TextLabel3->setText( tr( "Device" ) );
146 145
147 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); 146 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 );
148 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 147 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
149 tabLayout_2->addItem( spacer_3, 5, 0 ); 148 tabLayout_2->addItem( spacer_3, 5, 0 );
150 149
151 TextLabel1 = new QLabel( tab_2, "TextLabel1" ); 150 TextLabel1 = new QLabel( tab_2, "TextLabel1" );
152 TextLabel1->setText( tr( "Mount Point" ) ); 151 TextLabel1->setText( tr( "Mount Point" ) );
153 152
154 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); 153 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 );
155 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 154 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
156 tabLayout_2->addItem( spacer_4, 2, 1 ); 155 tabLayout_2->addItem( spacer_4, 2, 1 );
157 TabWidget->insertTab( tab_2, tr( "Advanced" ) ); 156 TabWidget->insertTab( tab_2, tr( "Advanced" ) );
158 157
159 FormatterAppLayout->addWidget( TabWidget, 0, 1 ); 158 FormatterAppLayout->addWidget( TabWidget, 0, 1 );
160 159
161 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); 160 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) );
162 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); 161 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) );
163 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); 162 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) );
164 163
165 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int) )); 164 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int) ));
166 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int) )); 165 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int) ));
167 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int) )); 166 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int) ));
168 167
169 168
170 fillCombos(); 169 fillCombos();
171} 170}
172 171
173FormatterApp::~FormatterApp() 172FormatterApp::~FormatterApp()
174{} 173{}
175 174
176void FormatterApp::doFormat() 175void FormatterApp::doFormat()
177{ 176{
178 int err=0; 177 int err=0;
179 Output *outDlg; 178 Output *outDlg;
180 QString umountS, remountS; 179 QString umountS, remountS;
181 QString text = storageComboBox->currentText(); 180 QString text = storageComboBox->currentText();
182 QString currentText = storageComboBox->currentText(); 181 QString currentText = storageComboBox->currentText();
183 QString cmd; 182 QString cmd;
184 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 183 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
185 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); 184 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE));
186 QString fs = fileSystemsCombo->currentText(); 185 QString fs = fileSystemsCombo->currentText();
187 186
188#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // lets test on something cheap 187#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // lets test on something cheap
189#else 188#else
190 currentText = diskDevice = "/dev/fd0"; 189 currentText = diskDevice = "/dev/fd0";
191 umountS = "umount -v /floppy 2>&1"; 190 umountS = "umount -v /floppy 2>&1";
192 remountS = "mount -v /floppy 2>&1"; 191 remountS = "mount -v /floppy 2>&1";
193#endif 192#endif
194 193
195 if( currentText.find("CF",0,TRUE) != -1) 194 if( currentText.find("CF",0,TRUE) != -1)
196 { 195 {
197 umountS = "umount "; 196 umountS = "umount ";
198 remountS = "mount "; 197 remountS = "mount ";
199 198
200 // umountS = "/sbin/cardctl eject"; 199 // umountS = "/sbin/cardctl eject";
201 // remountS = "/sbin/cardctl insert"; 200 // remountS = "/sbin/cardctl insert";
202 } 201 }
203 if( currentText.find("SD",0,TRUE) != -1) 202 if( currentText.find("SD",0,TRUE) != -1)
204 { 203 {
205 umountS = "umount "; 204 umountS = "umount ";
206 remountS = "mount "; 205 remountS = "mount ";
207 // umountS = "/etc/sdcontrol compeject"; 206 // umountS = "/etc/sdcontrol compeject";
208 // remountS = "/etc/sdcontrol insert"; 207 // remountS = "/etc/sdcontrol insert";
209 } 208 }
210 209
211 switch ( QMessageBox::warning(this,tr("Format?") 210 switch ( QMessageBox::warning(this,tr("Format?")
212 , tr("Really format\n") +diskName+" "+ currentText + 211 , tr("Really format\n") +diskName+" "+ currentText +
213 tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs ) 212 tr("\nwith %1 filesystem?\nYou will loose all data!!").arg( fs )
214 ,tr("Yes") 213 ,tr("Yes")
215 ,tr("No") 214 ,tr("No")
216 ,0 215 ,0
217 ,1 216 ,1
218 ,1) ) 217 ,1) )
219 { 218 {
220 case 0: 219 case 0:
221 { 220 {
222 if(fs == "vfat") 221 if(fs == "vfat")
223 cmd = "mkdosfs -v " + diskDevice+" 2>&1"; 222 cmd = "mkdosfs -v " + diskDevice+" 2>&1";
224 else if(fs == "ext2") 223 else if(fs == "ext2")
225 cmd = "mke2fs -v " + diskDevice+" 2>&1"; 224 cmd = "mke2fs -v " + diskDevice+" 2>&1";
226 else 225 else
227 { 226 {
228 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); 227 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok"));
229 break; 228 break;
230 } 229 }
231 // cmd = "ls -l"; 230 // cmd = "ls -l";
232 outDlg = new Output(this, tr("Formatter Output"),FALSE); 231 outDlg = new Output(this, tr("Formatter Output"),FALSE);
233 QPEApplication::showDialog( outDlg); 232 QPEApplication::showDialog( outDlg);
234 qApp->processEvents(); 233 qApp->processEvents();
235 FILE *fp; 234 FILE *fp;
236 char line[130]; 235 char line[130];
237 236
238 237
239 outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) ); 238 outDlg->OutputEdit->append( tr("Trying to umount %1.").arg( currentText) );
240 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 239 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
241 240
242 sleep(1); 241 sleep(1);
243 odebug << "Command is "+umountS << oendl; 242 odebug << "Command is "+umountS << oendl;
244 fp = popen( (const char *) umountS, "r"); 243 fp = popen( (const char *) umountS, "r");
245 // odebug << "" << fp << "" << oendl; 244 // odebug << "" << fp << "" << oendl;
246 if ( !fp ) 245 if ( !fp )
247 { 246 {
248 odebug << "Could not execute '" + umountS + "'! err=" << err << "\n" +(QString)strerror(errno) << oendl; 247 odebug << "Could not execute '" + umountS + "'! err=" << err << "\n" +(QString)strerror(errno) << oendl;
249 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); 248 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
250 pclose(fp); 249 pclose(fp);
251 return; 250 return;