author | zecke <zecke> | 2004-03-14 16:01:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 16:01:52 (UTC) |
commit | f12af18557c8f376f0c6c30e80a85737ff6c592e (patch) (unidiff) | |
tree | d60806f34f4ff6af82491579e80c9ef72cd4071e | |
parent | 13aeeabab5f2a6262b33de83cc9559a49365e325 (diff) | |
download | opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.zip opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.gz opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.bz2 |
Make use of ODP
37 files changed, 115 insertions, 68 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index d2babb4..da21cef 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -1,428 +1,429 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | 31 | ||
32 | #include <opie2/ofiledialog.h> | 32 | #include <opie2/ofiledialog.h> |
33 | 33 | ||
34 | #ifdef QWS | 34 | #ifdef QWS |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | #include <qpe/storage.h> | 39 | #include <qpe/storage.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qdialog.h> | 44 | #include <qdialog.h> |
45 | #include <qfileinfo.h> | 45 | #include <qfileinfo.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qmultilineedit.h> | 47 | #include <qmultilineedit.h> |
48 | #include <qlabel.h> | 48 | #include <qlabel.h> |
49 | #include <qlayout.h> | 49 | #include <qlayout.h> |
50 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
51 | 51 | ||
52 | #include "datamgr.h" | 52 | #include "datamgr.h" |
53 | #include "destination.h" | 53 | #include "destination.h" |
54 | #include "instoptionsimpl.h" | 54 | #include "instoptionsimpl.h" |
55 | #include "installdlgimpl.h" | 55 | #include "installdlgimpl.h" |
56 | #include "ipkg.h" | 56 | #include "ipkg.h" |
57 | #include "utils.h" | 57 | #include "utils.h" |
58 | #include "global.h" | 58 | #include "global.h" |
59 | 59 | ||
60 | using namespace Opie::Ui; | ||
60 | enum { | 61 | enum { |
61 | MAXLINES = 100, | 62 | MAXLINES = 100, |
62 | }; | 63 | }; |
63 | 64 | ||
64 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) | 65 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) |
65 | : QWidget( 0, 0, 0 ) | 66 | : QWidget( 0, 0, 0 ) |
66 | { | 67 | { |
67 | setCaption( title ); | 68 | setCaption( title ); |
68 | init( TRUE ); | 69 | init( TRUE ); |
69 | 70 | ||
70 | pIpkg = 0; | 71 | pIpkg = 0; |
71 | upgradePackages = false; | 72 | upgradePackages = false; |
72 | dataMgr = dataManager; | 73 | dataMgr = dataManager; |
73 | 74 | ||
74 | QString defaultDest = "root"; | 75 | QString defaultDest = "root"; |
75 | #ifdef QWS | 76 | #ifdef QWS |
76 | Config cfg( "aqpkg" ); | 77 | Config cfg( "aqpkg" ); |
77 | cfg.setGroup( "settings" ); | 78 | cfg.setGroup( "settings" ); |
78 | defaultDest = cfg.readEntry( "dest", "root" ); | 79 | defaultDest = cfg.readEntry( "dest", "root" ); |
79 | 80 | ||
80 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 81 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
81 | flags = cfg.readNumEntry( "installFlags", 0 ); | 82 | flags = cfg.readNumEntry( "installFlags", 0 ); |
82 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); | 83 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); |
83 | #else | 84 | #else |
84 | flags = 0; | 85 | flags = 0; |
85 | #endif | 86 | #endif |
86 | 87 | ||
87 | // Output text is read only | 88 | // Output text is read only |
88 | output->setReadOnly( true ); | 89 | output->setReadOnly( true ); |
89 | // QFont f( "helvetica" ); | 90 | // QFont f( "helvetica" ); |
90 | // f.setPointSize( 10 ); | 91 | // f.setPointSize( 10 ); |
91 | // output->setFont( f ); | 92 | // output->setFont( f ); |
92 | 93 | ||
93 | 94 | ||
94 | // setup destination data | 95 | // setup destination data |
95 | int defIndex = 0; | 96 | int defIndex = 0; |
96 | int i; | 97 | int i; |
97 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); | 98 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); |
98 | for ( i = 0; dit.current(); ++dit, ++i ) | 99 | for ( i = 0; dit.current(); ++dit, ++i ) |
99 | { | 100 | { |
100 | destination->insertItem( dit.current()->getDestinationName() ); | 101 | destination->insertItem( dit.current()->getDestinationName() ); |
101 | if ( dit.current()->getDestinationName() == defaultDest ) | 102 | if ( dit.current()->getDestinationName() == defaultDest ) |
102 | defIndex = i; | 103 | defIndex = i; |
103 | } | 104 | } |
104 | 105 | ||
105 | destination->setCurrentItem( defIndex ); | 106 | destination->setCurrentItem( defIndex ); |
106 | 107 | ||
107 | QListIterator<InstallData> it( packageList ); | 108 | QListIterator<InstallData> it( packageList ); |
108 | // setup package data | 109 | // setup package data |
109 | QString remove = tr( "Remove\n" ); | 110 | QString remove = tr( "Remove\n" ); |
110 | QString install = tr( "Install\n" ); | 111 | QString install = tr( "Install\n" ); |
111 | QString upgrade = tr( "Upgrade\n" ); | 112 | QString upgrade = tr( "Upgrade\n" ); |
112 | for ( ; it.current(); ++it ) | 113 | for ( ; it.current(); ++it ) |
113 | { | 114 | { |
114 | InstallData *item = it.current(); | 115 | InstallData *item = it.current(); |
115 | InstallData *newitem = new InstallData(); | 116 | InstallData *newitem = new InstallData(); |
116 | 117 | ||
117 | newitem->option = item->option; | 118 | newitem->option = item->option; |
118 | newitem->packageName = item->packageName; | 119 | newitem->packageName = item->packageName; |
119 | newitem->destination = item->destination; | 120 | newitem->destination = item->destination; |
120 | newitem->recreateLinks = item->recreateLinks; | 121 | newitem->recreateLinks = item->recreateLinks; |
121 | packages.append( newitem ); | 122 | packages.append( newitem ); |
122 | 123 | ||
123 | if ( item->option == "I" ) | 124 | if ( item->option == "I" ) |
124 | { | 125 | { |
125 | install.append( QString( " %1\n" ).arg( item->packageName ) ); | 126 | install.append( QString( " %1\n" ).arg( item->packageName ) ); |
126 | } | 127 | } |
127 | else if ( item->option == "D" ) | 128 | else if ( item->option == "D" ) |
128 | { | 129 | { |
129 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); | 130 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); |
130 | } | 131 | } |
131 | else if ( item->option == "U" || item->option == "R" ) | 132 | else if ( item->option == "U" || item->option == "R" ) |
132 | { | 133 | { |
133 | QString type; | 134 | QString type; |
134 | if ( item->option == "R" ) | 135 | if ( item->option == "R" ) |
135 | type = tr( "(ReInstall)" ); | 136 | type = tr( "(ReInstall)" ); |
136 | else | 137 | else |
137 | type = tr( "(Upgrade)" ); | 138 | type = tr( "(Upgrade)" ); |
138 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); | 139 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); |
139 | } | 140 | } |
140 | } | 141 | } |
141 | 142 | ||
142 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); | 143 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
143 | 144 | ||
144 | displayAvailableSpace( destination->currentText() ); | 145 | displayAvailableSpace( destination->currentText() ); |
145 | } | 146 | } |
146 | 147 | ||
147 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) | 148 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) |
148 | : QWidget( 0, 0, 0 ) | 149 | : QWidget( 0, 0, 0 ) |
149 | { | 150 | { |
150 | setCaption( title ); | 151 | setCaption( title ); |
151 | init( FALSE ); | 152 | init( FALSE ); |
152 | pIpkg = ipkg; | 153 | pIpkg = ipkg; |
153 | output->setText( initialText ); | 154 | output->setText( initialText ); |
154 | } | 155 | } |
155 | 156 | ||
156 | 157 | ||
157 | InstallDlgImpl::~InstallDlgImpl() | 158 | InstallDlgImpl::~InstallDlgImpl() |
158 | { | 159 | { |
159 | if ( pIpkg ) | 160 | if ( pIpkg ) |
160 | delete pIpkg; | 161 | delete pIpkg; |
161 | } | 162 | } |
162 | 163 | ||
163 | void InstallDlgImpl :: init( bool displayextrainfo ) | 164 | void InstallDlgImpl :: init( bool displayextrainfo ) |
164 | { | 165 | { |
165 | QGridLayout *layout = new QGridLayout( this ); | 166 | QGridLayout *layout = new QGridLayout( this ); |
166 | layout->setSpacing( 4 ); | 167 | layout->setSpacing( 4 ); |
167 | layout->setMargin( 4 ); | 168 | layout->setMargin( 4 ); |
168 | 169 | ||
169 | if ( displayextrainfo ) | 170 | if ( displayextrainfo ) |
170 | { | 171 | { |
171 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 172 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
172 | layout->addWidget( label, 0, 0 ); | 173 | layout->addWidget( label, 0, 0 ); |
173 | destination = new QComboBox( FALSE, this ); | 174 | destination = new QComboBox( FALSE, this ); |
174 | layout->addWidget( destination, 0, 1 ); | 175 | layout->addWidget( destination, 0, 1 ); |
175 | connect( destination, SIGNAL( highlighted(const QString&) ), | 176 | connect( destination, SIGNAL( highlighted(const QString&) ), |
176 | this, SLOT( displayAvailableSpace(const QString&) ) ); | 177 | this, SLOT( displayAvailableSpace(const QString&) ) ); |
177 | 178 | ||
178 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | 179 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); |
179 | layout->addWidget( label2, 1, 0 ); | 180 | layout->addWidget( label2, 1, 0 ); |
180 | txtAvailableSpace = new QLabel( "", this ); | 181 | txtAvailableSpace = new QLabel( "", this ); |
181 | layout->addWidget( txtAvailableSpace, 1, 1 ); | 182 | layout->addWidget( txtAvailableSpace, 1, 1 ); |
182 | } | 183 | } |
183 | else | 184 | else |
184 | { | 185 | { |
185 | destination = 0x0; | 186 | destination = 0x0; |
186 | txtAvailableSpace = 0x0; | 187 | txtAvailableSpace = 0x0; |
187 | } | 188 | } |
188 | 189 | ||
189 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 190 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
190 | GroupBox2->layout()->setSpacing( 0 ); | 191 | GroupBox2->layout()->setSpacing( 0 ); |
191 | GroupBox2->layout()->setMargin( 4 ); | 192 | GroupBox2->layout()->setMargin( 4 ); |
192 | 193 | ||
193 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | 194 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); |
194 | output = new QMultiLineEdit( GroupBox2 ); | 195 | output = new QMultiLineEdit( GroupBox2 ); |
195 | GroupBox2Layout->addWidget( output ); | 196 | GroupBox2Layout->addWidget( output ); |
196 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | 197 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); |
197 | 198 | ||
198 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | 199 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); |
199 | layout->addWidget( btnInstall, 3, 0 ); | 200 | layout->addWidget( btnInstall, 3, 0 ); |
200 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | 201 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); |
201 | 202 | ||
202 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 203 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
203 | layout->addWidget( btnOptions, 3, 1 ); | 204 | layout->addWidget( btnOptions, 3, 1 ); |
204 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | 205 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); |
205 | } | 206 | } |
206 | 207 | ||
207 | void InstallDlgImpl :: optionsSelected() | 208 | void InstallDlgImpl :: optionsSelected() |
208 | { | 209 | { |
209 | if ( btnOptions->text() == tr( "Options" ) ) | 210 | if ( btnOptions->text() == tr( "Options" ) ) |
210 | { | 211 | { |
211 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); | 212 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); |
212 | if ( opt.exec() == QDialog::Accepted ) | 213 | if ( opt.exec() == QDialog::Accepted ) |
213 | { | 214 | { |
214 | // set options selected from dialog | 215 | // set options selected from dialog |
215 | flags = opt.getFlags(); | 216 | flags = opt.getFlags(); |
216 | infoLevel = opt.getInfoLevel(); | 217 | infoLevel = opt.getInfoLevel(); |
217 | 218 | ||
218 | #ifdef QWS | 219 | #ifdef QWS |
219 | Config cfg( "aqpkg" ); | 220 | Config cfg( "aqpkg" ); |
220 | cfg.setGroup( "settings" ); | 221 | cfg.setGroup( "settings" ); |
221 | cfg.writeEntry( "installFlags", flags ); | 222 | cfg.writeEntry( "installFlags", flags ); |
222 | cfg.writeEntry( "infoLevel", infoLevel ); | 223 | cfg.writeEntry( "infoLevel", infoLevel ); |
223 | #endif | 224 | #endif |
224 | } | 225 | } |
225 | } | 226 | } |
226 | else // Save output | 227 | else // Save output |
227 | { | 228 | { |
228 | QMap<QString, QStringList> map; | 229 | QMap<QString, QStringList> map; |
229 | map.insert( tr( "All" ), QStringList() ); | 230 | map.insert( tr( "All" ), QStringList() ); |
230 | QStringList text; | 231 | QStringList text; |
231 | text << "text/*"; | 232 | text << "text/*"; |
232 | map.insert(tr( "Text" ), text ); | 233 | map.insert(tr( "Text" ), text ); |
233 | text << "*"; | 234 | text << "*"; |
234 | map.insert( tr( "All" ), text ); | 235 | map.insert( tr( "All" ), text ); |
235 | 236 | ||
236 | QString filename = Opie::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 237 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
237 | if( !filename.isEmpty() ) | 238 | if( !filename.isEmpty() ) |
238 | { | 239 | { |
239 | QString currentFileName = QFileInfo( filename ).fileName(); | 240 | QString currentFileName = QFileInfo( filename ).fileName(); |
240 | DocLnk doc; | 241 | DocLnk doc; |
241 | doc.setType( "text/plain" ); | 242 | doc.setType( "text/plain" ); |
242 | doc.setFile( filename ); | 243 | doc.setFile( filename ); |
243 | doc.setName( currentFileName ); | 244 | doc.setName( currentFileName ); |
244 | FileManager fm; | 245 | FileManager fm; |
245 | fm.saveFile( doc, output->text() ); | 246 | fm.saveFile( doc, output->text() ); |
246 | } | 247 | } |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
250 | void InstallDlgImpl :: installSelected() | 251 | void InstallDlgImpl :: installSelected() |
251 | { | 252 | { |
252 | if ( btnInstall->text() == tr( "Abort" ) ) | 253 | if ( btnInstall->text() == tr( "Abort" ) ) |
253 | { | 254 | { |
254 | if ( pIpkg ) | 255 | if ( pIpkg ) |
255 | { | 256 | { |
256 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); | 257 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
257 | pIpkg->abort(); | 258 | pIpkg->abort(); |
258 | displayText( tr( "**** Process Aborted ****" ) ); | 259 | displayText( tr( "**** Process Aborted ****" ) ); |
259 | } | 260 | } |
260 | 261 | ||
261 | btnInstall->setText( tr( "Close" ) ); | 262 | btnInstall->setText( tr( "Close" ) ); |
262 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 263 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
263 | return; | 264 | return; |
264 | } | 265 | } |
265 | else if ( btnInstall->text() == tr( "Close" ) ) | 266 | else if ( btnInstall->text() == tr( "Close" ) ) |
266 | { | 267 | { |
267 | emit reloadData( this ); | 268 | emit reloadData( this ); |
268 | return; | 269 | return; |
269 | } | 270 | } |
270 | 271 | ||
271 | // Disable buttons | 272 | // Disable buttons |
272 | btnOptions->setEnabled( false ); | 273 | btnOptions->setEnabled( false ); |
273 | // btnInstall->setEnabled( false ); | 274 | // btnInstall->setEnabled( false ); |
274 | 275 | ||
275 | btnInstall->setText( tr( "Abort" ) ); | 276 | btnInstall->setText( tr( "Abort" ) ); |
276 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | 277 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); |
277 | 278 | ||
278 | if ( pIpkg ) | 279 | if ( pIpkg ) |
279 | { | 280 | { |
280 | output->setText( "" ); | 281 | output->setText( "" ); |
281 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); | 282 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
282 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 283 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
283 | pIpkg->runIpkg(); | 284 | pIpkg->runIpkg(); |
284 | } | 285 | } |
285 | else | 286 | else |
286 | { | 287 | { |
287 | output->setText( "" ); | 288 | output->setText( "" ); |
288 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 289 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
289 | QString dest = d->getDestinationName(); | 290 | QString dest = d->getDestinationName(); |
290 | QString destDir = d->getDestinationPath(); | 291 | QString destDir = d->getDestinationPath(); |
291 | int instFlags = flags; | 292 | int instFlags = flags; |
292 | if ( d->linkToRoot() ) | 293 | if ( d->linkToRoot() ) |
293 | instFlags |= MAKE_LINKS; | 294 | instFlags |= MAKE_LINKS; |
294 | 295 | ||
295 | #ifdef QWS | 296 | #ifdef QWS |
296 | // Save settings | 297 | // Save settings |
297 | Config cfg( "aqpkg" ); | 298 | Config cfg( "aqpkg" ); |
298 | cfg.setGroup( "settings" ); | 299 | cfg.setGroup( "settings" ); |
299 | cfg.writeEntry( "dest", dest ); | 300 | cfg.writeEntry( "dest", dest ); |
300 | #endif | 301 | #endif |
301 | 302 | ||
302 | pIpkg = new Ipkg; | 303 | pIpkg = new Ipkg; |
303 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); | 304 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
304 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 305 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
305 | 306 | ||
306 | firstPackage = TRUE; | 307 | firstPackage = TRUE; |
307 | ipkgFinished(); | 308 | ipkgFinished(); |
308 | 309 | ||
309 | // First run through the remove list, then the install list then the upgrade list | 310 | // First run through the remove list, then the install list then the upgrade list |
310 | /* | 311 | /* |
311 | pIpkg->setOption( "remove" ); | 312 | pIpkg->setOption( "remove" ); |
312 | QListIterator<InstallData> it( removeList ); | 313 | QListIterator<InstallData> it( removeList ); |
313 | InstallData *idata; | 314 | InstallData *idata; |
314 | for ( ; it.current(); ++it ) | 315 | for ( ; it.current(); ++it ) |
315 | { | 316 | { |
316 | idata = it.current(); | 317 | idata = it.current(); |
317 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 318 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
318 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 319 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
319 | pIpkg->setPackage( idata->packageName ); | 320 | pIpkg->setPackage( idata->packageName ); |
320 | 321 | ||
321 | int tmpFlags = flags; | 322 | int tmpFlags = flags; |
322 | if ( idata->destination->linkToRoot() ) | 323 | if ( idata->destination->linkToRoot() ) |
323 | tmpFlags |= MAKE_LINKS; | 324 | tmpFlags |= MAKE_LINKS; |
324 | 325 | ||
325 | pIpkg->setFlags( tmpFlags, infoLevel ); | 326 | pIpkg->setFlags( tmpFlags, infoLevel ); |
326 | pIpkg->runIpkg(); | 327 | pIpkg->runIpkg(); |
327 | } | 328 | } |
328 | 329 | ||
329 | pIpkg->setOption( "install" ); | 330 | pIpkg->setOption( "install" ); |
330 | pIpkg->setDestination( dest ); | 331 | pIpkg->setDestination( dest ); |
331 | pIpkg->setDestinationDir( destDir ); | 332 | pIpkg->setDestinationDir( destDir ); |
332 | pIpkg->setFlags( instFlags, infoLevel ); | 333 | pIpkg->setFlags( instFlags, infoLevel ); |
333 | QListIterator<InstallData> it2( installList ); | 334 | QListIterator<InstallData> it2( installList ); |
334 | for ( ; it2.current(); ++it2 ) | 335 | for ( ; it2.current(); ++it2 ) |
335 | { | 336 | { |
336 | pIpkg->setPackage( it2.current()->packageName ); | 337 | pIpkg->setPackage( it2.current()->packageName ); |
337 | pIpkg->runIpkg(); | 338 | pIpkg->runIpkg(); |
338 | } | 339 | } |
339 | 340 | ||
340 | flags |= FORCE_REINSTALL; | 341 | flags |= FORCE_REINSTALL; |
341 | QListIterator<InstallData> it3( updateList ); | 342 | QListIterator<InstallData> it3( updateList ); |
342 | for ( ; it3.current() ; ++it3 ) | 343 | for ( ; it3.current() ; ++it3 ) |
343 | { | 344 | { |
344 | idata = it3.current(); | 345 | idata = it3.current(); |
345 | if ( idata->option == "R" ) | 346 | if ( idata->option == "R" ) |
346 | pIpkg->setOption( "reinstall" ); | 347 | pIpkg->setOption( "reinstall" ); |
347 | else | 348 | else |
348 | pIpkg->setOption( "upgrade" ); | 349 | pIpkg->setOption( "upgrade" ); |
349 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 350 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
350 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 351 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
351 | pIpkg->setPackage( idata->packageName ); | 352 | pIpkg->setPackage( idata->packageName ); |
352 | 353 | ||
353 | int tmpFlags = flags; | 354 | int tmpFlags = flags; |
354 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) | 355 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) |
355 | tmpFlags |= MAKE_LINKS; | 356 | tmpFlags |= MAKE_LINKS; |
356 | pIpkg->setFlags( tmpFlags, infoLevel ); | 357 | pIpkg->setFlags( tmpFlags, infoLevel ); |
357 | pIpkg->runIpkg(); | 358 | pIpkg->runIpkg(); |
358 | } | 359 | } |
359 | 360 | ||
360 | delete pIpkg; | 361 | delete pIpkg; |
361 | pIpkg = 0; | 362 | pIpkg = 0; |
362 | */ | 363 | */ |
363 | } | 364 | } |
364 | } | 365 | } |
365 | 366 | ||
366 | 367 | ||
367 | void InstallDlgImpl :: displayText(const QString &text ) | 368 | void InstallDlgImpl :: displayText(const QString &text ) |
368 | { | 369 | { |
369 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); | 370 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
370 | 371 | ||
371 | /* Set a max line count for the QMultiLineEdit, as users have reported | 372 | /* Set a max line count for the QMultiLineEdit, as users have reported |
372 | * performance issues when line count gets extreme. | 373 | * performance issues when line count gets extreme. |
373 | */ | 374 | */ |
374 | if(output->numLines() >= MAXLINES) | 375 | if(output->numLines() >= MAXLINES) |
375 | output->removeLine(0); | 376 | output->removeLine(0); |
376 | output->setText( newtext ); | 377 | output->setText( newtext ); |
377 | output->setCursorPosition( output->numLines(), 0 ); | 378 | output->setCursorPosition( output->numLines(), 0 ); |
378 | } | 379 | } |
379 | 380 | ||
380 | 381 | ||
381 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 382 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
382 | { | 383 | { |
383 | Destination *d = dataMgr->getDestination( text ); | 384 | Destination *d = dataMgr->getDestination( text ); |
384 | QString destDir = d->getDestinationPath(); | 385 | QString destDir = d->getDestinationPath(); |
385 | 386 | ||
386 | long blockSize = 0; | 387 | long blockSize = 0; |
387 | long totalBlocks = 0; | 388 | long totalBlocks = 0; |
388 | long availBlocks = 0; | 389 | long availBlocks = 0; |
389 | QString space; | 390 | QString space; |
390 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | 391 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) |
391 | { | 392 | { |
392 | long mult = blockSize / 1024; | 393 | long mult = blockSize / 1024; |
393 | long div = 1024 / blockSize; | 394 | long div = 1024 / blockSize; |
394 | 395 | ||
395 | if ( !mult ) mult = 1; | 396 | if ( !mult ) mult = 1; |
396 | if ( !div ) div = 1; | 397 | if ( !div ) div = 1; |
397 | long avail = availBlocks * mult / div; | 398 | long avail = availBlocks * mult / div; |
398 | 399 | ||
399 | space = tr( "%1 Kb" ).arg( avail ); | 400 | space = tr( "%1 Kb" ).arg( avail ); |
400 | } | 401 | } |
401 | else | 402 | else |
402 | space = tr( "Unknown" ); | 403 | space = tr( "Unknown" ); |
403 | 404 | ||
404 | if ( txtAvailableSpace ) | 405 | if ( txtAvailableSpace ) |
405 | txtAvailableSpace->setText( space ); | 406 | txtAvailableSpace->setText( space ); |
406 | } | 407 | } |
407 | 408 | ||
408 | void InstallDlgImpl :: ipkgFinished() | 409 | void InstallDlgImpl :: ipkgFinished() |
409 | { | 410 | { |
410 | InstallData *item; | 411 | InstallData *item; |
411 | if ( firstPackage ) | 412 | if ( firstPackage ) |
412 | item = packages.first(); | 413 | item = packages.first(); |
413 | else | 414 | else |
414 | { | 415 | { |
415 | // Create symlinks if necessary before moving on to next package | 416 | // Create symlinks if necessary before moving on to next package |
416 | pIpkg->createSymLinks(); | 417 | pIpkg->createSymLinks(); |
417 | 418 | ||
418 | item = packages.next(); | 419 | item = packages.next(); |
419 | } | 420 | } |
420 | 421 | ||
421 | firstPackage = FALSE; | 422 | firstPackage = FALSE; |
422 | if ( item ) | 423 | if ( item ) |
423 | { | 424 | { |
424 | pIpkg->setPackage( item->packageName ); | 425 | pIpkg->setPackage( item->packageName ); |
425 | int tmpFlags = flags; | 426 | int tmpFlags = flags; |
426 | 427 | ||
427 | if ( item->option == "I" ) | 428 | if ( item->option == "I" ) |
428 | { | 429 | { |
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 866afed..0091a3b 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -1,489 +1,490 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <opie2/oprocess.h> | 30 | #include <opie2/oprocess.h> |
31 | 31 | ||
32 | #ifdef QWS | 32 | #ifdef QWS |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | 40 | ||
41 | #include "utils.h" | 41 | #include "utils.h" |
42 | #include "ipkg.h" | 42 | #include "ipkg.h" |
43 | #include "global.h" | 43 | #include "global.h" |
44 | 44 | ||
45 | using namespace Opie::Core; | ||
45 | Ipkg :: Ipkg() | 46 | Ipkg :: Ipkg() |
46 | { | 47 | { |
47 | proc = 0; | 48 | proc = 0; |
48 | } | 49 | } |
49 | 50 | ||
50 | Ipkg :: ~Ipkg() | 51 | Ipkg :: ~Ipkg() |
51 | { | 52 | { |
52 | } | 53 | } |
53 | 54 | ||
54 | // Option is what we are going to do - install, upgrade, download, reinstall | 55 | // Option is what we are going to do - install, upgrade, download, reinstall |
55 | // package is the package name to install - either a fully qualified path and ipk | 56 | // package is the package name to install - either a fully qualified path and ipk |
56 | // file (if stored locally) or just the name of the package (for a network package) | 57 | // file (if stored locally) or just the name of the package (for a network package) |
57 | // packageName is the package name - (for a network package this will be the same as | 58 | // packageName is the package name - (for a network package this will be the same as |
58 | // package parameter) | 59 | // package parameter) |
59 | // dest is the destination alias (from ipk.conf) | 60 | // dest is the destination alias (from ipk.conf) |
60 | // destDir is the dir that the destination alias points to (used to link to root) | 61 | // destDir is the dir that the destination alias points to (used to link to root) |
61 | // flags is the ipkg options flags | 62 | // flags is the ipkg options flags |
62 | // dir is the directory to run ipkg in (defaults to "") | 63 | // dir is the directory to run ipkg in (defaults to "") |
63 | void Ipkg :: runIpkg() | 64 | void Ipkg :: runIpkg() |
64 | { | 65 | { |
65 | error = false; | 66 | error = false; |
66 | QStringList commands; | 67 | QStringList commands; |
67 | 68 | ||
68 | QDir::setCurrent( "/tmp" ); | 69 | QDir::setCurrent( "/tmp" ); |
69 | 70 | ||
70 | if ( runtimeDir != "" ) | 71 | if ( runtimeDir != "" ) |
71 | { | 72 | { |
72 | commands << "cd "; | 73 | commands << "cd "; |
73 | commands << runtimeDir; | 74 | commands << runtimeDir; |
74 | commands << ";"; | 75 | commands << ";"; |
75 | } | 76 | } |
76 | commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; | 77 | commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; |
77 | 78 | ||
78 | // only set the destination for an install operation | 79 | // only set the destination for an install operation |
79 | if ( option == "install" ) | 80 | if ( option == "install" ) |
80 | commands << "-dest" << destination; | 81 | commands << "-dest" << destination; |
81 | 82 | ||
82 | 83 | ||
83 | if ( option != "update" && option != "download" ) | 84 | if ( option != "update" && option != "download" ) |
84 | { | 85 | { |
85 | if ( flags & FORCE_DEPENDS ) | 86 | if ( flags & FORCE_DEPENDS ) |
86 | commands << "-force-depends"; | 87 | commands << "-force-depends"; |
87 | if ( flags & FORCE_REINSTALL ) | 88 | if ( flags & FORCE_REINSTALL ) |
88 | commands << "-force-reinstall"; | 89 | commands << "-force-reinstall"; |
89 | if ( flags & FORCE_REMOVE ) | 90 | if ( flags & FORCE_REMOVE ) |
90 | commands << "-force-removal-of-essential-packages"; | 91 | commands << "-force-removal-of-essential-packages"; |
91 | if ( flags & FORCE_OVERWRITE ) | 92 | if ( flags & FORCE_OVERWRITE ) |
92 | commands << "-force-overwrite"; | 93 | commands << "-force-overwrite"; |
93 | if ( infoLevel == 3 ) | 94 | if ( infoLevel == 3 ) |
94 | commands << "-verbose_wget"; | 95 | commands << "-verbose_wget"; |
95 | 96 | ||
96 | // Handle make links | 97 | // Handle make links |
97 | // Rules - If make links is switched on, create links to root | 98 | // Rules - If make links is switched on, create links to root |
98 | // if destDir is NOT / | 99 | // if destDir is NOT / |
99 | if ( flags & MAKE_LINKS ) | 100 | if ( flags & MAKE_LINKS ) |
100 | { | 101 | { |
101 | // If destDir == / turn off make links as package is being insalled | 102 | // If destDir == / turn off make links as package is being insalled |
102 | // to root already. | 103 | // to root already. |
103 | if ( destDir == "/" ) | 104 | if ( destDir == "/" ) |
104 | flags ^= MAKE_LINKS; | 105 | flags ^= MAKE_LINKS; |
105 | } | 106 | } |
106 | } | 107 | } |
107 | 108 | ||
108 | #ifdef X86 | 109 | #ifdef X86 |
109 | commands << "-f"; | 110 | commands << "-f"; |
110 | commands << IPKG_CONF; | 111 | commands << IPKG_CONF; |
111 | #endif | 112 | #endif |
112 | 113 | ||
113 | 114 | ||
114 | if ( option == "reinstall" ) | 115 | if ( option == "reinstall" ) |
115 | commands << "install"; | 116 | commands << "install"; |
116 | else | 117 | else |
117 | commands << option; | 118 | commands << option; |
118 | if ( package != "" ) | 119 | if ( package != "" ) |
119 | commands << package; | 120 | commands << package; |
120 | 121 | ||
121 | 122 | ||
122 | if ( package != "" ) | 123 | if ( package != "" ) |
123 | emit outputText( tr( "Dealing with package %1" ).arg( package) ); | 124 | emit outputText( tr( "Dealing with package %1" ).arg( package) ); |
124 | 125 | ||
125 | qApp->processEvents(); | 126 | qApp->processEvents(); |
126 | 127 | ||
127 | // If we are removing, reinstalling or upgrading packages and make links option is selected | 128 | // If we are removing, reinstalling or upgrading packages and make links option is selected |
128 | // create the links | 129 | // create the links |
129 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) | 130 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) |
130 | { | 131 | { |
131 | createLinks = false; | 132 | createLinks = false; |
132 | if ( flags & MAKE_LINKS ) | 133 | if ( flags & MAKE_LINKS ) |
133 | { | 134 | { |
134 | emit outputText( tr( "Removing symbolic links...\n" ) ); | 135 | emit outputText( tr( "Removing symbolic links...\n" ) ); |
135 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 136 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
136 | emit outputText( QString( " " ) ); | 137 | emit outputText( QString( " " ) ); |
137 | } | 138 | } |
138 | } | 139 | } |
139 | 140 | ||
140 | // Execute command | 141 | // Execute command |
141 | dependantPackages = new QList<QString>; | 142 | dependantPackages = new QList<QString>; |
142 | dependantPackages->setAutoDelete( true ); | 143 | dependantPackages->setAutoDelete( true ); |
143 | 144 | ||
144 | executeIpkgCommand( commands, option ); | 145 | executeIpkgCommand( commands, option ); |
145 | 146 | ||
146 | } | 147 | } |
147 | 148 | ||
148 | void Ipkg :: createSymLinks() | 149 | void Ipkg :: createSymLinks() |
149 | { | 150 | { |
150 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) | 151 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) |
151 | { | 152 | { |
152 | // If we are not removing packages and make links option is selected | 153 | // If we are not removing packages and make links option is selected |
153 | // create the links | 154 | // create the links |
154 | createLinks = true; | 155 | createLinks = true; |
155 | if ( flags & MAKE_LINKS ) | 156 | if ( flags & MAKE_LINKS ) |
156 | { | 157 | { |
157 | emit outputText( " " ); | 158 | emit outputText( " " ); |
158 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); | 159 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); |
159 | 160 | ||
160 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 161 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
161 | 162 | ||
162 | // link dependant packages that were installed with this release | 163 | // link dependant packages that were installed with this release |
163 | QString *pkg; | 164 | QString *pkg; |
164 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) | 165 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) |
165 | { | 166 | { |
166 | if ( *pkg == package ) | 167 | if ( *pkg == package ) |
167 | continue; | 168 | continue; |
168 | emit outputText( " " ); | 169 | emit outputText( " " ); |
169 | emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) ); | 170 | emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) ); |
170 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); | 171 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); |
171 | } | 172 | } |
172 | } | 173 | } |
173 | } | 174 | } |
174 | 175 | ||
175 | delete dependantPackages; | 176 | delete dependantPackages; |
176 | 177 | ||
177 | emit outputText( tr("Finished") ); | 178 | emit outputText( tr("Finished") ); |
178 | emit outputText( "" ); | 179 | emit outputText( "" ); |
179 | } | 180 | } |
180 | 181 | ||
181 | void Ipkg :: removeStatusEntry() | 182 | void Ipkg :: removeStatusEntry() |
182 | { | 183 | { |
183 | QString statusFile = destDir; | 184 | QString statusFile = destDir; |
184 | if ( statusFile.right( 1 ) != "/" ) | 185 | if ( statusFile.right( 1 ) != "/" ) |
185 | statusFile.append( "/" ); | 186 | statusFile.append( "/" ); |
186 | statusFile.append( "usr/lib/ipkg/status" ); | 187 | statusFile.append( "usr/lib/ipkg/status" ); |
187 | QString outStatusFile = statusFile; | 188 | QString outStatusFile = statusFile; |
188 | outStatusFile.append( ".tmp" ); | 189 | outStatusFile.append( ".tmp" ); |
189 | 190 | ||
190 | emit outputText( "" ); | 191 | emit outputText( "" ); |
191 | emit outputText( tr("Removing status entry...") ); | 192 | emit outputText( tr("Removing status entry...") ); |
192 | QString tempstr = tr("status file - "); | 193 | QString tempstr = tr("status file - "); |
193 | tempstr.append( statusFile ); | 194 | tempstr.append( statusFile ); |
194 | emit outputText( tempstr ); | 195 | emit outputText( tempstr ); |
195 | tempstr = tr("package - "); | 196 | tempstr = tr("package - "); |
196 | tempstr.append( package ); | 197 | tempstr.append( package ); |
197 | emit outputText( tempstr ); | 198 | emit outputText( tempstr ); |
198 | 199 | ||
199 | QFile readFile( statusFile ); | 200 | QFile readFile( statusFile ); |
200 | QFile writeFile( outStatusFile ); | 201 | QFile writeFile( outStatusFile ); |
201 | 202 | ||
202 | if ( !readFile.open( IO_ReadOnly ) ) | 203 | if ( !readFile.open( IO_ReadOnly ) ) |
203 | { | 204 | { |
204 | tempstr = tr("Couldn't open status file - "); | 205 | tempstr = tr("Couldn't open status file - "); |
205 | tempstr.append( statusFile ); | 206 | tempstr.append( statusFile ); |
206 | emit outputText( tempstr ); | 207 | emit outputText( tempstr ); |
207 | return; | 208 | return; |
208 | } | 209 | } |
209 | 210 | ||
210 | if ( !writeFile.open( IO_WriteOnly ) ) | 211 | if ( !writeFile.open( IO_WriteOnly ) ) |
211 | { | 212 | { |
212 | tempstr = tr("Couldn't create tempory status file - "); | 213 | tempstr = tr("Couldn't create tempory status file - "); |
213 | tempstr.append( outStatusFile ); | 214 | tempstr.append( outStatusFile ); |
214 | emit outputText( tempstr ); | 215 | emit outputText( tempstr ); |
215 | return; | 216 | return; |
216 | } | 217 | } |
217 | 218 | ||
218 | int i = 0; | 219 | int i = 0; |
219 | 220 | ||
220 | QTextStream readStream( &readFile ); | 221 | QTextStream readStream( &readFile ); |
221 | QTextStream writeStream( &writeFile ); | 222 | QTextStream writeStream( &writeFile ); |
222 | QString line; | 223 | QString line; |
223 | 224 | ||
224 | char k[21]; | 225 | char k[21]; |
225 | char v[1001]; | 226 | char v[1001]; |
226 | QString key; | 227 | QString key; |
227 | QString value; | 228 | QString value; |
228 | 229 | ||
229 | while ( !readStream.atEnd() ) | 230 | while ( !readStream.atEnd() ) |
230 | { | 231 | { |
231 | //read new line | 232 | //read new line |
232 | line = readStream.readLine(); | 233 | line = readStream.readLine(); |
233 | 234 | ||
234 | if ( line.contains( ":", TRUE ) ) | 235 | if ( line.contains( ":", TRUE ) ) |
235 | { | 236 | { |
236 | //grep key and value from line | 237 | //grep key and value from line |
237 | k[0] = '\0'; | 238 | k[0] = '\0'; |
238 | v[0] = '\0'; | 239 | v[0] = '\0'; |
239 | sscanf( line, "%[^:]: %[^\n]", k, v ); | 240 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
240 | key = k; | 241 | key = k; |
241 | value = v; | 242 | value = v; |
242 | key = key.stripWhiteSpace(); | 243 | key = key.stripWhiteSpace(); |
243 | value = value.stripWhiteSpace(); | 244 | value = value.stripWhiteSpace(); |
244 | } else { | 245 | } else { |
245 | key = ""; | 246 | key = ""; |
246 | value = ""; | 247 | value = ""; |
247 | } | 248 | } |
248 | 249 | ||
249 | if ( key == "Package" && value == package ) | 250 | if ( key == "Package" && value == package ) |
250 | { | 251 | { |
251 | //skip lines from the deleted package | 252 | //skip lines from the deleted package |
252 | while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) ) | 253 | while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) ) |
253 | { | 254 | { |
254 | line = readStream.readLine(); | 255 | line = readStream.readLine(); |
255 | } | 256 | } |
256 | } else { | 257 | } else { |
257 | 258 | ||
258 | //write other lines into the tempfile | 259 | //write other lines into the tempfile |
259 | writeStream << line << "\n"; | 260 | writeStream << line << "\n"; |
260 | 261 | ||
261 | // Improve UI responsiveness | 262 | // Improve UI responsiveness |
262 | i++; | 263 | i++; |
263 | if ( ( i % 50 ) == 0 ) | 264 | if ( ( i % 50 ) == 0 ) |
264 | qApp->processEvents(); | 265 | qApp->processEvents(); |
265 | } | 266 | } |
266 | } | 267 | } |
267 | 268 | ||
268 | readFile.close(); | 269 | readFile.close(); |
269 | writeFile.close(); | 270 | writeFile.close(); |
270 | 271 | ||
271 | // Remove old status file and put tmp stats file in its place | 272 | // Remove old status file and put tmp stats file in its place |
272 | remove( statusFile ); | 273 | remove( statusFile ); |
273 | rename( outStatusFile, statusFile ); | 274 | rename( outStatusFile, statusFile ); |
274 | } | 275 | } |
275 | 276 | ||
276 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | 277 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) |
277 | { | 278 | { |
278 | // If one is already running - should never be but just to be safe | 279 | // If one is already running - should never be but just to be safe |
279 | if ( proc ) | 280 | if ( proc ) |
280 | { | 281 | { |
281 | delete proc; | 282 | delete proc; |
282 | proc = 0; | 283 | proc = 0; |
283 | } | 284 | } |
284 | 285 | ||
285 | // OK we're gonna use OProcess to run this thing | 286 | // OK we're gonna use OProcess to run this thing |
286 | proc = new OProcess(); | 287 | proc = new OProcess(); |
287 | aborted = false; | 288 | aborted = false; |
288 | 289 | ||
289 | 290 | ||
290 | // Connect up our slots | 291 | // Connect up our slots |
291 | connect(proc, SIGNAL(processExited(OProcess*)), | 292 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), |
292 | this, SLOT( processFinished())); | 293 | this, SLOT( processFinished())); |
293 | 294 | ||
294 | connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), | 295 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
295 | this, SLOT(commandStdout(OProcess*,char*,int))); | 296 | this, SLOT(commandStdout(OProcess*,char*,int))); |
296 | 297 | ||
297 | connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), | 298 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
298 | this, SLOT(commandStderr(OProcess*,char*,int))); | 299 | this, SLOT(commandStderr(OProcess*,char*,int))); |
299 | 300 | ||
300 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) | 301 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) |
301 | { | 302 | { |
302 | *proc << (*it).latin1(); | 303 | *proc << (*it).latin1(); |
303 | } | 304 | } |
304 | 305 | ||
305 | // Start the process going | 306 | // Start the process going |
306 | finished = false; | 307 | finished = false; |
307 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) | 308 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) |
308 | { | 309 | { |
309 | emit outputText( tr("Couldn't start ipkg process" ) ); | 310 | emit outputText( tr("Couldn't start ipkg process" ) ); |
310 | } | 311 | } |
311 | } | 312 | } |
312 | 313 | ||
313 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | 314 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) |
314 | { | 315 | { |
315 | QString lineStr = buffer; | 316 | QString lineStr = buffer; |
316 | if ( lineStr[buflen-1] == '\n' ) | 317 | if ( lineStr[buflen-1] == '\n' ) |
317 | buflen --; | 318 | buflen --; |
318 | lineStr = lineStr.left( buflen ); | 319 | lineStr = lineStr.left( buflen ); |
319 | emit outputText( lineStr ); | 320 | emit outputText( lineStr ); |
320 | 321 | ||
321 | // check if we are installing dependant packages | 322 | // check if we are installing dependant packages |
322 | if ( option == "install" || option == "reinstall" ) | 323 | if ( option == "install" || option == "reinstall" ) |
323 | { | 324 | { |
324 | // Need to keep track of any dependant packages that get installed | 325 | // Need to keep track of any dependant packages that get installed |
325 | // so that we can create links to them as necessary | 326 | // so that we can create links to them as necessary |
326 | if ( lineStr.startsWith( "Installing " ) ) | 327 | if ( lineStr.startsWith( "Installing " ) ) |
327 | { | 328 | { |
328 | int start = lineStr.find( " " ) + 1; | 329 | int start = lineStr.find( " " ) + 1; |
329 | int end = lineStr.find( " ", start ); | 330 | int end = lineStr.find( " ", start ); |
330 | QString *package = new QString( lineStr.mid( start, end-start ) ); | 331 | QString *package = new QString( lineStr.mid( start, end-start ) ); |
331 | dependantPackages->append( package ); | 332 | dependantPackages->append( package ); |
332 | } | 333 | } |
333 | } | 334 | } |
334 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && | 335 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && |
335 | lineStr.find( "is depended upon by packages:" ) != -1 ) | 336 | lineStr.find( "is depended upon by packages:" ) != -1 ) |
336 | { | 337 | { |
337 | // Ipkg should send this to STDERR, but doesn't - so trap here | 338 | // Ipkg should send this to STDERR, but doesn't - so trap here |
338 | error = true; | 339 | error = true; |
339 | } | 340 | } |
340 | 341 | ||
341 | buffer[0] = '\0'; | 342 | buffer[0] = '\0'; |
342 | } | 343 | } |
343 | 344 | ||
344 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) | 345 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) |
345 | { | 346 | { |
346 | QString lineStr = buffer; | 347 | QString lineStr = buffer; |
347 | if ( lineStr[buflen-1] == '\n' ) | 348 | if ( lineStr[buflen-1] == '\n' ) |
348 | buflen --; | 349 | buflen --; |
349 | lineStr=lineStr.left( buflen ); | 350 | lineStr=lineStr.left( buflen ); |
350 | emit outputText( lineStr ); | 351 | emit outputText( lineStr ); |
351 | buffer[0] = '\0'; | 352 | buffer[0] = '\0'; |
352 | error = true; | 353 | error = true; |
353 | } | 354 | } |
354 | 355 | ||
355 | void Ipkg::processFinished() | 356 | void Ipkg::processFinished() |
356 | { | 357 | { |
357 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file | 358 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file |
358 | // to workaround an ipkg bug which stops reinstall to a different location | 359 | // to workaround an ipkg bug which stops reinstall to a different location |
359 | 360 | ||
360 | if ( !error && option == "remove" ) | 361 | if ( !error && option == "remove" ) |
361 | removeStatusEntry(); | 362 | removeStatusEntry(); |
362 | 363 | ||
363 | delete proc; | 364 | delete proc; |
364 | proc = 0; | 365 | proc = 0; |
365 | finished = true; | 366 | finished = true; |
366 | 367 | ||
367 | emit ipkgFinished(); | 368 | emit ipkgFinished(); |
368 | } | 369 | } |
369 | 370 | ||
370 | 371 | ||
371 | void Ipkg :: abort() | 372 | void Ipkg :: abort() |
372 | { | 373 | { |
373 | if ( proc ) | 374 | if ( proc ) |
374 | { | 375 | { |
375 | proc->kill(); | 376 | proc->kill(); |
376 | aborted = true; | 377 | aborted = true; |
377 | } | 378 | } |
378 | } | 379 | } |
379 | 380 | ||
380 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) | 381 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) |
381 | { | 382 | { |
382 | if ( dest == "root" || dest == "/" ) | 383 | if ( dest == "root" || dest == "/" ) |
383 | return; | 384 | return; |
384 | 385 | ||
385 | qApp->processEvents(); | 386 | qApp->processEvents(); |
386 | QStringList *fileList = getList( packFileName, destDir ); | 387 | QStringList *fileList = getList( packFileName, destDir ); |
387 | qApp->processEvents(); | 388 | qApp->processEvents(); |
388 | processFileList( fileList, destDir ); | 389 | processFileList( fileList, destDir ); |
389 | delete fileList; | 390 | delete fileList; |
390 | } | 391 | } |
391 | 392 | ||
392 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 393 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) |
393 | { | 394 | { |
394 | QString packageFileDir = destDir; | 395 | QString packageFileDir = destDir; |
395 | packageFileDir.append( "/usr/lib/ipkg/info/" ); | 396 | packageFileDir.append( "/usr/lib/ipkg/info/" ); |
396 | packageFileDir.append( packageFilename ); | 397 | packageFileDir.append( packageFilename ); |
397 | packageFileDir.append( ".list" ); | 398 | packageFileDir.append( ".list" ); |
398 | QFile f( packageFileDir ); | 399 | QFile f( packageFileDir ); |
399 | 400 | ||
400 | if ( !f.open(IO_ReadOnly) ) | 401 | if ( !f.open(IO_ReadOnly) ) |
401 | { | 402 | { |
402 | // Couldn't open from dest, try from / | 403 | // Couldn't open from dest, try from / |
403 | f.close(); | 404 | f.close(); |
404 | 405 | ||
405 | packageFileDir = "/usr/lib/ipkg/info/"; | 406 | packageFileDir = "/usr/lib/ipkg/info/"; |
406 | packageFileDir.append( packageFilename ); | 407 | packageFileDir.append( packageFilename ); |
407 | packageFileDir.append( ".list" ); | 408 | packageFileDir.append( ".list" ); |
408 | f.setName( packageFileDir ); | 409 | f.setName( packageFileDir ); |
409 | if ( ! f.open(IO_ReadOnly) ) | 410 | if ( ! f.open(IO_ReadOnly) ) |
410 | { | 411 | { |
411 | QString tempstr = tr("Could not open :"); | 412 | QString tempstr = tr("Could not open :"); |
412 | tempstr.append( packageFileDir ); | 413 | tempstr.append( packageFileDir ); |
413 | emit outputText( tempstr ); | 414 | emit outputText( tempstr ); |
414 | return (QStringList*)0; | 415 | return (QStringList*)0; |
415 | } | 416 | } |
416 | } | 417 | } |
417 | QStringList *fileList = new QStringList(); | 418 | QStringList *fileList = new QStringList(); |
418 | QTextStream t( &f ); | 419 | QTextStream t( &f ); |
419 | while ( !t.eof() ) | 420 | while ( !t.eof() ) |
420 | *fileList += t.readLine(); | 421 | *fileList += t.readLine(); |
421 | 422 | ||
422 | f.close(); | 423 | f.close(); |
423 | return fileList; | 424 | return fileList; |
424 | } | 425 | } |
425 | 426 | ||
426 | void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) | 427 | void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) |
427 | { | 428 | { |
428 | if ( !fileList || fileList->isEmpty() ) | 429 | if ( !fileList || fileList->isEmpty() ) |
429 | return; | 430 | return; |
430 | 431 | ||
431 | QString baseDir = ROOT; | 432 | QString baseDir = ROOT; |
432 | 433 | ||
433 | if ( createLinks == true ) | 434 | if ( createLinks == true ) |
434 | { | 435 | { |
435 | for ( uint i=0; i < fileList->count(); i++ ) | 436 | for ( uint i=0; i < fileList->count(); i++ ) |
436 | { | 437 | { |
437 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 438 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
438 | qApp->processEvents(); | 439 | qApp->processEvents(); |
439 | } | 440 | } |
440 | } | 441 | } |
441 | else | 442 | else |
442 | { | 443 | { |
443 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) | 444 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) |
444 | { | 445 | { |
445 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 446 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
446 | qApp->processEvents(); | 447 | qApp->processEvents(); |
447 | } | 448 | } |
448 | } | 449 | } |
449 | } | 450 | } |
450 | 451 | ||
451 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) | 452 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) |
452 | { | 453 | { |
453 | 454 | ||
454 | QString sourceFile = baseDir; | 455 | QString sourceFile = baseDir; |
455 | sourceFile.append( file ); | 456 | sourceFile.append( file ); |
456 | 457 | ||
457 | QString linkFile = destDir; | 458 | QString linkFile = destDir; |
458 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) | 459 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) |
459 | { | 460 | { |
460 | linkFile.append( file.mid( 1 ) ); | 461 | linkFile.append( file.mid( 1 ) ); |
461 | } | 462 | } |
462 | else | 463 | else |
463 | { | 464 | { |
464 | linkFile.append( file ); | 465 | linkFile.append( file ); |
465 | } | 466 | } |
466 | QString text; | 467 | QString text; |
467 | if ( createLinks ) | 468 | if ( createLinks ) |
468 | { | 469 | { |
469 | // If this file is a directory (ends with a /) and it doesn't exist, | 470 | // If this file is a directory (ends with a /) and it doesn't exist, |
470 | // we need to create it | 471 | // we need to create it |
471 | if ( file.right(1) == "/" ) | 472 | if ( file.right(1) == "/" ) |
472 | { | 473 | { |
473 | QFileInfo f( linkFile ); | 474 | QFileInfo f( linkFile ); |
474 | if ( !f.exists() ) | 475 | if ( !f.exists() ) |
475 | { | 476 | { |
476 | QString tempstr = tr("Creating directory "); | 477 | QString tempstr = tr("Creating directory "); |
477 | tempstr.append( linkFile ); | 478 | tempstr.append( linkFile ); |
478 | emit outputText( tempstr ); | 479 | emit outputText( tempstr ); |
479 | QDir d; | 480 | QDir d; |
480 | d.mkdir( linkFile, true ); | 481 | d.mkdir( linkFile, true ); |
481 | } | 482 | } |
482 | // else | 483 | // else |
483 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); | 484 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); |
484 | 485 | ||
485 | } | 486 | } |
486 | else | 487 | else |
487 | { | 488 | { |
488 | int rc = symlink( sourceFile, linkFile ); | 489 | int rc = symlink( sourceFile, linkFile ); |
489 | text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ). | 490 | text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ). |
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h index f892038..e216d17 100644 --- a/noncore/settings/aqpkg/ipkg.h +++ b/noncore/settings/aqpkg/ipkg.h | |||
@@ -1,104 +1,104 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef IPKG_H | 30 | #ifndef IPKG_H |
31 | #define IPKG_H | 31 | #define IPKG_H |
32 | 32 | ||
33 | 33 | ||
34 | /** | 34 | /** |
35 | *@author Andy Qua | 35 | *@author Andy Qua |
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | #include <qstring.h> | 39 | #include <qstring.h> |
40 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
41 | #include <qlist.h> | 41 | #include <qlist.h> |
42 | 42 | ||
43 | #define FORCE_DEPENDS 0x0001 | 43 | #define FORCE_DEPENDS 0x0001 |
44 | #define FORCE_REMOVE 0x0002 | 44 | #define FORCE_REMOVE 0x0002 |
45 | #define FORCE_REINSTALL 0x0004 | 45 | #define FORCE_REINSTALL 0x0004 |
46 | #define FORCE_OVERWRITE 0x0008 | 46 | #define FORCE_OVERWRITE 0x0008 |
47 | #define MAKE_LINKS 0x0010 | 47 | #define MAKE_LINKS 0x0010 |
48 | #define VERBOSE_WGET 0x0020 | 48 | #define VERBOSE_WGET 0x0020 |
49 | 49 | ||
50 | class OProcess; | 50 | namespace Opie {namespace Core {class OProcess;}} |
51 | 51 | ||
52 | class Ipkg : public QObject | 52 | class Ipkg : public QObject |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | public: | 55 | public: |
56 | Ipkg(); | 56 | Ipkg(); |
57 | ~Ipkg(); | 57 | ~Ipkg(); |
58 | void runIpkg(); | 58 | void runIpkg(); |
59 | void createSymLinks(); | 59 | void createSymLinks(); |
60 | 60 | ||
61 | void setOption( const char *opt ) { option = opt; } | 61 | void setOption( const char *opt ) { option = opt; } |
62 | void setPackage( const char *pkg ) { package = pkg; } | 62 | void setPackage( const char *pkg ) { package = pkg; } |
63 | void setDestination( const char *dest ) { destination = dest; } | 63 | void setDestination( const char *dest ) { destination = dest; } |
64 | void setDestinationDir( const char *dir ) { destDir = dir; } | 64 | void setDestinationDir( const char *dir ) { destDir = dir; } |
65 | void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } | 65 | void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } |
66 | void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } | 66 | void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } |
67 | 67 | ||
68 | signals: | 68 | signals: |
69 | void outputText( const QString &text ); | 69 | void outputText( const QString &text ); |
70 | void ipkgFinished(); | 70 | void ipkgFinished(); |
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | void commandStdout(OProcess*, char *buffer, int buflen); | 73 | void commandStdout(Opie::Core::OProcess*, char *buffer, int buflen); |
74 | void commandStderr(OProcess*, char *buffer, int buflen); | 74 | void commandStderr(Opie::Core::OProcess*, char *buffer, int buflen); |
75 | void processFinished(); | 75 | void processFinished(); |
76 | void abort(); | 76 | void abort(); |
77 | 77 | ||
78 | 78 | ||
79 | private: | 79 | private: |
80 | bool createLinks; | 80 | bool createLinks; |
81 | bool aborted; | 81 | bool aborted; |
82 | bool error; | 82 | bool error; |
83 | QString option; | 83 | QString option; |
84 | QString package; | 84 | QString package; |
85 | QString destination; | 85 | QString destination; |
86 | QString destDir; | 86 | QString destDir; |
87 | QString runtimeDir; | 87 | QString runtimeDir; |
88 | OProcess *proc; | 88 | Opie::Core::OProcess *proc; |
89 | int flags; | 89 | int flags; |
90 | int infoLevel; | 90 | int infoLevel; |
91 | bool finished; | 91 | bool finished; |
92 | 92 | ||
93 | QList<QString> *dependantPackages; | 93 | QList<QString> *dependantPackages; |
94 | 94 | ||
95 | int executeIpkgCommand( QStringList &cmd, const QString option ); | 95 | int executeIpkgCommand( QStringList &cmd, const QString option ); |
96 | void removeStatusEntry(); | 96 | void removeStatusEntry(); |
97 | void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); | 97 | void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); |
98 | QStringList* getList( const QString &packageFilename, const QString &destDir ); | 98 | QStringList* getList( const QString &packageFilename, const QString &destDir ); |
99 | void processFileList( const QStringList *fileList, const QString &destDir ); | 99 | void processFileList( const QStringList *fileList, const QString &destDir ); |
100 | void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); | 100 | void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); |
101 | 101 | ||
102 | }; | 102 | }; |
103 | 103 | ||
104 | #endif | 104 | #endif |
diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp index b391714..d27479c 100644 --- a/noncore/settings/aqpkg/main.cpp +++ b/noncore/settings/aqpkg/main.cpp | |||
@@ -1,38 +1,39 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "mainwin.h" | 30 | #include "mainwin.h" |
31 | 31 | ||
32 | #include <opie2/oapplicationfactory.h> | 32 | #include <opie2/oapplicationfactory.h> |
33 | 33 | ||
34 | /* be less intrusive for translation -zecke */ | 34 | /* be less intrusive for translation -zecke */ |
35 | extern QString LOCAL_SERVER; | 35 | extern QString LOCAL_SERVER; |
36 | extern QString LOCAL_IPKGS; | 36 | extern QString LOCAL_IPKGS; |
37 | 37 | ||
38 | using namespace Opie::Core; | ||
38 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 39 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index b9dbb6e..2f35617 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -1,258 +1,260 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "settingsimpl.h" | 30 | #include "settingsimpl.h" |
31 | #include "global.h" | 31 | #include "global.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/otabwidget.h> | 34 | #include <opie2/otabwidget.h> |
35 | #ifdef QWS | 35 | #ifdef QWS |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | #endif | 38 | #endif |
39 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qgroupbox.h> | 43 | #include <qgroupbox.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qlistbox.h> | 47 | #include <qlistbox.h> |
48 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
49 | 49 | ||
50 | /* STD */ | 50 | /* STD */ |
51 | #include <fstream> | 51 | #include <fstream> |
52 | #include <algorithm> | 52 | #include <algorithm> |
53 | using namespace std; | 53 | using namespace std; |
54 | 54 | ||
55 | using namespace Opie::Ui; | ||
56 | using namespace Opie::Ui; | ||
55 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 57 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
56 | : QDialog( parent, name, modal, fl ) | 58 | : QDialog( parent, name, modal, fl ) |
57 | { | 59 | { |
58 | setCaption( tr( "Configuration" ) ); | 60 | setCaption( tr( "Configuration" ) ); |
59 | 61 | ||
60 | // Setup layout to make everything pretty | 62 | // Setup layout to make everything pretty |
61 | QVBoxLayout *layout = new QVBoxLayout( this ); | 63 | QVBoxLayout *layout = new QVBoxLayout( this ); |
62 | layout->setMargin( 2 ); | 64 | layout->setMargin( 2 ); |
63 | layout->setSpacing( 4 ); | 65 | layout->setSpacing( 4 ); |
64 | 66 | ||
65 | // Setup tabs for all info | 67 | // Setup tabs for all info |
66 | Opie::OTabWidget *tabwidget = new Opie::OTabWidget( this ); | 68 | OTabWidget *tabwidget = new OTabWidget( this ); |
67 | layout->addWidget( tabwidget ); | 69 | layout->addWidget( tabwidget ); |
68 | 70 | ||
69 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); | 71 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); |
70 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); | 72 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); |
71 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); | 73 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); |
72 | tabwidget->setCurrentTab( tr( "Servers" ) ); | 74 | tabwidget->setCurrentTab( tr( "Servers" ) ); |
73 | 75 | ||
74 | dataMgr = dataManager; | 76 | dataMgr = dataManager; |
75 | setupData(); | 77 | setupData(); |
76 | changed = false; | 78 | changed = false; |
77 | newserver = false; | 79 | newserver = false; |
78 | newdestination = false; | 80 | newdestination = false; |
79 | } | 81 | } |
80 | 82 | ||
81 | SettingsImpl :: ~SettingsImpl() | 83 | SettingsImpl :: ~SettingsImpl() |
82 | { | 84 | { |
83 | } | 85 | } |
84 | 86 | ||
85 | bool SettingsImpl :: showDlg() | 87 | bool SettingsImpl :: showDlg() |
86 | { | 88 | { |
87 | QPEApplication::execDialog( this ); | 89 | QPEApplication::execDialog( this ); |
88 | if ( changed ) | 90 | if ( changed ) |
89 | dataMgr->writeOutIpkgConf(); | 91 | dataMgr->writeOutIpkgConf(); |
90 | 92 | ||
91 | return changed; | 93 | return changed; |
92 | } | 94 | } |
93 | 95 | ||
94 | QWidget *SettingsImpl :: initServerTab() | 96 | QWidget *SettingsImpl :: initServerTab() |
95 | { | 97 | { |
96 | QWidget *control = new QWidget( this ); | 98 | QWidget *control = new QWidget( this ); |
97 | 99 | ||
98 | QVBoxLayout *vb = new QVBoxLayout( control ); | 100 | QVBoxLayout *vb = new QVBoxLayout( control ); |
99 | 101 | ||
100 | QScrollView *sv = new QScrollView( control ); | 102 | QScrollView *sv = new QScrollView( control ); |
101 | vb->addWidget( sv, 0, 0 ); | 103 | vb->addWidget( sv, 0, 0 ); |
102 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 104 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
103 | sv->setFrameStyle( QFrame::NoFrame ); | 105 | sv->setFrameStyle( QFrame::NoFrame ); |
104 | 106 | ||
105 | QWidget *container = new QWidget( sv->viewport() ); | 107 | QWidget *container = new QWidget( sv->viewport() ); |
106 | sv->addChild( container ); | 108 | sv->addChild( container ); |
107 | 109 | ||
108 | QGridLayout *layout = new QGridLayout( container ); | 110 | QGridLayout *layout = new QGridLayout( container ); |
109 | layout->setSpacing( 2 ); | 111 | layout->setSpacing( 2 ); |
110 | layout->setMargin( 4 ); | 112 | layout->setMargin( 4 ); |
111 | 113 | ||
112 | servers = new QListBox( container ); | 114 | servers = new QListBox( container ); |
113 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 115 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
114 | connect( servers, SIGNAL( highlighted(int) ), this, SLOT( editServer(int) ) ); | 116 | connect( servers, SIGNAL( highlighted(int) ), this, SLOT( editServer(int) ) ); |
115 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); | 117 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); |
116 | 118 | ||
117 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 119 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
118 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); | 120 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); |
119 | layout->addWidget( btn, 1, 0 ); | 121 | layout->addWidget( btn, 1, 0 ); |
120 | 122 | ||
121 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 123 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
122 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); | 124 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); |
123 | layout->addWidget( btn, 1, 1 ); | 125 | layout->addWidget( btn, 1, 1 ); |
124 | 126 | ||
125 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 127 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
126 | grpbox->layout()->setSpacing( 2 ); | 128 | grpbox->layout()->setSpacing( 2 ); |
127 | grpbox->layout()->setMargin( 4 ); | 129 | grpbox->layout()->setMargin( 4 ); |
128 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 130 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
129 | 131 | ||
130 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 132 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
131 | 133 | ||
132 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 134 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
133 | grplayout->addWidget( label, 0, 0 ); | 135 | grplayout->addWidget( label, 0, 0 ); |
134 | servername = new QLineEdit( grpbox ); | 136 | servername = new QLineEdit( grpbox ); |
135 | grplayout->addWidget( servername, 0, 1 ); | 137 | grplayout->addWidget( servername, 0, 1 ); |
136 | 138 | ||
137 | label = new QLabel( tr( "Address:" ), grpbox ); | 139 | label = new QLabel( tr( "Address:" ), grpbox ); |
138 | grplayout->addWidget( label, 1, 0 ); | 140 | grplayout->addWidget( label, 1, 0 ); |
139 | serverurl = new QLineEdit( grpbox ); | 141 | serverurl = new QLineEdit( grpbox ); |
140 | grplayout->addWidget( serverurl, 1, 1 ); | 142 | grplayout->addWidget( serverurl, 1, 1 ); |
141 | 143 | ||
142 | active = new QCheckBox( tr( "Active Server" ), grpbox ); | 144 | active = new QCheckBox( tr( "Active Server" ), grpbox ); |
143 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); | 145 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); |
144 | 146 | ||
145 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 147 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
146 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); | 148 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); |
147 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 149 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
148 | 150 | ||
149 | return control; | 151 | return control; |
150 | } | 152 | } |
151 | 153 | ||
152 | QWidget *SettingsImpl :: initDestinationTab() | 154 | QWidget *SettingsImpl :: initDestinationTab() |
153 | { | 155 | { |
154 | QWidget *control = new QWidget( this ); | 156 | QWidget *control = new QWidget( this ); |
155 | 157 | ||
156 | QVBoxLayout *vb = new QVBoxLayout( control ); | 158 | QVBoxLayout *vb = new QVBoxLayout( control ); |
157 | 159 | ||
158 | QScrollView *sv = new QScrollView( control ); | 160 | QScrollView *sv = new QScrollView( control ); |
159 | vb->addWidget( sv, 0, 0 ); | 161 | vb->addWidget( sv, 0, 0 ); |
160 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 162 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
161 | sv->setFrameStyle( QFrame::NoFrame ); | 163 | sv->setFrameStyle( QFrame::NoFrame ); |
162 | 164 | ||
163 | QWidget *container = new QWidget( sv->viewport() ); | 165 | QWidget *container = new QWidget( sv->viewport() ); |
164 | sv->addChild( container ); | 166 | sv->addChild( container ); |
165 | 167 | ||
166 | QGridLayout *layout = new QGridLayout( container ); | 168 | QGridLayout *layout = new QGridLayout( container ); |
167 | layout->setSpacing( 2 ); | 169 | layout->setSpacing( 2 ); |
168 | layout->setMargin( 4 ); | 170 | layout->setMargin( 4 ); |
169 | 171 | ||
170 | destinations = new QListBox( container ); | 172 | destinations = new QListBox( container ); |
171 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 173 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
172 | connect( destinations, SIGNAL( highlighted(int) ), this, SLOT( editDestination(int) ) ); | 174 | connect( destinations, SIGNAL( highlighted(int) ), this, SLOT( editDestination(int) ) ); |
173 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); | 175 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); |
174 | 176 | ||
175 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 177 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
176 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); | 178 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); |
177 | layout->addWidget( btn, 1, 0 ); | 179 | layout->addWidget( btn, 1, 0 ); |
178 | 180 | ||
179 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 181 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
180 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); | 182 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); |
181 | layout->addWidget( btn, 1, 1 ); | 183 | layout->addWidget( btn, 1, 1 ); |
182 | 184 | ||
183 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 185 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
184 | grpbox->layout()->setSpacing( 2 ); | 186 | grpbox->layout()->setSpacing( 2 ); |
185 | grpbox->layout()->setMargin( 4 ); | 187 | grpbox->layout()->setMargin( 4 ); |
186 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 188 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
187 | 189 | ||
188 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 190 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
189 | 191 | ||
190 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 192 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
191 | grplayout->addWidget( label, 0, 0 ); | 193 | grplayout->addWidget( label, 0, 0 ); |
192 | destinationname = new QLineEdit( grpbox ); | 194 | destinationname = new QLineEdit( grpbox ); |
193 | grplayout->addWidget( destinationname, 0, 1 ); | 195 | grplayout->addWidget( destinationname, 0, 1 ); |
194 | 196 | ||
195 | label = new QLabel( tr( "Location:" ), grpbox ); | 197 | label = new QLabel( tr( "Location:" ), grpbox ); |
196 | grplayout->addWidget( label, 1, 0 ); | 198 | grplayout->addWidget( label, 1, 0 ); |
197 | destinationurl = new QLineEdit( grpbox ); | 199 | destinationurl = new QLineEdit( grpbox ); |
198 | grplayout->addWidget( destinationurl, 1, 1 ); | 200 | grplayout->addWidget( destinationurl, 1, 1 ); |
199 | 201 | ||
200 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); | 202 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); |
201 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 203 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
202 | 204 | ||
203 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 205 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
204 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); | 206 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); |
205 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 207 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
206 | 208 | ||
207 | return control; | 209 | return control; |
208 | } | 210 | } |
209 | 211 | ||
210 | QWidget *SettingsImpl :: initProxyTab() | 212 | QWidget *SettingsImpl :: initProxyTab() |
211 | { | 213 | { |
212 | QWidget *control = new QWidget( this ); | 214 | QWidget *control = new QWidget( this ); |
213 | 215 | ||
214 | QVBoxLayout *vb = new QVBoxLayout( control ); | 216 | QVBoxLayout *vb = new QVBoxLayout( control ); |
215 | 217 | ||
216 | QScrollView *sv = new QScrollView( control ); | 218 | QScrollView *sv = new QScrollView( control ); |
217 | vb->addWidget( sv, 0, 0 ); | 219 | vb->addWidget( sv, 0, 0 ); |
218 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 220 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
219 | sv->setFrameStyle( QFrame::NoFrame ); | 221 | sv->setFrameStyle( QFrame::NoFrame ); |
220 | 222 | ||
221 | QWidget *container = new QWidget( sv->viewport() ); | 223 | QWidget *container = new QWidget( sv->viewport() ); |
222 | sv->addChild( container ); | 224 | sv->addChild( container ); |
223 | 225 | ||
224 | QGridLayout *layout = new QGridLayout( container ); | 226 | QGridLayout *layout = new QGridLayout( container ); |
225 | layout->setSpacing( 2 ); | 227 | layout->setSpacing( 2 ); |
226 | layout->setMargin( 4 ); | 228 | layout->setMargin( 4 ); |
227 | 229 | ||
228 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 230 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
229 | grpbox->layout()->setSpacing( 2 ); | 231 | grpbox->layout()->setSpacing( 2 ); |
230 | grpbox->layout()->setMargin( 4 ); | 232 | grpbox->layout()->setMargin( 4 ); |
231 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 233 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
232 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 234 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
233 | txtHttpProxy = new QLineEdit( grpbox ); | 235 | txtHttpProxy = new QLineEdit( grpbox ); |
234 | grplayout->addWidget( txtHttpProxy ); | 236 | grplayout->addWidget( txtHttpProxy ); |
235 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 237 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
236 | grplayout->addWidget( chkHttpProxyEnabled ); | 238 | grplayout->addWidget( chkHttpProxyEnabled ); |
237 | 239 | ||
238 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 240 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
239 | grpbox->layout()->setSpacing( 2 ); | 241 | grpbox->layout()->setSpacing( 2 ); |
240 | grpbox->layout()->setMargin( 4 ); | 242 | grpbox->layout()->setMargin( 4 ); |
241 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 243 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
242 | grplayout = new QVBoxLayout( grpbox->layout() ); | 244 | grplayout = new QVBoxLayout( grpbox->layout() ); |
243 | txtFtpProxy = new QLineEdit( grpbox ); | 245 | txtFtpProxy = new QLineEdit( grpbox ); |
244 | grplayout->addWidget( txtFtpProxy ); | 246 | grplayout->addWidget( txtFtpProxy ); |
245 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 247 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
246 | grplayout->addWidget( chkFtpProxyEnabled ); | 248 | grplayout->addWidget( chkFtpProxyEnabled ); |
247 | 249 | ||
248 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 250 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
249 | layout->addWidget( label, 2, 0 ); | 251 | layout->addWidget( label, 2, 0 ); |
250 | txtUsername = new QLineEdit( container ); | 252 | txtUsername = new QLineEdit( container ); |
251 | layout->addWidget( txtUsername, 2, 1 ); | 253 | layout->addWidget( txtUsername, 2, 1 ); |
252 | 254 | ||
253 | label = new QLabel( tr( "Password:" ), container ); | 255 | label = new QLabel( tr( "Password:" ), container ); |
254 | layout->addWidget( label, 3, 0 ); | 256 | layout->addWidget( label, 3, 0 ); |
255 | txtPassword = new QLineEdit( container ); | 257 | txtPassword = new QLineEdit( container ); |
256 | layout->addWidget( txtPassword, 3, 1 ); | 258 | layout->addWidget( txtPassword, 3, 1 ); |
257 | 259 | ||
258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 260 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); |
diff --git a/noncore/settings/backup/main.cpp b/noncore/settings/backup/main.cpp index c254865..6246fd5 100644 --- a/noncore/settings/backup/main.cpp +++ b/noncore/settings/backup/main.cpp | |||
@@ -1,8 +1,9 @@ | |||
1 | #include "backuprestore.h" | 1 | #include "backuprestore.h" |
2 | #include "qnetworkprotocol.h" | 2 | #include "qnetworkprotocol.h" |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | #include <opie2/oapplicationfactory.h> | 4 | #include <opie2/oapplicationfactory.h> |
5 | 5 | ||
6 | 6 | ||
7 | using namespace Opie::Core; | ||
7 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<BackupAndRestore> ) | 8 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<BackupAndRestore> ) |
8 | 9 | ||
diff --git a/noncore/settings/doctab/main.cpp b/noncore/settings/doctab/main.cpp index 13591e0..75d9fcb 100644 --- a/noncore/settings/doctab/main.cpp +++ b/noncore/settings/doctab/main.cpp | |||
@@ -1,25 +1,26 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "doctab.h" | 21 | #include "doctab.h" |
22 | 22 | ||
23 | #include <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<DocTabSettings> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<DocTabSettings> ) |
diff --git a/noncore/settings/language/main.cpp b/noncore/settings/language/main.cpp index 17f7433..ec8366e 100644 --- a/noncore/settings/language/main.cpp +++ b/noncore/settings/language/main.cpp | |||
@@ -1,25 +1,26 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "settings.h" | 21 | #include "settings.h" |
22 | 22 | ||
23 | #include <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<LanguageSettings> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<LanguageSettings> ) |
diff --git a/noncore/settings/mediummount/main.cpp b/noncore/settings/mediummount/main.cpp index 8261490..5d188a9 100644 --- a/noncore/settings/mediummount/main.cpp +++ b/noncore/settings/mediummount/main.cpp | |||
@@ -1,8 +1,9 @@ | |||
1 | #include "mediumwidget.h" | 1 | #include "mediumwidget.h" |
2 | #include "mediumglobal.h" | 2 | #include "mediumglobal.h" |
3 | #include "mainwindow.h" | 3 | #include "mainwindow.h" |
4 | 4 | ||
5 | #include <opie2/oapplicationfactory.h> | 5 | #include <opie2/oapplicationfactory.h> |
6 | 6 | ||
7 | using namespace Opie::Core; | ||
7 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MediumMountSetting::MainWindow> ) | 8 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MediumMountSetting::MainWindow> ) |
8 | 9 | ||
diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp index 4a2d17c..dbcdc17 100644 --- a/noncore/settings/netsystemtime/main.cpp +++ b/noncore/settings/netsystemtime/main.cpp | |||
@@ -1,33 +1,34 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> | 4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | 30 | ||
31 | #include <opie2/oapplicationfactory.h> | 31 | #include <opie2/oapplicationfactory.h> |
32 | 32 | ||
33 | using namespace Opie::Core; | ||
33 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 34 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp index c995d6e..ba96f33 100644 --- a/noncore/settings/netsystemtime/mainwindow.cpp +++ b/noncore/settings/netsystemtime/mainwindow.cpp | |||
@@ -1,385 +1,387 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> | 4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "timetabwidget.h" | 30 | #include "timetabwidget.h" |
31 | #include "formattabwidget.h" | 31 | #include "formattabwidget.h" |
32 | #include "settingstabwidget.h" | 32 | #include "settingstabwidget.h" |
33 | #include "ntptabwidget.h" | 33 | #include "ntptabwidget.h" |
34 | #include "predicttabwidget.h" | 34 | #include "predicttabwidget.h" |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/datebookdb.h> | 37 | #include <qpe/datebookdb.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/qpedialog.h> | 39 | #include <qpe/qpedialog.h> |
40 | 40 | ||
41 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 41 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qsocket.h> | 47 | #include <qsocket.h> |
48 | #include <qstring.h> | 48 | #include <qstring.h> |
49 | #include <qtimer.h> | 49 | #include <qtimer.h> |
50 | 50 | ||
51 | using namespace Opie::Ui; | ||
52 | using namespace Opie::Core; | ||
51 | MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) | 53 | MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) |
52 | : QDialog( 0x0, 0x0, TRUE, 0 ) | 54 | : QDialog( 0x0, 0x0, TRUE, 0 ) |
53 | { | 55 | { |
54 | setCaption( tr( "SystemTime" ) ); | 56 | setCaption( tr( "SystemTime" ) ); |
55 | 57 | ||
56 | QVBoxLayout *layout = new QVBoxLayout( this ); | 58 | QVBoxLayout *layout = new QVBoxLayout( this ); |
57 | layout->setMargin( 2 ); | 59 | layout->setMargin( 2 ); |
58 | layout->setSpacing( 4 ); | 60 | layout->setSpacing( 4 ); |
59 | 61 | ||
60 | // Create main tabbed control | 62 | // Create main tabbed control |
61 | mainWidget = new OTabWidget( this ); | 63 | mainWidget = new OTabWidget( this ); |
62 | 64 | ||
63 | // Default object pointers to null | 65 | // Default object pointers to null |
64 | ntpProcess = 0x0; | 66 | ntpProcess = 0x0; |
65 | ntpTab = 0x0; | 67 | ntpTab = 0x0; |
66 | 68 | ||
67 | // Add tab widgets | 69 | // Add tab widgets |
68 | mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); | 70 | mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); |
69 | mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); | 71 | mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); |
70 | mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); | 72 | mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); |
71 | mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); | 73 | mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); |
72 | Config config( "ntp" ); | 74 | Config config( "ntp" ); |
73 | config.setGroup( "settings" ); | 75 | config.setGroup( "settings" ); |
74 | slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); | 76 | slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); |
75 | slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); | 77 | slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); |
76 | 78 | ||
77 | mainWidget->setCurrentTab( tr( "Time" ) ); | 79 | mainWidget->setCurrentTab( tr( "Time" ) ); |
78 | layout->addWidget( mainWidget ); | 80 | layout->addWidget( mainWidget ); |
79 | 81 | ||
80 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 82 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
81 | this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) ); | 83 | this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) ); |
82 | 84 | ||
83 | 85 | ||
84 | // Create NTP socket | 86 | // Create NTP socket |
85 | ntpSock = new QSocket( this ); | 87 | ntpSock = new QSocket( this ); |
86 | connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); | 88 | connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); |
87 | slotProbeNTPServer(); | 89 | slotProbeNTPServer(); |
88 | 90 | ||
89 | // Create timer for automatic time lookups | 91 | // Create timer for automatic time lookups |
90 | ntpTimer = new QTimer( this ); | 92 | ntpTimer = new QTimer( this ); |
91 | 93 | ||
92 | // Connect everything together | 94 | // Connect everything together |
93 | connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); | 95 | connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); |
94 | connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) ); | 96 | connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) ); |
95 | connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); | 97 | connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); |
96 | connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) ); | 98 | connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) ); |
97 | connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)), | 99 | connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)), |
98 | timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) ); | 100 | timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) ); |
99 | connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); | 101 | connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); |
100 | connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); | 102 | connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); |
101 | connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); | 103 | connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); |
102 | connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); | 104 | connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); |
103 | connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) ); | 105 | connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) ); |
104 | 106 | ||
105 | // Do initial time server check | 107 | // Do initial time server check |
106 | slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); | 108 | slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); |
107 | slotCheckNtp( -1 ); | 109 | slotCheckNtp( -1 ); |
108 | 110 | ||
109 | // Display app | 111 | // Display app |
110 | //showMaximized(); | 112 | //showMaximized(); |
111 | (void)new QPEDialogListener(this); | 113 | (void)new QPEDialogListener(this); |
112 | } | 114 | } |
113 | 115 | ||
114 | MainWindow::~MainWindow() | 116 | MainWindow::~MainWindow() |
115 | { | 117 | { |
116 | if ( ntpProcess ) | 118 | if ( ntpProcess ) |
117 | delete ntpProcess; | 119 | delete ntpProcess; |
118 | } | 120 | } |
119 | 121 | ||
120 | void MainWindow::accept() | 122 | void MainWindow::accept() |
121 | { | 123 | { |
122 | // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) | 124 | // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) |
123 | { | 125 | { |
124 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 126 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
125 | disableScreenSaver << 0 << 0 << 0; | 127 | disableScreenSaver << 0 << 0 << 0; |
126 | } | 128 | } |
127 | 129 | ||
128 | // Update the systemtime | 130 | // Update the systemtime |
129 | timeTab->saveSettings( TRUE ); | 131 | timeTab->saveSettings( TRUE ); |
130 | 132 | ||
131 | // Save format options | 133 | // Save format options |
132 | formatTab->saveSettings( TRUE ); | 134 | formatTab->saveSettings( TRUE ); |
133 | 135 | ||
134 | // Save settings options | 136 | // Save settings options |
135 | settingsTab->saveSettings(); | 137 | settingsTab->saveSettings(); |
136 | 138 | ||
137 | // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better | 139 | // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better |
138 | // grip on itself (example re-trigger alarms for when we travel back in time). | 140 | // grip on itself (example re-trigger alarms for when we travel back in time). |
139 | DateBookDB db; | 141 | DateBookDB db; |
140 | 142 | ||
141 | // Turn back on the screensaver | 143 | // Turn back on the screensaver |
142 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 144 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
143 | enableScreenSaver << -1 << -1 << -1; | 145 | enableScreenSaver << -1 << -1 << -1; |
144 | 146 | ||
145 | // Exit app | 147 | // Exit app |
146 | qApp->quit(); | 148 | qApp->quit(); |
147 | } | 149 | } |
148 | 150 | ||
149 | void MainWindow::reject() | 151 | void MainWindow::reject() |
150 | { | 152 | { |
151 | // Reset time settings | 153 | // Reset time settings |
152 | timeTab->saveSettings( FALSE ); | 154 | timeTab->saveSettings( FALSE ); |
153 | 155 | ||
154 | // Send notifications but do not save settings | 156 | // Send notifications but do not save settings |
155 | formatTab->saveSettings( FALSE ); | 157 | formatTab->saveSettings( FALSE ); |
156 | 158 | ||
157 | // Exit app | 159 | // Exit app |
158 | qApp->quit(); | 160 | qApp->quit(); |
159 | } | 161 | } |
160 | 162 | ||
161 | void MainWindow::runNTP() | 163 | void MainWindow::runNTP() |
162 | { | 164 | { |
163 | if ( !ntpDelayElapsed() && ntpInteractive ) | 165 | if ( !ntpDelayElapsed() && ntpInteractive ) |
164 | { | 166 | { |
165 | QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); | 167 | QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); |
166 | 168 | ||
167 | switch ( | 169 | switch ( |
168 | QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) | 170 | QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) |
169 | ) | 171 | ) |
170 | { | 172 | { |
171 | case QMessageBox::Yes: break; | 173 | case QMessageBox::Yes: break; |
172 | case QMessageBox::No: return; | 174 | case QMessageBox::No: return; |
173 | default: return; | 175 | default: return; |
174 | } | 176 | } |
175 | } | 177 | } |
176 | 178 | ||
177 | QString srv = settingsTab->ntpServer(); | 179 | QString srv = settingsTab->ntpServer(); |
178 | 180 | ||
179 | // Send information to time server tab if enabled | 181 | // Send information to time server tab if enabled |
180 | if ( ntpTabEnabled ) | 182 | if ( ntpTabEnabled ) |
181 | { | 183 | { |
182 | ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); | 184 | ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); |
183 | QString output = tr( "Running:\nntpdate " ); | 185 | QString output = tr( "Running:\nntpdate " ); |
184 | output.append( srv ); | 186 | output.append( srv ); |
185 | ntpTab->addNtpOutput( output ); | 187 | ntpTab->addNtpOutput( output ); |
186 | } | 188 | } |
187 | 189 | ||
188 | if ( !ntpProcess ) | 190 | if ( !ntpProcess ) |
189 | { | 191 | { |
190 | ntpProcess = new OProcess(); | 192 | ntpProcess = new OProcess(); |
191 | connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 193 | connect( ntpProcess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
192 | this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); | 194 | this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); |
193 | connect( ntpProcess, SIGNAL(processExited(OProcess*)), | 195 | connect( ntpProcess, SIGNAL(processExited(Opie::Core::OProcess*)), |
194 | this, SLOT(slotNtpFinished(OProcess*)) ); | 196 | this, SLOT(slotNtpFinished(OProcess*)) ); |
195 | } | 197 | } |
196 | 198 | ||
197 | else | 199 | else |
198 | ntpProcess->clearArguments(); | 200 | ntpProcess->clearArguments(); |
199 | 201 | ||
200 | *ntpProcess << "ntpdate" << srv; | 202 | *ntpProcess << "ntpdate" << srv; |
201 | bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); | 203 | bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); |
202 | if ( !ret ) | 204 | if ( !ret ) |
203 | { | 205 | { |
204 | QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); | 206 | QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); |
205 | if ( ntpTabEnabled ) | 207 | if ( ntpTabEnabled ) |
206 | ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); | 208 | ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); |
207 | } | 209 | } |
208 | } | 210 | } |
209 | 211 | ||
210 | bool MainWindow::ntpDelayElapsed() | 212 | bool MainWindow::ntpDelayElapsed() |
211 | { | 213 | { |
212 | // Determine if time elapsed is greater than time delay | 214 | // Determine if time elapsed is greater than time delay |
213 | Config config( "ntp" ); | 215 | Config config( "ntp" ); |
214 | config.setGroup( "lookups" ); | 216 | config.setGroup( "lookups" ); |
215 | _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); | 217 | _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); |
216 | if ( _lookupDiff < 0 ) | 218 | if ( _lookupDiff < 0 ) |
217 | return true; | 219 | return true; |
218 | return ( _lookupDiff - ( ntpDelay * 60) ) > 0; | 220 | return ( _lookupDiff - ( ntpDelay * 60) ) > 0; |
219 | } | 221 | } |
220 | 222 | ||
221 | void MainWindow::slotSetTime( const QDateTime &dt ) | 223 | void MainWindow::slotSetTime( const QDateTime &dt ) |
222 | { | 224 | { |
223 | timeTab->setDateTime( dt ); | 225 | timeTab->setDateTime( dt ); |
224 | } | 226 | } |
225 | 227 | ||
226 | void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) | 228 | void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) |
227 | { | 229 | { |
228 | if ( msg == "ntpLookup(QString)" ) | 230 | if ( msg == "ntpLookup(QString)" ) |
229 | { | 231 | { |
230 | ntpInteractive = false; | 232 | ntpInteractive = false; |
231 | runNTP(); | 233 | runNTP(); |
232 | } | 234 | } |
233 | if ( msg == "setPredictedTime(QString)" ) | 235 | if ( msg == "setPredictedTime(QString)" ) |
234 | { | 236 | { |
235 | //setPredictTime(); | 237 | //setPredictTime(); |
236 | } | 238 | } |
237 | } | 239 | } |
238 | 240 | ||
239 | void MainWindow::slotDisplayNTPTab( bool display ) | 241 | void MainWindow::slotDisplayNTPTab( bool display ) |
240 | { | 242 | { |
241 | ntpTabEnabled = display; | 243 | ntpTabEnabled = display; |
242 | 244 | ||
243 | // Create widget if it hasn't needed | 245 | // Create widget if it hasn't needed |
244 | if ( display && !ntpTab ) | 246 | if ( display && !ntpTab ) |
245 | { | 247 | { |
246 | ntpTab = new NTPTabWidget( mainWidget ); | 248 | ntpTab = new NTPTabWidget( mainWidget ); |
247 | connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); | 249 | connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); |
248 | } | 250 | } |
249 | 251 | ||
250 | // Display/hide tab | 252 | // Display/hide tab |
251 | display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) | 253 | display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) |
252 | : mainWidget->removePage( ntpTab ); | 254 | : mainWidget->removePage( ntpTab ); |
253 | } | 255 | } |
254 | 256 | ||
255 | void MainWindow::slotDisplayPredictTab( bool display ) | 257 | void MainWindow::slotDisplayPredictTab( bool display ) |
256 | { | 258 | { |
257 | predictTabEnabled = display; | 259 | predictTabEnabled = display; |
258 | 260 | ||
259 | // Create widget if it hasn't needed | 261 | // Create widget if it hasn't needed |
260 | if ( display && !predictTab ) | 262 | if ( display && !predictTab ) |
261 | { | 263 | { |
262 | } | 264 | } |
263 | // Display/hide tab | 265 | // Display/hide tab |
264 | display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) | 266 | display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) |
265 | : mainWidget->removePage( predictTab ); | 267 | : mainWidget->removePage( predictTab ); |
266 | } | 268 | } |
267 | 269 | ||
268 | void MainWindow::slotGetNTPTime() | 270 | void MainWindow::slotGetNTPTime() |
269 | { | 271 | { |
270 | ntpInteractive = TRUE; | 272 | ntpInteractive = TRUE; |
271 | runNTP(); | 273 | runNTP(); |
272 | } | 274 | } |
273 | 275 | ||
274 | void MainWindow::slotTimerGetNTPTime() | 276 | void MainWindow::slotTimerGetNTPTime() |
275 | { | 277 | { |
276 | ntpInteractive = FALSE; | 278 | ntpInteractive = FALSE; |
277 | runNTP(); | 279 | runNTP(); |
278 | } | 280 | } |
279 | 281 | ||
280 | void MainWindow::slotProbeNTPServer() | 282 | void MainWindow::slotProbeNTPServer() |
281 | { | 283 | { |
282 | ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); | 284 | ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); |
283 | } | 285 | } |
284 | 286 | ||
285 | void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) | 287 | void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) |
286 | { | 288 | { |
287 | QString output = QString( buffer ).left( buflen ); | 289 | QString output = QString( buffer ).left( buflen ); |
288 | ntpOutput.append( output ); | 290 | ntpOutput.append( output ); |
289 | 291 | ||
290 | if ( ntpTabEnabled ) | 292 | if ( ntpTabEnabled ) |
291 | ntpTab->addNtpOutput( output ); | 293 | ntpTab->addNtpOutput( output ); |
292 | } | 294 | } |
293 | 295 | ||
294 | void MainWindow::slotNtpFinished( OProcess *p ) | 296 | void MainWindow::slotNtpFinished( OProcess *p ) |
295 | { | 297 | { |
296 | QString output; | 298 | QString output; |
297 | QDateTime dt = QDateTime::currentDateTime(); | 299 | QDateTime dt = QDateTime::currentDateTime(); |
298 | 300 | ||
299 | // Verify run was successful | 301 | // Verify run was successful |
300 | if ( p->exitStatus() != 0 || !p->normalExit() ) | 302 | if ( p->exitStatus() != 0 || !p->normalExit() ) |
301 | { | 303 | { |
302 | if ( isVisible() && ntpInteractive ) | 304 | if ( isVisible() && ntpInteractive ) |
303 | { | 305 | { |
304 | output = tr( "Error while getting time from\n server: " ); | 306 | output = tr( "Error while getting time from\n server: " ); |
305 | output.append( settingsTab->ntpServer() ); | 307 | output.append( settingsTab->ntpServer() ); |
306 | QMessageBox::critical(this, tr( "Error" ), output ); | 308 | QMessageBox::critical(this, tr( "Error" ), output ); |
307 | } | 309 | } |
308 | // slotCheckNtp(-1); | 310 | // slotCheckNtp(-1); |
309 | return; | 311 | return; |
310 | } | 312 | } |
311 | 313 | ||
312 | // Set controls on time tab to new time value | 314 | // Set controls on time tab to new time value |
313 | timeTab->setDateTime( dt ); | 315 | timeTab->setDateTime( dt ); |
314 | 316 | ||
315 | // Write out lookup information | 317 | // Write out lookup information |
316 | Config config( "ntp" ); | 318 | Config config( "ntp" ); |
317 | config.setGroup( "lookups" ); | 319 | config.setGroup( "lookups" ); |
318 | int lastLookup = config.readNumEntry( "time", 0 ); | 320 | int lastLookup = config.readNumEntry( "time", 0 ); |
319 | int lookupCount = config.readNumEntry( "count", 0 ); | 321 | int lookupCount = config.readNumEntry( "count", 0 ); |
320 | bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); | 322 | bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); |
321 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 323 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
322 | config.writeEntry( "time", time ); | 324 | config.writeEntry( "time", time ); |
323 | 325 | ||
324 | // Calculate new time/time shift | 326 | // Calculate new time/time shift |
325 | QString _offset = "offset"; | 327 | QString _offset = "offset"; |
326 | QString _sec = "sec"; | 328 | QString _sec = "sec"; |
327 | QRegExp _reOffset = QRegExp( _offset ); | 329 | QRegExp _reOffset = QRegExp( _offset ); |
328 | QRegExp _reEndOffset = QRegExp( _sec ); | 330 | QRegExp _reEndOffset = QRegExp( _sec ); |
329 | int posOffset = _reOffset.match( ntpOutput ); | 331 | int posOffset = _reOffset.match( ntpOutput ); |
330 | int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); | 332 | int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); |
331 | posOffset += _offset.length() + 1; | 333 | posOffset += _offset.length() + 1; |
332 | QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); | 334 | QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); |
333 | 335 | ||
334 | float timeShift = diff.toFloat(); | 336 | float timeShift = diff.toFloat(); |
335 | if ( timeShift == 0.0 ) | 337 | if ( timeShift == 0.0 ) |
336 | return; | 338 | return; |
337 | int secsSinceLast = time - lastLookup; | 339 | int secsSinceLast = time - lastLookup; |
338 | output = tr( "%1 seconds").arg(QString::number( timeShift )); | 340 | output = tr( "%1 seconds").arg(QString::number( timeShift )); |
339 | 341 | ||
340 | // Display information on time server tab | 342 | // Display information on time server tab |
341 | if ( ntpTabEnabled ) | 343 | if ( ntpTabEnabled ) |
342 | { | 344 | { |
343 | ntpTab->setTimeShift( output ); | 345 | ntpTab->setTimeShift( output ); |
344 | ntpTab->setNewTime( dt.toString() ); | 346 | ntpTab->setNewTime( dt.toString() ); |
345 | } | 347 | } |
346 | 348 | ||
347 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) | 349 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) |
348 | { | 350 | { |
349 | QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); | 351 | QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); |
350 | config.setGroup( grpname ); | 352 | config.setGroup( grpname ); |
351 | lookupCount++; | 353 | lookupCount++; |
352 | predictTab->setShiftPerSec( timeShift / secsSinceLast ); | 354 | predictTab->setShiftPerSec( timeShift / secsSinceLast ); |
353 | config.writeEntry( "secsSinceLast", secsSinceLast ); | 355 | config.writeEntry( "secsSinceLast", secsSinceLast ); |
354 | config.writeEntry( "timeShift", QString::number( timeShift ) ); | 356 | config.writeEntry( "timeShift", QString::number( timeShift ) ); |
355 | config.setGroup( "lookups" ); | 357 | config.setGroup( "lookups" ); |
356 | config.writeEntry( "count", lookupCount ); | 358 | config.writeEntry( "count", lookupCount ); |
357 | config.writeEntry( "lastNtp", TRUE ); | 359 | config.writeEntry( "lastNtp", TRUE ); |
358 | } | 360 | } |
359 | } | 361 | } |
360 | 362 | ||
361 | void MainWindow::slotNTPDelayChanged( int delay ) | 363 | void MainWindow::slotNTPDelayChanged( int delay ) |
362 | { | 364 | { |
363 | ntpTimer->changeInterval( delay * 1000 * 60 ); | 365 | ntpTimer->changeInterval( delay * 1000 * 60 ); |
364 | ntpDelay = delay; | 366 | ntpDelay = delay; |
365 | } | 367 | } |
366 | 368 | ||
367 | void MainWindow::slotCheckNtp( int i ) | 369 | void MainWindow::slotCheckNtp( int i ) |
368 | { | 370 | { |
369 | if ( i == 0 ) | 371 | if ( i == 0 ) |
370 | { | 372 | { |
371 | if ( ntpDelayElapsed() ) | 373 | if ( ntpDelayElapsed() ) |
372 | { | 374 | { |
373 | runNTP(); | 375 | runNTP(); |
374 | disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); | 376 | disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); |
375 | connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); | 377 | connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); |
376 | } | 378 | } |
377 | else | 379 | else |
378 | { | 380 | { |
379 | disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); | 381 | disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); |
380 | connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); | 382 | connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); |
381 | } | 383 | } |
382 | } | 384 | } |
383 | else | 385 | else |
384 | { | 386 | { |
385 | predictTab->slotPredictTime(); | 387 | predictTab->slotPredictTime(); |
diff --git a/noncore/settings/netsystemtime/mainwindow.h b/noncore/settings/netsystemtime/mainwindow.h index d4a9713..8701803 100644 --- a/noncore/settings/netsystemtime/mainwindow.h +++ b/noncore/settings/netsystemtime/mainwindow.h | |||
@@ -1,99 +1,98 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> | 4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef MAINWINDOW_H | 29 | #ifndef MAINWINDOW_H |
30 | #define MAINWINDOW_H | 30 | #define MAINWINDOW_H |
31 | 31 | ||
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | 33 | ||
34 | #include <opie2/oprocess.h> | 34 | #include <opie2/oprocess.h> |
35 | #include <opie2/otabwidget.h> | 35 | #include <opie2/otabwidget.h> |
36 | 36 | ||
37 | class TimeTabWidget; | 37 | class TimeTabWidget; |
38 | class FormatTabWidget; | 38 | class FormatTabWidget; |
39 | class SettingsTabWidget; | 39 | class SettingsTabWidget; |
40 | class NTPTabWidget; | 40 | class NTPTabWidget; |
41 | class PredictTabWidget; | 41 | class PredictTabWidget; |
42 | 42 | ||
43 | using Opie::OTabWidget; | ||
44 | 43 | ||
45 | class QDateTime; | 44 | class QDateTime; |
46 | class QSocket; | 45 | class QSocket; |
47 | class QTimer; | 46 | class QTimer; |
48 | 47 | ||
49 | class MainWindow : public QDialog | 48 | class MainWindow : public QDialog |
50 | { | 49 | { |
51 | Q_OBJECT | 50 | Q_OBJECT |
52 | 51 | ||
53 | public: | 52 | public: |
54 | MainWindow( QWidget *parent = 0, const char *name = 0, bool modal = FALSE,WFlags f = 0); | 53 | MainWindow( QWidget *parent = 0, const char *name = 0, bool modal = FALSE,WFlags f = 0); |
55 | ~MainWindow(); | 54 | ~MainWindow(); |
56 | static QString appName() { return QString::fromLatin1("systemtime"); } | 55 | static QString appName() { return QString::fromLatin1("systemtime"); } |
57 | 56 | ||
58 | protected: | 57 | protected: |
59 | void accept(); | 58 | void accept(); |
60 | void reject(); | 59 | void reject(); |
61 | 60 | ||
62 | private: | 61 | private: |
63 | OTabWidget *mainWidget; | 62 | Opie::Ui::OTabWidget *mainWidget; |
64 | 63 | ||
65 | TimeTabWidget *timeTab; | 64 | TimeTabWidget *timeTab; |
66 | FormatTabWidget *formatTab; | 65 | FormatTabWidget *formatTab; |
67 | SettingsTabWidget *settingsTab; | 66 | SettingsTabWidget *settingsTab; |
68 | NTPTabWidget *ntpTab; | 67 | NTPTabWidget *ntpTab; |
69 | PredictTabWidget *predictTab; | 68 | PredictTabWidget *predictTab; |
70 | 69 | ||
71 | bool ntpTabEnabled; | 70 | bool ntpTabEnabled; |
72 | bool predictTabEnabled; | 71 | bool predictTabEnabled; |
73 | 72 | ||
74 | OProcess *ntpProcess; | 73 | Opie::Core::OProcess *ntpProcess; |
75 | QTimer *ntpTimer; | 74 | QTimer *ntpTimer; |
76 | QSocket *ntpSock; | 75 | QSocket *ntpSock; |
77 | int ntpDelay; | 76 | int ntpDelay; |
78 | bool ntpInteractive; | 77 | bool ntpInteractive; |
79 | QString ntpOutput; | 78 | QString ntpOutput; |
80 | int _lookupDiff; | 79 | int _lookupDiff; |
81 | 80 | ||
82 | void runNTP(); | 81 | void runNTP(); |
83 | bool ntpDelayElapsed(); | 82 | bool ntpDelayElapsed(); |
84 | 83 | ||
85 | private slots: | 84 | private slots: |
86 | void slotSetTime( const QDateTime & ); | 85 | void slotSetTime( const QDateTime & ); |
87 | void slotQCopReceive( const QCString &, const QByteArray & ); | 86 | void slotQCopReceive( const QCString &, const QByteArray & ); |
88 | void slotDisplayNTPTab( bool ); | 87 | void slotDisplayNTPTab( bool ); |
89 | void slotDisplayPredictTab( bool ); | 88 | void slotDisplayPredictTab( bool ); |
90 | void slotGetNTPTime(); | 89 | void slotGetNTPTime(); |
91 | void slotTimerGetNTPTime(); | 90 | void slotTimerGetNTPTime(); |
92 | void slotProbeNTPServer(); | 91 | void slotProbeNTPServer(); |
93 | void slotNtpOutput( OProcess *, char *, int ); | 92 | void slotNtpOutput( Opie::Core::OProcess *, char *, int ); |
94 | void slotNtpFinished( OProcess* ); | 93 | void slotNtpFinished( Opie::Core::OProcess* ); |
95 | void slotNTPDelayChanged( int ); | 94 | void slotNTPDelayChanged( int ); |
96 | void slotCheckNtp( int ); | 95 | void slotCheckNtp( int ); |
97 | }; | 96 | }; |
98 | 97 | ||
99 | #endif | 98 | #endif |
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 05340e4..7c2f85c 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -1,206 +1,208 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | 3 | ||
4 | #include <qcheckbox.h> | 4 | #include <qcheckbox.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qspinbox.h> | 6 | #include <qspinbox.h> |
7 | #include <qgroupbox.h> | 7 | #include <qgroupbox.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | 9 | ||
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | 11 | ||
12 | #include <opie2/oprocess.h> | 12 | #include <opie2/oprocess.h> |
13 | 13 | ||
14 | #ifdef QWS | 14 | #ifdef QWS |
15 | #include <opie2/owait.h> | 15 | #include <opie2/owait.h> |
16 | #include <qpe/global.h> | 16 | #include <qpe/global.h> |
17 | #include <qapplication.h> | 17 | #include <qapplication.h> |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | #define DNSSCRIPT "changedns" | 20 | #define DNSSCRIPT "changedns" |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Constuctor. Set up the connection. A profile must be set. | 23 | * Constuctor. Set up the connection. A profile must be set. |
24 | */ | 24 | */ |
25 | using namespace Opie::Ui; | ||
26 | using namespace Opie::Core; | ||
25 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ | 27 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ |
26 | if (j == 0) { | 28 | if (j == 0) { |
27 | delInterfaces = true; | 29 | delInterfaces = true; |
28 | interfaces = new Interfaces; | 30 | interfaces = new Interfaces; |
29 | } | 31 | } |
30 | } | 32 | } |
31 | 33 | ||
32 | /** | 34 | /** |
33 | * Destructor | 35 | * Destructor |
34 | */ | 36 | */ |
35 | InterfaceSetupImp::~InterfaceSetupImp(){ | 37 | InterfaceSetupImp::~InterfaceSetupImp(){ |
36 | if(delInterfaces) { | 38 | if(delInterfaces) { |
37 | delete interfaces; | 39 | delete interfaces; |
38 | } | 40 | } |
39 | } | 41 | } |
40 | 42 | ||
41 | /** | 43 | /** |
42 | * Save the current settings, then write out the interfaces file and close. | 44 | * Save the current settings, then write out the interfaces file and close. |
43 | */ | 45 | */ |
44 | bool InterfaceSetupImp::saveChanges(){ | 46 | bool InterfaceSetupImp::saveChanges(){ |
45 | bool error; | 47 | bool error; |
46 | QString iface = interfaces->getInterfaceName(error); | 48 | QString iface = interfaces->getInterfaceName(error); |
47 | qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); | 49 | qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); |
48 | if(!saveSettings()) | 50 | if(!saveSettings()) |
49 | return false; | 51 | return false; |
50 | 52 | ||
51 | interfaces->write(); | 53 | interfaces->write(); |
52 | 54 | ||
53 | if (interface->getStatus()) { | 55 | if (interface->getStatus()) { |
54 | QString ifup; | 56 | QString ifup; |
55 | ifup += "ifdown "; | 57 | ifup += "ifdown "; |
56 | ifup += iface; | 58 | ifup += iface; |
57 | ifup += "; ifup "; | 59 | ifup += "; ifup "; |
58 | ifup += iface; | 60 | ifup += iface; |
59 | ifup += ";"; | 61 | ifup += ";"; |
60 | 62 | ||
61 | OProcess restart; | 63 | OProcess restart; |
62 | restart << "sh"; | 64 | restart << "sh"; |
63 | restart << "-c"; | 65 | restart << "-c"; |
64 | restart << ifup; | 66 | restart << ifup; |
65 | 67 | ||
66 | OWait *owait = new OWait(); | 68 | OWait *owait = new OWait(); |
67 | Global::statusMessage( tr( "Restarting interface" ) ); | 69 | Global::statusMessage( tr( "Restarting interface" ) ); |
68 | 70 | ||
69 | owait->show(); | 71 | owait->show(); |
70 | qApp->processEvents(); | 72 | qApp->processEvents(); |
71 | 73 | ||
72 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { | 74 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { |
73 | qWarning("unstable to spawn ifdown/ifup"); | 75 | qWarning("unstable to spawn ifdown/ifup"); |
74 | } | 76 | } |
75 | 77 | ||
76 | owait->hide(); | 78 | owait->hide(); |
77 | delete owait; | 79 | delete owait; |
78 | 80 | ||
79 | interface->refresh(); | 81 | interface->refresh(); |
80 | } | 82 | } |
81 | return true; | 83 | return true; |
82 | } | 84 | } |
83 | 85 | ||
84 | /** | 86 | /** |
85 | * Save the settings for the current Interface. | 87 | * Save the settings for the current Interface. |
86 | * @return bool true if successful, false otherwise | 88 | * @return bool true if successful, false otherwise |
87 | */ | 89 | */ |
88 | bool InterfaceSetupImp::saveSettings(){ | 90 | bool InterfaceSetupImp::saveSettings(){ |
89 | // eh can't really do anything about it other then return. :-D | 91 | // eh can't really do anything about it other then return. :-D |
90 | if(!interfaces->isInterfaceSet()) | 92 | if(!interfaces->isInterfaceSet()) |
91 | return true; | 93 | return true; |
92 | 94 | ||
93 | bool error = false; | 95 | bool error = false; |
94 | // Loopback case | 96 | // Loopback case |
95 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 97 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
96 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 98 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
97 | return true; | 99 | return true; |
98 | } | 100 | } |
99 | 101 | ||
100 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 102 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
101 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); | 103 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); |
102 | return false; | 104 | return false; |
103 | } | 105 | } |
104 | // DHCP | 106 | // DHCP |
105 | if(dhcpCheckBox->isChecked()) { | 107 | if(dhcpCheckBox->isChecked()) { |
106 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 108 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
107 | interfaces->removeInterfaceOption("address"); | 109 | interfaces->removeInterfaceOption("address"); |
108 | interfaces->removeInterfaceOption("netmask"); | 110 | interfaces->removeInterfaceOption("netmask"); |
109 | interfaces->removeInterfaceOption("gateway"); | 111 | interfaces->removeInterfaceOption("gateway"); |
110 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | 112 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); |
111 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); | 113 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); |
112 | } else{ | 114 | } else{ |
113 | interfaces->setInterfaceMethod("static"); | 115 | interfaces->setInterfaceMethod("static"); |
114 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 116 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
115 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 117 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
116 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 118 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
117 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 119 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
118 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 120 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
119 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 121 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
120 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 122 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
121 | }else{ | 123 | }else{ |
122 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | 124 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); |
123 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); | 125 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); |
124 | } | 126 | } |
125 | } | 127 | } |
126 | 128 | ||
127 | // IP Information | 129 | // IP Information |
128 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 130 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
129 | return true; | 131 | return true; |
130 | } | 132 | } |
131 | 133 | ||
132 | /** | 134 | /** |
133 | * The Profile has changed. | 135 | * The Profile has changed. |
134 | * @param QString profile the new profile. | 136 | * @param QString profile the new profile. |
135 | */ | 137 | */ |
136 | void InterfaceSetupImp::setProfile(const QString &profile){ | 138 | void InterfaceSetupImp::setProfile(const QString &profile){ |
137 | /* | 139 | /* |
138 | bool error = false; | 140 | bool error = false; |
139 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 141 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
140 | staticGroupBox->hide(); | 142 | staticGroupBox->hide(); |
141 | dhcpCheckBox->hide(); | 143 | dhcpCheckBox->hide(); |
142 | leaseTime->hide(); | 144 | leaseTime->hide(); |
143 | leaseHoursLabel->hide(); | 145 | leaseHoursLabel->hide(); |
144 | } | 146 | } |
145 | */ | 147 | */ |
146 | 148 | ||
147 | QString newInterfaceName = interface->getInterfaceName(); | 149 | QString newInterfaceName = interface->getInterfaceName(); |
148 | if(profile.length() > 0) | 150 | if(profile.length() > 0) |
149 | newInterfaceName += "_" + profile; | 151 | newInterfaceName += "_" + profile; |
150 | // See if we have to make a interface. | 152 | // See if we have to make a interface. |
151 | if(!interfaces->setInterface(newInterfaceName)){ | 153 | if(!interfaces->setInterface(newInterfaceName)){ |
152 | // Add making for this new interface if need too | 154 | // Add making for this new interface if need too |
153 | if(profile != ""){ | 155 | if(profile != ""){ |
154 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 156 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
155 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 157 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
156 | interfaces->addMapping(interface->getInterfaceName()); | 158 | interfaces->addMapping(interface->getInterfaceName()); |
157 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 159 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
158 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); | 160 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); |
159 | return; | 161 | return; |
160 | } | 162 | } |
161 | } | 163 | } |
162 | interfaces->setMap("map", newInterfaceName); | 164 | interfaces->setMap("map", newInterfaceName); |
163 | interfaces->setScript("getprofile.sh"); | 165 | interfaces->setScript("getprofile.sh"); |
164 | } | 166 | } |
165 | else{ | 167 | else{ |
166 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 168 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
167 | if(!interfaces->setInterface(newInterfaceName)){ | 169 | if(!interfaces->setInterface(newInterfaceName)){ |
168 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); | 170 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); |
169 | return; | 171 | return; |
170 | } | 172 | } |
171 | } | 173 | } |
172 | } | 174 | } |
173 | 175 | ||
174 | // We must have a valid interface to get this far so read some settings. | 176 | // We must have a valid interface to get this far so read some settings. |
175 | 177 | ||
176 | // DHCP | 178 | // DHCP |
177 | bool error = false; | 179 | bool error = false; |
178 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 180 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
179 | dhcpCheckBox->setChecked(true); | 181 | dhcpCheckBox->setChecked(true); |
180 | else | 182 | else |
181 | dhcpCheckBox->setChecked(false); | 183 | dhcpCheckBox->setChecked(false); |
182 | 184 | ||
183 | // IP Information | 185 | // IP Information |
184 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 186 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
185 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 187 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
186 | qDebug("dns >%s<",dns.latin1()); | 188 | qDebug("dns >%s<",dns.latin1()); |
187 | if(dns.contains(" ")){ | 189 | if(dns.contains(" ")){ |
188 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 190 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
189 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 191 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
190 | }else firstDNSLineEdit->setText(dns); | 192 | }else firstDNSLineEdit->setText(dns); |
191 | 193 | ||
192 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 194 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
193 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 195 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
194 | if (subnetMaskEdit->text().isEmpty()) | 196 | if (subnetMaskEdit->text().isEmpty()) |
195 | subnetMaskEdit->setText( "255.255.255.0" ); | 197 | subnetMaskEdit->setText( "255.255.255.0" ); |
196 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 198 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
197 | 199 | ||
198 | 200 | ||
199 | 201 | ||
200 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); | 202 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); |
201 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); | 203 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); |
202 | 204 | ||
203 | } | 205 | } |
204 | 206 | ||
205 | // interfacesetup.cpp | 207 | // interfacesetup.cpp |
206 | 208 | ||
diff --git a/noncore/settings/networksettings/main.cpp b/noncore/settings/networksettings/main.cpp index bc11ab4..e4153c3 100644 --- a/noncore/settings/networksettings/main.cpp +++ b/noncore/settings/networksettings/main.cpp | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include <opie2/oapplicationfactory.h> | 2 | #include <opie2/oapplicationfactory.h> |
3 | 3 | ||
4 | using namespace Opie::Core; | ||
4 | OPIE_EXPORT_APP( OApplicationFactory<MainWindowImp> ) | 5 | OPIE_EXPORT_APP( OApplicationFactory<MainWindowImp> ) |
5 | 6 | ||
6 | 7 | ||
diff --git a/noncore/settings/networksettings/networksettings.pro b/noncore/settings/networksettings/networksettings.pro index 5db2d6b..281629c 100644 --- a/noncore/settings/networksettings/networksettings.pro +++ b/noncore/settings/networksettings/networksettings.pro | |||
@@ -1,12 +1,12 @@ | |||
1 | CONFIG = qt warn_on debug quick-app | 1 | CONFIG = qt warn_on debug quick-app |
2 | HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h | 2 | HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h |
3 | SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp | 3 | SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp |
4 | INCLUDEPATH += $(OPIEDIR)/include interfaces/ | 4 | INCLUDEPATH += $(OPIEDIR)/include interfaces/ . |
5 | DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/ | 5 | DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/ |
6 | LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopiecore2 -lopieui2 | 6 | LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopiecore2 -lopieui2 |
7 | INTERFACES = mainwindow.ui addconnection.ui | 7 | INTERFACES = mainwindow.ui addconnection.ui |
8 | TARGET = networksettings | 8 | TARGET = networksettings |
9 | 9 | ||
10 | 10 | ||
11 | 11 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 12 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index 95f4abe..80a9927 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -1,219 +1,220 @@ | |||
1 | #include "wlanimp.h" | 1 | #include "wlanimp.h" |
2 | #include "interfacesetupimp.h" | 2 | #include "interfacesetupimp.h" |
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qdir.h> | 5 | #include <qdir.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | #include <qspinbox.h> | 10 | #include <qspinbox.h> |
11 | #include <qradiobutton.h> | 11 | #include <qradiobutton.h> |
12 | #include <qcheckbox.h> | 12 | #include <qcheckbox.h> |
13 | #include <qtabwidget.h> | 13 | #include <qtabwidget.h> |
14 | #include <qcombobox.h> | 14 | #include <qcombobox.h> |
15 | 15 | ||
16 | #ifdef QWS | 16 | #ifdef QWS |
17 | #include <opie2/oprocess.h> | 17 | #include <opie2/oprocess.h> |
18 | #else | 18 | #else |
19 | #define OProcess KProcess | 19 | #define OProcess KProcess |
20 | #include <kprocess.h> | 20 | #include <kprocess.h> |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 23 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Constructor, read in the wireless.opts file for parsing later. | 26 | * Constructor, read in the wireless.opts file for parsing later. |
27 | */ | 27 | */ |
28 | using namespace Opie::Core; | ||
28 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { | 29 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { |
29 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); | 30 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); |
30 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 31 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
31 | 32 | ||
32 | // Read in the config file. | 33 | // Read in the config file. |
33 | QString wlanFile = WIRELESS_OPTS; | 34 | QString wlanFile = WIRELESS_OPTS; |
34 | QFile file(wlanFile); | 35 | QFile file(wlanFile); |
35 | if (file.open(IO_ReadOnly)){ | 36 | if (file.open(IO_ReadOnly)){ |
36 | QTextStream stream( &file ); | 37 | QTextStream stream( &file ); |
37 | QString line = ""; | 38 | QString line = ""; |
38 | while ( !stream.eof() ) { | 39 | while ( !stream.eof() ) { |
39 | line += stream.readLine(); | 40 | line += stream.readLine(); |
40 | line += "\n"; | 41 | line += "\n"; |
41 | } | 42 | } |
42 | file.close(); | 43 | file.close(); |
43 | settingsFileText = QStringList::split("\n", line, true); | 44 | settingsFileText = QStringList::split("\n", line, true); |
44 | parseSettingFile(); | 45 | parseSettingFile(); |
45 | } | 46 | } |
46 | else | 47 | else |
47 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); | 48 | qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); |
48 | connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); | 49 | connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); |
49 | } | 50 | } |
50 | 51 | ||
51 | void WLANImp::typeChanged(int mod){ | 52 | void WLANImp::typeChanged(int mod){ |
52 | networkChannel->setEnabled(mod); | 53 | networkChannel->setEnabled(mod); |
53 | channelLabel->setEnabled(mod); | 54 | channelLabel->setEnabled(mod); |
54 | } | 55 | } |
55 | 56 | ||
56 | /** | 57 | /** |
57 | * Change the profile for both wireless settings and network settings. | 58 | * Change the profile for both wireless settings and network settings. |
58 | */ | 59 | */ |
59 | void WLANImp::setProfile(const QString &profile){ | 60 | void WLANImp::setProfile(const QString &profile){ |
60 | interfaceSetup->setProfile(profile); | 61 | interfaceSetup->setProfile(profile); |
61 | parseSettingFile(); | 62 | parseSettingFile(); |
62 | } | 63 | } |
63 | 64 | ||
64 | /** | 65 | /** |
65 | * Parses the settings file that was read in and gets any setting from it. | 66 | * Parses the settings file that was read in and gets any setting from it. |
66 | */ | 67 | */ |
67 | void WLANImp::parseSettingFile(){ | 68 | void WLANImp::parseSettingFile(){ |
68 | bool foundCase = false; | 69 | bool foundCase = false; |
69 | bool found = false; | 70 | bool found = false; |
70 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 71 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
71 | QString line = (*it).simplifyWhiteSpace(); | 72 | QString line = (*it).simplifyWhiteSpace(); |
72 | if(line.contains("case")) | 73 | if(line.contains("case")) |
73 | foundCase = true; | 74 | foundCase = true; |
74 | // See if we found our scheme to write or the sceme couldn't be found | 75 | // See if we found our scheme to write or the sceme couldn't be found |
75 | if((foundCase && line.contains("esac")) || | 76 | if((foundCase && line.contains("esac")) || |
76 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) | 77 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) |
77 | found = true; | 78 | found = true; |
78 | 79 | ||
79 | if(line.contains(";;")) | 80 | if(line.contains(";;")) |
80 | found = false; | 81 | found = false; |
81 | if(found){ | 82 | if(found){ |
82 | // write out scheme | 83 | // write out scheme |
83 | if(line.contains("ESSID=")){ | 84 | if(line.contains("ESSID=")){ |
84 | QString id = line.mid(line.find("ESSID=")+6, line.length()); | 85 | QString id = line.mid(line.find("ESSID=")+6, line.length()); |
85 | if(id == "any"){ | 86 | if(id == "any"){ |
86 | essAny->setChecked(false); | 87 | essAny->setChecked(false); |
87 | }else{ | 88 | }else{ |
88 | essAny->setChecked(true); | 89 | essAny->setChecked(true); |
89 | essSpecificLineEdit->setText(id); | 90 | essSpecificLineEdit->setText(id); |
90 | } | 91 | } |
91 | } | 92 | } |
92 | if(line.contains("MODE=")){ | 93 | if(line.contains("MODE=")){ |
93 | QString mode = line.mid(line.find("MODE=")+5, line.length()); | 94 | QString mode = line.mid(line.find("MODE=")+5, line.length()); |
94 | if(mode == "Managed"){ | 95 | if(mode == "Managed"){ |
95 | networkType->setCurrentItem(0); | 96 | networkType->setCurrentItem(0); |
96 | channelLabel->setEnabled(false); | 97 | channelLabel->setEnabled(false); |
97 | networkChannel->setEnabled(false); | 98 | networkChannel->setEnabled(false); |
98 | } | 99 | } |
99 | else{ | 100 | else{ |
100 | networkType->setCurrentItem(1); | 101 | networkType->setCurrentItem(1); |
101 | networkChannel->setEnabled(true); | 102 | networkChannel->setEnabled(true); |
102 | channelLabel->setEnabled(true); | 103 | channelLabel->setEnabled(true); |
103 | } | 104 | } |
104 | } | 105 | } |
105 | if(line.contains("#KEY0=")) | 106 | if(line.contains("#KEY0=")) |
106 | keyLineEdit0->setText(line.mid(6, line.length())); | 107 | keyLineEdit0->setText(line.mid(6, line.length())); |
107 | if(line.contains("#KEY1=")) | 108 | if(line.contains("#KEY1=")) |
108 | keyLineEdit1->setText(line.mid(6, line.length())); | 109 | keyLineEdit1->setText(line.mid(6, line.length())); |
109 | if(line.contains("#KEY2=")) | 110 | if(line.contains("#KEY2=")) |
110 | keyLineEdit2->setText(line.mid(6, line.length())); | 111 | keyLineEdit2->setText(line.mid(6, line.length())); |
111 | if(line.contains("#KEY3=")) | 112 | if(line.contains("#KEY3=")) |
112 | keyLineEdit3->setText(line.mid(6, line.length())); | 113 | keyLineEdit3->setText(line.mid(6, line.length())); |
113 | 114 | ||
114 | if(line.contains("KEY=")){ | 115 | if(line.contains("KEY=")){ |
115 | wepEnabled->setChecked(true); | 116 | wepEnabled->setChecked(true); |
116 | QString key; | 117 | QString key; |
117 | if(line.right(5) == (" open")){ | 118 | if(line.right(5) == (" open")){ |
118 | key = line.mid(4, line.length()-5); | 119 | key = line.mid(4, line.length()-5); |
119 | authOpen->setChecked(true); | 120 | authOpen->setChecked(true); |
120 | authShared->setChecked(false); | 121 | authShared->setChecked(false); |
121 | } | 122 | } |
122 | else{ | 123 | else{ |
123 | authOpen->setChecked(false); | 124 | authOpen->setChecked(false); |
124 | authShared->setChecked(true); | 125 | authShared->setChecked(true); |
125 | key = line.mid(4, line.length()); | 126 | key = line.mid(4, line.length()); |
126 | } | 127 | } |
127 | if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); | 128 | if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); |
128 | if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); | 129 | if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); |
129 | if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); | 130 | if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); |
130 | if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); | 131 | if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); |
131 | } | 132 | } |
132 | if(line.contains("CHANNEL=")){ | 133 | if(line.contains("CHANNEL=")){ |
133 | networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); | 134 | networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); |
134 | } | 135 | } |
135 | } | 136 | } |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
139 | /** | 140 | /** |
140 | * Saves settings to the wireless.opts file using the current profile | 141 | * Saves settings to the wireless.opts file using the current profile |
141 | */ | 142 | */ |
142 | void WLANImp::changeAndSaveSettingFile(){ | 143 | void WLANImp::changeAndSaveSettingFile(){ |
143 | QString wlanFile = WIRELESS_OPTS; | 144 | QString wlanFile = WIRELESS_OPTS; |
144 | QFile::remove(wlanFile); | 145 | QFile::remove(wlanFile); |
145 | QFile file(wlanFile); | 146 | QFile file(wlanFile); |
146 | 147 | ||
147 | if (!file.open(IO_ReadWrite)){ | 148 | if (!file.open(IO_ReadWrite)){ |
148 | qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); | 149 | qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); |
149 | return; | 150 | return; |
150 | } | 151 | } |
151 | 152 | ||
152 | QTextStream stream( &file ); | 153 | QTextStream stream( &file ); |
153 | bool foundCase = false; | 154 | bool foundCase = false; |
154 | bool found = false; | 155 | bool found = false; |
155 | bool output = true; | 156 | bool output = true; |
156 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { | 157 | for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { |
157 | QString line = (*it).simplifyWhiteSpace(); | 158 | QString line = (*it).simplifyWhiteSpace(); |
158 | if(line.contains("case")) | 159 | if(line.contains("case")) |
159 | foundCase = true; | 160 | foundCase = true; |
160 | // See if we found our scheme to write or the sceme couldn't be found | 161 | // See if we found our scheme to write or the sceme couldn't be found |
161 | if((foundCase && line.contains("esac") && !found) || | 162 | if((foundCase && line.contains("esac") && !found) || |
162 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ | 163 | (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ |
163 | // write out scheme | 164 | // write out scheme |
164 | found = true; | 165 | found = true; |
165 | output = false; | 166 | output = false; |
166 | 167 | ||
167 | if(!line.contains("esac")) | 168 | if(!line.contains("esac")) |
168 | stream << line << "\n"; | 169 | stream << line << "\n"; |
169 | if(!essAny->isChecked() == true){ | 170 | if(!essAny->isChecked() == true){ |
170 | stream << "\tESSID=any\n"; | 171 | stream << "\tESSID=any\n"; |
171 | stream << "\tMODE=Managed\n"; | 172 | stream << "\tMODE=Managed\n"; |
172 | } | 173 | } |
173 | else{ | 174 | else{ |
174 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; | 175 | stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; |
175 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; | 176 | stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; |
176 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; | 177 | stream << "\tCHANNEL=" << networkChannel->value() << "\n"; |
177 | } | 178 | } |
178 | 179 | ||
179 | stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; | 180 | stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; |
180 | stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; | 181 | stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; |
181 | stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; | 182 | stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; |
182 | stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; | 183 | stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; |
183 | 184 | ||
184 | if(wepEnabled->isChecked()){ | 185 | if(wepEnabled->isChecked()){ |
185 | stream << "\tKEY=\""; | 186 | stream << "\tKEY=\""; |
186 | if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); | 187 | if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); |
187 | if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); | 188 | if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); |
188 | if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); | 189 | if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); |
189 | if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); | 190 | if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); |
190 | if(authOpen->isChecked()) | 191 | if(authOpen->isChecked()) |
191 | stream << " open"; | 192 | stream << " open"; |
192 | else | 193 | else |
193 | stream << " restricted"; | 194 | stream << " restricted"; |
194 | stream << "\"\n"; | 195 | stream << "\"\n"; |
195 | } | 196 | } |
196 | stream << "\tRATE=auto\n"; | 197 | stream << "\tRATE=auto\n"; |
197 | if(line.contains("esac")) | 198 | if(line.contains("esac")) |
198 | stream << line << "\n"; | 199 | stream << line << "\n"; |
199 | } | 200 | } |
200 | if(line.contains(";;")) | 201 | if(line.contains(";;")) |
201 | output = true; | 202 | output = true; |
202 | if(output && (*it).length() ) | 203 | if(output && (*it).length() ) |
203 | stream << (*it) << '\n'; | 204 | stream << (*it) << '\n'; |
204 | } | 205 | } |
205 | file.close(); | 206 | file.close(); |
206 | } | 207 | } |
207 | 208 | ||
208 | /** | 209 | /** |
209 | * Check to see if the current config is valid | 210 | * Check to see if the current config is valid |
210 | * Save wireless.opts, save interfaces | 211 | * Save wireless.opts, save interfaces |
211 | */ | 212 | */ |
212 | void WLANImp::accept(){ | 213 | void WLANImp::accept(){ |
213 | if(wepEnabled->isChecked()){ | 214 | if(wepEnabled->isChecked()){ |
214 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ | 215 | if(keyLineEdit0->text().isEmpty() && keyLineEdit1->text().isEmpty() && keyLineEdit2->text().isEmpty() && keyLineEdit3->text().isEmpty() ){ |
215 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); | 216 | QMessageBox::information(this, "Error", "Please enter a key for WEP.", QMessageBox::Ok); |
216 | return; | 217 | return; |
217 | } | 218 | } |
218 | } | 219 | } |
219 | 220 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index dd1db28..eeebe7f 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -1,236 +1,238 @@ | |||
1 | #include "wlanimp2.h" | 1 | #include "wlanimp2.h" |
2 | #include "keyedit.h" | 2 | #include "keyedit.h" |
3 | #include "interfacesetupimp.h" | 3 | #include "interfacesetupimp.h" |
4 | 4 | ||
5 | #include "../interfaces/interface.h" | 5 | #include "../interfaces/interface.h" |
6 | 6 | ||
7 | #include <assert.h> | 7 | #include <assert.h> |
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #include <qapplication.h> | 11 | #include <qapplication.h> |
12 | #include <qfile.h> | 12 | #include <qfile.h> |
13 | #include <qdir.h> | 13 | #include <qdir.h> |
14 | #include <qdialog.h> | 14 | #include <qdialog.h> |
15 | #include <qtextstream.h> | 15 | #include <qtextstream.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <qlineedit.h> | 17 | #include <qlineedit.h> |
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qspinbox.h> | 19 | #include <qspinbox.h> |
20 | #include <qradiobutton.h> | 20 | #include <qradiobutton.h> |
21 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
22 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qprogressbar.h> | 27 | #include <qprogressbar.h> |
28 | 28 | ||
29 | #ifdef QWS | 29 | #ifdef QWS |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <opie2/oprocess.h> | 31 | #include <opie2/oprocess.h> |
32 | #include <opie2/onetwork.h> | 32 | #include <opie2/onetwork.h> |
33 | #include <opie2/opcap.h> | 33 | #include <opie2/opcap.h> |
34 | #else | 34 | #else |
35 | #define OProcess KProcess | 35 | #define OProcess KProcess |
36 | #include <kprocess.h> | 36 | #include <kprocess.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 39 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
40 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" | 40 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Constructor, read in the wireless.opts file for parsing later. | 43 | * Constructor, read in the wireless.opts file for parsing later. |
44 | */ | 44 | */ |
45 | using namespace Opie::Net; | ||
46 | using namespace Opie::Core; | ||
45 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { | 47 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { |
46 | interfaces = new Interfaces(); | 48 | interfaces = new Interfaces(); |
47 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 49 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
48 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 50 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
49 | 51 | ||
50 | // Check sanity - the existance of the wireless-tools if-pre-up script | 52 | // Check sanity - the existance of the wireless-tools if-pre-up script |
51 | QFile file(QString(PREUP)); | 53 | QFile file(QString(PREUP)); |
52 | if (file.exists()) { | 54 | if (file.exists()) { |
53 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); | 55 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); |
54 | } | 56 | } |
55 | 57 | ||
56 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); | 58 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); |
57 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); | 59 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); |
58 | netView->setColumnAlignment( col_chn, AlignCenter ); | 60 | netView->setColumnAlignment( col_chn, AlignCenter ); |
59 | netView->setItemMargin( 3 ); | 61 | netView->setItemMargin( 3 ); |
60 | netView->setAllColumnsShowFocus( true ); | 62 | netView->setAllColumnsShowFocus( true ); |
61 | 63 | ||
62 | } | 64 | } |
63 | 65 | ||
64 | WLANImp::~WLANImp() { | 66 | WLANImp::~WLANImp() { |
65 | //FIXME: delete interfaces; | 67 | //FIXME: delete interfaces; |
66 | } | 68 | } |
67 | 69 | ||
68 | /** | 70 | /** |
69 | * Change the profile for both wireless settings and network settings. | 71 | * Change the profile for both wireless settings and network settings. |
70 | */ | 72 | */ |
71 | void WLANImp::setProfile(const QString &profile){ | 73 | void WLANImp::setProfile(const QString &profile){ |
72 | interfaceSetup->setProfile(profile); | 74 | interfaceSetup->setProfile(profile); |
73 | parseOpts(); | 75 | parseOpts(); |
74 | } | 76 | } |
75 | 77 | ||
76 | void WLANImp::parseOpts() { | 78 | void WLANImp::parseOpts() { |
77 | bool error; | 79 | bool error; |
78 | QString opt; | 80 | QString opt; |
79 | 81 | ||
80 | if (! interfaces->isInterfaceSet()) | 82 | if (! interfaces->isInterfaceSet()) |
81 | return; | 83 | return; |
82 | 84 | ||
83 | 85 | ||
84 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 86 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
85 | if(opt == "any" || opt == "off" || opt.isNull()){ | 87 | if(opt == "any" || opt == "off" || opt.isNull()){ |
86 | essid->setEditText("any"); | 88 | essid->setEditText("any"); |
87 | } else { | 89 | } else { |
88 | essid->setEditText(opt); | 90 | essid->setEditText(opt); |
89 | } | 91 | } |
90 | 92 | ||
91 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); | 93 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); |
92 | 94 | ||
93 | for ( int i = 0; i < mode->count(); i++) | 95 | for ( int i = 0; i < mode->count(); i++) |
94 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); | 96 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); |
95 | 97 | ||
96 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); | 98 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); |
97 | if (! opt.isNull()) { | 99 | if (! opt.isNull()) { |
98 | specifyAp->setChecked(true); | 100 | specifyAp->setChecked(true); |
99 | macEdit->setText(opt); | 101 | macEdit->setText(opt); |
100 | } | 102 | } |
101 | 103 | ||
102 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 104 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
103 | if (! opt.isNull()) { | 105 | if (! opt.isNull()) { |
104 | specifyChan->setChecked(true); | 106 | specifyChan->setChecked(true); |
105 | networkChannel->setValue(opt.toInt()); | 107 | networkChannel->setValue(opt.toInt()); |
106 | } | 108 | } |
107 | 109 | ||
108 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 110 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); |
109 | if (opt.isNull()) | 111 | if (opt.isNull()) |
110 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 112 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
111 | parseKeyStr(opt); | 113 | parseKeyStr(opt); |
112 | } | 114 | } |
113 | 115 | ||
114 | void WLANImp::parseKeyStr(QString keystr) { | 116 | void WLANImp::parseKeyStr(QString keystr) { |
115 | int loc = 0; | 117 | int loc = 0; |
116 | int index = 1; | 118 | int index = 1; |
117 | QString key; | 119 | QString key; |
118 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 120 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
119 | int enc = -1; // encryption state | 121 | int enc = -1; // encryption state |
120 | 122 | ||
121 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { | 123 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { |
122 | if ((*it).left(3) == "off") { | 124 | if ((*it).left(3) == "off") { |
123 | // encryption disabled | 125 | // encryption disabled |
124 | enc = 0; | 126 | enc = 0; |
125 | } else if ((*it).left(2) == "on") { | 127 | } else if ((*it).left(2) == "on") { |
126 | // encryption enabled | 128 | // encryption enabled |
127 | enc = 1; | 129 | enc = 1; |
128 | } else if ((*it).left(4) == "open") { | 130 | } else if ((*it).left(4) == "open") { |
129 | // open mode, accept non encrypted packets | 131 | // open mode, accept non encrypted packets |
130 | acceptNonEnc->setChecked(true); | 132 | acceptNonEnc->setChecked(true); |
131 | } else if ((*it).left(10) == "restricted") { | 133 | } else if ((*it).left(10) == "restricted") { |
132 | // restricted mode, only accept encrypted packets | 134 | // restricted mode, only accept encrypted packets |
133 | rejectNonEnc->setChecked(true); | 135 | rejectNonEnc->setChecked(true); |
134 | } else if ((*it).left(3) == "key") { | 136 | } else if ((*it).left(3) == "key") { |
135 | // new set of options | 137 | // new set of options |
136 | } else if ((*it).left(1) == "[") { | 138 | } else if ((*it).left(1) == "[") { |
137 | index = (*it).mid(1, 1).toInt(); | 139 | index = (*it).mid(1, 1).toInt(); |
138 | // switch current key to index | 140 | // switch current key to index |
139 | switch (index) { | 141 | switch (index) { |
140 | case 1: | 142 | case 1: |
141 | keyRadio0->setChecked(true); | 143 | keyRadio0->setChecked(true); |
142 | break; | 144 | break; |
143 | case 2: | 145 | case 2: |
144 | keyRadio1->setChecked(true); | 146 | keyRadio1->setChecked(true); |
145 | break; | 147 | break; |
146 | case 3: | 148 | case 3: |
147 | keyRadio2->setChecked(true); | 149 | keyRadio2->setChecked(true); |
148 | break; | 150 | break; |
149 | case 4: | 151 | case 4: |
150 | keyRadio3->setChecked(true); | 152 | keyRadio3->setChecked(true); |
151 | break; | 153 | break; |
152 | } | 154 | } |
153 | } else { | 155 | } else { |
154 | // key | 156 | // key |
155 | key = (*it); | 157 | key = (*it); |
156 | } | 158 | } |
157 | if (! key.isNull()) { | 159 | if (! key.isNull()) { |
158 | if (enc == -1) | 160 | if (enc == -1) |
159 | enc = 1; | 161 | enc = 1; |
160 | QStringList::Iterator next = ++it; | 162 | QStringList::Iterator next = ++it; |
161 | if (it == keys.end()) { | 163 | if (it == keys.end()) { |
162 | break; | 164 | break; |
163 | } | 165 | } |
164 | if ((*(next)).left(1) == "[") { | 166 | if ((*(next)).left(1) == "[") { |
165 | // set key at index | 167 | // set key at index |
166 | index = (*(next)).mid(1, 1).toInt(); | 168 | index = (*(next)).mid(1, 1).toInt(); |
167 | } else { | 169 | } else { |
168 | index = 1; | 170 | index = 1; |
169 | } | 171 | } |
170 | switch (index) { | 172 | switch (index) { |
171 | case 1: | 173 | case 1: |
172 | keyLineEdit0->setText(key); | 174 | keyLineEdit0->setText(key); |
173 | break; | 175 | break; |
174 | case 2: | 176 | case 2: |
175 | keyLineEdit1->setText(key); | 177 | keyLineEdit1->setText(key); |
176 | break; | 178 | break; |
177 | case 3: | 179 | case 3: |
178 | keyLineEdit2->setText(key); | 180 | keyLineEdit2->setText(key); |
179 | break; | 181 | break; |
180 | case 4: | 182 | case 4: |
181 | keyLineEdit3->setText(key); | 183 | keyLineEdit3->setText(key); |
182 | break; | 184 | break; |
183 | } | 185 | } |
184 | key = QString::null; | 186 | key = QString::null; |
185 | } | 187 | } |
186 | } | 188 | } |
187 | if (enc == 1) { | 189 | if (enc == 1) { |
188 | wepEnabled->setChecked(true); | 190 | wepEnabled->setChecked(true); |
189 | } else { | 191 | } else { |
190 | wepEnabled->setChecked(false); | 192 | wepEnabled->setChecked(false); |
191 | } | 193 | } |
192 | } | 194 | } |
193 | 195 | ||
194 | /** | 196 | /** |
195 | * Check to see if the current config is valid | 197 | * Check to see if the current config is valid |
196 | * Save interfaces | 198 | * Save interfaces |
197 | */ | 199 | */ |
198 | void WLANImp::accept() { | 200 | void WLANImp::accept() { |
199 | if (wepEnabled->isChecked()) { | 201 | if (wepEnabled->isChecked()) { |
200 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || | 202 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || |
201 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || | 203 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || |
202 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || | 204 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || |
203 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { | 205 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { |
204 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); | 206 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); |
205 | return; | 207 | return; |
206 | } | 208 | } |
207 | } | 209 | } |
208 | 210 | ||
209 | if (essid->currentText().isEmpty()) { | 211 | if (essid->currentText().isEmpty()) { |
210 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); | 212 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); |
211 | return; | 213 | return; |
212 | } | 214 | } |
213 | 215 | ||
214 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { | 216 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { |
215 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); | 217 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); |
216 | return; | 218 | return; |
217 | } | 219 | } |
218 | 220 | ||
219 | // Try to save the interfaces settings. | 221 | // Try to save the interfaces settings. |
220 | writeOpts(); | 222 | writeOpts(); |
221 | 223 | ||
222 | // Close out the dialog | 224 | // Close out the dialog |
223 | // FIXME: QDialog::accept(); | 225 | // FIXME: QDialog::accept(); |
224 | } | 226 | } |
225 | 227 | ||
226 | void WLANImp::writeOpts() { | 228 | void WLANImp::writeOpts() { |
227 | // eh can't really do anything about it other then return. :-D | 229 | // eh can't really do anything about it other then return. :-D |
228 | if(!interfaces->isInterfaceSet()){ | 230 | if(!interfaces->isInterfaceSet()){ |
229 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 231 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
230 | return; | 232 | return; |
231 | } | 233 | } |
232 | bool error = false; | 234 | bool error = false; |
233 | 235 | ||
234 | qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() ); | 236 | qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() ); |
235 | 237 | ||
236 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 238 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.h b/noncore/settings/networksettings/wlan/wlanimp2.h index a777203..c3d1eee 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.h +++ b/noncore/settings/networksettings/wlan/wlanimp2.h | |||
@@ -1,52 +1,52 @@ | |||
1 | #ifndef WLANIMP_H | 1 | #ifndef WLANIMP_H |
2 | #define WLANIMP_H | 2 | #define WLANIMP_H |
3 | 3 | ||
4 | #include "wlan.h" | 4 | #include "wlan.h" |
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | #include <opie2/onetutils.h> | 7 | #include <opie2/onetutils.h> |
8 | 8 | ||
9 | class InterfaceSetupImp; | 9 | class InterfaceSetupImp; |
10 | class Interface; | 10 | class Interface; |
11 | class Config; | 11 | class Config; |
12 | class OPacket; | 12 | namespace Opie {namespace Net {class OPacket;}} |
13 | class QListViewItem; | 13 | class QListViewItem; |
14 | 14 | ||
15 | const int col_mode= 0; | 15 | const int col_mode= 0; |
16 | const int col_ssid = 1; | 16 | const int col_ssid = 1; |
17 | const int col_chn = 2; | 17 | const int col_chn = 2; |
18 | const int col_mac = 3; | 18 | const int col_mac = 3; |
19 | 19 | ||
20 | class WLANImp : public WLAN { | 20 | class WLANImp : public WLAN { |
21 | Q_OBJECT | 21 | Q_OBJECT |
22 | 22 | ||
23 | public: | 23 | public: |
24 | WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); | 24 | WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); |
25 | ~WLANImp(); | 25 | ~WLANImp(); |
26 | void setProfile(const QString &profile); | 26 | void setProfile(const QString &profile); |
27 | 27 | ||
28 | public slots: | 28 | public slots: |
29 | void rescanNeighbourhood(); | 29 | void rescanNeighbourhood(); |
30 | void selectNetwork( QListViewItem* ); | 30 | void selectNetwork( QListViewItem* ); |
31 | 31 | ||
32 | protected: | 32 | protected: |
33 | void accept(); | 33 | void accept(); |
34 | 34 | ||
35 | private: | 35 | private: |
36 | void parseOpts(); | 36 | void parseOpts(); |
37 | void writeOpts(); | 37 | void writeOpts(); |
38 | 38 | ||
39 | void parseKeyStr(QString keystr); | 39 | void parseKeyStr(QString keystr); |
40 | 40 | ||
41 | void handlePacket( OPacket* ); | 41 | void handlePacket( Opie::Net::OPacket* ); |
42 | void displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const OMacAddress& mac ); | 42 | void displayFoundNetwork( const QString& mode, int channel, const QString& ssid, const Opie::Net::OMacAddress& mac ); |
43 | 43 | ||
44 | InterfaceSetupImp *interfaceSetup; | 44 | InterfaceSetupImp *interfaceSetup; |
45 | Interfaces *interfaces; | 45 | Interfaces *interfaces; |
46 | Interface *interface; | 46 | Interface *interface; |
47 | 47 | ||
48 | QString currentProfile; | 48 | QString currentProfile; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | #endif | 51 | #endif |
52 | 52 | ||
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index aedd972..4a55c10 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -1,301 +1,302 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "installdlg.h" | 30 | #include "installdlg.h" |
31 | 31 | ||
32 | #include <sys/vfs.h> | 32 | #include <sys/vfs.h> |
33 | 33 | ||
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qfileinfo.h> | 36 | #include <qfileinfo.h> |
37 | #include <qgroupbox.h> | 37 | #include <qgroupbox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qmap.h> | 40 | #include <qmap.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | 43 | ||
44 | #include <qpe/fileselector.h> | 44 | #include <qpe/fileselector.h> |
45 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
46 | #include <qpe/storage.h> | 46 | #include <qpe/storage.h> |
47 | 47 | ||
48 | #include <opie2/ofiledialog.h> | 48 | #include <opie2/ofiledialog.h> |
49 | 49 | ||
50 | #include "opackagemanager.h" | 50 | #include "opackagemanager.h" |
51 | 51 | ||
52 | using namespace Opie::Ui; | ||
52 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, | 53 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, |
53 | OPackage::Command command1, QStringList *packages1, | 54 | OPackage::Command command1, QStringList *packages1, |
54 | OPackage::Command command2, QStringList *packages2, | 55 | OPackage::Command command2, QStringList *packages2, |
55 | OPackage::Command command3, QStringList *packages3 ) | 56 | OPackage::Command command3, QStringList *packages3 ) |
56 | : QWidget( 0x0 ) | 57 | : QWidget( 0x0 ) |
57 | , m_packman( pm ) | 58 | , m_packman( pm ) |
58 | , m_numCommands( 0 ) | 59 | , m_numCommands( 0 ) |
59 | , m_currCommand( 0 ) | 60 | , m_currCommand( 0 ) |
60 | { | 61 | { |
61 | // Save command/package list information | 62 | // Save command/package list information |
62 | if ( command1 != OPackage::NotDefined ) | 63 | if ( command1 != OPackage::NotDefined ) |
63 | { | 64 | { |
64 | m_command[ m_numCommands ] = command1; | 65 | m_command[ m_numCommands ] = command1; |
65 | m_packages[ m_numCommands ] = packages1; | 66 | m_packages[ m_numCommands ] = packages1; |
66 | ++m_numCommands; | 67 | ++m_numCommands; |
67 | } | 68 | } |
68 | if ( command2 != OPackage::NotDefined ) | 69 | if ( command2 != OPackage::NotDefined ) |
69 | { | 70 | { |
70 | m_command[ m_numCommands ] = command2; | 71 | m_command[ m_numCommands ] = command2; |
71 | m_packages[ m_numCommands ] = packages2; | 72 | m_packages[ m_numCommands ] = packages2; |
72 | ++m_numCommands; | 73 | ++m_numCommands; |
73 | } | 74 | } |
74 | if ( command3 != OPackage::NotDefined ) | 75 | if ( command3 != OPackage::NotDefined ) |
75 | { | 76 | { |
76 | m_command[ m_numCommands ] = command3; | 77 | m_command[ m_numCommands ] = command3; |
77 | m_packages[ m_numCommands ] = packages3; | 78 | m_packages[ m_numCommands ] = packages3; |
78 | ++m_numCommands; | 79 | ++m_numCommands; |
79 | } | 80 | } |
80 | 81 | ||
81 | // Initialize UI | 82 | // Initialize UI |
82 | if ( parent ) | 83 | if ( parent ) |
83 | parent->setCaption( caption ); | 84 | parent->setCaption( caption ); |
84 | 85 | ||
85 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); | 86 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); |
86 | 87 | ||
87 | if ( showDestInfo ) | 88 | if ( showDestInfo ) |
88 | { | 89 | { |
89 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 90 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
90 | layout->addWidget( label, 0, 0 ); | 91 | layout->addWidget( label, 0, 0 ); |
91 | m_destination = new QComboBox( this ); | 92 | m_destination = new QComboBox( this ); |
92 | m_destination->insertStringList( *(m_packman->destinations()) ); | 93 | m_destination->insertStringList( *(m_packman->destinations()) ); |
93 | layout->addWidget( m_destination, 0, 1 ); | 94 | layout->addWidget( m_destination, 0, 1 ); |
94 | connect( m_destination, SIGNAL(highlighted(const QString&)), | 95 | connect( m_destination, SIGNAL(highlighted(const QString&)), |
95 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); | 96 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); |
96 | 97 | ||
97 | label = new QLabel( tr( "Space Avail" ), this ); | 98 | label = new QLabel( tr( "Space Avail" ), this ); |
98 | layout->addWidget( label, 1, 0 ); | 99 | layout->addWidget( label, 1, 0 ); |
99 | m_availSpace = new QLabel( this ); | 100 | m_availSpace = new QLabel( this ); |
100 | layout->addWidget( m_availSpace, 1, 1 ); | 101 | layout->addWidget( m_availSpace, 1, 1 ); |
101 | 102 | ||
102 | // TODO - select correct destination | 103 | // TODO - select correct destination |
103 | slotDisplayAvailSpace( m_destination->currentText() ); | 104 | slotDisplayAvailSpace( m_destination->currentText() ); |
104 | } | 105 | } |
105 | else | 106 | else |
106 | { | 107 | { |
107 | m_destination = 0x0; | 108 | m_destination = 0x0; |
108 | m_availSpace = 0x0; | 109 | m_availSpace = 0x0; |
109 | } | 110 | } |
110 | 111 | ||
111 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 112 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
112 | groupBox->layout()->setSpacing( 0 ); | 113 | groupBox->layout()->setSpacing( 0 ); |
113 | groupBox->layout()->setMargin( 4 ); | 114 | groupBox->layout()->setMargin( 4 ); |
114 | 115 | ||
115 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); | 116 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); |
116 | m_output = new QMultiLineEdit( groupBox ); | 117 | m_output = new QMultiLineEdit( groupBox ); |
117 | m_output->setReadOnly( true ); | 118 | m_output->setReadOnly( true ); |
118 | groupBoxLayout->addWidget( m_output ); | 119 | groupBoxLayout->addWidget( m_output ); |
119 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); | 120 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); |
120 | 121 | ||
121 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); | 122 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); |
122 | layout->addWidget( m_btnStart, 3, 0 ); | 123 | layout->addWidget( m_btnStart, 3, 0 ); |
123 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); | 124 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); |
124 | 125 | ||
125 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 126 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
126 | layout->addWidget( m_btnOptions, 3, 1 ); | 127 | layout->addWidget( m_btnOptions, 3, 1 ); |
127 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); | 128 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); |
128 | 129 | ||
129 | // Display packages being acted upon in output widget | 130 | // Display packages being acted upon in output widget |
130 | for( int i = 0; i < m_numCommands; i++ ) | 131 | for( int i = 0; i < m_numCommands; i++ ) |
131 | { | 132 | { |
132 | if ( m_packages[ i ] ) | 133 | if ( m_packages[ i ] ) |
133 | { | 134 | { |
134 | QString lineStr = tr( "Packages to " ); | 135 | QString lineStr = tr( "Packages to " ); |
135 | 136 | ||
136 | switch( m_command[ i ] ) | 137 | switch( m_command[ i ] ) |
137 | { | 138 | { |
138 | case OPackage::Install : lineStr.append( tr( "install" ) ); | 139 | case OPackage::Install : lineStr.append( tr( "install" ) ); |
139 | break; | 140 | break; |
140 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); | 141 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); |
141 | break; | 142 | break; |
142 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); | 143 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); |
143 | break; | 144 | break; |
144 | case OPackage::Download : lineStr.append( tr( "download" ) ); | 145 | case OPackage::Download : lineStr.append( tr( "download" ) ); |
145 | break; | 146 | break; |
146 | default : | 147 | default : |
147 | break; | 148 | break; |
148 | }; | 149 | }; |
149 | lineStr.append( ":\n" ); | 150 | lineStr.append( ":\n" ); |
150 | 151 | ||
151 | for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) | 152 | for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) |
152 | { | 153 | { |
153 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); | 154 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); |
154 | } | 155 | } |
155 | 156 | ||
156 | m_output->append( lineStr ); | 157 | m_output->append( lineStr ); |
157 | } | 158 | } |
158 | } | 159 | } |
159 | 160 | ||
160 | m_output->append( tr( "Press the start button to begin.\n" ) ); | 161 | m_output->append( tr( "Press the start button to begin.\n" ) ); |
161 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 162 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | InstallDlg::~InstallDlg() | 166 | InstallDlg::~InstallDlg() |
166 | { | 167 | { |
167 | for( int i = 0; i < m_numCommands; i++ ) | 168 | for( int i = 0; i < m_numCommands; i++ ) |
168 | { | 169 | { |
169 | if ( m_packages[ i ] ) | 170 | if ( m_packages[ i ] ) |
170 | delete m_packages[ i ]; | 171 | delete m_packages[ i ]; |
171 | } | 172 | } |
172 | } | 173 | } |
173 | 174 | ||
174 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 175 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
175 | { | 176 | { |
176 | // If available space is not displayed, exit | 177 | // If available space is not displayed, exit |
177 | if ( !m_availSpace ) | 178 | if ( !m_availSpace ) |
178 | return; | 179 | return; |
179 | 180 | ||
180 | QString space = tr( "Unknown" ); | 181 | QString space = tr( "Unknown" ); |
181 | 182 | ||
182 | // Get destination | 183 | // Get destination |
183 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); | 184 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); |
184 | 185 | ||
185 | if ( dest ) | 186 | if ( dest ) |
186 | { | 187 | { |
187 | // Calculate available space | 188 | // Calculate available space |
188 | struct statfs fs; | 189 | struct statfs fs; |
189 | if ( !statfs( dest->value(), &fs ) ) | 190 | if ( !statfs( dest->value(), &fs ) ) |
190 | { | 191 | { |
191 | long mult = fs.f_bsize / 1024; | 192 | long mult = fs.f_bsize / 1024; |
192 | long div = 1024 / fs.f_bsize; | 193 | long div = 1024 / fs.f_bsize; |
193 | 194 | ||
194 | if ( !mult ) mult = 1; | 195 | if ( !mult ) mult = 1; |
195 | if ( !div ) div = 1; | 196 | if ( !div ) div = 1; |
196 | long avail = fs.f_bavail * mult / div; | 197 | long avail = fs.f_bavail * mult / div; |
197 | 198 | ||
198 | space = tr( "%1 Kb" ).arg( avail ); | 199 | space = tr( "%1 Kb" ).arg( avail ); |
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | // Display available space | 203 | // Display available space |
203 | m_availSpace->setText( space ); | 204 | m_availSpace->setText( space ); |
204 | } | 205 | } |
205 | 206 | ||
206 | void InstallDlg::slotBtnStart() | 207 | void InstallDlg::slotBtnStart() |
207 | { | 208 | { |
208 | QString btnText = m_btnStart->text(); | 209 | QString btnText = m_btnStart->text(); |
209 | if ( btnText == tr( "Abort" ) ) | 210 | if ( btnText == tr( "Abort" ) ) |
210 | { | 211 | { |
211 | // Prevent unexecuted commands from executing | 212 | // Prevent unexecuted commands from executing |
212 | m_currCommand = 999; | 213 | m_currCommand = 999; |
213 | 214 | ||
214 | // Allow user to close dialog | 215 | // Allow user to close dialog |
215 | m_btnStart->setText( tr( "Close" ) ); | 216 | m_btnStart->setText( tr( "Close" ) ); |
216 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 217 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
217 | return; | 218 | return; |
218 | } | 219 | } |
219 | else if ( btnText == tr( "Close" ) ) | 220 | else if ( btnText == tr( "Close" ) ) |
220 | { | 221 | { |
221 | // TODO - force reload of package data | 222 | // TODO - force reload of package data |
222 | emit closeInstallDlg(); | 223 | emit closeInstallDlg(); |
223 | return; | 224 | return; |
224 | } | 225 | } |
225 | 226 | ||
226 | // Start was clicked, start executing | 227 | // Start was clicked, start executing |
227 | m_btnOptions->setEnabled( false ); | 228 | m_btnOptions->setEnabled( false ); |
228 | if ( m_numCommands > 1 ) | 229 | if ( m_numCommands > 1 ) |
229 | { | 230 | { |
230 | m_btnStart->setText( tr( "Abort" ) ); | 231 | m_btnStart->setText( tr( "Abort" ) ); |
231 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); | 232 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); |
232 | } | 233 | } |
233 | else | 234 | else |
234 | { | 235 | { |
235 | m_btnStart->setEnabled( false ); | 236 | m_btnStart->setEnabled( false ); |
236 | } | 237 | } |
237 | 238 | ||
238 | QString dest; | 239 | QString dest; |
239 | if ( m_destination ) | 240 | if ( m_destination ) |
240 | dest = m_destination->currentText(); | 241 | dest = m_destination->currentText(); |
241 | 242 | ||
242 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 243 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
243 | { | 244 | { |
244 | // Execute next command | 245 | // Execute next command |
245 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 246 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
246 | this, SLOT(slotOutput(char*)), true ); | 247 | this, SLOT(slotOutput(char*)), true ); |
247 | } | 248 | } |
248 | 249 | ||
249 | // All commands executed, allow user to close dialog | 250 | // All commands executed, allow user to close dialog |
250 | m_btnStart->setEnabled( true ); | 251 | m_btnStart->setEnabled( true ); |
251 | m_btnStart->setText( tr( "Close" ) ); | 252 | m_btnStart->setText( tr( "Close" ) ); |
252 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 253 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
253 | 254 | ||
254 | m_btnOptions->setEnabled( true ); | 255 | m_btnOptions->setEnabled( true ); |
255 | m_btnOptions->setText( tr( "Save output" ) ); | 256 | m_btnOptions->setText( tr( "Save output" ) ); |
256 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 257 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); |
257 | } | 258 | } |
258 | 259 | ||
259 | void InstallDlg::slotBtnOptions() | 260 | void InstallDlg::slotBtnOptions() |
260 | { | 261 | { |
261 | QString btnText = m_btnOptions->text(); | 262 | QString btnText = m_btnOptions->text(); |
262 | if ( btnText == tr( "Options" ) ) | 263 | if ( btnText == tr( "Options" ) ) |
263 | { | 264 | { |
264 | // Display configuration dialog (only options tab is enabled) | 265 | // Display configuration dialog (only options tab is enabled) |
265 | m_packman->configureDlg( true ); | 266 | m_packman->configureDlg( true ); |
266 | return; | 267 | return; |
267 | } | 268 | } |
268 | 269 | ||
269 | // Save output was clicked | 270 | // Save output was clicked |
270 | QMap<QString, QStringList> map; | 271 | QMap<QString, QStringList> map; |
271 | map.insert( tr( "All" ), QStringList() ); | 272 | map.insert( tr( "All" ), QStringList() ); |
272 | QStringList text; | 273 | QStringList text; |
273 | text << "text/*"; | 274 | text << "text/*"; |
274 | map.insert(tr( "Text" ), text ); | 275 | map.insert(tr( "Text" ), text ); |
275 | text << "*"; | 276 | text << "*"; |
276 | map.insert( tr( "All" ), text ); | 277 | map.insert( tr( "All" ), text ); |
277 | 278 | ||
278 | QString filename = Opie::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 279 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
279 | if( !filename.isEmpty() ) | 280 | if( !filename.isEmpty() ) |
280 | { | 281 | { |
281 | QString currentFileName = QFileInfo( filename ).fileName(); | 282 | QString currentFileName = QFileInfo( filename ).fileName(); |
282 | DocLnk doc; | 283 | DocLnk doc; |
283 | doc.setType( "text/plain" ); | 284 | doc.setType( "text/plain" ); |
284 | doc.setFile( filename ); | 285 | doc.setFile( filename ); |
285 | doc.setName( currentFileName ); | 286 | doc.setName( currentFileName ); |
286 | FileManager fm; | 287 | FileManager fm; |
287 | fm.saveFile( doc, m_output->text() ); | 288 | fm.saveFile( doc, m_output->text() ); |
288 | } | 289 | } |
289 | } | 290 | } |
290 | 291 | ||
291 | void InstallDlg::slotOutput( char *msg ) | 292 | void InstallDlg::slotOutput( char *msg ) |
292 | { | 293 | { |
293 | // Allow processing of other events | 294 | // Allow processing of other events |
294 | qApp->processEvents(); | 295 | qApp->processEvents(); |
295 | 296 | ||
296 | QString lineStr = msg; | 297 | QString lineStr = msg; |
297 | if ( lineStr[lineStr.length()-1] == '\n' ) | 298 | if ( lineStr[lineStr.length()-1] == '\n' ) |
298 | lineStr.truncate( lineStr.length() - 1 ); | 299 | lineStr.truncate( lineStr.length() - 1 ); |
299 | m_output->append( lineStr ); | 300 | m_output->append( lineStr ); |
300 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 301 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
301 | } | 302 | } |
diff --git a/noncore/settings/packagemanager/main.cpp b/noncore/settings/packagemanager/main.cpp index 18ed644..c050e1a 100644 --- a/noncore/settings/packagemanager/main.cpp +++ b/noncore/settings/packagemanager/main.cpp | |||
@@ -1,34 +1,35 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "mainwindow.h" | 30 | #include "mainwindow.h" |
31 | 31 | ||
32 | #include <opie2/oapplicationfactory.h> | 32 | #include <opie2/oapplicationfactory.h> |
33 | 33 | ||
34 | using namespace Opie::Core; | ||
34 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) | 35 | OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) |
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index 84c6de4..592de3e 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp | |||
@@ -1,236 +1,237 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "oipkgconfigdlg.h" | 32 | #include "oipkgconfigdlg.h" |
33 | 33 | ||
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qgroupbox.h> | 36 | #include <qgroupbox.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qlistbox.h> | 39 | #include <qlistbox.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qscrollview.h> | 41 | #include <qscrollview.h> |
42 | 42 | ||
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | 44 | ||
45 | using namespace Opie::Ui; | ||
45 | OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) | 46 | OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) |
46 | : QDialog( parent, QString::null, true ) | 47 | : QDialog( parent, QString::null, true ) |
47 | , m_ipkg( ipkg ) | 48 | , m_ipkg( ipkg ) |
48 | , m_configs( 0x0 ) | 49 | , m_configs( 0x0 ) |
49 | , m_installOptions( installOptions ) | 50 | , m_installOptions( installOptions ) |
50 | , m_serverNew( false ) | 51 | , m_serverNew( false ) |
51 | , m_serverCurrent( -1 ) | 52 | , m_serverCurrent( -1 ) |
52 | , m_destNew( false ) | 53 | , m_destNew( false ) |
53 | , m_destCurrent( -1 ) | 54 | , m_destCurrent( -1 ) |
54 | , m_layout( this, 2, 4 ) | 55 | , m_layout( this, 2, 4 ) |
55 | , m_tabWidget( this ) | 56 | , m_tabWidget( this ) |
56 | { | 57 | { |
57 | setCaption( tr( "Configuration" ) ); | 58 | setCaption( tr( "Configuration" ) ); |
58 | 59 | ||
59 | // Initialize configuration widgets | 60 | // Initialize configuration widgets |
60 | if ( !installOptions ) | 61 | if ( !installOptions ) |
61 | { | 62 | { |
62 | initServerWidget(); | 63 | initServerWidget(); |
63 | initDestinationWidget(); | 64 | initDestinationWidget(); |
64 | initProxyWidget(); | 65 | initProxyWidget(); |
65 | } | 66 | } |
66 | initOptionsWidget(); | 67 | initOptionsWidget(); |
67 | 68 | ||
68 | // Load configuration information | 69 | // Load configuration information |
69 | initData(); | 70 | initData(); |
70 | 71 | ||
71 | // Setup tabs for all info | 72 | // Setup tabs for all info |
72 | m_layout.addWidget( &m_tabWidget ); | 73 | m_layout.addWidget( &m_tabWidget ); |
73 | if ( !m_installOptions ) | 74 | if ( !m_installOptions ) |
74 | { | 75 | { |
75 | m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); | 76 | m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); |
76 | m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); | 77 | m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); |
77 | m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); | 78 | m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); |
78 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); | 79 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); |
79 | m_tabWidget.setCurrentTab( tr( "Servers" ) ); | 80 | m_tabWidget.setCurrentTab( tr( "Servers" ) ); |
80 | } | 81 | } |
81 | else | 82 | else |
82 | { | 83 | { |
83 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); | 84 | m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); |
84 | } | 85 | } |
85 | 86 | ||
86 | //showMaximized(); | 87 | //showMaximized(); |
87 | } | 88 | } |
88 | 89 | ||
89 | void OIpkgConfigDlg::accept() | 90 | void OIpkgConfigDlg::accept() |
90 | { | 91 | { |
91 | // Save server, destination and proxy configuration | 92 | // Save server, destination and proxy configuration |
92 | if ( !m_installOptions ) | 93 | if ( !m_installOptions ) |
93 | m_ipkg->setConfigItems( m_configs ); | 94 | m_ipkg->setConfigItems( m_configs ); |
94 | 95 | ||
95 | // Save options configuration | 96 | // Save options configuration |
96 | int options = 0; | 97 | int options = 0; |
97 | if ( m_optForceDepends->isChecked() ) | 98 | if ( m_optForceDepends->isChecked() ) |
98 | options |= FORCE_DEPENDS; | 99 | options |= FORCE_DEPENDS; |
99 | if ( m_optForceReinstall->isChecked() ) | 100 | if ( m_optForceReinstall->isChecked() ) |
100 | options |= FORCE_REINSTALL; | 101 | options |= FORCE_REINSTALL; |
101 | if ( m_optForceRemove->isChecked() ) | 102 | if ( m_optForceRemove->isChecked() ) |
102 | options |= FORCE_REMOVE; | 103 | options |= FORCE_REMOVE; |
103 | if ( m_optForceOverwrite->isChecked() ) | 104 | if ( m_optForceOverwrite->isChecked() ) |
104 | options |= FORCE_OVERWRITE; | 105 | options |= FORCE_OVERWRITE; |
105 | m_ipkg->setIpkgExecOptions( options ); | 106 | m_ipkg->setIpkgExecOptions( options ); |
106 | m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); | 107 | m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); |
107 | 108 | ||
108 | QDialog::accept(); | 109 | QDialog::accept(); |
109 | } | 110 | } |
110 | 111 | ||
111 | void OIpkgConfigDlg::reject() | 112 | void OIpkgConfigDlg::reject() |
112 | { | 113 | { |
113 | if ( m_configs ) | 114 | if ( m_configs ) |
114 | delete m_configs; | 115 | delete m_configs; |
115 | } | 116 | } |
116 | 117 | ||
117 | void OIpkgConfigDlg::initServerWidget() | 118 | void OIpkgConfigDlg::initServerWidget() |
118 | { | 119 | { |
119 | m_serverWidget = new QWidget( this ); | 120 | m_serverWidget = new QWidget( this ); |
120 | 121 | ||
121 | // Initialize UI | 122 | // Initialize UI |
122 | QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); | 123 | QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); |
123 | QScrollView *sv = new QScrollView( m_serverWidget ); | 124 | QScrollView *sv = new QScrollView( m_serverWidget ); |
124 | vb->addWidget( sv, 0, 0 ); | 125 | vb->addWidget( sv, 0, 0 ); |
125 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 126 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
126 | sv->setFrameStyle( QFrame::NoFrame ); | 127 | sv->setFrameStyle( QFrame::NoFrame ); |
127 | QWidget *container = new QWidget( sv->viewport() ); | 128 | QWidget *container = new QWidget( sv->viewport() ); |
128 | sv->addChild( container ); | 129 | sv->addChild( container ); |
129 | QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); | 130 | QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); |
130 | 131 | ||
131 | m_serverList = new QListBox( container ); | 132 | m_serverList = new QListBox( container ); |
132 | m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 133 | m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
133 | connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); | 134 | connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); |
134 | layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); | 135 | layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); |
135 | 136 | ||
136 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 137 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
137 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); | 138 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); |
138 | layout->addWidget( btn, 1, 0 ); | 139 | layout->addWidget( btn, 1, 0 ); |
139 | 140 | ||
140 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 141 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
141 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); | 142 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); |
142 | layout->addWidget( btn, 1, 1 ); | 143 | layout->addWidget( btn, 1, 1 ); |
143 | 144 | ||
144 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 145 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
145 | grpbox->layout()->setSpacing( 2 ); | 146 | grpbox->layout()->setSpacing( 2 ); |
146 | grpbox->layout()->setMargin( 4 ); | 147 | grpbox->layout()->setMargin( 4 ); |
147 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 148 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
148 | 149 | ||
149 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 150 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
150 | 151 | ||
151 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 152 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
152 | grplayout->addWidget( label, 0, 0 ); | 153 | grplayout->addWidget( label, 0, 0 ); |
153 | m_serverName = new QLineEdit( grpbox ); | 154 | m_serverName = new QLineEdit( grpbox ); |
154 | grplayout->addWidget( m_serverName, 0, 1 ); | 155 | grplayout->addWidget( m_serverName, 0, 1 ); |
155 | 156 | ||
156 | label = new QLabel( tr( "Address:" ), grpbox ); | 157 | label = new QLabel( tr( "Address:" ), grpbox ); |
157 | grplayout->addWidget( label, 1, 0 ); | 158 | grplayout->addWidget( label, 1, 0 ); |
158 | m_serverLocation = new QLineEdit( grpbox ); | 159 | m_serverLocation = new QLineEdit( grpbox ); |
159 | grplayout->addWidget( m_serverLocation, 1, 1 ); | 160 | grplayout->addWidget( m_serverLocation, 1, 1 ); |
160 | 161 | ||
161 | m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox ); | 162 | m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox ); |
162 | grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 ); | 163 | grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 ); |
163 | 164 | ||
164 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 165 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
165 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) ); | 166 | connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) ); |
166 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 167 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
167 | } | 168 | } |
168 | 169 | ||
169 | void OIpkgConfigDlg::initDestinationWidget() | 170 | void OIpkgConfigDlg::initDestinationWidget() |
170 | { | 171 | { |
171 | m_destWidget = new QWidget( this ); | 172 | m_destWidget = new QWidget( this ); |
172 | 173 | ||
173 | // Initialize UI | 174 | // Initialize UI |
174 | QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); | 175 | QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); |
175 | QScrollView *sv = new QScrollView( m_destWidget ); | 176 | QScrollView *sv = new QScrollView( m_destWidget ); |
176 | vb->addWidget( sv, 0, 0 ); | 177 | vb->addWidget( sv, 0, 0 ); |
177 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 178 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
178 | sv->setFrameStyle( QFrame::NoFrame ); | 179 | sv->setFrameStyle( QFrame::NoFrame ); |
179 | QWidget *container = new QWidget( sv->viewport() ); | 180 | QWidget *container = new QWidget( sv->viewport() ); |
180 | sv->addChild( container ); | 181 | sv->addChild( container ); |
181 | QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); | 182 | QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); |
182 | 183 | ||
183 | m_destList = new QListBox( container ); | 184 | m_destList = new QListBox( container ); |
184 | m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 185 | m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
185 | connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); | 186 | connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); |
186 | layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); | 187 | layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); |
187 | 188 | ||
188 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 189 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
189 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); | 190 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); |
190 | layout->addWidget( btn, 1, 0 ); | 191 | layout->addWidget( btn, 1, 0 ); |
191 | 192 | ||
192 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 193 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
193 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); | 194 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); |
194 | layout->addWidget( btn, 1, 1 ); | 195 | layout->addWidget( btn, 1, 1 ); |
195 | 196 | ||
196 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 197 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
197 | grpbox->layout()->setSpacing( 2 ); | 198 | grpbox->layout()->setSpacing( 2 ); |
198 | grpbox->layout()->setMargin( 4 ); | 199 | grpbox->layout()->setMargin( 4 ); |
199 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 200 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
200 | 201 | ||
201 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 202 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
202 | 203 | ||
203 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 204 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
204 | grplayout->addWidget( label, 0, 0 ); | 205 | grplayout->addWidget( label, 0, 0 ); |
205 | m_destName = new QLineEdit( grpbox ); | 206 | m_destName = new QLineEdit( grpbox ); |
206 | grplayout->addWidget( m_destName, 0, 1 ); | 207 | grplayout->addWidget( m_destName, 0, 1 ); |
207 | 208 | ||
208 | label = new QLabel( tr( "Address:" ), grpbox ); | 209 | label = new QLabel( tr( "Address:" ), grpbox ); |
209 | grplayout->addWidget( label, 1, 0 ); | 210 | grplayout->addWidget( label, 1, 0 ); |
210 | m_destLocation = new QLineEdit( grpbox ); | 211 | m_destLocation = new QLineEdit( grpbox ); |
211 | grplayout->addWidget( m_destLocation, 1, 1 ); | 212 | grplayout->addWidget( m_destLocation, 1, 1 ); |
212 | 213 | ||
213 | m_destActive = new QCheckBox( tr( "Active Server" ), grpbox ); | 214 | m_destActive = new QCheckBox( tr( "Active Server" ), grpbox ); |
214 | grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 1 ); | 215 | grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 1 ); |
215 | 216 | ||
216 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 217 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
217 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) ); | 218 | connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) ); |
218 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 219 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
219 | } | 220 | } |
220 | 221 | ||
221 | void OIpkgConfigDlg::initProxyWidget() | 222 | void OIpkgConfigDlg::initProxyWidget() |
222 | { | 223 | { |
223 | m_proxyWidget = new QWidget( this ); | 224 | m_proxyWidget = new QWidget( this ); |
224 | 225 | ||
225 | // Initialize UI | 226 | // Initialize UI |
226 | QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); | 227 | QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); |
227 | QScrollView *sv = new QScrollView( m_proxyWidget ); | 228 | QScrollView *sv = new QScrollView( m_proxyWidget ); |
228 | vb->addWidget( sv, 0, 0 ); | 229 | vb->addWidget( sv, 0, 0 ); |
229 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 230 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
230 | sv->setFrameStyle( QFrame::NoFrame ); | 231 | sv->setFrameStyle( QFrame::NoFrame ); |
231 | QWidget *container = new QWidget( sv->viewport() ); | 232 | QWidget *container = new QWidget( sv->viewport() ); |
232 | sv->addChild( container ); | 233 | sv->addChild( container ); |
233 | QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); | 234 | QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); |
234 | 235 | ||
235 | // HTTP proxy server configuration | 236 | // HTTP proxy server configuration |
236 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 237 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h index 88e020a..0aba898 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.h +++ b/noncore/settings/packagemanager/oipkgconfigdlg.h | |||
@@ -1,131 +1,131 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | 32 | ||
33 | #ifndef OIPKGCONFIGDLG_H | 33 | #ifndef OIPKGCONFIGDLG_H |
34 | #define OIPKGCONFIGDLG_H | 34 | #define OIPKGCONFIGDLG_H |
35 | 35 | ||
36 | #include <qdialog.h> | 36 | #include <qdialog.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | 38 | ||
39 | #include <opie2/otabwidget.h> | 39 | #include <opie2/otabwidget.h> |
40 | 40 | ||
41 | #include "oipkg.h" | 41 | #include "oipkg.h" |
42 | 42 | ||
43 | class QCheckBox; | 43 | class QCheckBox; |
44 | class QComboBox; | 44 | class QComboBox; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QListBox; | 46 | class QListBox; |
47 | 47 | ||
48 | class OIpkgConfigDlg : public QDialog | 48 | class OIpkgConfigDlg : public QDialog |
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 ); | 53 | OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 ); |
54 | 54 | ||
55 | protected slots: | 55 | protected slots: |
56 | void accept(); | 56 | void accept(); |
57 | void reject(); | 57 | void reject(); |
58 | 58 | ||
59 | private: | 59 | private: |
60 | OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options | 60 | OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options |
61 | OConfItemList *m_configs; // Local list of configuration items | 61 | OConfItemList *m_configs; // Local list of configuration items |
62 | 62 | ||
63 | bool m_installOptions; // If true, will only display the Options tab | 63 | bool m_installOptions; // If true, will only display the Options tab |
64 | 64 | ||
65 | // Server cached information | 65 | // Server cached information |
66 | bool m_serverNew; // Indicates if server information is for a new server | 66 | bool m_serverNew; // Indicates if server information is for a new server |
67 | int m_serverCurrent; // Index of currently selected server in m_serverList | 67 | int m_serverCurrent; // Index of currently selected server in m_serverList |
68 | QString m_serverCurrName; // Name of currently selected server in m_serverList | 68 | QString m_serverCurrName; // Name of currently selected server in m_serverList |
69 | 69 | ||
70 | // Destination cached information | 70 | // Destination cached information |
71 | bool m_destNew; // Indicates if destination information is for a new destination | 71 | bool m_destNew; // Indicates if destination information is for a new destination |
72 | int m_destCurrent; // Index of currently selected destination in m_destList | 72 | int m_destCurrent; // Index of currently selected destination in m_destList |
73 | QString m_destCurrName; // Name of currently selected destination in m_destList | 73 | QString m_destCurrName; // Name of currently selected destination in m_destList |
74 | 74 | ||
75 | // UI controls | 75 | // UI controls |
76 | QVBoxLayout m_layout; // Main dialog layout control | 76 | QVBoxLayout m_layout; // Main dialog layout control |
77 | OTabWidget m_tabWidget; // Main tab widget control | 77 | Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control |
78 | QWidget *m_serverWidget; // Widget containing server configuration controls | 78 | QWidget *m_serverWidget; // Widget containing server configuration controls |
79 | QWidget *m_destWidget; // Widget containing destination configuration controls | 79 | QWidget *m_destWidget; // Widget containing destination configuration controls |
80 | QWidget *m_proxyWidget; // Widget containing proxy configuration controls | 80 | QWidget *m_proxyWidget; // Widget containing proxy configuration controls |
81 | QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls | 81 | QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls |
82 | 82 | ||
83 | // Server configuration UI controls | 83 | // Server configuration UI controls |
84 | QListBox *m_serverList; // Server list selection | 84 | QListBox *m_serverList; // Server list selection |
85 | QLineEdit *m_serverName; // Server name edit box | 85 | QLineEdit *m_serverName; // Server name edit box |
86 | QLineEdit *m_serverLocation; // Server location URL edit box | 86 | QLineEdit *m_serverLocation; // Server location URL edit box |
87 | QCheckBox *m_serverActive; // Activate server check box | 87 | QCheckBox *m_serverActive; // Activate server check box |
88 | 88 | ||
89 | // Destination configuration UI controls | 89 | // Destination configuration UI controls |
90 | QListBox *m_destList; // Destination list selection | 90 | QListBox *m_destList; // Destination list selection |
91 | QLineEdit *m_destName; // Destination name edit box | 91 | QLineEdit *m_destName; // Destination name edit box |
92 | QLineEdit *m_destLocation; // Destination location URL edit box | 92 | QLineEdit *m_destLocation; // Destination location URL edit box |
93 | QCheckBox *m_destActive; // Activate destination check box | 93 | QCheckBox *m_destActive; // Activate destination check box |
94 | 94 | ||
95 | // Proxy server configuration UI controls | 95 | // Proxy server configuration UI controls |
96 | QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box | 96 | QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box |
97 | QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box | 97 | QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box |
98 | QLineEdit *m_proxyFtpServer; // FTP proxy server edit box | 98 | QLineEdit *m_proxyFtpServer; // FTP proxy server edit box |
99 | QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box | 99 | QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box |
100 | QLineEdit *m_proxyUsername; // Proxy server username edit box | 100 | QLineEdit *m_proxyUsername; // Proxy server username edit box |
101 | QLineEdit *m_proxyPassword; // Proxy server password edit box | 101 | QLineEdit *m_proxyPassword; // Proxy server password edit box |
102 | 102 | ||
103 | // Options configuration UI controls | 103 | // Options configuration UI controls |
104 | QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox | 104 | QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox |
105 | QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox | 105 | QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox |
106 | QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox | 106 | QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox |
107 | QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox | 107 | QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox |
108 | QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection | 108 | QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection |
109 | 109 | ||
110 | void initServerWidget(); | 110 | void initServerWidget(); |
111 | void initDestinationWidget(); | 111 | void initDestinationWidget(); |
112 | void initProxyWidget(); | 112 | void initProxyWidget(); |
113 | void initOptionsWidget(); | 113 | void initOptionsWidget(); |
114 | 114 | ||
115 | void initData(); | 115 | void initData(); |
116 | 116 | ||
117 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 ); | 117 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 ); |
118 | 118 | ||
119 | private slots: | 119 | private slots: |
120 | void slotServerEdit( int index ); | 120 | void slotServerEdit( int index ); |
121 | void slotServerNew(); | 121 | void slotServerNew(); |
122 | void slotServerDelete(); | 122 | void slotServerDelete(); |
123 | void slotServerUpdate(); | 123 | void slotServerUpdate(); |
124 | 124 | ||
125 | void slotDestEdit( int index ); | 125 | void slotDestEdit( int index ); |
126 | void slotDestNew(); | 126 | void slotDestNew(); |
127 | void slotDestDelete(); | 127 | void slotDestDelete(); |
128 | void slotDestUpdate(); | 128 | void slotDestUpdate(); |
129 | }; | 129 | }; |
130 | 130 | ||
131 | #endif | 131 | #endif |
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index 7abd17e..73d3de7 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp | |||
@@ -1,140 +1,141 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "packageinfodlg.h" | 30 | #include "packageinfodlg.h" |
31 | #include "opackage.h" | 31 | #include "opackage.h" |
32 | #include "opackagemanager.h" | 32 | #include "opackagemanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | 36 | ||
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | 38 | ||
39 | #include <opie2/otabwidget.h> | 39 | #include <opie2/otabwidget.h> |
40 | 40 | ||
41 | using namespace Opie::Ui; | ||
41 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) | 42 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) |
42 | : QWidget( 0x0 ) | 43 | : QWidget( 0x0 ) |
43 | , m_packman( pm ) | 44 | , m_packman( pm ) |
44 | , m_information( this ) | 45 | , m_information( this ) |
45 | , m_files( this ) | 46 | , m_files( this ) |
46 | { | 47 | { |
47 | // Initialize UI | 48 | // Initialize UI |
48 | if ( parent ) | 49 | if ( parent ) |
49 | parent->setCaption( package ); | 50 | parent->setCaption( package ); |
50 | 51 | ||
51 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); | 52 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); |
52 | 53 | ||
53 | OTabWidget *tabWidget = new OTabWidget( this ); | 54 | OTabWidget *tabWidget = new OTabWidget( this ); |
54 | layout->addWidget( tabWidget ); | 55 | layout->addWidget( tabWidget ); |
55 | 56 | ||
56 | // Information tab | 57 | // Information tab |
57 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); | 58 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); |
58 | m_information.setReadOnly( true ); | 59 | m_information.setReadOnly( true ); |
59 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); | 60 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); |
60 | 61 | ||
61 | // Retrive package information | 62 | // Retrive package information |
62 | m_package = m_packman->findPackage( package ); | 63 | m_package = m_packman->findPackage( package ); |
63 | if ( !m_package ) | 64 | if ( !m_package ) |
64 | { | 65 | { |
65 | m_information.setText( tr( "Unable to retrieve package information." ) ); | 66 | m_information.setText( tr( "Unable to retrieve package information." ) ); |
66 | return; | 67 | return; |
67 | } | 68 | } |
68 | 69 | ||
69 | // Display package information | 70 | // Display package information |
70 | if ( !m_package->information().isNull() ) | 71 | if ( !m_package->information().isNull() ) |
71 | m_information.setText( m_package->information() ); | 72 | m_information.setText( m_package->information() ); |
72 | else | 73 | else |
73 | { | 74 | { |
74 | // Package information is not cached, retrieve it | 75 | // Package information is not cached, retrieve it |
75 | QStringList list( package ); | 76 | QStringList list( package ); |
76 | m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true ); | 77 | m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true ); |
77 | } | 78 | } |
78 | 79 | ||
79 | // Files tab (display only if package is installed) | 80 | // Files tab (display only if package is installed) |
80 | if ( !m_package->versionInstalled().isNull() ) | 81 | if ( !m_package->versionInstalled().isNull() ) |
81 | { | 82 | { |
82 | QWidget *filesWidget = new QWidget( tabWidget ); | 83 | QWidget *filesWidget = new QWidget( tabWidget ); |
83 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); | 84 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); |
84 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); | 85 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); |
85 | m_files.setReadOnly( true ); | 86 | m_files.setReadOnly( true ); |
86 | filesLayout->addWidget( &m_files ); | 87 | filesLayout->addWidget( &m_files ); |
87 | 88 | ||
88 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), | 89 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), |
89 | tr( "Retrieve file list" ), filesWidget ); | 90 | tr( "Retrieve file list" ), filesWidget ); |
90 | filesLayout->addWidget( btn ); | 91 | filesLayout->addWidget( btn ); |
91 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); | 92 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); |
92 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); | 93 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); |
93 | 94 | ||
94 | tabWidget->setCurrentTab( tr( "Information" ) ); | 95 | tabWidget->setCurrentTab( tr( "Information" ) ); |
95 | 96 | ||
96 | // If file list is already cached, display | 97 | // If file list is already cached, display |
97 | if ( !m_package->files().isNull() ) | 98 | if ( !m_package->files().isNull() ) |
98 | m_files.setText( m_package->files() ); | 99 | m_files.setText( m_package->files() ); |
99 | } | 100 | } |
100 | else | 101 | else |
101 | m_files.hide(); | 102 | m_files.hide(); |
102 | } | 103 | } |
103 | 104 | ||
104 | PackageInfoDlg::~PackageInfoDlg() | 105 | PackageInfoDlg::~PackageInfoDlg() |
105 | { | 106 | { |
106 | if ( !m_package ) | 107 | if ( !m_package ) |
107 | return; | 108 | return; |
108 | 109 | ||
109 | // Cache package information | 110 | // Cache package information |
110 | if ( !m_information.text().isNull() ) | 111 | if ( !m_information.text().isNull() ) |
111 | m_package->setInformation( m_information.text() ); | 112 | m_package->setInformation( m_information.text() ); |
112 | 113 | ||
113 | // Cache package file list | 114 | // Cache package file list |
114 | if ( !m_files.text().isNull() ) | 115 | if ( !m_files.text().isNull() ) |
115 | m_package->setFiles( m_files.text() ); | 116 | m_package->setFiles( m_files.text() ); |
116 | } | 117 | } |
117 | 118 | ||
118 | void PackageInfoDlg::slotBtnFileScan() | 119 | void PackageInfoDlg::slotBtnFileScan() |
119 | { | 120 | { |
120 | m_files.clear(); | 121 | m_files.clear(); |
121 | 122 | ||
122 | QStringList list( m_package->name() ); | 123 | QStringList list( m_package->name() ); |
123 | m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true ); | 124 | m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true ); |
124 | } | 125 | } |
125 | 126 | ||
126 | void PackageInfoDlg::slotInfo( char *info ) | 127 | void PackageInfoDlg::slotInfo( char *info ) |
127 | { | 128 | { |
128 | m_information.append( info ); | 129 | m_information.append( info ); |
129 | } | 130 | } |
130 | 131 | ||
131 | void PackageInfoDlg::slotFiles( char *filelist ) | 132 | void PackageInfoDlg::slotFiles( char *filelist ) |
132 | { | 133 | { |
133 | QString str = filelist; | 134 | QString str = filelist; |
134 | 135 | ||
135 | // Skip first line of output ("Package xxx is installed...") | 136 | // Skip first line of output ("Package xxx is installed...") |
136 | if ( str.startsWith( "Package " ) ) | 137 | if ( str.startsWith( "Package " ) ) |
137 | str = str.right( str.length() - str.find( '\n' ) - 1 ); | 138 | str = str.right( str.length() - str.find( '\n' ) - 1 ); |
138 | 139 | ||
139 | m_files.append( str ); | 140 | m_files.append( str ); |
140 | } | 141 | } |
diff --git a/noncore/settings/sound/main.cpp b/noncore/settings/sound/main.cpp index 49497c3..946bb3a 100644 --- a/noncore/settings/sound/main.cpp +++ b/noncore/settings/sound/main.cpp | |||
@@ -1,28 +1,29 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "soundsettings.h" | 21 | #include "soundsettings.h" |
22 | 22 | ||
23 | #include <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<SoundSettings> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<SoundSettings> ) |
26 | 27 | ||
27 | 28 | ||
28 | 29 | ||
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp index e76fd6b..31f6b85 100644 --- a/noncore/settings/sshkeys/sshkeys.cpp +++ b/noncore/settings/sshkeys/sshkeys.cpp | |||
@@ -1,293 +1,294 @@ | |||
1 | /* | 1 | /* |
2 | * ssh-agent key manipulation utility | 2 | * ssh-agent key manipulation utility |
3 | * | 3 | * |
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | 4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | #include "sshkeys.h" | 21 | #include "sshkeys.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qmultilineedit.h> | 24 | #include <qmultilineedit.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qlistview.h> | 26 | #include <qlistview.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | 28 | ||
29 | #include <sys/types.h> | 29 | #include <sys/types.h> |
30 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <stdio.h> | 33 | #include <stdio.h> |
34 | #include <ctype.h> | 34 | #include <ctype.h> |
35 | 35 | ||
36 | using namespace Opie::Core; | ||
36 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; | 37 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; |
37 | 38 | ||
38 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) | 39 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) |
39 | : SSHKeysBase( parent, name, fl ) | 40 | : SSHKeysBase( parent, name, fl ) |
40 | { | 41 | { |
41 | char *home = getenv("HOME"); | 42 | char *home = getenv("HOME"); |
42 | unsigned i; | 43 | unsigned i; |
43 | 44 | ||
44 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); | 45 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); |
45 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); | 46 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); |
46 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); | 47 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); |
47 | 48 | ||
48 | connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 49 | connect(&addprocess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
49 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); | 50 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); |
50 | connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)), | 51 | connect(&addprocess, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
51 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); | 52 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); |
52 | connect(&addprocess, SIGNAL(processExited(OProcess*)), | 53 | connect(&addprocess, SIGNAL(processExited(Opie::Core::OProcess*)), |
53 | this, SLOT(ssh_add_exited(OProcess*))); | 54 | this, SLOT(ssh_add_exited(OProcess*))); |
54 | 55 | ||
55 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), | 56 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), |
56 | this, SLOT(add_text_changed(const QString&))); | 57 | this, SLOT(add_text_changed(const QString&))); |
57 | 58 | ||
58 | if (home) { | 59 | if (home) { |
59 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { | 60 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { |
60 | char thiskeyname[32]; | 61 | char thiskeyname[32]; |
61 | 62 | ||
62 | thiskeyname[31] = 0; | 63 | thiskeyname[31] = 0; |
63 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); | 64 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); |
64 | if (!access(thiskeyname, R_OK)) { | 65 | if (!access(thiskeyname, R_OK)) { |
65 | KeyFileName->insertItem(thiskeyname); | 66 | KeyFileName->insertItem(thiskeyname); |
66 | } | 67 | } |
67 | } | 68 | } |
68 | } | 69 | } |
69 | 70 | ||
70 | doRefreshListButton(); | 71 | doRefreshListButton(); |
71 | } | 72 | } |
72 | 73 | ||
73 | SSHKeysApp::~SSHKeysApp() | 74 | SSHKeysApp::~SSHKeysApp() |
74 | { | 75 | { |
75 | } | 76 | } |
76 | 77 | ||
77 | void SSHKeysApp::doRefreshListButton() | 78 | void SSHKeysApp::doRefreshListButton() |
78 | { | 79 | { |
79 | OProcess sshadd_process; | 80 | OProcess sshadd_process; |
80 | QListViewItem *t = KeyList->firstChild(); | 81 | QListViewItem *t = KeyList->firstChild(); |
81 | 82 | ||
82 | while(t) { | 83 | while(t) { |
83 | QListViewItem *next = t->nextSibling(); | 84 | QListViewItem *next = t->nextSibling(); |
84 | KeyList->takeItem(t); | 85 | KeyList->takeItem(t); |
85 | delete(t); | 86 | delete(t); |
86 | t = next; | 87 | t = next; |
87 | } | 88 | } |
88 | 89 | ||
89 | connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), | 90 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
90 | this, SLOT(get_list_keys_output(OProcess*,char*,int))); | 91 | this, SLOT(get_list_keys_output(OProcess*,char*,int))); |
91 | connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), | 92 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
92 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); | 93 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); |
93 | 94 | ||
94 | keystate = KeySize; | 95 | keystate = KeySize; |
95 | incoming_keyname=""; | 96 | incoming_keyname=""; |
96 | incoming_keysize=""; | 97 | incoming_keysize=""; |
97 | incoming_keyfingerprint=""; | 98 | incoming_keyfingerprint=""; |
98 | 99 | ||
99 | // log_text("Running ssh-add -l"); | 100 | // log_text("Running ssh-add -l"); |
100 | sshadd_process << "ssh-add" << "-l"; | 101 | sshadd_process << "ssh-add" << "-l"; |
101 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); | 102 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); |
102 | if (!ret) { | 103 | if (!ret) { |
103 | log_text(tr("Error running ssh-add")); | 104 | log_text(tr("Error running ssh-add")); |
104 | return; | 105 | return; |
105 | } | 106 | } |
106 | flush_sshadd_output(); | 107 | flush_sshadd_output(); |
107 | if (sshadd_process.exitStatus() == 2) { | 108 | if (sshadd_process.exitStatus() == 2) { |
108 | setEnabled(FALSE); | 109 | setEnabled(FALSE); |
109 | } | 110 | } |
110 | } | 111 | } |
111 | 112 | ||
112 | void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) | 113 | void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) |
113 | { | 114 | { |
114 | int i; | 115 | int i; |
115 | (void) proc; | 116 | (void) proc; |
116 | 117 | ||
117 | for (i=0; i<buflen; i++) { | 118 | for (i=0; i<buflen; i++) { |
118 | switch(keystate) { | 119 | switch(keystate) { |
119 | case Noise: | 120 | case Noise: |
120 | noise: | 121 | noise: |
121 | if (buffer[i] == '\n') { | 122 | if (buffer[i] == '\n') { |
122 | log_text(incoming_noise.local8Bit()); | 123 | log_text(incoming_noise.local8Bit()); |
123 | incoming_noise = ""; | 124 | incoming_noise = ""; |
124 | keystate = KeySize; | 125 | keystate = KeySize; |
125 | } else { | 126 | } else { |
126 | incoming_noise += buffer[i]; | 127 | incoming_noise += buffer[i]; |
127 | } | 128 | } |
128 | break; | 129 | break; |
129 | 130 | ||
130 | case KeySize: | 131 | case KeySize: |
131 | if (isdigit(buffer[i])) { | 132 | if (isdigit(buffer[i])) { |
132 | incoming_keysize += buffer[i]; | 133 | incoming_keysize += buffer[i]; |
133 | } else if (buffer[i] == ' ') { | 134 | } else if (buffer[i] == ' ') { |
134 | keystate = KeyFingerprint; | 135 | keystate = KeyFingerprint; |
135 | } else { | 136 | } else { |
136 | incoming_keysize = ""; | 137 | incoming_keysize = ""; |
137 | incoming_noise = ""; | 138 | incoming_noise = ""; |
138 | keystate = Noise; | 139 | keystate = Noise; |
139 | goto noise; | 140 | goto noise; |
140 | } | 141 | } |
141 | break; | 142 | break; |
142 | 143 | ||
143 | case KeyFingerprint: | 144 | case KeyFingerprint: |
144 | if (isxdigit(buffer[i]) || buffer[i] == ':') { | 145 | if (isxdigit(buffer[i]) || buffer[i] == ':') { |
145 | incoming_keyfingerprint += buffer[i]; | 146 | incoming_keyfingerprint += buffer[i]; |
146 | } else if (buffer[i] == ' ') { | 147 | } else if (buffer[i] == ' ') { |
147 | keystate = KeyName; | 148 | keystate = KeyName; |
148 | } else { | 149 | } else { |
149 | incoming_keysize = ""; | 150 | incoming_keysize = ""; |
150 | incoming_keyfingerprint = ""; | 151 | incoming_keyfingerprint = ""; |
151 | incoming_noise = ""; | 152 | incoming_noise = ""; |
152 | keystate = Noise; | 153 | keystate = Noise; |
153 | goto noise; | 154 | goto noise; |
154 | } | 155 | } |
155 | break; | 156 | break; |
156 | 157 | ||
157 | case KeyName: | 158 | case KeyName: |
158 | if (buffer[i] == '\n') { | 159 | if (buffer[i] == '\n') { |
159 | /* Wheee. Got one. */ | 160 | /* Wheee. Got one. */ |
160 | KeyList->insertItem(new | 161 | KeyList->insertItem(new |
161 | QListViewItem(KeyList, incoming_keyname, incoming_keysize, incoming_keyfingerprint)); | 162 | QListViewItem(KeyList, incoming_keyname, incoming_keysize, incoming_keyfingerprint)); |
162 | incoming_keysize = ""; | 163 | incoming_keysize = ""; |
163 | incoming_keyfingerprint = ""; | 164 | incoming_keyfingerprint = ""; |
164 | incoming_keyname = ""; | 165 | incoming_keyname = ""; |
165 | keystate = KeySize; | 166 | keystate = KeySize; |
166 | } else if (isprint(buffer[i])) { | 167 | } else if (isprint(buffer[i])) { |
167 | incoming_keyname += buffer[i]; | 168 | incoming_keyname += buffer[i]; |
168 | } else { | 169 | } else { |
169 | incoming_keysize = ""; | 170 | incoming_keysize = ""; |
170 | incoming_keyfingerprint = ""; | 171 | incoming_keyfingerprint = ""; |
171 | incoming_noise = ""; | 172 | incoming_noise = ""; |
172 | keystate = Noise; | 173 | keystate = Noise; |
173 | goto noise; | 174 | goto noise; |
174 | } | 175 | } |
175 | break; | 176 | break; |
176 | } | 177 | } |
177 | } | 178 | } |
178 | } | 179 | } |
179 | 180 | ||
180 | void SSHKeysApp::flush_sshadd_output(void) | 181 | void SSHKeysApp::flush_sshadd_output(void) |
181 | { | 182 | { |
182 | if (pending_stdout.length()) { | 183 | if (pending_stdout.length()) { |
183 | log_text(pending_stdout.ascii()); | 184 | log_text(pending_stdout.ascii()); |
184 | } | 185 | } |
185 | pending_stdout = ""; | 186 | pending_stdout = ""; |
186 | 187 | ||
187 | if (pending_stderr.length()) { | 188 | if (pending_stderr.length()) { |
188 | log_text(pending_stderr.ascii()); | 189 | log_text(pending_stderr.ascii()); |
189 | } | 190 | } |
190 | pending_stderr = ""; | 191 | pending_stderr = ""; |
191 | } | 192 | } |
192 | 193 | ||
193 | void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen) | 194 | void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen) |
194 | { | 195 | { |
195 | (void) proc; | 196 | (void) proc; |
196 | 197 | ||
197 | while (buflen) { | 198 | while (buflen) { |
198 | if (*buffer == '\n') { | 199 | if (*buffer == '\n') { |
199 | log_text(pending_stdout); | 200 | log_text(pending_stdout); |
200 | pending_stdout = ""; | 201 | pending_stdout = ""; |
201 | } else { | 202 | } else { |
202 | pending_stdout += *buffer; | 203 | pending_stdout += *buffer; |
203 | } | 204 | } |
204 | buffer++; | 205 | buffer++; |
205 | buflen--; | 206 | buflen--; |
206 | } | 207 | } |
207 | } | 208 | } |
208 | 209 | ||
209 | void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen) | 210 | void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen) |
210 | { | 211 | { |
211 | (void) proc; | 212 | (void) proc; |
212 | 213 | ||
213 | while (buflen) { | 214 | while (buflen) { |
214 | if (*buffer == '\n') { | 215 | if (*buffer == '\n') { |
215 | log_text(pending_stderr); | 216 | log_text(pending_stderr); |
216 | pending_stderr = ""; | 217 | pending_stderr = ""; |
217 | } else { | 218 | } else { |
218 | pending_stderr += *buffer; | 219 | pending_stderr += *buffer; |
219 | } | 220 | } |
220 | buffer++; | 221 | buffer++; |
221 | buflen--; | 222 | buflen--; |
222 | } | 223 | } |
223 | } | 224 | } |
224 | 225 | ||
225 | void SSHKeysApp::ssh_add_exited(OProcess *proc) | 226 | void SSHKeysApp::ssh_add_exited(OProcess *proc) |
226 | { | 227 | { |
227 | (void)proc; | 228 | (void)proc; |
228 | 229 | ||
229 | doRefreshListButton(); | 230 | doRefreshListButton(); |
230 | setEnabled(TRUE); | 231 | setEnabled(TRUE); |
231 | if (proc->exitStatus() == 2) { | 232 | if (proc->exitStatus() == 2) { |
232 | setEnabled(FALSE); | 233 | setEnabled(FALSE); |
233 | } | 234 | } |
234 | } | 235 | } |
235 | 236 | ||
236 | void SSHKeysApp::add_text_changed(const QString &text) | 237 | void SSHKeysApp::add_text_changed(const QString &text) |
237 | { | 238 | { |
238 | struct stat sbuf; | 239 | struct stat sbuf; |
239 | 240 | ||
240 | if (!text.length() || (!access(text.ascii(), R_OK) && | 241 | if (!text.length() || (!access(text.ascii(), R_OK) && |
241 | !stat(text.ascii(), &sbuf) && | 242 | !stat(text.ascii(), &sbuf) && |
242 | S_ISREG(sbuf.st_mode))) | 243 | S_ISREG(sbuf.st_mode))) |
243 | AddButton->setEnabled(TRUE); | 244 | AddButton->setEnabled(TRUE); |
244 | else | 245 | else |
245 | AddButton->setEnabled(FALSE); | 246 | AddButton->setEnabled(FALSE); |
246 | } | 247 | } |
247 | 248 | ||
248 | void SSHKeysApp::doAddButton() | 249 | void SSHKeysApp::doAddButton() |
249 | { | 250 | { |
250 | addprocess.clearArguments(); | 251 | addprocess.clearArguments(); |
251 | 252 | ||
252 | setEnabled(FALSE); | 253 | setEnabled(FALSE); |
253 | 254 | ||
254 | if (KeyFileName->currentText().length()) { | 255 | if (KeyFileName->currentText().length()) { |
255 | addprocess << "ssh-add" << "--" << KeyFileName->currentText(); | 256 | addprocess << "ssh-add" << "--" << KeyFileName->currentText(); |
256 | // log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); | 257 | // log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); |
257 | } else { | 258 | } else { |
258 | addprocess << "ssh-add"; | 259 | addprocess << "ssh-add"; |
259 | // log_text(tr("Running ssh-add")); | 260 | // log_text(tr("Running ssh-add")); |
260 | } | 261 | } |
261 | bool ret = addprocess.start(OProcess::NotifyOnExit, OProcess::AllOutput); | 262 | bool ret = addprocess.start(OProcess::NotifyOnExit, OProcess::AllOutput); |
262 | if (!ret) { | 263 | if (!ret) { |
263 | log_text(tr("Error running ssh-add")); | 264 | log_text(tr("Error running ssh-add")); |
264 | doRefreshListButton(); | 265 | doRefreshListButton(); |
265 | setEnabled(TRUE); | 266 | setEnabled(TRUE); |
266 | } | 267 | } |
267 | flush_sshadd_output(); | 268 | flush_sshadd_output(); |
268 | } | 269 | } |
269 | 270 | ||
270 | void SSHKeysApp::log_text(const char *text) | 271 | void SSHKeysApp::log_text(const char *text) |
271 | { | 272 | { |
272 | TextOutput->append(text); | 273 | TextOutput->append(text); |
273 | TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); | 274 | TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); |
274 | } | 275 | } |
275 | 276 | ||
276 | void SSHKeysApp::doRemoveAllButton() | 277 | void SSHKeysApp::doRemoveAllButton() |
277 | { | 278 | { |
278 | OProcess sshadd_process; | 279 | OProcess sshadd_process; |
279 | 280 | ||
280 | connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), | 281 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
281 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); | 282 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); |
282 | connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), | 283 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
283 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); | 284 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); |
284 | 285 | ||
285 | // log_text(tr("Running ssh-add -D")); | 286 | // log_text(tr("Running ssh-add -D")); |
286 | sshadd_process << "ssh-add" << "-D"; | 287 | sshadd_process << "ssh-add" << "-D"; |
287 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); | 288 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); |
288 | if (!ret) { | 289 | if (!ret) { |
289 | log_text(tr("Error running ssh-add")); | 290 | log_text(tr("Error running ssh-add")); |
290 | } | 291 | } |
291 | flush_sshadd_output(); | 292 | flush_sshadd_output(); |
292 | doRefreshListButton(); | 293 | doRefreshListButton(); |
293 | } | 294 | } |
diff --git a/noncore/settings/sshkeys/sshkeys.h b/noncore/settings/sshkeys/sshkeys.h index 7483bbc..519f540 100644 --- a/noncore/settings/sshkeys/sshkeys.h +++ b/noncore/settings/sshkeys/sshkeys.h | |||
@@ -1,61 +1,61 @@ | |||
1 | /* | 1 | /* |
2 | * ssh-agent key manipulation utility | 2 | * ssh-agent key manipulation utility |
3 | * | 3 | * |
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | 4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef SSHKEYSAPP_H | 22 | #ifndef SSHKEYSAPP_H |
23 | #define SSHKEYSAPP_H | 23 | #define SSHKEYSAPP_H |
24 | 24 | ||
25 | #include "sshkeysbase.h" | 25 | #include "sshkeysbase.h" |
26 | 26 | ||
27 | #include <opie2/oprocess.h> | 27 | #include <opie2/oprocess.h> |
28 | 28 | ||
29 | class SSHKeysApp : public SSHKeysBase | 29 | class SSHKeysApp : public SSHKeysBase |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
34 | SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 34 | SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
35 | ~SSHKeysApp(); | 35 | ~SSHKeysApp(); |
36 | 36 | ||
37 | private: | 37 | private: |
38 | void log_text(const char *text); | 38 | void log_text(const char *text); |
39 | void flush_sshadd_output(void); | 39 | void flush_sshadd_output(void); |
40 | 40 | ||
41 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; | 41 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; |
42 | QString incoming_keyname; | 42 | QString incoming_keyname; |
43 | QString incoming_keysize; | 43 | QString incoming_keysize; |
44 | QString incoming_keyfingerprint; | 44 | QString incoming_keyfingerprint; |
45 | QString incoming_noise; | 45 | QString incoming_noise; |
46 | OProcess addprocess; | 46 | Opie::Core::OProcess addprocess; |
47 | QString pending_stdout; | 47 | QString pending_stdout; |
48 | QString pending_stderr; | 48 | QString pending_stderr; |
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | void doAddButton(); | 51 | void doAddButton(); |
52 | void doRefreshListButton(); | 52 | void doRefreshListButton(); |
53 | void doRemoveAllButton(); | 53 | void doRemoveAllButton(); |
54 | void get_list_keys_output(OProcess *proc, char *buffer, int buflen); | 54 | void get_list_keys_output(Opie::Core::OProcess *proc, char *buffer, int buflen); |
55 | void log_sshadd_output(OProcess *proc, char *buffer, int buflen); | 55 | void log_sshadd_output(Opie::Core::OProcess *proc, char *buffer, int buflen); |
56 | void log_sshadd_stderr(OProcess *proc, char *buffer, int buflen); | 56 | void log_sshadd_stderr(Opie::Core::OProcess *proc, char *buffer, int buflen); |
57 | void ssh_add_exited(OProcess *proc); | 57 | void ssh_add_exited(Opie::Core::OProcess *proc); |
58 | void add_text_changed(const QString &text); | 58 | void add_text_changed(const QString &text); |
59 | }; | 59 | }; |
60 | #endif | 60 | #endif |
61 | 61 | ||
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 3c2c15f..2a52b00 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -1,477 +1,480 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** BenchmarkInfo | 2 | ** BenchmarkInfo |
3 | ** | 3 | ** |
4 | ** A benchmark for Qt/Embedded | 4 | ** A benchmark for Qt/Embedded |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> | 6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> |
7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> | 7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> |
8 | ** | 8 | ** |
9 | ** This file may be distributed and/or modified under the terms of the | 9 | ** This file may be distributed and/or modified under the terms of the |
10 | ** GNU General Public License version 2 as published by the Free Software | 10 | ** GNU General Public License version 2 as published by the Free Software |
11 | ** Foundation and appearing in the file LICENSE.GPL included in the | 11 | ** Foundation and appearing in the file LICENSE.GPL included in the |
12 | ** packaging of this file. | 12 | ** packaging of this file. |
13 | ** | 13 | ** |
14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
16 | ** | 16 | ** |
17 | **********************************************************************/ | 17 | **********************************************************************/ |
18 | 18 | ||
19 | #include "benchmarkinfo.h" | 19 | #include "benchmarkinfo.h" |
20 | 20 | ||
21 | /* OPIE */ | 21 | /* OPIE */ |
22 | #include <opie2/ostorageinfo.h> | 22 | #include <opie2/ostorageinfo.h> |
23 | #include <opie2/olistview.h> | 23 | #include <opie2/olistview.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | #include <qpe/qpedecoration_qws.h> | 26 | #include <qpe/qpedecoration_qws.h> |
27 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | #include <qclipboard.h> | 31 | #include <qclipboard.h> |
32 | #include <qcolor.h> | 32 | #include <qcolor.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qdirectpainter_qws.h> | 34 | #include <qdirectpainter_qws.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
37 | #include <qfiledialog.h> | 37 | #include <qfiledialog.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qpainter.h> | 40 | #include <qpainter.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwhatsthis.h> | 43 | #include <qwhatsthis.h> |
44 | 44 | ||
45 | /* STD */ | 45 | /* STD */ |
46 | #include <time.h> | 46 | #include <time.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <math.h> | 49 | #include <math.h> |
50 | #if defined (__GNUC__) && (__GNUC__ < 3) | 50 | #if defined (__GNUC__) && (__GNUC__ < 3) |
51 | extern double round(double); | 51 | extern double round(double); |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | using namespace Opie::Ui; | ||
55 | using namespace Opie::Core; | ||
54 | extern "C" | 56 | extern "C" |
57 | |||
55 | { | 58 | { |
56 | void BenchFFT( void ); | 59 | void BenchFFT( void ); |
57 | double dhry_main( int ); | 60 | double dhry_main( int ); |
58 | } | 61 | } |
59 | 62 | ||
60 | #define DHRYSTONE_RUNS 20000000 | 63 | #define DHRYSTONE_RUNS 20000000 |
61 | #define TEST_DURATION 3 | 64 | #define TEST_DURATION 3 |
62 | 65 | ||
63 | #define BUFF_SIZE 8192 | 66 | #define BUFF_SIZE 8192 |
64 | #define FILE_SIZE 1024 * 1024 // 1Mb | 67 | #define FILE_SIZE 1024 * 1024 // 1Mb |
65 | 68 | ||
66 | //=========================================================================== | 69 | //=========================================================================== |
67 | 70 | ||
68 | class BenchmarkPaintWidget : public QWidget | 71 | class BenchmarkPaintWidget : public QWidget |
69 | { | 72 | { |
70 | public: | 73 | public: |
71 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 74 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
72 | { | 75 | { |
73 | resize( QApplication::desktop()->size() ); | 76 | resize( QApplication::desktop()->size() ); |
74 | show(); | 77 | show(); |
75 | p.begin( this ); | 78 | p.begin( this ); |
76 | }; | 79 | }; |
77 | 80 | ||
78 | ~BenchmarkPaintWidget() | 81 | ~BenchmarkPaintWidget() |
79 | { | 82 | { |
80 | p.end(); | 83 | p.end(); |
81 | hide(); | 84 | hide(); |
82 | }; | 85 | }; |
83 | 86 | ||
84 | QPainter p; | 87 | QPainter p; |
85 | }; | 88 | }; |
86 | 89 | ||
87 | //=========================================================================== | 90 | //=========================================================================== |
88 | 91 | ||
89 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 92 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
90 | : QWidget( parent, name, wFlags ) | 93 | : QWidget( parent, name, wFlags ) |
91 | { | 94 | { |
92 | 95 | ||
93 | setMinimumSize( 200, 150 ); | 96 | setMinimumSize( 200, 150 ); |
94 | 97 | ||
95 | QVBoxLayout* vb = new QVBoxLayout( this ); | 98 | QVBoxLayout* vb = new QVBoxLayout( this ); |
96 | vb->setSpacing( 4 ); | 99 | vb->setSpacing( 4 ); |
97 | vb->setMargin( 4 ); | 100 | vb->setMargin( 4 ); |
98 | 101 | ||
99 | tests = new OListView( this ); | 102 | tests = new OListView( this ); |
100 | QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " | 103 | QWhatsThis::add( tests->viewport(), tr( "This area shows the available tests, the results for which the tests " |
101 | "have been performed, and comparison values for one selected device. " | 104 | "have been performed, and comparison values for one selected device. " |
102 | "Use the checkboxes to define which tests you want to perform." ) ); | 105 | "Use the checkboxes to define which tests you want to perform." ) ); |
103 | tests->setMargin( 0 ); | 106 | tests->setMargin( 0 ); |
104 | tests->addColumn( tr( "Tests" ) ); | 107 | tests->addColumn( tr( "Tests" ) ); |
105 | tests->addColumn( tr( "Results" ) ); | 108 | tests->addColumn( tr( "Results" ) ); |
106 | tests->addColumn( tr( "Comparison" ) ); | 109 | tests->addColumn( tr( "Comparison" ) ); |
107 | tests->setShowSortIndicator( true ); | 110 | tests->setShowSortIndicator( true ); |
108 | 111 | ||
109 | test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); | 112 | test_alu = new OCheckListItem( tests, tr( "1. Integer Arithmetic " ), OCheckListItem::CheckBox ); |
110 | test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); | 113 | test_fpu = new OCheckListItem( tests, tr( "2. Floating Point Unit " ), OCheckListItem::CheckBox ); |
111 | test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); | 114 | test_txt = new OCheckListItem( tests, tr( "3. Text Rendering " ), OCheckListItem::CheckBox ); |
112 | test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); | 115 | test_gfx = new OCheckListItem( tests, tr( "4. Gfx Rendering " ), OCheckListItem::CheckBox ); |
113 | test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); | 116 | test_ram = new OCheckListItem( tests, tr( "5. RAM Performance " ), OCheckListItem::CheckBox ); |
114 | test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); | 117 | test_sd = new OCheckListItem( tests, tr( "6. SD Card Performance " ), OCheckListItem::CheckBox ); |
115 | test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); | 118 | test_cf = new OCheckListItem( tests, tr( "7. CF Card Performance " ), OCheckListItem::CheckBox ); |
116 | 119 | ||
117 | test_alu->setText( 1, "n/a" ); | 120 | test_alu->setText( 1, "n/a" ); |
118 | test_fpu->setText( 1, "n/a" ); | 121 | test_fpu->setText( 1, "n/a" ); |
119 | test_txt->setText( 1, "n/a" ); | 122 | test_txt->setText( 1, "n/a" ); |
120 | test_gfx->setText( 1, "n/a" ); | 123 | test_gfx->setText( 1, "n/a" ); |
121 | test_ram->setText( 1, "n/a" ); | 124 | test_ram->setText( 1, "n/a" ); |
122 | test_sd->setText( 1, "n/a" ); | 125 | test_sd->setText( 1, "n/a" ); |
123 | test_cf->setText( 1, "n/a" ); | 126 | test_cf->setText( 1, "n/a" ); |
124 | 127 | ||
125 | test_alu->setText( 2, "n/a" ); | 128 | test_alu->setText( 2, "n/a" ); |
126 | test_fpu->setText( 2, "n/a" ); | 129 | test_fpu->setText( 2, "n/a" ); |
127 | test_txt->setText( 2, "n/a" ); | 130 | test_txt->setText( 2, "n/a" ); |
128 | test_gfx->setText( 2, "n/a" ); | 131 | test_gfx->setText( 2, "n/a" ); |
129 | test_ram->setText( 2, "n/a" ); | 132 | test_ram->setText( 2, "n/a" ); |
130 | test_sd->setText( 2, "n/a" ); | 133 | test_sd->setText( 2, "n/a" ); |
131 | test_cf->setText( 2, "n/a" ); | 134 | test_cf->setText( 2, "n/a" ); |
132 | 135 | ||
133 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 136 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
134 | QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); | 137 | QWhatsThis::add( startButton, tr( "Click here to perform the selected tests." ) ); |
135 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 138 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
136 | vb->addWidget( tests, 2 ); | 139 | vb->addWidget( tests, 2 ); |
137 | 140 | ||
138 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 141 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
139 | if ( f.open( IO_ReadOnly ) ) | 142 | if ( f.open( IO_ReadOnly ) ) |
140 | { | 143 | { |
141 | machineCombo = new QComboBox( this ); | 144 | machineCombo = new QComboBox( this ); |
142 | QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); | 145 | QWhatsThis::add( machineCombo, tr( "Choose a model to compare your results with." ) ); |
143 | 146 | ||
144 | QTextStream ts( &f ); | 147 | QTextStream ts( &f ); |
145 | while( !ts.eof() ) | 148 | while( !ts.eof() ) |
146 | { | 149 | { |
147 | QString machline = ts.readLine(); | 150 | QString machline = ts.readLine(); |
148 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); | 151 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); |
149 | QString resline = ts.readLine(); | 152 | QString resline = ts.readLine(); |
150 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 153 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
151 | machineCombo->insertItem( machline ); | 154 | machineCombo->insertItem( machline ); |
152 | } | 155 | } |
153 | 156 | ||
154 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 157 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
155 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); | 158 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); |
156 | hb->addWidget( machineCombo, 2 ); | 159 | hb->addWidget( machineCombo, 2 ); |
157 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); | 160 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
158 | } | 161 | } |
159 | 162 | ||
160 | vb->addWidget( startButton, 2 ); | 163 | vb->addWidget( startButton, 2 ); |
161 | } | 164 | } |
162 | 165 | ||
163 | 166 | ||
164 | BenchmarkInfo::~BenchmarkInfo() | 167 | BenchmarkInfo::~BenchmarkInfo() |
165 | {} | 168 | {} |
166 | 169 | ||
167 | 170 | ||
168 | void BenchmarkInfo::machineActivated( int index ) | 171 | void BenchmarkInfo::machineActivated( int index ) |
169 | { | 172 | { |
170 | QStringList* results = machines[ machineCombo->text( index ) ]; | 173 | QStringList* results = machines[ machineCombo->text( index ) ]; |
171 | if ( !results ) | 174 | if ( !results ) |
172 | { | 175 | { |
173 | qDebug( "sysinfo: no results available." ); | 176 | qDebug( "sysinfo: no results available." ); |
174 | return; | 177 | return; |
175 | } | 178 | } |
176 | QStringList::Iterator it = results->begin(); | 179 | QStringList::Iterator it = results->begin(); |
177 | test_alu->setText( 2, *(it++) ); | 180 | test_alu->setText( 2, *(it++) ); |
178 | test_fpu->setText( 2, *(it++) ); | 181 | test_fpu->setText( 2, *(it++) ); |
179 | test_txt->setText( 2, *(it++) ); | 182 | test_txt->setText( 2, *(it++) ); |
180 | test_gfx->setText( 2, *(it++) ); | 183 | test_gfx->setText( 2, *(it++) ); |
181 | test_ram->setText( 2, *(it++) ); | 184 | test_ram->setText( 2, *(it++) ); |
182 | test_sd->setText( 2, *(it++) ); | 185 | test_sd->setText( 2, *(it++) ); |
183 | test_cf->setText( 2, *(it++) ); | 186 | test_cf->setText( 2, *(it++) ); |
184 | } | 187 | } |
185 | 188 | ||
186 | 189 | ||
187 | void BenchmarkInfo::run() | 190 | void BenchmarkInfo::run() |
188 | { | 191 | { |
189 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 192 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
190 | qApp->processEvents(); | 193 | qApp->processEvents(); |
191 | QTime t; | 194 | QTime t; |
192 | 195 | ||
193 | if ( test_alu->isOn() ) | 196 | if ( test_alu->isOn() ) |
194 | { | 197 | { |
195 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 198 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
196 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); | 199 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
197 | test_alu->setOn( false ); | 200 | test_alu->setOn( false ); |
198 | } | 201 | } |
199 | 202 | ||
200 | if ( test_fpu->isOn() ) | 203 | if ( test_fpu->isOn() ) |
201 | { | 204 | { |
202 | t.start(); | 205 | t.start(); |
203 | BenchFFT(); | 206 | BenchFFT(); |
204 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 207 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
205 | test_fpu->setOn( false ); | 208 | test_fpu->setOn( false ); |
206 | } | 209 | } |
207 | 210 | ||
208 | if ( test_txt->isOn() ) | 211 | if ( test_txt->isOn() ) |
209 | { | 212 | { |
210 | int value = textRendering( TEST_DURATION ); | 213 | int value = textRendering( TEST_DURATION ); |
211 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); | 214 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
212 | test_txt->setOn( false ); | 215 | test_txt->setOn( false ); |
213 | } | 216 | } |
214 | 217 | ||
215 | if ( test_gfx->isOn() ) | 218 | if ( test_gfx->isOn() ) |
216 | { | 219 | { |
217 | int value = gfxRendering( TEST_DURATION ); | 220 | int value = gfxRendering( TEST_DURATION ); |
218 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests | 221 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
219 | test_gfx->setOn( false ); | 222 | test_gfx->setOn( false ); |
220 | } | 223 | } |
221 | 224 | ||
222 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 225 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
223 | { | 226 | { |
224 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 227 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
225 | } | 228 | } |
226 | 229 | ||
227 | if ( test_cf->isOn() ) | 230 | if ( test_cf->isOn() ) |
228 | { | 231 | { |
229 | OStorageInfo storage; | 232 | OStorageInfo storage; |
230 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 233 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
231 | } | 234 | } |
232 | 235 | ||
233 | if ( test_sd->isOn() ) | 236 | if ( test_sd->isOn() ) |
234 | { | 237 | { |
235 | OStorageInfo storage; | 238 | OStorageInfo storage; |
236 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 239 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
237 | } | 240 | } |
238 | 241 | ||
239 | startButton->setText( tr( "&Start Tests!" ) ); | 242 | startButton->setText( tr( "&Start Tests!" ) ); |
240 | } | 243 | } |
241 | 244 | ||
242 | 245 | ||
243 | int BenchmarkInfo::textRendering( int seconds ) | 246 | int BenchmarkInfo::textRendering( int seconds ) |
244 | { | 247 | { |
245 | QTime t; | 248 | QTime t; |
246 | t.start(); | 249 | t.start(); |
247 | int stop = t.elapsed() + seconds * 1000; | 250 | int stop = t.elapsed() + seconds * 1000; |
248 | 251 | ||
249 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 252 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
250 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 253 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
251 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 254 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
252 | const QString text( "Opie Benchmark Test" ); | 255 | const QString text( "Opie Benchmark Test" ); |
253 | 256 | ||
254 | int w = QApplication::desktop()->width(); | 257 | int w = QApplication::desktop()->width(); |
255 | int h = QApplication::desktop()->height(); | 258 | int h = QApplication::desktop()->height(); |
256 | 259 | ||
257 | srand( time( NULL ) ); | 260 | srand( time( NULL ) ); |
258 | 261 | ||
259 | BenchmarkPaintWidget bpw; | 262 | BenchmarkPaintWidget bpw; |
260 | 263 | ||
261 | int loops = 0; | 264 | int loops = 0; |
262 | 265 | ||
263 | while ( t.elapsed() < stop ) | 266 | while ( t.elapsed() < stop ) |
264 | { | 267 | { |
265 | int k = rand() % 9; | 268 | int k = rand() % 9; |
266 | int s = rand() % 100; | 269 | int s = rand() % 100; |
267 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 270 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
268 | bpw.p.setFont( QFont( "Vera", s ) ); | 271 | bpw.p.setFont( QFont( "Vera", s ) ); |
269 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 272 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
270 | ++loops; | 273 | ++loops; |
271 | } | 274 | } |
272 | 275 | ||
273 | return loops * text.length(); | 276 | return loops * text.length(); |
274 | } | 277 | } |
275 | 278 | ||
276 | int BenchmarkInfo::gfxRendering( int seconds ) | 279 | int BenchmarkInfo::gfxRendering( int seconds ) |
277 | { | 280 | { |
278 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 281 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
279 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 282 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
280 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 283 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
281 | 284 | ||
282 | int w = QApplication::desktop()->width(); | 285 | int w = QApplication::desktop()->width(); |
283 | int h = QApplication::desktop()->height(); | 286 | int h = QApplication::desktop()->height(); |
284 | 287 | ||
285 | srand( time( NULL ) ); | 288 | srand( time( NULL ) ); |
286 | 289 | ||
287 | BenchmarkPaintWidget bpw; | 290 | BenchmarkPaintWidget bpw; |
288 | 291 | ||
289 | QTime t; | 292 | QTime t; |
290 | t.start(); | 293 | t.start(); |
291 | int stop = t.elapsed() + seconds*1000; | 294 | int stop = t.elapsed() + seconds*1000; |
292 | int loops = 0; | 295 | int loops = 0; |
293 | 296 | ||
294 | while ( t.elapsed() < stop ) | 297 | while ( t.elapsed() < stop ) |
295 | { | 298 | { |
296 | int k = rand() % 9; | 299 | int k = rand() % 9; |
297 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 300 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
298 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 301 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
299 | ++loops; | 302 | ++loops; |
300 | } | 303 | } |
301 | 304 | ||
302 | t.restart(); | 305 | t.restart(); |
303 | stop = t.elapsed() + seconds*1000; | 306 | stop = t.elapsed() + seconds*1000; |
304 | 307 | ||
305 | while ( t.elapsed() < stop ) | 308 | while ( t.elapsed() < stop ) |
306 | { | 309 | { |
307 | int k = rand() % 9; | 310 | int k = rand() % 9; |
308 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 311 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
309 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 312 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
310 | ++loops; | 313 | ++loops; |
311 | } | 314 | } |
312 | 315 | ||
313 | QBrush br1; | 316 | QBrush br1; |
314 | br1.setStyle( SolidPattern ); | 317 | br1.setStyle( SolidPattern ); |
315 | t.restart(); | 318 | t.restart(); |
316 | stop = t.elapsed() + seconds*1000; | 319 | stop = t.elapsed() + seconds*1000; |
317 | 320 | ||
318 | while ( t.elapsed() < stop ) | 321 | while ( t.elapsed() < stop ) |
319 | { | 322 | { |
320 | int k = rand() % 9; | 323 | int k = rand() % 9; |
321 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 324 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
322 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 325 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
323 | ++loops; | 326 | ++loops; |
324 | } | 327 | } |
325 | 328 | ||
326 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 329 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
327 | t.restart(); | 330 | t.restart(); |
328 | stop = t.elapsed() + seconds*1000; | 331 | stop = t.elapsed() + seconds*1000; |
329 | 332 | ||
330 | while ( t.elapsed() < stop ) | 333 | while ( t.elapsed() < stop ) |
331 | { | 334 | { |
332 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 335 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
333 | ++loops; | 336 | ++loops; |
334 | } | 337 | } |
335 | 338 | ||
336 | return loops; | 339 | return loops; |
337 | 340 | ||
338 | } | 341 | } |
339 | 342 | ||
340 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) | 343 | void BenchmarkInfo::performFileTest( const QString& fname, OCheckListItem* item ) |
341 | { | 344 | { |
342 | QTime time; | 345 | QTime time; |
343 | time.start(); | 346 | time.start(); |
344 | if ( writeFile( fname ) && | 347 | if ( writeFile( fname ) && |
345 | readFile( fname ) ) | 348 | readFile( fname ) ) |
346 | { | 349 | { |
347 | QFile::remove( fname ); | 350 | QFile::remove( fname ); |
348 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); | 351 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); |
349 | item->setOn( false ); | 352 | item->setOn( false ); |
350 | } | 353 | } |
351 | else | 354 | else |
352 | { | 355 | { |
353 | item->setText( 1, tr( "error" ) ); | 356 | item->setText( 1, tr( "error" ) ); |
354 | } | 357 | } |
355 | } | 358 | } |
356 | 359 | ||
357 | char FileBuf[ BUFF_SIZE + 1 ]; | 360 | char FileBuf[ BUFF_SIZE + 1 ]; |
358 | 361 | ||
359 | bool BenchmarkInfo::writeFile( const QString& w_path ) | 362 | bool BenchmarkInfo::writeFile( const QString& w_path ) |
360 | { | 363 | { |
361 | int i; | 364 | int i; |
362 | int k; | 365 | int k; |
363 | int n; | 366 | int n; |
364 | int pos; | 367 | int pos; |
365 | int len; | 368 | int len; |
366 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 | 369 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 |
367 | 370 | ||
368 | 371 | ||
369 | // /*------------------------------------ | 372 | // /*------------------------------------ |
370 | int w_len; | 373 | int w_len; |
371 | 374 | ||
372 | QFile writeFile( w_path ); | 375 | QFile writeFile( w_path ); |
373 | srand( time( NULL ) ); | 376 | srand( time( NULL ) ); |
374 | 377 | ||
375 | for ( n = 0 ; n < 20 ; n++ ) | 378 | for ( n = 0 ; n < 20 ; n++ ) |
376 | { | 379 | { |
377 | if ( ! writeFile.open( IO_WriteOnly ) ) | 380 | if ( ! writeFile.open( IO_WriteOnly ) ) |
378 | { | 381 | { |
379 | writeFile.close(); | 382 | writeFile.close(); |
380 | writeFile.remove(); | 383 | writeFile.remove(); |
381 | return ( false ); | 384 | return ( false ); |
382 | } | 385 | } |
383 | // ------------------------------------------ sequential write | 386 | // ------------------------------------------ sequential write |
384 | for ( k = 0 ; k < 256 ; k++ ) | 387 | for ( k = 0 ; k < 256 ; k++ ) |
385 | { | 388 | { |
386 | n = rand() % 30; | 389 | n = rand() % 30; |
387 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); | 390 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); |
388 | } | 391 | } |
389 | 392 | ||
390 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 393 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
391 | { | 394 | { |
392 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); | 395 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); |
393 | if ( w_len != BUFF_SIZE ) | 396 | if ( w_len != BUFF_SIZE ) |
394 | { | 397 | { |
395 | writeFile.close(); | 398 | writeFile.close(); |
396 | writeFile.remove(); | 399 | writeFile.remove(); |
397 | return ( false ); | 400 | return ( false ); |
398 | } | 401 | } |
399 | writeFile.flush(); | 402 | writeFile.flush(); |
400 | } | 403 | } |
401 | // ------------------------------------------ random write | 404 | // ------------------------------------------ random write |
402 | for ( i = 0 ; i < 400 ; i++ ) | 405 | for ( i = 0 ; i < 400 ; i++ ) |
403 | { | 406 | { |
404 | len = rand() % 90 + 4000; | 407 | len = rand() % 90 + 4000; |
405 | for ( k = 0 ; k < 128 ; k++ ) | 408 | for ( k = 0 ; k < 128 ; k++ ) |
406 | { | 409 | { |
407 | n = rand() % 30; | 410 | n = rand() % 30; |
408 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); | 411 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); |
409 | } | 412 | } |
410 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); | 413 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); |
411 | 414 | ||
412 | writeFile.at( pos ); | 415 | writeFile.at( pos ); |
413 | w_len = writeFile.writeBlock( FileBuf, len ); | 416 | w_len = writeFile.writeBlock( FileBuf, len ); |
414 | if ( w_len != len ) | 417 | if ( w_len != len ) |
415 | { | 418 | { |
416 | writeFile.close(); | 419 | writeFile.close(); |
417 | writeFile.remove(); | 420 | writeFile.remove(); |
418 | return ( false ); | 421 | return ( false ); |
419 | } | 422 | } |
420 | writeFile.flush(); | 423 | writeFile.flush(); |
421 | } | 424 | } |
422 | writeFile.close(); | 425 | writeFile.close(); |
423 | } | 426 | } |
424 | return ( true ); | 427 | return ( true ); |
425 | 428 | ||
426 | } | 429 | } |
427 | 430 | ||
428 | 431 | ||
429 | bool BenchmarkInfo::readFile( const QString& r_path ) | 432 | bool BenchmarkInfo::readFile( const QString& r_path ) |
430 | { | 433 | { |
431 | int i; | 434 | int i; |
432 | int k; | 435 | int k; |
433 | int len; | 436 | int len; |
434 | int pos; | 437 | int pos; |
435 | int r_len; | 438 | int r_len; |
436 | 439 | ||
437 | QFile readFile( r_path ); | 440 | QFile readFile( r_path ); |
438 | srand( time( NULL ) ); | 441 | srand( time( NULL ) ); |
439 | 442 | ||
440 | for ( k = 0 ; k < 200 ; k++ ) | 443 | for ( k = 0 ; k < 200 ; k++ ) |
441 | { | 444 | { |
442 | if ( ! readFile.open( IO_ReadOnly ) ) | 445 | if ( ! readFile.open( IO_ReadOnly ) ) |
443 | { | 446 | { |
444 | readFile.remove(); | 447 | readFile.remove(); |
445 | return ( false ); | 448 | return ( false ); |
446 | } | 449 | } |
447 | // ------------------------------------------ sequential read | 450 | // ------------------------------------------ sequential read |
448 | readFile.at( 0 ); | 451 | readFile.at( 0 ); |
449 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 452 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
450 | { | 453 | { |
451 | readFile.at( i * BUFF_SIZE ); | 454 | readFile.at( i * BUFF_SIZE ); |
452 | r_len = readFile.readBlock( FileBuf, BUFF_SIZE ); | 455 | r_len = readFile.readBlock( FileBuf, BUFF_SIZE ); |
453 | if ( r_len != BUFF_SIZE ) | 456 | if ( r_len != BUFF_SIZE ) |
454 | { | 457 | { |
455 | readFile.close(); | 458 | readFile.close(); |
456 | readFile.remove(); | 459 | readFile.remove(); |
457 | return ( false ); | 460 | return ( false ); |
458 | } | 461 | } |
459 | } | 462 | } |
460 | // ------------------------------------------ random read | 463 | // ------------------------------------------ random read |
461 | for ( i = 0 ; i < 1000 ; i++ ) | 464 | for ( i = 0 ; i < 1000 ; i++ ) |
462 | { | 465 | { |
463 | len = rand() % 120 + 8; | 466 | len = rand() % 120 + 8; |
464 | pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE ); | 467 | pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE ); |
465 | readFile.at( pos ); | 468 | readFile.at( pos ); |
466 | r_len = readFile.readBlock( FileBuf, len ); | 469 | r_len = readFile.readBlock( FileBuf, len ); |
467 | if ( r_len != len ) | 470 | if ( r_len != len ) |
468 | { | 471 | { |
469 | readFile.close(); | 472 | readFile.close(); |
470 | readFile.remove(); | 473 | readFile.remove(); |
471 | return ( false ); | 474 | return ( false ); |
472 | } | 475 | } |
473 | } | 476 | } |
474 | readFile.close(); | 477 | readFile.close(); |
475 | } | 478 | } |
476 | return ( true ); | 479 | return ( true ); |
477 | } | 480 | } |
diff --git a/noncore/settings/sysinfo/benchmarkinfo.h b/noncore/settings/sysinfo/benchmarkinfo.h index c3d44ec..0a61134 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.h +++ b/noncore/settings/sysinfo/benchmarkinfo.h | |||
@@ -1,69 +1,69 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** BenchmarkInfo | 2 | ** BenchmarkInfo |
3 | ** | 3 | ** |
4 | ** A benchmark for Qt/Embedded | 4 | ** A benchmark for Qt/Embedded |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> | 6 | ** Copyright (C) 2004 Michael Lauer <mickey@vanille.de> |
7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> | 7 | ** Inspired by ZBench (C) 2002 Satoshi <af230533@im07.alpha-net.ne.jp> |
8 | ** | 8 | ** |
9 | ** This file may be distributed and/or modified under the terms of the | 9 | ** This file may be distributed and/or modified under the terms of the |
10 | ** GNU General Public License version 2 as published by the Free Software | 10 | ** GNU General Public License version 2 as published by the Free Software |
11 | ** Foundation and appearing in the file LICENSE.GPL included in the | 11 | ** Foundation and appearing in the file LICENSE.GPL included in the |
12 | ** packaging of this file. | 12 | ** packaging of this file. |
13 | ** | 13 | ** |
14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 14 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 15 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
16 | ** | 16 | ** |
17 | **********************************************************************/ | 17 | **********************************************************************/ |
18 | 18 | ||
19 | #include <qwidget.h> | 19 | #include <qwidget.h> |
20 | #include <qdialog.h> | 20 | #include <qdialog.h> |
21 | #include <qdict.h> | 21 | #include <qdict.h> |
22 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
23 | 23 | ||
24 | class QClipboard; | 24 | class QClipboard; |
25 | class QComboBox; | 25 | class QComboBox; |
26 | class OCheckListItem; | 26 | namespace Opie {namespace Ui {class OCheckListItem;}} |
27 | class QPushButton; | 27 | class QPushButton; |
28 | class OListView; | 28 | namespace Opie {namespace Ui {class OListView;}} |
29 | 29 | ||
30 | class BenchmarkInfo : public QWidget | 30 | class BenchmarkInfo : public QWidget |
31 | { | 31 | { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | 33 | ||
34 | public: | 34 | public: |
35 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); | 35 | BenchmarkInfo( QWidget *parent = 0, const char *name = 0, int wFlags = 0 ); |
36 | ~BenchmarkInfo(); | 36 | ~BenchmarkInfo(); |
37 | 37 | ||
38 | OCheckListItem* test_alu; | 38 | Opie::Ui::OCheckListItem* test_alu; |
39 | OCheckListItem* test_fpu; | 39 | Opie::Ui::OCheckListItem* test_fpu; |
40 | OCheckListItem* test_txt; | 40 | Opie::Ui::OCheckListItem* test_txt; |
41 | OCheckListItem* test_gfx; | 41 | Opie::Ui::OCheckListItem* test_gfx; |
42 | OCheckListItem* test_ram; | 42 | Opie::Ui::OCheckListItem* test_ram; |
43 | OCheckListItem* test_sd; | 43 | Opie::Ui::OCheckListItem* test_sd; |
44 | OCheckListItem* test_cf; | 44 | Opie::Ui::OCheckListItem* test_cf; |
45 | 45 | ||
46 | bool main_rd; | 46 | bool main_rd; |
47 | bool main_wt; | 47 | bool main_wt; |
48 | bool sd_rd; | 48 | bool sd_rd; |
49 | bool sd_wt; | 49 | bool sd_wt; |
50 | bool cf_rd; | 50 | bool cf_rd; |
51 | bool cf_wt; | 51 | bool cf_wt; |
52 | 52 | ||
53 | QClipboard* clb; | 53 | QClipboard* clb; |
54 | QComboBox* machineCombo; | 54 | QComboBox* machineCombo; |
55 | OListView* tests; | 55 | Opie::Ui::OListView* tests; |
56 | QPushButton* startButton; | 56 | QPushButton* startButton; |
57 | QDict <QStringList> machines; | 57 | QDict <QStringList> machines; |
58 | 58 | ||
59 | int textRendering( int ); | 59 | int textRendering( int ); |
60 | int gfxRendering( int ); | 60 | int gfxRendering( int ); |
61 | void performFileTest( const QString& fname, OCheckListItem* item ); | 61 | void performFileTest( const QString& fname, Opie::Ui::OCheckListItem* item ); |
62 | 62 | ||
63 | private slots: | 63 | private slots: |
64 | bool writeFile( const QString& ); | 64 | bool writeFile( const QString& ); |
65 | bool readFile( const QString& ); | 65 | bool readFile( const QString& ); |
66 | void run(); | 66 | void run(); |
67 | void machineActivated( int ); | 67 | void machineActivated( int ); |
68 | }; | 68 | }; |
69 | 69 | ||
diff --git a/noncore/settings/sysinfo/main.cpp b/noncore/settings/sysinfo/main.cpp index 3a7b1b1..8ebac20 100644 --- a/noncore/settings/sysinfo/main.cpp +++ b/noncore/settings/sysinfo/main.cpp | |||
@@ -1,26 +1,27 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "sysinfo.h" | 21 | #include "sysinfo.h" |
22 | 22 | ||
23 | #include <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | 25 | ||
26 | using namespace Opie::Core; | ||
26 | OPIE_EXPORT_APP( OApplicationFactory<SystemInfo> ) | 27 | OPIE_EXPORT_APP( OApplicationFactory<SystemInfo> ) |
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index dfe48e1..71cefcb 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -1,194 +1,200 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ModulesInfo | 2 | ** ModulesInfo |
3 | ** | 3 | ** |
4 | ** Display Modules information | 4 | ** Display Modules information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Michael Lauer | 6 | ** Copyright (C) 2002, Michael Lauer |
7 | ** mickey@tm.informatik.uni-frankfurt.de | 7 | ** mickey@tm.informatik.uni-frankfurt.de |
8 | ** http://www.Vanille.de | 8 | ** http://www.Vanille.de |
9 | ** | 9 | ** |
10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> | 10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> |
11 | ** | 11 | ** |
12 | ** This file may be distributed and/or modified under the terms of the | 12 | ** This file may be distributed and/or modified under the terms of the |
13 | ** GNU General Public License version 2 as published by the Free Software | 13 | ** GNU General Public License version 2 as published by the Free Software |
14 | ** Foundation and appearing in the file LICENSE.GPL included in the | 14 | ** Foundation and appearing in the file LICENSE.GPL included in the |
15 | ** packaging of this file. | 15 | ** packaging of this file. |
16 | ** | 16 | ** |
17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include "modulesinfo.h" | 22 | #include "modulesinfo.h" |
23 | #include "detail.h" | 23 | #include "detail.h" |
24 | 24 | ||
25 | /* OPIE */ | 25 | /* OPIE */ |
26 | #include <opie2/olistview.h> | 26 | #include <opie2/olistview.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | /* QT */ | 29 | /* QT */ |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qtextview.h> | 35 | #include <qtextview.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qwhatsthis.h> | 37 | #include <qwhatsthis.h> |
38 | 38 | ||
39 | using namespace Opie::Ui; | ||
39 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 40 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
40 | : QWidget( parent, name, fl ) | 41 | : QWidget( parent, name, fl ) |
41 | { | 42 | { |
42 | QGridLayout *layout = new QGridLayout( this ); | 43 | QGridLayout *layout = new QGridLayout( this ); |
43 | layout->setSpacing( 4 ); | 44 | layout->setSpacing( 4 ); |
44 | layout->setMargin( 4 ); | 45 | layout->setMargin( 4 ); |
45 | 46 | ||
46 | ModulesView = new OListView( this ); | 47 | ModulesView = new OListView( this ); |
47 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 48 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
48 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 49 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
49 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 50 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
50 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 51 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
51 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 52 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
52 | colnum = ModulesView->addColumn( tr( "Used by" ) ); | 53 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
53 | ModulesView->setAllColumnsShowFocus( TRUE ); | 54 | ModulesView->setAllColumnsShowFocus( TRUE ); |
54 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 55 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
55 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); | 56 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); |
56 | 57 | ||
57 | // Test if we have /sbin/modinfo, and if so, allow module detail window | 58 | // Test if we have /sbin/modinfo, and if so, allow module detail window |
58 | if ( QFile::exists( "/sbin/modinfo" ) ) | 59 | if ( QFile::exists( "/sbin/modinfo" ) ) |
59 | { | 60 | { |
60 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 61 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
61 | connect( ModulesView, SIGNAL( rightButtonPressed(OListViewItem*,const QPoint&,int) ), | 62 | connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
62 | this, SLOT( viewModules(OListViewItem*) ) ); | 63 | this, SLOT( viewModules(QListViewItem*) ) ); |
63 | } | 64 | } |
64 | 65 | ||
65 | CommandCB = new QComboBox( FALSE, this ); | 66 | CommandCB = new QComboBox( FALSE, this ); |
66 | CommandCB->insertItem( "modprobe -r" ); | 67 | CommandCB->insertItem( "modprobe -r" ); |
67 | CommandCB->insertItem( "rmmod" ); | 68 | CommandCB->insertItem( "rmmod" ); |
68 | // I can't think of other useful commands yet. Anyone? | 69 | // I can't think of other useful commands yet. Anyone? |
69 | layout->addWidget( CommandCB, 1, 0 ); | 70 | layout->addWidget( CommandCB, 1, 0 ); |
70 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); | 71 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); |
71 | 72 | ||
72 | QPushButton *btn = new QPushButton( this ); | 73 | QPushButton *btn = new QPushButton( this ); |
73 | btn->setMinimumSize( QSize( 50, 24 ) ); | 74 | btn->setMinimumSize( QSize( 50, 24 ) ); |
74 | btn->setMaximumSize( QSize( 50, 24 ) ); | 75 | btn->setMaximumSize( QSize( 50, 24 ) ); |
75 | btn->setText( tr( "Send" ) ); | 76 | btn->setText( tr( "Send" ) ); |
76 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 77 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
77 | layout->addWidget( btn, 1, 1 ); | 78 | layout->addWidget( btn, 1, 1 ); |
78 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 79 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
79 | 80 | ||
80 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
81 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
82 | t->start( 5000 ); | 83 | t->start( 5000 ); |
83 | 84 | ||
84 | updateData(); | 85 | updateData(); |
85 | 86 | ||
86 | ModulesDtl = new Detail(); | 87 | ModulesDtl = new Detail(); |
87 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | 88 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); |
88 | } | 89 | } |
89 | 90 | ||
90 | ModulesInfo::~ModulesInfo() | 91 | ModulesInfo::~ModulesInfo() |
91 | {} | 92 | {} |
92 | 93 | ||
93 | void ModulesInfo::updateData() | 94 | void ModulesInfo::updateData() |
94 | { | 95 | { |
95 | char modname[64]; | 96 | char modname[64]; |
96 | char usage[200]; | 97 | char usage[200]; |
97 | int modsize, usecount; | 98 | int modsize, usecount; |
98 | 99 | ||
99 | QString selectedmod; | 100 | QString selectedmod; |
100 | OListViewItem *curritem = static_cast<OListViewItem*>( ModulesView->currentItem() ); | 101 | OListViewItem *curritem = static_cast<OListViewItem*>( ModulesView->currentItem() ); |
101 | if ( curritem ) | 102 | if ( curritem ) |
102 | { | 103 | { |
103 | selectedmod = curritem->text( 0 ); | 104 | selectedmod = curritem->text( 0 ); |
104 | } | 105 | } |
105 | 106 | ||
106 | ModulesView->clear(); | 107 | ModulesView->clear(); |
107 | 108 | ||
108 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 109 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
109 | 110 | ||
110 | if ( procfile ) | 111 | if ( procfile ) |
111 | { | 112 | { |
112 | OListViewItem *newitem; | 113 | OListViewItem *newitem; |
113 | OListViewItem *selecteditem = 0x0; | 114 | OListViewItem *selecteditem = 0x0; |
114 | while ( true ) | 115 | while ( true ) |
115 | { | 116 | { |
116 | modname[0] = '\0'; | 117 | modname[0] = '\0'; |
117 | usage[0] = '\0'; | 118 | usage[0] = '\0'; |
118 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 119 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
119 | 120 | ||
120 | if ( success == EOF ) | 121 | if ( success == EOF ) |
121 | break; | 122 | break; |
122 | 123 | ||
123 | QString qmodname = QString( modname ); | 124 | QString qmodname = QString( modname ); |
124 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 125 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
125 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 126 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
126 | QString qusage = QString( usage ); | 127 | QString qusage = QString( usage ); |
127 | 128 | ||
128 | newitem = new OListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 129 | newitem = new OListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
129 | if ( qmodname == selectedmod ) | 130 | if ( qmodname == selectedmod ) |
130 | { | 131 | { |
131 | selecteditem = newitem; | 132 | selecteditem = newitem; |
132 | } | 133 | } |
133 | } | 134 | } |
134 | ModulesView->setCurrentItem( selecteditem ); | 135 | ModulesView->setCurrentItem( selecteditem ); |
135 | 136 | ||
136 | fclose( procfile ); | 137 | fclose( procfile ); |
137 | } | 138 | } |
138 | } | 139 | } |
139 | 140 | ||
140 | void ModulesInfo::slotSendClicked() | 141 | void ModulesInfo::slotSendClicked() |
141 | { | 142 | { |
142 | if ( !ModulesView->currentItem() ) | 143 | if ( !ModulesView->currentItem() ) |
143 | { | 144 | { |
144 | return; | 145 | return; |
145 | } | 146 | } |
146 | 147 | ||
147 | QString capstr = tr( "You really want to execute\n%1 for this module?" ).arg( CommandCB->currentText() ); | 148 | QString capstr = tr( "You really want to execute\n%1 for this module?" ).arg( CommandCB->currentText() ); |
148 | 149 | ||
149 | QString modname = ModulesView->currentItem()->text( 0 ); | 150 | QString modname = ModulesView->currentItem()->text( 0 ); |
150 | 151 | ||
151 | if ( QMessageBox::warning( this, modname, capstr, | 152 | if ( QMessageBox::warning( this, modname, capstr, |
152 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 153 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
153 | { | 154 | { |
154 | QString command = "/sbin/"; | 155 | QString command = "/sbin/"; |
155 | command.append( CommandCB->currentText() ); | 156 | command.append( CommandCB->currentText() ); |
156 | command.append( " " ); | 157 | command.append( " " ); |
157 | command.append( modname ); | 158 | command.append( modname ); |
158 | 159 | ||
159 | FILE* stream = popen( command, "r" ); | 160 | FILE* stream = popen( command, "r" ); |
160 | if ( stream ) | 161 | if ( stream ) |
161 | pclose( stream ); | 162 | pclose( stream ); |
162 | } | 163 | } |
163 | 164 | ||
164 | } | 165 | } |
165 | 166 | ||
167 | void ModulesInfo::viewModules( QListViewItem *module ) { | ||
168 | if ( !module ) | ||
169 | return; | ||
170 | viewModules( static_cast<OListViewItem*>( module ) ); | ||
171 | } | ||
166 | void ModulesInfo::viewModules( OListViewItem *modules ) | 172 | void ModulesInfo::viewModules( OListViewItem *modules ) |
167 | { | 173 | { |
168 | QString modname = modules->text( 0 ); | 174 | QString modname = modules->text( 0 ); |
169 | QString capstr = "Module: "; | 175 | QString capstr = "Module: "; |
170 | capstr.append( modname ); | 176 | capstr.append( modname ); |
171 | ModulesDtl->setCaption( capstr ); | 177 | ModulesDtl->setCaption( capstr ); |
172 | QString command = "/sbin/modinfo "; | 178 | QString command = "/sbin/modinfo "; |
173 | command.append( modname ); | 179 | command.append( modname ); |
174 | FILE* modinfo = popen( command, "r" ); | 180 | FILE* modinfo = popen( command, "r" ); |
175 | 181 | ||
176 | if ( modinfo ) | 182 | if ( modinfo ) |
177 | { | 183 | { |
178 | char line[200]; | 184 | char line[200]; |
179 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); | 185 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); |
180 | 186 | ||
181 | while( true ) | 187 | while( true ) |
182 | { | 188 | { |
183 | int success = fscanf( modinfo, "%[^\n]\n", line ); | 189 | int success = fscanf( modinfo, "%[^\n]\n", line ); |
184 | if ( success == EOF ) | 190 | if ( success == EOF ) |
185 | break; | 191 | break; |
186 | ModulesDtl->detailView->append( line ); | 192 | ModulesDtl->detailView->append( line ); |
187 | } | 193 | } |
188 | 194 | ||
189 | pclose( modinfo ); | 195 | pclose( modinfo ); |
190 | } | 196 | } |
191 | 197 | ||
192 | QPEApplication::showWidget( ModulesDtl ); | 198 | QPEApplication::showWidget( ModulesDtl ); |
193 | } | 199 | } |
194 | 200 | ||
diff --git a/noncore/settings/sysinfo/modulesinfo.h b/noncore/settings/sysinfo/modulesinfo.h index 78dce73..b816b41 100644 --- a/noncore/settings/sysinfo/modulesinfo.h +++ b/noncore/settings/sysinfo/modulesinfo.h | |||
@@ -1,51 +1,53 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ModulesInfo | 2 | ** ModulesInfo |
3 | ** | 3 | ** |
4 | ** Display modules information | 4 | ** Display modules information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Michael Lauer | 6 | ** Copyright (C) 2002, Michael Lauer |
7 | ** mickey@tm.informatik.uni-frankfurt.de | 7 | ** mickey@tm.informatik.uni-frankfurt.de |
8 | ** http://www.Vanille.de | 8 | ** http://www.Vanille.de |
9 | ** | 9 | ** |
10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> | 10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> |
11 | ** | 11 | ** |
12 | ** This file may be distributed and/or modified under the terms of the | 12 | ** This file may be distributed and/or modified under the terms of the |
13 | ** GNU General Public License version 2 as published by the Free Software | 13 | ** GNU General Public License version 2 as published by the Free Software |
14 | ** Foundation and appearing in the file LICENSE.GPL included in the | 14 | ** Foundation and appearing in the file LICENSE.GPL included in the |
15 | ** packaging of this file. | 15 | ** packaging of this file. |
16 | ** | 16 | ** |
17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef MODULESINFO_H | 22 | #ifndef MODULESINFO_H |
23 | #define MODULESINFO_H | 23 | #define MODULESINFO_H |
24 | 24 | ||
25 | #include <qwidget.h> | 25 | #include <qwidget.h> |
26 | 26 | ||
27 | class Detail; | 27 | class Detail; |
28 | class QComboBox; | 28 | class QComboBox; |
29 | class OListView; | 29 | class QListViewItem; |
30 | class OListViewItem; | 30 | namespace Opie {namespace Ui {class OListView;}} |
31 | namespace Opie {namespace Ui {class OListViewItem;}} | ||
31 | 32 | ||
32 | class ModulesInfo : public QWidget | 33 | class ModulesInfo : public QWidget |
33 | { | 34 | { |
34 | Q_OBJECT | 35 | Q_OBJECT |
35 | public: | 36 | public: |
36 | ModulesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 37 | ModulesInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
37 | ~ModulesInfo(); | 38 | ~ModulesInfo(); |
38 | 39 | ||
39 | private: | 40 | private: |
40 | OListView* ModulesView; | 41 | Opie::Ui::OListView* ModulesView; |
41 | QComboBox* CommandCB; | 42 | QComboBox* CommandCB; |
42 | 43 | ||
43 | Detail* ModulesDtl; | 44 | Detail* ModulesDtl; |
44 | 45 | ||
45 | private slots: | 46 | private slots: |
46 | void updateData(); | 47 | void updateData(); |
47 | void slotSendClicked(); | 48 | void slotSendClicked(); |
48 | void viewModules( OListViewItem * ); | 49 | void viewModules( QListViewItem* ); |
50 | void viewModules( Opie::Ui::OListViewItem * ); | ||
49 | }; | 51 | }; |
50 | 52 | ||
51 | #endif | 53 | #endif |
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index dd9a05d..e887267 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -1,206 +1,213 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ProcessInfo | 2 | ** ProcessInfo |
3 | ** | 3 | ** |
4 | ** Display process information | 4 | ** Display process information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Dan Williams | 6 | ** Copyright (C) 2002, Dan Williams |
7 | ** williamsdr@acm.org | 7 | ** williamsdr@acm.org |
8 | ** http://draknor.net | 8 | ** http://draknor.net |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #include "processinfo.h" | 20 | #include "processinfo.h" |
21 | #include "detail.h" | 21 | #include "detail.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/olistview.h> | 24 | #include <opie2/olistview.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | 26 | ||
27 | /* QT */ | 27 | /* QT */ |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qtextview.h> | 33 | #include <qtextview.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <sys/types.h> | 38 | #include <sys/types.h> |
39 | #include <signal.h> | 39 | #include <signal.h> |
40 | 40 | ||
41 | using namespace Opie::Ui; | ||
41 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 42 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
42 | : QWidget( parent, name, fl ) | 43 | : QWidget( parent, name, fl ) |
43 | { | 44 | { |
44 | QGridLayout *layout = new QGridLayout( this ); | 45 | QGridLayout *layout = new QGridLayout( this ); |
45 | layout->setSpacing( 4 ); | 46 | layout->setSpacing( 4 ); |
46 | layout->setMargin( 4 ); | 47 | layout->setMargin( 4 ); |
47 | 48 | ||
48 | 49 | ||
49 | ProcessView = new OListView( this, "ProcessView" ); | 50 | ProcessView = new OListView( this, "ProcessView" ); |
50 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 51 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 52 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
52 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 53 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
53 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 54 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
54 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 55 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
55 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 56 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
56 | ProcessView->setAllColumnsShowFocus( TRUE ); | 57 | ProcessView->setAllColumnsShowFocus( TRUE ); |
57 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 58 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
58 | connect( ProcessView, SIGNAL( rightButtonPressed(OListViewItem*,const QPoint&,int) ), | 59 | connect( ProcessView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
59 | this, SLOT( viewProcess(OListViewItem*) ) ); | 60 | this, SLOT( viewProcess(QListViewItem*) ) ); |
60 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 61 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
61 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); | 62 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); |
62 | 63 | ||
63 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 64 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
64 | SignalCB->insertItem( " 1: SIGHUP" ); | 65 | SignalCB->insertItem( " 1: SIGHUP" ); |
65 | SignalCB->insertItem( " 2: SIGINT" ); | 66 | SignalCB->insertItem( " 2: SIGINT" ); |
66 | SignalCB->insertItem( " 3: SIGQUIT" ); | 67 | SignalCB->insertItem( " 3: SIGQUIT" ); |
67 | SignalCB->insertItem( " 5: SIGTRAP" ); | 68 | SignalCB->insertItem( " 5: SIGTRAP" ); |
68 | SignalCB->insertItem( " 6: SIGABRT" ); | 69 | SignalCB->insertItem( " 6: SIGABRT" ); |
69 | SignalCB->insertItem( " 9: SIGKILL" ); | 70 | SignalCB->insertItem( " 9: SIGKILL" ); |
70 | SignalCB->insertItem( "14: SIGALRM" ); | 71 | SignalCB->insertItem( "14: SIGALRM" ); |
71 | SignalCB->insertItem( "15: SIGTERM" ); | 72 | SignalCB->insertItem( "15: SIGTERM" ); |
72 | SignalCB->insertItem( "18: SIGCONT" ); | 73 | SignalCB->insertItem( "18: SIGCONT" ); |
73 | SignalCB->insertItem( "19: SIGSTOP" ); | 74 | SignalCB->insertItem( "19: SIGSTOP" ); |
74 | layout->addWidget( SignalCB, 1, 0 ); | 75 | layout->addWidget( SignalCB, 1, 0 ); |
75 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); | 76 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); |
76 | 77 | ||
77 | SendButton = new QPushButton( this, "SendButton" ); | 78 | SendButton = new QPushButton( this, "SendButton" ); |
78 | SendButton->setMinimumSize( QSize( 50, 24 ) ); | 79 | SendButton->setMinimumSize( QSize( 50, 24 ) ); |
79 | SendButton->setMaximumSize( QSize( 50, 24 ) ); | 80 | SendButton->setMaximumSize( QSize( 50, 24 ) ); |
80 | SendButton->setText( tr( "Send" ) ); | 81 | SendButton->setText( tr( "Send" ) ); |
81 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 82 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
82 | layout->addWidget( SendButton, 1, 1 ); | 83 | layout->addWidget( SendButton, 1, 1 ); |
83 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); | 84 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); |
84 | 85 | ||
85 | QTimer *t = new QTimer( this ); | 86 | QTimer *t = new QTimer( this ); |
86 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 87 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
87 | t->start( 5000 ); | 88 | t->start( 5000 ); |
88 | 89 | ||
89 | updateData(); | 90 | updateData(); |
90 | 91 | ||
91 | ProcessDtl = new Detail(); | 92 | ProcessDtl = new Detail(); |
92 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); | 93 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); |
93 | } | 94 | } |
94 | 95 | ||
95 | ProcessInfo::~ProcessInfo() | 96 | ProcessInfo::~ProcessInfo() |
96 | {} | 97 | {} |
97 | 98 | ||
98 | void ProcessInfo::updateData() | 99 | void ProcessInfo::updateData() |
99 | { | 100 | { |
100 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, | 101 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, |
101 | signal, blocked, sigignore, sigcatch; | 102 | signal, blocked, sigignore, sigcatch; |
102 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, | 103 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, |
103 | endcode, startstack, kstkesp, kstkeip, wchan; | 104 | endcode, startstack, kstkesp, kstkeip, wchan; |
104 | char state; | 105 | char state; |
105 | char comm[64]; | 106 | char comm[64]; |
106 | 107 | ||
107 | QString selectedpid; | 108 | QString selectedpid; |
108 | OListViewItem *curritem = static_cast<OListViewItem*>( ProcessView->currentItem() ); | 109 | OListViewItem *curritem = static_cast<OListViewItem*>( ProcessView->currentItem() ); |
109 | if ( curritem ) | 110 | if ( curritem ) |
110 | { | 111 | { |
111 | selectedpid = curritem->text( 0 ); | 112 | selectedpid = curritem->text( 0 ); |
112 | } | 113 | } |
113 | 114 | ||
114 | ProcessView->clear(); | 115 | ProcessView->clear(); |
115 | 116 | ||
116 | OListViewItem *newitem; | 117 | OListViewItem *newitem; |
117 | OListViewItem *selecteditem = 0x0; | 118 | OListViewItem *selecteditem = 0x0; |
118 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 119 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
119 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 120 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
120 | if ( proclist ) | 121 | if ( proclist ) |
121 | { | 122 | { |
122 | QFileInfoListIterator it(*proclist); | 123 | QFileInfoListIterator it(*proclist); |
123 | QFileInfo *f; | 124 | QFileInfo *f; |
124 | while ( ( f = it.current() ) != 0 ) | 125 | while ( ( f = it.current() ) != 0 ) |
125 | { | 126 | { |
126 | ++it; | 127 | ++it; |
127 | QString processnum = f->fileName(); | 128 | QString processnum = f->fileName(); |
128 | if ( processnum >= "1" && processnum <= "99999" ) | 129 | if ( processnum >= "1" && processnum <= "99999" ) |
129 | { | 130 | { |
130 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 131 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
131 | 132 | ||
132 | if ( procfile ) | 133 | if ( procfile ) |
133 | { | 134 | { |
134 | fscanf( procfile, | 135 | fscanf( procfile, |
135 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", | 136 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", |
136 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 137 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
137 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 138 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
138 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 139 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
139 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 140 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
140 | processnum = processnum.rightJustify( 5, ' ' ); | 141 | processnum = processnum.rightJustify( 5, ' ' ); |
141 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 142 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
142 | QString processstatus = QChar(state); | 143 | QString processstatus = QChar(state); |
143 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 144 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
144 | processtime = processtime.rightJustify( 9, ' ' ); | 145 | processtime = processtime.rightJustify( 9, ' ' ); |
145 | fclose( procfile ); | 146 | fclose( procfile ); |
146 | 147 | ||
147 | newitem = new OListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 148 | newitem = new OListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
148 | if ( processnum == selectedpid ) | 149 | if ( processnum == selectedpid ) |
149 | { | 150 | { |
150 | selecteditem = newitem; | 151 | selecteditem = newitem; |
151 | } | 152 | } |
152 | } | 153 | } |
153 | } | 154 | } |
154 | } | 155 | } |
155 | ProcessView->setCurrentItem( selecteditem ); | 156 | ProcessView->setCurrentItem( selecteditem ); |
156 | } | 157 | } |
157 | 158 | ||
158 | delete proclist; | 159 | delete proclist; |
159 | delete procdir; | 160 | delete procdir; |
160 | } | 161 | } |
161 | 162 | ||
162 | void ProcessInfo::slotSendClicked() | 163 | void ProcessInfo::slotSendClicked() |
163 | { | 164 | { |
164 | OListViewItem *currprocess = static_cast<OListViewItem*>( ProcessView->currentItem() ); | 165 | OListViewItem *currprocess = static_cast<OListViewItem*>( ProcessView->currentItem() ); |
165 | if ( !currprocess ) | 166 | if ( !currprocess ) |
166 | { | 167 | { |
167 | return; | 168 | return; |
168 | } | 169 | } |
169 | 170 | ||
170 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); | 171 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); |
171 | 172 | ||
172 | 173 | ||
173 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 174 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
174 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 175 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
175 | { | 176 | { |
176 | currprocess = static_cast<OListViewItem*>( ProcessView->currentItem() ); | 177 | currprocess = static_cast<OListViewItem*>( ProcessView->currentItem() ); |
177 | if ( currprocess ) | 178 | if ( currprocess ) |
178 | { | 179 | { |
179 | QString sigstr = SignalCB->currentText(); | 180 | QString sigstr = SignalCB->currentText(); |
180 | sigstr.truncate(2); | 181 | sigstr.truncate(2); |
181 | int sigid = sigstr.toUInt(); | 182 | int sigid = sigstr.toUInt(); |
182 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); | 183 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); |
183 | } | 184 | } |
184 | } | 185 | } |
185 | 186 | ||
186 | } | 187 | } |
187 | 188 | ||
189 | void ProcessInfo::viewProcess( QListViewItem* process ) { | ||
190 | if ( !process ) | ||
191 | return; | ||
192 | viewProcess( static_cast<OListViewItem*>( process ) ); | ||
193 | } | ||
194 | |||
188 | void ProcessInfo::viewProcess( OListViewItem *process ) | 195 | void ProcessInfo::viewProcess( OListViewItem *process ) |
189 | { | 196 | { |
190 | QString pid= process->text( 0 ).stripWhiteSpace(); | 197 | QString pid= process->text( 0 ).stripWhiteSpace(); |
191 | QString command = process->text( 1 ); | 198 | QString command = process->text( 1 ); |
192 | ProcessDtl->setCaption( pid + " - " + command ); | 199 | ProcessDtl->setCaption( pid + " - " + command ); |
193 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 200 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
194 | if ( statfile ) | 201 | if ( statfile ) |
195 | { | 202 | { |
196 | char line[81]; | 203 | char line[81]; |
197 | fgets( line, 81, statfile ); | 204 | fgets( line, 81, statfile ); |
198 | ProcessDtl->detailView->setText( line ); | 205 | ProcessDtl->detailView->setText( line ); |
199 | while ( fgets( line, 81, statfile ) ) | 206 | while ( fgets( line, 81, statfile ) ) |
200 | { | 207 | { |
201 | ProcessDtl->detailView->append( line ); | 208 | ProcessDtl->detailView->append( line ); |
202 | } | 209 | } |
203 | fclose( statfile ); | 210 | fclose( statfile ); |
204 | } | 211 | } |
205 | QPEApplication::showWidget( ProcessDtl ); | 212 | QPEApplication::showWidget( ProcessDtl ); |
206 | } | 213 | } |
diff --git a/noncore/settings/sysinfo/processinfo.h b/noncore/settings/sysinfo/processinfo.h index 6e7acd5..0a1682b 100644 --- a/noncore/settings/sysinfo/processinfo.h +++ b/noncore/settings/sysinfo/processinfo.h | |||
@@ -1,50 +1,52 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ProcessInfo | 2 | ** ProcessInfo |
3 | ** | 3 | ** |
4 | ** Display process information | 4 | ** Display process information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Dan Williams | 6 | ** Copyright (C) 2002, Dan Williams |
7 | ** williamsdr@acm.org | 7 | ** williamsdr@acm.org |
8 | ** http://draknor.net | 8 | ** http://draknor.net |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #ifndef PROCESSINFO_H | 20 | #ifndef PROCESSINFO_H |
21 | #define PROCESSINFO_H | 21 | #define PROCESSINFO_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | 24 | ||
25 | class Detail; | 25 | class Detail; |
26 | class QComboBox; | 26 | class QComboBox; |
27 | class OListView; | 27 | class QListViewItem; |
28 | class OListViewItem; | 28 | namespace Opie {namespace Ui {class OListView;}} |
29 | namespace Opie {namespace Ui {class OListViewItem;}} | ||
29 | 30 | ||
30 | class ProcessInfo : public QWidget | 31 | class ProcessInfo : public QWidget |
31 | { | 32 | { |
32 | Q_OBJECT | 33 | Q_OBJECT |
33 | public: | 34 | public: |
34 | ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 35 | ProcessInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
35 | ~ProcessInfo(); | 36 | ~ProcessInfo(); |
36 | 37 | ||
37 | private: | 38 | private: |
38 | OListView* ProcessView; | 39 | Opie::Ui::OListView* ProcessView; |
39 | QComboBox* SignalCB; | 40 | QComboBox* SignalCB; |
40 | QPushButton* SendButton; | 41 | QPushButton* SendButton; |
41 | 42 | ||
42 | Detail *ProcessDtl; | 43 | Detail *ProcessDtl; |
43 | 44 | ||
44 | private slots: | 45 | private slots: |
45 | void updateData(); | 46 | void updateData(); |
46 | void slotSendClicked(); | 47 | void slotSendClicked(); |
47 | void viewProcess( OListViewItem * ); | 48 | void viewProcess( QListViewItem* ); |
49 | void viewProcess( Opie::Ui::OListViewItem * ); | ||
48 | }; | 50 | }; |
49 | 51 | ||
50 | #endif | 52 | #endif |
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp index fda6352..4c58999 100644 --- a/noncore/settings/sysinfo/sysinfo.cpp +++ b/noncore/settings/sysinfo/sysinfo.cpp | |||
@@ -1,73 +1,74 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ********************************************************************** | 19 | ********************************************************************** |
20 | ** | 20 | ** |
21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | 21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> |
22 | ** | 22 | ** |
23 | **********************************************************************/ | 23 | **********************************************************************/ |
24 | 24 | ||
25 | #include "memory.h" | 25 | #include "memory.h" |
26 | #include "load.h" | 26 | #include "load.h" |
27 | #include "storage.h" | 27 | #include "storage.h" |
28 | #include "processinfo.h" | 28 | #include "processinfo.h" |
29 | #include "modulesinfo.h" | 29 | #include "modulesinfo.h" |
30 | #include "benchmarkinfo.h" | 30 | #include "benchmarkinfo.h" |
31 | #include "versioninfo.h" | 31 | #include "versioninfo.h" |
32 | #include "sysinfo.h" | 32 | #include "sysinfo.h" |
33 | 33 | ||
34 | #include <opie2/otabwidget.h> | 34 | #include <opie2/otabwidget.h> |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | 38 | ||
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | 40 | ||
41 | using namespace Opie::Ui; | ||
41 | SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags ) | 42 | SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags ) |
42 | : QWidget( parent, name, WStyle_ContextHelp ) | 43 | : QWidget( parent, name, WStyle_ContextHelp ) |
43 | { | 44 | { |
44 | setIcon( Resource::loadPixmap( "system_icon" ) ); | 45 | setIcon( Resource::loadPixmap( "system_icon" ) ); |
45 | setCaption( tr("System Info") ); | 46 | setCaption( tr("System Info") ); |
46 | 47 | ||
47 | resize( 220, 180 ); | 48 | resize( 220, 180 ); |
48 | 49 | ||
49 | Config config( "qpe" ); | 50 | Config config( "qpe" ); |
50 | config.setGroup( "Appearance" ); | 51 | config.setGroup( "Appearance" ); |
51 | bool advanced = config.readBoolEntry( "Advanced", TRUE ); | 52 | bool advanced = config.readBoolEntry( "Advanced", TRUE ); |
52 | 53 | ||
53 | QVBoxLayout *lay = new QVBoxLayout( this ); | 54 | QVBoxLayout *lay = new QVBoxLayout( this ); |
54 | OTabWidget *tab = new OTabWidget( this, "tabwidget", OTabWidget::Global ); | 55 | OTabWidget *tab = new OTabWidget( this, "tabwidget", OTabWidget::Global ); |
55 | lay->addWidget( tab ); | 56 | lay->addWidget( tab ); |
56 | 57 | ||
57 | tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon", tr("Memory") ); | 58 | tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon", tr("Memory") ); |
58 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 59 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
59 | tab->addTab( new FileSysInfo( tab ), "sysinfo/storagetabicon", tr("Storage") ); | 60 | tab->addTab( new FileSysInfo( tab ), "sysinfo/storagetabicon", tr("Storage") ); |
60 | #endif | 61 | #endif |
61 | tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon", tr("CPU") ); | 62 | tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon", tr("CPU") ); |
62 | if ( advanced ) | 63 | if ( advanced ) |
63 | { | 64 | { |
64 | tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon", tr("Process") ); | 65 | tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon", tr("Process") ); |
65 | tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon", tr("Modules") ); | 66 | tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon", tr("Modules") ); |
66 | } | 67 | } |
67 | tab->addTab( new BenchmarkInfo( tab ), "sysinfo/benchmarktabicon", tr( "Benchmark" ) ); | 68 | tab->addTab( new BenchmarkInfo( tab ), "sysinfo/benchmarktabicon", tr( "Benchmark" ) ); |
68 | tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon", tr("Version") ); | 69 | tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon", tr("Version") ); |
69 | 70 | ||
70 | tab->setCurrentTab( tr( "Memory" ) ); | 71 | tab->setCurrentTab( tr( "Memory" ) ); |
71 | } | 72 | } |
72 | 73 | ||
73 | 74 | ||
diff --git a/noncore/settings/sysinfo/versioninfo.cpp b/noncore/settings/sysinfo/versioninfo.cpp index 4bebd06..6764aa6 100644 --- a/noncore/settings/sysinfo/versioninfo.cpp +++ b/noncore/settings/sysinfo/versioninfo.cpp | |||
@@ -1,172 +1,172 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "versioninfo.h" | 21 | #include "versioninfo.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odevice.h> | 24 | #include <opie2/odevice.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/version.h> | 26 | #include <qpe/version.h> |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qscrollview.h> | 32 | #include <qscrollview.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qwhatsthis.h> | 34 | #include <qwhatsthis.h> |
35 | 35 | ||
36 | using namespace Opie; | 36 | using namespace Opie::Core; |
37 | 37 | ||
38 | VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f ) | 38 | VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f ) |
39 | : QWidget( parent, name, f ) | 39 | : QWidget( parent, name, f ) |
40 | { | 40 | { |
41 | setMinimumSize( 200, 150 ); | 41 | setMinimumSize( 200, 150 ); |
42 | 42 | ||
43 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 43 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
44 | QScrollView *sv = new QScrollView( this ); | 44 | QScrollView *sv = new QScrollView( this ); |
45 | tmpvb->addWidget( sv, 0, 0 ); | 45 | tmpvb->addWidget( sv, 0, 0 ); |
46 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 46 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
47 | sv->setFrameStyle( QFrame::NoFrame ); | 47 | sv->setFrameStyle( QFrame::NoFrame ); |
48 | QWidget *container = new QWidget( sv->viewport() ); | 48 | QWidget *container = new QWidget( sv->viewport() ); |
49 | sv->addChild( container ); | 49 | sv->addChild( container ); |
50 | 50 | ||
51 | QVBoxLayout *vb = new QVBoxLayout( container, 3 ); | 51 | QVBoxLayout *vb = new QVBoxLayout( container, 3 ); |
52 | 52 | ||
53 | QString kernelVersionString; | 53 | QString kernelVersionString; |
54 | QFile file( "/proc/version" ); | 54 | QFile file( "/proc/version" ); |
55 | if ( file.open( IO_ReadOnly ) ) | 55 | if ( file.open( IO_ReadOnly ) ) |
56 | { | 56 | { |
57 | QTextStream t( &file ); | 57 | QTextStream t( &file ); |
58 | QStringList strList; | 58 | QStringList strList; |
59 | 59 | ||
60 | strList = QStringList::split( " " , t.read(), false ); | 60 | strList = QStringList::split( " " , t.read(), false ); |
61 | 61 | ||
62 | kernelVersionString = "<qt>" + tr( "<b>Linux Kernel</b><p>Version: " ); | 62 | kernelVersionString = "<qt>" + tr( "<b>Linux Kernel</b><p>Version: " ); |
63 | kernelVersionString.append( strList[2] ); | 63 | kernelVersionString.append( strList[2] ); |
64 | kernelVersionString.append( "<br>" ); | 64 | kernelVersionString.append( "<br>" ); |
65 | kernelVersionString.append( tr( "Compiled by: " ) ); | 65 | kernelVersionString.append( tr( "Compiled by: " ) ); |
66 | kernelVersionString.append( strList[3] ); | 66 | kernelVersionString.append( strList[3] ); |
67 | kernelVersionString.append("</qt>"); | 67 | kernelVersionString.append("</qt>"); |
68 | file.close(); | 68 | file.close(); |
69 | } | 69 | } |
70 | 70 | ||
71 | QString palmtopVersionString = "<qt>" + tr( "<b>Opie</b><p>Version: " ); | 71 | QString palmtopVersionString = "<qt>" + tr( "<b>Opie</b><p>Version: " ); |
72 | palmtopVersionString.append( QPE_VERSION ); | 72 | palmtopVersionString.append( QPE_VERSION ); |
73 | palmtopVersionString.append( "<br>" ); | 73 | palmtopVersionString.append( "<br>" ); |
74 | #ifdef QPE_VENDOR | 74 | #ifdef QPE_VENDOR |
75 | QString builder = QPE_VENDOR; | 75 | QString builder = QPE_VENDOR; |
76 | #else | 76 | #else |
77 | QString builder = "Unknown"; | 77 | QString builder = "Unknown"; |
78 | #endif | 78 | #endif |
79 | palmtopVersionString.append( tr( "Compiled by: " ) ); | 79 | palmtopVersionString.append( tr( "Compiled by: " ) ); |
80 | palmtopVersionString.append( builder ); | 80 | palmtopVersionString.append( builder ); |
81 | palmtopVersionString.append( "<br>" ); | 81 | palmtopVersionString.append( "<br>" ); |
82 | palmtopVersionString.append( tr( "Built on: " ) ); | 82 | palmtopVersionString.append( tr( "Built on: " ) ); |
83 | palmtopVersionString.append( __DATE__ ); | 83 | palmtopVersionString.append( __DATE__ ); |
84 | palmtopVersionString.append( "</qt>" ); | 84 | palmtopVersionString.append( "</qt>" ); |
85 | 85 | ||
86 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); | 86 | QHBoxLayout *hb1 = new QHBoxLayout( vb ); |
87 | hb1->setSpacing( 2 ); | 87 | hb1->setSpacing( 2 ); |
88 | 88 | ||
89 | QLabel *palmtopLogo = new QLabel( container ); | 89 | QLabel *palmtopLogo = new QLabel( container ); |
90 | QImage logo1 = Resource::loadImage( "logo/opielogo" ); | 90 | QImage logo1 = Resource::loadImage( "logo/opielogo" ); |
91 | logo1 = logo1.smoothScale( 50, 55 ); | 91 | logo1 = logo1.smoothScale( 50, 55 ); |
92 | QPixmap logo1Pixmap; | 92 | QPixmap logo1Pixmap; |
93 | logo1Pixmap.convertFromImage( logo1 ); | 93 | logo1Pixmap.convertFromImage( logo1 ); |
94 | palmtopLogo->setPixmap( logo1Pixmap ); | 94 | palmtopLogo->setPixmap( logo1Pixmap ); |
95 | palmtopLogo->setFixedSize( 60, 60 ); | 95 | palmtopLogo->setFixedSize( 60, 60 ); |
96 | hb1->addWidget( palmtopLogo, 0, Qt::AlignTop + Qt::AlignLeft ); | 96 | hb1->addWidget( palmtopLogo, 0, Qt::AlignTop + Qt::AlignLeft ); |
97 | 97 | ||
98 | QLabel *palmtopVersion = new QLabel( container ); | 98 | QLabel *palmtopVersion = new QLabel( container ); |
99 | palmtopVersion->setText( palmtopVersionString ); | 99 | palmtopVersion->setText( palmtopVersionString ); |
100 | hb1->addWidget( palmtopVersion, 1, Qt::AlignTop + Qt::AlignLeft ); | 100 | hb1->addWidget( palmtopVersion, 1, Qt::AlignTop + Qt::AlignLeft ); |
101 | 101 | ||
102 | 102 | ||
103 | QHBoxLayout *hb2 = new QHBoxLayout( vb ); | 103 | QHBoxLayout *hb2 = new QHBoxLayout( vb ); |
104 | hb1->setSpacing( 2 ); | 104 | hb1->setSpacing( 2 ); |
105 | 105 | ||
106 | QLabel *linuxLogo = new QLabel( container ); | 106 | QLabel *linuxLogo = new QLabel( container ); |
107 | QImage logo2 = Resource::loadImage( "logo/tux-logo" ); | 107 | QImage logo2 = Resource::loadImage( "logo/tux-logo" ); |
108 | logo2 = logo2.smoothScale( 55, 60 ); | 108 | logo2 = logo2.smoothScale( 55, 60 ); |
109 | QPixmap logo2Pixmap; | 109 | QPixmap logo2Pixmap; |
110 | logo2Pixmap.convertFromImage( logo2 ); | 110 | logo2Pixmap.convertFromImage( logo2 ); |
111 | linuxLogo->setPixmap( logo2Pixmap ); | 111 | linuxLogo->setPixmap( logo2Pixmap ); |
112 | linuxLogo->setFixedSize( 60, 60 ); | 112 | linuxLogo->setFixedSize( 60, 60 ); |
113 | hb2->addWidget( linuxLogo, 0, Qt::AlignTop + Qt::AlignLeft ); | 113 | hb2->addWidget( linuxLogo, 0, Qt::AlignTop + Qt::AlignLeft ); |
114 | 114 | ||
115 | QLabel *kernelVersion = new QLabel( container ); | 115 | QLabel *kernelVersion = new QLabel( container ); |
116 | kernelVersion->setText( kernelVersionString ); | 116 | kernelVersion->setText( kernelVersionString ); |
117 | hb2->addWidget( kernelVersion, 1, Qt::AlignTop + Qt::AlignLeft ); | 117 | hb2->addWidget( kernelVersion, 1, Qt::AlignTop + Qt::AlignLeft ); |
118 | 118 | ||
119 | 119 | ||
120 | QHBoxLayout *hb3 = new QHBoxLayout( vb ); | 120 | QHBoxLayout *hb3 = new QHBoxLayout( vb ); |
121 | hb3->setSpacing( 2 ); | 121 | hb3->setSpacing( 2 ); |
122 | 122 | ||
123 | QLabel *palmtopLogo3 = new QLabel( container ); | 123 | QLabel *palmtopLogo3 = new QLabel( container ); |
124 | 124 | ||
125 | OModel model = ODevice::inst()->model(); | 125 | OModel model = ODevice::inst()->model(); |
126 | QString modelPixmap = "sysinfo/"; | 126 | QString modelPixmap = "sysinfo/"; |
127 | if ( model == Model_Zaurus_SLC7x0 ) | 127 | if ( model == Model_Zaurus_SLC7x0 ) |
128 | modelPixmap += "zaurusc700"; | 128 | modelPixmap += "zaurusc700"; |
129 | else if ( model >= Model_Zaurus_SL5000 && model <= Model_Zaurus_SLB600 ) | 129 | else if ( model >= Model_Zaurus_SL5000 && model <= Model_Zaurus_SLB600 ) |
130 | modelPixmap += "zaurus5500"; | 130 | modelPixmap += "zaurus5500"; |
131 | else if ( model >= Model_iPAQ_H31xx && model <= Model_iPAQ_H5xxx ) | 131 | else if ( model >= Model_iPAQ_H31xx && model <= Model_iPAQ_H5xxx ) |
132 | modelPixmap += "ipaq3600"; | 132 | modelPixmap += "ipaq3600"; |
133 | else if ( model >= Model_SIMpad_CL4 && model <= Model_SIMpad_TSinus ) | 133 | else if ( model >= Model_SIMpad_CL4 && model <= Model_SIMpad_TSinus ) |
134 | modelPixmap += "simpad"; | 134 | modelPixmap += "simpad"; |
135 | else | 135 | else |
136 | modelPixmap += "pda"; | 136 | modelPixmap += "pda"; |
137 | 137 | ||
138 | QImage logo3 = Resource::loadImage( modelPixmap ); | 138 | QImage logo3 = Resource::loadImage( modelPixmap ); |
139 | 139 | ||
140 | int width = logo3.width(); | 140 | int width = logo3.width(); |
141 | int height = logo3.height(); | 141 | int height = logo3.height(); |
142 | float aspect = float( height ) / width; | 142 | float aspect = float( height ) / width; |
143 | logo3 = logo3.smoothScale( 50, 50.0 * aspect ); | 143 | logo3 = logo3.smoothScale( 50, 50.0 * aspect ); |
144 | 144 | ||
145 | QPixmap logo3Pixmap; | 145 | QPixmap logo3Pixmap; |
146 | logo3Pixmap.convertFromImage( logo3 ); | 146 | logo3Pixmap.convertFromImage( logo3 ); |
147 | palmtopLogo3->setPixmap( logo3Pixmap ); | 147 | palmtopLogo3->setPixmap( logo3Pixmap ); |
148 | palmtopLogo3->setFixedSize( 60, 100 ); | 148 | palmtopLogo3->setFixedSize( 60, 100 ); |
149 | hb3->addWidget( palmtopLogo3, 0, Qt::AlignTop + Qt::AlignLeft ); | 149 | hb3->addWidget( palmtopLogo3, 0, Qt::AlignTop + Qt::AlignLeft ); |
150 | 150 | ||
151 | QString systemString = "<qt><b>"; | 151 | QString systemString = "<qt><b>"; |
152 | systemString.append( ODevice::inst()->systemString() ); | 152 | systemString.append( ODevice::inst()->systemString() ); |
153 | systemString.append( "</b>" ); | 153 | systemString.append( "</b>" ); |
154 | systemString.append( tr( "<p>Version: " ) ); | 154 | systemString.append( tr( "<p>Version: " ) ); |
155 | systemString.append( ODevice::inst()->systemVersionString() ); | 155 | systemString.append( ODevice::inst()->systemVersionString() ); |
156 | systemString.append( tr( "<br>Model: " ) ); | 156 | systemString.append( tr( "<br>Model: " ) ); |
157 | systemString.append( ODevice::inst()->modelString() ); | 157 | systemString.append( ODevice::inst()->modelString() ); |
158 | systemString.append( tr( "<br>Vendor: " ) ); | 158 | systemString.append( tr( "<br>Vendor: " ) ); |
159 | systemString.append( ODevice::inst()->vendorString() ); | 159 | systemString.append( ODevice::inst()->vendorString() ); |
160 | systemString.append("</qt>"); | 160 | systemString.append("</qt>"); |
161 | 161 | ||
162 | QLabel *systemVersion = new QLabel( container ); | 162 | QLabel *systemVersion = new QLabel( container ); |
163 | systemVersion->setText( systemString ); | 163 | systemVersion->setText( systemString ); |
164 | hb3->addWidget( systemVersion, 1, Qt::AlignTop + Qt::AlignLeft ); | 164 | hb3->addWidget( systemVersion, 1, Qt::AlignTop + Qt::AlignLeft ); |
165 | 165 | ||
166 | QWhatsThis::add( this, tr( "This page shows the current versions of Opie, the Linux kernel and distribution running on this handheld device." ) ); | 166 | QWhatsThis::add( this, tr( "This page shows the current versions of Opie, the Linux kernel and distribution running on this handheld device." ) ); |
167 | } | 167 | } |
168 | 168 | ||
169 | VersionInfo::~VersionInfo() | 169 | VersionInfo::~VersionInfo() |
170 | { | 170 | { |
171 | } | 171 | } |
172 | 172 | ||
diff --git a/noncore/settings/usermanager/main.cpp b/noncore/settings/usermanager/main.cpp index d7147d1..807d528 100644 --- a/noncore/settings/usermanager/main.cpp +++ b/noncore/settings/usermanager/main.cpp | |||
@@ -1,14 +1,15 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | #include "usermanager.h" | 10 | #include "usermanager.h" |
11 | 11 | ||
12 | #include <opie2/oapplicationfactory.h> | 12 | #include <opie2/oapplicationfactory.h> |
13 | 13 | ||
14 | using namespace Opie::Core; | ||
14 | OPIE_EXPORT_APP( OApplicationFactory<UserConfig> ) | 15 | OPIE_EXPORT_APP( OApplicationFactory<UserConfig> ) |
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index eb9a289..5854fe0 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -1,228 +1,229 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | #include "userdialog.h" | 10 | #include "userdialog.h" |
11 | #include "passwd.h" | 11 | #include "passwd.h" |
12 | 12 | ||
13 | /* OPIE */ | 13 | /* OPIE */ |
14 | #include <opie2/odevice.h> | 14 | #include <opie2/odevice.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | 16 | ||
17 | /* QT */ | 17 | /* QT */ |
18 | #include <qlayout.h> | 18 | #include <qlayout.h> |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | 22 | ||
23 | /* STD */ | 23 | /* STD */ |
24 | #include <sys/types.h> | 24 | #include <sys/types.h> |
25 | #include <sys/wait.h> | 25 | #include <sys/wait.h> |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #include <signal.h> | 27 | #include <signal.h> |
28 | 28 | ||
29 | 29 | ||
30 | using namespace Opie; | 30 | using namespace Opie::Core; |
31 | 31 | ||
32 | 32 | ||
33 | /** | 33 | /** |
34 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. | 34 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. |
35 | * | 35 | * |
36 | */ | 36 | */ |
37 | using namespace Opie::Ui; | ||
37 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) | 38 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) |
38 | { | 39 | { |
39 | vm=viewmode; | 40 | vm=viewmode; |
40 | QVBoxLayout *layout = new QVBoxLayout(this); | 41 | QVBoxLayout *layout = new QVBoxLayout(this); |
41 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 42 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
42 | layout->addWidget(myTabWidget); | 43 | layout->addWidget(myTabWidget); |
43 | setupTab1(); | 44 | setupTab1(); |
44 | setupTab2(); | 45 | setupTab2(); |
45 | 46 | ||
46 | accounts->groupStringList.sort(); | 47 | accounts->groupStringList.sort(); |
47 | // And also fill the listview & the combobox with all available groups. | 48 | // And also fill the listview & the combobox with all available groups. |
48 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) | 49 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) |
49 | { | 50 | { |
50 | accounts->splitGroupEntry(*it); | 51 | accounts->splitGroupEntry(*it); |
51 | if(accounts->gr_name.find(QRegExp("^#"),0)) | 52 | if(accounts->gr_name.find(QRegExp("^#"),0)) |
52 | { // Skip commented lines. | 53 | { // Skip commented lines. |
53 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); | 54 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); |
54 | groupComboBox->insertItem(accounts->gr_name); | 55 | groupComboBox->insertItem(accounts->gr_name); |
55 | } | 56 | } |
56 | } | 57 | } |
57 | QPEApplication::showDialog( this ); | 58 | QPEApplication::showDialog( this ); |
58 | } | 59 | } |
59 | 60 | ||
60 | /** | 61 | /** |
61 | * Empty destructor. | 62 | * Empty destructor. |
62 | * | 63 | * |
63 | */ | 64 | */ |
64 | UserDialog::~UserDialog() | 65 | UserDialog::~UserDialog() |
65 | {} | 66 | {} |
66 | 67 | ||
67 | /** | 68 | /** |
68 | * Creates the first tab, all userinfo is here. | 69 | * Creates the first tab, all userinfo is here. |
69 | * | 70 | * |
70 | */ | 71 | */ |
71 | void UserDialog::setupTab1() | 72 | void UserDialog::setupTab1() |
72 | { | 73 | { |
73 | QPixmap mypixmap; | 74 | QPixmap mypixmap; |
74 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); | 75 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); |
75 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 76 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
76 | layout->setMargin(5); | 77 | layout->setMargin(5); |
77 | 78 | ||
78 | // Picture | 79 | // Picture |
79 | picturePushButton = new QPushButton(tabpage,"Label"); | 80 | picturePushButton = new QPushButton(tabpage,"Label"); |
80 | picturePushButton->setMinimumSize(48,48); | 81 | picturePushButton->setMinimumSize(48,48); |
81 | picturePushButton->setMaximumSize(48,48); | 82 | picturePushButton->setMaximumSize(48,48); |
82 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon")); // Load default usericon. | 83 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon")); // Load default usericon. |
83 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector. | 84 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector. |
84 | 85 | ||
85 | // Login | 86 | // Login |
86 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); | 87 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); |
87 | loginLabel->setText("Login: "); | 88 | loginLabel->setText("Login: "); |
88 | loginLineEdit=new QLineEdit(tabpage,"Login: "); | 89 | loginLineEdit=new QLineEdit(tabpage,"Login: "); |
89 | 90 | ||
90 | // UID | 91 | // UID |
91 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); | 92 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); |
92 | uidLabel->setText("UserID: "); | 93 | uidLabel->setText("UserID: "); |
93 | uidLineEdit=new QLineEdit(tabpage,"uid: "); | 94 | uidLineEdit=new QLineEdit(tabpage,"uid: "); |
94 | uidLineEdit->setEnabled(false); | 95 | uidLineEdit->setEnabled(false); |
95 | 96 | ||
96 | // Username (gecos) | 97 | // Username (gecos) |
97 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); | 98 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); |
98 | gecosLabel->setText("Username: "); | 99 | gecosLabel->setText("Username: "); |
99 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); | 100 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); |
100 | 101 | ||
101 | // Password | 102 | // Password |
102 | QLabel *passwordLabel=new QLabel(tabpage,"password"); | 103 | QLabel *passwordLabel=new QLabel(tabpage,"password"); |
103 | passwordLabel->setText("Password: "); | 104 | passwordLabel->setText("Password: "); |
104 | passwordLineEdit=new QLineEdit(tabpage,"password"); | 105 | passwordLineEdit=new QLineEdit(tabpage,"password"); |
105 | passwordLineEdit->setEchoMode(QLineEdit::Password); | 106 | passwordLineEdit->setEchoMode(QLineEdit::Password); |
106 | 107 | ||
107 | // Shell | 108 | // Shell |
108 | QLabel *shellLabel=new QLabel(tabpage,"shell"); | 109 | QLabel *shellLabel=new QLabel(tabpage,"shell"); |
109 | shellLabel->setText("Shell: "); | 110 | shellLabel->setText("Shell: "); |
110 | shellComboBox=new QComboBox(tabpage,"shell"); | 111 | shellComboBox=new QComboBox(tabpage,"shell"); |
111 | shellComboBox->setEditable(true); | 112 | shellComboBox->setEditable(true); |
112 | shellComboBox->insertItem("/bin/sh"); | 113 | shellComboBox->insertItem("/bin/sh"); |
113 | shellComboBox->insertItem("/bin/ash"); | 114 | shellComboBox->insertItem("/bin/ash"); |
114 | shellComboBox->insertItem("/bin/false"); | 115 | shellComboBox->insertItem("/bin/false"); |
115 | 116 | ||
116 | // Primary Group | 117 | // Primary Group |
117 | QLabel *groupLabel=new QLabel(tabpage,"group"); | 118 | QLabel *groupLabel=new QLabel(tabpage,"group"); |
118 | groupLabel->setText("Primary group: "); | 119 | groupLabel->setText("Primary group: "); |
119 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 120 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); |
120 | 121 | ||
121 | if(vm==VIEWMODE_NEW) | 122 | if(vm==VIEWMODE_NEW) |
122 | { | 123 | { |
123 | // Copy /etc/skel | 124 | // Copy /etc/skel |
124 | skelLabel=new QLabel(tabpage,"skel"); | 125 | skelLabel=new QLabel(tabpage,"skel"); |
125 | skelLabel->setText("Copy /etc/skel: "); | 126 | skelLabel->setText("Copy /etc/skel: "); |
126 | skelCheckBox=new QCheckBox(tabpage); | 127 | skelCheckBox=new QCheckBox(tabpage); |
127 | skelCheckBox->setChecked(true); | 128 | skelCheckBox->setChecked(true); |
128 | } | 129 | } |
129 | 130 | ||
130 | // Widget layout | 131 | // Widget layout |
131 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 132 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
132 | layout->addWidget(picturePushButton); | 133 | layout->addWidget(picturePushButton); |
133 | layout->addSpacing(5); | 134 | layout->addSpacing(5); |
134 | layout->addLayout(hlayout); | 135 | layout->addLayout(hlayout); |
135 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); | 136 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); |
136 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); | 137 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); |
137 | // First column, labels | 138 | // First column, labels |
138 | vlayout1->addWidget(loginLabel); | 139 | vlayout1->addWidget(loginLabel); |
139 | vlayout1->addSpacing(5); | 140 | vlayout1->addSpacing(5); |
140 | vlayout1->addWidget(uidLabel); | 141 | vlayout1->addWidget(uidLabel); |
141 | vlayout1->addSpacing(5); | 142 | vlayout1->addSpacing(5); |
142 | vlayout1->addWidget(gecosLabel); | 143 | vlayout1->addWidget(gecosLabel); |
143 | vlayout1->addSpacing(5); | 144 | vlayout1->addSpacing(5); |
144 | vlayout1->addWidget(passwordLabel); | 145 | vlayout1->addWidget(passwordLabel); |
145 | vlayout1->addSpacing(5); | 146 | vlayout1->addSpacing(5); |
146 | vlayout1->addWidget(shellLabel); | 147 | vlayout1->addWidget(shellLabel); |
147 | vlayout1->addSpacing(5); | 148 | vlayout1->addSpacing(5); |
148 | vlayout1->addWidget(groupLabel); | 149 | vlayout1->addWidget(groupLabel); |
149 | if(vm==VIEWMODE_NEW) | 150 | if(vm==VIEWMODE_NEW) |
150 | { | 151 | { |
151 | vlayout1->addSpacing(5); | 152 | vlayout1->addSpacing(5); |
152 | vlayout1->addWidget(skelLabel); | 153 | vlayout1->addWidget(skelLabel); |
153 | } | 154 | } |
154 | // Second column, data | 155 | // Second column, data |
155 | vlayout2->addWidget(loginLineEdit); | 156 | vlayout2->addWidget(loginLineEdit); |
156 | vlayout2->addSpacing(5); | 157 | vlayout2->addSpacing(5); |
157 | vlayout2->addWidget(uidLineEdit); | 158 | vlayout2->addWidget(uidLineEdit); |
158 | vlayout2->addSpacing(5); | 159 | vlayout2->addSpacing(5); |
159 | vlayout2->addWidget(gecosLineEdit); | 160 | vlayout2->addWidget(gecosLineEdit); |
160 | vlayout2->addSpacing(5); | 161 | vlayout2->addSpacing(5); |
161 | vlayout2->addWidget(passwordLineEdit); | 162 | vlayout2->addWidget(passwordLineEdit); |
162 | vlayout2->addSpacing(5); | 163 | vlayout2->addSpacing(5); |
163 | vlayout2->addWidget(shellComboBox); | 164 | vlayout2->addWidget(shellComboBox); |
164 | vlayout2->addSpacing(5); | 165 | vlayout2->addSpacing(5); |
165 | vlayout2->addWidget(groupComboBox); | 166 | vlayout2->addWidget(groupComboBox); |
166 | if(vm==VIEWMODE_NEW) | 167 | if(vm==VIEWMODE_NEW) |
167 | { | 168 | { |
168 | vlayout2->addSpacing(5); | 169 | vlayout2->addSpacing(5); |
169 | vlayout2->addWidget(skelCheckBox); | 170 | vlayout2->addWidget(skelCheckBox); |
170 | } | 171 | } |
171 | hlayout->addLayout(vlayout1); | 172 | hlayout->addLayout(vlayout1); |
172 | hlayout->addLayout(vlayout2); | 173 | hlayout->addLayout(vlayout2); |
173 | 174 | ||
174 | myTabWidget->addTab(tabpage,"User Info"); | 175 | myTabWidget->addTab(tabpage,"User Info"); |
175 | } | 176 | } |
176 | 177 | ||
177 | /** | 178 | /** |
178 | * Creates the second tab containing additional groups for the user. | 179 | * Creates the second tab containing additional groups for the user. |
179 | * | 180 | * |
180 | */ | 181 | */ |
181 | void UserDialog::setupTab2() | 182 | void UserDialog::setupTab2() |
182 | { | 183 | { |
183 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); | 184 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); |
184 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 185 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
185 | layout->setMargin(5); | 186 | layout->setMargin(5); |
186 | 187 | ||
187 | // Additional groups | 188 | // Additional groups |
188 | groupsListView=new QListView(tabpage,"groups"); | 189 | groupsListView=new QListView(tabpage,"groups"); |
189 | groupsListView->addColumn("Additional groups"); | 190 | groupsListView->addColumn("Additional groups"); |
190 | groupsListView->setColumnWidthMode(0,QListView::Maximum); | 191 | groupsListView->setColumnWidthMode(0,QListView::Maximum); |
191 | groupsListView->setMultiSelection(false); | 192 | groupsListView->setMultiSelection(false); |
192 | groupsListView->setAllColumnsShowFocus(false); | 193 | groupsListView->setAllColumnsShowFocus(false); |
193 | 194 | ||
194 | layout->addSpacing(5); | 195 | layout->addSpacing(5); |
195 | // Grouplist | 196 | // Grouplist |
196 | layout->addWidget(groupsListView); | 197 | layout->addWidget(groupsListView); |
197 | 198 | ||
198 | myTabWidget->addTab(tabpage,"User Groups"); | 199 | myTabWidget->addTab(tabpage,"User Groups"); |
199 | } | 200 | } |
200 | 201 | ||
201 | /** | 202 | /** |
202 | * Static function that creates the userinfo dialog. | 203 | * Static function that creates the userinfo dialog. |
203 | * The user will be prompted to add a user. | 204 | * The user will be prompted to add a user. |
204 | * | 205 | * |
205 | * @param uid This is a suggested available UID. | 206 | * @param uid This is a suggested available UID. |
206 | * @param gid This is a suggested available GID. | 207 | * @param gid This is a suggested available GID. |
207 | * | 208 | * |
208 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. | 209 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. |
209 | * | 210 | * |
210 | */ | 211 | */ |
211 | bool UserDialog::addUser(int uid, int gid) | 212 | bool UserDialog::addUser(int uid, int gid) |
212 | { | 213 | { |
213 | QCheckListItem *temp; | 214 | QCheckListItem *temp; |
214 | QFile ozTest; | 215 | QFile ozTest; |
215 | int oz=false; | 216 | int oz=false; |
216 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; | 217 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; |
217 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. | 218 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. |
218 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); | 219 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); |
219 | adduserDialog->setCaption(tr("Add User")); | 220 | adduserDialog->setCaption(tr("Add User")); |
220 | adduserDialog->userID=uid; // Set next available UID as default uid. | 221 | adduserDialog->userID=uid; // Set next available UID as default uid. |
221 | adduserDialog->groupID=gid; // Set next available GID as default gid. | 222 | adduserDialog->groupID=gid; // Set next available GID as default gid. |
222 | // Insert default group into groupComboBox | 223 | // Insert default group into groupComboBox |
223 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 224 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
224 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 225 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
225 | // If we're running on OZ, add new users to some default groups. | 226 | // If we're running on OZ, add new users to some default groups. |
226 | if(oz) | 227 | if(oz) |
227 | { | 228 | { |
228 | QListViewItemIterator iter( adduserDialog->groupsListView ); | 229 | QListViewItemIterator iter( adduserDialog->groupsListView ); |