27 files changed, 107 insertions, 107 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index b39203b..8ae87fe 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -1,874 +1,874 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
4 | =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> | 4 | =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 5 | .=l. Copyright (c) 2002 Robert Griebl <sandman@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 "appearance.h" | 30 | #include "appearance.h" |
31 | #include "editScheme.h" | 31 | #include "editScheme.h" |
32 | #include "stylelistitem.h" | 32 | #include "stylelistitem.h" |
33 | #include "decolistitem.h" | 33 | #include "decolistitem.h" |
34 | #include "colorlistitem.h" | 34 | #include "colorlistitem.h" |
35 | #include "exceptlistitem.h" | 35 | #include "exceptlistitem.h" |
36 | #include "sample.h" | 36 | #include "sample.h" |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/odevice.h> | 39 | #include <opie2/odevice.h> |
40 | #include <opie2/ofiledialog.h> | 40 | #include <opie2/ofiledialog.h> |
41 | #include <opie2/otabwidget.h> | 41 | #include <opie2/otabwidget.h> |
42 | 42 | ||
43 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
44 | #include <qpe/global.h> | 44 | #include <qpe/global.h> |
45 | #include <qpe/qpeapplication.h> | 45 | #include <qpe/qpeapplication.h> |
46 | #include <qpe/qpemessagebox.h> | 46 | #include <qpe/qpemessagebox.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
48 | #include <qpe/qpestyle.h> | 48 | #include <qpe/qpestyle.h> |
49 | #include <qpe/lightstyle.h> | 49 | #include <qpe/lightstyle.h> |
50 | #include <qpe/styleinterface.h> | 50 | #include <qpe/styleinterface.h> |
51 | 51 | ||
52 | /* QT */ | 52 | /* QT */ |
53 | #include <qbuttongroup.h> | 53 | #include <qbuttongroup.h> |
54 | #include <qcheckbox.h> | 54 | #include <qcheckbox.h> |
55 | #include <qcombobox.h> | 55 | #include <qcombobox.h> |
56 | #include <qdialog.h> | 56 | #include <qdialog.h> |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | #include <qlabel.h> | 58 | #include <qlabel.h> |
59 | #include <qlayout.h> | 59 | #include <qlayout.h> |
60 | #include <qlineedit.h> | 60 | #include <qlineedit.h> |
61 | #include <qlistbox.h> | 61 | #include <qlistbox.h> |
62 | #include <qmessagebox.h> | 62 | #include <qmessagebox.h> |
63 | #include <qpushbutton.h> | 63 | #include <qpushbutton.h> |
64 | #include <qradiobutton.h> | 64 | #include <qradiobutton.h> |
65 | #if QT_VERSION >= 300 | 65 | #if QT_VERSION >= 300 |
66 | #include <qstylefactory.h> | 66 | #include <qstylefactory.h> |
67 | #endif | 67 | #endif |
68 | #include <qtoolbutton.h> | 68 | #include <qtoolbutton.h> |
69 | #include <qwindowsstyle.h> | 69 | #include <qwindowsstyle.h> |
70 | #include <qlistview.h> | 70 | #include <qlistview.h> |
71 | #include <qheader.h> | 71 | #include <qheader.h> |
72 | #include <qvbox.h> | 72 | #include <qvbox.h> |
73 | #include <qwhatsthis.h> | 73 | #include <qwhatsthis.h> |
74 | 74 | ||
75 | using namespace Opie; | 75 | using namespace Opie; |
76 | 76 | ||
77 | 77 | ||
78 | class DefaultWindowDecoration : public WindowDecorationInterface | 78 | class DefaultWindowDecoration : public WindowDecorationInterface |
79 | { | 79 | { |
80 | public: | 80 | public: |
81 | DefaultWindowDecoration() : ref(0) {} | 81 | DefaultWindowDecoration() : ref(0) {} |
82 | QString name() const | 82 | QString name() const |
83 | { | 83 | { |
84 | return "Default"; | 84 | return "Default"; |
85 | } | 85 | } |
86 | QPixmap icon() const | 86 | QPixmap icon() const |
87 | { | 87 | { |
88 | return QPixmap(); | 88 | return QPixmap(); |
89 | } | 89 | } |
90 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 90 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
91 | { | 91 | { |
92 | *iface = 0; | 92 | *iface = 0; |
93 | if ( uuid == IID_QUnknown ) | 93 | if ( uuid == IID_QUnknown ) |
94 | *iface = this; | 94 | *iface = this; |
95 | else if ( uuid == IID_WindowDecoration ) | 95 | else if ( uuid == IID_WindowDecoration ) |
96 | *iface = this; | 96 | *iface = this; |
97 | 97 | ||
98 | if ( *iface ) | 98 | if ( *iface ) |
99 | (*iface)->addRef(); | 99 | (*iface)->addRef(); |
100 | return QS_OK; | 100 | return QS_OK; |
101 | } | 101 | } |
102 | Q_REFCOUNT | 102 | Q_REFCOUNT |
103 | 103 | ||
104 | private: | 104 | private: |
105 | ulong ref; | 105 | ulong ref; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | 113 | ||
114 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) | 114 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) |
115 | { | 115 | { |
116 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 116 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
117 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 117 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
118 | 118 | ||
119 | m_style_list = new QListBox( tab, "m_style_list" ); | 119 | m_style_list = new QListBox( tab, "m_style_list" ); |
120 | vertLayout->addWidget( m_style_list ); | 120 | vertLayout->addWidget( m_style_list ); |
121 | QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); | 121 | QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); |
122 | 122 | ||
123 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 123 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
124 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 124 | connect ( m_style_settings, SIGNAL( clicked()), this, SLOT( styleSettingsClicked())); |
125 | vertLayout-> addWidget ( m_style_settings ); | 125 | vertLayout-> addWidget ( m_style_settings ); |
126 | QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); | 126 | QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); |
127 | 127 | ||
128 | QString s = cfg. readEntry ( "Style", "Light" ); | 128 | QString s = cfg. readEntry ( "Style", "Light" ); |
129 | 129 | ||
130 | 130 | ||
131 | #if QT_VERSION >= 300 | 131 | #if QT_VERSION >= 300 |
132 | m_style_list->insertStringList(QStyleFactory::styles()); | 132 | m_style_list->insertStringList(QStyleFactory::styles()); |
133 | #else | 133 | #else |
134 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 134 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
135 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); | 135 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); |
136 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); | 136 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); |
137 | #endif | 137 | #endif |
138 | 138 | ||
139 | { | 139 | { |
140 | QString path = QPEApplication::qpeDir ( ); | 140 | QString path = QPEApplication::qpeDir ( ); |
141 | path.append( "/plugins/styles/" ); | 141 | path.append( "/plugins/styles/" ); |
142 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 142 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
143 | 143 | ||
144 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 144 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
145 | { | 145 | { |
146 | QString libstr = path; | 146 | QString libstr = path; |
147 | libstr.append( "/" ); | 147 | libstr.append( "/" ); |
148 | libstr.append( *it ); | 148 | libstr.append( *it ); |
149 | QLibrary *lib = new QLibrary ( libstr ); | 149 | QLibrary *lib = new QLibrary ( libstr ); |
150 | StyleInterface *iface; | 150 | StyleInterface *iface; |
151 | 151 | ||
152 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) | 152 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) |
153 | { | 153 | { |
154 | StyleListItem *slit = new StyleListItem ( lib, iface ); | 154 | StyleListItem *slit = new StyleListItem ( lib, iface ); |
155 | m_style_list-> insertItem ( slit ); | 155 | m_style_list-> insertItem ( slit ); |
156 | 156 | ||
157 | if ( slit-> key ( ) == s ) | 157 | if ( slit-> key ( ) == s ) |
158 | m_style_list-> setCurrentItem ( slit ); | 158 | m_style_list-> setCurrentItem ( slit ); |
159 | } | 159 | } |
160 | else | 160 | else |
161 | delete lib; | 161 | delete lib; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | m_original_style = m_style_list-> currentItem ( ); | 165 | m_original_style = m_style_list-> currentItem ( ); |
166 | styleClicked ( m_original_style ); | 166 | styleClicked ( m_original_style ); |
167 | 167 | ||
168 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 168 | connect( m_style_list, SIGNAL( highlighted(int) ), this, SLOT( styleClicked(int) ) ); |
169 | 169 | ||
170 | return tab; | 170 | return tab; |
171 | } | 171 | } |
172 | 172 | ||
173 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) | 173 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) |
174 | { | 174 | { |
175 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 175 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
176 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 176 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
177 | 177 | ||
178 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 178 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
179 | vertLayout->addWidget( m_deco_list ); | 179 | vertLayout->addWidget( m_deco_list ); |
180 | QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); | 180 | QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); |
181 | 181 | ||
182 | QString s = cfg. readEntry ( "Decoration", "libflat.so" ); | 182 | QString s = cfg. readEntry ( "Decoration", "libflat.so" ); |
183 | 183 | ||
184 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); | 184 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); |
185 | 185 | ||
186 | { | 186 | { |
187 | QString path = QPEApplication::qpeDir(); | 187 | QString path = QPEApplication::qpeDir(); |
188 | path.append( "/plugins/decorations/" ); | 188 | path.append( "/plugins/decorations/" ); |
189 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 189 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
190 | 190 | ||
191 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 191 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
192 | { | 192 | { |
193 | QString libstr = path; | 193 | QString libstr = path; |
194 | libstr.append( "/" ); | 194 | libstr.append( "/" ); |
195 | libstr.append( *it ); | 195 | libstr.append( *it ); |
196 | QLibrary *lib = new QLibrary ( libstr ); | 196 | QLibrary *lib = new QLibrary ( libstr ); |
197 | WindowDecorationInterface *iface; | 197 | WindowDecorationInterface *iface; |
198 | 198 | ||
199 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) | 199 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) |
200 | { | 200 | { |
201 | DecoListItem *dlit = new DecoListItem ( lib, iface ); | 201 | DecoListItem *dlit = new DecoListItem ( lib, iface ); |
202 | m_deco_list-> insertItem ( dlit ); | 202 | m_deco_list-> insertItem ( dlit ); |
203 | 203 | ||
204 | if ( dlit-> key ( ) == s ) | 204 | if ( dlit-> key ( ) == s ) |
205 | m_deco_list-> setCurrentItem ( dlit ); | 205 | m_deco_list-> setCurrentItem ( dlit ); |
206 | } | 206 | } |
207 | else | 207 | else |
208 | delete lib; | 208 | delete lib; |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | m_original_deco = m_deco_list-> currentItem ( ); | 212 | m_original_deco = m_deco_list-> currentItem ( ); |
213 | if ( m_deco_list-> currentItem ( ) < 0 ) | 213 | if ( m_deco_list-> currentItem ( ) < 0 ) |
214 | m_deco_list-> setCurrentItem ( 0 ); | 214 | m_deco_list-> setCurrentItem ( 0 ); |
215 | decoClicked ( m_original_deco ); | 215 | decoClicked ( m_original_deco ); |
216 | 216 | ||
217 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 217 | connect( m_deco_list, SIGNAL( highlighted(int) ), this, SLOT( decoClicked(int) ) ); |
218 | 218 | ||
219 | return tab; | 219 | return tab; |
220 | } | 220 | } |
221 | 221 | ||
222 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) | 222 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) |
223 | { | 223 | { |
224 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); | 224 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); |
225 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); | 225 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); |
226 | int size = cfg. readNumEntry ( "FontSize", 10 ); | 226 | int size = cfg. readNumEntry ( "FontSize", 10 ); |
227 | 227 | ||
228 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); | 228 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); |
229 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 229 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
230 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); | 230 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); |
231 | 231 | ||
232 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 232 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), |
233 | this, SLOT( fontClicked ( const QFont & ))); | 233 | this, SLOT( fontClicked(const QFont&))); |
234 | 234 | ||
235 | return m_fontselect; | 235 | return m_fontselect; |
236 | } | 236 | } |
237 | 237 | ||
238 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) | 238 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) |
239 | { | 239 | { |
240 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 240 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
241 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); | 241 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); |
242 | gridLayout->setRowStretch ( 3, 10 ); | 242 | gridLayout->setRowStretch ( 3, 10 ); |
243 | 243 | ||
244 | m_color_list = new QListBox ( tab ); | 244 | m_color_list = new QListBox ( tab ); |
245 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 245 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
246 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 246 | connect( m_color_list, SIGNAL( highlighted(int) ), this, SLOT( colorClicked(int) ) ); |
247 | QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); | 247 | QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); |
248 | 248 | ||
249 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); | 249 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); |
250 | 250 | ||
251 | QString path = QPEApplication::qpeDir ( ); | 251 | QString path = QPEApplication::qpeDir ( ); |
252 | path.append( "/etc/colors/" ); | 252 | path.append( "/etc/colors/" ); |
253 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 253 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
254 | 254 | ||
255 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 255 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
256 | { | 256 | { |
257 | QString name = (*it). left ((*it). find ( ".scheme" )); | 257 | QString name = (*it). left ((*it). find ( ".scheme" )); |
258 | QString pathstr = path; | 258 | QString pathstr = path; |
259 | pathstr.append( *it ); | 259 | pathstr.append( *it ); |
260 | Config config ( pathstr, Config::File ); | 260 | Config config ( pathstr, Config::File ); |
261 | config. setGroup ( "Colors" ); | 261 | config. setGroup ( "Colors" ); |
262 | 262 | ||
263 | m_color_list-> insertItem ( new ColorListItem ( name, config )); | 263 | m_color_list-> insertItem ( new ColorListItem ( name, config )); |
264 | } | 264 | } |
265 | 265 | ||
266 | m_color_list-> setCurrentItem ( 0 ); | 266 | m_color_list-> setCurrentItem ( 0 ); |
267 | 267 | ||
268 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 268 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
269 | tempButton->setText( tr( "Edit..." ) ); | 269 | tempButton->setText( tr( "Edit..." ) ); |
270 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 270 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
271 | gridLayout->addWidget( tempButton, 0, 1 ); | 271 | gridLayout->addWidget( tempButton, 0, 1 ); |
272 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); | 272 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); |
273 | 273 | ||
274 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 274 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
275 | tempButton->setText( tr( "Delete" ) ); | 275 | tempButton->setText( tr( "Delete" ) ); |
276 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 276 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
277 | gridLayout->addWidget( tempButton, 1, 1 ); | 277 | gridLayout->addWidget( tempButton, 1, 1 ); |
278 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); | 278 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); |
279 | 279 | ||
280 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 280 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
281 | tempButton->setText( tr( "Save" ) ); | 281 | tempButton->setText( tr( "Save" ) ); |
282 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 282 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
283 | gridLayout->addWidget( tempButton, 2, 1 ); | 283 | gridLayout->addWidget( tempButton, 2, 1 ); |
284 | QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); | 284 | QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); |
285 | 285 | ||
286 | return tab; | 286 | return tab; |
287 | } | 287 | } |
288 | 288 | ||
289 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) | 289 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) |
290 | { | 290 | { |
291 | QWidget *tab = new QWidget ( parent ); | 291 | QWidget *tab = new QWidget ( parent ); |
292 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 292 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
293 | 293 | ||
294 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 294 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
295 | 295 | ||
296 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); | 296 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); |
297 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); | 297 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); |
298 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); | 298 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); |
299 | QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); | 299 | QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); |
300 | 300 | ||
301 | QLabel *l = new QLabel ( tab ); | 301 | QLabel *l = new QLabel ( tab ); |
302 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); | 302 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); |
303 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); | 303 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); |
304 | QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); | 304 | QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); |
305 | 305 | ||
306 | m_except = new QListView ( tab ); | 306 | m_except = new QListView ( tab ); |
307 | m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); | 307 | m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); |
308 | m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); | 308 | m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); |
309 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); | 309 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); |
310 | m_except-> addColumn ( tr( "Binary file(s)" )); | 310 | m_except-> addColumn ( tr( "Binary file(s)" )); |
311 | m_except-> setColumnAlignment ( 0, AlignCenter ); | 311 | m_except-> setColumnAlignment ( 0, AlignCenter ); |
312 | m_except-> setColumnAlignment ( 1, AlignCenter ); | 312 | m_except-> setColumnAlignment ( 1, AlignCenter ); |
313 | m_except-> setColumnAlignment ( 2, AlignCenter ); | 313 | m_except-> setColumnAlignment ( 2, AlignCenter ); |
314 | m_except-> setAllColumnsShowFocus ( true ); | 314 | m_except-> setAllColumnsShowFocus ( true ); |
315 | m_except-> setMinimumHeight ( 30 ); | 315 | m_except-> setMinimumHeight ( 30 ); |
316 | m_except-> header ( )-> setClickEnabled ( false ); | 316 | m_except-> header ( )-> setClickEnabled ( false ); |
317 | m_except-> header ( )-> setResizeEnabled ( false ); | 317 | m_except-> header ( )-> setResizeEnabled ( false ); |
318 | m_except-> header ( )-> setMovingEnabled ( false ); | 318 | m_except-> header ( )-> setMovingEnabled ( false ); |
319 | m_except-> setSorting ( -1 ); | 319 | m_except-> setSorting ( -1 ); |
320 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); | 320 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); |
321 | QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); | 321 | QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); |
322 | 322 | ||
323 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); | 323 | connect ( m_except, SIGNAL( clicked(QListViewItem*,const QPoint&,int)), this, SLOT( clickedExcept(QListViewItem*,const QPoint&,int))); |
324 | 324 | ||
325 | QToolButton *tb = new QToolButton ( tab ); | 325 | QToolButton *tb = new QToolButton ( tab ); |
326 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); | 326 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); |
327 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 327 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
328 | lay-> addWidget ( tb, 2, 1 ); | 328 | lay-> addWidget ( tb, 2, 1 ); |
329 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); | 329 | connect ( tb, SIGNAL( clicked()), this, SLOT( addExcept())); |
330 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); | 330 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); |
331 | 331 | ||
332 | tb = new QToolButton ( tab ); | 332 | tb = new QToolButton ( tab ); |
333 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); | 333 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); |
334 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 334 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
335 | lay-> addWidget ( tb, 3, 1 ); | 335 | lay-> addWidget ( tb, 3, 1 ); |
336 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); | 336 | connect ( tb, SIGNAL( clicked()), this, SLOT( delExcept())); |
337 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); | 337 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); |
338 | 338 | ||
339 | tb = new QToolButton ( tab ); | 339 | tb = new QToolButton ( tab ); |
340 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); | 340 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); |
341 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 341 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
342 | lay-> addWidget ( tb, 4, 1 ); | 342 | lay-> addWidget ( tb, 4, 1 ); |
343 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); | 343 | connect ( tb, SIGNAL( clicked()), this, SLOT( upExcept())); |
344 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); | 344 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); |
345 | 345 | ||
346 | tb = new QToolButton ( tab ); | 346 | tb = new QToolButton ( tab ); |
347 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); | 347 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); |
348 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 348 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
349 | lay-> addWidget ( tb, 5, 1 ); | 349 | lay-> addWidget ( tb, 5, 1 ); |
350 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); | 350 | connect ( tb, SIGNAL( clicked()), this, SLOT( downExcept())); |
351 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); | 351 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); |
352 | 352 | ||
353 | lay-> setRowStretch ( 6, 10 ); | 353 | lay-> setRowStretch ( 6, 10 ); |
354 | lay-> setColStretch ( 0, 10 ); | 354 | lay-> setColStretch ( 0, 10 ); |
355 | 355 | ||
356 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); | 356 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); |
357 | QListViewItem *lvit = 0; | 357 | QListViewItem *lvit = 0; |
358 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 358 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
359 | { | 359 | { |
360 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 360 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
361 | 361 | ||
362 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); | 362 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | vertLayout-> addSpacing ( 3 ); | 366 | vertLayout-> addSpacing ( 3 ); |
367 | QFrame *f = new QFrame ( tab ); | 367 | QFrame *f = new QFrame ( tab ); |
368 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); | 368 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); |
369 | vertLayout-> addWidget ( f ); | 369 | vertLayout-> addWidget ( f ); |
370 | vertLayout-> addSpacing ( 3 ); | 370 | vertLayout-> addSpacing ( 3 ); |
371 | 371 | ||
372 | 372 | ||
373 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 373 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
374 | 374 | ||
375 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; | 375 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; |
376 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); | 376 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); |
377 | 377 | ||
378 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 378 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
379 | gridLayout-> addWidget ( label, 0, 0 ); | 379 | gridLayout-> addWidget ( label, 0, 0 ); |
380 | QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); | 380 | QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); |
381 | 381 | ||
382 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 382 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
383 | btngrp-> hide ( ); | 383 | btngrp-> hide ( ); |
384 | btngrp-> setExclusive ( true ); | 384 | btngrp-> setExclusive ( true ); |
385 | 385 | ||
386 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 386 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
387 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 387 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
388 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 388 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
389 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 389 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
390 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 390 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
391 | m_tabstyle_list-> setCurrentItem ( style ); | 391 | m_tabstyle_list-> setCurrentItem ( style ); |
392 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 392 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
393 | QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); | 393 | QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); |
394 | 394 | ||
395 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 395 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
396 | btngrp-> insert ( m_tabstyle_top ); | 396 | btngrp-> insert ( m_tabstyle_top ); |
397 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 397 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
398 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); | 398 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); |
399 | 399 | ||
400 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 400 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
401 | btngrp-> insert ( m_tabstyle_bottom ); | 401 | btngrp-> insert ( m_tabstyle_bottom ); |
402 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 402 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
403 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); | 403 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); |
404 | 404 | ||
405 | m_tabstyle_top-> setChecked ( tabtop ); | 405 | m_tabstyle_top-> setChecked ( tabtop ); |
406 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 406 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
407 | 407 | ||
408 | m_original_tabstyle = style; | 408 | m_original_tabstyle = style; |
409 | m_original_tabpos = tabtop; | 409 | m_original_tabpos = tabtop; |
410 | 410 | ||
411 | vertLayout-> addSpacing ( 3 ); | 411 | vertLayout-> addSpacing ( 3 ); |
412 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); | 412 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); |
413 | 413 | ||
414 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); | 414 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); |
415 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); | 415 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); |
416 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); | 416 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); |
417 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); | 417 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); |
418 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); | 418 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); |
419 | QPixmap ccw1; | 419 | QPixmap ccw1; |
420 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); | 420 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); |
421 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); | 421 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); |
422 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); | 422 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); |
423 | 423 | ||
424 | rotbtngrp-> hide ( ); | 424 | rotbtngrp-> hide ( ); |
425 | rotbtngrp-> setExclusive ( true ); | 425 | rotbtngrp-> setExclusive ( true ); |
426 | rotbtngrp-> insert ( m_rotdir_cw ); | 426 | rotbtngrp-> insert ( m_rotdir_cw ); |
427 | rotbtngrp-> insert ( m_rotdir_ccw ); | 427 | rotbtngrp-> insert ( m_rotdir_ccw ); |
428 | rotbtngrp-> insert ( m_rotdir_flip ); | 428 | rotbtngrp-> insert ( m_rotdir_flip ); |
429 | 429 | ||
430 | ccw1. convertFromImage( ccwImage ); | 430 | ccw1. convertFromImage( ccwImage ); |
431 | m_rotdir_cw-> setPixmap( cw1 ); | 431 | m_rotdir_cw-> setPixmap( cw1 ); |
432 | m_rotdir_ccw-> setPixmap( ccw1 ); | 432 | m_rotdir_ccw-> setPixmap( ccw1 ); |
433 | m_rotdir_flip-> setPixmap( flip1 ); | 433 | m_rotdir_flip-> setPixmap( flip1 ); |
434 | 434 | ||
435 | rotLay-> addWidget ( rotlabel, 0 ); | 435 | rotLay-> addWidget ( rotlabel, 0 ); |
436 | rotLay-> addWidget ( m_rotdir_cw, 0 ); | 436 | rotLay-> addWidget ( m_rotdir_cw, 0 ); |
437 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); | 437 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); |
438 | rotLay-> addWidget ( m_rotdir_flip, 0 ); | 438 | rotLay-> addWidget ( m_rotdir_flip, 0 ); |
439 | 439 | ||
440 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 440 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
441 | ODirection rot = CW; | 441 | ODirection rot = CW; |
442 | 442 | ||
443 | if (rotDirection == -1) | 443 | if (rotDirection == -1) |
444 | { | 444 | { |
445 | rot = ODevice::inst ( )-> direction ( ); | 445 | rot = ODevice::inst ( )-> direction ( ); |
446 | } | 446 | } |
447 | else | 447 | else |
448 | { | 448 | { |
449 | rot = (ODirection)rotDirection; | 449 | rot = (ODirection)rotDirection; |
450 | } | 450 | } |
451 | 451 | ||
452 | m_rotdir_cw-> setChecked ( rot == CW ); | 452 | m_rotdir_cw-> setChecked ( rot == CW ); |
453 | m_rotdir_ccw-> setChecked ( rot == CCW ); | 453 | m_rotdir_ccw-> setChecked ( rot == CCW ); |
454 | m_rotdir_flip-> setChecked ( rot == Flip ); | 454 | m_rotdir_flip-> setChecked ( rot == Flip ); |
455 | 455 | ||
456 | return tab; | 456 | return tab; |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 460 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
461 | : QDialog ( parent, name, true, WStyle_ContextHelp ) | 461 | : QDialog ( parent, name, true, WStyle_ContextHelp ) |
462 | { | 462 | { |
463 | setCaption( tr( "Appearance Settings" ) ); | 463 | setCaption( tr( "Appearance Settings" ) ); |
464 | 464 | ||
465 | Config config( "qpe" ); | 465 | Config config( "qpe" ); |
466 | config.setGroup( "Appearance" ); | 466 | config.setGroup( "Appearance" ); |
467 | 467 | ||
468 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); | 468 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); |
469 | 469 | ||
470 | m_sample = new SampleWindow ( this ); | 470 | m_sample = new SampleWindow ( this ); |
471 | 471 | ||
472 | m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); | 472 | m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); |
473 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); | 473 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); |
474 | 474 | ||
475 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 475 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
476 | QWidget *styletab; | 476 | QWidget *styletab; |
477 | 477 | ||
478 | m_color_list = 0; | 478 | m_color_list = 0; |
479 | 479 | ||
480 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); | 480 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); |
481 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); | 481 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); |
482 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); | 482 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); |
483 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); | 483 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); |
484 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); | 484 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); |
485 | 485 | ||
486 | top-> addWidget ( tw, 10 ); | 486 | top-> addWidget ( tw, 10 ); |
487 | top-> addWidget ( m_sample, 1 ); | 487 | top-> addWidget ( m_sample, 1 ); |
488 | 488 | ||
489 | tw-> setCurrentTab ( styletab ); | 489 | tw-> setCurrentTab ( styletab ); |
490 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); | 490 | connect ( tw, SIGNAL( currentChanged(QWidget*)), this, SLOT( tabChanged(QWidget*))); |
491 | 491 | ||
492 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; | 492 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; |
493 | } | 493 | } |
494 | 494 | ||
495 | Appearance::~Appearance() | 495 | Appearance::~Appearance() |
496 | {} | 496 | {} |
497 | 497 | ||
498 | void Appearance::tabChanged ( QWidget *w ) | 498 | void Appearance::tabChanged ( QWidget *w ) |
499 | { | 499 | { |
500 | if ( w == m_advtab ) | 500 | if ( w == m_advtab ) |
501 | { | 501 | { |
502 | m_sample-> hide ( ); | 502 | m_sample-> hide ( ); |
503 | updateGeometry ( ); // shouldn't be necessary ... | 503 | updateGeometry ( ); // shouldn't be necessary ... |
504 | } | 504 | } |
505 | else | 505 | else |
506 | m_sample-> show ( ); | 506 | m_sample-> show ( ); |
507 | } | 507 | } |
508 | 508 | ||
509 | void Appearance::accept ( ) | 509 | void Appearance::accept ( ) |
510 | { | 510 | { |
511 | bool newtabpos = m_tabstyle_top-> isChecked ( ); | 511 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
512 | int newtabstyle = m_tabstyle_list-> currentItem ( ); | 512 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
513 | 513 | ||
514 | Config config ( "qpe" ); | 514 | Config config ( "qpe" ); |
515 | config. setGroup ( "Appearance" ); | 515 | config. setGroup ( "Appearance" ); |
516 | 516 | ||
517 | if ( m_style_changed ) | 517 | if ( m_style_changed ) |
518 | { | 518 | { |
519 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 519 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
520 | if ( item ) | 520 | if ( item ) |
521 | config.writeEntry( "Style", item-> key ( )); | 521 | config.writeEntry( "Style", item-> key ( )); |
522 | } | 522 | } |
523 | 523 | ||
524 | if ( m_deco_changed ) | 524 | if ( m_deco_changed ) |
525 | { | 525 | { |
526 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); | 526 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); |
527 | if ( item ) | 527 | if ( item ) |
528 | config.writeEntry( "Decoration", item-> key ( )); | 528 | config.writeEntry( "Decoration", item-> key ( )); |
529 | } | 529 | } |
530 | 530 | ||
531 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) | 531 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) |
532 | { | 532 | { |
533 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | 533 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); |
534 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | 534 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); |
535 | } | 535 | } |
536 | 536 | ||
537 | if ( m_font_changed ) | 537 | if ( m_font_changed ) |
538 | { | 538 | { |
539 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); | 539 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
540 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); | 540 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
541 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); | 541 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | if ( m_color_changed ) | 545 | if ( m_color_changed ) |
546 | { | 546 | { |
547 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 547 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
548 | 548 | ||
549 | if ( item ) | 549 | if ( item ) |
550 | item-> save ( config ); | 550 | item-> save ( config ); |
551 | } | 551 | } |
552 | 552 | ||
553 | ODirection rot; | 553 | ODirection rot; |
554 | if (m_rotdir_ccw-> isChecked ( )) | 554 | if (m_rotdir_ccw-> isChecked ( )) |
555 | { | 555 | { |
556 | rot = CCW; | 556 | rot = CCW; |
557 | } | 557 | } |
558 | else if (m_rotdir_cw-> isChecked ( )) | 558 | else if (m_rotdir_cw-> isChecked ( )) |
559 | { | 559 | { |
560 | rot = CW; | 560 | rot = CW; |
561 | } | 561 | } |
562 | else | 562 | else |
563 | { | 563 | { |
564 | rot = Flip; | 564 | rot = Flip; |
565 | } | 565 | } |
566 | config. writeEntry ( "rotatedir", (int)rot ); | 566 | config. writeEntry ( "rotatedir", (int)rot ); |
567 | 567 | ||
568 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated | 568 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated |
569 | 569 | ||
570 | QStringList sl; | 570 | QStringList sl; |
571 | QString exceptstr; | 571 | QString exceptstr; |
572 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) | 572 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) |
573 | { | 573 | { |
574 | int fl = 0; | 574 | int fl = 0; |
575 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); | 575 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); |
576 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); | 576 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); |
577 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); | 577 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); |
578 | exceptstr = QString::number ( fl, 32 ); | 578 | exceptstr = QString::number ( fl, 32 ); |
579 | exceptstr.append( it-> pattern ( )); | 579 | exceptstr.append( it-> pattern ( )); |
580 | sl << exceptstr; | 580 | sl << exceptstr; |
581 | } | 581 | } |
582 | config. writeEntry ( "NoStyle", sl, ';' ); | 582 | config. writeEntry ( "NoStyle", sl, ';' ); |
583 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); | 583 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); |
584 | 584 | ||
585 | config. write ( ); // need to flush the config info first | 585 | config. write ( ); // need to flush the config info first |
586 | Global::applyStyle ( ); | 586 | Global::applyStyle ( ); |
587 | 587 | ||
588 | QDialog::accept ( ); | 588 | QDialog::accept ( ); |
589 | } | 589 | } |
590 | 590 | ||
591 | void Appearance::done ( int r ) | 591 | void Appearance::done ( int r ) |
592 | { | 592 | { |
593 | QDialog::done ( r ); | 593 | QDialog::done ( r ); |
594 | close ( ); | 594 | close ( ); |
595 | } | 595 | } |
596 | 596 | ||
597 | 597 | ||
598 | void Appearance::styleClicked ( int index ) | 598 | void Appearance::styleClicked ( int index ) |
599 | { | 599 | { |
600 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); | 600 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); |
601 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); | 601 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); |
602 | 602 | ||
603 | if ( m_sample && sli && sli-> style ( )) | 603 | if ( m_sample && sli && sli-> style ( )) |
604 | { | 604 | { |
605 | int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; | 605 | int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; |
606 | 606 | ||
607 | m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); | 607 | m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); |
608 | } | 608 | } |
609 | 609 | ||
610 | m_style_changed |= ( index != m_original_style ); | 610 | m_style_changed |= ( index != m_original_style ); |
611 | } | 611 | } |
612 | 612 | ||
613 | void Appearance::styleSettingsClicked ( ) | 613 | void Appearance::styleSettingsClicked ( ) |
614 | { | 614 | { |
615 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 615 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
616 | 616 | ||
617 | if ( item && item-> hasSettings ( )) | 617 | if ( item && item-> hasSettings ( )) |
618 | { | 618 | { |
619 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); | 619 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); |
620 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); | 620 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); |
621 | 621 | ||
622 | QWidget *w = item-> settings ( d ); | 622 | QWidget *w = item-> settings ( d ); |
623 | 623 | ||
624 | if ( w ) | 624 | if ( w ) |
625 | { | 625 | { |
626 | vbox-> addWidget ( w ); | 626 | vbox-> addWidget ( w ); |
627 | 627 | ||
628 | d-> setCaption ( w-> caption ( )); | 628 | d-> setCaption ( w-> caption ( )); |
629 | 629 | ||
630 | bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted ); | 630 | bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted ); |
631 | 631 | ||
632 | if ( item-> setSettings ( accepted )) | 632 | if ( item-> setSettings ( accepted )) |
633 | m_style_changed = true; | 633 | m_style_changed = true; |
634 | } | 634 | } |
635 | delete d; | 635 | delete d; |
636 | } | 636 | } |
637 | } | 637 | } |
638 | 638 | ||
639 | void Appearance::decoClicked ( int index ) | 639 | void Appearance::decoClicked ( int index ) |
640 | { | 640 | { |
641 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); | 641 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); |
642 | 642 | ||
643 | if ( m_sample ) | 643 | if ( m_sample ) |
644 | { | 644 | { |
645 | if ( dli && dli-> interface ( )) | 645 | if ( dli && dli-> interface ( )) |
646 | m_sample-> setDecoration ( dli-> interface ( )); | 646 | m_sample-> setDecoration ( dli-> interface ( )); |
647 | else | 647 | else |
648 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 648 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
649 | m_sample-> repaint ( ); | 649 | m_sample-> repaint ( ); |
650 | } | 650 | } |
651 | m_deco_changed |= ( index != m_original_deco ); | 651 | m_deco_changed |= ( index != m_original_deco ); |
652 | } | 652 | } |
653 | 653 | ||
654 | void Appearance::fontClicked ( const QFont &f ) | 654 | void Appearance::fontClicked ( const QFont &f ) |
655 | { | 655 | { |
656 | m_font_changed |= ( f != m_sample-> font ( )); | 656 | m_font_changed |= ( f != m_sample-> font ( )); |
657 | m_sample-> setFont ( f ); | 657 | m_sample-> setFont ( f ); |
658 | } | 658 | } |
659 | 659 | ||
660 | void Appearance::colorClicked ( int index ) | 660 | void Appearance::colorClicked ( int index ) |
661 | { | 661 | { |
662 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); | 662 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); |
663 | 663 | ||
664 | if ( item ) | 664 | if ( item ) |
665 | m_sample-> setPalette ( item-> palette ( )); | 665 | m_sample-> setPalette ( item-> palette ( )); |
666 | 666 | ||
667 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 667 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
668 | } | 668 | } |
669 | 669 | ||
670 | 670 | ||
671 | void Appearance::editSchemeClicked ( ) | 671 | void Appearance::editSchemeClicked ( ) |
672 | { | 672 | { |
673 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 673 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
674 | 674 | ||
675 | int cnt = 0; | 675 | int cnt = 0; |
676 | QString labels [QColorGroup::NColorRoles]; | 676 | QString labels [QColorGroup::NColorRoles]; |
677 | QColor colors [QColorGroup::NColorRoles]; | 677 | QColor colors [QColorGroup::NColorRoles]; |
678 | 678 | ||
679 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) | 679 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) |
680 | { | 680 | { |
681 | QColor col = item-> color ( role ); | 681 | QColor col = item-> color ( role ); |
682 | 682 | ||
683 | if ( col. isValid ( )) | 683 | if ( col. isValid ( )) |
684 | { | 684 | { |
685 | labels [cnt] = item-> label ( role ); | 685 | labels [cnt] = item-> label ( role ); |
686 | colors [cnt] = col; | 686 | colors [cnt] = col; |
687 | 687 | ||
688 | cnt++; | 688 | cnt++; |
689 | } | 689 | } |
690 | } | 690 | } |
691 | 691 | ||
692 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); | 692 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); |
693 | if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted ) | 693 | if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted ) |
694 | { | 694 | { |
695 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); | 695 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); |
696 | cnt = 0; | 696 | cnt = 0; |
697 | 697 | ||
698 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) | 698 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) |
699 | { | 699 | { |
700 | if ( item-> color ( role ). isValid ( )) | 700 | if ( item-> color ( role ). isValid ( )) |
701 | { | 701 | { |
702 | citem-> setColor ( role, colors [cnt] ); | 702 | citem-> setColor ( role, colors [cnt] ); |
703 | cnt++; | 703 | cnt++; |
704 | } | 704 | } |
705 | } | 705 | } |
706 | 706 | ||
707 | m_color_list-> setCurrentItem ( 0 ); | 707 | m_color_list-> setCurrentItem ( 0 ); |
708 | colorClicked ( 0 ); | 708 | colorClicked ( 0 ); |
709 | 709 | ||
710 | m_color_changed = true; | 710 | m_color_changed = true; |
711 | } | 711 | } |
712 | delete editdlg; | 712 | delete editdlg; |
713 | } | 713 | } |
714 | 714 | ||
715 | 715 | ||
716 | void Appearance::saveSchemeClicked() | 716 | void Appearance::saveSchemeClicked() |
717 | { | 717 | { |
718 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 718 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
719 | 719 | ||
720 | if ( !item ) | 720 | if ( !item ) |
721 | return; | 721 | return; |
722 | 722 | ||
723 | QDialog *d = new QDialog ( this, 0, true ); | 723 | QDialog *d = new QDialog ( this, 0, true ); |
724 | d-> setCaption ( tr( "Save Scheme" )); | 724 | d-> setCaption ( tr( "Save Scheme" )); |
725 | QLineEdit *ed = new QLineEdit ( d ); | 725 | QLineEdit *ed = new QLineEdit ( d ); |
726 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); | 726 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); |
727 | ed-> setFocus ( ); | 727 | ed-> setFocus ( ); |
728 | 728 | ||
729 | if ( d-> exec ( ) == QDialog::Accepted ) | 729 | if ( d-> exec ( ) == QDialog::Accepted ) |
730 | { | 730 | { |
731 | QString schemename = ed-> text ( ); | 731 | QString schemename = ed-> text ( ); |
732 | QString filestr = QPEApplication::qpeDir(); | 732 | QString filestr = QPEApplication::qpeDir(); |
733 | filestr.append( "/etc/colors/" ); | 733 | filestr.append( "/etc/colors/" ); |
734 | filestr.append( schemename ); | 734 | filestr.append( schemename ); |
735 | filestr.append( ".scheme" ); | 735 | filestr.append( ".scheme" ); |
736 | QFile file ( filestr ); | 736 | QFile file ( filestr ); |
737 | if ( !file. exists ( )) | 737 | if ( !file. exists ( )) |
738 | { | 738 | { |
739 | QPalette p = item-> palette ( ); | 739 | QPalette p = item-> palette ( ); |
740 | 740 | ||
741 | Config config ( file.name(), Config::File ); | 741 | Config config ( file.name(), Config::File ); |
742 | config. setGroup( "Colors" ); | 742 | config. setGroup( "Colors" ); |
743 | 743 | ||
744 | item-> save ( config ); | 744 | item-> save ( config ); |
745 | 745 | ||
746 | config. write ( ); // need to flush the config info first | 746 | config. write ( ); // need to flush the config info first |
747 | 747 | ||
748 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); | 748 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); |
749 | } | 749 | } |
750 | else | 750 | else |
751 | { | 751 | { |
752 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 752 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
753 | } | 753 | } |
754 | } | 754 | } |
755 | delete d; | 755 | delete d; |
756 | } | 756 | } |
757 | 757 | ||
758 | void Appearance::deleteSchemeClicked() | 758 | void Appearance::deleteSchemeClicked() |
759 | { | 759 | { |
760 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 760 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
761 | 761 | ||
762 | if ( !item ) | 762 | if ( !item ) |
763 | return; | 763 | return; |
764 | 764 | ||
765 | if ( m_color_list-> currentItem ( ) > 0 ) | 765 | if ( m_color_list-> currentItem ( ) > 0 ) |
766 | { | 766 | { |
767 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) ) | 767 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) ) |
768 | { | 768 | { |
769 | QString filestr = QPEApplication::qpeDir ( ); | 769 | QString filestr = QPEApplication::qpeDir ( ); |
770 | filestr.append( "/etc/colors/" ); | 770 | filestr.append( "/etc/colors/" ); |
771 | filestr.append( item-> text ( ) ); | 771 | filestr.append( item-> text ( ) ); |
772 | filestr.append( ".scheme" ); | 772 | filestr.append( ".scheme" ); |
773 | QFile::remove ( filestr ); | 773 | QFile::remove ( filestr ); |
774 | delete item; | 774 | delete item; |
775 | } | 775 | } |
776 | } | 776 | } |
777 | else | 777 | else |
778 | { | 778 | { |
779 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); | 779 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); |
780 | } | 780 | } |
781 | } | 781 | } |
782 | 782 | ||
783 | 783 | ||
784 | void Appearance::addExcept ( ) | 784 | void Appearance::addExcept ( ) |
785 | { | 785 | { |
786 | ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); | 786 | ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); |
787 | m_except-> ensureItemVisible ( it ); | 787 | m_except-> ensureItemVisible ( it ); |
788 | m_except-> setSelected ( it, true ); | 788 | m_except-> setSelected ( it, true ); |
789 | } | 789 | } |
790 | 790 | ||
791 | void Appearance::delExcept ( ) | 791 | void Appearance::delExcept ( ) |
792 | { | 792 | { |
793 | if ( m_except-> selectedItem ( )) | 793 | if ( m_except-> selectedItem ( )) |
794 | { | 794 | { |
795 | m_except-> setFocus ( ); | 795 | m_except-> setFocus ( ); |
796 | delete m_except-> selectedItem ( ); | 796 | delete m_except-> selectedItem ( ); |
797 | } | 797 | } |
798 | } | 798 | } |
799 | 799 | ||
800 | void Appearance::upExcept ( ) | 800 | void Appearance::upExcept ( ) |
801 | { | 801 | { |
802 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 802 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
803 | 803 | ||
804 | if ( it && it-> itemAbove ( )) | 804 | if ( it && it-> itemAbove ( )) |
805 | it-> itemAbove ( )-> moveItem ( it ); | 805 | it-> itemAbove ( )-> moveItem ( it ); |
806 | } | 806 | } |
807 | 807 | ||
808 | void Appearance::downExcept ( ) | 808 | void Appearance::downExcept ( ) |
809 | { | 809 | { |
810 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 810 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
811 | 811 | ||
812 | if ( it && it-> itemBelow ( )) | 812 | if ( it && it-> itemBelow ( )) |
813 | it-> moveItem ( it-> itemBelow ( )); | 813 | it-> moveItem ( it-> itemBelow ( )); |
814 | } | 814 | } |
815 | 815 | ||
816 | class ExEdit : public QLineEdit | 816 | class ExEdit : public QLineEdit |
817 | { | 817 | { |
818 | public: | 818 | public: |
819 | ExEdit ( ExceptListItem *item ) | 819 | ExEdit ( ExceptListItem *item ) |
820 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) | 820 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) |
821 | { | 821 | { |
822 | setFrame ( false ); | 822 | setFrame ( false ); |
823 | 823 | ||
824 | QRect r = it-> listView ( )-> itemRect ( it ); | 824 | QRect r = it-> listView ( )-> itemRect ( it ); |
825 | 825 | ||
826 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; | 826 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; |
827 | int y = r. y ( ); | 827 | int y = r. y ( ); |
828 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; | 828 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; |
829 | int h = r. height ( ); // + 2; | 829 | int h = r. height ( ); // + 2; |
830 | 830 | ||
831 | setText ( it-> pattern ( )); | 831 | setText ( it-> pattern ( )); |
832 | setGeometry ( x, y, w, h ); | 832 | setGeometry ( x, y, w, h ); |
833 | 833 | ||
834 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); | 834 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); |
835 | 835 | ||
836 | m_out = true; | 836 | m_out = true; |
837 | 837 | ||
838 | show ( ); | 838 | show ( ); |
839 | setFocus ( ); | 839 | setFocus ( ); |
840 | selectAll ( ); | 840 | selectAll ( ); |
841 | end ( true ); | 841 | end ( true ); |
842 | } | 842 | } |
843 | 843 | ||
844 | virtual void focusOutEvent ( QFocusEvent * ) | 844 | virtual void focusOutEvent ( QFocusEvent * ) |
845 | { | 845 | { |
846 | hide ( ); | 846 | hide ( ); |
847 | if ( m_out ) | 847 | if ( m_out ) |
848 | it-> setPattern ( text ( )); | 848 | it-> setPattern ( text ( )); |
849 | delete this; | 849 | delete this; |
850 | } | 850 | } |
851 | 851 | ||
852 | virtual void keyPressEvent ( QKeyEvent *e ) | 852 | virtual void keyPressEvent ( QKeyEvent *e ) |
853 | { | 853 | { |
854 | if ( e-> key ( ) == Key_Return ) | 854 | if ( e-> key ( ) == Key_Return ) |
855 | it-> listView ( )-> setFocus ( ); | 855 | it-> listView ( )-> setFocus ( ); |
856 | else if ( e-> key ( ) == Key_Escape ) | 856 | else if ( e-> key ( ) == Key_Escape ) |
857 | { | 857 | { |
858 | m_out = false; | 858 | m_out = false; |
859 | it-> listView ( )-> setFocus ( ); | 859 | it-> listView ( )-> setFocus ( ); |
860 | } | 860 | } |
861 | else | 861 | else |
862 | QLineEdit::keyPressEvent ( e ); | 862 | QLineEdit::keyPressEvent ( e ); |
863 | } | 863 | } |
864 | 864 | ||
865 | private: | 865 | private: |
866 | ExceptListItem *it; | 866 | ExceptListItem *it; |
867 | bool m_out; | 867 | bool m_out; |
868 | }; | 868 | }; |
869 | 869 | ||
870 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) | 870 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) |
871 | { | 871 | { |
872 | if ( !item || c < 0 || c > 3 ) | 872 | if ( !item || c < 0 || c > 3 ) |
873 | return; | 873 | return; |
874 | 874 | ||
diff --git a/noncore/settings/appearance2/sample.cpp b/noncore/settings/appearance2/sample.cpp index b3a9d48..f6c4dca 100644 --- a/noncore/settings/appearance2/sample.cpp +++ b/noncore/settings/appearance2/sample.cpp | |||
@@ -1,271 +1,271 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@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 <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qscrollbar.h> | 35 | #include <qscrollbar.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qwhatsthis.h> | 37 | #include <qwhatsthis.h> |
38 | #include <qpixmapcache.h> | 38 | #include <qpixmapcache.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | #include <qobjectlist.h> | 40 | #include <qobjectlist.h> |
41 | #include <qcommonstyle.h> | 41 | #include <qcommonstyle.h> |
42 | 42 | ||
43 | #include "sample.h" | 43 | #include "sample.h" |
44 | 44 | ||
45 | 45 | ||
46 | class SampleText : public QWidget | 46 | class SampleText : public QWidget |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | SampleText( const QString &t, bool h, QWidget *parent ) | 49 | SampleText( const QString &t, bool h, QWidget *parent ) |
50 | : QWidget( parent ), hl(h), text(t) | 50 | : QWidget( parent ), hl(h), text(t) |
51 | { | 51 | { |
52 | if ( hl ) | 52 | if ( hl ) |
53 | setBackgroundMode( PaletteHighlight ); | 53 | setBackgroundMode( PaletteHighlight ); |
54 | else | 54 | else |
55 | setBackgroundMode( PaletteBase ); | 55 | setBackgroundMode( PaletteBase ); |
56 | } | 56 | } |
57 | 57 | ||
58 | QSize sizeHint() const | 58 | QSize sizeHint() const |
59 | { | 59 | { |
60 | QFontMetrics fm(font()); | 60 | QFontMetrics fm(font()); |
61 | return QSize( fm.width(text)+10, fm.height()+4 ); | 61 | return QSize( fm.width(text)+10, fm.height()+4 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | void paintEvent( QPaintEvent * ) | 64 | void paintEvent( QPaintEvent * ) |
65 | { | 65 | { |
66 | QPainter p(this); | 66 | QPainter p(this); |
67 | if ( hl ) | 67 | if ( hl ) |
68 | p.setPen( colorGroup().highlightedText() ); | 68 | p.setPen( colorGroup().highlightedText() ); |
69 | else | 69 | else |
70 | p.setPen( colorGroup().text() ); | 70 | p.setPen( colorGroup().text() ); |
71 | p.drawText( rect(), AlignCenter, text ); | 71 | p.drawText( rect(), AlignCenter, text ); |
72 | } | 72 | } |
73 | 73 | ||
74 | private: | 74 | private: |
75 | bool hl; | 75 | bool hl; |
76 | QString text; | 76 | QString text; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0) | 80 | SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0) |
81 | { | 81 | { |
82 | init(); | 82 | init(); |
83 | } | 83 | } |
84 | 84 | ||
85 | QSize SampleWindow::sizeHint() const | 85 | QSize SampleWindow::sizeHint() const |
86 | { | 86 | { |
87 | return container->sizeHint() + QSize( 10, 35 ); | 87 | return container->sizeHint() + QSize( 10, 35 ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void SampleWindow::setFont( const QFont &f ) | 90 | void SampleWindow::setFont( const QFont &f ) |
91 | { | 91 | { |
92 | QWidget::setFont( f ); | 92 | QWidget::setFont( f ); |
93 | popup->setFont( f ); | 93 | popup->setFont( f ); |
94 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 94 | QTimer::singleShot ( 0, this, SLOT( fixGeometry())); |
95 | } | 95 | } |
96 | 96 | ||
97 | static void setStyleRecursive ( QWidget *w, QStyle *s ) | 97 | static void setStyleRecursive ( QWidget *w, QStyle *s ) |
98 | { | 98 | { |
99 | w->setStyle( s ); | 99 | w->setStyle( s ); |
100 | QObjectList *childObjects=(QObjectList*)w->children(); | 100 | QObjectList *childObjects=(QObjectList*)w->children(); |
101 | if ( childObjects ) { | 101 | if ( childObjects ) { |
102 | QObject * o; | 102 | QObject * o; |
103 | for(o=childObjects->first();o!=0;o=childObjects->next()) { | 103 | for(o=childObjects->first();o!=0;o=childObjects->next()) { |
104 | if( o->isWidgetType() ) { | 104 | if( o->isWidgetType() ) { |
105 | setStyleRecursive((QWidget *)o,s); | 105 | setStyleRecursive((QWidget *)o,s); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void SampleWindow::setStyle2 ( QStyle *sty, const QPalette &pal ) | 112 | void SampleWindow::setStyle2 ( QStyle *sty, const QPalette &pal ) |
113 | { | 113 | { |
114 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); | 114 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); |
115 | 115 | ||
116 | extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); | 116 | extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); |
117 | 117 | ||
118 | QPixmapCache::clear ( ); | 118 | QPixmapCache::clear ( ); |
119 | QPalette p = pal; // ette ( ); | 119 | QPalette p = pal; // ette ( ); |
120 | sty-> polish ( p ); | 120 | sty-> polish ( p ); |
121 | qt_set_draw_menu_bar_impl ( 0 ); | 121 | qt_set_draw_menu_bar_impl ( 0 ); |
122 | setStyleRecursive ( this, sty ); | 122 | setStyleRecursive ( this, sty ); |
123 | setPalette ( p ); | 123 | setPalette ( p ); |
124 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 124 | QTimer::singleShot ( 0, this, SLOT( fixGeometry())); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) | 128 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) |
129 | { | 129 | { |
130 | iface = i; | 130 | iface = i; |
131 | wd.rect = QRect( 0, 0, 150, 75 ); | 131 | wd.rect = QRect( 0, 0, 150, 75 ); |
132 | wd.caption = tr("Sample"); | 132 | wd.caption = tr("Sample"); |
133 | wd.palette = palette(); | 133 | wd.palette = palette(); |
134 | wd.flags = WindowDecorationInterface::WindowData::Dialog | | 134 | wd.flags = WindowDecorationInterface::WindowData::Dialog | |
135 | WindowDecorationInterface::WindowData::Active; | 135 | WindowDecorationInterface::WindowData::Active; |
136 | wd.reserved = 1; | 136 | wd.reserved = 1; |
137 | 137 | ||
138 | th = iface->metric(WindowDecorationInterface::TitleHeight, &wd); | 138 | th = iface->metric(WindowDecorationInterface::TitleHeight, &wd); |
139 | tb = iface->metric(WindowDecorationInterface::TopBorder, &wd); | 139 | tb = iface->metric(WindowDecorationInterface::TopBorder, &wd); |
140 | lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd); | 140 | lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd); |
141 | rb = iface->metric(WindowDecorationInterface::RightBorder, &wd); | 141 | rb = iface->metric(WindowDecorationInterface::RightBorder, &wd); |
142 | bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd); | 142 | bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd); |
143 | 143 | ||
144 | int yoff = th + tb; | 144 | int yoff = th + tb; |
145 | int xoff = lb; | 145 | int xoff = lb; |
146 | 146 | ||
147 | wd.rect.setX( 0 ); | 147 | wd.rect.setX( 0 ); |
148 | wd.rect.setWidth( width() - lb - rb ); | 148 | wd.rect.setWidth( width() - lb - rb ); |
149 | wd.rect.setY( 0 ); | 149 | wd.rect.setY( 0 ); |
150 | wd.rect.setHeight( height() - yoff - bb ); | 150 | wd.rect.setHeight( height() - yoff - bb ); |
151 | 151 | ||
152 | container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() ); | 152 | container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() ); |
153 | setMinimumSize( container->sizeHint().width()+lb+rb, | 153 | setMinimumSize( container->sizeHint().width()+lb+rb, |
154 | container->sizeHint().height()+tb+th+bb ); | 154 | container->sizeHint().height()+tb+th+bb ); |
155 | } | 155 | } |
156 | 156 | ||
157 | void SampleWindow::paintEvent( QPaintEvent * ) | 157 | void SampleWindow::paintEvent( QPaintEvent * ) |
158 | { | 158 | { |
159 | if ( !iface ) | 159 | if ( !iface ) |
160 | return; | 160 | return; |
161 | 161 | ||
162 | QPainter p( this ); | 162 | QPainter p( this ); |
163 | 163 | ||
164 | p.translate( lb, th+tb ); | 164 | p.translate( lb, th+tb ); |
165 | 165 | ||
166 | iface->drawArea(WindowDecorationInterface::Border, &p, &wd); | 166 | iface->drawArea(WindowDecorationInterface::Border, &p, &wd); |
167 | iface->drawArea(WindowDecorationInterface::Title, &p, &wd); | 167 | iface->drawArea(WindowDecorationInterface::Title, &p, &wd); |
168 | 168 | ||
169 | p.setPen(palette().active().color(QColorGroup::HighlightedText)); | 169 | p.setPen(palette().active().color(QColorGroup::HighlightedText)); |
170 | QFont f( font() ); | 170 | QFont f( font() ); |
171 | f.setWeight( QFont::Bold ); | 171 | f.setWeight( QFont::Bold ); |
172 | p.setFont(f); | 172 | p.setFont(f); |
173 | iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd); | 173 | iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd); |
174 | 174 | ||
175 | QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th ); | 175 | QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th ); |
176 | iface->drawButton( WindowDecorationInterface::Help, &p, &wd, | 176 | iface->drawButton( WindowDecorationInterface::Help, &p, &wd, |
177 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 177 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
178 | brect.moveBy( wd.rect.width() - | 178 | brect.moveBy( wd.rect.width() - |
179 | iface->metric(WindowDecorationInterface::OKWidth,&wd) - | 179 | iface->metric(WindowDecorationInterface::OKWidth,&wd) - |
180 | iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); | 180 | iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); |
181 | iface->drawButton( WindowDecorationInterface::Close, &p, &wd, | 181 | iface->drawButton( WindowDecorationInterface::Close, &p, &wd, |
182 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 182 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
183 | brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); | 183 | brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); |
184 | iface->drawButton( WindowDecorationInterface::OK, &p, &wd, | 184 | iface->drawButton( WindowDecorationInterface::OK, &p, &wd, |
185 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 185 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void SampleWindow::init() | 188 | void SampleWindow::init() |
189 | { | 189 | { |
190 | container = new QVBox( this ); | 190 | container = new QVBox( this ); |
191 | popup = new QPopupMenu( this ); | 191 | popup = new QPopupMenu( this ); |
192 | popup->insertItem( tr("Normal Item"), 1 ); | 192 | popup->insertItem( tr("Normal Item"), 1 ); |
193 | popup->insertItem( tr("Disabled Item"), 2 ); | 193 | popup->insertItem( tr("Disabled Item"), 2 ); |
194 | popup->setItemEnabled(2, FALSE); | 194 | popup->setItemEnabled(2, FALSE); |
195 | QMenuBar *mb = new QMenuBar( container ); | 195 | QMenuBar *mb = new QMenuBar( container ); |
196 | mb->insertItem( tr("Menu"), popup ); | 196 | mb->insertItem( tr("Menu"), popup ); |
197 | QHBox *hb = new QHBox( container ); | 197 | QHBox *hb = new QHBox( container ); |
198 | QWidget *w = new QWidget( hb ); | 198 | QWidget *w = new QWidget( hb ); |
199 | (void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb ); | 199 | (void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb ); |
200 | 200 | ||
201 | QGridLayout *gl = new QGridLayout( w, 2, 2, 4 ); | 201 | QGridLayout *gl = new QGridLayout( w, 2, 2, 4 ); |
202 | SampleText *l = new SampleText( tr("Normal Text"), FALSE, w ); | 202 | SampleText *l = new SampleText( tr("Normal Text"), FALSE, w ); |
203 | gl->addWidget( l, 0, 0 ); | 203 | gl->addWidget( l, 0, 0 ); |
204 | 204 | ||
205 | l = new SampleText( tr("Highlighted Text"), TRUE, w ); | 205 | l = new SampleText( tr("Highlighted Text"), TRUE, w ); |
206 | gl->addWidget( l, 1, 0 ); | 206 | gl->addWidget( l, 1, 0 ); |
207 | 207 | ||
208 | QPushButton *pb = new QPushButton( tr("Button"), w ); | 208 | QPushButton *pb = new QPushButton( tr("Button"), w ); |
209 | gl->addWidget( pb, 0, 1 ); | 209 | gl->addWidget( pb, 0, 1 ); |
210 | pb->setFocusPolicy( NoFocus ); | 210 | pb->setFocusPolicy( NoFocus ); |
211 | 211 | ||
212 | QCheckBox *cb = new QCheckBox( tr("Check Box"), w ); | 212 | QCheckBox *cb = new QCheckBox( tr("Check Box"), w ); |
213 | gl->addWidget( cb, 1, 1 ); | 213 | gl->addWidget( cb, 1, 1 ); |
214 | cb->setFocusPolicy( NoFocus ); | 214 | cb->setFocusPolicy( NoFocus ); |
215 | cb->setChecked( TRUE ); | 215 | cb->setChecked( TRUE ); |
216 | 216 | ||
217 | QWhatsThis::add( this, tr("Sample window using the selected settings.") ); | 217 | QWhatsThis::add( this, tr("Sample window using the selected settings.") ); |
218 | } | 218 | } |
219 | 219 | ||
220 | bool SampleWindow::eventFilter( QObject *, QEvent *e ) | 220 | bool SampleWindow::eventFilter( QObject *, QEvent *e ) |
221 | { | 221 | { |
222 | switch ( e->type() ) { | 222 | switch ( e->type() ) { |
223 | case QEvent::MouseButtonPress: | 223 | case QEvent::MouseButtonPress: |
224 | case QEvent::MouseButtonRelease: | 224 | case QEvent::MouseButtonRelease: |
225 | case QEvent::MouseButtonDblClick: | 225 | case QEvent::MouseButtonDblClick: |
226 | case QEvent::MouseMove: | 226 | case QEvent::MouseMove: |
227 | case QEvent::KeyPress: | 227 | case QEvent::KeyPress: |
228 | case QEvent::KeyRelease: | 228 | case QEvent::KeyRelease: |
229 | return TRUE; | 229 | return TRUE; |
230 | default: | 230 | default: |
231 | break; | 231 | break; |
232 | } | 232 | } |
233 | 233 | ||
234 | return FALSE; | 234 | return FALSE; |
235 | } | 235 | } |
236 | 236 | ||
237 | void SampleWindow::paletteChange( const QPalette &old ) | 237 | void SampleWindow::paletteChange( const QPalette &old ) |
238 | { | 238 | { |
239 | QWidget::paletteChange ( old ); | 239 | QWidget::paletteChange ( old ); |
240 | wd. palette = palette ( ); | 240 | wd. palette = palette ( ); |
241 | popup-> setPalette ( palette ( )); | 241 | popup-> setPalette ( palette ( )); |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||
245 | void SampleWindow::setPalette ( const QPalette &pal ) | 245 | void SampleWindow::setPalette ( const QPalette &pal ) |
246 | { | 246 | { |
247 | QPixmapCache::clear ( ); | 247 | QPixmapCache::clear ( ); |
248 | QPalette p = pal; | 248 | QPalette p = pal; |
249 | style ( ). polish ( p ); | 249 | style ( ). polish ( p ); |
250 | QWidget::setPalette ( p ); | 250 | QWidget::setPalette ( p ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void SampleWindow::resizeEvent( QResizeEvent *re ) | 253 | void SampleWindow::resizeEvent( QResizeEvent *re ) |
254 | { | 254 | { |
255 | wd.rect = QRect( 0, 0, 150, 75 ); | 255 | wd.rect = QRect( 0, 0, 150, 75 ); |
256 | 256 | ||
257 | wd.rect.setX( 0 ); | 257 | wd.rect.setX( 0 ); |
258 | wd.rect.setWidth( width() - lb - rb ); | 258 | wd.rect.setWidth( width() - lb - rb ); |
259 | wd.rect.setY( 0 ); | 259 | wd.rect.setY( 0 ); |
260 | wd.rect.setHeight( height() - th - tb - bb ); | 260 | wd.rect.setHeight( height() - th - tb - bb ); |
261 | 261 | ||
262 | container->setGeometry( lb, th+tb, wd.rect.width(), wd.rect.height() ); | 262 | container->setGeometry( lb, th+tb, wd.rect.width(), wd.rect.height() ); |
263 | QWidget::resizeEvent( re ); | 263 | QWidget::resizeEvent( re ); |
264 | } | 264 | } |
265 | 265 | ||
266 | void SampleWindow::fixGeometry() | 266 | void SampleWindow::fixGeometry() |
267 | { | 267 | { |
268 | setMinimumSize( container->sizeHint().width()+lb+rb, | 268 | setMinimumSize( container->sizeHint().width()+lb+rb, |
269 | container->sizeHint().height()+tb+th+bb ); | 269 | container->sizeHint().height()+tb+th+bb ); |
270 | } | 270 | } |
271 | 271 | ||
diff --git a/noncore/settings/aqpkg/inputdlg.cpp b/noncore/settings/aqpkg/inputdlg.cpp index 06e934c..30f0527 100644 --- a/noncore/settings/aqpkg/inputdlg.cpp +++ b/noncore/settings/aqpkg/inputdlg.cpp | |||
@@ -1,134 +1,134 @@ | |||
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 <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qspinbox.h> | 34 | #include <qspinbox.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qwidgetstack.h> | 36 | #include <qwidgetstack.h> |
37 | #include <qvalidator.h> | 37 | #include <qvalidator.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include "inputdlg.h" | 40 | #include "inputdlg.h" |
41 | #include "global.h" | 41 | #include "global.h" |
42 | 42 | ||
43 | 43 | ||
44 | InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, | 44 | InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, |
45 | bool modal ) | 45 | bool modal ) |
46 | : QDialog( parent, name, modal ) | 46 | : QDialog( parent, name, modal ) |
47 | { | 47 | { |
48 | lineEdit = 0; | 48 | lineEdit = 0; |
49 | 49 | ||
50 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); | 50 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); |
51 | 51 | ||
52 | QLabel* l = new QLabel( label, this ); | 52 | QLabel* l = new QLabel( label, this ); |
53 | vbox->addWidget( l ); | 53 | vbox->addWidget( l ); |
54 | 54 | ||
55 | lineEdit = new QLineEdit( this ); | 55 | lineEdit = new QLineEdit( this ); |
56 | vbox->addWidget( lineEdit ); | 56 | vbox->addWidget( lineEdit ); |
57 | 57 | ||
58 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); | 58 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); |
59 | vbox->addLayout( hbox, AlignRight ); | 59 | vbox->addLayout( hbox, AlignRight ); |
60 | 60 | ||
61 | ok = new QPushButton( tr( "&OK" ), this ); | 61 | ok = new QPushButton( tr( "&OK" ), this ); |
62 | ok->setDefault( TRUE ); | 62 | ok->setDefault( TRUE ); |
63 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); | 63 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); |
64 | 64 | ||
65 | QSize bs( ok->sizeHint() ); | 65 | QSize bs( ok->sizeHint() ); |
66 | if ( cancel->sizeHint().width() > bs.width() ) | 66 | if ( cancel->sizeHint().width() > bs.width() ) |
67 | bs.setWidth( cancel->sizeHint().width() ); | 67 | bs.setWidth( cancel->sizeHint().width() ); |
68 | 68 | ||
69 | ok->setFixedSize( bs ); | 69 | ok->setFixedSize( bs ); |
70 | cancel->setFixedSize( bs ); | 70 | cancel->setFixedSize( bs ); |
71 | 71 | ||
72 | hbox->addWidget( new QWidget( this ) ); | 72 | hbox->addWidget( new QWidget( this ) ); |
73 | hbox->addWidget( ok ); | 73 | hbox->addWidget( ok ); |
74 | hbox->addWidget( cancel ); | 74 | hbox->addWidget( cancel ); |
75 | 75 | ||
76 | connect( lineEdit, SIGNAL( returnPressed() ), | 76 | connect( lineEdit, SIGNAL( returnPressed() ), |
77 | this, SLOT( tryAccept() ) ); | 77 | this, SLOT( tryAccept() ) ); |
78 | connect( lineEdit, SIGNAL( textChanged( const QString & ) ), | 78 | connect( lineEdit, SIGNAL( textChanged(const QString&) ), |
79 | this, SLOT( textChanged( const QString & ) ) ); | 79 | this, SLOT( textChanged(const QString&) ) ); |
80 | 80 | ||
81 | connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 81 | connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
82 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); | 82 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
83 | 83 | ||
84 | resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); | 84 | resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); |
85 | } | 85 | } |
86 | 86 | ||
87 | /*! | 87 | /*! |
88 | Destructor. | 88 | Destructor. |
89 | */ | 89 | */ |
90 | 90 | ||
91 | InputDialog::~InputDialog() | 91 | InputDialog::~InputDialog() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | void InputDialog :: setText( const QString &text ) | 95 | void InputDialog :: setText( const QString &text ) |
96 | { | 96 | { |
97 | lineEdit->setText( text ); | 97 | lineEdit->setText( text ); |
98 | lineEdit->selectAll(); | 98 | lineEdit->selectAll(); |
99 | } | 99 | } |
100 | 100 | ||
101 | QString InputDialog :: getText() | 101 | QString InputDialog :: getText() |
102 | { | 102 | { |
103 | return lineEdit->text(); | 103 | return lineEdit->text(); |
104 | } | 104 | } |
105 | 105 | ||
106 | QString InputDialog::getText( const QString &caption, const QString &label, | 106 | QString InputDialog::getText( const QString &caption, const QString &label, |
107 | const QString &text, bool *ok, QWidget *parent, | 107 | const QString &text, bool *ok, QWidget *parent, |
108 | const char *name ) | 108 | const char *name ) |
109 | { | 109 | { |
110 | InputDialog *dlg = new InputDialog( label, parent, name, true ); | 110 | InputDialog *dlg = new InputDialog( label, parent, name, true ); |
111 | dlg->setCaption( caption ); | 111 | dlg->setCaption( caption ); |
112 | dlg->setText( text ); | 112 | dlg->setText( text ); |
113 | 113 | ||
114 | QString result; | 114 | QString result; |
115 | *ok = dlg->exec() == QDialog::Accepted; | 115 | *ok = dlg->exec() == QDialog::Accepted; |
116 | if ( *ok ) | 116 | if ( *ok ) |
117 | result = dlg->getText(); | 117 | result = dlg->getText(); |
118 | 118 | ||
119 | delete dlg; | 119 | delete dlg; |
120 | return result; | 120 | return result; |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | void InputDialog :: textChanged( const QString &s ) | 125 | void InputDialog :: textChanged( const QString &s ) |
126 | { | 126 | { |
127 | ok->setEnabled( !s.isEmpty() ); | 127 | ok->setEnabled( !s.isEmpty() ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void InputDialog :: tryAccept() | 130 | void InputDialog :: tryAccept() |
131 | { | 131 | { |
132 | if ( !lineEdit->text().isEmpty() ) | 132 | if ( !lineEdit->text().isEmpty() ) |
133 | accept(); | 133 | accept(); |
134 | } | 134 | } |
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index d927a36..d2babb4 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -1,476 +1,476 @@ | |||
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 | enum { | 60 | enum { |
61 | MAXLINES = 100, | 61 | MAXLINES = 100, |
62 | }; | 62 | }; |
63 | 63 | ||
64 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) | 64 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) |
65 | : QWidget( 0, 0, 0 ) | 65 | : QWidget( 0, 0, 0 ) |
66 | { | 66 | { |
67 | setCaption( title ); | 67 | setCaption( title ); |
68 | init( TRUE ); | 68 | init( TRUE ); |
69 | 69 | ||
70 | pIpkg = 0; | 70 | pIpkg = 0; |
71 | upgradePackages = false; | 71 | upgradePackages = false; |
72 | dataMgr = dataManager; | 72 | dataMgr = dataManager; |
73 | 73 | ||
74 | QString defaultDest = "root"; | 74 | QString defaultDest = "root"; |
75 | #ifdef QWS | 75 | #ifdef QWS |
76 | Config cfg( "aqpkg" ); | 76 | Config cfg( "aqpkg" ); |
77 | cfg.setGroup( "settings" ); | 77 | cfg.setGroup( "settings" ); |
78 | defaultDest = cfg.readEntry( "dest", "root" ); | 78 | defaultDest = cfg.readEntry( "dest", "root" ); |
79 | 79 | ||
80 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 80 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
81 | flags = cfg.readNumEntry( "installFlags", 0 ); | 81 | flags = cfg.readNumEntry( "installFlags", 0 ); |
82 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); | 82 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); |
83 | #else | 83 | #else |
84 | flags = 0; | 84 | flags = 0; |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | // Output text is read only | 87 | // Output text is read only |
88 | output->setReadOnly( true ); | 88 | output->setReadOnly( true ); |
89 | // QFont f( "helvetica" ); | 89 | // QFont f( "helvetica" ); |
90 | // f.setPointSize( 10 ); | 90 | // f.setPointSize( 10 ); |
91 | // output->setFont( f ); | 91 | // output->setFont( f ); |
92 | 92 | ||
93 | 93 | ||
94 | // setup destination data | 94 | // setup destination data |
95 | int defIndex = 0; | 95 | int defIndex = 0; |
96 | int i; | 96 | int i; |
97 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); | 97 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); |
98 | for ( i = 0; dit.current(); ++dit, ++i ) | 98 | for ( i = 0; dit.current(); ++dit, ++i ) |
99 | { | 99 | { |
100 | destination->insertItem( dit.current()->getDestinationName() ); | 100 | destination->insertItem( dit.current()->getDestinationName() ); |
101 | if ( dit.current()->getDestinationName() == defaultDest ) | 101 | if ( dit.current()->getDestinationName() == defaultDest ) |
102 | defIndex = i; | 102 | defIndex = i; |
103 | } | 103 | } |
104 | 104 | ||
105 | destination->setCurrentItem( defIndex ); | 105 | destination->setCurrentItem( defIndex ); |
106 | 106 | ||
107 | QListIterator<InstallData> it( packageList ); | 107 | QListIterator<InstallData> it( packageList ); |
108 | // setup package data | 108 | // setup package data |
109 | QString remove = tr( "Remove\n" ); | 109 | QString remove = tr( "Remove\n" ); |
110 | QString install = tr( "Install\n" ); | 110 | QString install = tr( "Install\n" ); |
111 | QString upgrade = tr( "Upgrade\n" ); | 111 | QString upgrade = tr( "Upgrade\n" ); |
112 | for ( ; it.current(); ++it ) | 112 | for ( ; it.current(); ++it ) |
113 | { | 113 | { |
114 | InstallData *item = it.current(); | 114 | InstallData *item = it.current(); |
115 | InstallData *newitem = new InstallData(); | 115 | InstallData *newitem = new InstallData(); |
116 | 116 | ||
117 | newitem->option = item->option; | 117 | newitem->option = item->option; |
118 | newitem->packageName = item->packageName; | 118 | newitem->packageName = item->packageName; |
119 | newitem->destination = item->destination; | 119 | newitem->destination = item->destination; |
120 | newitem->recreateLinks = item->recreateLinks; | 120 | newitem->recreateLinks = item->recreateLinks; |
121 | packages.append( newitem ); | 121 | packages.append( newitem ); |
122 | 122 | ||
123 | if ( item->option == "I" ) | 123 | if ( item->option == "I" ) |
124 | { | 124 | { |
125 | install.append( QString( " %1\n" ).arg( item->packageName ) ); | 125 | install.append( QString( " %1\n" ).arg( item->packageName ) ); |
126 | } | 126 | } |
127 | else if ( item->option == "D" ) | 127 | else if ( item->option == "D" ) |
128 | { | 128 | { |
129 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); | 129 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); |
130 | } | 130 | } |
131 | else if ( item->option == "U" || item->option == "R" ) | 131 | else if ( item->option == "U" || item->option == "R" ) |
132 | { | 132 | { |
133 | QString type; | 133 | QString type; |
134 | if ( item->option == "R" ) | 134 | if ( item->option == "R" ) |
135 | type = tr( "(ReInstall)" ); | 135 | type = tr( "(ReInstall)" ); |
136 | else | 136 | else |
137 | type = tr( "(Upgrade)" ); | 137 | type = tr( "(Upgrade)" ); |
138 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); | 138 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); | 142 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
143 | 143 | ||
144 | displayAvailableSpace( destination->currentText() ); | 144 | displayAvailableSpace( destination->currentText() ); |
145 | } | 145 | } |
146 | 146 | ||
147 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) | 147 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) |
148 | : QWidget( 0, 0, 0 ) | 148 | : QWidget( 0, 0, 0 ) |
149 | { | 149 | { |
150 | setCaption( title ); | 150 | setCaption( title ); |
151 | init( FALSE ); | 151 | init( FALSE ); |
152 | pIpkg = ipkg; | 152 | pIpkg = ipkg; |
153 | output->setText( initialText ); | 153 | output->setText( initialText ); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | InstallDlgImpl::~InstallDlgImpl() | 157 | InstallDlgImpl::~InstallDlgImpl() |
158 | { | 158 | { |
159 | if ( pIpkg ) | 159 | if ( pIpkg ) |
160 | delete pIpkg; | 160 | delete pIpkg; |
161 | } | 161 | } |
162 | 162 | ||
163 | void InstallDlgImpl :: init( bool displayextrainfo ) | 163 | void InstallDlgImpl :: init( bool displayextrainfo ) |
164 | { | 164 | { |
165 | QGridLayout *layout = new QGridLayout( this ); | 165 | QGridLayout *layout = new QGridLayout( this ); |
166 | layout->setSpacing( 4 ); | 166 | layout->setSpacing( 4 ); |
167 | layout->setMargin( 4 ); | 167 | layout->setMargin( 4 ); |
168 | 168 | ||
169 | if ( displayextrainfo ) | 169 | if ( displayextrainfo ) |
170 | { | 170 | { |
171 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 171 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
172 | layout->addWidget( label, 0, 0 ); | 172 | layout->addWidget( label, 0, 0 ); |
173 | destination = new QComboBox( FALSE, this ); | 173 | destination = new QComboBox( FALSE, this ); |
174 | layout->addWidget( destination, 0, 1 ); | 174 | layout->addWidget( destination, 0, 1 ); |
175 | connect( destination, SIGNAL( highlighted( const QString & ) ), | 175 | connect( destination, SIGNAL( highlighted(const QString&) ), |
176 | this, SLOT( displayAvailableSpace( const QString & ) ) ); | 176 | this, SLOT( displayAvailableSpace(const QString&) ) ); |
177 | 177 | ||
178 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | 178 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); |
179 | layout->addWidget( label2, 1, 0 ); | 179 | layout->addWidget( label2, 1, 0 ); |
180 | txtAvailableSpace = new QLabel( "", this ); | 180 | txtAvailableSpace = new QLabel( "", this ); |
181 | layout->addWidget( txtAvailableSpace, 1, 1 ); | 181 | layout->addWidget( txtAvailableSpace, 1, 1 ); |
182 | } | 182 | } |
183 | else | 183 | else |
184 | { | 184 | { |
185 | destination = 0x0; | 185 | destination = 0x0; |
186 | txtAvailableSpace = 0x0; | 186 | txtAvailableSpace = 0x0; |
187 | } | 187 | } |
188 | 188 | ||
189 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 189 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
190 | GroupBox2->layout()->setSpacing( 0 ); | 190 | GroupBox2->layout()->setSpacing( 0 ); |
191 | GroupBox2->layout()->setMargin( 4 ); | 191 | GroupBox2->layout()->setMargin( 4 ); |
192 | 192 | ||
193 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | 193 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); |
194 | output = new QMultiLineEdit( GroupBox2 ); | 194 | output = new QMultiLineEdit( GroupBox2 ); |
195 | GroupBox2Layout->addWidget( output ); | 195 | GroupBox2Layout->addWidget( output ); |
196 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | 196 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); |
197 | 197 | ||
198 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | 198 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); |
199 | layout->addWidget( btnInstall, 3, 0 ); | 199 | layout->addWidget( btnInstall, 3, 0 ); |
200 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | 200 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); |
201 | 201 | ||
202 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 202 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
203 | layout->addWidget( btnOptions, 3, 1 ); | 203 | layout->addWidget( btnOptions, 3, 1 ); |
204 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | 204 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); |
205 | } | 205 | } |
206 | 206 | ||
207 | void InstallDlgImpl :: optionsSelected() | 207 | void InstallDlgImpl :: optionsSelected() |
208 | { | 208 | { |
209 | if ( btnOptions->text() == tr( "Options" ) ) | 209 | if ( btnOptions->text() == tr( "Options" ) ) |
210 | { | 210 | { |
211 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); | 211 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); |
212 | if ( opt.exec() == QDialog::Accepted ) | 212 | if ( opt.exec() == QDialog::Accepted ) |
213 | { | 213 | { |
214 | // set options selected from dialog | 214 | // set options selected from dialog |
215 | flags = opt.getFlags(); | 215 | flags = opt.getFlags(); |
216 | infoLevel = opt.getInfoLevel(); | 216 | infoLevel = opt.getInfoLevel(); |
217 | 217 | ||
218 | #ifdef QWS | 218 | #ifdef QWS |
219 | Config cfg( "aqpkg" ); | 219 | Config cfg( "aqpkg" ); |
220 | cfg.setGroup( "settings" ); | 220 | cfg.setGroup( "settings" ); |
221 | cfg.writeEntry( "installFlags", flags ); | 221 | cfg.writeEntry( "installFlags", flags ); |
222 | cfg.writeEntry( "infoLevel", infoLevel ); | 222 | cfg.writeEntry( "infoLevel", infoLevel ); |
223 | #endif | 223 | #endif |
224 | } | 224 | } |
225 | } | 225 | } |
226 | else // Save output | 226 | else // Save output |
227 | { | 227 | { |
228 | QMap<QString, QStringList> map; | 228 | QMap<QString, QStringList> map; |
229 | map.insert( tr( "All" ), QStringList() ); | 229 | map.insert( tr( "All" ), QStringList() ); |
230 | QStringList text; | 230 | QStringList text; |
231 | text << "text/*"; | 231 | text << "text/*"; |
232 | map.insert(tr( "Text" ), text ); | 232 | map.insert(tr( "Text" ), text ); |
233 | text << "*"; | 233 | text << "*"; |
234 | map.insert( tr( "All" ), text ); | 234 | map.insert( tr( "All" ), text ); |
235 | 235 | ||
236 | QString filename = Opie::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 236 | QString filename = Opie::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
237 | if( !filename.isEmpty() ) | 237 | if( !filename.isEmpty() ) |
238 | { | 238 | { |
239 | QString currentFileName = QFileInfo( filename ).fileName(); | 239 | QString currentFileName = QFileInfo( filename ).fileName(); |
240 | DocLnk doc; | 240 | DocLnk doc; |
241 | doc.setType( "text/plain" ); | 241 | doc.setType( "text/plain" ); |
242 | doc.setFile( filename ); | 242 | doc.setFile( filename ); |
243 | doc.setName( currentFileName ); | 243 | doc.setName( currentFileName ); |
244 | FileManager fm; | 244 | FileManager fm; |
245 | fm.saveFile( doc, output->text() ); | 245 | fm.saveFile( doc, output->text() ); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void InstallDlgImpl :: installSelected() | 250 | void InstallDlgImpl :: installSelected() |
251 | { | 251 | { |
252 | if ( btnInstall->text() == tr( "Abort" ) ) | 252 | if ( btnInstall->text() == tr( "Abort" ) ) |
253 | { | 253 | { |
254 | if ( pIpkg ) | 254 | if ( pIpkg ) |
255 | { | 255 | { |
256 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); | 256 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
257 | pIpkg->abort(); | 257 | pIpkg->abort(); |
258 | displayText( tr( "**** Process Aborted ****" ) ); | 258 | displayText( tr( "**** Process Aborted ****" ) ); |
259 | } | 259 | } |
260 | 260 | ||
261 | btnInstall->setText( tr( "Close" ) ); | 261 | btnInstall->setText( tr( "Close" ) ); |
262 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 262 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | else if ( btnInstall->text() == tr( "Close" ) ) | 265 | else if ( btnInstall->text() == tr( "Close" ) ) |
266 | { | 266 | { |
267 | emit reloadData( this ); | 267 | emit reloadData( this ); |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | 270 | ||
271 | // Disable buttons | 271 | // Disable buttons |
272 | btnOptions->setEnabled( false ); | 272 | btnOptions->setEnabled( false ); |
273 | // btnInstall->setEnabled( false ); | 273 | // btnInstall->setEnabled( false ); |
274 | 274 | ||
275 | btnInstall->setText( tr( "Abort" ) ); | 275 | btnInstall->setText( tr( "Abort" ) ); |
276 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | 276 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); |
277 | 277 | ||
278 | if ( pIpkg ) | 278 | if ( pIpkg ) |
279 | { | 279 | { |
280 | output->setText( "" ); | 280 | output->setText( "" ); |
281 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 281 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
282 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 282 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
283 | pIpkg->runIpkg(); | 283 | pIpkg->runIpkg(); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | { | 286 | { |
287 | output->setText( "" ); | 287 | output->setText( "" ); |
288 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 288 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
289 | QString dest = d->getDestinationName(); | 289 | QString dest = d->getDestinationName(); |
290 | QString destDir = d->getDestinationPath(); | 290 | QString destDir = d->getDestinationPath(); |
291 | int instFlags = flags; | 291 | int instFlags = flags; |
292 | if ( d->linkToRoot() ) | 292 | if ( d->linkToRoot() ) |
293 | instFlags |= MAKE_LINKS; | 293 | instFlags |= MAKE_LINKS; |
294 | 294 | ||
295 | #ifdef QWS | 295 | #ifdef QWS |
296 | // Save settings | 296 | // Save settings |
297 | Config cfg( "aqpkg" ); | 297 | Config cfg( "aqpkg" ); |
298 | cfg.setGroup( "settings" ); | 298 | cfg.setGroup( "settings" ); |
299 | cfg.writeEntry( "dest", dest ); | 299 | cfg.writeEntry( "dest", dest ); |
300 | #endif | 300 | #endif |
301 | 301 | ||
302 | pIpkg = new Ipkg; | 302 | pIpkg = new Ipkg; |
303 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 303 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
304 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 304 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
305 | 305 | ||
306 | firstPackage = TRUE; | 306 | firstPackage = TRUE; |
307 | ipkgFinished(); | 307 | ipkgFinished(); |
308 | 308 | ||
309 | // First run through the remove list, then the install list then the upgrade list | 309 | // First run through the remove list, then the install list then the upgrade list |
310 | /* | 310 | /* |
311 | pIpkg->setOption( "remove" ); | 311 | pIpkg->setOption( "remove" ); |
312 | QListIterator<InstallData> it( removeList ); | 312 | QListIterator<InstallData> it( removeList ); |
313 | InstallData *idata; | 313 | InstallData *idata; |
314 | for ( ; it.current(); ++it ) | 314 | for ( ; it.current(); ++it ) |
315 | { | 315 | { |
316 | idata = it.current(); | 316 | idata = it.current(); |
317 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 317 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
318 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 318 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
319 | pIpkg->setPackage( idata->packageName ); | 319 | pIpkg->setPackage( idata->packageName ); |
320 | 320 | ||
321 | int tmpFlags = flags; | 321 | int tmpFlags = flags; |
322 | if ( idata->destination->linkToRoot() ) | 322 | if ( idata->destination->linkToRoot() ) |
323 | tmpFlags |= MAKE_LINKS; | 323 | tmpFlags |= MAKE_LINKS; |
324 | 324 | ||
325 | pIpkg->setFlags( tmpFlags, infoLevel ); | 325 | pIpkg->setFlags( tmpFlags, infoLevel ); |
326 | pIpkg->runIpkg(); | 326 | pIpkg->runIpkg(); |
327 | } | 327 | } |
328 | 328 | ||
329 | pIpkg->setOption( "install" ); | 329 | pIpkg->setOption( "install" ); |
330 | pIpkg->setDestination( dest ); | 330 | pIpkg->setDestination( dest ); |
331 | pIpkg->setDestinationDir( destDir ); | 331 | pIpkg->setDestinationDir( destDir ); |
332 | pIpkg->setFlags( instFlags, infoLevel ); | 332 | pIpkg->setFlags( instFlags, infoLevel ); |
333 | QListIterator<InstallData> it2( installList ); | 333 | QListIterator<InstallData> it2( installList ); |
334 | for ( ; it2.current(); ++it2 ) | 334 | for ( ; it2.current(); ++it2 ) |
335 | { | 335 | { |
336 | pIpkg->setPackage( it2.current()->packageName ); | 336 | pIpkg->setPackage( it2.current()->packageName ); |
337 | pIpkg->runIpkg(); | 337 | pIpkg->runIpkg(); |
338 | } | 338 | } |
339 | 339 | ||
340 | flags |= FORCE_REINSTALL; | 340 | flags |= FORCE_REINSTALL; |
341 | QListIterator<InstallData> it3( updateList ); | 341 | QListIterator<InstallData> it3( updateList ); |
342 | for ( ; it3.current() ; ++it3 ) | 342 | for ( ; it3.current() ; ++it3 ) |
343 | { | 343 | { |
344 | idata = it3.current(); | 344 | idata = it3.current(); |
345 | if ( idata->option == "R" ) | 345 | if ( idata->option == "R" ) |
346 | pIpkg->setOption( "reinstall" ); | 346 | pIpkg->setOption( "reinstall" ); |
347 | else | 347 | else |
348 | pIpkg->setOption( "upgrade" ); | 348 | pIpkg->setOption( "upgrade" ); |
349 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 349 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
350 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 350 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
351 | pIpkg->setPackage( idata->packageName ); | 351 | pIpkg->setPackage( idata->packageName ); |
352 | 352 | ||
353 | int tmpFlags = flags; | 353 | int tmpFlags = flags; |
354 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) | 354 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) |
355 | tmpFlags |= MAKE_LINKS; | 355 | tmpFlags |= MAKE_LINKS; |
356 | pIpkg->setFlags( tmpFlags, infoLevel ); | 356 | pIpkg->setFlags( tmpFlags, infoLevel ); |
357 | pIpkg->runIpkg(); | 357 | pIpkg->runIpkg(); |
358 | } | 358 | } |
359 | 359 | ||
360 | delete pIpkg; | 360 | delete pIpkg; |
361 | pIpkg = 0; | 361 | pIpkg = 0; |
362 | */ | 362 | */ |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | 366 | ||
367 | void InstallDlgImpl :: displayText(const QString &text ) | 367 | void InstallDlgImpl :: displayText(const QString &text ) |
368 | { | 368 | { |
369 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); | 369 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
370 | 370 | ||
371 | /* Set a max line count for the QMultiLineEdit, as users have reported | 371 | /* Set a max line count for the QMultiLineEdit, as users have reported |
372 | * performance issues when line count gets extreme. | 372 | * performance issues when line count gets extreme. |
373 | */ | 373 | */ |
374 | if(output->numLines() >= MAXLINES) | 374 | if(output->numLines() >= MAXLINES) |
375 | output->removeLine(0); | 375 | output->removeLine(0); |
376 | output->setText( newtext ); | 376 | output->setText( newtext ); |
377 | output->setCursorPosition( output->numLines(), 0 ); | 377 | output->setCursorPosition( output->numLines(), 0 ); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 381 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
382 | { | 382 | { |
383 | Destination *d = dataMgr->getDestination( text ); | 383 | Destination *d = dataMgr->getDestination( text ); |
384 | QString destDir = d->getDestinationPath(); | 384 | QString destDir = d->getDestinationPath(); |
385 | 385 | ||
386 | long blockSize = 0; | 386 | long blockSize = 0; |
387 | long totalBlocks = 0; | 387 | long totalBlocks = 0; |
388 | long availBlocks = 0; | 388 | long availBlocks = 0; |
389 | QString space; | 389 | QString space; |
390 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | 390 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) |
391 | { | 391 | { |
392 | long mult = blockSize / 1024; | 392 | long mult = blockSize / 1024; |
393 | long div = 1024 / blockSize; | 393 | long div = 1024 / blockSize; |
394 | 394 | ||
395 | if ( !mult ) mult = 1; | 395 | if ( !mult ) mult = 1; |
396 | if ( !div ) div = 1; | 396 | if ( !div ) div = 1; |
397 | long avail = availBlocks * mult / div; | 397 | long avail = availBlocks * mult / div; |
398 | 398 | ||
399 | space = tr( "%1 Kb" ).arg( avail ); | 399 | space = tr( "%1 Kb" ).arg( avail ); |
400 | } | 400 | } |
401 | else | 401 | else |
402 | space = tr( "Unknown" ); | 402 | space = tr( "Unknown" ); |
403 | 403 | ||
404 | if ( txtAvailableSpace ) | 404 | if ( txtAvailableSpace ) |
405 | txtAvailableSpace->setText( space ); | 405 | txtAvailableSpace->setText( space ); |
406 | } | 406 | } |
407 | 407 | ||
408 | void InstallDlgImpl :: ipkgFinished() | 408 | void InstallDlgImpl :: ipkgFinished() |
409 | { | 409 | { |
410 | InstallData *item; | 410 | InstallData *item; |
411 | if ( firstPackage ) | 411 | if ( firstPackage ) |
412 | item = packages.first(); | 412 | item = packages.first(); |
413 | else | 413 | else |
414 | { | 414 | { |
415 | // Create symlinks if necessary before moving on to next package | 415 | // Create symlinks if necessary before moving on to next package |
416 | pIpkg->createSymLinks(); | 416 | pIpkg->createSymLinks(); |
417 | 417 | ||
418 | item = packages.next(); | 418 | item = packages.next(); |
419 | } | 419 | } |
420 | 420 | ||
421 | firstPackage = FALSE; | 421 | firstPackage = FALSE; |
422 | if ( item ) | 422 | if ( item ) |
423 | { | 423 | { |
424 | pIpkg->setPackage( item->packageName ); | 424 | pIpkg->setPackage( item->packageName ); |
425 | int tmpFlags = flags; | 425 | int tmpFlags = flags; |
426 | 426 | ||
427 | if ( item->option == "I" ) | 427 | if ( item->option == "I" ) |
428 | { | 428 | { |
429 | pIpkg->setOption( "install" ); | 429 | pIpkg->setOption( "install" ); |
430 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 430 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
431 | pIpkg->setDestination( d->getDestinationName() ); | 431 | pIpkg->setDestination( d->getDestinationName() ); |
432 | pIpkg->setDestinationDir( d->getDestinationPath() ); | 432 | pIpkg->setDestinationDir( d->getDestinationPath() ); |
433 | 433 | ||
434 | if ( d->linkToRoot() ) | 434 | if ( d->linkToRoot() ) |
435 | tmpFlags |= MAKE_LINKS; | 435 | tmpFlags |= MAKE_LINKS; |
436 | } | 436 | } |
437 | else if ( item->option == "D" ) | 437 | else if ( item->option == "D" ) |
438 | { | 438 | { |
439 | pIpkg->setOption( "remove" ); | 439 | pIpkg->setOption( "remove" ); |
440 | pIpkg->setDestination( item->destination->getDestinationName() ); | 440 | pIpkg->setDestination( item->destination->getDestinationName() ); |
441 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); | 441 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); |
442 | 442 | ||
443 | if ( item->destination->linkToRoot() ) | 443 | if ( item->destination->linkToRoot() ) |
444 | tmpFlags |= MAKE_LINKS; | 444 | tmpFlags |= MAKE_LINKS; |
445 | } | 445 | } |
446 | else | 446 | else |
447 | { | 447 | { |
448 | if ( item->option == "R" ) | 448 | if ( item->option == "R" ) |
449 | pIpkg->setOption( "reinstall" ); | 449 | pIpkg->setOption( "reinstall" ); |
450 | else | 450 | else |
451 | pIpkg->setOption( "upgrade" ); | 451 | pIpkg->setOption( "upgrade" ); |
452 | 452 | ||
453 | pIpkg->setDestination( item->destination->getDestinationName() ); | 453 | pIpkg->setDestination( item->destination->getDestinationName() ); |
454 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); | 454 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); |
455 | pIpkg->setPackage( item->packageName ); | 455 | pIpkg->setPackage( item->packageName ); |
456 | 456 | ||
457 | tmpFlags |= FORCE_REINSTALL; | 457 | tmpFlags |= FORCE_REINSTALL; |
458 | if ( item->destination->linkToRoot() && item->recreateLinks ) | 458 | if ( item->destination->linkToRoot() && item->recreateLinks ) |
459 | tmpFlags |= MAKE_LINKS; | 459 | tmpFlags |= MAKE_LINKS; |
460 | } | 460 | } |
461 | pIpkg->setFlags( tmpFlags, infoLevel ); | 461 | pIpkg->setFlags( tmpFlags, infoLevel ); |
462 | pIpkg->runIpkg(); | 462 | pIpkg->runIpkg(); |
463 | } | 463 | } |
464 | else | 464 | else |
465 | { | 465 | { |
466 | btnOptions->setEnabled( true ); | 466 | btnOptions->setEnabled( true ); |
467 | btnInstall->setText( tr( "Close" ) ); | 467 | btnInstall->setText( tr( "Close" ) ); |
468 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 468 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
469 | 469 | ||
470 | btnOptions->setText( tr( "Save output" ) ); | 470 | btnOptions->setText( tr( "Save output" ) ); |
471 | btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 471 | btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); |
472 | 472 | ||
473 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) | 473 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) |
474 | displayAvailableSpace( destination->currentText() ); | 474 | displayAvailableSpace( destination->currentText() ); |
475 | } | 475 | } |
476 | } | 476 | } |
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 3761b67..866afed 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -1,520 +1,520 @@ | |||
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 | Ipkg :: Ipkg() | 45 | Ipkg :: Ipkg() |
46 | { | 46 | { |
47 | proc = 0; | 47 | proc = 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | Ipkg :: ~Ipkg() | 50 | Ipkg :: ~Ipkg() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | // Option is what we are going to do - install, upgrade, download, reinstall | 54 | // 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 | 55 | // 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) | 56 | // 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 | 57 | // packageName is the package name - (for a network package this will be the same as |
58 | // package parameter) | 58 | // package parameter) |
59 | // dest is the destination alias (from ipk.conf) | 59 | // dest is the destination alias (from ipk.conf) |
60 | // destDir is the dir that the destination alias points to (used to link to root) | 60 | // destDir is the dir that the destination alias points to (used to link to root) |
61 | // flags is the ipkg options flags | 61 | // flags is the ipkg options flags |
62 | // dir is the directory to run ipkg in (defaults to "") | 62 | // dir is the directory to run ipkg in (defaults to "") |
63 | void Ipkg :: runIpkg() | 63 | void Ipkg :: runIpkg() |
64 | { | 64 | { |
65 | error = false; | 65 | error = false; |
66 | QStringList commands; | 66 | QStringList commands; |
67 | 67 | ||
68 | QDir::setCurrent( "/tmp" ); | 68 | QDir::setCurrent( "/tmp" ); |
69 | 69 | ||
70 | if ( runtimeDir != "" ) | 70 | if ( runtimeDir != "" ) |
71 | { | 71 | { |
72 | commands << "cd "; | 72 | commands << "cd "; |
73 | commands << runtimeDir; | 73 | commands << runtimeDir; |
74 | commands << ";"; | 74 | commands << ";"; |
75 | } | 75 | } |
76 | commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; | 76 | commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; |
77 | 77 | ||
78 | // only set the destination for an install operation | 78 | // only set the destination for an install operation |
79 | if ( option == "install" ) | 79 | if ( option == "install" ) |
80 | commands << "-dest" << destination; | 80 | commands << "-dest" << destination; |
81 | 81 | ||
82 | 82 | ||
83 | if ( option != "update" && option != "download" ) | 83 | if ( option != "update" && option != "download" ) |
84 | { | 84 | { |
85 | if ( flags & FORCE_DEPENDS ) | 85 | if ( flags & FORCE_DEPENDS ) |
86 | commands << "-force-depends"; | 86 | commands << "-force-depends"; |
87 | if ( flags & FORCE_REINSTALL ) | 87 | if ( flags & FORCE_REINSTALL ) |
88 | commands << "-force-reinstall"; | 88 | commands << "-force-reinstall"; |
89 | if ( flags & FORCE_REMOVE ) | 89 | if ( flags & FORCE_REMOVE ) |
90 | commands << "-force-removal-of-essential-packages"; | 90 | commands << "-force-removal-of-essential-packages"; |
91 | if ( flags & FORCE_OVERWRITE ) | 91 | if ( flags & FORCE_OVERWRITE ) |
92 | commands << "-force-overwrite"; | 92 | commands << "-force-overwrite"; |
93 | if ( infoLevel == 3 ) | 93 | if ( infoLevel == 3 ) |
94 | commands << "-verbose_wget"; | 94 | commands << "-verbose_wget"; |
95 | 95 | ||
96 | // Handle make links | 96 | // Handle make links |
97 | // Rules - If make links is switched on, create links to root | 97 | // Rules - If make links is switched on, create links to root |
98 | // if destDir is NOT / | 98 | // if destDir is NOT / |
99 | if ( flags & MAKE_LINKS ) | 99 | if ( flags & MAKE_LINKS ) |
100 | { | 100 | { |
101 | // If destDir == / turn off make links as package is being insalled | 101 | // If destDir == / turn off make links as package is being insalled |
102 | // to root already. | 102 | // to root already. |
103 | if ( destDir == "/" ) | 103 | if ( destDir == "/" ) |
104 | flags ^= MAKE_LINKS; | 104 | flags ^= MAKE_LINKS; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | #ifdef X86 | 108 | #ifdef X86 |
109 | commands << "-f"; | 109 | commands << "-f"; |
110 | commands << IPKG_CONF; | 110 | commands << IPKG_CONF; |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | 113 | ||
114 | if ( option == "reinstall" ) | 114 | if ( option == "reinstall" ) |
115 | commands << "install"; | 115 | commands << "install"; |
116 | else | 116 | else |
117 | commands << option; | 117 | commands << option; |
118 | if ( package != "" ) | 118 | if ( package != "" ) |
119 | commands << package; | 119 | commands << package; |
120 | 120 | ||
121 | 121 | ||
122 | if ( package != "" ) | 122 | if ( package != "" ) |
123 | emit outputText( tr( "Dealing with package %1" ).arg( package) ); | 123 | emit outputText( tr( "Dealing with package %1" ).arg( package) ); |
124 | 124 | ||
125 | qApp->processEvents(); | 125 | qApp->processEvents(); |
126 | 126 | ||
127 | // If we are removing, reinstalling or upgrading packages and make links option is selected | 127 | // If we are removing, reinstalling or upgrading packages and make links option is selected |
128 | // create the links | 128 | // create the links |
129 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) | 129 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) |
130 | { | 130 | { |
131 | createLinks = false; | 131 | createLinks = false; |
132 | if ( flags & MAKE_LINKS ) | 132 | if ( flags & MAKE_LINKS ) |
133 | { | 133 | { |
134 | emit outputText( tr( "Removing symbolic links...\n" ) ); | 134 | emit outputText( tr( "Removing symbolic links...\n" ) ); |
135 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 135 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
136 | emit outputText( QString( " " ) ); | 136 | emit outputText( QString( " " ) ); |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | // Execute command | 140 | // Execute command |
141 | dependantPackages = new QList<QString>; | 141 | dependantPackages = new QList<QString>; |
142 | dependantPackages->setAutoDelete( true ); | 142 | dependantPackages->setAutoDelete( true ); |
143 | 143 | ||
144 | executeIpkgCommand( commands, option ); | 144 | executeIpkgCommand( commands, option ); |
145 | 145 | ||
146 | } | 146 | } |
147 | 147 | ||
148 | void Ipkg :: createSymLinks() | 148 | void Ipkg :: createSymLinks() |
149 | { | 149 | { |
150 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) | 150 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) |
151 | { | 151 | { |
152 | // If we are not removing packages and make links option is selected | 152 | // If we are not removing packages and make links option is selected |
153 | // create the links | 153 | // create the links |
154 | createLinks = true; | 154 | createLinks = true; |
155 | if ( flags & MAKE_LINKS ) | 155 | if ( flags & MAKE_LINKS ) |
156 | { | 156 | { |
157 | emit outputText( " " ); | 157 | emit outputText( " " ); |
158 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); | 158 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); |
159 | 159 | ||
160 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 160 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
161 | 161 | ||
162 | // link dependant packages that were installed with this release | 162 | // link dependant packages that were installed with this release |
163 | QString *pkg; | 163 | QString *pkg; |
164 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) | 164 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) |
165 | { | 165 | { |
166 | if ( *pkg == package ) | 166 | if ( *pkg == package ) |
167 | continue; | 167 | continue; |
168 | emit outputText( " " ); | 168 | emit outputText( " " ); |
169 | emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) ); | 169 | emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) ); |
170 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); | 170 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | delete dependantPackages; | 175 | delete dependantPackages; |
176 | 176 | ||
177 | emit outputText( tr("Finished") ); | 177 | emit outputText( tr("Finished") ); |
178 | emit outputText( "" ); | 178 | emit outputText( "" ); |
179 | } | 179 | } |
180 | 180 | ||
181 | void Ipkg :: removeStatusEntry() | 181 | void Ipkg :: removeStatusEntry() |
182 | { | 182 | { |
183 | QString statusFile = destDir; | 183 | QString statusFile = destDir; |
184 | if ( statusFile.right( 1 ) != "/" ) | 184 | if ( statusFile.right( 1 ) != "/" ) |
185 | statusFile.append( "/" ); | 185 | statusFile.append( "/" ); |
186 | statusFile.append( "usr/lib/ipkg/status" ); | 186 | statusFile.append( "usr/lib/ipkg/status" ); |
187 | QString outStatusFile = statusFile; | 187 | QString outStatusFile = statusFile; |
188 | outStatusFile.append( ".tmp" ); | 188 | outStatusFile.append( ".tmp" ); |
189 | 189 | ||
190 | emit outputText( "" ); | 190 | emit outputText( "" ); |
191 | emit outputText( tr("Removing status entry...") ); | 191 | emit outputText( tr("Removing status entry...") ); |
192 | QString tempstr = tr("status file - "); | 192 | QString tempstr = tr("status file - "); |
193 | tempstr.append( statusFile ); | 193 | tempstr.append( statusFile ); |
194 | emit outputText( tempstr ); | 194 | emit outputText( tempstr ); |
195 | tempstr = tr("package - "); | 195 | tempstr = tr("package - "); |
196 | tempstr.append( package ); | 196 | tempstr.append( package ); |
197 | emit outputText( tempstr ); | 197 | emit outputText( tempstr ); |
198 | 198 | ||
199 | QFile readFile( statusFile ); | 199 | QFile readFile( statusFile ); |
200 | QFile writeFile( outStatusFile ); | 200 | QFile writeFile( outStatusFile ); |
201 | 201 | ||
202 | if ( !readFile.open( IO_ReadOnly ) ) | 202 | if ( !readFile.open( IO_ReadOnly ) ) |
203 | { | 203 | { |
204 | tempstr = tr("Couldn't open status file - "); | 204 | tempstr = tr("Couldn't open status file - "); |
205 | tempstr.append( statusFile ); | 205 | tempstr.append( statusFile ); |
206 | emit outputText( tempstr ); | 206 | emit outputText( tempstr ); |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | 209 | ||
210 | if ( !writeFile.open( IO_WriteOnly ) ) | 210 | if ( !writeFile.open( IO_WriteOnly ) ) |
211 | { | 211 | { |
212 | tempstr = tr("Couldn't create tempory status file - "); | 212 | tempstr = tr("Couldn't create tempory status file - "); |
213 | tempstr.append( outStatusFile ); | 213 | tempstr.append( outStatusFile ); |
214 | emit outputText( tempstr ); | 214 | emit outputText( tempstr ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | int i = 0; | 218 | int i = 0; |
219 | 219 | ||
220 | QTextStream readStream( &readFile ); | 220 | QTextStream readStream( &readFile ); |
221 | QTextStream writeStream( &writeFile ); | 221 | QTextStream writeStream( &writeFile ); |
222 | QString line; | 222 | QString line; |
223 | 223 | ||
224 | char k[21]; | 224 | char k[21]; |
225 | char v[1001]; | 225 | char v[1001]; |
226 | QString key; | 226 | QString key; |
227 | QString value; | 227 | QString value; |
228 | 228 | ||
229 | while ( !readStream.atEnd() ) | 229 | while ( !readStream.atEnd() ) |
230 | { | 230 | { |
231 | //read new line | 231 | //read new line |
232 | line = readStream.readLine(); | 232 | line = readStream.readLine(); |
233 | 233 | ||
234 | if ( line.contains( ":", TRUE ) ) | 234 | if ( line.contains( ":", TRUE ) ) |
235 | { | 235 | { |
236 | //grep key and value from line | 236 | //grep key and value from line |
237 | k[0] = '\0'; | 237 | k[0] = '\0'; |
238 | v[0] = '\0'; | 238 | v[0] = '\0'; |
239 | sscanf( line, "%[^:]: %[^\n]", k, v ); | 239 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
240 | key = k; | 240 | key = k; |
241 | value = v; | 241 | value = v; |
242 | key = key.stripWhiteSpace(); | 242 | key = key.stripWhiteSpace(); |
243 | value = value.stripWhiteSpace(); | 243 | value = value.stripWhiteSpace(); |
244 | } else { | 244 | } else { |
245 | key = ""; | 245 | key = ""; |
246 | value = ""; | 246 | value = ""; |
247 | } | 247 | } |
248 | 248 | ||
249 | if ( key == "Package" && value == package ) | 249 | if ( key == "Package" && value == package ) |
250 | { | 250 | { |
251 | //skip lines from the deleted package | 251 | //skip lines from the deleted package |
252 | while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) ) | 252 | while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) ) |
253 | { | 253 | { |
254 | line = readStream.readLine(); | 254 | line = readStream.readLine(); |
255 | } | 255 | } |
256 | } else { | 256 | } else { |
257 | 257 | ||
258 | //write other lines into the tempfile | 258 | //write other lines into the tempfile |
259 | writeStream << line << "\n"; | 259 | writeStream << line << "\n"; |
260 | 260 | ||
261 | // Improve UI responsiveness | 261 | // Improve UI responsiveness |
262 | i++; | 262 | i++; |
263 | if ( ( i % 50 ) == 0 ) | 263 | if ( ( i % 50 ) == 0 ) |
264 | qApp->processEvents(); | 264 | qApp->processEvents(); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | readFile.close(); | 268 | readFile.close(); |
269 | writeFile.close(); | 269 | writeFile.close(); |
270 | 270 | ||
271 | // Remove old status file and put tmp stats file in its place | 271 | // Remove old status file and put tmp stats file in its place |
272 | remove( statusFile ); | 272 | remove( statusFile ); |
273 | rename( outStatusFile, statusFile ); | 273 | rename( outStatusFile, statusFile ); |
274 | } | 274 | } |
275 | 275 | ||
276 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | 276 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) |
277 | { | 277 | { |
278 | // If one is already running - should never be but just to be safe | 278 | // If one is already running - should never be but just to be safe |
279 | if ( proc ) | 279 | if ( proc ) |
280 | { | 280 | { |
281 | delete proc; | 281 | delete proc; |
282 | proc = 0; | 282 | proc = 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | // OK we're gonna use OProcess to run this thing | 285 | // OK we're gonna use OProcess to run this thing |
286 | proc = new OProcess(); | 286 | proc = new OProcess(); |
287 | aborted = false; | 287 | aborted = false; |
288 | 288 | ||
289 | 289 | ||
290 | // Connect up our slots | 290 | // Connect up our slots |
291 | connect(proc, SIGNAL(processExited(OProcess *)), | 291 | connect(proc, SIGNAL(processExited(OProcess*)), |
292 | this, SLOT( processFinished())); | 292 | this, SLOT( processFinished())); |
293 | 293 | ||
294 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 294 | connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), |
295 | this, SLOT(commandStdout(OProcess *, char *, int))); | 295 | this, SLOT(commandStdout(OProcess*,char*,int))); |
296 | 296 | ||
297 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 297 | connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), |
298 | this, SLOT(commandStderr(OProcess *, char *, int))); | 298 | this, SLOT(commandStderr(OProcess*,char*,int))); |
299 | 299 | ||
300 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) | 300 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) |
301 | { | 301 | { |
302 | *proc << (*it).latin1(); | 302 | *proc << (*it).latin1(); |
303 | } | 303 | } |
304 | 304 | ||
305 | // Start the process going | 305 | // Start the process going |
306 | finished = false; | 306 | finished = false; |
307 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) | 307 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) |
308 | { | 308 | { |
309 | emit outputText( tr("Couldn't start ipkg process" ) ); | 309 | emit outputText( tr("Couldn't start ipkg process" ) ); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | 313 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) |
314 | { | 314 | { |
315 | QString lineStr = buffer; | 315 | QString lineStr = buffer; |
316 | if ( lineStr[buflen-1] == '\n' ) | 316 | if ( lineStr[buflen-1] == '\n' ) |
317 | buflen --; | 317 | buflen --; |
318 | lineStr = lineStr.left( buflen ); | 318 | lineStr = lineStr.left( buflen ); |
319 | emit outputText( lineStr ); | 319 | emit outputText( lineStr ); |
320 | 320 | ||
321 | // check if we are installing dependant packages | 321 | // check if we are installing dependant packages |
322 | if ( option == "install" || option == "reinstall" ) | 322 | if ( option == "install" || option == "reinstall" ) |
323 | { | 323 | { |
324 | // Need to keep track of any dependant packages that get installed | 324 | // Need to keep track of any dependant packages that get installed |
325 | // so that we can create links to them as necessary | 325 | // so that we can create links to them as necessary |
326 | if ( lineStr.startsWith( "Installing " ) ) | 326 | if ( lineStr.startsWith( "Installing " ) ) |
327 | { | 327 | { |
328 | int start = lineStr.find( " " ) + 1; | 328 | int start = lineStr.find( " " ) + 1; |
329 | int end = lineStr.find( " ", start ); | 329 | int end = lineStr.find( " ", start ); |
330 | QString *package = new QString( lineStr.mid( start, end-start ) ); | 330 | QString *package = new QString( lineStr.mid( start, end-start ) ); |
331 | dependantPackages->append( package ); | 331 | dependantPackages->append( package ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && | 334 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && |
335 | lineStr.find( "is depended upon by packages:" ) != -1 ) | 335 | lineStr.find( "is depended upon by packages:" ) != -1 ) |
336 | { | 336 | { |
337 | // Ipkg should send this to STDERR, but doesn't - so trap here | 337 | // Ipkg should send this to STDERR, but doesn't - so trap here |
338 | error = true; | 338 | error = true; |
339 | } | 339 | } |
340 | 340 | ||
341 | buffer[0] = '\0'; | 341 | buffer[0] = '\0'; |
342 | } | 342 | } |
343 | 343 | ||
344 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) | 344 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) |
345 | { | 345 | { |
346 | QString lineStr = buffer; | 346 | QString lineStr = buffer; |
347 | if ( lineStr[buflen-1] == '\n' ) | 347 | if ( lineStr[buflen-1] == '\n' ) |
348 | buflen --; | 348 | buflen --; |
349 | lineStr=lineStr.left( buflen ); | 349 | lineStr=lineStr.left( buflen ); |
350 | emit outputText( lineStr ); | 350 | emit outputText( lineStr ); |
351 | buffer[0] = '\0'; | 351 | buffer[0] = '\0'; |
352 | error = true; | 352 | error = true; |
353 | } | 353 | } |
354 | 354 | ||
355 | void Ipkg::processFinished() | 355 | void Ipkg::processFinished() |
356 | { | 356 | { |
357 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file | 357 | // 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 | 358 | // to workaround an ipkg bug which stops reinstall to a different location |
359 | 359 | ||
360 | if ( !error && option == "remove" ) | 360 | if ( !error && option == "remove" ) |
361 | removeStatusEntry(); | 361 | removeStatusEntry(); |
362 | 362 | ||
363 | delete proc; | 363 | delete proc; |
364 | proc = 0; | 364 | proc = 0; |
365 | finished = true; | 365 | finished = true; |
366 | 366 | ||
367 | emit ipkgFinished(); | 367 | emit ipkgFinished(); |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
371 | void Ipkg :: abort() | 371 | void Ipkg :: abort() |
372 | { | 372 | { |
373 | if ( proc ) | 373 | if ( proc ) |
374 | { | 374 | { |
375 | proc->kill(); | 375 | proc->kill(); |
376 | aborted = true; | 376 | aborted = true; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) | 380 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) |
381 | { | 381 | { |
382 | if ( dest == "root" || dest == "/" ) | 382 | if ( dest == "root" || dest == "/" ) |
383 | return; | 383 | return; |
384 | 384 | ||
385 | qApp->processEvents(); | 385 | qApp->processEvents(); |
386 | QStringList *fileList = getList( packFileName, destDir ); | 386 | QStringList *fileList = getList( packFileName, destDir ); |
387 | qApp->processEvents(); | 387 | qApp->processEvents(); |
388 | processFileList( fileList, destDir ); | 388 | processFileList( fileList, destDir ); |
389 | delete fileList; | 389 | delete fileList; |
390 | } | 390 | } |
391 | 391 | ||
392 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 392 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) |
393 | { | 393 | { |
394 | QString packageFileDir = destDir; | 394 | QString packageFileDir = destDir; |
395 | packageFileDir.append( "/usr/lib/ipkg/info/" ); | 395 | packageFileDir.append( "/usr/lib/ipkg/info/" ); |
396 | packageFileDir.append( packageFilename ); | 396 | packageFileDir.append( packageFilename ); |
397 | packageFileDir.append( ".list" ); | 397 | packageFileDir.append( ".list" ); |
398 | QFile f( packageFileDir ); | 398 | QFile f( packageFileDir ); |
399 | 399 | ||
400 | if ( !f.open(IO_ReadOnly) ) | 400 | if ( !f.open(IO_ReadOnly) ) |
401 | { | 401 | { |
402 | // Couldn't open from dest, try from / | 402 | // Couldn't open from dest, try from / |
403 | f.close(); | 403 | f.close(); |
404 | 404 | ||
405 | packageFileDir = "/usr/lib/ipkg/info/"; | 405 | packageFileDir = "/usr/lib/ipkg/info/"; |
406 | packageFileDir.append( packageFilename ); | 406 | packageFileDir.append( packageFilename ); |
407 | packageFileDir.append( ".list" ); | 407 | packageFileDir.append( ".list" ); |
408 | f.setName( packageFileDir ); | 408 | f.setName( packageFileDir ); |
409 | if ( ! f.open(IO_ReadOnly) ) | 409 | if ( ! f.open(IO_ReadOnly) ) |
410 | { | 410 | { |
411 | QString tempstr = tr("Could not open :"); | 411 | QString tempstr = tr("Could not open :"); |
412 | tempstr.append( packageFileDir ); | 412 | tempstr.append( packageFileDir ); |
413 | emit outputText( tempstr ); | 413 | emit outputText( tempstr ); |
414 | return (QStringList*)0; | 414 | return (QStringList*)0; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | QStringList *fileList = new QStringList(); | 417 | QStringList *fileList = new QStringList(); |
418 | QTextStream t( &f ); | 418 | QTextStream t( &f ); |
419 | while ( !t.eof() ) | 419 | while ( !t.eof() ) |
420 | *fileList += t.readLine(); | 420 | *fileList += t.readLine(); |
421 | 421 | ||
422 | f.close(); | 422 | f.close(); |
423 | return fileList; | 423 | return fileList; |
424 | } | 424 | } |
425 | 425 | ||
426 | void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) | 426 | void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) |
427 | { | 427 | { |
428 | if ( !fileList || fileList->isEmpty() ) | 428 | if ( !fileList || fileList->isEmpty() ) |
429 | return; | 429 | return; |
430 | 430 | ||
431 | QString baseDir = ROOT; | 431 | QString baseDir = ROOT; |
432 | 432 | ||
433 | if ( createLinks == true ) | 433 | if ( createLinks == true ) |
434 | { | 434 | { |
435 | for ( uint i=0; i < fileList->count(); i++ ) | 435 | for ( uint i=0; i < fileList->count(); i++ ) |
436 | { | 436 | { |
437 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 437 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
438 | qApp->processEvents(); | 438 | qApp->processEvents(); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) | 443 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) |
444 | { | 444 | { |
445 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 445 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
446 | qApp->processEvents(); | 446 | qApp->processEvents(); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) | 451 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) |
452 | { | 452 | { |
453 | 453 | ||
454 | QString sourceFile = baseDir; | 454 | QString sourceFile = baseDir; |
455 | sourceFile.append( file ); | 455 | sourceFile.append( file ); |
456 | 456 | ||
457 | QString linkFile = destDir; | 457 | QString linkFile = destDir; |
458 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) | 458 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) |
459 | { | 459 | { |
460 | linkFile.append( file.mid( 1 ) ); | 460 | linkFile.append( file.mid( 1 ) ); |
461 | } | 461 | } |
462 | else | 462 | else |
463 | { | 463 | { |
464 | linkFile.append( file ); | 464 | linkFile.append( file ); |
465 | } | 465 | } |
466 | QString text; | 466 | QString text; |
467 | if ( createLinks ) | 467 | if ( createLinks ) |
468 | { | 468 | { |
469 | // If this file is a directory (ends with a /) and it doesn't exist, | 469 | // If this file is a directory (ends with a /) and it doesn't exist, |
470 | // we need to create it | 470 | // we need to create it |
471 | if ( file.right(1) == "/" ) | 471 | if ( file.right(1) == "/" ) |
472 | { | 472 | { |
473 | QFileInfo f( linkFile ); | 473 | QFileInfo f( linkFile ); |
474 | if ( !f.exists() ) | 474 | if ( !f.exists() ) |
475 | { | 475 | { |
476 | QString tempstr = tr("Creating directory "); | 476 | QString tempstr = tr("Creating directory "); |
477 | tempstr.append( linkFile ); | 477 | tempstr.append( linkFile ); |
478 | emit outputText( tempstr ); | 478 | emit outputText( tempstr ); |
479 | QDir d; | 479 | QDir d; |
480 | d.mkdir( linkFile, true ); | 480 | d.mkdir( linkFile, true ); |
481 | } | 481 | } |
482 | // else | 482 | // else |
483 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); | 483 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); |
484 | 484 | ||
485 | } | 485 | } |
486 | else | 486 | else |
487 | { | 487 | { |
488 | int rc = symlink( sourceFile, linkFile ); | 488 | int rc = symlink( sourceFile, linkFile ); |
489 | text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ). | 489 | text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ). |
490 | arg( sourceFile ). | 490 | arg( sourceFile ). |
491 | arg( linkFile ); | 491 | arg( linkFile ); |
492 | emit outputText( text ); | 492 | emit outputText( text ); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | else | 495 | else |
496 | { | 496 | { |
497 | QFileInfo f( linkFile ); | 497 | QFileInfo f( linkFile ); |
498 | if ( f.exists() ) | 498 | if ( f.exists() ) |
499 | { | 499 | { |
500 | if ( f.isFile() ) | 500 | if ( f.isFile() ) |
501 | { | 501 | { |
502 | QFile f( linkFile ); | 502 | QFile f( linkFile ); |
503 | bool rc = f.remove(); | 503 | bool rc = f.remove(); |
504 | 504 | ||
505 | text = ( rc ? tr( "Removed %1" ) : tr( "Failed to remove %1" ) ).arg( linkFile ); | 505 | text = ( rc ? tr( "Removed %1" ) : tr( "Failed to remove %1" ) ).arg( linkFile ); |
506 | emit outputText( text ); | 506 | emit outputText( text ); |
507 | } | 507 | } |
508 | else if ( f.isDir() ) | 508 | else if ( f.isDir() ) |
509 | { | 509 | { |
510 | QDir d; | 510 | QDir d; |
511 | bool rc = d.rmdir( linkFile, true ); | 511 | bool rc = d.rmdir( linkFile, true ); |
512 | if ( rc ) | 512 | if ( rc ) |
513 | { | 513 | { |
514 | text = ( rc ? tr( "Removed " ) : tr( "Failed to remove " ) ).arg( linkFile ); | 514 | text = ( rc ? tr( "Removed " ) : tr( "Failed to remove " ) ).arg( linkFile ); |
515 | emit outputText( text ); | 515 | emit outputText( text ); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | } | 518 | } |
519 | } | 519 | } |
520 | } | 520 | } |
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 6f5c712..6b31cd1 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,1244 +1,1244 @@ | |||
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 "categoryfilterimpl.h" | 30 | #include "categoryfilterimpl.h" |
31 | #include "datamgr.h" | 31 | #include "datamgr.h" |
32 | #include "global.h" | 32 | #include "global.h" |
33 | #include "inputdlg.h" | 33 | #include "inputdlg.h" |
34 | #include "ipkg.h" | 34 | #include "ipkg.h" |
35 | #include "installdlgimpl.h" | 35 | #include "installdlgimpl.h" |
36 | #include "letterpushbutton.h" | 36 | #include "letterpushbutton.h" |
37 | #include "mainwin.h" | 37 | #include "mainwin.h" |
38 | #include "packagewin.h" | 38 | #include "packagewin.h" |
39 | #include "settingsimpl.h" | 39 | #include "settingsimpl.h" |
40 | #include "utils.h" | 40 | #include "utils.h" |
41 | 41 | ||
42 | /* OPIE */ | 42 | /* OPIE */ |
43 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qpe/resource.h> | 46 | #include <qpe/resource.h> |
47 | 47 | ||
48 | /* QT */ | 48 | /* QT */ |
49 | #include <qmenubar.h> | 49 | #include <qmenubar.h> |
50 | #include <qtoolbar.h> | 50 | #include <qtoolbar.h> |
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qcombobox.h> | 52 | #include <qcombobox.h> |
53 | #include <qfile.h> | 53 | #include <qfile.h> |
54 | #include <qlabel.h> | 54 | #include <qlabel.h> |
55 | #include <qlayout.h> | 55 | #include <qlayout.h> |
56 | #include <qlineedit.h> | 56 | #include <qlineedit.h> |
57 | #include <qlistview.h> | 57 | #include <qlistview.h> |
58 | #include <qmenubar.h> | 58 | #include <qmenubar.h> |
59 | #include <qmessagebox.h> | 59 | #include <qmessagebox.h> |
60 | #include <qpopupmenu.h> | 60 | #include <qpopupmenu.h> |
61 | #include <qprogressbar.h> | 61 | #include <qprogressbar.h> |
62 | #include <qtimer.h> | 62 | #include <qtimer.h> |
63 | #include <qwhatsthis.h> | 63 | #include <qwhatsthis.h> |
64 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
65 | 65 | ||
66 | /* STD */ | 66 | /* STD */ |
67 | #include <linux/limits.h> | 67 | #include <linux/limits.h> |
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | 69 | ||
70 | extern int compareVersions( const char *v1, const char *v2 ); | 70 | extern int compareVersions( const char *v1, const char *v2 ); |
71 | 71 | ||
72 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) | 72 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) |
73 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) | 73 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
74 | { | 74 | { |
75 | // Disable suspend mode | 75 | // Disable suspend mode |
76 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 76 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
77 | 77 | ||
78 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | 78 | LOCAL_SERVER = QObject::tr( "Installed packages" ); |
79 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | 79 | LOCAL_IPKGS = QObject::tr( "Local packages" ); |
80 | 80 | ||
81 | setCaption( tr( "AQPkg - Package Manager" ) ); | 81 | setCaption( tr( "AQPkg - Package Manager" ) ); |
82 | 82 | ||
83 | // Create UI widgets | 83 | // Create UI widgets |
84 | initMainWidget(); | 84 | initMainWidget(); |
85 | initProgressWidget(); | 85 | initProgressWidget(); |
86 | 86 | ||
87 | // Build menu and tool bars | 87 | // Build menu and tool bars |
88 | setToolBarsMovable( FALSE ); | 88 | setToolBarsMovable( FALSE ); |
89 | 89 | ||
90 | QToolBar *bar = new QToolBar( this ); | 90 | QToolBar *bar = new QToolBar( this ); |
91 | bar->setHorizontalStretchable( TRUE ); | 91 | bar->setHorizontalStretchable( TRUE ); |
92 | QMenuBar *mb = new QMenuBar( bar ); | 92 | QMenuBar *mb = new QMenuBar( bar ); |
93 | mb->setMargin( 0 ); | 93 | mb->setMargin( 0 ); |
94 | bar = new QToolBar( this ); | 94 | bar = new QToolBar( this ); |
95 | 95 | ||
96 | // Find toolbar | 96 | // Find toolbar |
97 | findBar = new QToolBar( this ); | 97 | findBar = new QToolBar( this ); |
98 | addToolBar( findBar, QMainWindow::Top, true ); | 98 | addToolBar( findBar, QMainWindow::Top, true ); |
99 | findBar->setHorizontalStretchable( true ); | 99 | findBar->setHorizontalStretchable( true ); |
100 | findEdit = new QLineEdit( findBar ); | 100 | findEdit = new QLineEdit( findBar ); |
101 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 101 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
102 | findBar->setStretchableWidget( findEdit ); | 102 | findBar->setStretchableWidget( findEdit ); |
103 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 103 | connect( findEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( findPackage(const QString&) ) ); |
104 | 104 | ||
105 | // Quick jump toolbar | 105 | // Quick jump toolbar |
106 | jumpBar = new QToolBar( this ); | 106 | jumpBar = new QToolBar( this ); |
107 | addToolBar( jumpBar, QMainWindow::Top, true ); | 107 | addToolBar( jumpBar, QMainWindow::Top, true ); |
108 | jumpBar->setHorizontalStretchable( true ); | 108 | jumpBar->setHorizontalStretchable( true ); |
109 | QWidget *w = new QWidget( jumpBar ); | 109 | QWidget *w = new QWidget( jumpBar ); |
110 | jumpBar->setStretchableWidget( w ); | 110 | jumpBar->setStretchableWidget( w ); |
111 | 111 | ||
112 | QGridLayout *layout = new QGridLayout( w ); | 112 | QGridLayout *layout = new QGridLayout( w ); |
113 | 113 | ||
114 | char text[2]; | 114 | char text[2]; |
115 | text[1] = '\0'; | 115 | text[1] = '\0'; |
116 | for ( int i = 0 ; i < 26 ; ++i ) | 116 | for ( int i = 0 ; i < 26 ; ++i ) |
117 | { | 117 | { |
118 | text[0] = 'A' + i; | 118 | text[0] = 'A' + i; |
119 | LetterPushButton *b = new LetterPushButton( text, w ); | 119 | LetterPushButton *b = new LetterPushButton( text, w ); |
120 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 120 | connect( b, SIGNAL( released(QString) ), this, SLOT( letterPushed(QString) ) ); |
121 | layout->addWidget( b, i / 13, i % 13); | 121 | layout->addWidget( b, i / 13, i % 13); |
122 | } | 122 | } |
123 | 123 | ||
124 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | 124 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); |
125 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | 125 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); |
127 | a->addTo( jumpBar ); | 127 | a->addTo( jumpBar ); |
128 | jumpBar->hide(); | 128 | jumpBar->hide(); |
129 | 129 | ||
130 | // Packages menu | 130 | // Packages menu |
131 | QPopupMenu *popup = new QPopupMenu( this ); | 131 | QPopupMenu *popup = new QPopupMenu( this ); |
132 | 132 | ||
133 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 133 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
134 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 134 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
135 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 135 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
136 | a->addTo( popup ); | 136 | a->addTo( popup ); |
137 | a->addTo( bar ); | 137 | a->addTo( bar ); |
138 | 138 | ||
139 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 139 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
140 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 140 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
141 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 141 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
142 | actionUpgrade->addTo( popup ); | 142 | actionUpgrade->addTo( popup ); |
143 | actionUpgrade->addTo( bar ); | 143 | actionUpgrade->addTo( bar ); |
144 | 144 | ||
145 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 145 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
146 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 146 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
147 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 147 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
148 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 148 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
149 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 149 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
150 | actionDownload->addTo( popup ); | 150 | actionDownload->addTo( popup ); |
151 | actionDownload->addTo( bar ); | 151 | actionDownload->addTo( bar ); |
152 | 152 | ||
153 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 153 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
154 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 154 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
155 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 155 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
156 | a->addTo( popup ); | 156 | a->addTo( popup ); |
157 | a->addTo( bar ); | 157 | a->addTo( bar ); |
158 | 158 | ||
159 | popup->insertSeparator(); | 159 | popup->insertSeparator(); |
160 | 160 | ||
161 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 161 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
162 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 162 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
163 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 163 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
164 | a->addTo( popup ); | 164 | a->addTo( popup ); |
165 | mb->insertItem( tr( "Actions" ), popup ); | 165 | mb->insertItem( tr( "Actions" ), popup ); |
166 | 166 | ||
167 | // View menu | 167 | // View menu |
168 | popup = new QPopupMenu( this ); | 168 | popup = new QPopupMenu( this ); |
169 | 169 | ||
170 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 170 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
171 | actionUninstalled->setToggleAction( TRUE ); | 171 | actionUninstalled->setToggleAction( TRUE ); |
172 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 172 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
173 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 173 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
174 | actionUninstalled->addTo( popup ); | 174 | actionUninstalled->addTo( popup ); |
175 | 175 | ||
176 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 176 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
177 | actionInstalled->setToggleAction( TRUE ); | 177 | actionInstalled->setToggleAction( TRUE ); |
178 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 178 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
179 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 179 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
180 | actionInstalled->addTo( popup ); | 180 | actionInstalled->addTo( popup ); |
181 | 181 | ||
182 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 182 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
183 | actionUpdated->setToggleAction( TRUE ); | 183 | actionUpdated->setToggleAction( TRUE ); |
184 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 184 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
185 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 185 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
186 | actionUpdated->addTo( popup ); | 186 | actionUpdated->addTo( popup ); |
187 | 187 | ||
188 | popup->insertSeparator(); | 188 | popup->insertSeparator(); |
189 | 189 | ||
190 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 190 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
191 | actionFilter->setToggleAction( TRUE ); | 191 | actionFilter->setToggleAction( TRUE ); |
192 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 192 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
193 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 193 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
194 | actionFilter->addTo( popup ); | 194 | actionFilter->addTo( popup ); |
195 | 195 | ||
196 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 196 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
197 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 197 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
198 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
199 | a->addTo( popup ); | 199 | a->addTo( popup ); |
200 | 200 | ||
201 | popup->insertSeparator(); | 201 | popup->insertSeparator(); |
202 | 202 | ||
203 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 203 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
204 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 204 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
205 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 205 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
206 | a->addTo( popup ); | 206 | a->addTo( popup ); |
207 | 207 | ||
208 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 208 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
209 | actionFindNext->setEnabled( FALSE ); | 209 | actionFindNext->setEnabled( FALSE ); |
210 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 210 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
211 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 211 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
212 | actionFindNext->addTo( popup ); | 212 | actionFindNext->addTo( popup ); |
213 | actionFindNext->addTo( findBar ); | 213 | actionFindNext->addTo( findBar ); |
214 | 214 | ||
215 | 215 | ||
216 | popup->insertSeparator(); | 216 | popup->insertSeparator(); |
217 | 217 | ||
218 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 218 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); |
219 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | 219 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); |
220 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 220 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
221 | a->addTo( popup ); | 221 | a->addTo( popup ); |
222 | 222 | ||
223 | mb->insertItem( tr( "View" ), popup ); | 223 | mb->insertItem( tr( "View" ), popup ); |
224 | 224 | ||
225 | // Finish find toolbar creation | 225 | // Finish find toolbar creation |
226 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 226 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
227 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 227 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
228 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 228 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
229 | a->addTo( findBar ); | 229 | a->addTo( findBar ); |
230 | findBar->hide(); | 230 | findBar->hide(); |
231 | 231 | ||
232 | // Create widget stack and add UI widgets | 232 | // Create widget stack and add UI widgets |
233 | stack = new QWidgetStack( this ); | 233 | stack = new QWidgetStack( this ); |
234 | stack->addWidget( progressWindow, 2 ); | 234 | stack->addWidget( progressWindow, 2 ); |
235 | stack->addWidget( networkPkgWindow, 1 ); | 235 | stack->addWidget( networkPkgWindow, 1 ); |
236 | setCentralWidget( stack ); | 236 | setCentralWidget( stack ); |
237 | stack->raiseWidget( progressWindow ); | 237 | stack->raiseWidget( progressWindow ); |
238 | 238 | ||
239 | // Delayed call to finish initialization | 239 | // Delayed call to finish initialization |
240 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 240 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
241 | } | 241 | } |
242 | 242 | ||
243 | MainWindow :: ~MainWindow() | 243 | MainWindow :: ~MainWindow() |
244 | { | 244 | { |
245 | delete mgr; | 245 | delete mgr; |
246 | 246 | ||
247 | // Reenable suspend mode | 247 | // Reenable suspend mode |
248 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 248 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
249 | } | 249 | } |
250 | 250 | ||
251 | void MainWindow :: initMainWidget() | 251 | void MainWindow :: initMainWidget() |
252 | { | 252 | { |
253 | networkPkgWindow = new QWidget( this ); | 253 | networkPkgWindow = new QWidget( this ); |
254 | 254 | ||
255 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 255 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
256 | 256 | ||
257 | serversList = new QComboBox( networkPkgWindow ); | 257 | serversList = new QComboBox( networkPkgWindow ); |
258 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); | 258 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); |
259 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 259 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
260 | 260 | ||
261 | installedIcon = Resource::loadPixmap( "installed" ); | 261 | installedIcon = Resource::loadPixmap( "installed" ); |
262 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 262 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
263 | 263 | ||
264 | packagesList = new QListView( networkPkgWindow ); | 264 | packagesList = new QListView( networkPkgWindow ); |
265 | packagesList->addColumn( tr( "Packages" ), 225 ); | 265 | packagesList->addColumn( tr( "Packages" ), 225 ); |
266 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 266 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
267 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); | 267 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); |
268 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 268 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
269 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); | 269 | this, SLOT(slotDisplayPackage(QListViewItem*)) ); |
270 | 270 | ||
271 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 271 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
272 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 272 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
273 | hbox1->addWidget( l ); | 273 | hbox1->addWidget( l ); |
274 | hbox1->addWidget( serversList ); | 274 | hbox1->addWidget( serversList ); |
275 | 275 | ||
276 | vbox->addWidget( packagesList ); | 276 | vbox->addWidget( packagesList ); |
277 | 277 | ||
278 | downloadEnabled = TRUE; | 278 | downloadEnabled = TRUE; |
279 | } | 279 | } |
280 | 280 | ||
281 | void MainWindow :: initProgressWidget() | 281 | void MainWindow :: initProgressWidget() |
282 | { | 282 | { |
283 | progressWindow = new QWidget( this ); | 283 | progressWindow = new QWidget( this ); |
284 | 284 | ||
285 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 285 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
286 | 286 | ||
287 | m_status = new QLabel( progressWindow ); | 287 | m_status = new QLabel( progressWindow ); |
288 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 288 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
289 | layout->addWidget( m_status ); | 289 | layout->addWidget( m_status ); |
290 | 290 | ||
291 | m_progress = new QProgressBar( progressWindow ); | 291 | m_progress = new QProgressBar( progressWindow ); |
292 | layout->addWidget( m_progress ); | 292 | layout->addWidget( m_progress ); |
293 | } | 293 | } |
294 | 294 | ||
295 | void MainWindow :: init() | 295 | void MainWindow :: init() |
296 | { | 296 | { |
297 | #ifdef QWS | 297 | #ifdef QWS |
298 | // read download directory from config file | 298 | // read download directory from config file |
299 | Config cfg( "aqpkg" ); | 299 | Config cfg( "aqpkg" ); |
300 | cfg.setGroup( "settings" ); | 300 | cfg.setGroup( "settings" ); |
301 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 301 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
302 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 302 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
303 | 303 | ||
304 | #endif | 304 | #endif |
305 | 305 | ||
306 | stack->raiseWidget( progressWindow ); | 306 | stack->raiseWidget( progressWindow ); |
307 | 307 | ||
308 | mgr = new DataManager(); | 308 | mgr = new DataManager(); |
309 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 309 | connect( mgr, SIGNAL( progressSetSteps(int) ), this, SLOT( setProgressSteps(int) ) ); |
310 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 310 | connect( mgr, SIGNAL( progressSetMessage(const QString&) ), |
311 | this, SLOT( setProgressMessage( const QString & ) ) ); | 311 | this, SLOT( setProgressMessage(const QString&) ) ); |
312 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 312 | connect( mgr, SIGNAL( progressUpdate(int) ), this, SLOT( updateProgress(int) ) ); |
313 | mgr->loadServers(); | 313 | mgr->loadServers(); |
314 | 314 | ||
315 | showUninstalledPkgs = false; | 315 | showUninstalledPkgs = false; |
316 | showInstalledPkgs = false; | 316 | showInstalledPkgs = false; |
317 | showUpgradedPkgs = false; | 317 | showUpgradedPkgs = false; |
318 | categoryFilterEnabled = false; | 318 | categoryFilterEnabled = false; |
319 | 319 | ||
320 | updateData(); | 320 | updateData(); |
321 | 321 | ||
322 | stack->raiseWidget( networkPkgWindow ); | 322 | stack->raiseWidget( networkPkgWindow ); |
323 | } | 323 | } |
324 | 324 | ||
325 | void MainWindow :: setDocument( const QString &doc ) | 325 | void MainWindow :: setDocument( const QString &doc ) |
326 | { | 326 | { |
327 | // Remove path from package | 327 | // Remove path from package |
328 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 328 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
329 | 329 | ||
330 | // First select local server | 330 | // First select local server |
331 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 331 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
332 | { | 332 | { |
333 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 333 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
334 | { | 334 | { |
335 | serversList->setCurrentItem( i ); | 335 | serversList->setCurrentItem( i ); |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | serverSelected( 0 ); | 339 | serverSelected( 0 ); |
340 | 340 | ||
341 | // Now set the check box of the selected package | 341 | // Now set the check box of the selected package |
342 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 342 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
343 | item != 0 ; | 343 | item != 0 ; |
344 | item = (QCheckListItem *)item->nextSibling() ) | 344 | item = (QCheckListItem *)item->nextSibling() ) |
345 | { | 345 | { |
346 | if ( item->text().startsWith( package ) ) | 346 | if ( item->text().startsWith( package ) ) |
347 | { | 347 | { |
348 | item->setOn( true ); | 348 | item->setOn( true ); |
349 | break; | 349 | break; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | void MainWindow :: displaySettings() | 354 | void MainWindow :: displaySettings() |
355 | { | 355 | { |
356 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 356 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
357 | if ( dlg->showDlg() ) | 357 | if ( dlg->showDlg() ) |
358 | { | 358 | { |
359 | stack->raiseWidget( progressWindow ); | 359 | stack->raiseWidget( progressWindow ); |
360 | updateData(); | 360 | updateData(); |
361 | stack->raiseWidget( networkPkgWindow ); | 361 | stack->raiseWidget( networkPkgWindow ); |
362 | } | 362 | } |
363 | delete dlg; | 363 | delete dlg; |
364 | } | 364 | } |
365 | 365 | ||
366 | void MainWindow :: closeEvent( QCloseEvent *e ) | 366 | void MainWindow :: closeEvent( QCloseEvent *e ) |
367 | { | 367 | { |
368 | // If install dialog is visible, return to main view, otherwise close app | 368 | // If install dialog is visible, return to main view, otherwise close app |
369 | QWidget *widget = stack->visibleWidget(); | 369 | QWidget *widget = stack->visibleWidget(); |
370 | 370 | ||
371 | if ( widget != networkPkgWindow && widget != progressWindow ) | 371 | if ( widget != networkPkgWindow && widget != progressWindow ) |
372 | { | 372 | { |
373 | if ( widget ) delete widget; | 373 | if ( widget ) delete widget; |
374 | stack->raiseWidget( networkPkgWindow ); | 374 | stack->raiseWidget( networkPkgWindow ); |
375 | e->ignore(); | 375 | e->ignore(); |
376 | } | 376 | } |
377 | else | 377 | else |
378 | { | 378 | { |
379 | e->accept(); | 379 | e->accept(); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | void MainWindow :: displayFindBar() | 383 | void MainWindow :: displayFindBar() |
384 | { | 384 | { |
385 | findBar->show(); | 385 | findBar->show(); |
386 | findEdit->setFocus(); | 386 | findEdit->setFocus(); |
387 | } | 387 | } |
388 | 388 | ||
389 | void MainWindow :: displayJumpBar() | 389 | void MainWindow :: displayJumpBar() |
390 | { | 390 | { |
391 | jumpBar->show(); | 391 | jumpBar->show(); |
392 | } | 392 | } |
393 | 393 | ||
394 | void MainWindow :: repeatFind() | 394 | void MainWindow :: repeatFind() |
395 | { | 395 | { |
396 | searchForPackage( findEdit->text() ); | 396 | searchForPackage( findEdit->text() ); |
397 | } | 397 | } |
398 | 398 | ||
399 | void MainWindow :: findPackage( const QString &text ) | 399 | void MainWindow :: findPackage( const QString &text ) |
400 | { | 400 | { |
401 | actionFindNext->setEnabled( !text.isEmpty() ); | 401 | actionFindNext->setEnabled( !text.isEmpty() ); |
402 | searchForPackage( text ); | 402 | searchForPackage( text ); |
403 | } | 403 | } |
404 | 404 | ||
405 | void MainWindow :: hideFindBar() | 405 | void MainWindow :: hideFindBar() |
406 | { | 406 | { |
407 | findBar->hide(); | 407 | findBar->hide(); |
408 | } | 408 | } |
409 | 409 | ||
410 | void MainWindow :: hideJumpBar() | 410 | void MainWindow :: hideJumpBar() |
411 | { | 411 | { |
412 | jumpBar->hide(); | 412 | jumpBar->hide(); |
413 | } | 413 | } |
414 | 414 | ||
415 | void MainWindow :: filterUninstalledPackages() | 415 | void MainWindow :: filterUninstalledPackages() |
416 | { | 416 | { |
417 | showUninstalledPkgs = actionUninstalled->isOn(); | 417 | showUninstalledPkgs = actionUninstalled->isOn(); |
418 | if ( showUninstalledPkgs ) | 418 | if ( showUninstalledPkgs ) |
419 | { | 419 | { |
420 | showInstalledPkgs = FALSE; | 420 | showInstalledPkgs = FALSE; |
421 | showUpgradedPkgs = FALSE; | 421 | showUpgradedPkgs = FALSE; |
422 | } | 422 | } |
423 | serverSelected( -1 ); | 423 | serverSelected( -1 ); |
424 | 424 | ||
425 | actionInstalled->setOn( FALSE ); | 425 | actionInstalled->setOn( FALSE ); |
426 | actionUpdated->setOn( FALSE ); | 426 | actionUpdated->setOn( FALSE ); |
427 | } | 427 | } |
428 | 428 | ||
429 | void MainWindow :: filterInstalledPackages() | 429 | void MainWindow :: filterInstalledPackages() |
430 | { | 430 | { |
431 | showInstalledPkgs = actionInstalled->isOn(); | 431 | showInstalledPkgs = actionInstalled->isOn(); |
432 | if ( showInstalledPkgs ) | 432 | if ( showInstalledPkgs ) |
433 | { | 433 | { |
434 | showUninstalledPkgs = FALSE; | 434 | showUninstalledPkgs = FALSE; |
435 | showUpgradedPkgs = FALSE; | 435 | showUpgradedPkgs = FALSE; |
436 | } | 436 | } |
437 | serverSelected( -1 ); | 437 | serverSelected( -1 ); |
438 | 438 | ||
439 | actionUninstalled->setOn( FALSE ); | 439 | actionUninstalled->setOn( FALSE ); |
440 | actionUpdated->setOn( FALSE ); | 440 | actionUpdated->setOn( FALSE ); |
441 | } | 441 | } |
442 | 442 | ||
443 | void MainWindow :: filterUpgradedPackages() | 443 | void MainWindow :: filterUpgradedPackages() |
444 | { | 444 | { |
445 | showUpgradedPkgs = actionUpdated->isOn(); | 445 | showUpgradedPkgs = actionUpdated->isOn(); |
446 | if ( showUpgradedPkgs ) | 446 | if ( showUpgradedPkgs ) |
447 | { | 447 | { |
448 | showUninstalledPkgs = FALSE; | 448 | showUninstalledPkgs = FALSE; |
449 | showInstalledPkgs = FALSE; | 449 | showInstalledPkgs = FALSE; |
450 | } | 450 | } |
451 | serverSelected( -1 ); | 451 | serverSelected( -1 ); |
452 | 452 | ||
453 | actionUninstalled->setOn( FALSE ); | 453 | actionUninstalled->setOn( FALSE ); |
454 | actionInstalled->setOn( FALSE ); | 454 | actionInstalled->setOn( FALSE ); |
455 | } | 455 | } |
456 | 456 | ||
457 | bool MainWindow :: setFilterCategory() | 457 | bool MainWindow :: setFilterCategory() |
458 | { | 458 | { |
459 | // Get categories; | 459 | // Get categories; |
460 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 460 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
461 | if ( dlg.exec() == QDialog::Accepted ) | 461 | if ( dlg.exec() == QDialog::Accepted ) |
462 | { | 462 | { |
463 | categoryFilter = dlg.getSelectedFilter(); | 463 | categoryFilter = dlg.getSelectedFilter(); |
464 | 464 | ||
465 | if ( categoryFilter == "" ) | 465 | if ( categoryFilter == "" ) |
466 | return false; | 466 | return false; |
467 | 467 | ||
468 | categoryFilterEnabled = true; | 468 | categoryFilterEnabled = true; |
469 | serverSelected( -1 ); | 469 | serverSelected( -1 ); |
470 | actionFilter->setOn( TRUE ); | 470 | actionFilter->setOn( TRUE ); |
471 | return true; | 471 | return true; |
472 | } | 472 | } |
473 | 473 | ||
474 | return false; | 474 | return false; |
475 | } | 475 | } |
476 | 476 | ||
477 | void MainWindow :: filterCategory() | 477 | void MainWindow :: filterCategory() |
478 | { | 478 | { |
479 | if ( !actionFilter->isOn() ) | 479 | if ( !actionFilter->isOn() ) |
480 | { | 480 | { |
481 | filterByCategory( FALSE ); | 481 | filterByCategory( FALSE ); |
482 | } | 482 | } |
483 | else | 483 | else |
484 | { | 484 | { |
485 | actionFilter->setOn( filterByCategory( TRUE ) ); | 485 | actionFilter->setOn( filterByCategory( TRUE ) ); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | 488 | ||
489 | bool MainWindow :: filterByCategory( bool val ) | 489 | bool MainWindow :: filterByCategory( bool val ) |
490 | { | 490 | { |
491 | if ( val ) | 491 | if ( val ) |
492 | { | 492 | { |
493 | if ( categoryFilter == "" ) | 493 | if ( categoryFilter == "" ) |
494 | { | 494 | { |
495 | if ( !setFilterCategory() ) | 495 | if ( !setFilterCategory() ) |
496 | return false; | 496 | return false; |
497 | } | 497 | } |
498 | 498 | ||
499 | categoryFilterEnabled = true; | 499 | categoryFilterEnabled = true; |
500 | serverSelected( -1 ); | 500 | serverSelected( -1 ); |
501 | return true; | 501 | return true; |
502 | } | 502 | } |
503 | else | 503 | else |
504 | { | 504 | { |
505 | // Turn off filter | 505 | // Turn off filter |
506 | categoryFilterEnabled = false; | 506 | categoryFilterEnabled = false; |
507 | serverSelected( -1 ); | 507 | serverSelected( -1 ); |
508 | return false; | 508 | return false; |
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | void MainWindow :: raiseMainWidget() | 512 | void MainWindow :: raiseMainWidget() |
513 | { | 513 | { |
514 | stack->raiseWidget( networkPkgWindow ); | 514 | stack->raiseWidget( networkPkgWindow ); |
515 | } | 515 | } |
516 | 516 | ||
517 | void MainWindow :: raiseProgressWidget() | 517 | void MainWindow :: raiseProgressWidget() |
518 | { | 518 | { |
519 | stack->raiseWidget( progressWindow ); | 519 | stack->raiseWidget( progressWindow ); |
520 | } | 520 | } |
521 | 521 | ||
522 | void MainWindow :: enableUpgrade( bool enabled ) | 522 | void MainWindow :: enableUpgrade( bool enabled ) |
523 | { | 523 | { |
524 | actionUpgrade->setEnabled( enabled ); | 524 | actionUpgrade->setEnabled( enabled ); |
525 | } | 525 | } |
526 | 526 | ||
527 | void MainWindow :: enableDownload( bool enabled ) | 527 | void MainWindow :: enableDownload( bool enabled ) |
528 | { | 528 | { |
529 | if ( enabled ) | 529 | if ( enabled ) |
530 | { | 530 | { |
531 | actionDownload->setIconSet( iconDownload ); | 531 | actionDownload->setIconSet( iconDownload ); |
532 | actionDownload->setText( tr( "Download" ) ); | 532 | actionDownload->setText( tr( "Download" ) ); |
533 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 533 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
534 | } | 534 | } |
535 | else | 535 | else |
536 | { | 536 | { |
537 | actionDownload->setIconSet( iconRemove ); | 537 | actionDownload->setIconSet( iconRemove ); |
538 | actionDownload->setText( tr( "Remove" ) ); | 538 | actionDownload->setText( tr( "Remove" ) ); |
539 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 539 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | void MainWindow :: setProgressSteps( int numsteps ) | 543 | void MainWindow :: setProgressSteps( int numsteps ) |
544 | { | 544 | { |
545 | m_progress->setTotalSteps( numsteps ); | 545 | m_progress->setTotalSteps( numsteps ); |
546 | } | 546 | } |
547 | 547 | ||
548 | void MainWindow :: setProgressMessage( const QString &msg ) | 548 | void MainWindow :: setProgressMessage( const QString &msg ) |
549 | { | 549 | { |
550 | m_status->setText( msg ); | 550 | m_status->setText( msg ); |
551 | } | 551 | } |
552 | 552 | ||
553 | void MainWindow :: updateProgress( int progress ) | 553 | void MainWindow :: updateProgress( int progress ) |
554 | { | 554 | { |
555 | m_progress->setProgress( progress ); | 555 | m_progress->setProgress( progress ); |
556 | } | 556 | } |
557 | 557 | ||
558 | void MainWindow :: updateData() | 558 | void MainWindow :: updateData() |
559 | { | 559 | { |
560 | m_progress->setTotalSteps( mgr->getServerList().count() ); | 560 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
561 | 561 | ||
562 | serversList->clear(); | 562 | serversList->clear(); |
563 | packagesList->clear(); | 563 | packagesList->clear(); |
564 | 564 | ||
565 | int activeItem = -1; | 565 | int activeItem = -1; |
566 | int i = 0; | 566 | int i = 0; |
567 | QString serverName; | 567 | QString serverName; |
568 | 568 | ||
569 | QListIterator<Server> it( mgr->getServerList() ); | 569 | QListIterator<Server> it( mgr->getServerList() ); |
570 | Server *server; | 570 | Server *server; |
571 | 571 | ||
572 | for ( ; it.current(); ++it, ++i ) | 572 | for ( ; it.current(); ++it, ++i ) |
573 | { | 573 | { |
574 | server = it.current(); | 574 | server = it.current(); |
575 | serverName = server->getServerName(); | 575 | serverName = server->getServerName(); |
576 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 576 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
577 | m_progress->setProgress( i ); | 577 | m_progress->setProgress( i ); |
578 | qApp->processEvents(); | 578 | qApp->processEvents(); |
579 | 579 | ||
580 | if ( !server->isServerActive() ) | 580 | if ( !server->isServerActive() ) |
581 | { | 581 | { |
582 | i--; | 582 | i--; |
583 | continue; | 583 | continue; |
584 | } | 584 | } |
585 | 585 | ||
586 | serversList->insertItem( serverName ); | 586 | serversList->insertItem( serverName ); |
587 | if ( serverName == currentlySelectedServer ) | 587 | if ( serverName == currentlySelectedServer ) |
588 | activeItem = i; | 588 | activeItem = i; |
589 | } | 589 | } |
590 | 590 | ||
591 | // set selected server to be active server | 591 | // set selected server to be active server |
592 | if ( activeItem != -1 ) | 592 | if ( activeItem != -1 ) |
593 | serversList->setCurrentItem( activeItem ); | 593 | serversList->setCurrentItem( activeItem ); |
594 | serverSelected( 0, FALSE ); | 594 | serverSelected( 0, FALSE ); |
595 | } | 595 | } |
596 | 596 | ||
597 | void MainWindow :: serverSelected( int index ) | 597 | void MainWindow :: serverSelected( int index ) |
598 | { | 598 | { |
599 | serverSelected( index, TRUE ); | 599 | serverSelected( index, TRUE ); |
600 | } | 600 | } |
601 | 601 | ||
602 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 602 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
603 | { | 603 | { |
604 | QPixmap nullIcon( installedIcon.size() ); | 604 | QPixmap nullIcon( installedIcon.size() ); |
605 | nullIcon.fill( colorGroup().base() ); | 605 | nullIcon.fill( colorGroup().base() ); |
606 | 606 | ||
607 | // display packages | 607 | // display packages |
608 | QString serverName = serversList->currentText(); | 608 | QString serverName = serversList->currentText(); |
609 | currentlySelectedServer = serverName; | 609 | currentlySelectedServer = serverName; |
610 | 610 | ||
611 | Server *s = mgr->getServer( serverName ); | 611 | Server *s = mgr->getServer( serverName ); |
612 | 612 | ||
613 | QList<Package> &list = s->getPackageList(); | 613 | QList<Package> &list = s->getPackageList(); |
614 | QListIterator<Package> it( list ); | 614 | QListIterator<Package> it( list ); |
615 | 615 | ||
616 | // Display progress widget while loading list | 616 | // Display progress widget while loading list |
617 | bool doProgress = ( list.count() > 200 ); | 617 | bool doProgress = ( list.count() > 200 ); |
618 | if ( doProgress ) | 618 | if ( doProgress ) |
619 | { | 619 | { |
620 | if ( raiseProgress ) | 620 | if ( raiseProgress ) |
621 | { | 621 | { |
622 | stack->raiseWidget( progressWindow ); | 622 | stack->raiseWidget( progressWindow ); |
623 | } | 623 | } |
624 | m_progress->setTotalSteps( list.count() ); | 624 | m_progress->setTotalSteps( list.count() ); |
625 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 625 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
626 | } | 626 | } |
627 | 627 | ||
628 | packagesList->clear(); | 628 | packagesList->clear(); |
629 | 629 | ||
630 | #ifdef QWS | 630 | #ifdef QWS |
631 | // read download directory from config file | 631 | // read download directory from config file |
632 | Config cfg( "aqpkg" ); | 632 | Config cfg( "aqpkg" ); |
633 | cfg.setGroup( "settings" ); | 633 | cfg.setGroup( "settings" ); |
634 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 634 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
635 | #endif | 635 | #endif |
636 | 636 | ||
637 | int i = 0; | 637 | int i = 0; |
638 | Package *package; | 638 | Package *package; |
639 | for ( ; it.current(); ++it ) | 639 | for ( ; it.current(); ++it ) |
640 | { | 640 | { |
641 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 641 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
642 | i++; | 642 | i++; |
643 | if ( ( i % 100 ) == 0 ) | 643 | if ( ( i % 100 ) == 0 ) |
644 | { | 644 | { |
645 | if ( doProgress ) | 645 | if ( doProgress ) |
646 | { | 646 | { |
647 | m_progress->setProgress( i ); | 647 | m_progress->setProgress( i ); |
648 | } | 648 | } |
649 | qApp->processEvents(); | 649 | qApp->processEvents(); |
650 | } | 650 | } |
651 | 651 | ||
652 | QString text = ""; | 652 | QString text = ""; |
653 | 653 | ||
654 | package = it.current(); | 654 | package = it.current(); |
655 | 655 | ||
656 | // Apply show only uninstalled packages filter | 656 | // Apply show only uninstalled packages filter |
657 | if ( showUninstalledPkgs && package->isInstalled() ) | 657 | if ( showUninstalledPkgs && package->isInstalled() ) |
658 | continue; | 658 | continue; |
659 | 659 | ||
660 | // Apply show only installed packages filter | 660 | // Apply show only installed packages filter |
661 | if ( showInstalledPkgs && !package->isInstalled() ) | 661 | if ( showInstalledPkgs && !package->isInstalled() ) |
662 | continue; | 662 | continue; |
663 | 663 | ||
664 | // Apply show only new installed packages filter | 664 | // Apply show only new installed packages filter |
665 | if ( showUpgradedPkgs ) | 665 | if ( showUpgradedPkgs ) |
666 | { | 666 | { |
667 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) | 667 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) |
668 | continue; | 668 | continue; |
669 | } | 669 | } |
670 | 670 | ||
671 | // Apply the section filter | 671 | // Apply the section filter |
672 | if ( categoryFilterEnabled && categoryFilter != "" ) | 672 | if ( categoryFilterEnabled && categoryFilter != "" ) |
673 | { | 673 | { |
674 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) | 674 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
675 | continue; | 675 | continue; |
676 | } | 676 | } |
677 | 677 | ||
678 | // If the local server, only display installed packages | 678 | // If the local server, only display installed packages |
679 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 679 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
680 | continue; | 680 | continue; |
681 | 681 | ||
682 | 682 | ||
683 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 683 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
684 | QCheckListItem::CheckBox ); | 684 | QCheckListItem::CheckBox ); |
685 | 685 | ||
686 | if ( package->isInstalled() ) | 686 | if ( package->isInstalled() ) |
687 | { | 687 | { |
688 | // If a different version of package is available, show update available icon | 688 | // If a different version of package is available, show update available icon |
689 | // Otherwise, show installed icon | 689 | // Otherwise, show installed icon |
690 | if ( package->getNewVersionAvailable()) | 690 | if ( package->getNewVersionAvailable()) |
691 | { | 691 | { |
692 | 692 | ||
693 | item->setPixmap( 0, updatedIcon ); | 693 | item->setPixmap( 0, updatedIcon ); |
694 | } | 694 | } |
695 | else | 695 | else |
696 | { | 696 | { |
697 | item->setPixmap( 0, installedIcon ); | 697 | item->setPixmap( 0, installedIcon ); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | else | 700 | else |
701 | { | 701 | { |
702 | item->setPixmap( 0, nullIcon ); | 702 | item->setPixmap( 0, nullIcon ); |
703 | } | 703 | } |
704 | 704 | ||
705 | packagesList->insertItem( item ); | 705 | packagesList->insertItem( item ); |
706 | } | 706 | } |
707 | 707 | ||
708 | // If the local server or the local ipkgs server disable the download button | 708 | // If the local server or the local ipkgs server disable the download button |
709 | if ( serverName == LOCAL_SERVER ) | 709 | if ( serverName == LOCAL_SERVER ) |
710 | { | 710 | { |
711 | downloadEnabled = TRUE; | 711 | downloadEnabled = TRUE; |
712 | actionUpgrade->setEnabled( FALSE ); | 712 | actionUpgrade->setEnabled( FALSE ); |
713 | } | 713 | } |
714 | else if ( serverName == LOCAL_IPKGS ) | 714 | else if ( serverName == LOCAL_IPKGS ) |
715 | { | 715 | { |
716 | downloadEnabled = FALSE; | 716 | downloadEnabled = FALSE; |
717 | actionUpgrade->setEnabled( FALSE ); | 717 | actionUpgrade->setEnabled( FALSE ); |
718 | } | 718 | } |
719 | else | 719 | else |
720 | { | 720 | { |
721 | downloadEnabled = TRUE; | 721 | downloadEnabled = TRUE; |
722 | actionUpgrade->setEnabled( TRUE ); | 722 | actionUpgrade->setEnabled( TRUE ); |
723 | } | 723 | } |
724 | enableDownload( downloadEnabled ); | 724 | enableDownload( downloadEnabled ); |
725 | 725 | ||
726 | // Display this widget once everything is done | 726 | // Display this widget once everything is done |
727 | if ( doProgress && raiseProgress ) | 727 | if ( doProgress && raiseProgress ) |
728 | { | 728 | { |
729 | stack->raiseWidget( networkPkgWindow ); | 729 | stack->raiseWidget( networkPkgWindow ); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | 732 | ||
733 | void MainWindow :: searchForPackage( const QString &text ) | 733 | void MainWindow :: searchForPackage( const QString &text ) |
734 | { | 734 | { |
735 | if ( !text.isEmpty() ) | 735 | if ( !text.isEmpty() ) |
736 | { | 736 | { |
737 | // look through package list for text startng at current position | 737 | // look through package list for text startng at current position |
738 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 738 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
739 | 739 | ||
740 | if ( start == 0 ) | 740 | if ( start == 0 ) |
741 | start = (QCheckListItem *)packagesList->firstChild(); | 741 | start = (QCheckListItem *)packagesList->firstChild(); |
742 | 742 | ||
743 | for ( QCheckListItem *item = start; item != 0 ; | 743 | for ( QCheckListItem *item = start; item != 0 ; |
744 | item = (QCheckListItem *)item->nextSibling() ) | 744 | item = (QCheckListItem *)item->nextSibling() ) |
745 | { | 745 | { |
746 | if ( item->text().lower().find( text ) != -1 ) | 746 | if ( item->text().lower().find( text ) != -1 ) |
747 | { | 747 | { |
748 | packagesList->ensureItemVisible( item ); | 748 | packagesList->ensureItemVisible( item ); |
749 | packagesList->setCurrentItem( item ); | 749 | packagesList->setCurrentItem( item ); |
750 | break; | 750 | break; |
751 | } | 751 | } |
752 | } | 752 | } |
753 | } | 753 | } |
754 | } | 754 | } |
755 | 755 | ||
756 | void MainWindow :: updateServer() | 756 | void MainWindow :: updateServer() |
757 | { | 757 | { |
758 | QString serverName = serversList->currentText(); | 758 | QString serverName = serversList->currentText(); |
759 | 759 | ||
760 | // Update the current server | 760 | // Update the current server |
761 | // Display dialog | 761 | // Display dialog |
762 | 762 | ||
763 | // Disable buttons to stop silly people clicking lots on them :) | 763 | // Disable buttons to stop silly people clicking lots on them :) |
764 | 764 | ||
765 | // First, write out ipkg_conf file so that ipkg can use it | 765 | // First, write out ipkg_conf file so that ipkg can use it |
766 | mgr->writeOutIpkgConf(); | 766 | mgr->writeOutIpkgConf(); |
767 | 767 | ||
768 | Ipkg *ipkg = new Ipkg; | 768 | Ipkg *ipkg = new Ipkg; |
769 | ipkg->setOption( "update" ); | 769 | ipkg->setOption( "update" ); |
770 | 770 | ||
771 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 771 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
772 | tr( "Update lists" ) ); | 772 | tr( "Update lists" ) ); |
773 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 773 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
774 | reloadDocuments = FALSE; | 774 | reloadDocuments = FALSE; |
775 | stack->addWidget( dlg, 3 ); | 775 | stack->addWidget( dlg, 3 ); |
776 | stack->raiseWidget( dlg ); | 776 | stack->raiseWidget( dlg ); |
777 | 777 | ||
778 | // delete progDlg; | 778 | // delete progDlg; |
779 | } | 779 | } |
780 | 780 | ||
781 | void MainWindow :: upgradePackages() | 781 | void MainWindow :: upgradePackages() |
782 | { | 782 | { |
783 | // We're gonna do an upgrade of all packages | 783 | // We're gonna do an upgrade of all packages |
784 | // First warn user that this isn't recommended | 784 | // First warn user that this isn't recommended |
785 | // TODO - ODevice???? | 785 | // TODO - ODevice???? |
786 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 786 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
787 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 787 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
788 | QMessageBox::Yes, | 788 | QMessageBox::Yes, |
789 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 789 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
790 | 0, this ); | 790 | 0, this ); |
791 | warn.adjustSize(); | 791 | warn.adjustSize(); |
792 | 792 | ||
793 | if ( warn.exec() == QMessageBox::Yes ) | 793 | if ( warn.exec() == QMessageBox::Yes ) |
794 | { | 794 | { |
795 | // First, write out ipkg_conf file so that ipkg can use it | 795 | // First, write out ipkg_conf file so that ipkg can use it |
796 | mgr->writeOutIpkgConf(); | 796 | mgr->writeOutIpkgConf(); |
797 | 797 | ||
798 | // Now run upgrade | 798 | // Now run upgrade |
799 | Ipkg *ipkg = new Ipkg; | 799 | Ipkg *ipkg = new Ipkg; |
800 | ipkg->setOption( "upgrade" ); | 800 | ipkg->setOption( "upgrade" ); |
801 | 801 | ||
802 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 802 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
803 | tr ( "Upgrade" ) ); | 803 | tr ( "Upgrade" ) ); |
804 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 804 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
805 | reloadDocuments = TRUE; | 805 | reloadDocuments = TRUE; |
806 | stack->addWidget( dlg, 3 ); | 806 | stack->addWidget( dlg, 3 ); |
807 | stack->raiseWidget( dlg ); | 807 | stack->raiseWidget( dlg ); |
808 | } | 808 | } |
809 | } | 809 | } |
810 | 810 | ||
811 | void MainWindow :: downloadPackage() | 811 | void MainWindow :: downloadPackage() |
812 | { | 812 | { |
813 | bool doUpdate = true; | 813 | bool doUpdate = true; |
814 | if ( downloadEnabled ) | 814 | if ( downloadEnabled ) |
815 | { | 815 | { |
816 | // See if any packages are selected | 816 | // See if any packages are selected |
817 | bool found = false; | 817 | bool found = false; |
818 | if ( serversList->currentText() != LOCAL_SERVER ) | 818 | if ( serversList->currentText() != LOCAL_SERVER ) |
819 | { | 819 | { |
820 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 820 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
821 | item != 0 && !found; | 821 | item != 0 && !found; |
822 | item = (QCheckListItem *)item->nextSibling() ) | 822 | item = (QCheckListItem *)item->nextSibling() ) |
823 | { | 823 | { |
824 | if ( item->isOn() ) | 824 | if ( item->isOn() ) |
825 | found = true; | 825 | found = true; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
829 | // If user selected some packages then download the and store the locally | 829 | // If user selected some packages then download the and store the locally |
830 | // otherwise, display dialog asking user what package to download from an http server | 830 | // otherwise, display dialog asking user what package to download from an http server |
831 | // and whether to install it | 831 | // and whether to install it |
832 | if ( found ) | 832 | if ( found ) |
833 | downloadSelectedPackages(); | 833 | downloadSelectedPackages(); |
834 | else | 834 | else |
835 | downloadRemotePackage(); | 835 | downloadRemotePackage(); |
836 | 836 | ||
837 | } | 837 | } |
838 | else | 838 | else |
839 | { | 839 | { |
840 | doUpdate = false; | 840 | doUpdate = false; |
841 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 841 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
842 | item != 0 ; | 842 | item != 0 ; |
843 | item = (QCheckListItem *)item->nextSibling() ) | 843 | item = (QCheckListItem *)item->nextSibling() ) |
844 | { | 844 | { |
845 | if ( item->isOn() ) | 845 | if ( item->isOn() ) |
846 | { | 846 | { |
847 | QString name = item->text(); | 847 | QString name = item->text(); |
848 | int pos = name.find( "*" ); | 848 | int pos = name.find( "*" ); |
849 | name.truncate( pos ); | 849 | name.truncate( pos ); |
850 | 850 | ||
851 | // if (there is a (installed), remove it | 851 | // if (there is a (installed), remove it |
852 | pos = name.find( "(installed)" ); | 852 | pos = name.find( "(installed)" ); |
853 | if ( pos > 0 ) | 853 | if ( pos > 0 ) |
854 | name.truncate( pos - 1 ); | 854 | name.truncate( pos - 1 ); |
855 | 855 | ||
856 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 856 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
857 | 857 | ||
858 | QString msgtext; | 858 | QString msgtext; |
859 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 859 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
860 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 860 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
861 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 861 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
862 | { | 862 | { |
863 | doUpdate = true; | 863 | doUpdate = true; |
864 | QFile f( p->getFilename() ); | 864 | QFile f( p->getFilename() ); |
865 | f.remove(); | 865 | f.remove(); |
866 | } | 866 | } |
867 | } | 867 | } |
868 | } | 868 | } |
869 | } | 869 | } |
870 | 870 | ||
871 | if ( doUpdate ) | 871 | if ( doUpdate ) |
872 | { | 872 | { |
873 | reloadData( 0x0 ); | 873 | reloadData( 0x0 ); |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | void MainWindow :: downloadSelectedPackages() | 877 | void MainWindow :: downloadSelectedPackages() |
878 | { | 878 | { |
879 | // First, write out ipkg_conf file so that ipkg can use it | 879 | // First, write out ipkg_conf file so that ipkg can use it |
880 | mgr->writeOutIpkgConf(); | 880 | mgr->writeOutIpkgConf(); |
881 | 881 | ||
882 | // Display dialog to user asking where to download the files to | 882 | // Display dialog to user asking where to download the files to |
883 | bool ok = FALSE; | 883 | bool ok = FALSE; |
884 | QString dir = ""; | 884 | QString dir = ""; |
885 | #ifdef QWS | 885 | #ifdef QWS |
886 | // read download directory from config file | 886 | // read download directory from config file |
887 | Config cfg( "aqpkg" ); | 887 | Config cfg( "aqpkg" ); |
888 | cfg.setGroup( "settings" ); | 888 | cfg.setGroup( "settings" ); |
889 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 889 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
890 | #endif | 890 | #endif |
891 | 891 | ||
892 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 892 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
893 | if ( ok && !text.isEmpty() ) | 893 | if ( ok && !text.isEmpty() ) |
894 | dir = text; // user entered something and pressed ok | 894 | dir = text; // user entered something and pressed ok |
895 | else | 895 | else |
896 | return; // user entered nothing or pressed cancel | 896 | return; // user entered nothing or pressed cancel |
897 | 897 | ||
898 | #ifdef QWS | 898 | #ifdef QWS |
899 | // Store download directory in config file | 899 | // Store download directory in config file |
900 | cfg.writeEntry( "downloadDir", dir ); | 900 | cfg.writeEntry( "downloadDir", dir ); |
901 | #endif | 901 | #endif |
902 | 902 | ||
903 | // Get starting directory | 903 | // Get starting directory |
904 | char initDir[PATH_MAX]; | 904 | char initDir[PATH_MAX]; |
905 | getcwd( initDir, PATH_MAX ); | 905 | getcwd( initDir, PATH_MAX ); |
906 | 906 | ||
907 | // Download each package | 907 | // Download each package |
908 | Ipkg ipkg; | 908 | Ipkg ipkg; |
909 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 909 | connect( &ipkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
910 | 910 | ||
911 | ipkg.setOption( "download" ); | 911 | ipkg.setOption( "download" ); |
912 | ipkg.setRuntimeDirectory( dir ); | 912 | ipkg.setRuntimeDirectory( dir ); |
913 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 913 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
914 | item != 0 ; | 914 | item != 0 ; |
915 | item = (QCheckListItem *)item->nextSibling() ) | 915 | item = (QCheckListItem *)item->nextSibling() ) |
916 | { | 916 | { |
917 | if ( item->isOn() ) | 917 | if ( item->isOn() ) |
918 | { | 918 | { |
919 | ipkg.setPackage( item->text() ); | 919 | ipkg.setPackage( item->text() ); |
920 | ipkg.runIpkg( ); | 920 | ipkg.runIpkg( ); |
921 | } | 921 | } |
922 | } | 922 | } |
923 | } | 923 | } |
924 | 924 | ||
925 | void MainWindow :: downloadRemotePackage() | 925 | void MainWindow :: downloadRemotePackage() |
926 | { | 926 | { |
927 | // Display dialog | 927 | // Display dialog |
928 | bool ok; | 928 | bool ok; |
929 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 929 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
930 | if ( !ok || package.isEmpty() ) | 930 | if ( !ok || package.isEmpty() ) |
931 | return; | 931 | return; |
932 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 932 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
933 | // if ( dlg.exec() == QDialog::Rejected ) | 933 | // if ( dlg.exec() == QDialog::Rejected ) |
934 | // return; | 934 | // return; |
935 | 935 | ||
936 | // grab details from dialog | 936 | // grab details from dialog |
937 | // QString package = dlg.getPackageLocation(); | 937 | // QString package = dlg.getPackageLocation(); |
938 | 938 | ||
939 | InstallData *item = new InstallData(); | 939 | InstallData *item = new InstallData(); |
940 | item->option = "I"; | 940 | item->option = "I"; |
941 | item->packageName = package; | 941 | item->packageName = package; |
942 | QList<InstallData> workingPackages; | 942 | QList<InstallData> workingPackages; |
943 | workingPackages.setAutoDelete( TRUE ); | 943 | workingPackages.setAutoDelete( TRUE ); |
944 | workingPackages.append( item ); | 944 | workingPackages.append( item ); |
945 | 945 | ||
946 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 946 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
947 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 947 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
948 | reloadDocuments = TRUE; | 948 | reloadDocuments = TRUE; |
949 | stack->addWidget( dlg, 3 ); | 949 | stack->addWidget( dlg, 3 ); |
950 | stack->raiseWidget( dlg ); | 950 | stack->raiseWidget( dlg ); |
951 | } | 951 | } |
952 | 952 | ||
953 | 953 | ||
954 | void MainWindow :: applyChanges() | 954 | void MainWindow :: applyChanges() |
955 | { | 955 | { |
956 | stickyOption = ""; | 956 | stickyOption = ""; |
957 | 957 | ||
958 | // First, write out ipkg_conf file so that ipkg can use it | 958 | // First, write out ipkg_conf file so that ipkg can use it |
959 | mgr->writeOutIpkgConf(); | 959 | mgr->writeOutIpkgConf(); |
960 | 960 | ||
961 | // Now for each selected item | 961 | // Now for each selected item |
962 | // deal with it | 962 | // deal with it |
963 | 963 | ||
964 | QList<InstallData> workingPackages; | 964 | QList<InstallData> workingPackages; |
965 | workingPackages.setAutoDelete( TRUE ); | 965 | workingPackages.setAutoDelete( TRUE ); |
966 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 966 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
967 | item != 0 ; | 967 | item != 0 ; |
968 | item = (QCheckListItem *)item->nextSibling() ) | 968 | item = (QCheckListItem *)item->nextSibling() ) |
969 | { | 969 | { |
970 | if ( item->isOn() ) | 970 | if ( item->isOn() ) |
971 | { | 971 | { |
972 | InstallData *instdata = dealWithItem( item ); | 972 | InstallData *instdata = dealWithItem( item ); |
973 | if ( instdata ) | 973 | if ( instdata ) |
974 | workingPackages.append( instdata ); | 974 | workingPackages.append( instdata ); |
975 | else | 975 | else |
976 | return; | 976 | return; |
977 | } | 977 | } |
978 | } | 978 | } |
979 | 979 | ||
980 | if ( workingPackages.count() == 0 ) | 980 | if ( workingPackages.count() == 0 ) |
981 | { | 981 | { |
982 | // Nothing to do | 982 | // Nothing to do |
983 | QMessageBox::information( this, tr( "Nothing to do" ), | 983 | QMessageBox::information( this, tr( "Nothing to do" ), |
984 | tr( "No packages selected" ), tr( "OK" ) ); | 984 | tr( "No packages selected" ), tr( "OK" ) ); |
985 | 985 | ||
986 | return; | 986 | return; |
987 | } | 987 | } |
988 | 988 | ||
989 | // do the stuff | 989 | // do the stuff |
990 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 990 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
991 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 991 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
992 | reloadDocuments = TRUE; | 992 | reloadDocuments = TRUE; |
993 | stack->addWidget( dlg, 3 ); | 993 | stack->addWidget( dlg, 3 ); |
994 | stack->raiseWidget( dlg ); | 994 | stack->raiseWidget( dlg ); |
995 | } | 995 | } |
996 | 996 | ||
997 | // decide what to do - either remove, upgrade or install | 997 | // decide what to do - either remove, upgrade or install |
998 | // Current rules: | 998 | // Current rules: |
999 | // If not installed - install | 999 | // If not installed - install |
1000 | // If installed and different version available - upgrade | 1000 | // If installed and different version available - upgrade |
1001 | // If installed and version up to date - remove | 1001 | // If installed and version up to date - remove |
1002 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 1002 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
1003 | { | 1003 | { |
1004 | QString name = item->text(); | 1004 | QString name = item->text(); |
1005 | 1005 | ||
1006 | // Get package | 1006 | // Get package |
1007 | Server *s = mgr->getServer( serversList->currentText() ); | 1007 | Server *s = mgr->getServer( serversList->currentText() ); |
1008 | Package *p = s->getPackage( name ); | 1008 | Package *p = s->getPackage( name ); |
1009 | 1009 | ||
1010 | // If the package has a filename then it is a local file | 1010 | // If the package has a filename then it is a local file |
1011 | if ( p->isPackageStoredLocally() ) | 1011 | if ( p->isPackageStoredLocally() ) |
1012 | name = p->getFilename(); | 1012 | name = p->getFilename(); |
1013 | 1013 | ||
1014 | QString option; | 1014 | QString option; |
1015 | QString dest = "root"; | 1015 | QString dest = "root"; |
1016 | if ( !p->isInstalled() ) | 1016 | if ( !p->isInstalled() ) |
1017 | { | 1017 | { |
1018 | InstallData *newitem = new InstallData(); | 1018 | InstallData *newitem = new InstallData(); |
1019 | newitem->option = "I"; | 1019 | newitem->option = "I"; |
1020 | newitem->packageName = name; | 1020 | newitem->packageName = name; |
1021 | return newitem; | 1021 | return newitem; |
1022 | } | 1022 | } |
1023 | else | 1023 | else |
1024 | { | 1024 | { |
1025 | InstallData *newitem = new InstallData(); | 1025 | InstallData *newitem = new InstallData(); |
1026 | newitem->option = "D"; | 1026 | newitem->option = "D"; |
1027 | // If local file, remove using package name, not filename | 1027 | // If local file, remove using package name, not filename |
1028 | if ( p->isPackageStoredLocally() ) | 1028 | if ( p->isPackageStoredLocally() ) |
1029 | name = item->text(); | 1029 | name = item->text(); |
1030 | 1030 | ||
1031 | if ( !p->isPackageStoredLocally() ) | 1031 | if ( !p->isPackageStoredLocally() ) |
1032 | newitem->packageName = p->getInstalledPackageName(); | 1032 | newitem->packageName = p->getInstalledPackageName(); |
1033 | else | 1033 | else |
1034 | newitem->packageName = name; | 1034 | newitem->packageName = name; |
1035 | 1035 | ||
1036 | if ( p->getInstalledTo() ) | 1036 | if ( p->getInstalledTo() ) |
1037 | { | 1037 | { |
1038 | newitem->destination = p->getInstalledTo(); | 1038 | newitem->destination = p->getInstalledTo(); |
1039 | } | 1039 | } |
1040 | else | 1040 | else |
1041 | { | 1041 | { |
1042 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1042 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | // Now see if version is newer or not | 1045 | // Now see if version is newer or not |
1046 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1046 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1047 | 1047 | ||
1048 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1048 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1049 | if ( p->isPackageStoredLocally() && val == -1 ) | 1049 | if ( p->isPackageStoredLocally() && val == -1 ) |
1050 | val = 0; | 1050 | val = 0; |
1051 | 1051 | ||
1052 | if ( val == -2 ) | 1052 | if ( val == -2 ) |
1053 | { | 1053 | { |
1054 | // Error - should handle | 1054 | // Error - should handle |
1055 | } | 1055 | } |
1056 | else if ( val == -1 ) | 1056 | else if ( val == -1 ) |
1057 | { | 1057 | { |
1058 | // Version available is older - remove only | 1058 | // Version available is older - remove only |
1059 | newitem->option = "D"; | 1059 | newitem->option = "D"; |
1060 | // If local file, remove using package name, not filename | 1060 | // If local file, remove using package name, not filename |
1061 | if ( p->isPackageStoredLocally() ) | 1061 | if ( p->isPackageStoredLocally() ) |
1062 | name = item->text(); | 1062 | name = item->text(); |
1063 | } | 1063 | } |
1064 | else | 1064 | else |
1065 | { | 1065 | { |
1066 | QString caption; | 1066 | QString caption; |
1067 | QString text; | 1067 | QString text; |
1068 | QString secondButton; | 1068 | QString secondButton; |
1069 | QString secondOption; | 1069 | QString secondOption; |
1070 | if ( val == 0 ) | 1070 | if ( val == 0 ) |
1071 | { | 1071 | { |
1072 | // Version available is the same - option to remove or reinstall | 1072 | // Version available is the same - option to remove or reinstall |
1073 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1073 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1074 | text = tr( "Remove or ReInstall" ); | 1074 | text = tr( "Remove or ReInstall" ); |
1075 | secondButton = tr( "ReInstall" ); | 1075 | secondButton = tr( "ReInstall" ); |
1076 | secondOption = "R"; // Internal action code, do not translate | 1076 | secondOption = "R"; // Internal action code, do not translate |
1077 | } | 1077 | } |
1078 | else if ( val == 1 ) | 1078 | else if ( val == 1 ) |
1079 | { | 1079 | { |
1080 | // Version available is newer - option to remove or upgrade | 1080 | // Version available is newer - option to remove or upgrade |
1081 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1081 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1082 | text = tr( "Remove or Upgrade" ); | 1082 | text = tr( "Remove or Upgrade" ); |
1083 | secondButton = tr( "Upgrade" ); | 1083 | secondButton = tr( "Upgrade" ); |
1084 | secondOption = "U"; // Internal action code, do not translate | 1084 | secondOption = "U"; // Internal action code, do not translate |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | // Sticky option not implemented yet, but will eventually allow | 1087 | // Sticky option not implemented yet, but will eventually allow |
1088 | // the user to say something like 'remove all' | 1088 | // the user to say something like 'remove all' |
1089 | if ( stickyOption == "" ) | 1089 | if ( stickyOption == "" ) |
1090 | { | 1090 | { |
1091 | QString msgtext; | 1091 | QString msgtext; |
1092 | msgtext = caption.arg( ( const char * )name ); | 1092 | msgtext = caption.arg( ( const char * )name ); |
1093 | QuestionDlg dlg( text, msgtext, secondButton ); | 1093 | QuestionDlg dlg( text, msgtext, secondButton ); |
1094 | switch( dlg.exec() ) | 1094 | switch( dlg.exec() ) |
1095 | { | 1095 | { |
1096 | case 0: // Cancel | 1096 | case 0: // Cancel |
1097 | delete newitem; | 1097 | delete newitem; |
1098 | return 0x0; | 1098 | return 0x0; |
1099 | break; | 1099 | break; |
1100 | case 1: // Remove | 1100 | case 1: // Remove |
1101 | newitem->option = "D"; | 1101 | newitem->option = "D"; |
1102 | // If local file, remove using package name, not filename | 1102 | // If local file, remove using package name, not filename |
1103 | if ( p->isPackageStoredLocally() ) | 1103 | if ( p->isPackageStoredLocally() ) |
1104 | name = item->text(); | 1104 | name = item->text(); |
1105 | break; | 1105 | break; |
1106 | case 2: // Reinstall or Upgrade | 1106 | case 2: // Reinstall or Upgrade |
1107 | newitem->option = secondOption; | 1107 | newitem->option = secondOption; |
1108 | break; | 1108 | break; |
1109 | } | 1109 | } |
1110 | } | 1110 | } |
1111 | else | 1111 | else |
1112 | { | 1112 | { |
1113 | // newitem->option = stickyOption; | 1113 | // newitem->option = stickyOption; |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | 1117 | ||
1118 | // Check if we are reinstalling the same version | 1118 | // Check if we are reinstalling the same version |
1119 | if ( newitem->option != "R" ) | 1119 | if ( newitem->option != "R" ) |
1120 | newitem->recreateLinks = true; | 1120 | newitem->recreateLinks = true; |
1121 | else | 1121 | else |
1122 | newitem->recreateLinks = false; | 1122 | newitem->recreateLinks = false; |
1123 | 1123 | ||
1124 | // User hit cancel (on dlg - assume remove) | 1124 | // User hit cancel (on dlg - assume remove) |
1125 | return newitem; | 1125 | return newitem; |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1129 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1130 | { | 1130 | { |
1131 | stack->raiseWidget( progressWindow ); | 1131 | stack->raiseWidget( progressWindow ); |
1132 | 1132 | ||
1133 | if ( dlg ) | 1133 | if ( dlg ) |
1134 | { | 1134 | { |
1135 | dlg->close(); | 1135 | dlg->close(); |
1136 | delete dlg; | 1136 | delete dlg; |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | mgr->reloadServerData(); | 1139 | mgr->reloadServerData(); |
1140 | serverSelected( -1, FALSE ); | 1140 | serverSelected( -1, FALSE ); |
1141 | 1141 | ||
1142 | #ifdef QWS | 1142 | #ifdef QWS |
1143 | if ( reloadDocuments ) | 1143 | if ( reloadDocuments ) |
1144 | { | 1144 | { |
1145 | m_status->setText( tr( "Updating Launcher..." ) ); | 1145 | m_status->setText( tr( "Updating Launcher..." ) ); |
1146 | 1146 | ||
1147 | // Finally let the main system update itself | 1147 | // Finally let the main system update itself |
1148 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1148 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1149 | QString lf = QString::null; | 1149 | QString lf = QString::null; |
1150 | e << lf; | 1150 | e << lf; |
1151 | } | 1151 | } |
1152 | #endif | 1152 | #endif |
1153 | 1153 | ||
1154 | stack->raiseWidget( networkPkgWindow ); | 1154 | stack->raiseWidget( networkPkgWindow ); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | void MainWindow :: letterPushed( QString t ) | 1157 | void MainWindow :: letterPushed( QString t ) |
1158 | { | 1158 | { |
1159 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1159 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1160 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1160 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1161 | if ( packagesList->firstChild() == 0 ) | 1161 | if ( packagesList->firstChild() == 0 ) |
1162 | return; | 1162 | return; |
1163 | 1163 | ||
1164 | QCheckListItem *item; | 1164 | QCheckListItem *item; |
1165 | if ( start == 0 ) | 1165 | if ( start == 0 ) |
1166 | { | 1166 | { |
1167 | item = (QCheckListItem *)packagesList->firstChild(); | 1167 | item = (QCheckListItem *)packagesList->firstChild(); |
1168 | start = top; | 1168 | start = top; |
1169 | } | 1169 | } |
1170 | else | 1170 | else |
1171 | item = (QCheckListItem *)start->nextSibling(); | 1171 | item = (QCheckListItem *)start->nextSibling(); |
1172 | 1172 | ||
1173 | if ( item == 0 ) | 1173 | if ( item == 0 ) |
1174 | item = (QCheckListItem *)packagesList->firstChild(); | 1174 | item = (QCheckListItem *)packagesList->firstChild(); |
1175 | do | 1175 | do |
1176 | { | 1176 | { |
1177 | if ( item->text().lower().startsWith( t.lower() ) ) | 1177 | if ( item->text().lower().startsWith( t.lower() ) ) |
1178 | { | 1178 | { |
1179 | packagesList->setSelected( item, true ); | 1179 | packagesList->setSelected( item, true ); |
1180 | packagesList->ensureItemVisible( item ); | 1180 | packagesList->ensureItemVisible( item ); |
1181 | break; | 1181 | break; |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | item = (QCheckListItem *)item->nextSibling(); | 1184 | item = (QCheckListItem *)item->nextSibling(); |
1185 | if ( !item ) | 1185 | if ( !item ) |
1186 | item = (QCheckListItem *)packagesList->firstChild(); | 1186 | item = (QCheckListItem *)packagesList->firstChild(); |
1187 | } | 1187 | } |
1188 | while ( item != start); | 1188 | while ( item != start); |
1189 | } | 1189 | } |
1190 | 1190 | ||
1191 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1191 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1192 | { | 1192 | { |
1193 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1193 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1194 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1194 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1195 | QPEApplication::showWidget( p ); | 1195 | QPEApplication::showWidget( p ); |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | 1198 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) |
1199 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 1199 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
1200 | { | 1200 | { |
1201 | setCaption( caption ); | 1201 | setCaption( caption ); |
1202 | resize( 175, 100 ); | 1202 | resize( 175, 100 ); |
1203 | 1203 | ||
1204 | QGridLayout *layout = new QGridLayout( this ); | 1204 | QGridLayout *layout = new QGridLayout( this ); |
1205 | 1205 | ||
1206 | QLabel *l = new QLabel( text, this ); | 1206 | QLabel *l = new QLabel( text, this ); |
1207 | l->setAlignment( AlignCenter | WordBreak ); | 1207 | l->setAlignment( AlignCenter | WordBreak ); |
1208 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | 1208 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); |
1209 | 1209 | ||
1210 | btn1 = new QPushButton( tr( "Remove" ), this ); | 1210 | btn1 = new QPushButton( tr( "Remove" ), this ); |
1211 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1211 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1212 | layout->addWidget( btn1, 1, 0 ); | 1212 | layout->addWidget( btn1, 1, 0 ); |
1213 | 1213 | ||
1214 | btn2 = new QPushButton( secondbtn, this ); | 1214 | btn2 = new QPushButton( secondbtn, this ); |
1215 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1215 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1216 | layout->addWidget( btn2, 1, 1 ); | 1216 | layout->addWidget( btn2, 1, 1 ); |
1217 | 1217 | ||
1218 | executing = FALSE; | 1218 | executing = FALSE; |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | int QuestionDlg::exec() | 1221 | int QuestionDlg::exec() |
1222 | { | 1222 | { |
1223 | show(); | 1223 | show(); |
1224 | 1224 | ||
1225 | if ( !executing ) | 1225 | if ( !executing ) |
1226 | { | 1226 | { |
1227 | executing = TRUE; | 1227 | executing = TRUE; |
1228 | qApp->enter_loop(); | 1228 | qApp->enter_loop(); |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | return buttonpressed; | 1231 | return buttonpressed; |
1232 | } | 1232 | } |
1233 | 1233 | ||
1234 | void QuestionDlg::slotButtonPressed() | 1234 | void QuestionDlg::slotButtonPressed() |
1235 | { | 1235 | { |
1236 | if ( sender() == btn1 ) | 1236 | if ( sender() == btn1 ) |
1237 | buttonpressed = 1; | 1237 | buttonpressed = 1; |
1238 | else if ( sender() == btn2 ) | 1238 | else if ( sender() == btn2 ) |
1239 | buttonpressed = 2; | 1239 | buttonpressed = 2; |
1240 | else | 1240 | else |
1241 | buttonpressed = 0; | 1241 | buttonpressed = 0; |
1242 | 1242 | ||
1243 | qApp->exit_loop(); | 1243 | qApp->exit_loop(); |
1244 | } | 1244 | } |
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 6e9dd99..b9dbb6e 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -1,494 +1,494 @@ | |||
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 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 55 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
56 | : QDialog( parent, name, modal, fl ) | 56 | : QDialog( parent, name, modal, fl ) |
57 | { | 57 | { |
58 | setCaption( tr( "Configuration" ) ); | 58 | setCaption( tr( "Configuration" ) ); |
59 | 59 | ||
60 | // Setup layout to make everything pretty | 60 | // Setup layout to make everything pretty |
61 | QVBoxLayout *layout = new QVBoxLayout( this ); | 61 | QVBoxLayout *layout = new QVBoxLayout( this ); |
62 | layout->setMargin( 2 ); | 62 | layout->setMargin( 2 ); |
63 | layout->setSpacing( 4 ); | 63 | layout->setSpacing( 4 ); |
64 | 64 | ||
65 | // Setup tabs for all info | 65 | // Setup tabs for all info |
66 | Opie::OTabWidget *tabwidget = new Opie::OTabWidget( this ); | 66 | Opie::OTabWidget *tabwidget = new Opie::OTabWidget( this ); |
67 | layout->addWidget( tabwidget ); | 67 | layout->addWidget( tabwidget ); |
68 | 68 | ||
69 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); | 69 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); |
70 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); | 70 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); |
71 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); | 71 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); |
72 | tabwidget->setCurrentTab( tr( "Servers" ) ); | 72 | tabwidget->setCurrentTab( tr( "Servers" ) ); |
73 | 73 | ||
74 | dataMgr = dataManager; | 74 | dataMgr = dataManager; |
75 | setupData(); | 75 | setupData(); |
76 | changed = false; | 76 | changed = false; |
77 | newserver = false; | 77 | newserver = false; |
78 | newdestination = false; | 78 | newdestination = false; |
79 | } | 79 | } |
80 | 80 | ||
81 | SettingsImpl :: ~SettingsImpl() | 81 | SettingsImpl :: ~SettingsImpl() |
82 | { | 82 | { |
83 | } | 83 | } |
84 | 84 | ||
85 | bool SettingsImpl :: showDlg() | 85 | bool SettingsImpl :: showDlg() |
86 | { | 86 | { |
87 | QPEApplication::execDialog( this ); | 87 | QPEApplication::execDialog( this ); |
88 | if ( changed ) | 88 | if ( changed ) |
89 | dataMgr->writeOutIpkgConf(); | 89 | dataMgr->writeOutIpkgConf(); |
90 | 90 | ||
91 | return changed; | 91 | return changed; |
92 | } | 92 | } |
93 | 93 | ||
94 | QWidget *SettingsImpl :: initServerTab() | 94 | QWidget *SettingsImpl :: initServerTab() |
95 | { | 95 | { |
96 | QWidget *control = new QWidget( this ); | 96 | QWidget *control = new QWidget( this ); |
97 | 97 | ||
98 | QVBoxLayout *vb = new QVBoxLayout( control ); | 98 | QVBoxLayout *vb = new QVBoxLayout( control ); |
99 | 99 | ||
100 | QScrollView *sv = new QScrollView( control ); | 100 | QScrollView *sv = new QScrollView( control ); |
101 | vb->addWidget( sv, 0, 0 ); | 101 | vb->addWidget( sv, 0, 0 ); |
102 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 102 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
103 | sv->setFrameStyle( QFrame::NoFrame ); | 103 | sv->setFrameStyle( QFrame::NoFrame ); |
104 | 104 | ||
105 | QWidget *container = new QWidget( sv->viewport() ); | 105 | QWidget *container = new QWidget( sv->viewport() ); |
106 | sv->addChild( container ); | 106 | sv->addChild( container ); |
107 | 107 | ||
108 | QGridLayout *layout = new QGridLayout( container ); | 108 | QGridLayout *layout = new QGridLayout( container ); |
109 | layout->setSpacing( 2 ); | 109 | layout->setSpacing( 2 ); |
110 | layout->setMargin( 4 ); | 110 | layout->setMargin( 4 ); |
111 | 111 | ||
112 | servers = new QListBox( container ); | 112 | servers = new QListBox( container ); |
113 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 113 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
114 | connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); | 114 | connect( servers, SIGNAL( highlighted(int) ), this, SLOT( editServer(int) ) ); |
115 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); | 115 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); |
116 | 116 | ||
117 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 117 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
118 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); | 118 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); |
119 | layout->addWidget( btn, 1, 0 ); | 119 | layout->addWidget( btn, 1, 0 ); |
120 | 120 | ||
121 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 121 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
122 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); | 122 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); |
123 | layout->addWidget( btn, 1, 1 ); | 123 | layout->addWidget( btn, 1, 1 ); |
124 | 124 | ||
125 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 125 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
126 | grpbox->layout()->setSpacing( 2 ); | 126 | grpbox->layout()->setSpacing( 2 ); |
127 | grpbox->layout()->setMargin( 4 ); | 127 | grpbox->layout()->setMargin( 4 ); |
128 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 128 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
129 | 129 | ||
130 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 130 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
131 | 131 | ||
132 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 132 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
133 | grplayout->addWidget( label, 0, 0 ); | 133 | grplayout->addWidget( label, 0, 0 ); |
134 | servername = new QLineEdit( grpbox ); | 134 | servername = new QLineEdit( grpbox ); |
135 | grplayout->addWidget( servername, 0, 1 ); | 135 | grplayout->addWidget( servername, 0, 1 ); |
136 | 136 | ||
137 | label = new QLabel( tr( "Address:" ), grpbox ); | 137 | label = new QLabel( tr( "Address:" ), grpbox ); |
138 | grplayout->addWidget( label, 1, 0 ); | 138 | grplayout->addWidget( label, 1, 0 ); |
139 | serverurl = new QLineEdit( grpbox ); | 139 | serverurl = new QLineEdit( grpbox ); |
140 | grplayout->addWidget( serverurl, 1, 1 ); | 140 | grplayout->addWidget( serverurl, 1, 1 ); |
141 | 141 | ||
142 | active = new QCheckBox( tr( "Active Server" ), grpbox ); | 142 | active = new QCheckBox( tr( "Active Server" ), grpbox ); |
143 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); | 143 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); |
144 | 144 | ||
145 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 145 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
146 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); | 146 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); |
147 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 147 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
148 | 148 | ||
149 | return control; | 149 | return control; |
150 | } | 150 | } |
151 | 151 | ||
152 | QWidget *SettingsImpl :: initDestinationTab() | 152 | QWidget *SettingsImpl :: initDestinationTab() |
153 | { | 153 | { |
154 | QWidget *control = new QWidget( this ); | 154 | QWidget *control = new QWidget( this ); |
155 | 155 | ||
156 | QVBoxLayout *vb = new QVBoxLayout( control ); | 156 | QVBoxLayout *vb = new QVBoxLayout( control ); |
157 | 157 | ||
158 | QScrollView *sv = new QScrollView( control ); | 158 | QScrollView *sv = new QScrollView( control ); |
159 | vb->addWidget( sv, 0, 0 ); | 159 | vb->addWidget( sv, 0, 0 ); |
160 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 160 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
161 | sv->setFrameStyle( QFrame::NoFrame ); | 161 | sv->setFrameStyle( QFrame::NoFrame ); |
162 | 162 | ||
163 | QWidget *container = new QWidget( sv->viewport() ); | 163 | QWidget *container = new QWidget( sv->viewport() ); |
164 | sv->addChild( container ); | 164 | sv->addChild( container ); |
165 | 165 | ||
166 | QGridLayout *layout = new QGridLayout( container ); | 166 | QGridLayout *layout = new QGridLayout( container ); |
167 | layout->setSpacing( 2 ); | 167 | layout->setSpacing( 2 ); |
168 | layout->setMargin( 4 ); | 168 | layout->setMargin( 4 ); |
169 | 169 | ||
170 | destinations = new QListBox( container ); | 170 | destinations = new QListBox( container ); |
171 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 171 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
172 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); | 172 | connect( destinations, SIGNAL( highlighted(int) ), this, SLOT( editDestination(int) ) ); |
173 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); | 173 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); |
174 | 174 | ||
175 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 175 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
176 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); | 176 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); |
177 | layout->addWidget( btn, 1, 0 ); | 177 | layout->addWidget( btn, 1, 0 ); |
178 | 178 | ||
179 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 179 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
180 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); | 180 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); |
181 | layout->addWidget( btn, 1, 1 ); | 181 | layout->addWidget( btn, 1, 1 ); |
182 | 182 | ||
183 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 183 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
184 | grpbox->layout()->setSpacing( 2 ); | 184 | grpbox->layout()->setSpacing( 2 ); |
185 | grpbox->layout()->setMargin( 4 ); | 185 | grpbox->layout()->setMargin( 4 ); |
186 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 186 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
187 | 187 | ||
188 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 188 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
189 | 189 | ||
190 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 190 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
191 | grplayout->addWidget( label, 0, 0 ); | 191 | grplayout->addWidget( label, 0, 0 ); |
192 | destinationname = new QLineEdit( grpbox ); | 192 | destinationname = new QLineEdit( grpbox ); |
193 | grplayout->addWidget( destinationname, 0, 1 ); | 193 | grplayout->addWidget( destinationname, 0, 1 ); |
194 | 194 | ||
195 | label = new QLabel( tr( "Location:" ), grpbox ); | 195 | label = new QLabel( tr( "Location:" ), grpbox ); |
196 | grplayout->addWidget( label, 1, 0 ); | 196 | grplayout->addWidget( label, 1, 0 ); |
197 | destinationurl = new QLineEdit( grpbox ); | 197 | destinationurl = new QLineEdit( grpbox ); |
198 | grplayout->addWidget( destinationurl, 1, 1 ); | 198 | grplayout->addWidget( destinationurl, 1, 1 ); |
199 | 199 | ||
200 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); | 200 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); |
201 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 201 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
202 | 202 | ||
203 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 203 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
204 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); | 204 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); |
205 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 205 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
206 | 206 | ||
207 | return control; | 207 | return control; |
208 | } | 208 | } |
209 | 209 | ||
210 | QWidget *SettingsImpl :: initProxyTab() | 210 | QWidget *SettingsImpl :: initProxyTab() |
211 | { | 211 | { |
212 | QWidget *control = new QWidget( this ); | 212 | QWidget *control = new QWidget( this ); |
213 | 213 | ||
214 | QVBoxLayout *vb = new QVBoxLayout( control ); | 214 | QVBoxLayout *vb = new QVBoxLayout( control ); |
215 | 215 | ||
216 | QScrollView *sv = new QScrollView( control ); | 216 | QScrollView *sv = new QScrollView( control ); |
217 | vb->addWidget( sv, 0, 0 ); | 217 | vb->addWidget( sv, 0, 0 ); |
218 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 218 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
219 | sv->setFrameStyle( QFrame::NoFrame ); | 219 | sv->setFrameStyle( QFrame::NoFrame ); |
220 | 220 | ||
221 | QWidget *container = new QWidget( sv->viewport() ); | 221 | QWidget *container = new QWidget( sv->viewport() ); |
222 | sv->addChild( container ); | 222 | sv->addChild( container ); |
223 | 223 | ||
224 | QGridLayout *layout = new QGridLayout( container ); | 224 | QGridLayout *layout = new QGridLayout( container ); |
225 | layout->setSpacing( 2 ); | 225 | layout->setSpacing( 2 ); |
226 | layout->setMargin( 4 ); | 226 | layout->setMargin( 4 ); |
227 | 227 | ||
228 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 228 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
229 | grpbox->layout()->setSpacing( 2 ); | 229 | grpbox->layout()->setSpacing( 2 ); |
230 | grpbox->layout()->setMargin( 4 ); | 230 | grpbox->layout()->setMargin( 4 ); |
231 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 231 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
232 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 232 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
233 | txtHttpProxy = new QLineEdit( grpbox ); | 233 | txtHttpProxy = new QLineEdit( grpbox ); |
234 | grplayout->addWidget( txtHttpProxy ); | 234 | grplayout->addWidget( txtHttpProxy ); |
235 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 235 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
236 | grplayout->addWidget( chkHttpProxyEnabled ); | 236 | grplayout->addWidget( chkHttpProxyEnabled ); |
237 | 237 | ||
238 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 238 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
239 | grpbox->layout()->setSpacing( 2 ); | 239 | grpbox->layout()->setSpacing( 2 ); |
240 | grpbox->layout()->setMargin( 4 ); | 240 | grpbox->layout()->setMargin( 4 ); |
241 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 241 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
242 | grplayout = new QVBoxLayout( grpbox->layout() ); | 242 | grplayout = new QVBoxLayout( grpbox->layout() ); |
243 | txtFtpProxy = new QLineEdit( grpbox ); | 243 | txtFtpProxy = new QLineEdit( grpbox ); |
244 | grplayout->addWidget( txtFtpProxy ); | 244 | grplayout->addWidget( txtFtpProxy ); |
245 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 245 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
246 | grplayout->addWidget( chkFtpProxyEnabled ); | 246 | grplayout->addWidget( chkFtpProxyEnabled ); |
247 | 247 | ||
248 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 248 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
249 | layout->addWidget( label, 2, 0 ); | 249 | layout->addWidget( label, 2, 0 ); |
250 | txtUsername = new QLineEdit( container ); | 250 | txtUsername = new QLineEdit( container ); |
251 | layout->addWidget( txtUsername, 2, 1 ); | 251 | layout->addWidget( txtUsername, 2, 1 ); |
252 | 252 | ||
253 | label = new QLabel( tr( "Password:" ), container ); | 253 | label = new QLabel( tr( "Password:" ), container ); |
254 | layout->addWidget( label, 3, 0 ); | 254 | layout->addWidget( label, 3, 0 ); |
255 | txtPassword = new QLineEdit( container ); | 255 | txtPassword = new QLineEdit( container ); |
256 | layout->addWidget( txtPassword, 3, 1 ); | 256 | layout->addWidget( txtPassword, 3, 1 ); |
257 | 257 | ||
258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); |
259 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); | 259 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); |
260 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 260 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
261 | 261 | ||
262 | return control; | 262 | return control; |
263 | } | 263 | } |
264 | 264 | ||
265 | void SettingsImpl :: setupData() | 265 | void SettingsImpl :: setupData() |
266 | { | 266 | { |
267 | // add servers | 267 | // add servers |
268 | QString serverName; | 268 | QString serverName; |
269 | QListIterator<Server> it( dataMgr->getServerList() ); | 269 | QListIterator<Server> it( dataMgr->getServerList() ); |
270 | for ( ; it.current(); ++it ) | 270 | for ( ; it.current(); ++it ) |
271 | { | 271 | { |
272 | serverName = it.current()->getServerName(); | 272 | serverName = it.current()->getServerName(); |
273 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) | 273 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) |
274 | continue; | 274 | continue; |
275 | 275 | ||
276 | servers->insertItem( serverName ); | 276 | servers->insertItem( serverName ); |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | // add destinations | 280 | // add destinations |
281 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); | 281 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); |
282 | for ( ; it2.current(); ++it2 ) | 282 | for ( ; it2.current(); ++it2 ) |
283 | destinations->insertItem( it2.current()->getDestinationName() ); | 283 | destinations->insertItem( it2.current()->getDestinationName() ); |
284 | 284 | ||
285 | // setup proxy tab | 285 | // setup proxy tab |
286 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); | 286 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); |
287 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); | 287 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); |
288 | txtUsername->setText( dataMgr->getProxyUsername() ); | 288 | txtUsername->setText( dataMgr->getProxyUsername() ); |
289 | txtPassword->setText( dataMgr->getProxyPassword() ); | 289 | txtPassword->setText( dataMgr->getProxyPassword() ); |
290 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); | 290 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); |
291 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); | 291 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); |
292 | } | 292 | } |
293 | 293 | ||
294 | //------------------ Servers tab ---------------------- | 294 | //------------------ Servers tab ---------------------- |
295 | 295 | ||
296 | void SettingsImpl :: editServer( int sel ) | 296 | void SettingsImpl :: editServer( int sel ) |
297 | { | 297 | { |
298 | currentSelectedServer = sel; | 298 | currentSelectedServer = sel; |
299 | Server *s = dataMgr->getServer( servers->currentText() ); | 299 | Server *s = dataMgr->getServer( servers->currentText() ); |
300 | if ( s ) | 300 | if ( s ) |
301 | { | 301 | { |
302 | serverName = s->getServerName(); | 302 | serverName = s->getServerName(); |
303 | servername->setText( s->getServerName() ); | 303 | servername->setText( s->getServerName() ); |
304 | serverurl->setText( s->getServerUrl() ); | 304 | serverurl->setText( s->getServerUrl() ); |
305 | active->setChecked( s->isServerActive() ); | 305 | active->setChecked( s->isServerActive() ); |
306 | } | 306 | } |
307 | else | 307 | else |
308 | { | 308 | { |
309 | serverName = ""; | 309 | serverName = ""; |
310 | servername->setText( "" ); | 310 | servername->setText( "" ); |
311 | serverurl->setText( "" ); | 311 | serverurl->setText( "" ); |
312 | active->setChecked( false ); | 312 | active->setChecked( false ); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | void SettingsImpl :: newServer() | 316 | void SettingsImpl :: newServer() |
317 | { | 317 | { |
318 | newserver = true; | 318 | newserver = true; |
319 | servername->setText( "" ); | 319 | servername->setText( "" ); |
320 | serverurl->setText( "" ); | 320 | serverurl->setText( "" ); |
321 | servername->setFocus(); | 321 | servername->setFocus(); |
322 | active->setChecked( true ); | 322 | active->setChecked( true ); |
323 | } | 323 | } |
324 | 324 | ||
325 | void SettingsImpl :: removeServer() | 325 | void SettingsImpl :: removeServer() |
326 | { | 326 | { |
327 | changed = true; | 327 | changed = true; |
328 | Server *s = dataMgr->getServer( servers->currentText() ); | 328 | Server *s = dataMgr->getServer( servers->currentText() ); |
329 | if ( s ) | 329 | if ( s ) |
330 | { | 330 | { |
331 | dataMgr->getServerList().removeRef( s ); | 331 | dataMgr->getServerList().removeRef( s ); |
332 | servers->removeItem( currentSelectedServer ); | 332 | servers->removeItem( currentSelectedServer ); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | void SettingsImpl :: changeServerDetails() | 336 | void SettingsImpl :: changeServerDetails() |
337 | { | 337 | { |
338 | changed = true; | 338 | changed = true; |
339 | 339 | ||
340 | QString newName = servername->text(); | 340 | QString newName = servername->text(); |
341 | 341 | ||
342 | // Convert any spaces to underscores | 342 | // Convert any spaces to underscores |
343 | char *tmpStr = new char[newName.length() + 1]; | 343 | char *tmpStr = new char[newName.length() + 1]; |
344 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) | 344 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) |
345 | { | 345 | { |
346 | if ( newName[i] == ' ' ) | 346 | if ( newName[i] == ' ' ) |
347 | tmpStr[i] = '_'; | 347 | tmpStr[i] = '_'; |
348 | else | 348 | else |
349 | tmpStr[i] = newName[i].latin1(); | 349 | tmpStr[i] = newName[i].latin1(); |
350 | } | 350 | } |
351 | tmpStr[newName.length()] = '\0'; | 351 | tmpStr[newName.length()] = '\0'; |
352 | 352 | ||
353 | newName = tmpStr; | 353 | newName = tmpStr; |
354 | delete tmpStr; | 354 | delete tmpStr; |
355 | 355 | ||
356 | if ( !newserver ) | 356 | if ( !newserver ) |
357 | { | 357 | { |
358 | Server *s = dataMgr->getServer( servers->currentText() ); | 358 | Server *s = dataMgr->getServer( servers->currentText() ); |
359 | if ( s ) | 359 | if ( s ) |
360 | { | 360 | { |
361 | // Update url | 361 | // Update url |
362 | s->setServerUrl( serverurl->text() ); | 362 | s->setServerUrl( serverurl->text() ); |
363 | s->setActive( active->isChecked() ); | 363 | s->setActive( active->isChecked() ); |
364 | 364 | ||
365 | // Check if server name has changed, if it has then we need to replace the key in the map | 365 | // Check if server name has changed, if it has then we need to replace the key in the map |
366 | if ( serverName != newName ) | 366 | if ( serverName != newName ) |
367 | { | 367 | { |
368 | // Update server name | 368 | // Update server name |
369 | s->setServerName( newName ); | 369 | s->setServerName( newName ); |
370 | } | 370 | } |
371 | 371 | ||
372 | // Update list box | 372 | // Update list box |
373 | servers->changeItem( newName, currentSelectedServer ); | 373 | servers->changeItem( newName, currentSelectedServer ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | else | 376 | else |
377 | { | 377 | { |
378 | Server s( newName, serverurl->text() ); | 378 | Server s( newName, serverurl->text() ); |
379 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); | 379 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); |
380 | dataMgr->getServerList().last()->setActive( active->isChecked() ); | 380 | dataMgr->getServerList().last()->setActive( active->isChecked() ); |
381 | servers->insertItem( newName ); | 381 | servers->insertItem( newName ); |
382 | servers->setCurrentItem( servers->count() ); | 382 | servers->setCurrentItem( servers->count() ); |
383 | newserver = false; | 383 | newserver = false; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | //------------------ Destinations tab ---------------------- | 387 | //------------------ Destinations tab ---------------------- |
388 | 388 | ||
389 | void SettingsImpl :: editDestination( int sel ) | 389 | void SettingsImpl :: editDestination( int sel ) |
390 | { | 390 | { |
391 | currentSelectedDestination = sel; | 391 | currentSelectedDestination = sel; |
392 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 392 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
393 | if ( d ) | 393 | if ( d ) |
394 | { | 394 | { |
395 | destinationName = d->getDestinationName(); | 395 | destinationName = d->getDestinationName(); |
396 | destinationname->setText( d->getDestinationName() ); | 396 | destinationname->setText( d->getDestinationName() ); |
397 | destinationurl->setText( d->getDestinationPath() ); | 397 | destinationurl->setText( d->getDestinationPath() ); |
398 | linkToRoot->setChecked( d->linkToRoot() ); | 398 | linkToRoot->setChecked( d->linkToRoot() ); |
399 | } | 399 | } |
400 | else | 400 | else |
401 | { | 401 | { |
402 | destinationName = ""; | 402 | destinationName = ""; |
403 | destinationname->setText( "" ); | 403 | destinationname->setText( "" ); |
404 | destinationurl->setText( "" ); | 404 | destinationurl->setText( "" ); |
405 | linkToRoot->setChecked( false ); | 405 | linkToRoot->setChecked( false ); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | 408 | ||
409 | void SettingsImpl :: newDestination() | 409 | void SettingsImpl :: newDestination() |
410 | { | 410 | { |
411 | newdestination = true; | 411 | newdestination = true; |
412 | destinationname->setText( "" ); | 412 | destinationname->setText( "" ); |
413 | destinationurl->setText( "" ); | 413 | destinationurl->setText( "" ); |
414 | destinationname->setFocus(); | 414 | destinationname->setFocus(); |
415 | linkToRoot->setChecked( true ); | 415 | linkToRoot->setChecked( true ); |
416 | } | 416 | } |
417 | 417 | ||
418 | void SettingsImpl :: removeDestination() | 418 | void SettingsImpl :: removeDestination() |
419 | { | 419 | { |
420 | changed = true; | 420 | changed = true; |
421 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 421 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
422 | if ( d ) | 422 | if ( d ) |
423 | { | 423 | { |
424 | dataMgr->getDestinationList().removeRef( d ); | 424 | dataMgr->getDestinationList().removeRef( d ); |
425 | destinations->removeItem( currentSelectedDestination ); | 425 | destinations->removeItem( currentSelectedDestination ); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | void SettingsImpl :: changeDestinationDetails() | 429 | void SettingsImpl :: changeDestinationDetails() |
430 | { | 430 | { |
431 | changed = true; | 431 | changed = true; |
432 | 432 | ||
433 | #ifdef QWS | 433 | #ifdef QWS |
434 | Config cfg( "aqpkg" ); | 434 | Config cfg( "aqpkg" ); |
435 | cfg.setGroup( "destinations" ); | 435 | cfg.setGroup( "destinations" ); |
436 | #endif | 436 | #endif |
437 | 437 | ||
438 | QString newName = destinationname->text(); | 438 | QString newName = destinationname->text(); |
439 | if ( !newdestination ) | 439 | if ( !newdestination ) |
440 | { | 440 | { |
441 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 441 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
442 | if ( d ) | 442 | if ( d ) |
443 | { | 443 | { |
444 | // Update url | 444 | // Update url |
445 | d->setDestinationPath( destinationurl->text() ); | 445 | d->setDestinationPath( destinationurl->text() ); |
446 | d->linkToRoot( linkToRoot->isChecked() ); | 446 | d->linkToRoot( linkToRoot->isChecked() ); |
447 | 447 | ||
448 | // Check if server name has changed, if it has then we need to replace the key in the map | 448 | // Check if server name has changed, if it has then we need to replace the key in the map |
449 | if ( destinationName != newName ) | 449 | if ( destinationName != newName ) |
450 | { | 450 | { |
451 | // Update server name | 451 | // Update server name |
452 | d->setDestinationName( newName ); | 452 | d->setDestinationName( newName ); |
453 | 453 | ||
454 | // Update list box | 454 | // Update list box |
455 | destinations->changeItem( newName, currentSelectedDestination ); | 455 | destinations->changeItem( newName, currentSelectedDestination ); |
456 | } | 456 | } |
457 | 457 | ||
458 | #ifdef QWS | 458 | #ifdef QWS |
459 | QString key = newName; | 459 | QString key = newName; |
460 | key += "_linkToRoot"; | 460 | key += "_linkToRoot"; |
461 | int val = d->linkToRoot(); | 461 | int val = d->linkToRoot(); |
462 | cfg.writeEntry( key, val ); | 462 | cfg.writeEntry( key, val ); |
463 | #endif | 463 | #endif |
464 | 464 | ||
465 | } | 465 | } |
466 | } | 466 | } |
467 | else | 467 | else |
468 | { | 468 | { |
469 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); | 469 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); |
470 | destinations->insertItem( newName ); | 470 | destinations->insertItem( newName ); |
471 | destinations->setCurrentItem( destinations->count() ); | 471 | destinations->setCurrentItem( destinations->count() ); |
472 | newdestination = false; | 472 | newdestination = false; |
473 | 473 | ||
474 | #ifdef QWS | 474 | #ifdef QWS |
475 | QString key = newName; | 475 | QString key = newName; |
476 | key += "_linkToRoot"; | 476 | key += "_linkToRoot"; |
477 | cfg.writeEntry( key, true ); | 477 | cfg.writeEntry( key, true ); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | //------------------ Proxy tab ---------------------- | 483 | //------------------ Proxy tab ---------------------- |
484 | void SettingsImpl :: proxyApplyChanges() | 484 | void SettingsImpl :: proxyApplyChanges() |
485 | { | 485 | { |
486 | changed = true; | 486 | changed = true; |
487 | dataMgr->setHttpProxy( txtHttpProxy->text() ); | 487 | dataMgr->setHttpProxy( txtHttpProxy->text() ); |
488 | dataMgr->setFtpProxy( txtFtpProxy->text() ); | 488 | dataMgr->setFtpProxy( txtFtpProxy->text() ); |
489 | dataMgr->setProxyUsername( txtUsername->text() ); | 489 | dataMgr->setProxyUsername( txtUsername->text() ); |
490 | dataMgr->setProxyPassword( txtPassword->text() ); | 490 | dataMgr->setProxyPassword( txtPassword->text() ); |
491 | 491 | ||
492 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); | 492 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); |
493 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); | 493 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); |
494 | } | 494 | } |
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 977c283..6b83bc9 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,439 +1,439 @@ | |||
1 | 1 | ||
2 | #include "backuprestore.h" | 2 | #include "backuprestore.h" |
3 | #include "errordialog.h" | 3 | #include "errordialog.h" |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <opie2/ostorageinfo.h> | 6 | #include <opie2/ostorageinfo.h> |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | /* QT */ | 9 | /* QT */ |
10 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #include <qmultilineedit.h> | 11 | #include <qmultilineedit.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qfile.h> | 13 | #include <qfile.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlistview.h> | 15 | #include <qlistview.h> |
16 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
17 | #include <qheader.h> | 17 | #include <qheader.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qcombobox.h> | 21 | #include <qcombobox.h> |
22 | #include <qlist.h> | 22 | #include <qlist.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <qregexp.h> | 24 | #include <qregexp.h> |
25 | #include <qtextstream.h> | 25 | #include <qtextstream.h> |
26 | #include <qtextview.h> | 26 | #include <qtextview.h> |
27 | 27 | ||
28 | /* STD */ | 28 | /* STD */ |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <dirent.h> | 33 | #include <dirent.h> |
34 | 34 | ||
35 | #define HEADER_NAME 0 | 35 | #define HEADER_NAME 0 |
36 | #define HEADER_BACKUP 1 | 36 | #define HEADER_BACKUP 1 |
37 | #define BACKUP_LOCATION 2 | 37 | #define BACKUP_LOCATION 2 |
38 | 38 | ||
39 | #define EXTENSION ".bck" | 39 | #define EXTENSION ".bck" |
40 | 40 | ||
41 | const QString tempFileName = "/tmp/backup.err"; | 41 | const QString tempFileName = "/tmp/backup.err"; |
42 | 42 | ||
43 | 43 | ||
44 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) | 44 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) |
45 | : BackupAndRestoreBase(parent, name, fl) | 45 | : BackupAndRestoreBase(parent, name, fl) |
46 | { | 46 | { |
47 | backupList->header()->hide(); | 47 | backupList->header()->hide(); |
48 | restoreList->header()->hide(); | 48 | restoreList->header()->hide(); |
49 | connect(backupButton, SIGNAL(clicked()), | 49 | connect(backupButton, SIGNAL(clicked()), |
50 | this, SLOT(backup())); | 50 | this, SLOT(backup())); |
51 | connect(restoreButton, SIGNAL(clicked()), | 51 | connect(restoreButton, SIGNAL(clicked()), |
52 | this, SLOT(restore())); | 52 | this, SLOT(restore())); |
53 | connect(backupList, SIGNAL(clicked( QListViewItem * )), | 53 | connect(backupList, SIGNAL(clicked(QListViewItem*)), |
54 | this, SLOT(selectItem(QListViewItem*))); | 54 | this, SLOT(selectItem(QListViewItem*))); |
55 | connect(restoreSource, SIGNAL(activated( int )), | 55 | connect(restoreSource, SIGNAL(activated(int)), |
56 | this, SLOT(sourceDirChanged(int))); | 56 | this, SLOT(sourceDirChanged(int))); |
57 | connect(updateList, SIGNAL(clicked()), | 57 | connect(updateList, SIGNAL(clicked()), |
58 | this, SLOT( fileListUpdate())); | 58 | this, SLOT( fileListUpdate())); |
59 | 59 | ||
60 | //add directorys for backing up | 60 | //add directorys for backing up |
61 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); | 61 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); |
62 | selectItem(applicationSettings); | 62 | selectItem(applicationSettings); |
63 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); | 63 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); |
64 | selectItem(applicationSettings); | 64 | selectItem(applicationSettings); |
65 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); | 65 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); |
66 | selectItem(documents); | 66 | selectItem(documents); |
67 | 67 | ||
68 | scanForApplicationSettings(); | 68 | scanForApplicationSettings(); |
69 | 69 | ||
70 | OStorageInfo storage; | 70 | OStorageInfo storage; |
71 | 71 | ||
72 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); | 72 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); |
73 | if ( storage.hasCf() ) | 73 | if ( storage.hasCf() ) |
74 | { | 74 | { |
75 | backupLocations.insert( "CF", storage.cfPath() ); | 75 | backupLocations.insert( "CF", storage.cfPath() ); |
76 | qDebug( "Cf Path: " + storage.cfPath() ); | 76 | qDebug( "Cf Path: " + storage.cfPath() ); |
77 | } | 77 | } |
78 | if ( storage.hasSd() ) | 78 | if ( storage.hasSd() ) |
79 | { | 79 | { |
80 | backupLocations.insert( "SD", storage.sdPath() ); | 80 | backupLocations.insert( "SD", storage.sdPath() ); |
81 | qDebug( " Sd Path: " + storage.sdPath() ); | 81 | qDebug( " Sd Path: " + storage.sdPath() ); |
82 | } | 82 | } |
83 | if ( storage.hasMmc() ) | 83 | if ( storage.hasMmc() ) |
84 | { | 84 | { |
85 | backupLocations.insert( "MMC", storage.mmcPath() ); | 85 | backupLocations.insert( "MMC", storage.mmcPath() ); |
86 | qDebug( "Mmc Path: " + storage.mmcPath() ); | 86 | qDebug( "Mmc Path: " + storage.mmcPath() ); |
87 | } | 87 | } |
88 | 88 | ||
89 | Config config("BackupAndRestore"); | 89 | Config config("BackupAndRestore"); |
90 | //read last locations | 90 | //read last locations |
91 | config.setGroup("LastLocation"); | 91 | config.setGroup("LastLocation"); |
92 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); | 92 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); |
93 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); | 93 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); |
94 | int locationIndex = 0; | 94 | int locationIndex = 0; |
95 | 95 | ||
96 | QMap<QString, QString>::Iterator it; | 96 | QMap<QString, QString>::Iterator it; |
97 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) | 97 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) |
98 | { | 98 | { |
99 | storeToLocation->insertItem(it.key()); | 99 | storeToLocation->insertItem(it.key()); |
100 | restoreSource->insertItem(it.key()); | 100 | restoreSource->insertItem(it.key()); |
101 | 101 | ||
102 | //check for last locations | 102 | //check for last locations |
103 | if ( it.key() == lastStoreLocation ) | 103 | if ( it.key() == lastStoreLocation ) |
104 | storeToLocation->setCurrentItem( locationIndex ); | 104 | storeToLocation->setCurrentItem( locationIndex ); |
105 | if ( it.key() == lastRestoreLocation ) | 105 | if ( it.key() == lastRestoreLocation ) |
106 | restoreSource->setCurrentItem( locationIndex ); | 106 | restoreSource->setCurrentItem( locationIndex ); |
107 | locationIndex++; | 107 | locationIndex++; |
108 | } | 108 | } |
109 | 109 | ||
110 | // Read the list of items to ignore. | 110 | // Read the list of items to ignore. |
111 | QList<QString> dontBackupList; | 111 | QList<QString> dontBackupList; |
112 | dontBackupList.setAutoDelete(true); | 112 | dontBackupList.setAutoDelete(true); |
113 | config.setGroup("DontBackup"); | 113 | config.setGroup("DontBackup"); |
114 | int total = config.readNumEntry("Total", 0); | 114 | int total = config.readNumEntry("Total", 0); |
115 | for(int i = 0; i < total; i++) | 115 | for(int i = 0; i < total; i++) |
116 | { | 116 | { |
117 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); | 117 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); |
118 | } | 118 | } |
119 | 119 | ||
120 | QList<QListViewItem> list; | 120 | QList<QListViewItem> list; |
121 | getAllItems(backupList->firstChild(), list); | 121 | getAllItems(backupList->firstChild(), list); |
122 | 122 | ||
123 | for(uint i = 0; i < list.count(); i++) | 123 | for(uint i = 0; i < list.count(); i++) |
124 | { | 124 | { |
125 | QString text = list.at(i)->text(HEADER_NAME); | 125 | QString text = list.at(i)->text(HEADER_NAME); |
126 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) | 126 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) |
127 | { | 127 | { |
128 | if(*dontBackupList.at(i2) == text) | 128 | if(*dontBackupList.at(i2) == text) |
129 | { | 129 | { |
130 | selectItem(list.at(i)); | 130 | selectItem(list.at(i)); |
131 | break; | 131 | break; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | QPEApplication::showWidget( this ); | 135 | QPEApplication::showWidget( this ); |
136 | } | 136 | } |
137 | 137 | ||
138 | BackupAndRestore::~BackupAndRestore() | 138 | BackupAndRestore::~BackupAndRestore() |
139 | { | 139 | { |
140 | QList<QListViewItem> list; | 140 | QList<QListViewItem> list; |
141 | getAllItems(backupList->firstChild(), list); | 141 | getAllItems(backupList->firstChild(), list); |
142 | 142 | ||
143 | Config config("BackupAndRestore"); | 143 | Config config("BackupAndRestore"); |
144 | config.setGroup("DontBackup"); | 144 | config.setGroup("DontBackup"); |
145 | config.clearGroup(); | 145 | config.clearGroup(); |
146 | 146 | ||
147 | int count = 0; | 147 | int count = 0; |
148 | for(uint i = 0; i < list.count(); i++) | 148 | for(uint i = 0; i < list.count(); i++) |
149 | { | 149 | { |
150 | if(list.at(i)->text(HEADER_BACKUP) == "") | 150 | if(list.at(i)->text(HEADER_BACKUP) == "") |
151 | { | 151 | { |
152 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); | 152 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); |
153 | count++; | 153 | count++; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | config.writeEntry("Total", count); | 156 | config.writeEntry("Total", count); |
157 | 157 | ||
158 | // Remove Temp File | 158 | // Remove Temp File |
159 | if ( QFile::exists( tempFileName ) ) | 159 | if ( QFile::exists( tempFileName ) ) |
160 | QFile::remove( tempFileName ); | 160 | QFile::remove( tempFileName ); |
161 | } | 161 | } |
162 | 162 | ||
163 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) | 163 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) |
164 | { | 164 | { |
165 | while(item) | 165 | while(item) |
166 | { | 166 | { |
167 | if(item->childCount() > 0) | 167 | if(item->childCount() > 0) |
168 | getAllItems(item->firstChild(), list); | 168 | getAllItems(item->firstChild(), list); |
169 | list.append(item); | 169 | list.append(item); |
170 | item = item->nextSibling(); | 170 | item = item->nextSibling(); |
171 | } | 171 | } |
172 | return list; | 172 | return list; |
173 | } | 173 | } |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. | 176 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. |
177 | * and changing the icon to match | 177 | * and changing the icon to match |
178 | * @param currentItem the item to swich the selection choice. | 178 | * @param currentItem the item to swich the selection choice. |
179 | */ | 179 | */ |
180 | void BackupAndRestore::selectItem(QListViewItem *currentItem) | 180 | void BackupAndRestore::selectItem(QListViewItem *currentItem) |
181 | { | 181 | { |
182 | if(!currentItem) | 182 | if(!currentItem) |
183 | return; | 183 | return; |
184 | 184 | ||
185 | if(currentItem->text(HEADER_BACKUP) == "B") | 185 | if(currentItem->text(HEADER_BACKUP) == "B") |
186 | { | 186 | { |
187 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); | 187 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); |
188 | currentItem->setText(HEADER_BACKUP, ""); | 188 | currentItem->setText(HEADER_BACKUP, ""); |
189 | } | 189 | } |
190 | else | 190 | else |
191 | { | 191 | { |
192 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); | 192 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); |
193 | currentItem->setText(HEADER_BACKUP, "B"); | 193 | currentItem->setText(HEADER_BACKUP, "B"); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void BackupAndRestore::scanForApplicationSettings() | 197 | void BackupAndRestore::scanForApplicationSettings() |
198 | { | 198 | { |
199 | QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); | 199 | QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); |
200 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); | 200 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); |
201 | const QFileInfoList *list = d.entryInfoList(); | 201 | const QFileInfoList *list = d.entryInfoList(); |
202 | QFileInfoListIterator it( *list ); | 202 | QFileInfoListIterator it( *list ); |
203 | QFileInfo *fi; | 203 | QFileInfo *fi; |
204 | while ( (fi=it.current()) ) | 204 | while ( (fi=it.current()) ) |
205 | { | 205 | { |
206 | //qDebug((d.path()+"/"+fi->fileName()).latin1()); | 206 | //qDebug((d.path()+"/"+fi->fileName()).latin1()); |
207 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) | 207 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) |
208 | { | 208 | { |
209 | QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); | 209 | QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); |
210 | selectItem(newItem); | 210 | selectItem(newItem); |
211 | } | 211 | } |
212 | ++it; | 212 | ++it; |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | /** | 216 | /** |
217 | * The "Backup" button has been pressed. Get a list of all of the files that | 217 | * The "Backup" button has been pressed. Get a list of all of the files that |
218 | * should be backed up. If there are no files, emit and error and exit. | 218 | * should be backed up. If there are no files, emit and error and exit. |
219 | * Determine the file name to store the backup in. Backup the file(s) using | 219 | * Determine the file name to store the backup in. Backup the file(s) using |
220 | * tar and gzip --best. Report failure or success | 220 | * tar and gzip --best. Report failure or success |
221 | */ | 221 | */ |
222 | void BackupAndRestore::backup() | 222 | void BackupAndRestore::backup() |
223 | { | 223 | { |
224 | QString backupFiles; | 224 | QString backupFiles; |
225 | if(getBackupFiles(backupFiles, NULL) == 0) | 225 | if(getBackupFiles(backupFiles, NULL) == 0) |
226 | { | 226 | { |
227 | QMessageBox::critical(this, "Message", | 227 | QMessageBox::critical(this, "Message", |
228 | "No items selected.",QString("Ok") ); | 228 | "No items selected.",QString("Ok") ); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | 231 | ||
232 | setCaption(tr("Backup and Restore... working...")); | 232 | setCaption(tr("Backup and Restore... working...")); |
233 | QString outputFile = backupLocations[storeToLocation->currentText()]; | 233 | QString outputFile = backupLocations[storeToLocation->currentText()]; |
234 | 234 | ||
235 | QDateTime datetime = QDateTime::currentDateTime(); | 235 | QDateTime datetime = QDateTime::currentDateTime(); |
236 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + | 236 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + |
237 | QString::number( datetime.date().day() ).rightJustify(2, '0'); | 237 | QString::number( datetime.date().day() ).rightJustify(2, '0'); |
238 | 238 | ||
239 | outputFile += "/" + dateString; | 239 | outputFile += "/" + dateString; |
240 | 240 | ||
241 | QString t = outputFile; | 241 | QString t = outputFile; |
242 | int c = 1; | 242 | int c = 1; |
243 | while(QFile::exists(outputFile + EXTENSION)) | 243 | while(QFile::exists(outputFile + EXTENSION)) |
244 | { | 244 | { |
245 | outputFile = t + QString("%1").arg(c); | 245 | outputFile = t + QString("%1").arg(c); |
246 | c++; | 246 | c++; |
247 | } | 247 | } |
248 | 248 | ||
249 | // We execute tar and compressing its output with gzip.. | 249 | // We execute tar and compressing its output with gzip.. |
250 | // The error output will be written into a temp-file which could be provided | 250 | // The error output will be written into a temp-file which could be provided |
251 | // for debugging.. | 251 | // for debugging.. |
252 | qDebug( "Storing file: %s", outputFile.latin1() ); | 252 | qDebug( "Storing file: %s", outputFile.latin1() ); |
253 | outputFile += EXTENSION; | 253 | outputFile += EXTENSION; |
254 | 254 | ||
255 | QString commandLine = QString( "(tar -C %1 -z --exclude=*.bck -c %2 > %3 ) 2> %4" ).arg( QDir::homeDirPath() ) | 255 | QString commandLine = QString( "(tar -C %1 -z --exclude=*.bck -c %2 > %3 ) 2> %4" ).arg( QDir::homeDirPath() ) |
256 | .arg( backupFiles ) | 256 | .arg( backupFiles ) |
257 | .arg( outputFile.latin1() ) | 257 | .arg( outputFile.latin1() ) |
258 | .arg( tempFileName.latin1() ); | 258 | .arg( tempFileName.latin1() ); |
259 | 259 | ||
260 | qDebug( commandLine ); | 260 | qDebug( commandLine ); |
261 | 261 | ||
262 | int r = system( commandLine ); | 262 | int r = system( commandLine ); |
263 | 263 | ||
264 | if(r != 0) | 264 | if(r != 0) |
265 | { | 265 | { |
266 | perror("Error: "); | 266 | perror("Error: "); |
267 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); | 267 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
268 | 268 | ||
269 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" | 269 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" |
270 | + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) | 270 | + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) |
271 | { | 271 | { |
272 | 272 | ||
273 | case 1: | 273 | case 1: |
274 | qWarning("Details pressed !"); | 274 | qWarning("Details pressed !"); |
275 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | 275 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); |
276 | QFile errorFile( tempFileName ); | 276 | QFile errorFile( tempFileName ); |
277 | if ( errorFile.open(IO_ReadOnly) ) | 277 | if ( errorFile.open(IO_ReadOnly) ) |
278 | { | 278 | { |
279 | QTextStream t( &errorFile ); | 279 | QTextStream t( &errorFile ); |
280 | QString s; | 280 | QString s; |
281 | while ( !t.eof() ) | 281 | while ( !t.eof() ) |
282 | { // until end of file... | 282 | { // until end of file... |
283 | s += t.readLine(); // line of text excluding '\n' | 283 | s += t.readLine(); // line of text excluding '\n' |
284 | } | 284 | } |
285 | errorFile.close(); | 285 | errorFile.close(); |
286 | 286 | ||
287 | pErrDialog->m_textarea->setText( s ); | 287 | pErrDialog->m_textarea->setText( s ); |
288 | } | 288 | } |
289 | else | 289 | else |
290 | { | 290 | { |
291 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); | 291 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); |
292 | } | 292 | } |
293 | QPEApplication::execDialog( pErrDialog ); | 293 | QPEApplication::execDialog( pErrDialog ); |
294 | delete pErrDialog; | 294 | delete pErrDialog; |
295 | break; | 295 | break; |
296 | } | 296 | } |
297 | setCaption(tr("Backup and Restore.. Failed !!")); | 297 | setCaption(tr("Backup and Restore.. Failed !!")); |
298 | return; | 298 | return; |
299 | } | 299 | } |
300 | else | 300 | else |
301 | { | 301 | { |
302 | QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); | 302 | QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); |
303 | 303 | ||
304 | } | 304 | } |
305 | 305 | ||
306 | //write store-location | 306 | //write store-location |
307 | Config config( "BackupAndRestore" ); | 307 | Config config( "BackupAndRestore" ); |
308 | config.setGroup( "LastLocation" ); | 308 | config.setGroup( "LastLocation" ); |
309 | config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); | 309 | config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); |
310 | 310 | ||
311 | setCaption(tr("Backup and Restore")); | 311 | setCaption(tr("Backup and Restore")); |
312 | } | 312 | } |
313 | 313 | ||
314 | /*** | 314 | /*** |
315 | * Get a list of all of the files to backup. | 315 | * Get a list of all of the files to backup. |
316 | */ | 316 | */ |
317 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) | 317 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) |
318 | { | 318 | { |
319 | QListViewItem * currentItem; | 319 | QListViewItem * currentItem; |
320 | QString currentHome; | 320 | QString currentHome; |
321 | if(!parent) | 321 | if(!parent) |
322 | currentItem = backupList->firstChild(); | 322 | currentItem = backupList->firstChild(); |
323 | else | 323 | else |
324 | { | 324 | { |
325 | currentItem = parent->firstChild(); | 325 | currentItem = parent->firstChild(); |
326 | currentHome = parent->text(BACKUP_LOCATION); | 326 | currentHome = parent->text(BACKUP_LOCATION); |
327 | } | 327 | } |
328 | 328 | ||
329 | uint count = 0; | 329 | uint count = 0; |
330 | while( currentItem != 0 ) | 330 | while( currentItem != 0 ) |
331 | { | 331 | { |
332 | if(currentItem->text(HEADER_BACKUP) == "B" ) | 332 | if(currentItem->text(HEADER_BACKUP) == "B" ) |
333 | { | 333 | { |
334 | if(currentItem->childCount() == 0 ) | 334 | if(currentItem->childCount() == 0 ) |
335 | { | 335 | { |
336 | if(parent == NULL) | 336 | if(parent == NULL) |
337 | backupFiles += currentItem->text(BACKUP_LOCATION); | 337 | backupFiles += currentItem->text(BACKUP_LOCATION); |
338 | else | 338 | else |
339 | backupFiles += currentHome + currentItem->text(HEADER_NAME); | 339 | backupFiles += currentHome + currentItem->text(HEADER_NAME); |
340 | backupFiles += " "; | 340 | backupFiles += " "; |
341 | count++; | 341 | count++; |
342 | } | 342 | } |
343 | else | 343 | else |
344 | { | 344 | { |
345 | count += getBackupFiles(backupFiles, currentItem); | 345 | count += getBackupFiles(backupFiles, currentItem); |
346 | } | 346 | } |
347 | } | 347 | } |
348 | currentItem = currentItem->nextSibling(); | 348 | currentItem = currentItem->nextSibling(); |
349 | } | 349 | } |
350 | return count; | 350 | return count; |
351 | } | 351 | } |
352 | 352 | ||
353 | void BackupAndRestore::sourceDirChanged(int selection) | 353 | void BackupAndRestore::sourceDirChanged(int selection) |
354 | { | 354 | { |
355 | restoreList->clear(); | 355 | restoreList->clear(); |
356 | rescanFolder(backupLocations[restoreSource->text(selection)]); | 356 | rescanFolder(backupLocations[restoreSource->text(selection)]); |
357 | } | 357 | } |
358 | 358 | ||
359 | void BackupAndRestore::fileListUpdate() | 359 | void BackupAndRestore::fileListUpdate() |
360 | { | 360 | { |
361 | qWarning("void BackupAndRestore::fileListUpdate()"); | 361 | qWarning("void BackupAndRestore::fileListUpdate()"); |
362 | restoreList->clear(); | 362 | restoreList->clear(); |
363 | rescanFolder( backupLocations[restoreSource->currentText()] ); | 363 | rescanFolder( backupLocations[restoreSource->currentText()] ); |
364 | } | 364 | } |
365 | 365 | ||
366 | /** | 366 | /** |
367 | * Scans directory for any backup files. Will recursivly go down, | 367 | * Scans directory for any backup files. Will recursivly go down, |
368 | * but will not follow symlinks. | 368 | * but will not follow symlinks. |
369 | * @param directory - the directory to look in. | 369 | * @param directory - the directory to look in. |
370 | */ | 370 | */ |
371 | void BackupAndRestore::rescanFolder(QString directory) | 371 | void BackupAndRestore::rescanFolder(QString directory) |
372 | { | 372 | { |
373 | //qDebug(QString("rescanFolder: ") + directory.latin1()); | 373 | //qDebug(QString("rescanFolder: ") + directory.latin1()); |
374 | QDir d(directory); | 374 | QDir d(directory); |
375 | if(!d.exists()) | 375 | if(!d.exists()) |
376 | return; | 376 | return; |
377 | 377 | ||
378 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); | 378 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); |
379 | const QFileInfoList *list = d.entryInfoList(); | 379 | const QFileInfoList *list = d.entryInfoList(); |
380 | QFileInfoListIterator it( *list ); | 380 | QFileInfoListIterator it( *list ); |
381 | QFileInfo *file; | 381 | QFileInfo *file; |
382 | while ( (file=it.current()) ) | 382 | while ( (file=it.current()) ) |
383 | { // for each file... | 383 | { // for each file... |
384 | // If it is a dir and not .. or . then add it as a tab and go down. | 384 | // If it is a dir and not .. or . then add it as a tab and go down. |
385 | if(file->isDir()) | 385 | if(file->isDir()) |
386 | { | 386 | { |
387 | if(file->fileName() != ".." && file->fileName() != ".") | 387 | if(file->fileName() != ".." && file->fileName() != ".") |
388 | { | 388 | { |
389 | rescanFolder(directory + "/" + file->fileName()); | 389 | rescanFolder(directory + "/" + file->fileName()); |
390 | } | 390 | } |
391 | } | 391 | } |
392 | else | 392 | else |
393 | { | 393 | { |
394 | // If it is a backup file add to list. | 394 | // If it is a backup file add to list. |
395 | if(file->fileName().contains(EXTENSION)) | 395 | if(file->fileName().contains(EXTENSION)) |
396 | (void)new QListViewItem(restoreList, file->fileName()); | 396 | (void)new QListViewItem(restoreList, file->fileName()); |
397 | } | 397 | } |
398 | ++it; | 398 | ++it; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | /** | 402 | /** |
403 | * Restore a backup file. | 403 | * Restore a backup file. |
404 | * Report errors or success | 404 | * Report errors or success |
405 | */ | 405 | */ |
406 | void BackupAndRestore::restore() | 406 | void BackupAndRestore::restore() |
407 | { | 407 | { |
408 | QListViewItem *restoreItem = restoreList->currentItem(); | 408 | QListViewItem *restoreItem = restoreList->currentItem(); |
409 | if(!restoreItem) | 409 | if(!restoreItem) |
410 | { | 410 | { |
411 | QMessageBox::critical(this, tr( "Message" ), | 411 | QMessageBox::critical(this, tr( "Message" ), |
412 | tr( "Please select something to restore." ),QString( tr( "Ok") ) ); | 412 | tr( "Please select something to restore." ),QString( tr( "Ok") ) ); |
413 | return; | 413 | return; |
414 | } | 414 | } |
415 | setCaption(tr("Backup and Restore... working...")); | 415 | setCaption(tr("Backup and Restore... working...")); |
416 | 416 | ||
417 | QString restoreFile = backupLocations[restoreSource->currentText()]; | 417 | QString restoreFile = backupLocations[restoreSource->currentText()]; |
418 | 418 | ||
419 | restoreFile += "/" + restoreItem->text(0); | 419 | restoreFile += "/" + restoreItem->text(0); |
420 | 420 | ||
421 | qDebug( restoreFile ); | 421 | qDebug( restoreFile ); |
422 | 422 | ||
423 | QString commandLine = QString( "tar -C %1 -zxf %2 2> %3" ).arg( QDir::homeDirPath() ) | 423 | QString commandLine = QString( "tar -C %1 -zxf %2 2> %3" ).arg( QDir::homeDirPath() ) |
424 | .arg( restoreFile.latin1() ) | 424 | .arg( restoreFile.latin1() ) |
425 | .arg( tempFileName.latin1() ); | 425 | .arg( tempFileName.latin1() ); |
426 | 426 | ||
427 | qDebug( commandLine ); | 427 | qDebug( commandLine ); |
428 | 428 | ||
429 | int r = system( commandLine ); | 429 | int r = system( commandLine ); |
430 | 430 | ||
431 | if(r != 0) | 431 | if(r != 0) |
432 | { | 432 | { |
433 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); | 433 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
434 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" | 434 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" |
435 | + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) | 435 | + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) |
436 | { | 436 | { |
437 | case 1: | 437 | case 1: |
438 | qWarning("Details pressed !"); | 438 | qWarning("Details pressed !"); |
439 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | 439 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); |
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp index 7df41d4..c995d6e 100644 --- a/noncore/settings/netsystemtime/mainwindow.cpp +++ b/noncore/settings/netsystemtime/mainwindow.cpp | |||
@@ -1,396 +1,396 @@ | |||
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 | MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) | 51 | MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) |
52 | : QDialog( 0x0, 0x0, TRUE, 0 ) | 52 | : QDialog( 0x0, 0x0, TRUE, 0 ) |
53 | { | 53 | { |
54 | setCaption( tr( "SystemTime" ) ); | 54 | setCaption( tr( "SystemTime" ) ); |
55 | 55 | ||
56 | QVBoxLayout *layout = new QVBoxLayout( this ); | 56 | QVBoxLayout *layout = new QVBoxLayout( this ); |
57 | layout->setMargin( 2 ); | 57 | layout->setMargin( 2 ); |
58 | layout->setSpacing( 4 ); | 58 | layout->setSpacing( 4 ); |
59 | 59 | ||
60 | // Create main tabbed control | 60 | // Create main tabbed control |
61 | mainWidget = new OTabWidget( this ); | 61 | mainWidget = new OTabWidget( this ); |
62 | 62 | ||
63 | // Default object pointers to null | 63 | // Default object pointers to null |
64 | ntpProcess = 0x0; | 64 | ntpProcess = 0x0; |
65 | ntpTab = 0x0; | 65 | ntpTab = 0x0; |
66 | 66 | ||
67 | // Add tab widgets | 67 | // Add tab widgets |
68 | mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); | 68 | mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); |
69 | mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); | 69 | mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); |
70 | mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); | 70 | mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); |
71 | mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); | 71 | mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); |
72 | Config config( "ntp" ); | 72 | Config config( "ntp" ); |
73 | config.setGroup( "settings" ); | 73 | config.setGroup( "settings" ); |
74 | slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); | 74 | slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); |
75 | slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); | 75 | slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); |
76 | 76 | ||
77 | mainWidget->setCurrentTab( tr( "Time" ) ); | 77 | mainWidget->setCurrentTab( tr( "Time" ) ); |
78 | layout->addWidget( mainWidget ); | 78 | layout->addWidget( mainWidget ); |
79 | 79 | ||
80 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 80 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
81 | this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) ); | 81 | this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) ); |
82 | 82 | ||
83 | 83 | ||
84 | // Create NTP socket | 84 | // Create NTP socket |
85 | ntpSock = new QSocket( this ); | 85 | ntpSock = new QSocket( this ); |
86 | connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); | 86 | connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); |
87 | slotProbeNTPServer(); | 87 | slotProbeNTPServer(); |
88 | 88 | ||
89 | // Create timer for automatic time lookups | 89 | // Create timer for automatic time lookups |
90 | ntpTimer = new QTimer( this ); | 90 | ntpTimer = new QTimer( this ); |
91 | 91 | ||
92 | // Connect everything together | 92 | // Connect everything together |
93 | connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); | 93 | connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); |
94 | connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) ); | 94 | connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) ); |
95 | connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); | 95 | connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); |
96 | connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) ); | 96 | connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) ); |
97 | connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)), | 97 | connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)), |
98 | timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) ); | 98 | timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) ); |
99 | connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); | 99 | connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); |
100 | connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); | 100 | connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); |
101 | connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); | 101 | connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); |
102 | connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); | 102 | connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); |
103 | connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) ); | 103 | connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) ); |
104 | 104 | ||
105 | // Do initial time server check | 105 | // Do initial time server check |
106 | slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); | 106 | slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); |
107 | slotCheckNtp( -1 ); | 107 | slotCheckNtp( -1 ); |
108 | 108 | ||
109 | // Display app | 109 | // Display app |
110 | //showMaximized(); | 110 | //showMaximized(); |
111 | (void)new QPEDialogListener(this); | 111 | (void)new QPEDialogListener(this); |
112 | } | 112 | } |
113 | 113 | ||
114 | MainWindow::~MainWindow() | 114 | MainWindow::~MainWindow() |
115 | { | 115 | { |
116 | if ( ntpProcess ) | 116 | if ( ntpProcess ) |
117 | delete ntpProcess; | 117 | delete ntpProcess; |
118 | } | 118 | } |
119 | 119 | ||
120 | void MainWindow::accept() | 120 | void MainWindow::accept() |
121 | { | 121 | { |
122 | // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) | 122 | // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) |
123 | { | 123 | { |
124 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 124 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
125 | disableScreenSaver << 0 << 0 << 0; | 125 | disableScreenSaver << 0 << 0 << 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | // Update the systemtime | 128 | // Update the systemtime |
129 | timeTab->saveSettings( TRUE ); | 129 | timeTab->saveSettings( TRUE ); |
130 | 130 | ||
131 | // Save format options | 131 | // Save format options |
132 | formatTab->saveSettings( TRUE ); | 132 | formatTab->saveSettings( TRUE ); |
133 | 133 | ||
134 | // Save settings options | 134 | // Save settings options |
135 | settingsTab->saveSettings(); | 135 | settingsTab->saveSettings(); |
136 | 136 | ||
137 | // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better | 137 | // 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). | 138 | // grip on itself (example re-trigger alarms for when we travel back in time). |
139 | DateBookDB db; | 139 | DateBookDB db; |
140 | 140 | ||
141 | // Turn back on the screensaver | 141 | // Turn back on the screensaver |
142 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 142 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
143 | enableScreenSaver << -1 << -1 << -1; | 143 | enableScreenSaver << -1 << -1 << -1; |
144 | 144 | ||
145 | // Exit app | 145 | // Exit app |
146 | qApp->quit(); | 146 | qApp->quit(); |
147 | } | 147 | } |
148 | 148 | ||
149 | void MainWindow::reject() | 149 | void MainWindow::reject() |
150 | { | 150 | { |
151 | // Reset time settings | 151 | // Reset time settings |
152 | timeTab->saveSettings( FALSE ); | 152 | timeTab->saveSettings( FALSE ); |
153 | 153 | ||
154 | // Send notifications but do not save settings | 154 | // Send notifications but do not save settings |
155 | formatTab->saveSettings( FALSE ); | 155 | formatTab->saveSettings( FALSE ); |
156 | 156 | ||
157 | // Exit app | 157 | // Exit app |
158 | qApp->quit(); | 158 | qApp->quit(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void MainWindow::runNTP() | 161 | void MainWindow::runNTP() |
162 | { | 162 | { |
163 | if ( !ntpDelayElapsed() && ntpInteractive ) | 163 | if ( !ntpDelayElapsed() && ntpInteractive ) |
164 | { | 164 | { |
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 ) ); | 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 ) ); |
166 | 166 | ||
167 | switch ( | 167 | switch ( |
168 | QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) | 168 | QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) |
169 | ) | 169 | ) |
170 | { | 170 | { |
171 | case QMessageBox::Yes: break; | 171 | case QMessageBox::Yes: break; |
172 | case QMessageBox::No: return; | 172 | case QMessageBox::No: return; |
173 | default: return; | 173 | default: return; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | QString srv = settingsTab->ntpServer(); | 177 | QString srv = settingsTab->ntpServer(); |
178 | 178 | ||
179 | // Send information to time server tab if enabled | 179 | // Send information to time server tab if enabled |
180 | if ( ntpTabEnabled ) | 180 | if ( ntpTabEnabled ) |
181 | { | 181 | { |
182 | ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); | 182 | ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); |
183 | QString output = tr( "Running:\nntpdate " ); | 183 | QString output = tr( "Running:\nntpdate " ); |
184 | output.append( srv ); | 184 | output.append( srv ); |
185 | ntpTab->addNtpOutput( output ); | 185 | ntpTab->addNtpOutput( output ); |
186 | } | 186 | } |
187 | 187 | ||
188 | if ( !ntpProcess ) | 188 | if ( !ntpProcess ) |
189 | { | 189 | { |
190 | ntpProcess = new OProcess(); | 190 | ntpProcess = new OProcess(); |
191 | connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 191 | connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), |
192 | this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); | 192 | this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); |
193 | connect( ntpProcess, SIGNAL(processExited(OProcess*)), | 193 | connect( ntpProcess, SIGNAL(processExited(OProcess*)), |
194 | this, SLOT(slotNtpFinished(OProcess*)) ); | 194 | this, SLOT(slotNtpFinished(OProcess*)) ); |
195 | } | 195 | } |
196 | 196 | ||
197 | else | 197 | else |
198 | ntpProcess->clearArguments(); | 198 | ntpProcess->clearArguments(); |
199 | 199 | ||
200 | *ntpProcess << "ntpdate" << srv; | 200 | *ntpProcess << "ntpdate" << srv; |
201 | bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); | 201 | bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); |
202 | if ( !ret ) | 202 | if ( !ret ) |
203 | { | 203 | { |
204 | QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); | 204 | QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); |
205 | if ( ntpTabEnabled ) | 205 | if ( ntpTabEnabled ) |
206 | ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); | 206 | ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | bool MainWindow::ntpDelayElapsed() | 210 | bool MainWindow::ntpDelayElapsed() |
211 | { | 211 | { |
212 | // Determine if time elapsed is greater than time delay | 212 | // Determine if time elapsed is greater than time delay |
213 | Config config( "ntp" ); | 213 | Config config( "ntp" ); |
214 | config.setGroup( "lookups" ); | 214 | config.setGroup( "lookups" ); |
215 | _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); | 215 | _lookupDiff = TimeConversion::toUTC( QDateTime::currentDateTime() ) - config.readNumEntry( "time", 0 ); |
216 | if ( _lookupDiff < 0 ) | 216 | if ( _lookupDiff < 0 ) |
217 | return true; | 217 | return true; |
218 | return ( _lookupDiff - ( ntpDelay * 60) ) > 0; | 218 | return ( _lookupDiff - ( ntpDelay * 60) ) > 0; |
219 | } | 219 | } |
220 | 220 | ||
221 | void MainWindow::slotSetTime( const QDateTime &dt ) | 221 | void MainWindow::slotSetTime( const QDateTime &dt ) |
222 | { | 222 | { |
223 | timeTab->setDateTime( dt ); | 223 | timeTab->setDateTime( dt ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) | 226 | void MainWindow::slotQCopReceive( const QCString &msg, const QByteArray & ) |
227 | { | 227 | { |
228 | if ( msg == "ntpLookup(QString)" ) | 228 | if ( msg == "ntpLookup(QString)" ) |
229 | { | 229 | { |
230 | ntpInteractive = false; | 230 | ntpInteractive = false; |
231 | runNTP(); | 231 | runNTP(); |
232 | } | 232 | } |
233 | if ( msg == "setPredictedTime(QString)" ) | 233 | if ( msg == "setPredictedTime(QString)" ) |
234 | { | 234 | { |
235 | //setPredictTime(); | 235 | //setPredictTime(); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | void MainWindow::slotDisplayNTPTab( bool display ) | 239 | void MainWindow::slotDisplayNTPTab( bool display ) |
240 | { | 240 | { |
241 | ntpTabEnabled = display; | 241 | ntpTabEnabled = display; |
242 | 242 | ||
243 | // Create widget if it hasn't needed | 243 | // Create widget if it hasn't needed |
244 | if ( display && !ntpTab ) | 244 | if ( display && !ntpTab ) |
245 | { | 245 | { |
246 | ntpTab = new NTPTabWidget( mainWidget ); | 246 | ntpTab = new NTPTabWidget( mainWidget ); |
247 | connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); | 247 | connect( ntpTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); |
248 | } | 248 | } |
249 | 249 | ||
250 | // Display/hide tab | 250 | // Display/hide tab |
251 | display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) | 251 | display ? mainWidget->addTab( ntpTab, "netsystemtime/ntptab", tr( "Time Server" ) ) |
252 | : mainWidget->removePage( ntpTab ); | 252 | : mainWidget->removePage( ntpTab ); |
253 | } | 253 | } |
254 | 254 | ||
255 | void MainWindow::slotDisplayPredictTab( bool display ) | 255 | void MainWindow::slotDisplayPredictTab( bool display ) |
256 | { | 256 | { |
257 | predictTabEnabled = display; | 257 | predictTabEnabled = display; |
258 | 258 | ||
259 | // Create widget if it hasn't needed | 259 | // Create widget if it hasn't needed |
260 | if ( display && !predictTab ) | 260 | if ( display && !predictTab ) |
261 | { | 261 | { |
262 | } | 262 | } |
263 | // Display/hide tab | 263 | // Display/hide tab |
264 | display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) | 264 | display ? mainWidget->addTab( predictTab, "netsystemtime/predicttab", tr( "Predict" ) ) |
265 | : mainWidget->removePage( predictTab ); | 265 | : mainWidget->removePage( predictTab ); |
266 | } | 266 | } |
267 | 267 | ||
268 | void MainWindow::slotGetNTPTime() | 268 | void MainWindow::slotGetNTPTime() |
269 | { | 269 | { |
270 | ntpInteractive = TRUE; | 270 | ntpInteractive = TRUE; |
271 | runNTP(); | 271 | runNTP(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void MainWindow::slotTimerGetNTPTime() | 274 | void MainWindow::slotTimerGetNTPTime() |
275 | { | 275 | { |
276 | ntpInteractive = FALSE; | 276 | ntpInteractive = FALSE; |
277 | runNTP(); | 277 | runNTP(); |
278 | } | 278 | } |
279 | 279 | ||
280 | void MainWindow::slotProbeNTPServer() | 280 | void MainWindow::slotProbeNTPServer() |
281 | { | 281 | { |
282 | ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); | 282 | ntpSock->connectToHost( settingsTab->ntpServer(), 123 ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) | 285 | void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) |
286 | { | 286 | { |
287 | QString output = QString( buffer ).left( buflen ); | 287 | QString output = QString( buffer ).left( buflen ); |
288 | ntpOutput.append( output ); | 288 | ntpOutput.append( output ); |
289 | 289 | ||
290 | if ( ntpTabEnabled ) | 290 | if ( ntpTabEnabled ) |
291 | ntpTab->addNtpOutput( output ); | 291 | ntpTab->addNtpOutput( output ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void MainWindow::slotNtpFinished( OProcess *p ) | 294 | void MainWindow::slotNtpFinished( OProcess *p ) |
295 | { | 295 | { |
296 | QString output; | 296 | QString output; |
297 | QDateTime dt = QDateTime::currentDateTime(); | 297 | QDateTime dt = QDateTime::currentDateTime(); |
298 | 298 | ||
299 | // Verify run was successful | 299 | // Verify run was successful |
300 | if ( p->exitStatus() != 0 || !p->normalExit() ) | 300 | if ( p->exitStatus() != 0 || !p->normalExit() ) |
301 | { | 301 | { |
302 | if ( isVisible() && ntpInteractive ) | 302 | if ( isVisible() && ntpInteractive ) |
303 | { | 303 | { |
304 | output = tr( "Error while getting time from\n server: " ); | 304 | output = tr( "Error while getting time from\n server: " ); |
305 | output.append( settingsTab->ntpServer() ); | 305 | output.append( settingsTab->ntpServer() ); |
306 | QMessageBox::critical(this, tr( "Error" ), output ); | 306 | QMessageBox::critical(this, tr( "Error" ), output ); |
307 | } | 307 | } |
308 | // slotCheckNtp(-1); | 308 | // slotCheckNtp(-1); |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | 311 | ||
312 | // Set controls on time tab to new time value | 312 | // Set controls on time tab to new time value |
313 | timeTab->setDateTime( dt ); | 313 | timeTab->setDateTime( dt ); |
314 | 314 | ||
315 | // Write out lookup information | 315 | // Write out lookup information |
316 | Config config( "ntp" ); | 316 | Config config( "ntp" ); |
317 | config.setGroup( "lookups" ); | 317 | config.setGroup( "lookups" ); |
318 | int lastLookup = config.readNumEntry( "time", 0 ); | 318 | int lastLookup = config.readNumEntry( "time", 0 ); |
319 | int lookupCount = config.readNumEntry( "count", 0 ); | 319 | int lookupCount = config.readNumEntry( "count", 0 ); |
320 | bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); | 320 | bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); |
321 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); | 321 | int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); |
322 | config.writeEntry( "time", time ); | 322 | config.writeEntry( "time", time ); |
323 | 323 | ||
324 | // Calculate new time/time shift | 324 | // Calculate new time/time shift |
325 | QString _offset = "offset"; | 325 | QString _offset = "offset"; |
326 | QString _sec = "sec"; | 326 | QString _sec = "sec"; |
327 | QRegExp _reOffset = QRegExp( _offset ); | 327 | QRegExp _reOffset = QRegExp( _offset ); |
328 | QRegExp _reEndOffset = QRegExp( _sec ); | 328 | QRegExp _reEndOffset = QRegExp( _sec ); |
329 | int posOffset = _reOffset.match( ntpOutput ); | 329 | int posOffset = _reOffset.match( ntpOutput ); |
330 | int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); | 330 | int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); |
331 | posOffset += _offset.length() + 1; | 331 | posOffset += _offset.length() + 1; |
332 | QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); | 332 | QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); |
333 | 333 | ||
334 | float timeShift = diff.toFloat(); | 334 | float timeShift = diff.toFloat(); |
335 | if ( timeShift == 0.0 ) | 335 | if ( timeShift == 0.0 ) |
336 | return; | 336 | return; |
337 | int secsSinceLast = time - lastLookup; | 337 | int secsSinceLast = time - lastLookup; |
338 | output = tr( "%1 seconds").arg(QString::number( timeShift )); | 338 | output = tr( "%1 seconds").arg(QString::number( timeShift )); |
339 | 339 | ||
340 | // Display information on time server tab | 340 | // Display information on time server tab |
341 | if ( ntpTabEnabled ) | 341 | if ( ntpTabEnabled ) |
342 | { | 342 | { |
343 | ntpTab->setTimeShift( output ); | 343 | ntpTab->setTimeShift( output ); |
344 | ntpTab->setNewTime( dt.toString() ); | 344 | ntpTab->setNewTime( dt.toString() ); |
345 | } | 345 | } |
346 | 346 | ||
347 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) | 347 | if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) |
348 | { | 348 | { |
349 | QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); | 349 | QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); |
350 | config.setGroup( grpname ); | 350 | config.setGroup( grpname ); |
351 | lookupCount++; | 351 | lookupCount++; |
352 | predictTab->setShiftPerSec( timeShift / secsSinceLast ); | 352 | predictTab->setShiftPerSec( timeShift / secsSinceLast ); |
353 | config.writeEntry( "secsSinceLast", secsSinceLast ); | 353 | config.writeEntry( "secsSinceLast", secsSinceLast ); |
354 | config.writeEntry( "timeShift", QString::number( timeShift ) ); | 354 | config.writeEntry( "timeShift", QString::number( timeShift ) ); |
355 | config.setGroup( "lookups" ); | 355 | config.setGroup( "lookups" ); |
356 | config.writeEntry( "count", lookupCount ); | 356 | config.writeEntry( "count", lookupCount ); |
357 | config.writeEntry( "lastNtp", TRUE ); | 357 | config.writeEntry( "lastNtp", TRUE ); |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | void MainWindow::slotNTPDelayChanged( int delay ) | 361 | void MainWindow::slotNTPDelayChanged( int delay ) |
362 | { | 362 | { |
363 | ntpTimer->changeInterval( delay * 1000 * 60 ); | 363 | ntpTimer->changeInterval( delay * 1000 * 60 ); |
364 | ntpDelay = delay; | 364 | ntpDelay = delay; |
365 | } | 365 | } |
366 | 366 | ||
367 | void MainWindow::slotCheckNtp( int i ) | 367 | void MainWindow::slotCheckNtp( int i ) |
368 | { | 368 | { |
369 | if ( i == 0 ) | 369 | if ( i == 0 ) |
370 | { | 370 | { |
371 | if ( ntpDelayElapsed() ) | 371 | if ( ntpDelayElapsed() ) |
372 | { | 372 | { |
373 | runNTP(); | 373 | runNTP(); |
374 | disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); | 374 | disconnect( ntpTimer, SIGNAL(timeout()), this, SLOT(slotProbeNTPServer()) ); |
375 | connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); | 375 | connect( ntpTimer, SIGNAL(timeout()), SLOT(slotTimerGetNTPTime()) ); |
376 | } | 376 | } |
377 | else | 377 | else |
378 | { | 378 | { |
379 | disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); | 379 | disconnect(ntpTimer, SIGNAL(timeout()), this, SLOT(slotTimerGetNTPTime()) ); |
380 | connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); | 380 | connect(ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); |
381 | } | 381 | } |
382 | } | 382 | } |
383 | else | 383 | else |
384 | { | 384 | { |
385 | predictTab->slotPredictTime(); | 385 | predictTab->slotPredictTime(); |
386 | if ( i > 0 ) | 386 | if ( i > 0 ) |
387 | { | 387 | { |
388 | QString output = tr( "Could not connect to server " ); | 388 | QString output = tr( "Could not connect to server " ); |
389 | output.append( settingsTab->ntpServer() ); | 389 | output.append( settingsTab->ntpServer() ); |
390 | ntpOutput.append( output ); | 390 | ntpOutput.append( output ); |
391 | if ( ntpTabEnabled ) | 391 | if ( ntpTabEnabled ) |
392 | ntpTab->addNtpOutput( output ); | 392 | ntpTab->addNtpOutput( output ); |
393 | } | 393 | } |
394 | connect( ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); | 394 | connect( ntpTimer, SIGNAL(timeout()), SLOT(slotProbeNTPServer()) ); |
395 | } | 395 | } |
396 | } | 396 | } |
diff --git a/noncore/settings/netsystemtime/settingstabwidget.cpp b/noncore/settings/netsystemtime/settingstabwidget.cpp index 2a7e28d..ad80e05 100644 --- a/noncore/settings/netsystemtime/settingstabwidget.cpp +++ b/noncore/settings/netsystemtime/settingstabwidget.cpp | |||
@@ -1,159 +1,159 @@ | |||
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 "settingstabwidget.h" | 29 | #include "settingstabwidget.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | 33 | ||
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | #include <qscrollview.h> | 38 | #include <qscrollview.h> |
39 | #include <qspinbox.h> | 39 | #include <qspinbox.h> |
40 | 40 | ||
41 | SettingsTabWidget::SettingsTabWidget( QWidget *parent ) | 41 | SettingsTabWidget::SettingsTabWidget( QWidget *parent ) |
42 | : QWidget( parent, 0x0, 0 ) | 42 | : QWidget( parent, 0x0, 0 ) |
43 | { | 43 | { |
44 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 44 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
45 | QScrollView *sv = new QScrollView( this ); | 45 | QScrollView *sv = new QScrollView( this ); |
46 | tmpvb->addWidget( sv, 0, 0 ); | 46 | tmpvb->addWidget( sv, 0, 0 ); |
47 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 47 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
48 | sv->setFrameStyle( QFrame::NoFrame ); | 48 | sv->setFrameStyle( QFrame::NoFrame ); |
49 | QWidget *container = new QWidget( sv->viewport() ); | 49 | QWidget *container = new QWidget( sv->viewport() ); |
50 | sv->addChild( container ); | 50 | sv->addChild( container ); |
51 | 51 | ||
52 | QGridLayout *layout = new QGridLayout( container ); | 52 | QGridLayout *layout = new QGridLayout( container ); |
53 | layout->setMargin( 2 ); | 53 | layout->setMargin( 2 ); |
54 | layout->setSpacing( 4 ); | 54 | layout->setSpacing( 4 ); |
55 | 55 | ||
56 | // Time server selector | 56 | // Time server selector |
57 | layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 ); | 57 | layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 ); |
58 | cbTimeServer = new QComboBox( TRUE, container ); | 58 | cbTimeServer = new QComboBox( TRUE, container ); |
59 | layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 ); | 59 | layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 ); |
60 | 60 | ||
61 | // Lookup delay selector | 61 | // Lookup delay selector |
62 | layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 ); | 62 | layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 ); |
63 | sbNtpDelay = new QSpinBox( 1, 9999999, 1, container ); | 63 | sbNtpDelay = new QSpinBox( 1, 9999999, 1, container ); |
64 | sbNtpDelay->setWrapping( TRUE ); | 64 | sbNtpDelay->setWrapping( TRUE ); |
65 | sbNtpDelay->setMaximumWidth( 50 ); | 65 | sbNtpDelay->setMaximumWidth( 50 ); |
66 | connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) ); | 66 | connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) ); |
67 | layout->addWidget( sbNtpDelay, 2, 0 ); | 67 | layout->addWidget( sbNtpDelay, 2, 0 ); |
68 | 68 | ||
69 | // Prediction delay selector | 69 | // Prediction delay selector |
70 | layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 ); | 70 | layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 ); |
71 | sbPredictDelay = new QSpinBox( 42, 9999999, 1, container ); | 71 | sbPredictDelay = new QSpinBox( 42, 9999999, 1, container ); |
72 | sbPredictDelay->setWrapping( TRUE ); | 72 | sbPredictDelay->setWrapping( TRUE ); |
73 | sbPredictDelay->setMaximumWidth( 50 ); | 73 | sbPredictDelay->setMaximumWidth( 50 ); |
74 | layout->addWidget( sbPredictDelay, 3, 0 ); | 74 | layout->addWidget( sbPredictDelay, 3, 0 ); |
75 | 75 | ||
76 | // Space filler | 76 | // Space filler |
77 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); | 77 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); |
78 | 78 | ||
79 | // Display time server information selector | 79 | // Display time server information selector |
80 | chNtpTab = new QCheckBox( tr( "Display time server information" ), container ); | 80 | chNtpTab = new QCheckBox( tr( "Display time server information" ), container ); |
81 | connect( chNtpTab, SIGNAL( toggled( bool ) ), this, SIGNAL( displayNTPTab( bool ) ) ); | 81 | connect( chNtpTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayNTPTab(bool) ) ); |
82 | layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 ); | 82 | layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 ); |
83 | 83 | ||
84 | // Display time prediction information selector | 84 | // Display time prediction information selector |
85 | chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container ); | 85 | chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container ); |
86 | connect( chPredictTab, SIGNAL( toggled( bool ) ), this, SIGNAL( displayPredictTab( bool ) ) ); | 86 | connect( chPredictTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayPredictTab(bool) ) ); |
87 | layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 ); | 87 | layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 ); |
88 | 88 | ||
89 | // Space filler | 89 | // Space filler |
90 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); | 90 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); |
91 | 91 | ||
92 | // Initialize values | 92 | // Initialize values |
93 | QString ntpSrvsFile = QPEApplication::qpeDir(); | 93 | QString ntpSrvsFile = QPEApplication::qpeDir(); |
94 | ntpSrvsFile.append( "etc/ntpservers" ); | 94 | ntpSrvsFile.append( "etc/ntpservers" ); |
95 | Config ntpSrvs( ntpSrvsFile, Config::File ); | 95 | Config ntpSrvs( ntpSrvsFile, Config::File ); |
96 | ntpSrvs.setGroup( "servers" ); | 96 | ntpSrvs.setGroup( "servers" ); |
97 | int srvCount = ntpSrvs.readNumEntry( "count", 0 ); | 97 | int srvCount = ntpSrvs.readNumEntry( "count", 0 ); |
98 | for ( int i = 0; i < srvCount; i++ ) | 98 | for ( int i = 0; i < srvCount; i++ ) |
99 | { | 99 | { |
100 | ntpSrvs.setGroup( QString::number( i ) ); | 100 | ntpSrvs.setGroup( QString::number( i ) ); |
101 | cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) ); | 101 | cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) ); |
102 | } | 102 | } |
103 | if ( srvCount==0 ) | 103 | if ( srvCount==0 ) |
104 | cbTimeServer->insertItem( "time.fu-berlin.de" ); | 104 | cbTimeServer->insertItem( "time.fu-berlin.de" ); |
105 | 105 | ||
106 | Config config( "ntp" ); | 106 | Config config( "ntp" ); |
107 | config.setGroup( "settings" ); | 107 | config.setGroup( "settings" ); |
108 | sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) ); | 108 | sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) ); |
109 | sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); | 109 | sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); |
110 | cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) ); | 110 | cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) ); |
111 | chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) ); | 111 | chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) ); |
112 | chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) ); | 112 | chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) ); |
113 | } | 113 | } |
114 | 114 | ||
115 | SettingsTabWidget::~SettingsTabWidget() | 115 | SettingsTabWidget::~SettingsTabWidget() |
116 | { | 116 | { |
117 | } | 117 | } |
118 | 118 | ||
119 | void SettingsTabWidget::saveSettings() | 119 | void SettingsTabWidget::saveSettings() |
120 | { | 120 | { |
121 | int srvCount = cbTimeServer->count(); | 121 | int srvCount = cbTimeServer->count(); |
122 | bool serversChanged = TRUE; | 122 | bool serversChanged = TRUE; |
123 | int curSrv = cbTimeServer->currentItem(); | 123 | int curSrv = cbTimeServer->currentItem(); |
124 | QString edit = cbTimeServer->currentText(); | 124 | QString edit = cbTimeServer->currentText(); |
125 | for ( int i = 0; i < srvCount; i++ ) | 125 | for ( int i = 0; i < srvCount; i++ ) |
126 | { | 126 | { |
127 | if ( edit == cbTimeServer->text( i ) ) | 127 | if ( edit == cbTimeServer->text( i ) ) |
128 | serversChanged = FALSE; | 128 | serversChanged = FALSE; |
129 | } | 129 | } |
130 | if ( serversChanged ) | 130 | if ( serversChanged ) |
131 | { | 131 | { |
132 | QString ntpSrvsFile = QPEApplication::qpeDir(); | 132 | QString ntpSrvsFile = QPEApplication::qpeDir(); |
133 | ntpSrvsFile.append( "etc/ntpservers" ); | 133 | ntpSrvsFile.append( "etc/ntpservers" ); |
134 | Config ntpSrvs( ntpSrvsFile, Config::File ); | 134 | Config ntpSrvs( ntpSrvsFile, Config::File ); |
135 | ntpSrvs.setGroup( "servers" ); | 135 | ntpSrvs.setGroup( "servers" ); |
136 | ntpSrvs.writeEntry( "count", ++srvCount ); | 136 | ntpSrvs.writeEntry( "count", ++srvCount ); |
137 | ntpSrvs.setGroup( "0" ); | 137 | ntpSrvs.setGroup( "0" ); |
138 | ntpSrvs.writeEntry( "name", edit ); | 138 | ntpSrvs.writeEntry( "name", edit ); |
139 | curSrv = 0; | 139 | curSrv = 0; |
140 | for ( int i = 1; i < srvCount; i++ ) | 140 | for ( int i = 1; i < srvCount; i++ ) |
141 | { | 141 | { |
142 | // qDebug( "ntpSrvs[%i/%i]=%s", i, srvCount, cbTimeServer->text( i ).latin1() ); | 142 | // qDebug( "ntpSrvs[%i/%i]=%s", i, srvCount, cbTimeServer->text( i ).latin1() ); |
143 | ntpSrvs.setGroup( QString::number( i ) ); | 143 | ntpSrvs.setGroup( QString::number( i ) ); |
144 | ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) ); | 144 | ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) ); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | Config config( "ntp", Config::User ); | 147 | Config config( "ntp", Config::User ); |
148 | config.setGroup( "settings" ); | 148 | config.setGroup( "settings" ); |
149 | config.writeEntry( "ntpServer", curSrv ); | 149 | config.writeEntry( "ntpServer", curSrv ); |
150 | config.writeEntry( "minLookupDiff", sbPredictDelay->value() ); | 150 | config.writeEntry( "minLookupDiff", sbPredictDelay->value() ); |
151 | config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() ); | 151 | config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() ); |
152 | config.writeEntry( "displayNtpTab", chNtpTab->isChecked() ); | 152 | config.writeEntry( "displayNtpTab", chNtpTab->isChecked() ); |
153 | config.writeEntry( "displayPredictTab", chPredictTab->isChecked() ); | 153 | config.writeEntry( "displayPredictTab", chPredictTab->isChecked() ); |
154 | } | 154 | } |
155 | 155 | ||
156 | QString SettingsTabWidget::ntpServer() | 156 | QString SettingsTabWidget::ntpServer() |
157 | { | 157 | { |
158 | return cbTimeServer->currentText(); | 158 | return cbTimeServer->currentText(); |
159 | } | 159 | } |
diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp index 6f24462..1ea460e 100644 --- a/noncore/settings/netsystemtime/timetabwidget.cpp +++ b/noncore/settings/netsystemtime/timetabwidget.cpp | |||
@@ -1,292 +1,292 @@ | |||
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 "timetabwidget.h" | 29 | #include "timetabwidget.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/datebookmonth.h> | 32 | #include <qpe/datebookmonth.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/tzselect.h> | 35 | #include <qpe/tzselect.h> |
36 | 36 | ||
37 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 37 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qdatetime.h> | 42 | #include <qdatetime.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | #include <qscrollview.h> | 47 | #include <qscrollview.h> |
48 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
49 | 49 | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <sys/time.h> | 51 | #include <sys/time.h> |
52 | 52 | ||
53 | static const int ValueAM = 0; | 53 | static const int ValueAM = 0; |
54 | static const int ValuePM = 1; | 54 | static const int ValuePM = 1; |
55 | 55 | ||
56 | TimeTabWidget::TimeTabWidget( QWidget *parent ) | 56 | TimeTabWidget::TimeTabWidget( QWidget *parent ) |
57 | : QWidget( parent, 0x0, 0 ) | 57 | : QWidget( parent, 0x0, 0 ) |
58 | { | 58 | { |
59 | // Synchronize HW clock to systemtime | 59 | // Synchronize HW clock to systemtime |
60 | // This app will update systemtime | 60 | // This app will update systemtime |
61 | // - if Cancel is clicked, will reset systemtime to HW clock's time | 61 | // - if Cancel is clicked, will reset systemtime to HW clock's time |
62 | // - if Ok is clicked, will leave systemtime as is | 62 | // - if Ok is clicked, will leave systemtime as is |
63 | system("/sbin/hwclock --systohc --utc"); | 63 | system("/sbin/hwclock --systohc --utc"); |
64 | 64 | ||
65 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 65 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
66 | QScrollView *sv = new QScrollView( this ); | 66 | QScrollView *sv = new QScrollView( this ); |
67 | tmpvb->addWidget( sv, 0, 0 ); | 67 | tmpvb->addWidget( sv, 0, 0 ); |
68 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 68 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
69 | sv->setFrameStyle( QFrame::NoFrame ); | 69 | sv->setFrameStyle( QFrame::NoFrame ); |
70 | QWidget *container = new QWidget( sv->viewport() ); | 70 | QWidget *container = new QWidget( sv->viewport() ); |
71 | sv->addChild( container ); | 71 | sv->addChild( container ); |
72 | 72 | ||
73 | QGridLayout *layout = new QGridLayout( container ); | 73 | QGridLayout *layout = new QGridLayout( container ); |
74 | layout->setMargin( 2 ); | 74 | layout->setMargin( 2 ); |
75 | layout->setSpacing( 4 ); | 75 | layout->setSpacing( 4 ); |
76 | 76 | ||
77 | // Hours | 77 | // Hours |
78 | layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 ); | 78 | layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 ); |
79 | sbHour = new QSpinBox( container ); | 79 | sbHour = new QSpinBox( container ); |
80 | sbHour->setWrapping( TRUE ); | 80 | sbHour->setWrapping( TRUE ); |
81 | layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 ); | 81 | layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 ); |
82 | 82 | ||
83 | // Minutes | 83 | // Minutes |
84 | layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 ); | 84 | layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 ); |
85 | sbMin = new QSpinBox( container ); | 85 | sbMin = new QSpinBox( container ); |
86 | sbMin->setWrapping( TRUE ); | 86 | sbMin->setWrapping( TRUE ); |
87 | sbMin->setMinValue( 0 ); | 87 | sbMin->setMinValue( 0 ); |
88 | sbMin->setMaxValue( 59 ); | 88 | sbMin->setMaxValue( 59 ); |
89 | layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 ); | 89 | layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 ); |
90 | 90 | ||
91 | // AM/PM | 91 | // AM/PM |
92 | cbAmpm = new QComboBox( container ); | 92 | cbAmpm = new QComboBox( container ); |
93 | cbAmpm->insertItem( tr( "AM" ), ValueAM ); | 93 | cbAmpm->insertItem( tr( "AM" ), ValueAM ); |
94 | cbAmpm->insertItem( tr( "PM" ), ValuePM ); | 94 | cbAmpm->insertItem( tr( "PM" ), ValuePM ); |
95 | layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 ); | 95 | layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 ); |
96 | 96 | ||
97 | // Date | 97 | // Date |
98 | layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 ); | 98 | layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 ); |
99 | btnDate = new DateButton( TRUE, container ); | 99 | btnDate = new DateButton( TRUE, container ); |
100 | layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 ); | 100 | layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 ); |
101 | 101 | ||
102 | // Timezone | 102 | // Timezone |
103 | layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 ); | 103 | layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 ); |
104 | selTimeZone = new TimeZoneSelector( container ); | 104 | selTimeZone = new TimeZoneSelector( container ); |
105 | connect( selTimeZone, SIGNAL(signalNewTz(const QString &)), this, SLOT(slotTZChanged(const QString &)) ); | 105 | connect( selTimeZone, SIGNAL(signalNewTz(const QString&)), this, SLOT(slotTZChanged(const QString&)) ); |
106 | layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 ); | 106 | layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 ); |
107 | 107 | ||
108 | // Space filler | 108 | // Space filler |
109 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); | 109 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); |
110 | 110 | ||
111 | // Set NTP time button | 111 | // Set NTP time button |
112 | QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), | 112 | QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), |
113 | tr( "Get time from the network" ), container ); | 113 | tr( "Get time from the network" ), container ); |
114 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); | 114 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); |
115 | layout->addMultiCellWidget( pb, 8, 8, 0, 5 ); | 115 | layout->addMultiCellWidget( pb, 8, 8, 0, 5 ); |
116 | 116 | ||
117 | // Set predicted time button | 117 | // Set predicted time button |
118 | pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), | 118 | pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), |
119 | container ); | 119 | container ); |
120 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) ); | 120 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) ); |
121 | layout->addMultiCellWidget( pb, 9, 9, 0, 5 ); | 121 | layout->addMultiCellWidget( pb, 9, 9, 0, 5 ); |
122 | 122 | ||
123 | // Space filler at bottom of widget | 123 | // Space filler at bottom of widget |
124 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 ); | 124 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 ); |
125 | 125 | ||
126 | // Initialize values | 126 | // Initialize values |
127 | Config config( "locale" ); | 127 | Config config( "locale" ); |
128 | config.setGroup( "Location" ); | 128 | config.setGroup( "Location" ); |
129 | selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) ); | 129 | selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) ); |
130 | use12HourTime = FALSE; | 130 | use12HourTime = FALSE; |
131 | setDateTime( QDateTime::currentDateTime() ); | 131 | setDateTime( QDateTime::currentDateTime() ); |
132 | } | 132 | } |
133 | 133 | ||
134 | TimeTabWidget::~TimeTabWidget() | 134 | TimeTabWidget::~TimeTabWidget() |
135 | { | 135 | { |
136 | } | 136 | } |
137 | 137 | ||
138 | void TimeTabWidget::saveSettings( bool commit ) | 138 | void TimeTabWidget::saveSettings( bool commit ) |
139 | { | 139 | { |
140 | if ( commit ) | 140 | if ( commit ) |
141 | { | 141 | { |
142 | // Set timezone and announce to world | 142 | // Set timezone and announce to world |
143 | QString tz = selTimeZone->currentZone(); | 143 | QString tz = selTimeZone->currentZone(); |
144 | Config config("locale"); | 144 | Config config("locale"); |
145 | config.setGroup( "Location" ); | 145 | config.setGroup( "Location" ); |
146 | config.writeEntry( "Timezone", tz ); | 146 | config.writeEntry( "Timezone", tz ); |
147 | setenv( "TZ", tz, 1 ); | 147 | setenv( "TZ", tz, 1 ); |
148 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 148 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
149 | setTimeZone << tz; | 149 | setTimeZone << tz; |
150 | 150 | ||
151 | // If controls have a valid date & time, update systemtime | 151 | // If controls have a valid date & time, update systemtime |
152 | int hour = sbHour->value(); | 152 | int hour = sbHour->value(); |
153 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) | 153 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) |
154 | hour += 12; | 154 | hour += 12; |
155 | QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); | 155 | QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); |
156 | setSystemTime( dt ); | 156 | setSystemTime( dt ); |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | // Reset systemtime to hardware clock (i.e. undo any changes made by this app) | 160 | // Reset systemtime to hardware clock (i.e. undo any changes made by this app) |
161 | system("/sbin/hwclock --hctosys --utc"); | 161 | system("/sbin/hwclock --hctosys --utc"); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void TimeTabWidget::setDateTime( const QDateTime &dt ) | 165 | void TimeTabWidget::setDateTime( const QDateTime &dt ) |
166 | { | 166 | { |
167 | // Set time | 167 | // Set time |
168 | QTime t = dt.time(); | 168 | QTime t = dt.time(); |
169 | if( use12HourTime ) | 169 | if( use12HourTime ) |
170 | { | 170 | { |
171 | int show_hour = t.hour(); | 171 | int show_hour = t.hour(); |
172 | if ( t.hour() >= 12 ) | 172 | if ( t.hour() >= 12 ) |
173 | { | 173 | { |
174 | show_hour -= 12; | 174 | show_hour -= 12; |
175 | cbAmpm->setCurrentItem( ValuePM ); | 175 | cbAmpm->setCurrentItem( ValuePM ); |
176 | } | 176 | } |
177 | else | 177 | else |
178 | { | 178 | { |
179 | cbAmpm->setCurrentItem( ValueAM ); | 179 | cbAmpm->setCurrentItem( ValueAM ); |
180 | } | 180 | } |
181 | if ( show_hour == 0 ) | 181 | if ( show_hour == 0 ) |
182 | show_hour = 12; | 182 | show_hour = 12; |
183 | sbHour->setValue( show_hour ); | 183 | sbHour->setValue( show_hour ); |
184 | } | 184 | } |
185 | else | 185 | else |
186 | { | 186 | { |
187 | sbHour->setValue( t.hour() ); | 187 | sbHour->setValue( t.hour() ); |
188 | } | 188 | } |
189 | sbMin->setValue( t.minute() ); | 189 | sbMin->setValue( t.minute() ); |
190 | 190 | ||
191 | // Set date | 191 | // Set date |
192 | btnDate->setDate( dt.date() ); | 192 | btnDate->setDate( dt.date() ); |
193 | } | 193 | } |
194 | 194 | ||
195 | void TimeTabWidget::setSystemTime( const QDateTime &dt ) | 195 | void TimeTabWidget::setSystemTime( const QDateTime &dt ) |
196 | { | 196 | { |
197 | // Set system clock | 197 | // Set system clock |
198 | if ( dt.isValid() ) | 198 | if ( dt.isValid() ) |
199 | { | 199 | { |
200 | struct timeval myTv; | 200 | struct timeval myTv; |
201 | int t = TimeConversion::toUTC( dt ); | 201 | int t = TimeConversion::toUTC( dt ); |
202 | myTv.tv_sec = t; | 202 | myTv.tv_sec = t; |
203 | myTv.tv_usec = 0; | 203 | myTv.tv_usec = 0; |
204 | 204 | ||
205 | if ( myTv.tv_sec != -1 ) | 205 | if ( myTv.tv_sec != -1 ) |
206 | ::settimeofday( &myTv, 0 ); | 206 | ::settimeofday( &myTv, 0 ); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void TimeTabWidget::slotUse12HourTime( int i ) | 210 | void TimeTabWidget::slotUse12HourTime( int i ) |
211 | { | 211 | { |
212 | use12HourTime = (i == 1); | 212 | use12HourTime = (i == 1); |
213 | 213 | ||
214 | cbAmpm->setEnabled( use12HourTime ); | 214 | cbAmpm->setEnabled( use12HourTime ); |
215 | 215 | ||
216 | int show_hour = sbHour->value(); | 216 | int show_hour = sbHour->value(); |
217 | 217 | ||
218 | if ( use12HourTime ) | 218 | if ( use12HourTime ) |
219 | { | 219 | { |
220 | sbHour->setMinValue( 1 ); | 220 | sbHour->setMinValue( 1 ); |
221 | sbHour->setMaxValue( 12 ); | 221 | sbHour->setMaxValue( 12 ); |
222 | 222 | ||
223 | if ( show_hour >= 12 ) | 223 | if ( show_hour >= 12 ) |
224 | { | 224 | { |
225 | show_hour -= 12; | 225 | show_hour -= 12; |
226 | cbAmpm->setCurrentItem( ValuePM ); | 226 | cbAmpm->setCurrentItem( ValuePM ); |
227 | } | 227 | } |
228 | else | 228 | else |
229 | { | 229 | { |
230 | cbAmpm->setCurrentItem( ValueAM ); | 230 | cbAmpm->setCurrentItem( ValueAM ); |
231 | } | 231 | } |
232 | if ( show_hour == 0 ) | 232 | if ( show_hour == 0 ) |
233 | show_hour = 12; | 233 | show_hour = 12; |
234 | } | 234 | } |
235 | else | 235 | else |
236 | { | 236 | { |
237 | sbHour->setMinValue( 0 ); | 237 | sbHour->setMinValue( 0 ); |
238 | sbHour->setMaxValue( 23 ); | 238 | sbHour->setMaxValue( 23 ); |
239 | 239 | ||
240 | if ( cbAmpm->currentItem() == ValuePM ) | 240 | if ( cbAmpm->currentItem() == ValuePM ) |
241 | { | 241 | { |
242 | show_hour += 12; | 242 | show_hour += 12; |
243 | if ( show_hour == 24 ) | 243 | if ( show_hour == 24 ) |
244 | show_hour = 0; | 244 | show_hour = 0; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | sbHour->setValue( show_hour ); | 248 | sbHour->setValue( show_hour ); |
249 | } | 249 | } |
250 | 250 | ||
251 | void TimeTabWidget::slotDateFormatChanged( const DateFormat &df ) | 251 | void TimeTabWidget::slotDateFormatChanged( const DateFormat &df ) |
252 | { | 252 | { |
253 | btnDate->setDateFormat( df ); | 253 | btnDate->setDateFormat( df ); |
254 | } | 254 | } |
255 | 255 | ||
256 | void TimeTabWidget::slotWeekStartChanged( int monday ) | 256 | void TimeTabWidget::slotWeekStartChanged( int monday ) |
257 | { | 257 | { |
258 | btnDate->setWeekStartsMonday( monday ); | 258 | btnDate->setWeekStartsMonday( monday ); |
259 | } | 259 | } |
260 | 260 | ||
261 | void TimeTabWidget::slotTZChanged( const QString &newtz ) | 261 | void TimeTabWidget::slotTZChanged( const QString &newtz ) |
262 | { | 262 | { |
263 | // If controls have a valid date & time, update systemtime | 263 | // If controls have a valid date & time, update systemtime |
264 | int hour = sbHour->value(); | 264 | int hour = sbHour->value(); |
265 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) | 265 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) |
266 | hour += 12; | 266 | hour += 12; |
267 | QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); | 267 | QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); |
268 | setSystemTime( dt ); | 268 | setSystemTime( dt ); |
269 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 269 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
270 | setTimeZone << newtz; | 270 | setTimeZone << newtz; |
271 | 271 | ||
272 | // Set system timezone | 272 | // Set system timezone |
273 | QString currtz = getenv( "TZ" ); | 273 | QString currtz = getenv( "TZ" ); |
274 | setenv( "TZ", newtz, 1 ); | 274 | setenv( "TZ", newtz, 1 ); |
275 | 275 | ||
276 | // Get new date/time | 276 | // Get new date/time |
277 | hour = sbHour->value(); | 277 | hour = sbHour->value(); |
278 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) | 278 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) |
279 | hour += 12; | 279 | hour += 12; |
280 | dt = QDateTime::currentDateTime(); | 280 | dt = QDateTime::currentDateTime(); |
281 | 281 | ||
282 | // Reset system timezone | 282 | // Reset system timezone |
283 | if ( !currtz.isNull() ) | 283 | if ( !currtz.isNull() ) |
284 | { | 284 | { |
285 | setenv( "TZ", currtz, 1 ); | 285 | setenv( "TZ", currtz, 1 ); |
286 | } | 286 | } |
287 | 287 | ||
288 | // Set controls to new time | 288 | // Set controls to new time |
289 | setDateTime( dt ); | 289 | setDateTime( dt ); |
290 | 290 | ||
291 | emit tzChanged( newtz ); | 291 | emit tzChanged( newtz ); |
292 | } | 292 | } |
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp index 698dfd3..ff65424 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp | |||
@@ -1,104 +1,104 @@ | |||
1 | 1 | ||
2 | #include "interfaceinformationimp.h" | 2 | #include "interfaceinformationimp.h" |
3 | #include "interfaceadvanced.h" | 3 | #include "interfaceadvanced.h" |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | /* QT */ | 9 | /* QT */ |
10 | #include <qcheckbox.h> | 10 | #include <qcheckbox.h> |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qlabel.h> | 12 | #include <qlabel.h> |
13 | #include <qgroupbox.h> | 13 | #include <qgroupbox.h> |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | 15 | ||
16 | 16 | ||
17 | #ifdef QWS | 17 | #ifdef QWS |
18 | #else | 18 | #else |
19 | #define showMaximized show | 19 | #define showMaximized show |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Constructor for the InterfaceInformationImp class. This class pretty much | 23 | * Constructor for the InterfaceInformationImp class. This class pretty much |
24 | * just display's information about the interface that is passed to it. | 24 | * just display's information about the interface that is passed to it. |
25 | */ | 25 | */ |
26 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i) | 26 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i) |
27 | { | 27 | { |
28 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 28 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); |
29 | connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); | 29 | connect(i, SIGNAL(updateMessage(const QString&)), this, SLOT(showMessage(const QString&))); |
30 | updateInterface(interface); | 30 | updateInterface(interface); |
31 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); | 31 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); |
32 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); | 32 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); |
33 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); | 33 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); |
34 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); | 34 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); |
35 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); | 35 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); |
36 | Config cfg("networksettings", Config::User); | 36 | Config cfg("networksettings", Config::User); |
37 | cfg.setGroup("interface"); | 37 | cfg.setGroup("interface"); |
38 | CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) ); | 38 | CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) ); |
39 | } | 39 | } |
40 | 40 | ||
41 | InterfaceInformationImp::~InterfaceInformationImp() | 41 | InterfaceInformationImp::~InterfaceInformationImp() |
42 | { | 42 | { |
43 | Config cfg("networksettings", Config::User); | 43 | Config cfg("networksettings", Config::User); |
44 | cfg.setGroup("interface"); | 44 | cfg.setGroup("interface"); |
45 | cfg.writeEntry("silent", CheckBoxSilent->isChecked() ); | 45 | cfg.writeEntry("silent", CheckBoxSilent->isChecked() ); |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Update the interface information and buttons. | 49 | * Update the interface information and buttons. |
50 | * @param Intarface *i the interface to update (should be the one we already | 50 | * @param Intarface *i the interface to update (should be the one we already |
51 | * know about). | 51 | * know about). |
52 | */ | 52 | */ |
53 | void InterfaceInformationImp::updateInterface(Interface *) | 53 | void InterfaceInformationImp::updateInterface(Interface *) |
54 | { | 54 | { |
55 | if(interface->getStatus()) | 55 | if(interface->getStatus()) |
56 | { | 56 | { |
57 | startButton->setEnabled(false); | 57 | startButton->setEnabled(false); |
58 | stopButton->setEnabled(true); | 58 | stopButton->setEnabled(true); |
59 | restartButton->setEnabled(true); | 59 | restartButton->setEnabled(true); |
60 | } | 60 | } |
61 | else | 61 | else |
62 | { | 62 | { |
63 | startButton->setEnabled(true); | 63 | startButton->setEnabled(true); |
64 | stopButton->setEnabled(false); | 64 | stopButton->setEnabled(false); |
65 | restartButton->setEnabled(false); | 65 | restartButton->setEnabled(false); |
66 | } | 66 | } |
67 | macAddressLabel->setText(interface->getMacAddress()); | 67 | macAddressLabel->setText(interface->getMacAddress()); |
68 | ipAddressLabel->setText(interface->getIp()); | 68 | ipAddressLabel->setText(interface->getIp()); |
69 | subnetMaskLabel->setText(interface->getSubnetMask()); | 69 | subnetMaskLabel->setText(interface->getSubnetMask()); |
70 | broadcastLabel->setText(interface->getBroadcast()); | 70 | broadcastLabel->setText(interface->getBroadcast()); |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Create the advanced widget. Fill it with the current interface's information. | 74 | * Create the advanced widget. Fill it with the current interface's information. |
75 | * Display it. | 75 | * Display it. |
76 | */ | 76 | */ |
77 | void InterfaceInformationImp::advanced() | 77 | void InterfaceInformationImp::advanced() |
78 | { | 78 | { |
79 | InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); | 79 | InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); |
80 | a->interfaceName->setText(interface->getInterfaceName()); | 80 | a->interfaceName->setText(interface->getInterfaceName()); |
81 | a->macAddressLabel->setText(interface->getMacAddress()); | 81 | a->macAddressLabel->setText(interface->getMacAddress()); |
82 | a->ipAddressLabel->setText(interface->getIp()); | 82 | a->ipAddressLabel->setText(interface->getIp()); |
83 | a->subnetMaskLabel->setText(interface->getSubnetMask()); | 83 | a->subnetMaskLabel->setText(interface->getSubnetMask()); |
84 | a->broadcastLabel->setText(interface->getBroadcast()); | 84 | a->broadcastLabel->setText(interface->getBroadcast()); |
85 | a->dhcpServerLabel->setText(interface->getDhcpServerIp()); | 85 | a->dhcpServerLabel->setText(interface->getDhcpServerIp()); |
86 | a->leaseObtainedLabel->setText(interface->getLeaseObtained()); | 86 | a->leaseObtainedLabel->setText(interface->getLeaseObtained()); |
87 | a->leaseExpiresLabel->setText(interface->getLeaseExpires()); | 87 | a->leaseExpiresLabel->setText(interface->getLeaseExpires()); |
88 | a->dhcpInformation->setEnabled(interface->isDhcp()); | 88 | a->dhcpInformation->setEnabled(interface->isDhcp()); |
89 | QPEApplication::showWidget( a ); | 89 | QPEApplication::showWidget( a ); |
90 | } | 90 | } |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Messages from the interface if start/stop went as planned. | 93 | * Messages from the interface if start/stop went as planned. |
94 | * Purly for user feedback. | 94 | * Purly for user feedback. |
95 | * @param message the message to display. | 95 | * @param message the message to display. |
96 | */ | 96 | */ |
97 | void InterfaceInformationImp::showMessage(const QString &message) | 97 | void InterfaceInformationImp::showMessage(const QString &message) |
98 | { | 98 | { |
99 | if (CheckBoxSilent->isChecked()) return; | 99 | if (CheckBoxSilent->isChecked()) return; |
100 | QMessageBox::information(this, "Message", message, QMessageBox::Ok); | 100 | QMessageBox::information(this, "Message", message, QMessageBox::Ok); |
101 | } | 101 | } |
102 | 102 | ||
103 | // infoimp.cpp | 103 | // infoimp.cpp |
104 | 104 | ||
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index b0a1dd9..1e16b97 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -1,748 +1,748 @@ | |||
1 | 1 | ||
2 | #include "mainwindowimp.h" | 2 | #include "mainwindowimp.h" |
3 | #include "addconnectionimp.h" | 3 | #include "addconnectionimp.h" |
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
5 | #include "interfacesetupimp.h" | 5 | #include "interfacesetupimp.h" |
6 | #include "interfaces.h" | 6 | #include "interfaces.h" |
7 | #include "module.h" | 7 | #include "module.h" |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <qpe/qcopenvelope_qws.h> | 10 | #include <qpe/qcopenvelope_qws.h> |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/qlibrary.h> | 13 | #include <qpe/qlibrary.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | /* QT */ | 16 | /* QT */ |
17 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
18 | #include <qlistbox.h> | 18 | #include <qlistbox.h> |
19 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
20 | #include <qlistview.h> | 20 | #include <qlistview.h> |
21 | #include <qheader.h> | 21 | #include <qheader.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qtabwidget.h> // in order to disable the profiles tab | 23 | #include <qtabwidget.h> // in order to disable the profiles tab |
24 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
25 | 25 | ||
26 | 26 | ||
27 | #if QT_VERSION < 300 | 27 | #if QT_VERSION < 300 |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | #else | 29 | #else |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #endif | 31 | #endif |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <net/if.h> | 38 | #include <net/if.h> |
39 | #include <sys/ioctl.h> | 39 | #include <sys/ioctl.h> |
40 | #include <sys/socket.h> | 40 | #include <sys/socket.h> |
41 | 41 | ||
42 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 42 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
43 | #define _PROCNETDEV "/proc/net/dev" | 43 | #define _PROCNETDEV "/proc/net/dev" |
44 | 44 | ||
45 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) | 45 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) |
46 | { | 46 | { |
47 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 47 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
48 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 48 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
49 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 49 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
50 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 50 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
51 | 51 | ||
52 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 52 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
53 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 53 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
54 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 54 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
55 | 55 | ||
56 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 56 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
57 | 57 | ||
58 | //FIXME: disable profiles for the moment: | 58 | //FIXME: disable profiles for the moment: |
59 | tabWidget->setTabEnabled( tab, false ); | 59 | tabWidget->setTabEnabled( tab, false ); |
60 | 60 | ||
61 | // Load connections. | 61 | // Load connections. |
62 | // /usr/local/kde/lib/libinterfaces.la | 62 | // /usr/local/kde/lib/libinterfaces.la |
63 | #ifdef QWS | 63 | #ifdef QWS |
64 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 64 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
65 | #else | 65 | #else |
66 | loader = KLibLoader::self(); | 66 | loader = KLibLoader::self(); |
67 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 67 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
68 | #endif | 68 | #endif |
69 | getAllInterfaces(); | 69 | getAllInterfaces(); |
70 | 70 | ||
71 | Interfaces i; | 71 | Interfaces i; |
72 | QStringList list = i.getInterfaceList(); | 72 | QStringList list = i.getInterfaceList(); |
73 | QMap<QString, Interface*>::Iterator it; | 73 | QMap<QString, Interface*>::Iterator it; |
74 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) | 74 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) |
75 | { | 75 | { |
76 | /* | 76 | /* |
77 | * we skipped it in getAllInterfaces now | 77 | * we skipped it in getAllInterfaces now |
78 | * we need to ignore it as well | 78 | * we need to ignore it as well |
79 | */ | 79 | */ |
80 | if (m_handledIfaces.contains( *ni) ) | 80 | if (m_handledIfaces.contains( *ni) ) |
81 | { | 81 | { |
82 | qDebug("Not up iface handled by module"); | 82 | qDebug("Not up iface handled by module"); |
83 | continue; | 83 | continue; |
84 | } | 84 | } |
85 | bool found = false; | 85 | bool found = false; |
86 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) | 86 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) |
87 | { | 87 | { |
88 | if(it.key() == (*ni)) | 88 | if(it.key() == (*ni)) |
89 | found = true; | 89 | found = true; |
90 | } | 90 | } |
91 | if(!found) | 91 | if(!found) |
92 | { | 92 | { |
93 | if(!(*ni).contains("_")) | 93 | if(!(*ni).contains("_")) |
94 | { | 94 | { |
95 | Interface *i = new Interface(this, *ni, false); | 95 | Interface *i = new Interface(this, *ni, false); |
96 | i->setAttached(false); | 96 | i->setAttached(false); |
97 | i->setHardwareName(tr("Disconnected")); | 97 | i->setHardwareName(tr("Disconnected")); |
98 | interfaceNames.insert(i->getInterfaceName(), i); | 98 | interfaceNames.insert(i->getInterfaceName(), i); |
99 | updateInterface(i); | 99 | updateInterface(i); |
100 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 100 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | //getInterfaceList(); | 105 | //getInterfaceList(); |
106 | connectionList->header()->hide(); | 106 | connectionList->header()->hide(); |
107 | 107 | ||
108 | Config cfg("NetworkSetup"); | 108 | Config cfg("NetworkSetup"); |
109 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 109 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
110 | for ( QStringList::Iterator it = profiles.begin(); | 110 | for ( QStringList::Iterator it = profiles.begin(); |
111 | it != profiles.end(); ++it) | 111 | it != profiles.end(); ++it) |
112 | profilesList->insertItem((*it)); | 112 | profilesList->insertItem((*it)); |
113 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 113 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
114 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 114 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
115 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 115 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
116 | 116 | ||
117 | QFile file(scheme); | 117 | QFile file(scheme); |
118 | if ( file.open(IO_ReadOnly) ) | 118 | if ( file.open(IO_ReadOnly) ) |
119 | { // file opened successfully | 119 | { // file opened successfully |
120 | QTextStream stream( &file ); // use a text stream | 120 | QTextStream stream( &file ); // use a text stream |
121 | while ( !stream.eof() ) | 121 | while ( !stream.eof() ) |
122 | { // until end of file... | 122 | { // until end of file... |
123 | QString line = stream.readLine(); // line of text excluding '\n' | 123 | QString line = stream.readLine(); // line of text excluding '\n' |
124 | if(line.contains("SCHEME")) | 124 | if(line.contains("SCHEME")) |
125 | { | 125 | { |
126 | line = line.mid(7, line.length()); | 126 | line = line.mid(7, line.length()); |
127 | currentProfileLabel->setText(line); | 127 | currentProfileLabel->setText(line); |
128 | break; | 128 | break; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | file.close(); | 131 | file.close(); |
132 | } | 132 | } |
133 | makeChannel(); | 133 | makeChannel(); |
134 | } | 134 | } |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Deconstructor. Save profiles. Delete loaded libraries. | 137 | * Deconstructor. Save profiles. Delete loaded libraries. |
138 | */ | 138 | */ |
139 | MainWindowImp::~MainWindowImp() | 139 | MainWindowImp::~MainWindowImp() |
140 | { | 140 | { |
141 | // Save profiles. | 141 | // Save profiles. |
142 | Config cfg("NetworkSetup"); | 142 | Config cfg("NetworkSetup"); |
143 | cfg.setGroup("General"); | 143 | cfg.setGroup("General"); |
144 | cfg.writeEntry("Profiles", profiles.join(" ")); | 144 | cfg.writeEntry("Profiles", profiles.join(" ")); |
145 | 145 | ||
146 | // Delete all interfaces that don't have owners. | 146 | // Delete all interfaces that don't have owners. |
147 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 147 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
148 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) | 148 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
149 | { | 149 | { |
150 | if(iIt.key()->getModuleOwner() == NULL) | 150 | if(iIt.key()->getModuleOwner() == NULL) |
151 | delete iIt.key(); | 151 | delete iIt.key(); |
152 | } | 152 | } |
153 | 153 | ||
154 | #ifdef QWS | 154 | #ifdef QWS |
155 | // Delete Modules and Libraries | 155 | // Delete Modules and Libraries |
156 | QMap<Module*, QLibrary*>::Iterator it; | 156 | QMap<Module*, QLibrary*>::Iterator it; |
157 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 157 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
158 | { | 158 | { |
159 | delete it.key(); | 159 | delete it.key(); |
160 | // I wonder why I can't delete the libraries | 160 | // I wonder why I can't delete the libraries |
161 | // What fucking shit this is. | 161 | // What fucking shit this is. |
162 | //delete it.data(); | 162 | //delete it.data(); |
163 | } | 163 | } |
164 | #else | 164 | #else |
165 | // klibloader automaticly deletes the libraries for us... | 165 | // klibloader automaticly deletes the libraries for us... |
166 | #endif | 166 | #endif |
167 | } | 167 | } |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Query the kernel for all of the interfaces. | 170 | * Query the kernel for all of the interfaces. |
171 | */ | 171 | */ |
172 | void MainWindowImp::getAllInterfaces() | 172 | void MainWindowImp::getAllInterfaces() |
173 | { | 173 | { |
174 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 174 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
175 | if(sockfd == -1) | 175 | if(sockfd == -1) |
176 | return; | 176 | return; |
177 | 177 | ||
178 | struct ifreq ifr; | 178 | struct ifreq ifr; |
179 | QStringList ifaces; | 179 | QStringList ifaces; |
180 | QFile procFile(QString(_PROCNETDEV)); | 180 | QFile procFile(QString(_PROCNETDEV)); |
181 | int result; | 181 | int result; |
182 | Interface *i; | 182 | Interface *i; |
183 | 183 | ||
184 | if (! procFile.exists()) | 184 | if (! procFile.exists()) |
185 | { | 185 | { |
186 | struct ifreq ifrs[100]; | 186 | struct ifreq ifrs[100]; |
187 | struct ifconf ifc; | 187 | struct ifconf ifc; |
188 | ifc.ifc_len = sizeof(ifrs); | 188 | ifc.ifc_len = sizeof(ifrs); |
189 | ifc.ifc_req = ifrs; | 189 | ifc.ifc_req = ifrs; |
190 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 190 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
191 | 191 | ||
192 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) | 192 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) |
193 | { | 193 | { |
194 | struct ifreq *pifr = &ifrs[i]; | 194 | struct ifreq *pifr = &ifrs[i]; |
195 | 195 | ||
196 | ifaces += pifr->ifr_name; | 196 | ifaces += pifr->ifr_name; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | else | 199 | else |
200 | { | 200 | { |
201 | procFile.open(IO_ReadOnly); | 201 | procFile.open(IO_ReadOnly); |
202 | QString line; | 202 | QString line; |
203 | QTextStream procTs(&procFile); | 203 | QTextStream procTs(&procFile); |
204 | int loc = -1; | 204 | int loc = -1; |
205 | 205 | ||
206 | procTs.readLine(); // eat a line | 206 | procTs.readLine(); // eat a line |
207 | procTs.readLine(); // eat a line | 207 | procTs.readLine(); // eat a line |
208 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) | 208 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) |
209 | { | 209 | { |
210 | if((loc = line.find(":")) != -1) | 210 | if((loc = line.find(":")) != -1) |
211 | { | 211 | { |
212 | ifaces += line.left(loc); | 212 | ifaces += line.left(loc); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) | 217 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
218 | { | 218 | { |
219 | int flags = 0; | 219 | int flags = 0; |
220 | if ( m_handledIfaces.contains( (*it) ) ) | 220 | if ( m_handledIfaces.contains( (*it) ) ) |
221 | { | 221 | { |
222 | qDebug(" %s is handled by a module", (*it).latin1() ); | 222 | qDebug(" %s is handled by a module", (*it).latin1() ); |
223 | continue; | 223 | continue; |
224 | } | 224 | } |
225 | // int family; | 225 | // int family; |
226 | i = NULL; | 226 | i = NULL; |
227 | 227 | ||
228 | strcpy(ifr.ifr_name, (*it).latin1()); | 228 | strcpy(ifr.ifr_name, (*it).latin1()); |
229 | 229 | ||
230 | struct ifreq ifcopy; | 230 | struct ifreq ifcopy; |
231 | ifcopy = ifr; | 231 | ifcopy = ifr; |
232 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 232 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
233 | flags = ifcopy.ifr_flags; | 233 | flags = ifcopy.ifr_flags; |
234 | i = new Interface(this, ifr.ifr_name, false); | 234 | i = new Interface(this, ifr.ifr_name, false); |
235 | i->setAttached(true); | 235 | i->setAttached(true); |
236 | if ((flags & IFF_UP) == IFF_UP) | 236 | if ((flags & IFF_UP) == IFF_UP) |
237 | i->setStatus(true); | 237 | i->setStatus(true); |
238 | else | 238 | else |
239 | i->setStatus(false); | 239 | i->setStatus(false); |
240 | 240 | ||
241 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 241 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
242 | i->setHardwareName("Ethernet"); | 242 | i->setHardwareName("Ethernet"); |
243 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 243 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
244 | i->setHardwareName("Point to Point"); | 244 | i->setHardwareName("Point to Point"); |
245 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 245 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
246 | i->setHardwareName("Multicast"); | 246 | i->setHardwareName("Multicast"); |
247 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 247 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
248 | i->setHardwareName("Loopback"); | 248 | i->setHardwareName("Loopback"); |
249 | else | 249 | else |
250 | i->setHardwareName("Unknown"); | 250 | i->setHardwareName("Unknown"); |
251 | 251 | ||
252 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); | 252 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); |
253 | interfaceNames.insert(i->getInterfaceName(), i); | 253 | interfaceNames.insert(i->getInterfaceName(), i); |
254 | updateInterface(i); | 254 | updateInterface(i); |
255 | connect(i, SIGNAL(updateInterface(Interface *)), | 255 | connect(i, SIGNAL(updateInterface(Interface*)), |
256 | this, SLOT(updateInterface(Interface *))); | 256 | this, SLOT(updateInterface(Interface*))); |
257 | } | 257 | } |
258 | // now lets ask the plugins too ;) | 258 | // now lets ask the plugins too ;) |
259 | QMap<Module*, QLibrary*>::Iterator it; | 259 | QMap<Module*, QLibrary*>::Iterator it; |
260 | QList<Interface> ilist; | 260 | QList<Interface> ilist; |
261 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 261 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
262 | { | 262 | { |
263 | if(it.key()) | 263 | if(it.key()) |
264 | { | 264 | { |
265 | ilist = it.key()->getInterfaces(); | 265 | ilist = it.key()->getInterfaces(); |
266 | for( i = ilist.first(); i != 0; i = ilist.next() ) | 266 | for( i = ilist.first(); i != 0; i = ilist.next() ) |
267 | { | 267 | { |
268 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | 268 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); |
269 | interfaceNames.insert(i->getInterfaceName(), i); | 269 | interfaceNames.insert(i->getInterfaceName(), i); |
270 | updateInterface(i); | 270 | updateInterface(i); |
271 | connect(i, SIGNAL(updateInterface(Interface *)), | 271 | connect(i, SIGNAL(updateInterface(Interface*)), |
272 | this, SLOT(updateInterface(Interface *))); | 272 | this, SLOT(updateInterface(Interface*))); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | /** | 278 | /** |
279 | * Load all modules that are found in the path | 279 | * Load all modules that are found in the path |
280 | * @param path a directory that is scaned for any plugins that can be loaded | 280 | * @param path a directory that is scaned for any plugins that can be loaded |
281 | * and attempts to load them | 281 | * and attempts to load them |
282 | */ | 282 | */ |
283 | void MainWindowImp::loadModules(const QString &path) | 283 | void MainWindowImp::loadModules(const QString &path) |
284 | { | 284 | { |
285 | #ifdef DEBUG | 285 | #ifdef DEBUG |
286 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); | 286 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); |
287 | #endif | 287 | #endif |
288 | QDir d(path); | 288 | QDir d(path); |
289 | if(!d.exists()) | 289 | if(!d.exists()) |
290 | return; | 290 | return; |
291 | 291 | ||
292 | // Don't want sym links | 292 | // Don't want sym links |
293 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 293 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
294 | const QFileInfoList *list = d.entryInfoList(); | 294 | const QFileInfoList *list = d.entryInfoList(); |
295 | QFileInfoListIterator it( *list ); | 295 | QFileInfoListIterator it( *list ); |
296 | QFileInfo *fi; | 296 | QFileInfo *fi; |
297 | while ( (fi=it.current()) ) | 297 | while ( (fi=it.current()) ) |
298 | { | 298 | { |
299 | #ifdef QWS | 299 | #ifdef QWS |
300 | if(fi->fileName().contains(".so")) | 300 | if(fi->fileName().contains(".so")) |
301 | { | 301 | { |
302 | #else | 302 | #else |
303 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")) | 303 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")) |
304 | { | 304 | { |
305 | #endif | 305 | #endif |
306 | loadPlugin(path + "/" + fi->fileName()); | 306 | loadPlugin(path + "/" + fi->fileName()); |
307 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); | 307 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); |
308 | } | 308 | } |
309 | ++it; | 309 | ++it; |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | /** | 313 | /** |
314 | * Attempt to load a function and resolve a function. | 314 | * Attempt to load a function and resolve a function. |
315 | * @param pluginFileName - the name of the file in which to attempt to load | 315 | * @param pluginFileName - the name of the file in which to attempt to load |
316 | * @param resolveString - function pointer to resolve | 316 | * @param resolveString - function pointer to resolve |
317 | * @return pointer to the function with name resolveString or NULL | 317 | * @return pointer to the function with name resolveString or NULL |
318 | */ | 318 | */ |
319 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) | 319 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
320 | { | 320 | { |
321 | #ifdef DEBUG | 321 | #ifdef DEBUG |
322 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); | 322 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); |
323 | #endif | 323 | #endif |
324 | #ifdef QWS | 324 | #ifdef QWS |
325 | QLibrary *lib = new QLibrary(pluginFileName); | 325 | QLibrary *lib = new QLibrary(pluginFileName); |
326 | void *functionPointer = lib->resolve(resolveString); | 326 | void *functionPointer = lib->resolve(resolveString); |
327 | if( !functionPointer ) | 327 | if( !functionPointer ) |
328 | { | 328 | { |
329 | #ifdef DEBUG | 329 | #ifdef DEBUG |
330 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); | 330 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); |
331 | #endif | 331 | #endif |
332 | delete lib; | 332 | delete lib; |
333 | return NULL; | 333 | return NULL; |
334 | } | 334 | } |
335 | // Try to get an object. | 335 | // Try to get an object. |
336 | Module *object = ((Module* (*)()) functionPointer)(); | 336 | Module *object = ((Module* (*)()) functionPointer)(); |
337 | if(object == NULL) | 337 | if(object == NULL) |
338 | { | 338 | { |
339 | #ifdef DEBUG | 339 | #ifdef DEBUG |
340 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 340 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
341 | #endif | 341 | #endif |
342 | delete lib; | 342 | delete lib; |
343 | return NULL; | 343 | return NULL; |
344 | } | 344 | } |
345 | 345 | ||
346 | m_handledIfaces += object->handledInterfaceNames(); | 346 | m_handledIfaces += object->handledInterfaceNames(); |
347 | // Store for deletion later | 347 | // Store for deletion later |
348 | libraries.insert(object, lib); | 348 | libraries.insert(object, lib); |
349 | return object; | 349 | return object; |
350 | 350 | ||
351 | #else | 351 | #else |
352 | QLibrary *lib = loader->library(pluginFileName); | 352 | QLibrary *lib = loader->library(pluginFileName); |
353 | if( !lib || !lib->hasSymbol(resolveString) ) | 353 | if( !lib || !lib->hasSymbol(resolveString) ) |
354 | { | 354 | { |
355 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 355 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
356 | return NULL; | 356 | return NULL; |
357 | } | 357 | } |
358 | // Try to get an object. | 358 | // Try to get an object. |
359 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); | 359 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); |
360 | if(object == NULL) | 360 | if(object == NULL) |
361 | { | 361 | { |
362 | #ifdef DEBUG | 362 | #ifdef DEBUG |
363 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 363 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
364 | #endif | 364 | #endif |
365 | return NULL; | 365 | return NULL; |
366 | } | 366 | } |
367 | #ifdef DEBUG | 367 | #ifdef DEBUG |
368 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); | 368 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); |
369 | #endif | 369 | #endif |
370 | // Store for deletion later | 370 | // Store for deletion later |
371 | libraries.insert(object, lib); | 371 | libraries.insert(object, lib); |
372 | return object; | 372 | return object; |
373 | #endif | 373 | #endif |
374 | } | 374 | } |
375 | 375 | ||
376 | /** | 376 | /** |
377 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 377 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
378 | * load the plugin and append it to the list | 378 | * load the plugin and append it to the list |
379 | */ | 379 | */ |
380 | void MainWindowImp::addClicked() | 380 | void MainWindowImp::addClicked() |
381 | { | 381 | { |
382 | QMap<Module*, QLibrary*>::Iterator it; | 382 | QMap<Module*, QLibrary*>::Iterator it; |
383 | QMap<QString, QString> list; | 383 | QMap<QString, QString> list; |
384 | QMap<QString, Module*> newInterfaceOwners; | 384 | QMap<QString, Module*> newInterfaceOwners; |
385 | 385 | ||
386 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 386 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
387 | { | 387 | { |
388 | if(it.key()) | 388 | if(it.key()) |
389 | { | 389 | { |
390 | (it.key())->possibleNewInterfaces(list); | 390 | (it.key())->possibleNewInterfaces(list); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | // See if the list has anything that we can add. | 393 | // See if the list has anything that we can add. |
394 | if(list.count() == 0) | 394 | if(list.count() == 0) |
395 | { | 395 | { |
396 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 396 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
397 | return; | 397 | return; |
398 | } | 398 | } |
399 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 399 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
400 | addNewConnection.addConnections(list); | 400 | addNewConnection.addConnections(list); |
401 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) | 401 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) |
402 | { | 402 | { |
403 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 403 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
404 | if(!item) | 404 | if(!item) |
405 | return; | 405 | return; |
406 | 406 | ||
407 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 407 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
408 | { | 408 | { |
409 | if(it.key()) | 409 | if(it.key()) |
410 | { | 410 | { |
411 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 411 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
412 | if(i) | 412 | if(i) |
413 | { | 413 | { |
414 | qDebug("iface name %s",i->getInterfaceName().latin1()); | 414 | qDebug("iface name %s",i->getInterfaceName().latin1()); |
415 | interfaceNames.insert(i->getInterfaceName(), i); | 415 | interfaceNames.insert(i->getInterfaceName(), i); |
416 | updateInterface(i); | 416 | updateInterface(i); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | 422 | ||
423 | /** | 423 | /** |
424 | * Prompt the user to see if they really want to do this. | 424 | * Prompt the user to see if they really want to do this. |
425 | * If they do then remove from the list and unload. | 425 | * If they do then remove from the list and unload. |
426 | */ | 426 | */ |
427 | void MainWindowImp::removeClicked() | 427 | void MainWindowImp::removeClicked() |
428 | { | 428 | { |
429 | QListViewItem *item = connectionList->currentItem(); | 429 | QListViewItem *item = connectionList->currentItem(); |
430 | if(!item) | 430 | if(!item) |
431 | { | 431 | { |
432 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 432 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
433 | return; | 433 | return; |
434 | } | 434 | } |
435 | 435 | ||
436 | Interface *i = interfaceItems[item]; | 436 | Interface *i = interfaceItems[item]; |
437 | if(i->getModuleOwner() == NULL) | 437 | if(i->getModuleOwner() == NULL) |
438 | { | 438 | { |
439 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 439 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
440 | } | 440 | } |
441 | else | 441 | else |
442 | { | 442 | { |
443 | if(!i->getModuleOwner()->remove(i)) | 443 | if(!i->getModuleOwner()->remove(i)) |
444 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 444 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
445 | else | 445 | else |
446 | { | 446 | { |
447 | delete item; | 447 | delete item; |
448 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 448 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
449 | } | 449 | } |
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | /** | 453 | /** |
454 | * Pull up the configure about the currently selected interface. | 454 | * Pull up the configure about the currently selected interface. |
455 | * Report an error if no interface is selected. | 455 | * Report an error if no interface is selected. |
456 | * If the interface has a module owner then request its configure. | 456 | * If the interface has a module owner then request its configure. |
457 | */ | 457 | */ |
458 | void MainWindowImp::configureClicked() | 458 | void MainWindowImp::configureClicked() |
459 | { | 459 | { |
460 | QListViewItem *item = connectionList->currentItem(); | 460 | QListViewItem *item = connectionList->currentItem(); |
461 | if(!item) | 461 | if(!item) |
462 | { | 462 | { |
463 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 463 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
464 | return; | 464 | return; |
465 | } | 465 | } |
466 | 466 | ||
467 | QString currentProfileText = currentProfileLabel->text(); | 467 | QString currentProfileText = currentProfileLabel->text(); |
468 | if(currentProfileText.upper() == "ALL"); | 468 | if(currentProfileText.upper() == "ALL"); |
469 | currentProfileText = ""; | 469 | currentProfileText = ""; |
470 | 470 | ||
471 | Interface *i = interfaceItems[item]; | 471 | Interface *i = interfaceItems[item]; |
472 | 472 | ||
473 | if(i->getModuleOwner()) | 473 | if(i->getModuleOwner()) |
474 | { | 474 | { |
475 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 475 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
476 | if(moduleConfigure != NULL) | 476 | if(moduleConfigure != NULL) |
477 | { | 477 | { |
478 | i->getModuleOwner()->setProfile(currentProfileText); | 478 | i->getModuleOwner()->setProfile(currentProfileText); |
479 | QPEApplication::showWidget( moduleConfigure ); | 479 | QPEApplication::showWidget( moduleConfigure ); |
480 | return; | 480 | return; |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); | 484 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
485 | configure->setProfile(currentProfileText); | 485 | configure->setProfile(currentProfileText); |
486 | QPEApplication::showDialog( configure ); | 486 | QPEApplication::showDialog( configure ); |
487 | } | 487 | } |
488 | 488 | ||
489 | /** | 489 | /** |
490 | * Pull up the information about the currently selected interface. | 490 | * Pull up the information about the currently selected interface. |
491 | * Report an error if no interface is selected. | 491 | * Report an error if no interface is selected. |
492 | * If the interface has a module owner then request its configure. | 492 | * If the interface has a module owner then request its configure. |
493 | */ | 493 | */ |
494 | void MainWindowImp::informationClicked() | 494 | void MainWindowImp::informationClicked() |
495 | { | 495 | { |
496 | QListViewItem *item = connectionList->currentItem(); | 496 | QListViewItem *item = connectionList->currentItem(); |
497 | if(!item) | 497 | if(!item) |
498 | { | 498 | { |
499 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 499 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
500 | return; | 500 | return; |
501 | } | 501 | } |
502 | 502 | ||
503 | Interface *i = interfaceItems[item]; | 503 | Interface *i = interfaceItems[item]; |
504 | // if(!i->isAttached()){ | 504 | // if(!i->isAttached()){ |
505 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 505 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
506 | // return; | 506 | // return; |
507 | // } | 507 | // } |
508 | 508 | ||
509 | if(i->getModuleOwner()) | 509 | if(i->getModuleOwner()) |
510 | { | 510 | { |
511 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 511 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
512 | if(moduleInformation != NULL) | 512 | if(moduleInformation != NULL) |
513 | { | 513 | { |
514 | QPEApplication::showWidget( moduleInformation ); | 514 | QPEApplication::showWidget( moduleInformation ); |
515 | #ifdef DEBUG | 515 | #ifdef DEBUG |
516 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 516 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
517 | #endif | 517 | #endif |
518 | return; | 518 | return; |
519 | } | 519 | } |
520 | } | 520 | } |
521 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); | 521 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); |
522 | QPEApplication::showWidget( information ); | 522 | QPEApplication::showWidget( information ); |
523 | } | 523 | } |
524 | 524 | ||
525 | /** | 525 | /** |
526 | * Update this interface. If no QListViewItem exists create one. | 526 | * Update this interface. If no QListViewItem exists create one. |
527 | * @param Interface* pointer to the interface that needs to be updated. | 527 | * @param Interface* pointer to the interface that needs to be updated. |
528 | */ | 528 | */ |
529 | void MainWindowImp::updateInterface(Interface *i) | 529 | void MainWindowImp::updateInterface(Interface *i) |
530 | { | 530 | { |
531 | if(!advancedUserMode) | 531 | if(!advancedUserMode) |
532 | { | 532 | { |
533 | if(i->getInterfaceName() == "lo") | 533 | if(i->getInterfaceName() == "lo") |
534 | return; | 534 | return; |
535 | } | 535 | } |
536 | 536 | ||
537 | QListViewItem *item = NULL; | 537 | QListViewItem *item = NULL; |
538 | 538 | ||
539 | // Find the interface, making it if needed. | 539 | // Find the interface, making it if needed. |
540 | if(items.find(i) == items.end()) | 540 | if(items.find(i) == items.end()) |
541 | { | 541 | { |
542 | item = new QListViewItem(connectionList, "", "", ""); | 542 | item = new QListViewItem(connectionList, "", "", ""); |
543 | // See if you can't find a module owner for this interface | 543 | // See if you can't find a module owner for this interface |
544 | QMap<Module*, QLibrary*>::Iterator it; | 544 | QMap<Module*, QLibrary*>::Iterator it; |
545 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 545 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
546 | { | 546 | { |
547 | if(it.key()->isOwner(i)) | 547 | if(it.key()->isOwner(i)) |
548 | i->setModuleOwner(it.key()); | 548 | i->setModuleOwner(it.key()); |
549 | } | 549 | } |
550 | items.insert(i, item); | 550 | items.insert(i, item); |
551 | interfaceItems.insert(item, i); | 551 | interfaceItems.insert(item, i); |
552 | } | 552 | } |
553 | else | 553 | else |
554 | item = items[i]; | 554 | item = items[i]; |
555 | 555 | ||
556 | // Update the icons and information | 556 | // Update the icons and information |
557 | #ifdef QWS | 557 | #ifdef QWS |
558 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 558 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
559 | #else | 559 | #else |
560 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 560 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
561 | #endif | 561 | #endif |
562 | 562 | ||
563 | QString typeName = "lan"; | 563 | QString typeName = "lan"; |
564 | if(i->getInterfaceName() == "lo") | 564 | if(i->getInterfaceName() == "lo") |
565 | typeName = "lo"; | 565 | typeName = "lo"; |
566 | if(i->getInterfaceName().contains("irda")) | 566 | if(i->getInterfaceName().contains("irda")) |
567 | typeName = "irda"; | 567 | typeName = "irda"; |
568 | if(i->getInterfaceName().contains("wlan")) | 568 | if(i->getInterfaceName().contains("wlan")) |
569 | typeName = "wlan"; | 569 | typeName = "wlan"; |
570 | if(i->getInterfaceName().contains("usb")) | 570 | if(i->getInterfaceName().contains("usb")) |
571 | typeName = "usb"; | 571 | typeName = "usb"; |
572 | 572 | ||
573 | if(!i->isAttached()) | 573 | if(!i->isAttached()) |
574 | typeName = "connect_no"; | 574 | typeName = "connect_no"; |
575 | // Actually try to use the Module | 575 | // Actually try to use the Module |
576 | if(i->getModuleOwner() != NULL) | 576 | if(i->getModuleOwner() != NULL) |
577 | typeName = i->getModuleOwner()->getPixmapName(i); | 577 | typeName = i->getModuleOwner()->getPixmapName(i); |
578 | 578 | ||
579 | #ifdef QWS | 579 | #ifdef QWS |
580 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 580 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
581 | #else | 581 | #else |
582 | item->setPixmap(1, (SmallIcon(typeName))); | 582 | item->setPixmap(1, (SmallIcon(typeName))); |
583 | #endif | 583 | #endif |
584 | item->setText(2, i->getHardwareName()); | 584 | item->setText(2, i->getHardwareName()); |
585 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 585 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
586 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 586 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
587 | } | 587 | } |
588 | 588 | ||
589 | void MainWindowImp::newProfileChanged(const QString& newText) | 589 | void MainWindowImp::newProfileChanged(const QString& newText) |
590 | { | 590 | { |
591 | if(newText.length() > 0) | 591 | if(newText.length() > 0) |
592 | newProfileButton->setEnabled(true); | 592 | newProfileButton->setEnabled(true); |
593 | else | 593 | else |
594 | newProfileButton->setEnabled(false); | 594 | newProfileButton->setEnabled(false); |
595 | } | 595 | } |
596 | 596 | ||
597 | /** | 597 | /** |
598 | * Adds a new profile to the list of profiles. | 598 | * Adds a new profile to the list of profiles. |
599 | * Don't add profiles that already exists. | 599 | * Don't add profiles that already exists. |
600 | * Appends to the list and QStringList | 600 | * Appends to the list and QStringList |
601 | */ | 601 | */ |
602 | void MainWindowImp::addProfile() | 602 | void MainWindowImp::addProfile() |
603 | { | 603 | { |
604 | QString newProfileName = newProfile->text(); | 604 | QString newProfileName = newProfile->text(); |
605 | if(profiles.grep(newProfileName).count() > 0) | 605 | if(profiles.grep(newProfileName).count() > 0) |
606 | { | 606 | { |
607 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 607 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
608 | return; | 608 | return; |
609 | } | 609 | } |
610 | profiles.append(newProfileName); | 610 | profiles.append(newProfileName); |
611 | profilesList->insertItem(newProfileName); | 611 | profilesList->insertItem(newProfileName); |
612 | } | 612 | } |
613 | 613 | ||
614 | /** | 614 | /** |
615 | * Removes the currently selected profile in the combo. | 615 | * Removes the currently selected profile in the combo. |
616 | * Doesn't delete if there are less then 2 profiles. | 616 | * Doesn't delete if there are less then 2 profiles. |
617 | */ | 617 | */ |
618 | void MainWindowImp::removeProfile() | 618 | void MainWindowImp::removeProfile() |
619 | { | 619 | { |
620 | if(profilesList->count() <= 1) | 620 | if(profilesList->count() <= 1) |
621 | { | 621 | { |
622 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 622 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
623 | return; | 623 | return; |
624 | } | 624 | } |
625 | QString profileToRemove = profilesList->currentText(); | 625 | QString profileToRemove = profilesList->currentText(); |
626 | if(profileToRemove == "All") | 626 | if(profileToRemove == "All") |
627 | { | 627 | { |
628 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 628 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
629 | return; | 629 | return; |
630 | } | 630 | } |
631 | // Can't remove the curent profile | 631 | // Can't remove the curent profile |
632 | if(profileToRemove == currentProfileLabel->text()) | 632 | if(profileToRemove == currentProfileLabel->text()) |
633 | { | 633 | { |
634 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 634 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
635 | return; | 635 | return; |
636 | 636 | ||
637 | } | 637 | } |
638 | 638 | ||
639 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) | 639 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) |
640 | { | 640 | { |
641 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 641 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
642 | profilesList->clear(); | 642 | profilesList->clear(); |
643 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 643 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
644 | profilesList->insertItem((*it)); | 644 | profilesList->insertItem((*it)); |
645 | 645 | ||
646 | // Remove any interface settings and mappings. | 646 | // Remove any interface settings and mappings. |
647 | Interfaces interfaces; | 647 | Interfaces interfaces; |
648 | // Go through them one by one | 648 | // Go through them one by one |
649 | QMap<Interface*, QListViewItem*>::Iterator it; | 649 | QMap<Interface*, QListViewItem*>::Iterator it; |
650 | for( it = items.begin(); it != items.end(); ++it ) | 650 | for( it = items.begin(); it != items.end(); ++it ) |
651 | { | 651 | { |
652 | QString interfaceName = it.key()->getInterfaceName(); | 652 | QString interfaceName = it.key()->getInterfaceName(); |
653 | qDebug(interfaceName.latin1()); | 653 | qDebug(interfaceName.latin1()); |
654 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) | 654 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) |
655 | { | 655 | { |
656 | interfaces.removeInterface(); | 656 | interfaces.removeInterface(); |
657 | if(interfaces.setMapping(interfaceName)) | 657 | if(interfaces.setMapping(interfaceName)) |
658 | { | 658 | { |
659 | if(profilesList->count() == 1) | 659 | if(profilesList->count() == 1) |
660 | interfaces.removeMapping(); | 660 | interfaces.removeMapping(); |
661 | else | 661 | else |
662 | { | 662 | { |
663 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 663 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
664 | } | 664 | } |
665 | } | 665 | } |
666 | interfaces.write(); | 666 | interfaces.write(); |
667 | break; | 667 | break; |
668 | } | 668 | } |
669 | } | 669 | } |
670 | } | 670 | } |
671 | } | 671 | } |
672 | 672 | ||
673 | /** | 673 | /** |
674 | * A new profile has been selected, change. | 674 | * A new profile has been selected, change. |
675 | * @param newProfile the new profile. | 675 | * @param newProfile the new profile. |
676 | */ | 676 | */ |
677 | void MainWindowImp::changeProfile() | 677 | void MainWindowImp::changeProfile() |
678 | { | 678 | { |
679 | if(profilesList->currentItem() == -1) | 679 | if(profilesList->currentItem() == -1) |
680 | { | 680 | { |
681 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 681 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
682 | return; | 682 | return; |
683 | } | 683 | } |
684 | QString newProfile = profilesList->text(profilesList->currentItem()); | 684 | QString newProfile = profilesList->text(profilesList->currentItem()); |
685 | if(newProfile != currentProfileLabel->text()) | 685 | if(newProfile != currentProfileLabel->text()) |
686 | { | 686 | { |
687 | currentProfileLabel->setText(newProfile); | 687 | currentProfileLabel->setText(newProfile); |
688 | QFile::remove(scheme); | 688 | QFile::remove(scheme); |
689 | QFile file(scheme); | 689 | QFile file(scheme); |
690 | if ( file.open(IO_ReadWrite) ) | 690 | if ( file.open(IO_ReadWrite) ) |
691 | { | 691 | { |
692 | QTextStream stream( &file ); | 692 | QTextStream stream( &file ); |
693 | stream << QString("SCHEME=%1").arg(newProfile); | 693 | stream << QString("SCHEME=%1").arg(newProfile); |
694 | file.close(); | 694 | file.close(); |
695 | } | 695 | } |
696 | // restart all up devices? | 696 | // restart all up devices? |
697 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) | 697 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) |
698 | { | 698 | { |
699 | // Go through them one by one | 699 | // Go through them one by one |
700 | QMap<Interface*, QListViewItem*>::Iterator it; | 700 | QMap<Interface*, QListViewItem*>::Iterator it; |
701 | for( it = items.begin(); it != items.end(); ++it ) | 701 | for( it = items.begin(); it != items.end(); ++it ) |
702 | { | 702 | { |
703 | if(it.key()->getStatus() == true) | 703 | if(it.key()->getStatus() == true) |
704 | it.key()->restart(); | 704 | it.key()->restart(); |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } | 707 | } |
708 | // TODO change the profile in the modules | 708 | // TODO change the profile in the modules |
709 | } | 709 | } |
710 | 710 | ||
711 | 711 | ||
712 | void MainWindowImp::makeChannel() | 712 | void MainWindowImp::makeChannel() |
713 | { | 713 | { |
714 | channel = new QCopChannel( "QPE/Application/networksettings", this ); | 714 | channel = new QCopChannel( "QPE/Application/networksettings", this ); |
715 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 715 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
716 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 716 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
717 | } | 717 | } |
718 | 718 | ||
719 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | 719 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) |
720 | { | 720 | { |
721 | bool found = false; | 721 | bool found = false; |
722 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); | 722 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); |
723 | if (msg == "raise") | 723 | if (msg == "raise") |
724 | { | 724 | { |
725 | raise(); | 725 | raise(); |
726 | return; | 726 | return; |
727 | } | 727 | } |
728 | 728 | ||
729 | QString dest = msg.left(msg.find("(")); | 729 | QString dest = msg.left(msg.find("(")); |
730 | QCString param = msg.right(msg.length() - msg.find("(") - 1); | 730 | QCString param = msg.right(msg.length() - msg.find("(") - 1); |
731 | param = param.left( param.length() - 1 ); | 731 | param = param.left( param.length() - 1 ); |
732 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); | 732 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); |
733 | 733 | ||
734 | QMap<Module*, QLibrary*>::Iterator it; | 734 | QMap<Module*, QLibrary*>::Iterator it; |
735 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 735 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
736 | { | 736 | { |
737 | qDebug("plugin >%s<", it.key()->type().latin1() ); | 737 | qDebug("plugin >%s<", it.key()->type().latin1() ); |
738 | if(it.key()->type() == dest) | 738 | if(it.key()->type() == dest) |
739 | { | 739 | { |
740 | it.key()->receive( param, arg ); | 740 | it.key()->receive( param, arg ); |
741 | found = true; | 741 | found = true; |
742 | } | 742 | } |
743 | } | 743 | } |
744 | 744 | ||
745 | 745 | ||
746 | if (found) QPEApplication::setKeepRunning(); | 746 | if (found) QPEApplication::setKeepRunning(); |
747 | else qDebug("Huh what do ya want"); | 747 | else qDebug("Huh what do ya want"); |
748 | } | 748 | } |
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 7d21605..3b2393c 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -191,1021 +191,1021 @@ void DialWidget::selectionChanged(int) | |||
191 | 191 | ||
192 | 192 | ||
193 | void DialWidget::addNumber() | 193 | void DialWidget::addNumber() |
194 | { | 194 | { |
195 | PhoneNumberDialog dlg(this); | 195 | PhoneNumberDialog dlg(this); |
196 | if(dlg.exec()) | 196 | if(dlg.exec()) |
197 | { | 197 | { |
198 | numbers->insertItem(dlg.phoneNumber()); | 198 | numbers->insertItem(dlg.phoneNumber()); |
199 | numbersChanged(); | 199 | numbersChanged(); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | void DialWidget::delNumber() | 204 | void DialWidget::delNumber() |
205 | { | 205 | { |
206 | if(numbers->currentItem() != -1) | 206 | if(numbers->currentItem() != -1) |
207 | { | 207 | { |
208 | numbers->removeItem(numbers->currentItem()); | 208 | numbers->removeItem(numbers->currentItem()); |
209 | numbersChanged(); | 209 | numbersChanged(); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | 213 | ||
214 | void DialWidget::upNumber() | 214 | void DialWidget::upNumber() |
215 | { | 215 | { |
216 | int idx = numbers->currentItem(); | 216 | int idx = numbers->currentItem(); |
217 | if(idx != -1) | 217 | if(idx != -1) |
218 | { | 218 | { |
219 | QString item = numbers->text(idx); | 219 | QString item = numbers->text(idx); |
220 | numbers->removeItem(idx); | 220 | numbers->removeItem(idx); |
221 | numbers->insertItem(item, idx-1); | 221 | numbers->insertItem(item, idx-1); |
222 | numbers->setCurrentItem(idx-1); | 222 | numbers->setCurrentItem(idx-1); |
223 | numbersChanged(); | 223 | numbersChanged(); |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | 227 | ||
228 | void DialWidget::downNumber() | 228 | void DialWidget::downNumber() |
229 | { | 229 | { |
230 | int idx = numbers->currentItem(); | 230 | int idx = numbers->currentItem(); |
231 | if(idx != -1) | 231 | if(idx != -1) |
232 | { | 232 | { |
233 | QString item = numbers->text(idx); | 233 | QString item = numbers->text(idx); |
234 | numbers->removeItem(idx); | 234 | numbers->removeItem(idx); |
235 | numbers->insertItem(item, idx+1); | 235 | numbers->insertItem(item, idx+1); |
236 | numbers->setCurrentItem(idx+1); | 236 | numbers->setCurrentItem(idx+1); |
237 | numbersChanged(); | 237 | numbersChanged(); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void DialWidget::pppdargsbutton() | 242 | void DialWidget::pppdargsbutton() |
243 | { | 243 | { |
244 | PPPdArguments pa(_pppdata, this); | 244 | PPPdArguments pa(_pppdata, this); |
245 | QPEApplication::execDialog( &pa ); | 245 | QPEApplication::execDialog( &pa ); |
246 | } | 246 | } |
247 | 247 | ||
248 | 248 | ||
249 | 249 | ||
250 | ///////////////////////////////////////////////////////////////////////////// | 250 | ///////////////////////////////////////////////////////////////////////////// |
251 | // ExecWidget | 251 | // ExecWidget |
252 | ///////////////////////////////////////////////////////////////////////////// | 252 | ///////////////////////////////////////////////////////////////////////////// |
253 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : | 253 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
254 | QWidget(parent, name), _pppdata(pd) | 254 | QWidget(parent, name), _pppdata(pd) |
255 | { | 255 | { |
256 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 256 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
257 | 257 | ||
258 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); | 258 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); |
259 | 259 | ||
260 | tl->addWidget(l); | 260 | tl->addWidget(l); |
261 | tl->addStretch(1); | 261 | tl->addStretch(1); |
262 | 262 | ||
263 | QGridLayout *l1 = new QGridLayout(4, 2, 10); | 263 | QGridLayout *l1 = new QGridLayout(4, 2, 10); |
264 | tl->addLayout(l1); | 264 | tl->addLayout(l1); |
265 | l1->setColStretch(0, 0); | 265 | l1->setColStretch(0, 0); |
266 | l1->setColStretch(1, 1); | 266 | l1->setColStretch(1, 1); |
267 | 267 | ||
268 | before_connect_l = new QLabel(tr("Before connect:"), this); | 268 | before_connect_l = new QLabel(tr("Before connect:"), this); |
269 | before_connect_l->setAlignment(AlignVCenter); | 269 | before_connect_l->setAlignment(AlignVCenter); |
270 | l1->addWidget(before_connect_l, 0, 0); | 270 | l1->addWidget(before_connect_l, 0, 0); |
271 | before_connect = new QLineEdit(this); | 271 | before_connect = new QLineEdit(this); |
272 | // before_connect->setMaxLength(COMMAND_SIZE); | 272 | // before_connect->setMaxLength(COMMAND_SIZE); |
273 | l1->addWidget(before_connect, 0, 1); | 273 | l1->addWidget(before_connect, 0, 1); |
274 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 274 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
275 | "is established. It is called immediately before\n" | 275 | "is established. It is called immediately before\n" |
276 | "dialing has begun.\n\n" | 276 | "dialing has begun.\n\n" |
277 | "This might be useful, e.g. to stop HylaFAX blocking the\n" | 277 | "This might be useful, e.g. to stop HylaFAX blocking the\n" |
278 | "modem."); | 278 | "modem."); |
279 | 279 | ||
280 | QWhatsThis::add(before_connect_l,tmp); | 280 | QWhatsThis::add(before_connect_l,tmp); |
281 | QWhatsThis::add(before_connect,tmp); | 281 | QWhatsThis::add(before_connect,tmp); |
282 | 282 | ||
283 | command_label = new QLabel(tr("Upon connect:"), this); | 283 | command_label = new QLabel(tr("Upon connect:"), this); |
284 | command_label->setAlignment(AlignVCenter); | 284 | command_label->setAlignment(AlignVCenter); |
285 | l1->addWidget(command_label, 1, 0); | 285 | l1->addWidget(command_label, 1, 0); |
286 | command = new QLineEdit(this); | 286 | command = new QLineEdit(this); |
287 | // command->setMaxLength(COMMAND_SIZE); | 287 | // command->setMaxLength(COMMAND_SIZE); |
288 | l1->addWidget(command, 1, 1); | 288 | l1->addWidget(command, 1, 1); |
289 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 289 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
290 | "is established. When your program is called, all\n" | 290 | "is established. When your program is called, all\n" |
291 | "preparations for an Internet connection are finished.\n" | 291 | "preparations for an Internet connection are finished.\n" |
292 | "\n" | 292 | "\n" |
293 | "Very useful for fetching mail and news"); | 293 | "Very useful for fetching mail and news"); |
294 | 294 | ||
295 | QWhatsThis::add(command_label,tmp); | 295 | QWhatsThis::add(command_label,tmp); |
296 | QWhatsThis::add(command,tmp); | 296 | QWhatsThis::add(command,tmp); |
297 | 297 | ||
298 | predisconnect_label = new QLabel(tr("Before disconnect:"), | 298 | predisconnect_label = new QLabel(tr("Before disconnect:"), |
299 | this); | 299 | this); |
300 | predisconnect_label->setAlignment(AlignVCenter); | 300 | predisconnect_label->setAlignment(AlignVCenter); |
301 | l1->addWidget(predisconnect_label, 2, 0); | 301 | l1->addWidget(predisconnect_label, 2, 0); |
302 | predisconnect = new QLineEdit(this); | 302 | predisconnect = new QLineEdit(this); |
303 | // predisconnect->setMaxLength(COMMAND_SIZE); | 303 | // predisconnect->setMaxLength(COMMAND_SIZE); |
304 | l1->addWidget(predisconnect, 2, 1); | 304 | l1->addWidget(predisconnect, 2, 1); |
305 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 305 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
306 | "is closed. The connection will stay open until\n" | 306 | "is closed. The connection will stay open until\n" |
307 | "the program exits."); | 307 | "the program exits."); |
308 | 308 | ||
309 | QWhatsThis::add(predisconnect_label,tmp); | 309 | QWhatsThis::add(predisconnect_label,tmp); |
310 | QWhatsThis::add(predisconnect,tmp); | 310 | QWhatsThis::add(predisconnect,tmp); |
311 | 311 | ||
312 | discommand_label = new QLabel(tr("Upon disconnect:"), | 312 | discommand_label = new QLabel(tr("Upon disconnect:"), |
313 | this); | 313 | this); |
314 | discommand_label->setAlignment(AlignVCenter); | 314 | discommand_label->setAlignment(AlignVCenter); |
315 | l1->addWidget(discommand_label, 3, 0); | 315 | l1->addWidget(discommand_label, 3, 0); |
316 | 316 | ||
317 | discommand = new QLineEdit(this); | 317 | discommand = new QLineEdit(this); |
318 | // discommand->setMaxLength(COMMAND_SIZE); | 318 | // discommand->setMaxLength(COMMAND_SIZE); |
319 | l1->addWidget(discommand, 3, 1); | 319 | l1->addWidget(discommand, 3, 1); |
320 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 320 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
321 | "has been closed."); | 321 | "has been closed."); |
322 | 322 | ||
323 | QWhatsThis::add(discommand_label,tmp); | 323 | QWhatsThis::add(discommand_label,tmp); |
324 | QWhatsThis::add(discommand,tmp); | 324 | QWhatsThis::add(discommand,tmp); |
325 | 325 | ||
326 | // extra space between entries | 326 | // extra space between entries |
327 | l1->addRowSpacing(1, 5); | 327 | l1->addRowSpacing(1, 5); |
328 | l1->addRowSpacing(3, 5); | 328 | l1->addRowSpacing(3, 5); |
329 | 329 | ||
330 | tl->addStretch(1); | 330 | tl->addStretch(1); |
331 | tl->activate(); | 331 | tl->activate(); |
332 | 332 | ||
333 | // Set defaults if editing an existing connection | 333 | // Set defaults if editing an existing connection |
334 | if(!isnewaccount) | 334 | if(!isnewaccount) |
335 | { | 335 | { |
336 | before_connect->setText(_pppdata->command_before_connect()); | 336 | before_connect->setText(_pppdata->command_before_connect()); |
337 | command->setText(_pppdata->command_on_connect()); | 337 | command->setText(_pppdata->command_on_connect()); |
338 | discommand->setText(_pppdata->command_on_disconnect()); | 338 | discommand->setText(_pppdata->command_on_disconnect()); |
339 | predisconnect->setText(_pppdata->command_before_disconnect()); | 339 | predisconnect->setText(_pppdata->command_before_disconnect()); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | bool ExecWidget::save() | 344 | bool ExecWidget::save() |
345 | { | 345 | { |
346 | _pppdata->setCommand_before_connect(before_connect->text()); | 346 | _pppdata->setCommand_before_connect(before_connect->text()); |
347 | _pppdata->setCommand_on_connect(command->text()); | 347 | _pppdata->setCommand_on_connect(command->text()); |
348 | _pppdata->setCommand_before_disconnect(predisconnect->text()); | 348 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
349 | _pppdata->setCommand_on_disconnect(discommand->text()); | 349 | _pppdata->setCommand_on_disconnect(discommand->text()); |
350 | return true; | 350 | return true; |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | 354 | ||
355 | ///////////////////////////////////////////////////////////////////////////// | 355 | ///////////////////////////////////////////////////////////////////////////// |
356 | // | 356 | // |
357 | // IPWidget | 357 | // IPWidget |
358 | // | 358 | // |
359 | ///////////////////////////////////////////////////////////////////////////// | 359 | ///////////////////////////////////////////////////////////////////////////// |
360 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 360 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
361 | : QWidget(parent, name), _pppdata(pd) | 361 | : QWidget(parent, name), _pppdata(pd) |
362 | { | 362 | { |
363 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 363 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
364 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | 364 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); |
365 | 365 | ||
366 | box = new QVGroupBox(tr("Configuration"), this); | 366 | box = new QVGroupBox(tr("Configuration"), this); |
367 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | 367 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); |
368 | 368 | ||
369 | rb = new QButtonGroup(this); | 369 | rb = new QButtonGroup(this); |
370 | rb->hide(); | 370 | rb->hide(); |
371 | connect(rb, SIGNAL(clicked(int)), | 371 | connect(rb, SIGNAL(clicked(int)), |
372 | SLOT(hitIPSelect(int))); | 372 | SLOT(hitIPSelect(int))); |
373 | 373 | ||
374 | dynamicadd_rb = new QRadioButton(box); | 374 | dynamicadd_rb = new QRadioButton(box); |
375 | dynamicadd_rb->setText(tr("Dynamic IP address")); | 375 | dynamicadd_rb->setText(tr("Dynamic IP address")); |
376 | QWhatsThis::add(dynamicadd_rb, | 376 | QWhatsThis::add(dynamicadd_rb, |
377 | tr("Select this option when your computer gets an\n" | 377 | tr("Select this option when your computer gets an\n" |
378 | "internet address (IP) every time a\n" | 378 | "internet address (IP) every time a\n" |
379 | "connection is made.\n" | 379 | "connection is made.\n" |
380 | "\n" | 380 | "\n" |
381 | "Almost every Internet Service Provider uses\n" | 381 | "Almost every Internet Service Provider uses\n" |
382 | "this method, so this should be turned on.")); | 382 | "this method, so this should be turned on.")); |
383 | 383 | ||
384 | staticadd_rb = new QRadioButton(box); | 384 | staticadd_rb = new QRadioButton(box); |
385 | staticadd_rb->setText(tr("Static IP address")); | 385 | staticadd_rb->setText(tr("Static IP address")); |
386 | rb->insert(dynamicadd_rb, 0); | 386 | rb->insert(dynamicadd_rb, 0); |
387 | rb->insert(staticadd_rb, 1); | 387 | rb->insert(staticadd_rb, 1); |
388 | QWhatsThis::add(staticadd_rb, | 388 | QWhatsThis::add(staticadd_rb, |
389 | tr("Select this option when your computer has a\n" | 389 | tr("Select this option when your computer has a\n" |
390 | "fixed internet address (IP). Most computers\n" | 390 | "fixed internet address (IP). Most computers\n" |
391 | "don't have this, so you should probably select\n" | 391 | "don't have this, so you should probably select\n" |
392 | "dynamic IP addressing unless you know what you\n" | 392 | "dynamic IP addressing unless you know what you\n" |
393 | "are doing.")); | 393 | "are doing.")); |
394 | 394 | ||
395 | QWidget *ipWidget = new QWidget(box); | 395 | QWidget *ipWidget = new QWidget(box); |
396 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); | 396 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); |
397 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); | 397 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); |
398 | 398 | ||
399 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); | 399 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); |
400 | QString tmp = tr("If your computer has a permanent internet\n" | 400 | QString tmp = tr("If your computer has a permanent internet\n" |
401 | "address, you must supply your IP address here."); | 401 | "address, you must supply your IP address here."); |
402 | ipLayout->addWidget(ipaddress_label, 0, 0); | 402 | ipLayout->addWidget(ipaddress_label, 0, 0); |
403 | 403 | ||
404 | ipaddress_l = new IPLineEdit(ipWidget); | 404 | ipaddress_l = new IPLineEdit(ipWidget); |
405 | ipLayout->addWidget(ipaddress_l, 0, 1); | 405 | ipLayout->addWidget(ipaddress_l, 0, 1); |
406 | 406 | ||
407 | QWhatsThis::add(ipaddress_label,tmp); | 407 | QWhatsThis::add(ipaddress_label,tmp); |
408 | QWhatsThis::add(ipaddress_l,tmp); | 408 | QWhatsThis::add(ipaddress_l,tmp); |
409 | 409 | ||
410 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); | 410 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); |
411 | tmp = tr("<p>If your computer has a static Internet address,\n" | 411 | tmp = tr("<p>If your computer has a static Internet address,\n" |
412 | "you must supply a network mask here. In almost\n" | 412 | "you must supply a network mask here. In almost\n" |
413 | "all cases this netmask will be <b>255.255.255.0</b>,\n" | 413 | "all cases this netmask will be <b>255.255.255.0</b>,\n" |
414 | "but your mileage may vary.\n" | 414 | "but your mileage may vary.\n" |
415 | "\n" | 415 | "\n" |
416 | "If unsure, contact your Internet Service Provider"); | 416 | "If unsure, contact your Internet Service Provider"); |
417 | ipLayout->addWidget(sub_label, 1, 0); | 417 | ipLayout->addWidget(sub_label, 1, 0); |
418 | 418 | ||
419 | subnetmask_l = new IPLineEdit(ipWidget); | 419 | subnetmask_l = new IPLineEdit(ipWidget); |
420 | ipLayout->addWidget(subnetmask_l, 1, 1); | 420 | ipLayout->addWidget(subnetmask_l, 1, 1); |
421 | 421 | ||
422 | QWhatsThis::add(sub_label,tmp); | 422 | QWhatsThis::add(sub_label,tmp); |
423 | QWhatsThis::add(subnetmask_l,tmp); | 423 | QWhatsThis::add(subnetmask_l,tmp); |
424 | 424 | ||
425 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); | 425 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); |
426 | autoname->setChecked(_pppdata->autoname()); | 426 | autoname->setChecked(_pppdata->autoname()); |
427 | connect(autoname,SIGNAL(toggled(bool)), | 427 | connect(autoname,SIGNAL(toggled(bool)), |
428 | this,SLOT(autoname_t(bool))); | 428 | this,SLOT(autoname_t(bool))); |
429 | 429 | ||
430 | QWhatsThis::add(autoname, | 430 | QWhatsThis::add(autoname, |
431 | tr("<p>Whenever you connect, this reconfigures\n" | 431 | tr("<p>Whenever you connect, this reconfigures\n" |
432 | "your hostname to match the IP address you\n" | 432 | "your hostname to match the IP address you\n" |
433 | "got from the PPP server. This may be useful\n" | 433 | "got from the PPP server. This may be useful\n" |
434 | "if you need to use a protocol which depends\n" | 434 | "if you need to use a protocol which depends\n" |
435 | "on this information, but it can also cause several\n" | 435 | "on this information, but it can also cause several\n" |
436 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 436 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
437 | "\n" | 437 | "\n" |
438 | "Don't enable this unless you really need it.")); | 438 | "Don't enable this unless you really need it.")); |
439 | 439 | ||
440 | topLayout->addWidget(box); | 440 | topLayout->addWidget(box); |
441 | topLayout->addWidget(autoname); | 441 | topLayout->addWidget(autoname); |
442 | topLayout->addStretch(); | 442 | topLayout->addStretch(); |
443 | 443 | ||
444 | //load info from gpppdata | 444 | //load info from gpppdata |
445 | if(!isnewaccount) | 445 | if(!isnewaccount) |
446 | { | 446 | { |
447 | if(_pppdata->ipaddr() == "0.0.0.0" && | 447 | if(_pppdata->ipaddr() == "0.0.0.0" && |
448 | _pppdata->subnetmask() == "0.0.0.0") | 448 | _pppdata->subnetmask() == "0.0.0.0") |
449 | { | 449 | { |
450 | dynamicadd_rb->setChecked(true); | 450 | dynamicadd_rb->setChecked(true); |
451 | hitIPSelect(0); | 451 | hitIPSelect(0); |
452 | autoname->setChecked(_pppdata->autoname()); | 452 | autoname->setChecked(_pppdata->autoname()); |
453 | } | 453 | } |
454 | else | 454 | else |
455 | { | 455 | { |
456 | ipaddress_l->setText(_pppdata->ipaddr()); | 456 | ipaddress_l->setText(_pppdata->ipaddr()); |
457 | subnetmask_l->setText(_pppdata->subnetmask()); | 457 | subnetmask_l->setText(_pppdata->subnetmask()); |
458 | staticadd_rb->setChecked(true); | 458 | staticadd_rb->setChecked(true); |
459 | autoname->setChecked(false); | 459 | autoname->setChecked(false); |
460 | } | 460 | } |
461 | } | 461 | } |
462 | else | 462 | else |
463 | { | 463 | { |
464 | dynamicadd_rb->setChecked(true); | 464 | dynamicadd_rb->setChecked(true); |
465 | hitIPSelect(0); | 465 | hitIPSelect(0); |
466 | } | 466 | } |
467 | 467 | ||
468 | } | 468 | } |
469 | 469 | ||
470 | void IPWidget::autoname_t(bool on) | 470 | void IPWidget::autoname_t(bool on) |
471 | { | 471 | { |
472 | static bool was_warned = false; | 472 | static bool was_warned = false; |
473 | 473 | ||
474 | // big-fat warning when selecting the auto configure hostname option | 474 | // big-fat warning when selecting the auto configure hostname option |
475 | if(on && !was_warned) | 475 | if(on && !was_warned) |
476 | { | 476 | { |
477 | QMessageBox::information(this, | 477 | QMessageBox::information(this, |
478 | tr("Selecting this option might cause some weird " | 478 | tr("Selecting this option might cause some weird " |
479 | "problems with the X-server and applications " | 479 | "problems with the X-server and applications " |
480 | "while kppp is connected. Don't use it until " | 480 | "while kppp is connected. Don't use it until " |
481 | "you know what you are doing!\n" | 481 | "you know what you are doing!\n" |
482 | "For more information take a look at the " | 482 | "For more information take a look at the " |
483 | "handbook (or help) in the section \"Frequently " | 483 | "handbook (or help) in the section \"Frequently " |
484 | "asked questions\"."), | 484 | "asked questions\"."), |
485 | tr("Warning")); | 485 | tr("Warning")); |
486 | was_warned = true; | 486 | was_warned = true; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | 489 | ||
490 | 490 | ||
491 | void IPWidget::save() | 491 | void IPWidget::save() |
492 | { | 492 | { |
493 | if(dynamicadd_rb->isChecked()) | 493 | if(dynamicadd_rb->isChecked()) |
494 | { | 494 | { |
495 | _pppdata->setIpaddr("0.0.0.0"); | 495 | _pppdata->setIpaddr("0.0.0.0"); |
496 | _pppdata->setSubnetmask("0.0.0.0"); | 496 | _pppdata->setSubnetmask("0.0.0.0"); |
497 | } | 497 | } |
498 | else | 498 | else |
499 | { | 499 | { |
500 | _pppdata->setIpaddr(ipaddress_l->text()); | 500 | _pppdata->setIpaddr(ipaddress_l->text()); |
501 | _pppdata->setSubnetmask(subnetmask_l->text()); | 501 | _pppdata->setSubnetmask(subnetmask_l->text()); |
502 | } | 502 | } |
503 | _pppdata->setAutoname(autoname->isChecked()); | 503 | _pppdata->setAutoname(autoname->isChecked()); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | void IPWidget::hitIPSelect( int i ) | 507 | void IPWidget::hitIPSelect( int i ) |
508 | { | 508 | { |
509 | if(i == 0) | 509 | if(i == 0) |
510 | { | 510 | { |
511 | ipaddress_label->setEnabled(false); | 511 | ipaddress_label->setEnabled(false); |
512 | sub_label->setEnabled(false); | 512 | sub_label->setEnabled(false); |
513 | ipaddress_l->setEnabled(false); | 513 | ipaddress_l->setEnabled(false); |
514 | subnetmask_l->setEnabled(false); | 514 | subnetmask_l->setEnabled(false); |
515 | } | 515 | } |
516 | else | 516 | else |
517 | { | 517 | { |
518 | ipaddress_label->setEnabled(true); | 518 | ipaddress_label->setEnabled(true); |
519 | sub_label->setEnabled(true); | 519 | sub_label->setEnabled(true); |
520 | ipaddress_l->setEnabled(true); | 520 | ipaddress_l->setEnabled(true); |
521 | subnetmask_l->setEnabled(true); | 521 | subnetmask_l->setEnabled(true); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | 525 | ||
526 | 526 | ||
527 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 527 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
528 | : QWidget(parent, name), _pppdata(pd) | 528 | : QWidget(parent, name), _pppdata(pd) |
529 | { | 529 | { |
530 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); | 530 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); |
531 | 531 | ||
532 | dnsdomain_label = new QLabel(tr("Domain name:"), this); | 532 | dnsdomain_label = new QLabel(tr("Domain name:"), this); |
533 | tl->addWidget(dnsdomain_label, 0, 0); | 533 | tl->addWidget(dnsdomain_label, 0, 0); |
534 | 534 | ||
535 | dnsdomain = new QLineEdit(this); | 535 | dnsdomain = new QLineEdit(this); |
536 | 536 | ||
537 | tl->addWidget(dnsdomain, 0, 1); | 537 | tl->addWidget(dnsdomain, 0, 1); |
538 | QString tmp = tr("If you enter a domain name here, this domain\n" | 538 | QString tmp = tr("If you enter a domain name here, this domain\n" |
539 | "name is used for your computer while you are\n" | 539 | "name is used for your computer while you are\n" |
540 | "connected. When the connection is closed, the\n" | 540 | "connected. When the connection is closed, the\n" |
541 | "original domain name of your computer is\n" | 541 | "original domain name of your computer is\n" |
542 | "restored.\n" | 542 | "restored.\n" |
543 | "\n" | 543 | "\n" |
544 | "If you leave this field blank, no changes are\n" | 544 | "If you leave this field blank, no changes are\n" |
545 | "made to the domain name."); | 545 | "made to the domain name."); |
546 | 546 | ||
547 | QWhatsThis::add(dnsdomain_label,tmp); | 547 | QWhatsThis::add(dnsdomain_label,tmp); |
548 | QWhatsThis::add(dnsdomain,tmp); | 548 | QWhatsThis::add(dnsdomain,tmp); |
549 | 549 | ||
550 | conf_label = new QLabel(tr("Configuration:"), this); | 550 | conf_label = new QLabel(tr("Configuration:"), this); |
551 | tl->addWidget(conf_label, 1, 0); | 551 | tl->addWidget(conf_label, 1, 0); |
552 | 552 | ||
553 | bg = new QButtonGroup("Group", this); | 553 | bg = new QButtonGroup("Group", this); |
554 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 554 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
555 | bg->hide(); | 555 | bg->hide(); |
556 | 556 | ||
557 | autodns = new QRadioButton(tr("Automatic"), this); | 557 | autodns = new QRadioButton(tr("Automatic"), this); |
558 | bg->insert(autodns, 0); | 558 | bg->insert(autodns, 0); |
559 | tl->addWidget(autodns, 1, 1); | 559 | tl->addWidget(autodns, 1, 1); |
560 | if(!_pppdata->pppdVersionMin(2, 3, 7)) | 560 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
561 | autodns->setEnabled(false); | 561 | autodns->setEnabled(false); |
562 | 562 | ||
563 | mandns = new QRadioButton(tr("Manual"), this); | 563 | mandns = new QRadioButton(tr("Manual"), this); |
564 | bg->insert(mandns, 1); | 564 | bg->insert(mandns, 1); |
565 | tl->addWidget(mandns, 2, 1); | 565 | tl->addWidget(mandns, 2, 1); |
566 | 566 | ||
567 | dns_label = new QLabel(tr("DNS IP address:"), this); | 567 | dns_label = new QLabel(tr("DNS IP address:"), this); |
568 | tl->addWidget(dns_label, 3, 0); | 568 | tl->addWidget(dns_label, 3, 0); |
569 | 569 | ||
570 | QHBoxLayout *l2 = new QHBoxLayout; | 570 | QHBoxLayout *l2 = new QHBoxLayout; |
571 | tl->addLayout(l2, 3, 1); | 571 | tl->addLayout(l2, 3, 1); |
572 | dnsipaddr = new IPLineEdit(this); | 572 | dnsipaddr = new IPLineEdit(this); |
573 | connect(dnsipaddr, SIGNAL(returnPressed()), | 573 | connect(dnsipaddr, SIGNAL(returnPressed()), |
574 | SLOT(adddns())); | 574 | SLOT(adddns())); |
575 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), | 575 | connect(dnsipaddr, SIGNAL(textChanged(const QString&)), |
576 | SLOT(DNS_Edit_Changed(const QString &))); | 576 | SLOT(DNS_Edit_Changed(const QString&))); |
577 | l2->addWidget(dnsipaddr, 1); | 577 | l2->addWidget(dnsipaddr, 1); |
578 | l2->addStretch(1); | 578 | l2->addStretch(1); |
579 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" | 579 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" |
580 | "used while you are connected. When the\n" | 580 | "used while you are connected. When the\n" |
581 | "connection is closed, this DNS entry will be\n" | 581 | "connection is closed, this DNS entry will be\n" |
582 | "removed again.\n" | 582 | "removed again.\n" |
583 | "\n" | 583 | "\n" |
584 | "To add a DNS server, type in the IP address of\n" | 584 | "To add a DNS server, type in the IP address of\n" |
585 | "the DNS server here and click on <b>Add</b>"); | 585 | "the DNS server here and click on <b>Add</b>"); |
586 | 586 | ||
587 | QWhatsThis::add(dns_label, tmp); | 587 | QWhatsThis::add(dns_label, tmp); |
588 | QWhatsThis::add(dnsipaddr, tmp); | 588 | QWhatsThis::add(dnsipaddr, tmp); |
589 | 589 | ||
590 | QHBoxLayout *l1 = new QHBoxLayout; | 590 | QHBoxLayout *l1 = new QHBoxLayout; |
591 | tl->addLayout(l1, 4, 1); | 591 | tl->addLayout(l1, 4, 1); |
592 | add = new QPushButton(tr("Add"), this); | 592 | add = new QPushButton(tr("Add"), this); |
593 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | 593 | connect(add, SIGNAL(clicked()), SLOT(adddns())); |
594 | l1->addWidget(add); | 594 | l1->addWidget(add); |
595 | // l1->addStretch(1); | 595 | // l1->addStretch(1); |
596 | QWhatsThis::add(add, | 596 | QWhatsThis::add(add, |
597 | tr("Click this button to add the DNS server\n" | 597 | tr("Click this button to add the DNS server\n" |
598 | "specified in the field above. The entry\n" | 598 | "specified in the field above. The entry\n" |
599 | "will then be added to the list below")); | 599 | "will then be added to the list below")); |
600 | 600 | ||
601 | remove = new QPushButton(tr("Remove"), this); | 601 | remove = new QPushButton(tr("Remove"), this); |
602 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | 602 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); |
603 | l1->addWidget(remove); | 603 | l1->addWidget(remove); |
604 | QWhatsThis::add(remove, | 604 | QWhatsThis::add(remove, |
605 | tr("Click this button to remove the selected DNS\n" | 605 | tr("Click this button to remove the selected DNS\n" |
606 | "server entry from the list below")); | 606 | "server entry from the list below")); |
607 | 607 | ||
608 | servers_label = new QLabel(tr("DNS address list:"), this); | 608 | servers_label = new QLabel(tr("DNS address list:"), this); |
609 | servers_label->setAlignment(AlignTop|AlignLeft); | 609 | servers_label->setAlignment(AlignTop|AlignLeft); |
610 | tl->addWidget(servers_label, 5, 0); | 610 | tl->addWidget(servers_label, 5, 0); |
611 | 611 | ||
612 | dnsservers = new QListBox(this); | 612 | dnsservers = new QListBox(this); |
613 | dnsservers->setMinimumSize(150, 80); | 613 | dnsservers->setMinimumSize(150, 80); |
614 | connect(dnsservers, SIGNAL(highlighted(int)), | 614 | connect(dnsservers, SIGNAL(highlighted(int)), |
615 | SLOT(DNS_Entry_Selected(int))); | 615 | SLOT(DNS_Entry_Selected(int))); |
616 | tl->addWidget(dnsservers, 5, 1); | 616 | tl->addWidget(dnsservers, 5, 1); |
617 | tmp = tr("<p>This shows all defined DNS servers to use\n" | 617 | tmp = tr("<p>This shows all defined DNS servers to use\n" |
618 | "while you are connected. Use the <b>Add</b> and\n" | 618 | "while you are connected. Use the <b>Add</b> and\n" |
619 | "<b>Remove</b> buttons to modify the list"); | 619 | "<b>Remove</b> buttons to modify the list"); |
620 | 620 | ||
621 | QWhatsThis::add(servers_label,tmp); | 621 | QWhatsThis::add(servers_label,tmp); |
622 | QWhatsThis::add(dnsservers,tmp); | 622 | QWhatsThis::add(dnsservers,tmp); |
623 | 623 | ||
624 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); | 624 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); |
625 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); | 625 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); |
626 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); | 626 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
627 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 627 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
628 | QWhatsThis::add(exdnsdisabled_toggle, | 628 | QWhatsThis::add(exdnsdisabled_toggle, |
629 | tr("<p>When this option is selected, all DNS\n" | 629 | tr("<p>When this option is selected, all DNS\n" |
630 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 630 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
631 | "temporary disabled while the dialup connection\n" | 631 | "temporary disabled while the dialup connection\n" |
632 | "is established. After the connection is\n" | 632 | "is established. After the connection is\n" |
633 | "closed, the servers will be re-enabled\n" | 633 | "closed, the servers will be re-enabled\n" |
634 | "\n" | 634 | "\n" |
635 | "Typically, there is no reason to use this\n" | 635 | "Typically, there is no reason to use this\n" |
636 | "option, but it may become useful under \n" | 636 | "option, but it may become useful under \n" |
637 | "some circumstances.")); | 637 | "some circumstances.")); |
638 | 638 | ||
639 | 639 | ||
640 | // restore data if editing | 640 | // restore data if editing |
641 | if(!isnewaccount) | 641 | if(!isnewaccount) |
642 | { | 642 | { |
643 | dnsservers->insertStringList(_pppdata->dns()); | 643 | dnsservers->insertStringList(_pppdata->dns()); |
644 | dnsdomain->setText(_pppdata->domain()); | 644 | dnsdomain->setText(_pppdata->domain()); |
645 | } | 645 | } |
646 | 646 | ||
647 | int mode = _pppdata->autoDNS() ? 0 : 1; | 647 | int mode = _pppdata->autoDNS() ? 0 : 1; |
648 | bg->setButton(mode); | 648 | bg->setButton(mode); |
649 | DNS_Mode_Selected(mode); | 649 | DNS_Mode_Selected(mode); |
650 | 650 | ||
651 | tl->activate(); | 651 | tl->activate(); |
652 | } | 652 | } |
653 | 653 | ||
654 | void DNSWidget::DNS_Edit_Changed(const QString &text) | 654 | void DNSWidget::DNS_Edit_Changed(const QString &text) |
655 | { | 655 | { |
656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
657 | add->setEnabled(text.find(r) != -1); | 657 | add->setEnabled(text.find(r) != -1); |
658 | } | 658 | } |
659 | 659 | ||
660 | void DNSWidget::DNS_Entry_Selected(int) | 660 | void DNSWidget::DNS_Entry_Selected(int) |
661 | { | 661 | { |
662 | remove->setEnabled(true); | 662 | remove->setEnabled(true); |
663 | } | 663 | } |
664 | 664 | ||
665 | void DNSWidget::DNS_Mode_Selected(int mode) | 665 | void DNSWidget::DNS_Mode_Selected(int mode) |
666 | { | 666 | { |
667 | bool on = (mode == 1); | 667 | bool on = (mode == 1); |
668 | dns_label->setEnabled(on); | 668 | dns_label->setEnabled(on); |
669 | servers_label->setEnabled(on); | 669 | servers_label->setEnabled(on); |
670 | dnsipaddr->setText(""); | 670 | dnsipaddr->setText(""); |
671 | dnsipaddr->setEnabled(on); | 671 | dnsipaddr->setEnabled(on); |
672 | add->setEnabled(false); | 672 | add->setEnabled(false); |
673 | remove->setEnabled(dnsservers->count()>0 && on); | 673 | remove->setEnabled(dnsservers->count()>0 && on); |
674 | dnsservers->clearSelection(); | 674 | dnsservers->clearSelection(); |
675 | dnsservers->setEnabled(on); | 675 | dnsservers->setEnabled(on); |
676 | dnsservers->triggerUpdate(false); | 676 | dnsservers->triggerUpdate(false); |
677 | } | 677 | } |
678 | 678 | ||
679 | void DNSWidget::save() | 679 | void DNSWidget::save() |
680 | { | 680 | { |
681 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); | 681 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
682 | QStringList serverlist; | 682 | QStringList serverlist; |
683 | for(uint i=0; i < dnsservers->count(); i++) | 683 | for(uint i=0; i < dnsservers->count(); i++) |
684 | serverlist.append(dnsservers->text(i)); | 684 | serverlist.append(dnsservers->text(i)); |
685 | _pppdata->setDns(serverlist); | 685 | _pppdata->setDns(serverlist); |
686 | 686 | ||
687 | // strip leading dot | 687 | // strip leading dot |
688 | QString s(dnsdomain->text()); | 688 | QString s(dnsdomain->text()); |
689 | if(s.left(1) == ".") | 689 | if(s.left(1) == ".") |
690 | _pppdata->setDomain(s.mid(1)); | 690 | _pppdata->setDomain(s.mid(1)); |
691 | else | 691 | else |
692 | _pppdata->setDomain(dnsdomain->text()); | 692 | _pppdata->setDomain(dnsdomain->text()); |
693 | 693 | ||
694 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 694 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); |
695 | } | 695 | } |
696 | 696 | ||
697 | 697 | ||
698 | void DNSWidget::adddns() | 698 | void DNSWidget::adddns() |
699 | { | 699 | { |
700 | if(dnsservers->count() < MAX_DNS_ENTRIES) | 700 | if(dnsservers->count() < MAX_DNS_ENTRIES) |
701 | { | 701 | { |
702 | dnsservers->insertItem(dnsipaddr->text()); | 702 | dnsservers->insertItem(dnsipaddr->text()); |
703 | dnsipaddr->setText(""); | 703 | dnsipaddr->setText(""); |
704 | } | 704 | } |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void DNSWidget::removedns() | 708 | void DNSWidget::removedns() |
709 | { | 709 | { |
710 | int i; | 710 | int i; |
711 | i = dnsservers->currentItem(); | 711 | i = dnsservers->currentItem(); |
712 | if(i != -1) | 712 | if(i != -1) |
713 | dnsservers->removeItem(i); | 713 | dnsservers->removeItem(i); |
714 | remove->setEnabled(dnsservers->count()>0); | 714 | remove->setEnabled(dnsservers->count()>0); |
715 | } | 715 | } |
716 | 716 | ||
717 | 717 | ||
718 | // | 718 | // |
719 | // GatewayWidget | 719 | // GatewayWidget |
720 | // | 720 | // |
721 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 721 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
722 | : QWidget(parent, name), _pppdata(pd) | 722 | : QWidget(parent, name), _pppdata(pd) |
723 | { | 723 | { |
724 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 724 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
725 | topLayout->setSpacing( 2 ); | 725 | topLayout->setSpacing( 2 ); |
726 | topLayout->setMargin( 0 ); | 726 | topLayout->setMargin( 0 ); |
727 | 727 | ||
728 | box = new QVGroupBox(tr("Configuration"), this); | 728 | box = new QVGroupBox(tr("Configuration"), this); |
729 | 729 | ||
730 | rb = new QButtonGroup(this); | 730 | rb = new QButtonGroup(this); |
731 | rb->hide(); | 731 | rb->hide(); |
732 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | 732 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); |
733 | 733 | ||
734 | defaultgateway = new QRadioButton(box); | 734 | defaultgateway = new QRadioButton(box); |
735 | defaultgateway->setText(tr("Default gateway")); | 735 | defaultgateway->setText(tr("Default gateway")); |
736 | rb->insert(defaultgateway, 0); | 736 | rb->insert(defaultgateway, 0); |
737 | QWhatsThis::add(defaultgateway, | 737 | QWhatsThis::add(defaultgateway, |
738 | tr("This makes the PPP peer computer (the computer\n" | 738 | tr("This makes the PPP peer computer (the computer\n" |
739 | "you are connected to with your modem) to act as\n" | 739 | "you are connected to with your modem) to act as\n" |
740 | "a gateway. Your computer will send all packets not\n" | 740 | "a gateway. Your computer will send all packets not\n" |
741 | "going to a computer inside your local net to this\n" | 741 | "going to a computer inside your local net to this\n" |
742 | "computer, which will route these packets.\n" | 742 | "computer, which will route these packets.\n" |
743 | "\n" | 743 | "\n" |
744 | "This is the default for most ISPs, so you should\n" | 744 | "This is the default for most ISPs, so you should\n" |
745 | "probably leave this option on.")); | 745 | "probably leave this option on.")); |
746 | 746 | ||
747 | 747 | ||
748 | staticgateway = new QRadioButton(box); | 748 | staticgateway = new QRadioButton(box); |
749 | staticgateway->setText(tr("Static gateway")); | 749 | staticgateway->setText(tr("Static gateway")); |
750 | rb->insert(staticgateway, 1); | 750 | rb->insert(staticgateway, 1); |
751 | QWhatsThis::add(staticgateway, | 751 | QWhatsThis::add(staticgateway, |
752 | tr("<p>Allows you to specify which computer you want\n" | 752 | tr("<p>Allows you to specify which computer you want\n" |
753 | "to use as gateway (see <i>Default Gateway</i> above)")); | 753 | "to use as gateway (see <i>Default Gateway</i> above)")); |
754 | 754 | ||
755 | QHBox *gateBox = new QHBox(box); | 755 | QHBox *gateBox = new QHBox(box); |
756 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); | 756 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); |
757 | gatewayaddr = new IPLineEdit(gateBox); | 757 | gatewayaddr = new IPLineEdit(gateBox); |
758 | 758 | ||
759 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), | 759 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), |
760 | this); | 760 | this); |
761 | QWhatsThis::add(defaultroute, | 761 | QWhatsThis::add(defaultroute, |
762 | tr("If this option is enabled, all packets not\n" | 762 | tr("If this option is enabled, all packets not\n" |
763 | "going to the local net are routed through\n" | 763 | "going to the local net are routed through\n" |
764 | "the PPP connection.\n" | 764 | "the PPP connection.\n" |
765 | "\n" | 765 | "\n" |
766 | "Normally, you should turn this on")); | 766 | "Normally, you should turn this on")); |
767 | 767 | ||
768 | topLayout->addWidget(box); | 768 | topLayout->addWidget(box); |
769 | topLayout->addWidget(defaultroute); | 769 | topLayout->addWidget(defaultroute); |
770 | topLayout->addStretch(); | 770 | topLayout->addStretch(); |
771 | 771 | ||
772 | //load info from gpppdata | 772 | //load info from gpppdata |
773 | if(!isnewaccount) | 773 | if(!isnewaccount) |
774 | { | 774 | { |
775 | if(_pppdata->gateway() == "0.0.0.0") | 775 | if(_pppdata->gateway() == "0.0.0.0") |
776 | { | 776 | { |
777 | defaultgateway->setChecked(true); | 777 | defaultgateway->setChecked(true); |
778 | hitGatewaySelect(0); | 778 | hitGatewaySelect(0); |
779 | } | 779 | } |
780 | else | 780 | else |
781 | { | 781 | { |
782 | gatewayaddr->setText(_pppdata->gateway()); | 782 | gatewayaddr->setText(_pppdata->gateway()); |
783 | staticgateway->setChecked(true); | 783 | staticgateway->setChecked(true); |
784 | } | 784 | } |
785 | defaultroute->setChecked(_pppdata->defaultroute()); | 785 | defaultroute->setChecked(_pppdata->defaultroute()); |
786 | } | 786 | } |
787 | else | 787 | else |
788 | { | 788 | { |
789 | defaultgateway->setChecked(true); | 789 | defaultgateway->setChecked(true); |
790 | hitGatewaySelect(0); | 790 | hitGatewaySelect(0); |
791 | defaultroute->setChecked(true); | 791 | defaultroute->setChecked(true); |
792 | } | 792 | } |
793 | } | 793 | } |
794 | 794 | ||
795 | void GatewayWidget::save() | 795 | void GatewayWidget::save() |
796 | { | 796 | { |
797 | _pppdata->setGateway(gatewayaddr->text()); | 797 | _pppdata->setGateway(gatewayaddr->text()); |
798 | _pppdata->setDefaultroute(defaultroute->isChecked()); | 798 | _pppdata->setDefaultroute(defaultroute->isChecked()); |
799 | } | 799 | } |
800 | 800 | ||
801 | 801 | ||
802 | void GatewayWidget::hitGatewaySelect( int i ) | 802 | void GatewayWidget::hitGatewaySelect( int i ) |
803 | { | 803 | { |
804 | if(i == 0) | 804 | if(i == 0) |
805 | { | 805 | { |
806 | gatewayaddr->setText("0.0.0.0"); | 806 | gatewayaddr->setText("0.0.0.0"); |
807 | gatewayaddr->setEnabled(false); | 807 | gatewayaddr->setEnabled(false); |
808 | gate_label->setEnabled(false); | 808 | gate_label->setEnabled(false); |
809 | } | 809 | } |
810 | else | 810 | else |
811 | { | 811 | { |
812 | gatewayaddr->setEnabled(true); | 812 | gatewayaddr->setEnabled(true); |
813 | gatewayaddr->setText(""); | 813 | gatewayaddr->setText(""); |
814 | gate_label->setEnabled(true); | 814 | gate_label->setEnabled(true); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | 817 | ||
818 | 818 | ||
819 | 819 | ||
820 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 820 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
821 | : QWidget(parent, name),_pppdata(pd) | 821 | : QWidget(parent, name),_pppdata(pd) |
822 | { | 822 | { |
823 | 823 | ||
824 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); | 824 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); |
825 | se = new ScriptEdit(this); | 825 | se = new ScriptEdit(this); |
826 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | 826 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); |
827 | tl->addWidget(se); | 827 | tl->addWidget(se); |
828 | 828 | ||
829 | // insert equal-sized buttons | 829 | // insert equal-sized buttons |
830 | QHBoxLayout *hl = new QHBoxLayout( this ); | 830 | QHBoxLayout *hl = new QHBoxLayout( this ); |
831 | tl->addLayout( hl ); | 831 | tl->addLayout( hl ); |
832 | add = new QPushButton( tr("Add"), this ); | 832 | add = new QPushButton( tr("Add"), this ); |
833 | hl->addWidget( add ); | 833 | hl->addWidget( add ); |
834 | connect(add, SIGNAL(clicked()), SLOT(addButton())); | 834 | connect(add, SIGNAL(clicked()), SLOT(addButton())); |
835 | insert = new QPushButton( tr("Insert"), this ); | 835 | insert = new QPushButton( tr("Insert"), this ); |
836 | hl->addWidget( insert ); | 836 | hl->addWidget( insert ); |
837 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); | 837 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); |
838 | remove = new QPushButton( tr("Remove"), this ); | 838 | remove = new QPushButton( tr("Remove"), this ); |
839 | hl->addWidget( remove ); | 839 | hl->addWidget( remove ); |
840 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); | 840 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); |
841 | 841 | ||
842 | QHBoxLayout *l12 = new QHBoxLayout(0); | 842 | QHBoxLayout *l12 = new QHBoxLayout(0); |
843 | tl->addLayout(l12); | 843 | tl->addLayout(l12); |
844 | stl = new QListBox(this); | 844 | stl = new QListBox(this); |
845 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); | 845 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); |
846 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); | 846 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); |
847 | // stl->setMinimumSize(QSize(70, 140)); | 847 | // stl->setMinimumSize(QSize(70, 140)); |
848 | 848 | ||
849 | sl = new QListBox(this); | 849 | sl = new QListBox(this); |
850 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); | 850 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); |
851 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | 851 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); |
852 | // sl->setMinimumSize(QSize(150, 140)); | 852 | // sl->setMinimumSize(QSize(150, 140)); |
853 | 853 | ||
854 | slb = new QScrollBar(this); | 854 | slb = new QScrollBar(this); |
855 | // slb->setFixedWidth(slb->sizeHint().width()); | 855 | // slb->setFixedWidth(slb->sizeHint().width()); |
856 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 856 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
857 | 857 | ||
858 | l12->addWidget(stl, 1); | 858 | l12->addWidget(stl, 1); |
859 | l12->addWidget(sl, 3); | 859 | l12->addWidget(sl, 3); |
860 | l12->addWidget(slb, 0); | 860 | l12->addWidget(slb, 0); |
861 | 861 | ||
862 | //load data from gpppdata | 862 | //load data from gpppdata |
863 | if(!isnewaccount) | 863 | if(!isnewaccount) |
864 | { | 864 | { |
865 | QStringList &comlist = _pppdata->scriptType(); | 865 | QStringList &comlist = _pppdata->scriptType(); |
866 | QStringList &arglist = _pppdata->script(); | 866 | QStringList &arglist = _pppdata->script(); |
867 | QStringList::Iterator itcom = comlist.begin(); | 867 | QStringList::Iterator itcom = comlist.begin(); |
868 | QStringList::Iterator itarg = arglist.begin(); | 868 | QStringList::Iterator itarg = arglist.begin(); |
869 | 869 | ||
870 | for ( ; | 870 | for ( ; |
871 | itcom != comlist.end() && itarg != arglist.end(); | 871 | itcom != comlist.end() && itarg != arglist.end(); |
872 | ++itcom, ++itarg ) | 872 | ++itcom, ++itarg ) |
873 | { | 873 | { |
874 | stl->insertItem(*itcom); | 874 | stl->insertItem(*itcom); |
875 | sl->insertItem(*itarg); | 875 | sl->insertItem(*itarg); |
876 | } | 876 | } |
877 | } | 877 | } |
878 | 878 | ||
879 | insert->setEnabled(false); | 879 | insert->setEnabled(false); |
880 | remove->setEnabled(false); | 880 | remove->setEnabled(false); |
881 | adjustScrollBar(); | 881 | adjustScrollBar(); |
882 | tl->activate(); | 882 | tl->activate(); |
883 | } | 883 | } |
884 | 884 | ||
885 | bool ScriptWidget::check() | 885 | bool ScriptWidget::check() |
886 | { | 886 | { |
887 | uint lstart = 0; | 887 | uint lstart = 0; |
888 | uint lend = 0; | 888 | uint lend = 0; |
889 | uint errcnt = 0; | 889 | uint errcnt = 0; |
890 | 890 | ||
891 | if(sl->count() > 0) | 891 | if(sl->count() > 0) |
892 | { | 892 | { |
893 | for( uint i=0; i <= sl->count()-1; i++) | 893 | for( uint i=0; i <= sl->count()-1; i++) |
894 | { | 894 | { |
895 | if(stl->text(i) == "LoopStart") | 895 | if(stl->text(i) == "LoopStart") |
896 | { | 896 | { |
897 | lstart++; | 897 | lstart++; |
898 | } | 898 | } |
899 | if (stl->text(i) == "LoopEnd") | 899 | if (stl->text(i) == "LoopEnd") |
900 | { | 900 | { |
901 | lend++; | 901 | lend++; |
902 | } | 902 | } |
903 | if ( lend > lstart ) errcnt++; | 903 | if ( lend > lstart ) errcnt++; |
904 | } | 904 | } |
905 | return ( (errcnt == 0 ) && (lstart == lend) ); | 905 | return ( (errcnt == 0 ) && (lstart == lend) ); |
906 | } | 906 | } |
907 | return true; | 907 | return true; |
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | void ScriptWidget::save() | 911 | void ScriptWidget::save() |
912 | { | 912 | { |
913 | QStringList typelist, arglist; | 913 | QStringList typelist, arglist; |
914 | for(uint i=0; i < sl->count(); i++) | 914 | for(uint i=0; i < sl->count(); i++) |
915 | { | 915 | { |
916 | typelist.append(stl->text(i)); | 916 | typelist.append(stl->text(i)); |
917 | arglist.append(sl->text(i)); | 917 | arglist.append(sl->text(i)); |
918 | } | 918 | } |
919 | _pppdata->setScriptType(typelist); | 919 | _pppdata->setScriptType(typelist); |
920 | _pppdata->setScript(arglist); | 920 | _pppdata->setScript(arglist); |
921 | } | 921 | } |
922 | 922 | ||
923 | 923 | ||
924 | 924 | ||
925 | void ScriptWidget::adjustScrollBar() | 925 | void ScriptWidget::adjustScrollBar() |
926 | { | 926 | { |
927 | if((int)sl->count() <= sl->numItemsVisible()) | 927 | if((int)sl->count() <= sl->numItemsVisible()) |
928 | slb->setRange(0, 0); | 928 | slb->setRange(0, 0); |
929 | else | 929 | else |
930 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 930 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); |
931 | } | 931 | } |
932 | 932 | ||
933 | 933 | ||
934 | void ScriptWidget::scrolling(int i) | 934 | void ScriptWidget::scrolling(int i) |
935 | { | 935 | { |
936 | sl->setTopItem(i); | 936 | sl->setTopItem(i); |
937 | stl->setTopItem(i); | 937 | stl->setTopItem(i); |
938 | } | 938 | } |
939 | 939 | ||
940 | 940 | ||
941 | void ScriptWidget::slhighlighted(int i) | 941 | void ScriptWidget::slhighlighted(int i) |
942 | { | 942 | { |
943 | insert->setEnabled(true); | 943 | insert->setEnabled(true); |
944 | remove->setEnabled(true); | 944 | remove->setEnabled(true); |
945 | stl->setCurrentItem(i); | 945 | stl->setCurrentItem(i); |
946 | } | 946 | } |
947 | 947 | ||
948 | 948 | ||
949 | void ScriptWidget::stlhighlighted(int i) | 949 | void ScriptWidget::stlhighlighted(int i) |
950 | { | 950 | { |
951 | insert->setEnabled(true); | 951 | insert->setEnabled(true); |
952 | remove->setEnabled(true); | 952 | remove->setEnabled(true); |
953 | sl->setCurrentItem(i); | 953 | sl->setCurrentItem(i); |
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | void ScriptWidget::addButton() | 957 | void ScriptWidget::addButton() |
958 | { | 958 | { |
959 | //don't allow more than the maximum script entries | 959 | //don't allow more than the maximum script entries |
960 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | 960 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) |
961 | return; | 961 | return; |
962 | 962 | ||
963 | switch(se->type()) | 963 | switch(se->type()) |
964 | { | 964 | { |
965 | case ScriptEdit::Expect: | 965 | case ScriptEdit::Expect: |
966 | stl->insertItem("Expect"); | 966 | stl->insertItem("Expect"); |
967 | sl->insertItem(se->text()); | 967 | sl->insertItem(se->text()); |
968 | break; | 968 | break; |
969 | 969 | ||
970 | case ScriptEdit::Send: | 970 | case ScriptEdit::Send: |
971 | stl->insertItem("Send"); | 971 | stl->insertItem("Send"); |
972 | sl->insertItem(se->text()); | 972 | sl->insertItem(se->text()); |
973 | break; | 973 | break; |
974 | 974 | ||
975 | case ScriptEdit::SendNoEcho: | 975 | case ScriptEdit::SendNoEcho: |
976 | stl->insertItem("SendNoEcho"); | 976 | stl->insertItem("SendNoEcho"); |
977 | sl->insertItem(se->text()); | 977 | sl->insertItem(se->text()); |
978 | break; | 978 | break; |
979 | 979 | ||
980 | case ScriptEdit::Pause: | 980 | case ScriptEdit::Pause: |
981 | stl->insertItem("Pause"); | 981 | stl->insertItem("Pause"); |
982 | sl->insertItem(se->text()); | 982 | sl->insertItem(se->text()); |
983 | break; | 983 | break; |
984 | 984 | ||
985 | case ScriptEdit::Hangup: | 985 | case ScriptEdit::Hangup: |
986 | stl->insertItem("Hangup"); | 986 | stl->insertItem("Hangup"); |
987 | sl->insertItem(""); | 987 | sl->insertItem(""); |
988 | break; | 988 | break; |
989 | 989 | ||
990 | case ScriptEdit::Answer: | 990 | case ScriptEdit::Answer: |
991 | stl->insertItem("Answer"); | 991 | stl->insertItem("Answer"); |
992 | sl->insertItem(""); | 992 | sl->insertItem(""); |
993 | break; | 993 | break; |
994 | 994 | ||
995 | case ScriptEdit::Timeout: | 995 | case ScriptEdit::Timeout: |
996 | stl->insertItem("Timeout"); | 996 | stl->insertItem("Timeout"); |
997 | sl->insertItem(se->text()); | 997 | sl->insertItem(se->text()); |
998 | break; | 998 | break; |
999 | 999 | ||
1000 | case ScriptEdit::Password: | 1000 | case ScriptEdit::Password: |
1001 | stl->insertItem("Password"); | 1001 | stl->insertItem("Password"); |
1002 | sl->insertItem(se->text()); | 1002 | sl->insertItem(se->text()); |
1003 | break; | 1003 | break; |
1004 | 1004 | ||
1005 | case ScriptEdit::ID: | 1005 | case ScriptEdit::ID: |
1006 | stl->insertItem("ID"); | 1006 | stl->insertItem("ID"); |
1007 | sl->insertItem(se->text()); | 1007 | sl->insertItem(se->text()); |
1008 | break; | 1008 | break; |
1009 | 1009 | ||
1010 | case ScriptEdit::Prompt: | 1010 | case ScriptEdit::Prompt: |
1011 | stl->insertItem("Prompt"); | 1011 | stl->insertItem("Prompt"); |
1012 | sl->insertItem(se->text()); | 1012 | sl->insertItem(se->text()); |
1013 | break; | 1013 | break; |
1014 | 1014 | ||
1015 | case ScriptEdit::PWPrompt: | 1015 | case ScriptEdit::PWPrompt: |
1016 | stl->insertItem("PWPrompt"); | 1016 | stl->insertItem("PWPrompt"); |
1017 | sl->insertItem(se->text()); | 1017 | sl->insertItem(se->text()); |
1018 | break; | 1018 | break; |
1019 | 1019 | ||
1020 | case ScriptEdit::LoopStart: | 1020 | case ScriptEdit::LoopStart: |
1021 | stl->insertItem("LoopStart"); | 1021 | stl->insertItem("LoopStart"); |
1022 | sl->insertItem(se->text()); | 1022 | sl->insertItem(se->text()); |
1023 | break; | 1023 | break; |
1024 | 1024 | ||
1025 | case ScriptEdit::LoopEnd: | 1025 | case ScriptEdit::LoopEnd: |
1026 | stl->insertItem("LoopEnd"); | 1026 | stl->insertItem("LoopEnd"); |
1027 | sl->insertItem(se->text()); | 1027 | sl->insertItem(se->text()); |
1028 | break; | 1028 | break; |
1029 | 1029 | ||
1030 | case ScriptEdit::Scan: | 1030 | case ScriptEdit::Scan: |
1031 | stl->insertItem("Scan"); | 1031 | stl->insertItem("Scan"); |
1032 | sl->insertItem(se->text()); | 1032 | sl->insertItem(se->text()); |
1033 | break; | 1033 | break; |
1034 | 1034 | ||
1035 | case ScriptEdit::Save: | 1035 | case ScriptEdit::Save: |
1036 | stl->insertItem("Save"); | 1036 | stl->insertItem("Save"); |
1037 | sl->insertItem(se->text()); | 1037 | sl->insertItem(se->text()); |
1038 | break; | 1038 | break; |
1039 | 1039 | ||
1040 | default: | 1040 | default: |
1041 | break; | 1041 | break; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | //get the scrollbar adjusted, and scroll the list so we can see what | 1044 | //get the scrollbar adjusted, and scroll the list so we can see what |
1045 | //we're adding to | 1045 | //we're adding to |
1046 | adjustScrollBar(); | 1046 | adjustScrollBar(); |
1047 | slb->setValue(slb->maxValue()); | 1047 | slb->setValue(slb->maxValue()); |
1048 | 1048 | ||
1049 | //clear the text in the entry box | 1049 | //clear the text in the entry box |
1050 | se->setText(""); | 1050 | se->setText(""); |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | 1053 | ||
1054 | void ScriptWidget::insertButton() | 1054 | void ScriptWidget::insertButton() |
1055 | { | 1055 | { |
1056 | //exit if there is no highlighted item, or we've reached the | 1056 | //exit if there is no highlighted item, or we've reached the |
1057 | //maximum entries in the script list | 1057 | //maximum entries in the script list |
1058 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | 1058 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) |
1059 | return; | 1059 | return; |
1060 | 1060 | ||
1061 | switch(se->type()) | 1061 | switch(se->type()) |
1062 | { | 1062 | { |
1063 | case ScriptEdit::Expect: | 1063 | case ScriptEdit::Expect: |
1064 | stl->insertItem("Expect", stl->currentItem()); | 1064 | stl->insertItem("Expect", stl->currentItem()); |
1065 | sl->insertItem(se->text(), sl->currentItem()); | 1065 | sl->insertItem(se->text(), sl->currentItem()); |
1066 | break; | 1066 | break; |
1067 | 1067 | ||
1068 | case ScriptEdit::Send: | 1068 | case ScriptEdit::Send: |
1069 | stl->insertItem("Send", stl->currentItem()); | 1069 | stl->insertItem("Send", stl->currentItem()); |
1070 | sl->insertItem(se->text(), sl->currentItem()); | 1070 | sl->insertItem(se->text(), sl->currentItem()); |
1071 | break; | 1071 | break; |
1072 | 1072 | ||
1073 | case ScriptEdit::SendNoEcho: | 1073 | case ScriptEdit::SendNoEcho: |
1074 | stl->insertItem("SendNoEcho", stl->currentItem()); | 1074 | stl->insertItem("SendNoEcho", stl->currentItem()); |
1075 | sl->insertItem(se->text(), sl->currentItem()); | 1075 | sl->insertItem(se->text(), sl->currentItem()); |
1076 | break; | 1076 | break; |
1077 | 1077 | ||
1078 | case ScriptEdit::Pause: | 1078 | case ScriptEdit::Pause: |
1079 | stl->insertItem("Pause", stl->currentItem()); | 1079 | stl->insertItem("Pause", stl->currentItem()); |
1080 | sl->insertItem(se->text(), sl->currentItem()); | 1080 | sl->insertItem(se->text(), sl->currentItem()); |
1081 | break; | 1081 | break; |
1082 | 1082 | ||
1083 | case ScriptEdit::Hangup: | 1083 | case ScriptEdit::Hangup: |
1084 | stl->insertItem("Hangup", stl->currentItem()); | 1084 | stl->insertItem("Hangup", stl->currentItem()); |
1085 | sl->insertItem("", sl->currentItem()); | 1085 | sl->insertItem("", sl->currentItem()); |
1086 | break; | 1086 | break; |
1087 | 1087 | ||
1088 | case ScriptEdit::Answer: | 1088 | case ScriptEdit::Answer: |
1089 | stl->insertItem("Answer", stl->currentItem()); | 1089 | stl->insertItem("Answer", stl->currentItem()); |
1090 | sl->insertItem("", sl->currentItem()); | 1090 | sl->insertItem("", sl->currentItem()); |
1091 | break; | 1091 | break; |
1092 | 1092 | ||
1093 | case ScriptEdit::Timeout: | 1093 | case ScriptEdit::Timeout: |
1094 | stl->insertItem("Timeout", stl->currentItem()); | 1094 | stl->insertItem("Timeout", stl->currentItem()); |
1095 | sl->insertItem(se->text(), sl->currentItem()); | 1095 | sl->insertItem(se->text(), sl->currentItem()); |
1096 | break; | 1096 | break; |
1097 | 1097 | ||
1098 | case ScriptEdit::Password: | 1098 | case ScriptEdit::Password: |
1099 | stl->insertItem("Password", stl->currentItem()); | 1099 | stl->insertItem("Password", stl->currentItem()); |
1100 | sl->insertItem(se->text(), sl->currentItem()); | 1100 | sl->insertItem(se->text(), sl->currentItem()); |
1101 | break; | 1101 | break; |
1102 | 1102 | ||
1103 | case ScriptEdit::ID: | 1103 | case ScriptEdit::ID: |
1104 | stl->insertItem("ID", stl->currentItem()); | 1104 | stl->insertItem("ID", stl->currentItem()); |
1105 | sl->insertItem(se->text(), sl->currentItem()); | 1105 | sl->insertItem(se->text(), sl->currentItem()); |
1106 | break; | 1106 | break; |
1107 | 1107 | ||
1108 | case ScriptEdit::Prompt: | 1108 | case ScriptEdit::Prompt: |
1109 | stl->insertItem("Prompt", stl->currentItem()); | 1109 | stl->insertItem("Prompt", stl->currentItem()); |
1110 | sl->insertItem(se->text(), sl->currentItem()); | 1110 | sl->insertItem(se->text(), sl->currentItem()); |
1111 | break; | 1111 | break; |
1112 | 1112 | ||
1113 | case ScriptEdit::PWPrompt: | 1113 | case ScriptEdit::PWPrompt: |
1114 | stl->insertItem("PWPrompt", stl->currentItem()); | 1114 | stl->insertItem("PWPrompt", stl->currentItem()); |
1115 | sl->insertItem(se->text(), sl->currentItem()); | 1115 | sl->insertItem(se->text(), sl->currentItem()); |
1116 | break; | 1116 | break; |
1117 | 1117 | ||
1118 | case ScriptEdit::LoopStart: | 1118 | case ScriptEdit::LoopStart: |
1119 | stl->insertItem("LoopStart", stl->currentItem()); | 1119 | stl->insertItem("LoopStart", stl->currentItem()); |
1120 | sl->insertItem(se->text(), sl->currentItem()); | 1120 | sl->insertItem(se->text(), sl->currentItem()); |
1121 | break; | 1121 | break; |
1122 | 1122 | ||
1123 | case ScriptEdit::LoopEnd: | 1123 | case ScriptEdit::LoopEnd: |
1124 | stl->insertItem("LoopEnd", stl->currentItem()); | 1124 | stl->insertItem("LoopEnd", stl->currentItem()); |
1125 | sl->insertItem(se->text(), sl->currentItem()); | 1125 | sl->insertItem(se->text(), sl->currentItem()); |
1126 | break; | 1126 | break; |
1127 | 1127 | ||
1128 | case ScriptEdit::Scan: | 1128 | case ScriptEdit::Scan: |
1129 | stl->insertItem("Scan", stl->currentItem()); | 1129 | stl->insertItem("Scan", stl->currentItem()); |
1130 | sl->insertItem(se->text(), sl->currentItem()); | 1130 | sl->insertItem(se->text(), sl->currentItem()); |
1131 | break; | 1131 | break; |
1132 | 1132 | ||
1133 | case ScriptEdit::Save: | 1133 | case ScriptEdit::Save: |
1134 | stl->insertItem("Save", stl->currentItem()); | 1134 | stl->insertItem("Save", stl->currentItem()); |
1135 | sl->insertItem(se->text(), sl->currentItem()); | 1135 | sl->insertItem(se->text(), sl->currentItem()); |
1136 | break; | 1136 | break; |
1137 | 1137 | ||
1138 | default: | 1138 | default: |
1139 | break; | 1139 | break; |
1140 | } | 1140 | } |
1141 | adjustScrollBar(); | 1141 | adjustScrollBar(); |
1142 | se->setText(""); | 1142 | se->setText(""); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | 1145 | ||
1146 | void ScriptWidget::removeButton() | 1146 | void ScriptWidget::removeButton() |
1147 | { | 1147 | { |
1148 | if(sl->currentItem() >= 0) | 1148 | if(sl->currentItem() >= 0) |
1149 | { | 1149 | { |
1150 | int stlc = stl->currentItem(); | 1150 | int stlc = stl->currentItem(); |
1151 | sl->removeItem(sl->currentItem()); | 1151 | sl->removeItem(sl->currentItem()); |
1152 | stl->removeItem(stlc); | 1152 | stl->removeItem(stlc); |
1153 | adjustScrollBar(); | 1153 | adjustScrollBar(); |
1154 | insert->setEnabled(sl->currentItem() != -1); | 1154 | insert->setEnabled(sl->currentItem() != -1); |
1155 | remove->setEnabled(sl->currentItem() != -1); | 1155 | remove->setEnabled(sl->currentItem() != -1); |
1156 | } | 1156 | } |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | 1159 | ||
1160 | 1160 | ||
1161 | ///////////////////////////////////////////////////////////////////////////// | 1161 | ///////////////////////////////////////////////////////////////////////////// |
1162 | // | 1162 | // |
1163 | // Used to specify a new phone number | 1163 | // Used to specify a new phone number |
1164 | // | 1164 | // |
1165 | ///////////////////////////////////////////////////////////////////////////// | 1165 | ///////////////////////////////////////////////////////////////////////////// |
1166 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | 1166 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) |
1167 | : QDialog(parent,"PhoneNumberDialog",true) | 1167 | : QDialog(parent,"PhoneNumberDialog",true) |
1168 | { | 1168 | { |
1169 | setCaption( tr("Add Phone Number") ); | 1169 | setCaption( tr("Add Phone Number") ); |
1170 | 1170 | ||
1171 | 1171 | ||
1172 | QVBoxLayout *layout = new QVBoxLayout( this ); | 1172 | QVBoxLayout *layout = new QVBoxLayout( this ); |
1173 | layout->setSpacing( 3 ); | 1173 | layout->setSpacing( 3 ); |
1174 | layout->setMargin( 3 ); | 1174 | layout->setMargin( 3 ); |
1175 | 1175 | ||
1176 | // QHBox *hbox = new QHBox(this); | 1176 | // QHBox *hbox = new QHBox(this); |
1177 | // setMainWidget(hbox); | 1177 | // setMainWidget(hbox); |
1178 | 1178 | ||
1179 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); | 1179 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); |
1180 | 1180 | ||
1181 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); | 1181 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); |
1182 | layout->addWidget( label ); | 1182 | layout->addWidget( label ); |
1183 | 1183 | ||
1184 | le = new QLineEdit(this, "lineEdit"); | 1184 | le = new QLineEdit(this, "lineEdit"); |
1185 | layout->addWidget( le ); | 1185 | layout->addWidget( le ); |
1186 | 1186 | ||
1187 | connect(le, SIGNAL(textChanged(const QString &)), | 1187 | connect(le, SIGNAL(textChanged(const QString&)), |
1188 | this, SLOT(textChanged(const QString &))); | 1188 | this, SLOT(textChanged(const QString&))); |
1189 | 1189 | ||
1190 | le->setFocus(); | 1190 | le->setFocus(); |
1191 | textChanged(""); | 1191 | textChanged(""); |
1192 | 1192 | ||
1193 | 1193 | ||
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | 1196 | ||
1197 | QString PhoneNumberDialog::phoneNumber() | 1197 | QString PhoneNumberDialog::phoneNumber() |
1198 | { | 1198 | { |
1199 | QString s = le->text(); | 1199 | QString s = le->text(); |
1200 | 1200 | ||
1201 | return s; | 1201 | return s; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | 1204 | ||
1205 | void PhoneNumberDialog::textChanged(const QString &s) | 1205 | void PhoneNumberDialog::textChanged(const QString &s) |
1206 | { | 1206 | { |
1207 | // enableButtonOK(s.length() > 0); | 1207 | // enableButtonOK(s.length() > 0); |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | 1210 | ||
1211 | //#include "edit.moc" | 1211 | //#include "edit.moc" |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index ff1b11b..81dab38 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -1,472 +1,472 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "general.h" | 27 | #include "general.h" |
28 | #include "interfaceppp.h" | 28 | #include "interfaceppp.h" |
29 | #include "modeminfo.h" | 29 | #include "modeminfo.h" |
30 | #include "modemcmds.h" | 30 | #include "modemcmds.h" |
31 | #include "pppdata.h" | 31 | #include "pppdata.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qslider.h> | 43 | #include <qslider.h> |
44 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
45 | #include <qwhatsthis.h> | 45 | #include <qwhatsthis.h> |
46 | 46 | ||
47 | /* STD */ | 47 | /* STD */ |
48 | #include <termios.h> | 48 | #include <termios.h> |
49 | #include <string.h> | 49 | #include <string.h> |
50 | 50 | ||
51 | 51 | ||
52 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) | 52 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) |
53 | : QWidget(parent, name), _pppdata(pd) | 53 | : QWidget(parent, name), _pppdata(pd) |
54 | { | 54 | { |
55 | int k; | 55 | int k; |
56 | 56 | ||
57 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); | 57 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); |
58 | 58 | ||
59 | QLabel *label1; | 59 | QLabel *label1; |
60 | 60 | ||
61 | label1 = new QLabel(tr("Modem &name:"), this); | 61 | label1 = new QLabel(tr("Modem &name:"), this); |
62 | tl->addWidget(label1, 0, 0); | 62 | tl->addWidget(label1, 0, 0); |
63 | 63 | ||
64 | modemname = new QLineEdit(this, "modemName"); | 64 | modemname = new QLineEdit(this, "modemName"); |
65 | modemname->setText( _pppdata->devname() ); | 65 | modemname->setText( _pppdata->devname() ); |
66 | label1->setBuddy(modemname); | 66 | label1->setBuddy(modemname); |
67 | tl->addWidget(modemname, 0, 1); | 67 | tl->addWidget(modemname, 0, 1); |
68 | 68 | ||
69 | label1 = new QLabel(tr("Modem de&vice:"), this); | 69 | label1 = new QLabel(tr("Modem de&vice:"), this); |
70 | tl->addWidget(label1, 1, 0); | 70 | tl->addWidget(label1, 1, 0); |
71 | 71 | ||
72 | modemdevice = new QComboBox(false, this); | 72 | modemdevice = new QComboBox(false, this); |
73 | modemdevice->setEditable( true ); | 73 | modemdevice->setEditable( true ); |
74 | modemdevice->setDuplicatesEnabled ( false ); | 74 | modemdevice->setDuplicatesEnabled ( false ); |
75 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); | 75 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); |
76 | label1->setBuddy(modemdevice); | 76 | label1->setBuddy(modemdevice); |
77 | 77 | ||
78 | Config cfg("NetworkSetupPPP"); | 78 | Config cfg("NetworkSetupPPP"); |
79 | cfg.setGroup("Devices_General"); | 79 | cfg.setGroup("Devices_General"); |
80 | QStringList devs = cfg.readListEntry("devices",','); | 80 | QStringList devs = cfg.readListEntry("devices",','); |
81 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; | 81 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; |
82 | modemdevice->insertStringList( devs ); | 82 | modemdevice->insertStringList( devs ); |
83 | tl->addWidget(modemdevice, 1, 1); | 83 | tl->addWidget(modemdevice, 1, 1); |
84 | 84 | ||
85 | // connect(modemdevice, SIGNAL(activated(int)), | 85 | // connect(modemdevice, SIGNAL(activated(int)), |
86 | // SLOT(setmodemdc(int))); | 86 | // SLOT(setmodemdc(int))); |
87 | // connect(modemdevice, SIGNAL(textChanged( const QString & ) ), | 87 | // connect(modemdevice, SIGNAL(textChanged(const QString&) ), |
88 | // SLOT( setmodemdc( const QString &) ) ); | 88 | // SLOT( setmodemdc(const QString&) ) ); |
89 | 89 | ||
90 | QString tmp = tr("This specifies the serial port your modem is attached \n" | 90 | QString tmp = tr("This specifies the serial port your modem is attached \n" |
91 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" | 91 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" |
92 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" | 92 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" |
93 | "\n" | 93 | "\n" |
94 | "If you have an internal ISDN card with AT command\n" | 94 | "If you have an internal ISDN card with AT command\n" |
95 | "emulation (most cards under Linux support this), you\n" | 95 | "emulation (most cards under Linux support this), you\n" |
96 | "should select one of the /dev/ttyIx devices."); | 96 | "should select one of the /dev/ttyIx devices."); |
97 | 97 | ||
98 | QWhatsThis::add(label1,tmp); | 98 | QWhatsThis::add(label1,tmp); |
99 | QWhatsThis::add(modemdevice,tmp); | 99 | QWhatsThis::add(modemdevice,tmp); |
100 | 100 | ||
101 | 101 | ||
102 | label1 = new QLabel(tr("&Flow control:"), this); | 102 | label1 = new QLabel(tr("&Flow control:"), this); |
103 | tl->addWidget(label1, 2, 0); | 103 | tl->addWidget(label1, 2, 0); |
104 | 104 | ||
105 | flowcontrol = new QComboBox(false, this); | 105 | flowcontrol = new QComboBox(false, this); |
106 | label1->setBuddy(flowcontrol); | 106 | label1->setBuddy(flowcontrol); |
107 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); | 107 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); |
108 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); | 108 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); |
109 | flowcontrol->insertItem(tr("None")); | 109 | flowcontrol->insertItem(tr("None")); |
110 | tl->addWidget(flowcontrol, 2, 1); | 110 | tl->addWidget(flowcontrol, 2, 1); |
111 | // connect(flowcontrol, SIGNAL(activated(int)), | 111 | // connect(flowcontrol, SIGNAL(activated(int)), |
112 | // SLOT(setflowcontrol(int))); | 112 | // SLOT(setflowcontrol(int))); |
113 | 113 | ||
114 | tmp = tr("<p>Specifies how the serial port and modem\n" | 114 | tmp = tr("<p>Specifies how the serial port and modem\n" |
115 | "communicate. You should not change this unless\n" | 115 | "communicate. You should not change this unless\n" |
116 | "you know what you are doing.\n" | 116 | "you know what you are doing.\n" |
117 | "\n" | 117 | "\n" |
118 | "<b>Default</b>: CRTSCTS"); | 118 | "<b>Default</b>: CRTSCTS"); |
119 | 119 | ||
120 | QWhatsThis::add(label1,tmp); | 120 | QWhatsThis::add(label1,tmp); |
121 | QWhatsThis::add(flowcontrol,tmp); | 121 | QWhatsThis::add(flowcontrol,tmp); |
122 | 122 | ||
123 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); | 123 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); |
124 | tl->addWidget(labelenter, 3, 0); | 124 | tl->addWidget(labelenter, 3, 0); |
125 | 125 | ||
126 | enter = new QComboBox(false, this); | 126 | enter = new QComboBox(false, this); |
127 | labelenter->setBuddy(enter); | 127 | labelenter->setBuddy(enter); |
128 | enter->insertItem("CR"); | 128 | enter->insertItem("CR"); |
129 | enter->insertItem("LF"); | 129 | enter->insertItem("LF"); |
130 | enter->insertItem("CR/LF"); | 130 | enter->insertItem("CR/LF"); |
131 | tl->addWidget(enter, 3, 1); | 131 | tl->addWidget(enter, 3, 1); |
132 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); | 132 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); |
133 | tmp = tr("<p>Specifies how AT commands are sent to your\n" | 133 | tmp = tr("<p>Specifies how AT commands are sent to your\n" |
134 | "modem. Most modems will work fine with the\n" | 134 | "modem. Most modems will work fine with the\n" |
135 | "default <i>CR/LF</i>. If your modem does not react\n" | 135 | "default <i>CR/LF</i>. If your modem does not react\n" |
136 | "to the init string, you should try different\n" | 136 | "to the init string, you should try different\n" |
137 | "settings here\n" | 137 | "settings here\n" |
138 | "\n" | 138 | "\n" |
139 | "<b>Default</b>: CR/LF"); | 139 | "<b>Default</b>: CR/LF"); |
140 | 140 | ||
141 | QWhatsThis::add(labelenter,tmp); | 141 | QWhatsThis::add(labelenter,tmp); |
142 | QWhatsThis::add(enter, tmp); | 142 | QWhatsThis::add(enter, tmp); |
143 | 143 | ||
144 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); | 144 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); |
145 | tl->addWidget(baud_label, 4, 0); | 145 | tl->addWidget(baud_label, 4, 0); |
146 | baud_c = new QComboBox(this); | 146 | baud_c = new QComboBox(this); |
147 | baud_label->setBuddy(baud_c); | 147 | baud_label->setBuddy(baud_c); |
148 | 148 | ||
149 | static const char *baudrates[] = | 149 | static const char *baudrates[] = |
150 | { | 150 | { |
151 | 151 | ||
152 | #ifdef B460800 | 152 | #ifdef B460800 |
153 | "460800", | 153 | "460800", |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | #ifdef B230400 | 156 | #ifdef B230400 |
157 | "230400", | 157 | "230400", |
158 | #endif | 158 | #endif |
159 | 159 | ||
160 | #ifdef B115200 | 160 | #ifdef B115200 |
161 | "115200", | 161 | "115200", |
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | #ifdef B57600 | 164 | #ifdef B57600 |
165 | "57600", | 165 | "57600", |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | "38400", | 168 | "38400", |
169 | "19200", | 169 | "19200", |
170 | "9600", | 170 | "9600", |
171 | "2400", | 171 | "2400", |
172 | 0 | 172 | 0 |
173 | }; | 173 | }; |
174 | 174 | ||
175 | for(k = 0; baudrates[k]; k++) | 175 | for(k = 0; baudrates[k]; k++) |
176 | baud_c->insertItem(baudrates[k]); | 176 | baud_c->insertItem(baudrates[k]); |
177 | 177 | ||
178 | baud_c->setCurrentItem(3); | 178 | baud_c->setCurrentItem(3); |
179 | // connect(baud_c, SIGNAL(activated(int)), | 179 | // connect(baud_c, SIGNAL(activated(int)), |
180 | // this, SLOT(speed_selection(int))); | 180 | // this, SLOT(speed_selection(int))); |
181 | tl->addWidget(baud_c, 4, 1); | 181 | tl->addWidget(baud_c, 4, 1); |
182 | 182 | ||
183 | tmp = tr("Specifies the speed your modem and the serial\n" | 183 | tmp = tr("Specifies the speed your modem and the serial\n" |
184 | "port talk to each other. You should begin with\n" | 184 | "port talk to each other. You should begin with\n" |
185 | "the default of 38400 bits/sec. If everything\n" | 185 | "the default of 38400 bits/sec. If everything\n" |
186 | "works you can try to increase this value, but to\n" | 186 | "works you can try to increase this value, but to\n" |
187 | "no more than 115200 bits/sec (unless you know\n" | 187 | "no more than 115200 bits/sec (unless you know\n" |
188 | "that your serial port supports higher speeds)."); | 188 | "that your serial port supports higher speeds)."); |
189 | 189 | ||
190 | QWhatsThis::add(baud_label,tmp); | 190 | QWhatsThis::add(baud_label,tmp); |
191 | QWhatsThis::add(baud_c,tmp); | 191 | QWhatsThis::add(baud_c,tmp); |
192 | 192 | ||
193 | for(int i=0; i <= enter->count()-1; i++) | 193 | for(int i=0; i <= enter->count()-1; i++) |
194 | { | 194 | { |
195 | if(_pppdata->enter() == enter->text(i)) | 195 | if(_pppdata->enter() == enter->text(i)) |
196 | enter->setCurrentItem(i); | 196 | enter->setCurrentItem(i); |
197 | } | 197 | } |
198 | 198 | ||
199 | tl->addRowSpacing(5, 10); | 199 | tl->addRowSpacing(5, 10); |
200 | 200 | ||
201 | //Modem Lock File | 201 | //Modem Lock File |
202 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); | 202 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); |
203 | 203 | ||
204 | modemlockfile->setChecked(_pppdata->modemLockFile()); | 204 | modemlockfile->setChecked(_pppdata->modemLockFile()); |
205 | // connect(modemlockfile, SIGNAL(toggled(bool)), | 205 | // connect(modemlockfile, SIGNAL(toggled(bool)), |
206 | // SLOT(modemlockfilechanged(bool))); | 206 | // SLOT(modemlockfilechanged(bool))); |
207 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); | 207 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); |
208 | // l12->addStretch(1); | 208 | // l12->addStretch(1); |
209 | QWhatsThis::add(modemlockfile, | 209 | QWhatsThis::add(modemlockfile, |
210 | tr("<p>To prevent other programs from accessing the\n" | 210 | tr("<p>To prevent other programs from accessing the\n" |
211 | "modem while a connection is established, a\n" | 211 | "modem while a connection is established, a\n" |
212 | "file can be created to indicate that the modem\n" | 212 | "file can be created to indicate that the modem\n" |
213 | "is in use. On Linux an example file would be\n" | 213 | "is in use. On Linux an example file would be\n" |
214 | "<tt>/var/lock/LCK..ttyS1</tt>\n" | 214 | "<tt>/var/lock/LCK..ttyS1</tt>\n" |
215 | "Here you can select whether this locking will\n" | 215 | "Here you can select whether this locking will\n" |
216 | "be done.\n" | 216 | "be done.\n" |
217 | "\n" | 217 | "\n" |
218 | "<b>Default</b>: On")); | 218 | "<b>Default</b>: On")); |
219 | 219 | ||
220 | // Modem Timeout Line Edit Box | 220 | // Modem Timeout Line Edit Box |
221 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); | 221 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); |
222 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); | 222 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); |
223 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); | 223 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); |
224 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); | 224 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); |
225 | // modemtimeout->setLabel(tr("Modem &timeout:")); | 225 | // modemtimeout->setLabel(tr("Modem &timeout:")); |
226 | // modemtimeout->setRange(1, 120, 1); | 226 | // modemtimeout->setRange(1, 120, 1); |
227 | modemtimeout->setSuffix(tr(" sec")); | 227 | modemtimeout->setSuffix(tr(" sec")); |
228 | modemtimeout->setValue( _pppdata->modemTimeout() ); | 228 | modemtimeout->setValue( _pppdata->modemTimeout() ); |
229 | // connect(modemtimeout, SIGNAL(valueChanged(int)), | 229 | // connect(modemtimeout, SIGNAL(valueChanged(int)), |
230 | // SLOT(modemtimeoutchanged(int))); | 230 | // SLOT(modemtimeoutchanged(int))); |
231 | timeoutLayout->addWidget(timeoutlabel); | 231 | timeoutLayout->addWidget(timeoutlabel); |
232 | timeoutLayout->addWidget(modemtimeout); | 232 | timeoutLayout->addWidget(modemtimeout); |
233 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); | 233 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); |
234 | 234 | ||
235 | QWhatsThis::add(modemtimeout, | 235 | QWhatsThis::add(modemtimeout, |
236 | tr("This specifies how long <i>kppp</i> waits for a\n" | 236 | tr("This specifies how long <i>kppp</i> waits for a\n" |
237 | "<i>CONNECT</i> response from your modem. The\n" | 237 | "<i>CONNECT</i> response from your modem. The\n" |
238 | "recommended value is 30 seconds.")); | 238 | "recommended value is 30 seconds.")); |
239 | 239 | ||
240 | //set stuff from gpppdata | 240 | //set stuff from gpppdata |
241 | for(int i=0; i <= enter->count()-1; i++) | 241 | for(int i=0; i <= enter->count()-1; i++) |
242 | { | 242 | { |
243 | if(_pppdata->enter() == enter->text(i)) | 243 | if(_pppdata->enter() == enter->text(i)) |
244 | enter->setCurrentItem(i); | 244 | enter->setCurrentItem(i); |
245 | } | 245 | } |
246 | 246 | ||
247 | for(int i=0; i <= modemdevice->count()-1; i++) | 247 | for(int i=0; i <= modemdevice->count()-1; i++) |
248 | { | 248 | { |
249 | if(_pppdata->modemDevice() == modemdevice->text(i)) | 249 | if(_pppdata->modemDevice() == modemdevice->text(i)) |
250 | modemdevice->setCurrentItem(i); | 250 | modemdevice->setCurrentItem(i); |
251 | } | 251 | } |
252 | 252 | ||
253 | for(int i=0; i <= flowcontrol->count()-1; i++) | 253 | for(int i=0; i <= flowcontrol->count()-1; i++) |
254 | { | 254 | { |
255 | if(_pppdata->flowcontrol() == flowcontrol->text(i)) | 255 | if(_pppdata->flowcontrol() == flowcontrol->text(i)) |
256 | flowcontrol->setCurrentItem(i); | 256 | flowcontrol->setCurrentItem(i); |
257 | } | 257 | } |
258 | 258 | ||
259 | //set the modem speed | 259 | //set the modem speed |
260 | for(int i=0; i < baud_c->count(); i++) | 260 | for(int i=0; i < baud_c->count(); i++) |
261 | if(baud_c->text(i) == _pppdata->speed()) | 261 | if(baud_c->text(i) == _pppdata->speed()) |
262 | baud_c->setCurrentItem(i); | 262 | baud_c->setCurrentItem(i); |
263 | 263 | ||
264 | tl->setRowStretch(1, 1); | 264 | tl->setRowStretch(1, 1); |
265 | } | 265 | } |
266 | 266 | ||
267 | ModemWidget::~ModemWidget() | 267 | ModemWidget::~ModemWidget() |
268 | { | 268 | { |
269 | QStringList devs; | 269 | QStringList devs; |
270 | 270 | ||
271 | for (int i=0;i<modemdevice->count();i++) | 271 | for (int i=0;i<modemdevice->count();i++) |
272 | { | 272 | { |
273 | QString s = modemdevice->text(i); | 273 | QString s = modemdevice->text(i); |
274 | s.simplifyWhiteSpace(); | 274 | s.simplifyWhiteSpace(); |
275 | if (! s.isEmpty() ) devs << s; | 275 | if (! s.isEmpty() ) devs << s; |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | QString edited = modemdevice->currentText(); | 279 | QString edited = modemdevice->currentText(); |
280 | if ( !( edited ).isEmpty() ) | 280 | if ( !( edited ).isEmpty() ) |
281 | { | 281 | { |
282 | edited.simplifyWhiteSpace(); | 282 | edited.simplifyWhiteSpace(); |
283 | if ( devs.contains( edited ) == 0 ) | 283 | if ( devs.contains( edited ) == 0 ) |
284 | { | 284 | { |
285 | devs << edited; | 285 | devs << edited; |
286 | } | 286 | } |
287 | _pppdata->setModemDevice( edited ); | 287 | _pppdata->setModemDevice( edited ); |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | Config cfg("NetworkSetupPPP"); | 291 | Config cfg("NetworkSetupPPP"); |
292 | cfg.setGroup("Devices_General"); | 292 | cfg.setGroup("Devices_General"); |
293 | cfg.writeEntry("devices",devs,','); | 293 | cfg.writeEntry("devices",devs,','); |
294 | 294 | ||
295 | } | 295 | } |
296 | 296 | ||
297 | // void ModemWidget::speed_selection(int) { | 297 | // void ModemWidget::speed_selection(int) { |
298 | // _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); | 298 | // _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); |
299 | // } | 299 | // } |
300 | 300 | ||
301 | 301 | ||
302 | // void ModemWidget::setenter(int ) { | 302 | // void ModemWidget::setenter(int ) { |
303 | // _pppdata->setEnter(enter->text(enter->currentItem())); | 303 | // _pppdata->setEnter(enter->text(enter->currentItem())); |
304 | // } | 304 | // } |
305 | 305 | ||
306 | 306 | ||
307 | // void ModemWidget::setmodemdc(int i) { | 307 | // void ModemWidget::setmodemdc(int i) { |
308 | // _pppdata->setModemDevice(modemdevice->text(i)); | 308 | // _pppdata->setModemDevice(modemdevice->text(i)); |
309 | // } | 309 | // } |
310 | 310 | ||
311 | // void ModemWidget::setmodemdc( const QString &string ) { | 311 | // void ModemWidget::setmodemdc( const QString &string ) { |
312 | // _pppdata->setModemDevice( string ); | 312 | // _pppdata->setModemDevice( string ); |
313 | // } | 313 | // } |
314 | 314 | ||
315 | // void ModemWidget::setflowcontrol(int i) { | 315 | // void ModemWidget::setflowcontrol(int i) { |
316 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); | 316 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); |
317 | // } | 317 | // } |
318 | 318 | ||
319 | 319 | ||
320 | // void ModemWidget::modemlockfilechanged(bool set) { | 320 | // void ModemWidget::modemlockfilechanged(bool set) { |
321 | // _pppdata->setModemLockFile(set); | 321 | // _pppdata->setModemLockFile(set); |
322 | // } | 322 | // } |
323 | 323 | ||
324 | 324 | ||
325 | // void ModemWidget::modemtimeoutchanged(int n) { | 325 | // void ModemWidget::modemtimeoutchanged(int n) { |
326 | // _pppdata->setModemTimeout(n); | 326 | // _pppdata->setModemTimeout(n); |
327 | // } | 327 | // } |
328 | 328 | ||
329 | 329 | ||
330 | 330 | ||
331 | bool ModemWidget::save() | 331 | bool ModemWidget::save() |
332 | { | 332 | { |
333 | //first check to make sure that the device name is unique! | 333 | //first check to make sure that the device name is unique! |
334 | if(modemname->text().isEmpty() || | 334 | if(modemname->text().isEmpty() || |
335 | !_pppdata->isUniqueDevname(modemname->text())) | 335 | !_pppdata->isUniqueDevname(modemname->text())) |
336 | return false; | 336 | return false; |
337 | 337 | ||
338 | qDebug("ModemWidget::save saving modem1 data"); | 338 | qDebug("ModemWidget::save saving modem1 data"); |
339 | _pppdata->setDevname( modemname->text() ); | 339 | _pppdata->setDevname( modemname->text() ); |
340 | _pppdata->setModemDevice( modemdevice->currentText() ); | 340 | _pppdata->setModemDevice( modemdevice->currentText() ); |
341 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 341 | _pppdata->setFlowcontrol(flowcontrol->currentText()); |
342 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | 342 | _pppdata->setFlowcontrol(flowcontrol->currentText()); |
343 | _pppdata->setSpeed(baud_c->currentText()); | 343 | _pppdata->setSpeed(baud_c->currentText()); |
344 | _pppdata->setModemLockFile( modemlockfile->isChecked()); | 344 | _pppdata->setModemLockFile( modemlockfile->isChecked()); |
345 | _pppdata->setModemTimeout( modemtimeout->value() ); | 345 | _pppdata->setModemTimeout( modemtimeout->value() ); |
346 | return true; | 346 | return true; |
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, | 350 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, |
351 | const char *name) | 351 | const char *name) |
352 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) | 352 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) |
353 | { | 353 | { |
354 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 354 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
355 | 355 | ||
356 | 356 | ||
357 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); | 357 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); |
358 | waitfordt->setChecked(_pppdata->waitForDialTone()); | 358 | waitfordt->setChecked(_pppdata->waitForDialTone()); |
359 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); | 359 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); |
360 | l1->addWidget(waitfordt); | 360 | l1->addWidget(waitfordt); |
361 | QWhatsThis::add(waitfordt, | 361 | QWhatsThis::add(waitfordt, |
362 | tr("<p>Normally the modem waits for a dial tone\n" | 362 | tr("<p>Normally the modem waits for a dial tone\n" |
363 | "from your phone line, indicating that it can\n" | 363 | "from your phone line, indicating that it can\n" |
364 | "start to dial a number. If your modem does not\n" | 364 | "start to dial a number. If your modem does not\n" |
365 | "recognize this sound, or your local phone system\n" | 365 | "recognize this sound, or your local phone system\n" |
366 | "does not emit such a tone, uncheck this option\n" | 366 | "does not emit such a tone, uncheck this option\n" |
367 | "\n" | 367 | "\n" |
368 | "<b>Default:</b>: On")); | 368 | "<b>Default:</b>: On")); |
369 | 369 | ||
370 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); | 370 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); |
371 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); | 371 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); |
372 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); | 372 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); |
373 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); | 373 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); |
374 | // busywait->setLabel(tr("B&usy wait:")); | 374 | // busywait->setLabel(tr("B&usy wait:")); |
375 | // busywait->setRange(0, 300, 5, true); | 375 | // busywait->setRange(0, 300, 5, true); |
376 | busywait->setSuffix(tr(" sec")); | 376 | busywait->setSuffix(tr(" sec")); |
377 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); | 377 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); |
378 | waitLayout->addWidget(waitLabel); | 378 | waitLayout->addWidget(waitLabel); |
379 | waitLayout->addWidget(busywait); | 379 | waitLayout->addWidget(busywait); |
380 | l1->addLayout( waitLayout ); | 380 | l1->addLayout( waitLayout ); |
381 | 381 | ||
382 | QWhatsThis::add(busywait, | 382 | QWhatsThis::add(busywait, |
383 | tr("Specifies the number of seconds to wait before\n" | 383 | tr("Specifies the number of seconds to wait before\n" |
384 | "redial if all dialed numbers are busy. This is\n" | 384 | "redial if all dialed numbers are busy. This is\n" |
385 | "necessary because some modems get stuck if the\n" | 385 | "necessary because some modems get stuck if the\n" |
386 | "same number is busy too often.\n" | 386 | "same number is busy too often.\n" |
387 | "\n" | 387 | "\n" |
388 | "The default is 0 seconds, you should not change\n" | 388 | "The default is 0 seconds, you should not change\n" |
389 | "this unless you need to.")); | 389 | "this unless you need to.")); |
390 | 390 | ||
391 | l1->addSpacing(10); | 391 | l1->addSpacing(10); |
392 | 392 | ||
393 | QHBoxLayout *hbl = new QHBoxLayout; | 393 | QHBoxLayout *hbl = new QHBoxLayout; |
394 | hbl->setSpacing(2);//KDialog::spacingHint()); | 394 | hbl->setSpacing(2);//KDialog::spacingHint()); |
395 | 395 | ||
396 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); | 396 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); |
397 | hbl->addWidget(volumeLabel); | 397 | hbl->addWidget(volumeLabel); |
398 | volume = new QSlider(0, 2, 1, _pppdata->volume(), | 398 | volume = new QSlider(0, 2, 1, _pppdata->volume(), |
399 | QSlider::Horizontal, this); | 399 | QSlider::Horizontal, this); |
400 | volumeLabel->setBuddy(volume); | 400 | volumeLabel->setBuddy(volume); |
401 | volume->setTickmarks(QSlider::Below); | 401 | volume->setTickmarks(QSlider::Below); |
402 | hbl->addWidget(volume); | 402 | hbl->addWidget(volume); |
403 | 403 | ||
404 | l1->addLayout(hbl); | 404 | l1->addLayout(hbl); |
405 | 405 | ||
406 | // connect(volume, SIGNAL(valueChanged(int)), | 406 | // connect(volume, SIGNAL(valueChanged(int)), |
407 | // this, SLOT(volumeChanged(int))); | 407 | // this, SLOT(volumeChanged(int))); |
408 | QString tmp = tr("Most modems have a speaker which makes\n" | 408 | QString tmp = tr("Most modems have a speaker which makes\n" |
409 | "a lot of noise when dialing. Here you can\n" | 409 | "a lot of noise when dialing. Here you can\n" |
410 | "either turn this completely off or select a\n" | 410 | "either turn this completely off or select a\n" |
411 | "lower volume.\n" | 411 | "lower volume.\n" |
412 | "\n" | 412 | "\n" |
413 | "If this does not work for your modem,\n" | 413 | "If this does not work for your modem,\n" |
414 | "you must modify the modem volume command."); | 414 | "you must modify the modem volume command."); |
415 | 415 | ||
416 | QWhatsThis::add(volumeLabel,tmp); | 416 | QWhatsThis::add(volumeLabel,tmp); |
417 | QWhatsThis::add(volume, tmp); | 417 | QWhatsThis::add(volume, tmp); |
418 | 418 | ||
419 | l1->addSpacing(20); | 419 | l1->addSpacing(20); |
420 | 420 | ||
421 | #if 0 | 421 | #if 0 |
422 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); | 422 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); |
423 | chkbox1->setChecked(_pppdata->UseCDLine()); | 423 | chkbox1->setChecked(_pppdata->UseCDLine()); |
424 | connect(chkbox1,SIGNAL(toggled(bool)), | 424 | connect(chkbox1,SIGNAL(toggled(bool)), |
425 | this,SLOT(use_cdline_toggled(bool))); | 425 | this,SLOT(use_cdline_toggled(bool))); |
426 | l12->addWidget(chkbox1); | 426 | l12->addWidget(chkbox1); |
427 | l12->addStretch(1); | 427 | l12->addStretch(1); |
428 | l1->addStretch(1); | 428 | l1->addStretch(1); |
429 | QWhatsThis::add(chkbox1, | 429 | QWhatsThis::add(chkbox1, |
430 | tr("This controls how <i>kppp</i> detects that the modem\n" | 430 | tr("This controls how <i>kppp</i> detects that the modem\n" |
431 | "is not responding. Unless you are having\n" | 431 | "is not responding. Unless you are having\n" |
432 | "problems with this, do not modify this setting.\n" | 432 | "problems with this, do not modify this setting.\n" |
433 | "\n" | 433 | "\n" |
434 | "<b>Default</b>: Off")); | 434 | "<b>Default</b>: Off")); |
435 | #endif | 435 | #endif |
436 | 436 | ||
437 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); | 437 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); |
438 | QWhatsThis::add(modemcmds, | 438 | QWhatsThis::add(modemcmds, |
439 | tr("Allows you to change the AT command for\n" | 439 | tr("Allows you to change the AT command for\n" |
440 | "your modem.")); | 440 | "your modem.")); |
441 | 441 | ||
442 | modeminfo_button = new QPushButton(tr("&Query Modem..."), this); | 442 | modeminfo_button = new QPushButton(tr("&Query Modem..."), this); |
443 | QWhatsThis::add(modeminfo_button, | 443 | QWhatsThis::add(modeminfo_button, |
444 | tr("Most modems support the ATI command set to\n" | 444 | tr("Most modems support the ATI command set to\n" |
445 | "find out vendor and revision of your modem.\n" | 445 | "find out vendor and revision of your modem.\n" |
446 | "\n" | 446 | "\n" |
447 | "Press this button to query your modem for\n" | 447 | "Press this button to query your modem for\n" |
448 | "this information. It can be useful to help\n" | 448 | "this information. It can be useful to help\n" |
449 | "you setup the modem")); | 449 | "you setup the modem")); |
450 | 450 | ||
451 | // terminal_button = new QPushButton(tr("&Terminal..."), this); | 451 | // terminal_button = new QPushButton(tr("&Terminal..."), this); |
452 | // QWhatsThis::add(terminal_button, | 452 | // QWhatsThis::add(terminal_button, |
453 | // tr("Opens the built-in terminal program. You\n" | 453 | // tr("Opens the built-in terminal program. You\n" |
454 | // "can use this if you want to play around\n" | 454 | // "can use this if you want to play around\n" |
455 | // "with your modem's AT command set")); | 455 | // "with your modem's AT command set")); |
456 | 456 | ||
457 | QHBoxLayout *hbox = new QHBoxLayout(); | 457 | QHBoxLayout *hbox = new QHBoxLayout(); |
458 | l1->addLayout(hbox); | 458 | l1->addLayout(hbox); |
459 | hbox->addStretch(1); | 459 | hbox->addStretch(1); |
460 | QVBoxLayout *vbox = new QVBoxLayout(); | 460 | QVBoxLayout *vbox = new QVBoxLayout(); |
461 | hbox->addLayout(vbox); | 461 | hbox->addLayout(vbox); |
462 | 462 | ||
463 | vbox->addWidget(modemcmds); | 463 | vbox->addWidget(modemcmds); |
464 | vbox->addWidget(modeminfo_button); | 464 | vbox->addWidget(modeminfo_button); |
465 | // vbox->addWidget(terminal_button); | 465 | // vbox->addWidget(terminal_button); |
466 | 466 | ||
467 | hbox->addStretch(1); | 467 | hbox->addStretch(1); |
468 | l1->addStretch(1); | 468 | l1->addStretch(1); |
469 | 469 | ||
470 | connect(modemcmds, SIGNAL(clicked()), | 470 | connect(modemcmds, SIGNAL(clicked()), |
471 | SLOT(modemcmdsbutton())); | 471 | SLOT(modemcmdsbutton())); |
472 | connect(modeminfo_button, SIGNAL(clicked()), | 472 | connect(modeminfo_button, SIGNAL(clicked()), |
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index e466358..e21bbc7 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp | |||
@@ -15,863 +15,863 @@ | |||
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "kpppwidget.h" | 27 | #include "kpppwidget.h" |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qevent.h> | 32 | #include <qevent.h> |
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | 41 | ||
42 | // #include <kaboutdata.h> | 42 | // #include <kaboutdata.h> |
43 | // #include <kapplication.h> | 43 | // #include <kapplication.h> |
44 | #include <qbuttongroup.h> | 44 | #include <qbuttongroup.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | 47 | ||
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <errno.h> | 49 | #include <errno.h> |
50 | #include <signal.h> | 50 | #include <signal.h> |
51 | 51 | ||
52 | #include "runtests.h" | 52 | #include "runtests.h" |
53 | 53 | ||
54 | //#include "main.h" | 54 | //#include "main.h" |
55 | #include "auth.h" | 55 | #include "auth.h" |
56 | #include "modem.h" | 56 | #include "modem.h" |
57 | //#include "ppplog.h" | 57 | //#include "ppplog.h" |
58 | //#include "opener.h" | 58 | //#include "opener.h" |
59 | //#include "requester.h" | 59 | //#include "requester.h" |
60 | //#include "pppstats.h" | 60 | //#include "pppstats.h" |
61 | #include "pppdata.h" | 61 | #include "pppdata.h" |
62 | #include "general.h" | 62 | #include "general.h" |
63 | #include "interface.h" | 63 | #include "interface.h" |
64 | 64 | ||
65 | #define execute_command system | 65 | #define execute_command system |
66 | 66 | ||
67 | KPPPWidget *p_kppp = 0; | 67 | KPPPWidget *p_kppp = 0; |
68 | 68 | ||
69 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) | 69 | KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *name, bool modal, WFlags fl ) |
70 | : QDialog(parent, name, modal, Qt::WStyle_ContextHelp ), _pppdata(pd) | 70 | : QDialog(parent, name, modal, Qt::WStyle_ContextHelp ), _pppdata(pd) |
71 | { | 71 | { |
72 | // tabWindow = 0; | 72 | // tabWindow = 0; |
73 | p_kppp = this; | 73 | p_kppp = this; |
74 | // before doing anything else, run a few tests | 74 | // before doing anything else, run a few tests |
75 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) | 75 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) |
76 | _pppdata->setModemDevice("/dev/modem"); | 76 | _pppdata->setModemDevice("/dev/modem"); |
77 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 77 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
78 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); | 78 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); |
79 | if (!_pppdata->setAccount( i->getHardwareName() )) | 79 | if (!_pppdata->setAccount( i->getHardwareName() )) |
80 | _pppdata->setAccount( 0 ); | 80 | _pppdata->setAccount( 0 ); |
81 | 81 | ||
82 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); | 82 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); |
83 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); | 83 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); |
84 | 84 | ||
85 | int result = runTests(); | 85 | int result = runTests(); |
86 | if(result == TEST_CRITICAL) | 86 | if(result == TEST_CRITICAL) |
87 | exit(4); | 87 | exit(4); |
88 | 88 | ||
89 | // installEventFilter(this); | 89 | // installEventFilter(this); |
90 | 90 | ||
91 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 91 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
92 | 92 | ||
93 | QGridLayout *l1 = new QGridLayout(3, 4); | 93 | QGridLayout *l1 = new QGridLayout(3, 4); |
94 | tl->addLayout(l1); | 94 | tl->addLayout(l1); |
95 | l1->addColSpacing(0, 10); | 95 | l1->addColSpacing(0, 10); |
96 | l1->addColSpacing(3, 10); | 96 | l1->addColSpacing(3, 10); |
97 | l1->setColStretch(1, 3); | 97 | l1->setColStretch(1, 3); |
98 | l1->setColStretch(2, 4); | 98 | l1->setColStretch(2, 4); |
99 | 99 | ||
100 | label1 = new QLabel(QObject::tr("C&onnect to: "), this); | 100 | label1 = new QLabel(QObject::tr("C&onnect to: "), this); |
101 | l1->addWidget(label1, 0, 1); | 101 | l1->addWidget(label1, 0, 1); |
102 | 102 | ||
103 | connectto_c = new QComboBox(false, this); | 103 | connectto_c = new QComboBox(false, this); |
104 | label1->setBuddy(connectto_c); | 104 | label1->setBuddy(connectto_c); |
105 | 105 | ||
106 | connect(connectto_c, SIGNAL(activated(int)), | 106 | connect(connectto_c, SIGNAL(activated(int)), |
107 | SLOT(newdefaultaccount(int))); | 107 | SLOT(newdefaultaccount(int))); |
108 | l1->addWidget(connectto_c, 0, 2); | 108 | l1->addWidget(connectto_c, 0, 2); |
109 | 109 | ||
110 | ID_Label = new QLabel(QObject::tr("&Login ID:"), this); | 110 | ID_Label = new QLabel(QObject::tr("&Login ID:"), this); |
111 | l1->addWidget(ID_Label, 1, 1); | 111 | l1->addWidget(ID_Label, 1, 1); |
112 | 112 | ||
113 | // the entry line for usernames | 113 | // the entry line for usernames |
114 | ID_Edit = new QLineEdit(this); | 114 | ID_Edit = new QLineEdit(this); |
115 | ID_Label->setBuddy(ID_Edit); | 115 | ID_Label->setBuddy(ID_Edit); |
116 | l1->addWidget(ID_Edit, 1, 2); | 116 | l1->addWidget(ID_Edit, 1, 2); |
117 | connect(ID_Edit, SIGNAL(returnPressed()), | 117 | connect(ID_Edit, SIGNAL(returnPressed()), |
118 | this, SLOT(enterPressedInID())); | 118 | this, SLOT(enterPressedInID())); |
119 | QString tmp = QObject::tr("<p>Type in the username that you got from your\n" | 119 | QString tmp = QObject::tr("<p>Type in the username that you got from your\n" |
120 | "ISP. This is especially important for PAP\n" | 120 | "ISP. This is especially important for PAP\n" |
121 | "and CHAP. You may omit this when you use\n" | 121 | "and CHAP. You may omit this when you use\n" |
122 | "terminal-based or script-based authentication.\n" | 122 | "terminal-based or script-based authentication.\n" |
123 | "\n" | 123 | "\n" |
124 | "<b>Important</b>: case is important here:\n" | 124 | "<b>Important</b>: case is important here:\n" |
125 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); | 125 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); |
126 | 126 | ||
127 | QWhatsThis::add(ID_Label,tmp); | 127 | QWhatsThis::add(ID_Label,tmp); |
128 | QWhatsThis::add(ID_Edit,tmp); | 128 | QWhatsThis::add(ID_Edit,tmp); |
129 | 129 | ||
130 | PW_Label = new QLabel(QObject::tr("&Password:"), this); | 130 | PW_Label = new QLabel(QObject::tr("&Password:"), this); |
131 | l1->addWidget(PW_Label, 2, 1); | 131 | l1->addWidget(PW_Label, 2, 1); |
132 | 132 | ||
133 | PW_Edit= new QLineEdit(this); | 133 | PW_Edit= new QLineEdit(this); |
134 | PW_Label->setBuddy(PW_Edit); | 134 | PW_Label->setBuddy(PW_Edit); |
135 | PW_Edit->setEchoMode(QLineEdit::Password); | 135 | PW_Edit->setEchoMode(QLineEdit::Password); |
136 | l1->addWidget(PW_Edit, 2, 2); | 136 | l1->addWidget(PW_Edit, 2, 2); |
137 | connect(PW_Edit, SIGNAL(returnPressed()), | 137 | connect(PW_Edit, SIGNAL(returnPressed()), |
138 | this, SLOT(enterPressedInPW())); | 138 | this, SLOT(enterPressedInPW())); |
139 | 139 | ||
140 | tmp = QObject::tr("<p>Type in the password that you got from your\n" | 140 | tmp = QObject::tr("<p>Type in the password that you got from your\n" |
141 | "ISP. This is especially important for PAP\n" | 141 | "ISP. This is especially important for PAP\n" |
142 | "and CHAP. You may omit this when you use\n" | 142 | "and CHAP. You may omit this when you use\n" |
143 | "terminal-based or script-based authentication.\n" | 143 | "terminal-based or script-based authentication.\n" |
144 | "\n" | 144 | "\n" |
145 | "<b>Important</b>: case is important here:\n" | 145 | "<b>Important</b>: case is important here:\n" |
146 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); | 146 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); |
147 | 147 | ||
148 | QWhatsThis::add(PW_Label,tmp); | 148 | QWhatsThis::add(PW_Label,tmp); |
149 | QWhatsThis::add(PW_Edit,tmp); | 149 | QWhatsThis::add(PW_Edit,tmp); |
150 | 150 | ||
151 | QHBoxLayout *l3 = new QHBoxLayout; | 151 | QHBoxLayout *l3 = new QHBoxLayout; |
152 | tl->addSpacing(5); | 152 | tl->addSpacing(5); |
153 | tl->addLayout(l3); | 153 | tl->addLayout(l3); |
154 | tl->addSpacing(5); | 154 | tl->addSpacing(5); |
155 | l3->addSpacing(10); | 155 | l3->addSpacing(10); |
156 | log = new QCheckBox(QObject::tr("Show lo&g window"), this); | 156 | log = new QCheckBox(QObject::tr("Show lo&g window"), this); |
157 | connect(log, SIGNAL(toggled(bool)), | 157 | connect(log, SIGNAL(toggled(bool)), |
158 | this, SLOT(log_window_toggled(bool))); | 158 | this, SLOT(log_window_toggled(bool))); |
159 | log->setChecked(_pppdata->get_show_log_window()); | 159 | log->setChecked(_pppdata->get_show_log_window()); |
160 | l3->addWidget(log); | 160 | l3->addWidget(log); |
161 | 161 | ||
162 | QWhatsThis::add(log, | 162 | QWhatsThis::add(log, |
163 | QObject::tr("<p>This controls whether a log window is shown.\n" | 163 | QObject::tr("<p>This controls whether a log window is shown.\n" |
164 | "A log window shows the communication between\n" | 164 | "A log window shows the communication between\n" |
165 | "<i>kppp</i> and your modem. This will help you\n" | 165 | "<i>kppp</i> and your modem. This will help you\n" |
166 | "in tracking down problems.\n" | 166 | "in tracking down problems.\n" |
167 | "\n" | 167 | "\n" |
168 | "Turn it off if <i>kppp</i> routinely connects without\n" | 168 | "Turn it off if <i>kppp</i> routinely connects without\n" |
169 | "problems")); | 169 | "problems")); |
170 | 170 | ||
171 | // fline = new QSeparator( KSeparator::HLine, this); | 171 | // fline = new QSeparator( KSeparator::HLine, this); |
172 | // tl->addWidget(fline); | 172 | // tl->addWidget(fline); |
173 | 173 | ||
174 | QHBoxLayout *l2 = new QHBoxLayout(this); | 174 | QHBoxLayout *l2 = new QHBoxLayout(this); |
175 | tl->addLayout(l2); | 175 | tl->addLayout(l2); |
176 | 176 | ||
177 | int minw = 0; | 177 | int minw = 0; |
178 | quit_b = new QPushButton(QObject::tr("&Quit"), this); | 178 | quit_b = new QPushButton(QObject::tr("&Quit"), this); |
179 | // quit_b-> setGuiItem (KGuiItem(QObject::tr("&Quit"), "exit" ) ); | 179 | // quit_b-> setGuiItem (KGuiItem(QObject::tr("&Quit"), "exit" ) ); |
180 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); | 180 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); |
181 | if(quit_b->sizeHint().width() > minw) | 181 | if(quit_b->sizeHint().width() > minw) |
182 | minw = quit_b->sizeHint().width(); | 182 | minw = quit_b->sizeHint().width(); |
183 | 183 | ||
184 | setup_b = new QPushButton(QObject::tr("&Setup..."), this); | 184 | setup_b = new QPushButton(QObject::tr("&Setup..."), this); |
185 | // setup_b->setGuiItem (KGuiItem(QObject::tr("&Setup...")) ); | 185 | // setup_b->setGuiItem (KGuiItem(QObject::tr("&Setup...")) ); |
186 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); | 186 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); |
187 | if(setup_b->sizeHint().width() > minw) | 187 | if(setup_b->sizeHint().width() > minw) |
188 | minw = setup_b->sizeHint().width(); | 188 | minw = setup_b->sizeHint().width(); |
189 | 189 | ||
190 | 190 | ||
191 | 191 | ||
192 | // if(_pppdata->access() != KConfig::ReadWrite) | 192 | // if(_pppdata->access() != KConfig::ReadWrite) |
193 | // setup_b->setEnabled(false); | 193 | // setup_b->setEnabled(false); |
194 | 194 | ||
195 | // help_b = new QPushButton(QObject::tr("&Help"), this); | 195 | // help_b = new QPushButton(QObject::tr("&Help"), this); |
196 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); | 196 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); |
197 | 197 | ||
198 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); | 198 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); |
199 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); | 199 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); |
200 | // help_b->setGuiItem (KGuiItem(QObject::tr("&Help"), "help" ) ); | 200 | // help_b->setGuiItem (KGuiItem(QObject::tr("&Help"), "help" ) ); |
201 | 201 | ||
202 | // if(help_b->sizeHint().width() > minw) | 202 | // if(help_b->sizeHint().width() > minw) |
203 | // minw = help_b->sizeHint().width(); | 203 | // minw = help_b->sizeHint().width(); |
204 | 204 | ||
205 | connect_b = new QPushButton(QObject::tr("&Connect"), this); | 205 | connect_b = new QPushButton(QObject::tr("&Connect"), this); |
206 | connect_b->setDefault(true); | 206 | connect_b->setDefault(true); |
207 | connect_b->setFocus(); | 207 | connect_b->setFocus(); |
208 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); | 208 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); |
209 | if(connect_b->sizeHint().width() > minw) | 209 | if(connect_b->sizeHint().width() > minw) |
210 | minw = connect_b->sizeHint().width(); | 210 | minw = connect_b->sizeHint().width(); |
211 | 211 | ||
212 | quit_b->setFixedWidth(minw); | 212 | quit_b->setFixedWidth(minw); |
213 | setup_b->setFixedWidth(minw); | 213 | setup_b->setFixedWidth(minw); |
214 | // help_b->setFixedWidth(help_b->sizeHint().width()); | 214 | // help_b->setFixedWidth(help_b->sizeHint().width()); |
215 | connect_b->setFixedWidth(minw); | 215 | connect_b->setFixedWidth(minw); |
216 | 216 | ||
217 | l2->addWidget(quit_b); | 217 | l2->addWidget(quit_b); |
218 | l2->addWidget(setup_b); | 218 | l2->addWidget(setup_b); |
219 | // l2->addWidget(help_b); | 219 | // l2->addWidget(help_b); |
220 | l2->addSpacing(20); | 220 | l2->addSpacing(20); |
221 | l2->addWidget(connect_b); | 221 | l2->addWidget(connect_b); |
222 | 222 | ||
223 | setFixedSize(sizeHint()); | 223 | setFixedSize(sizeHint()); |
224 | 224 | ||
225 | (void)new Modem(_pppdata); | 225 | (void)new Modem(_pppdata); |
226 | 226 | ||
227 | // we also connect cmld_start to the beginConnect so that I can run | 227 | // we also connect cmld_start to the beginConnect so that I can run |
228 | // the dialer through a command line argument | 228 | // the dialer through a command line argument |
229 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); | 229 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); |
230 | 230 | ||
231 | // stats = new PPPStats; | 231 | // stats = new PPPStats; |
232 | 232 | ||
233 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 233 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
234 | 234 | ||
235 | // constructor of con_win reads position from config file | 235 | // constructor of con_win reads position from config file |
236 | con_win = new ConWindow(_pppdata, 0, "conw", this); | 236 | con_win = new ConWindow(_pppdata, 0, "conw", this); |
237 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); | 237 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); |
238 | 238 | ||
239 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); | 239 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); |
240 | // statdlg->hide(); | 240 | // statdlg->hide(); |
241 | 241 | ||
242 | // load up the accounts combo box | 242 | // load up the accounts combo box |
243 | 243 | ||
244 | // resetaccounts(); | 244 | // resetaccounts(); |
245 | con = new ConnectWidget(_pppdata, 0, "con"); | 245 | con = new ConnectWidget(_pppdata, 0, "con"); |
246 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); | 246 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); |
247 | connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); | 247 | connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); |
248 | // Is this the best we can do here? it's not right. | 248 | // Is this the best we can do here? it's not right. |
249 | // QRect desk = QApplication::desktop()->screenGeometry( | 249 | // QRect desk = QApplication::desktop()->screenGeometry( |
250 | // QApplication::desktop()->screenNumber(topLevelWidget())); | 250 | // QApplication::desktop()->screenNumber(topLevelWidget())); |
251 | // con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); | 251 | // con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110); |
252 | 252 | ||
253 | // connect the ConnectWidgets various signals | 253 | // connect the ConnectWidgets various signals |
254 | connect(con, SIGNAL(startAccounting()), | 254 | connect(con, SIGNAL(startAccounting()), |
255 | this, SLOT(startAccounting())); | 255 | this, SLOT(startAccounting())); |
256 | connect(con, SIGNAL(stopAccounting()), | 256 | connect(con, SIGNAL(stopAccounting()), |
257 | this, SLOT(stopAccounting())); | 257 | this, SLOT(stopAccounting())); |
258 | connect(qApp, SIGNAL(saveYourself()), | 258 | connect(qApp, SIGNAL(saveYourself()), |
259 | this, SLOT(saveMyself())); | 259 | this, SLOT(saveMyself())); |
260 | connect(qApp, SIGNAL(shutDown()), | 260 | connect(qApp, SIGNAL(shutDown()), |
261 | this, SLOT(shutDown())); | 261 | this, SLOT(shutDown())); |
262 | 262 | ||
263 | 263 | ||
264 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 264 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
265 | 265 | ||
266 | // m_strCmdlAccount = args->getOption("c"); | 266 | // m_strCmdlAccount = args->getOption("c"); |
267 | // m_bQuitOnDisconnect = args->isSet("q"); | 267 | // m_bQuitOnDisconnect = args->isSet("q"); |
268 | 268 | ||
269 | // if(!m_strCmdlAccount.isEmpty()) { | 269 | // if(!m_strCmdlAccount.isEmpty()) { |
270 | // m_bCmdlAccount = true; | 270 | // m_bCmdlAccount = true; |
271 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; | 271 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; |
272 | // } | 272 | // } |
273 | 273 | ||
274 | // if(m_bCmdlAccount){ | 274 | // if(m_bCmdlAccount){ |
275 | // bool result = _pppdata->setAccount(m_strCmdlAccount); | 275 | // bool result = _pppdata->setAccount(m_strCmdlAccount); |
276 | // if (!result){ | 276 | // if (!result){ |
277 | // QString string; | 277 | // QString string; |
278 | // string = QObject::tr("No such Account:\n%1").arg(m_strCmdlAccount); | 278 | // string = QObject::tr("No such Account:\n%1").arg(m_strCmdlAccount); |
279 | // KMessageBox::error(this, string); | 279 | // KMessageBox::error(this, string); |
280 | // m_bCmdlAccount = false; | 280 | // m_bCmdlAccount = false; |
281 | // this->show(); | 281 | // this->show(); |
282 | // } else { | 282 | // } else { |
283 | // beginConnect(); | 283 | // beginConnect(); |
284 | // } | 284 | // } |
285 | // } else | 285 | // } else |
286 | // expandbutton(); | 286 | // expandbutton(); |
287 | // show(); | 287 | // show(); |
288 | 288 | ||
289 | 289 | ||
290 | //#define KPPP_SHOW_NEWS | 290 | //#define KPPP_SHOW_NEWS |
291 | #ifdef KPPP_SHOW_NEWS | 291 | #ifdef KPPP_SHOW_NEWS |
292 | // keep user informed about recent changes | 292 | // keep user informed about recent changes |
293 | if(!m_bCmdlAccount) | 293 | if(!m_bCmdlAccount) |
294 | showNews(); | 294 | showNews(); |
295 | #endif | 295 | #endif |
296 | } | 296 | } |
297 | 297 | ||
298 | KPPPWidget::~KPPPWidget() | 298 | KPPPWidget::~KPPPWidget() |
299 | { | 299 | { |
300 | p_kppp = 0; | 300 | p_kppp = 0; |
301 | // delete stats; | 301 | // delete stats; |
302 | } | 302 | } |
303 | 303 | ||
304 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { | 304 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { |
305 | // if(e->type() == QEvent::User) { | 305 | // if(e->type() == QEvent::User) { |
306 | // switch(((SignalEvent*)e)->sigType()) { | 306 | // switch(((SignalEvent*)e)->sigType()) { |
307 | // case SIGINT: | 307 | // case SIGINT: |
308 | // qDebug( "Received a SIGINT" ); | 308 | // qDebug( "Received a SIGINT" ); |
309 | // interruptConnection(); | 309 | // interruptConnection(); |
310 | // break; | 310 | // break; |
311 | // case SIGCHLD: | 311 | // case SIGCHLD: |
312 | // sigChld(); | 312 | // sigChld(); |
313 | // break; | 313 | // break; |
314 | // case SIGUSR1: | 314 | // case SIGUSR1: |
315 | // sigPPPDDied(); | 315 | // sigPPPDDied(); |
316 | // break; | 316 | // break; |
317 | // } | 317 | // } |
318 | // return true; | 318 | // return true; |
319 | // } | 319 | // } |
320 | 320 | ||
321 | // if(o == connect_b) { | 321 | // if(o == connect_b) { |
322 | // if(e->type() == QEvent::KeyPress) { | 322 | // if(e->type() == QEvent::KeyPress) { |
323 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { | 323 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { |
324 | // beginConnect(); | 324 | // beginConnect(); |
325 | // return true; | 325 | // return true; |
326 | // } | 326 | // } |
327 | // } | 327 | // } |
328 | // } | 328 | // } |
329 | 329 | ||
330 | // return false; | 330 | // return false; |
331 | // } | 331 | // } |
332 | 332 | ||
333 | 333 | ||
334 | 334 | ||
335 | 335 | ||
336 | void KPPPWidget::enterPressedInID() { | 336 | void KPPPWidget::enterPressedInID() { |
337 | PW_Edit->setFocus(); | 337 | PW_Edit->setFocus(); |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | void KPPPWidget::enterPressedInPW() { | 341 | void KPPPWidget::enterPressedInPW() { |
342 | connect_b->setFocus(); | 342 | connect_b->setFocus(); |
343 | } | 343 | } |
344 | 344 | ||
345 | // triggered by the session manager | 345 | // triggered by the session manager |
346 | void KPPPWidget::saveMyself() { | 346 | void KPPPWidget::saveMyself() { |
347 | _pppdata->save(); | 347 | _pppdata->save(); |
348 | } | 348 | } |
349 | 349 | ||
350 | void KPPPWidget::shutDown() { | 350 | void KPPPWidget::shutDown() { |
351 | interruptConnection(); | 351 | interruptConnection(); |
352 | saveMyself(); | 352 | saveMyself(); |
353 | } | 353 | } |
354 | 354 | ||
355 | void KPPPWidget::log_window_toggled(bool on) { | 355 | void KPPPWidget::log_window_toggled(bool on) { |
356 | _pppdata->set_show_log_window(on); | 356 | _pppdata->set_show_log_window(on); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | 360 | ||
361 | 361 | ||
362 | // void KPPPWidget::resetaccounts() { | 362 | // void KPPPWidget::resetaccounts() { |
363 | // connectto_c->clear(); | 363 | // connectto_c->clear(); |
364 | 364 | ||
365 | // int count = _pppdata->count(); | 365 | // int count = _pppdata->count(); |
366 | 366 | ||
367 | // // enable/disable controls | 367 | // // enable/disable controls |
368 | // connectto_c->setEnabled(count > 0); | 368 | // connectto_c->setEnabled(count > 0); |
369 | // connect_b->setEnabled(count > 0); | 369 | // connect_b->setEnabled(count > 0); |
370 | // log->setEnabled(count > 0); | 370 | // log->setEnabled(count > 0); |
371 | // ID_Edit->setEnabled(count > 0); | 371 | // ID_Edit->setEnabled(count > 0); |
372 | // PW_Edit->setEnabled(count > 0); | 372 | // PW_Edit->setEnabled(count > 0); |
373 | 373 | ||
374 | // //load the accounts | 374 | // //load the accounts |
375 | // for(int i=0; i < count; i++) { | 375 | // for(int i=0; i < count; i++) { |
376 | // _pppdata->setAccountbyIndex(i); | 376 | // _pppdata->setAccountbyIndex(i); |
377 | // connectto_c->insertItem(_pppdata->accname()); | 377 | // connectto_c->insertItem(_pppdata->accname()); |
378 | // } | 378 | // } |
379 | 379 | ||
380 | // //set the default account | 380 | // //set the default account |
381 | // if(!_pppdata->defaultAccount().isEmpty()) { | 381 | // if(!_pppdata->defaultAccount().isEmpty()) { |
382 | // for(int i=0; i < count; i++) | 382 | // for(int i=0; i < count; i++) |
383 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { | 383 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { |
384 | // connectto_c->setCurrentItem(i); | 384 | // connectto_c->setCurrentItem(i); |
385 | // _pppdata->setAccountbyIndex(i); | 385 | // _pppdata->setAccountbyIndex(i); |
386 | 386 | ||
387 | // ID_Edit->setText(_pppdata->storedUsername()); | 387 | // ID_Edit->setText(_pppdata->storedUsername()); |
388 | // PW_Edit->setText(_pppdata->storedPassword()); | 388 | // PW_Edit->setText(_pppdata->storedPassword()); |
389 | // } | 389 | // } |
390 | // } | 390 | // } |
391 | // else | 391 | // else |
392 | // if(count > 0) { | 392 | // if(count > 0) { |
393 | // _pppdata->setDefaultAccount(connectto_c->text(0)); | 393 | // _pppdata->setDefaultAccount(connectto_c->text(0)); |
394 | // _pppdata->save(); | 394 | // _pppdata->save(); |
395 | // ID_Edit->setText(_pppdata->storedUsername()); | 395 | // ID_Edit->setText(_pppdata->storedUsername()); |
396 | // PW_Edit->setText(_pppdata->storedPassword()); | 396 | // PW_Edit->setText(_pppdata->storedPassword()); |
397 | // } | 397 | // } |
398 | 398 | ||
399 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), | 399 | // connect(ID_Edit, SIGNAL(textChanged(const QString&)), |
400 | // this, SLOT(usernameChanged(const QString &))); | 400 | // this, SLOT(usernameChanged(const QString&))); |
401 | 401 | ||
402 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), | 402 | // connect(PW_Edit, SIGNAL(textChanged(const QString&)), |
403 | // this, SLOT(passwordChanged(const QString &))); | 403 | // this, SLOT(passwordChanged(const QString&))); |
404 | 404 | ||
405 | // if (ID_Edit->text().isEmpty()) | 405 | // if (ID_Edit->text().isEmpty()) |
406 | // ID_Edit->setFocus(); | 406 | // ID_Edit->setFocus(); |
407 | // else if (PW_Edit->text().isEmpty()) | 407 | // else if (PW_Edit->text().isEmpty()) |
408 | // PW_Edit->setFocus(); | 408 | // PW_Edit->setFocus(); |
409 | // } | 409 | // } |
410 | 410 | ||
411 | 411 | ||
412 | void KPPPWidget::interruptConnection() { | 412 | void KPPPWidget::interruptConnection() { |
413 | // interrupt dial up | 413 | // interrupt dial up |
414 | // | 414 | // |
415 | 415 | ||
416 | if (con->isVisible()) | 416 | if (con->isVisible()) |
417 | emit con->cancelbutton(); | 417 | emit con->cancelbutton(); |
418 | 418 | ||
419 | // disconnect if online | 419 | // disconnect if online |
420 | if (_pppdata->pppdRunning()) | 420 | if (_pppdata->pppdRunning()) |
421 | emit disconnect(); | 421 | emit disconnect(); |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | void KPPPWidget::sigPPPDDied() { | 425 | void KPPPWidget::sigPPPDDied() { |
426 | qDebug( "Received a SIGUSR1" ); | 426 | qDebug( "Received a SIGUSR1" ); |
427 | 427 | ||
428 | // if we are not connected pppdpid is -1 so have have to check for that | 428 | // if we are not connected pppdpid is -1 so have have to check for that |
429 | // in the followin line to make sure that we don't raise a false alarm | 429 | // in the followin line to make sure that we don't raise a false alarm |
430 | // such as would be the case when the log file viewer exits. | 430 | // such as would be the case when the log file viewer exits. |
431 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { | 431 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { |
432 | qDebug( "It was pppd that died" ); | 432 | qDebug( "It was pppd that died" ); |
433 | 433 | ||
434 | // when we killpppd() on Cancel in ConnectWidget | 434 | // when we killpppd() on Cancel in ConnectWidget |
435 | // we set pppid to -1 so we won't | 435 | // we set pppid to -1 so we won't |
436 | // enter this block | 436 | // enter this block |
437 | 437 | ||
438 | // just to be sure | 438 | // just to be sure |
439 | 439 | ||
440 | Modem::modem->removeSecret(AUTH_PAP); | 440 | Modem::modem->removeSecret(AUTH_PAP); |
441 | Modem::modem->removeSecret(AUTH_CHAP); | 441 | Modem::modem->removeSecret(AUTH_CHAP); |
442 | 442 | ||
443 | _pppdata->setpppdRunning(false); | 443 | _pppdata->setpppdRunning(false); |
444 | 444 | ||
445 | qDebug( "Executing command on disconnect since pppd has died." ); | 445 | qDebug( "Executing command on disconnect since pppd has died." ); |
446 | QApplication::flushX(); | 446 | QApplication::flushX(); |
447 | execute_command(_pppdata->command_on_disconnect()); | 447 | execute_command(_pppdata->command_on_disconnect()); |
448 | 448 | ||
449 | // stopAccounting(); | 449 | // stopAccounting(); |
450 | 450 | ||
451 | con_win->stopClock(); | 451 | con_win->stopClock(); |
452 | // DockWidget::dock_widget->stop_stats(); | 452 | // DockWidget::dock_widget->stop_stats(); |
453 | // DockWidget::dock_widget->hide(); | 453 | // DockWidget::dock_widget->hide(); |
454 | 454 | ||
455 | if(!_pppdata->pppdError()) | 455 | if(!_pppdata->pppdError()) |
456 | _pppdata->setpppdError(E_PPPD_DIED); | 456 | _pppdata->setpppdError(E_PPPD_DIED); |
457 | removedns(); | 457 | removedns(); |
458 | Modem::modem->unlockdevice(); | 458 | Modem::modem->unlockdevice(); |
459 | // | 459 | // |
460 | con->pppdDied(); | 460 | con->pppdDied(); |
461 | 461 | ||
462 | if(!_pppdata->automatic_redial()) { | 462 | if(!_pppdata->automatic_redial()) { |
463 | quit_b->setFocus(); | 463 | quit_b->setFocus(); |
464 | show(); | 464 | show(); |
465 | con_win->stopClock(); | 465 | con_win->stopClock(); |
466 | //stopAccounting(); | 466 | //stopAccounting(); |
467 | con_win->hide(); | 467 | con_win->hide(); |
468 | con->hide(); | 468 | con->hide(); |
469 | 469 | ||
470 | _pppdata->setpppdRunning(false); | 470 | _pppdata->setpppdRunning(false); |
471 | // // not in a signal handler !!! KNotifyClient::beep(); | 471 | // // not in a signal handler !!! KNotifyClient::beep(); |
472 | QString msg; | 472 | QString msg; |
473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) | 473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) |
474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " | 474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " |
475 | "to come up!"); | 475 | "to come up!"); |
476 | else { | 476 | else { |
477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); | 477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); |
478 | Modem::modem->pppdExitStatus(); | 478 | Modem::modem->pppdExitStatus(); |
479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only | 479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only |
480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); | 480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); |
481 | msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error " | 481 | msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error " |
482 | "codes or take a look at the kppp FAQ on " | 482 | "codes or take a look at the kppp FAQ on " |
483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" | 483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" |
484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); | 484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) | 488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) |
489 | // // PPPL_ShowLog(); | 489 | // // PPPL_ShowLog(); |
490 | // } else { /* reconnect on disconnect */ | 490 | // } else { /* reconnect on disconnect */ |
491 | if (false){ | 491 | if (false){ |
492 | qDebug( "Trying to reconnect... " ); | 492 | qDebug( "Trying to reconnect... " ); |
493 | 493 | ||
494 | if(_pppdata->authMethod() == AUTH_PAP || | 494 | if(_pppdata->authMethod() == AUTH_PAP || |
495 | _pppdata->authMethod() == AUTH_CHAP || | 495 | _pppdata->authMethod() == AUTH_CHAP || |
496 | _pppdata->authMethod() == AUTH_PAPCHAP) | 496 | _pppdata->authMethod() == AUTH_PAPCHAP) |
497 | Modem::modem->setSecret(_pppdata->authMethod(), | 497 | Modem::modem->setSecret(_pppdata->authMethod(), |
498 | encodeWord(_pppdata->storedUsername()), | 498 | encodeWord(_pppdata->storedUsername()), |
499 | encodeWord(_pppdata->password())); | 499 | encodeWord(_pppdata->password())); |
500 | 500 | ||
501 | con_win->hide(); | 501 | con_win->hide(); |
502 | con_win->stopClock(); | 502 | con_win->stopClock(); |
503 | //stopAccounting(); | 503 | //stopAccounting(); |
504 | _pppdata->setpppdRunning(false); | 504 | _pppdata->setpppdRunning(false); |
505 | // not in a signal handler !!!KNotifyClient::beep(); | 505 | // not in a signal handler !!!KNotifyClient::beep(); |
506 | emit cmdl_start(); | 506 | emit cmdl_start(); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | _pppdata->setpppdError(0); | 509 | _pppdata->setpppdError(0); |
510 | } | 510 | } |
511 | } | 511 | } |
512 | 512 | ||
513 | // void KPPPWidget::sigChld() { | 513 | // void KPPPWidget::sigChld() { |
514 | // qDebug( "sigchld()" ); | 514 | // qDebug( "sigchld()" ); |
515 | // // pid_t id = wait(0L); | 515 | // // pid_t id = wait(0L); |
516 | // // if(id == helperPid && helperPid != -1) { | 516 | // // if(id == helperPid && helperPid != -1) { |
517 | // // kdDebug(5002) << "It was the setuid child that died" << endl; | 517 | // // kdDebug(5002) << "It was the setuid child that died" << endl; |
518 | // // helperPid = -1; | 518 | // // helperPid = -1; |
519 | // QString msg = QObject::tr("kppp's helper process just died.\n" | 519 | // QString msg = QObject::tr("kppp's helper process just died.\n" |
520 | // "Since a further execution would be pointless, " | 520 | // "Since a further execution would be pointless, " |
521 | // "kppp will shut down now."); | 521 | // "kppp will shut down now."); |
522 | // QMessageBox::warning(0L,"error", msg); | 522 | // QMessageBox::warning(0L,"error", msg); |
523 | // //remove_pidfile(); | 523 | // //remove_pidfile(); |
524 | // exit(1); | 524 | // exit(1); |
525 | // // } | 525 | // // } |
526 | // } | 526 | // } |
527 | 527 | ||
528 | 528 | ||
529 | void KPPPWidget::newdefaultaccount(int i) { | 529 | void KPPPWidget::newdefaultaccount(int i) { |
530 | _pppdata->setDefaultAccount(connectto_c->text(i)); | 530 | _pppdata->setDefaultAccount(connectto_c->text(i)); |
531 | _pppdata->save(); | 531 | _pppdata->save(); |
532 | ID_Edit->setText(_pppdata->storedUsername()); | 532 | ID_Edit->setText(_pppdata->storedUsername()); |
533 | PW_Edit->setText(_pppdata->storedPassword()); | 533 | PW_Edit->setText(_pppdata->storedPassword()); |
534 | } | 534 | } |
535 | 535 | ||
536 | 536 | ||
537 | 537 | ||
538 | 538 | ||
539 | void KPPPWidget::beginConnect() { | 539 | void KPPPWidget::beginConnect() { |
540 | // make sure to connect to the account that is selected in the combo box | 540 | // make sure to connect to the account that is selected in the combo box |
541 | // (exeption: an account given by a command line argument) | 541 | // (exeption: an account given by a command line argument) |
542 | // if(!m_bCmdlAccount) { | 542 | // if(!m_bCmdlAccount) { |
543 | // _pppdata->setAccount(connectto_c->currentText()); | 543 | // _pppdata->setAccount(connectto_c->currentText()); |
544 | // _pppdata->setPassword(PW_Edit->text()); | 544 | // _pppdata->setPassword(PW_Edit->text()); |
545 | // } else { | 545 | // } else { |
546 | _pppdata->setPassword(_pppdata->storedPassword()); | 546 | _pppdata->setPassword(_pppdata->storedPassword()); |
547 | // } | 547 | // } |
548 | 548 | ||
549 | QFileInfo info(pppdPath()); | 549 | QFileInfo info(pppdPath()); |
550 | 550 | ||
551 | if(!info.exists()){ | 551 | if(!info.exists()){ |
552 | QMessageBox::warning(this, "error", QObject::tr("Cannot find the PPP daemon!\n" | 552 | QMessageBox::warning(this, "error", QObject::tr("Cannot find the PPP daemon!\n" |
553 | "Make sure that pppd is installed and " | 553 | "Make sure that pppd is installed and " |
554 | "that you have entered the correct path.")); | 554 | "that you have entered the correct path.")); |
555 | return; | 555 | return; |
556 | } | 556 | } |
557 | #if 0 | 557 | #if 0 |
558 | if(!info.isExecutable()){ | 558 | if(!info.isExecutable()){ |
559 | 559 | ||
560 | QString string; | 560 | QString string; |
561 | string = QObject::tr("kppp cannot execute:\n %1\n" | 561 | string = QObject::tr("kppp cannot execute:\n %1\n" |
562 | "Please make sure that you have given kppp " | 562 | "Please make sure that you have given kppp " |
563 | "setuid permission and that " | 563 | "setuid permission and that " |
564 | "pppd is executable.").arg(_pppdata->pppdPath()); | 564 | "pppd is executable.").arg(_pppdata->pppdPath()); |
565 | KMessageBox::error(this, string); | 565 | KMessageBox::error(this, string); |
566 | return; | 566 | return; |
567 | 567 | ||
568 | } | 568 | } |
569 | #endif | 569 | #endif |
570 | 570 | ||
571 | QFileInfo info2(_pppdata->modemDevice()); | 571 | QFileInfo info2(_pppdata->modemDevice()); |
572 | 572 | ||
573 | if(!info2.exists()){ | 573 | if(!info2.exists()){ |
574 | QString string; | 574 | QString string; |
575 | string = QObject::tr("kppp can not find:\n %1\nPlease make sure you have setup " | 575 | string = QObject::tr("kppp can not find:\n %1\nPlease make sure you have setup " |
576 | "your modem device properly " | 576 | "your modem device properly " |
577 | "and/or adjust the location of the modem device on " | 577 | "and/or adjust the location of the modem device on " |
578 | "the modem tab of " | 578 | "the modem tab of " |
579 | "the setup dialog.").arg(_pppdata->modemDevice()); | 579 | "the setup dialog.").arg(_pppdata->modemDevice()); |
580 | QMessageBox::warning(this, "error", string); | 580 | QMessageBox::warning(this, "error", string); |
581 | return; | 581 | return; |
582 | } | 582 | } |
583 | 583 | ||
584 | // if this is a PAP or CHAP account, ensure that username is | 584 | // if this is a PAP or CHAP account, ensure that username is |
585 | // supplied | 585 | // supplied |
586 | if(_pppdata->authMethod() == AUTH_PAP || | 586 | if(_pppdata->authMethod() == AUTH_PAP || |
587 | _pppdata->authMethod() == AUTH_CHAP || | 587 | _pppdata->authMethod() == AUTH_CHAP || |
588 | _pppdata->authMethod() == AUTH_PAPCHAP ) { | 588 | _pppdata->authMethod() == AUTH_PAPCHAP ) { |
589 | if(ID_Edit->text().isEmpty()) { | 589 | if(ID_Edit->text().isEmpty()) { |
590 | QMessageBox::warning(this,"error", | 590 | QMessageBox::warning(this,"error", |
591 | QObject::tr("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); | 591 | QObject::tr("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!")); |
592 | return; | 592 | return; |
593 | } else { | 593 | } else { |
594 | if(!Modem::modem->setSecret(_pppdata->authMethod(), | 594 | if(!Modem::modem->setSecret(_pppdata->authMethod(), |
595 | encodeWord(_pppdata->storedUsername()), | 595 | encodeWord(_pppdata->storedUsername()), |
596 | encodeWord(_pppdata->password()))) { | 596 | encodeWord(_pppdata->password()))) { |
597 | QString s; | 597 | QString s; |
598 | s = QObject::tr("Cannot create PAP/CHAP authentication\n" | 598 | s = QObject::tr("Cannot create PAP/CHAP authentication\n" |
599 | "file \"%1\"").arg(PAP_AUTH_FILE); | 599 | "file \"%1\"").arg(PAP_AUTH_FILE); |
600 | QMessageBox::warning(this, "error", s); | 600 | QMessageBox::warning(this, "error", s); |
601 | return; | 601 | return; |
602 | } | 602 | } |
603 | } | 603 | } |
604 | } | 604 | } |
605 | 605 | ||
606 | if (_pppdata->phonenumber().isEmpty()) { | 606 | if (_pppdata->phonenumber().isEmpty()) { |
607 | QString s = QObject::tr("You must specify a telephone number!"); | 607 | QString s = QObject::tr("You must specify a telephone number!"); |
608 | QMessageBox::warning(this, "error", s); | 608 | QMessageBox::warning(this, "error", s); |
609 | return; | 609 | return; |
610 | } | 610 | } |
611 | 611 | ||
612 | this->hide(); | 612 | this->hide(); |
613 | 613 | ||
614 | QString tit = QObject::tr("Connecting to: %1").arg(_pppdata->accname()); | 614 | QString tit = QObject::tr("Connecting to: %1").arg(_pppdata->accname()); |
615 | // con->setCaption(tit); | 615 | // con->setCaption(tit); |
616 | 616 | ||
617 | // con->show(); | 617 | // con->show(); |
618 | 618 | ||
619 | 619 | ||
620 | emit begin_connect(); | 620 | emit begin_connect(); |
621 | } | 621 | } |
622 | 622 | ||
623 | 623 | ||
624 | void KPPPWidget::disconnect() { | 624 | void KPPPWidget::disconnect() { |
625 | if (!_pppdata->command_before_disconnect().isEmpty()) { | 625 | if (!_pppdata->command_before_disconnect().isEmpty()) { |
626 | con_win->hide(); | 626 | con_win->hide(); |
627 | con->show(); | 627 | con->show(); |
628 | con->setCaption(QObject::tr("Disconnecting...")); | 628 | con->setCaption(QObject::tr("Disconnecting...")); |
629 | con->setMsg(QObject::tr("Executing command before disconnection.")); | 629 | con->setMsg(QObject::tr("Executing command before disconnection.")); |
630 | 630 | ||
631 | qApp->processEvents(); | 631 | qApp->processEvents(); |
632 | QApplication::flushX(); | 632 | QApplication::flushX(); |
633 | // pid_t id = | 633 | // pid_t id = |
634 | execute_command(_pppdata->command_before_disconnect()); | 634 | execute_command(_pppdata->command_before_disconnect()); |
635 | // int i, status; | 635 | // int i, status; |
636 | 636 | ||
637 | // do { | 637 | // do { |
638 | // kapp->processEvents(); | 638 | // kapp->processEvents(); |
639 | // i = waitpid(id, &status, WNOHANG); | 639 | // i = waitpid(id, &status, WNOHANG); |
640 | // usleep(500000); | 640 | // usleep(500000); |
641 | // } while (i == 0 && errno == 0); | 641 | // } while (i == 0 && errno == 0); |
642 | 642 | ||
643 | con->hide(); | 643 | con->hide(); |
644 | } | 644 | } |
645 | 645 | ||
646 | qApp->processEvents(); | 646 | qApp->processEvents(); |
647 | 647 | ||
648 | // statdlg->stop_stats(); | 648 | // statdlg->stop_stats(); |
649 | Modem::modem->killPPPDaemon(); | 649 | Modem::modem->killPPPDaemon(); |
650 | 650 | ||
651 | QApplication::flushX(); | 651 | QApplication::flushX(); |
652 | execute_command(_pppdata->command_on_disconnect()); | 652 | execute_command(_pppdata->command_on_disconnect()); |
653 | 653 | ||
654 | Modem::modem->removeSecret(AUTH_PAP); | 654 | Modem::modem->removeSecret(AUTH_PAP); |
655 | Modem::modem->removeSecret(AUTH_CHAP); | 655 | Modem::modem->removeSecret(AUTH_CHAP); |
656 | 656 | ||
657 | removedns(); | 657 | removedns(); |
658 | Modem::modem->unlockdevice(); | 658 | Modem::modem->unlockdevice(); |
659 | 659 | ||
660 | con_win->stopClock(); | 660 | con_win->stopClock(); |
661 | // p_kppp->stopAccounting(); | 661 | // p_kppp->stopAccounting(); |
662 | con_win->hide(); | 662 | con_win->hide(); |
663 | 663 | ||
664 | // DockWidget::dock_widget->stop_stats(); | 664 | // DockWidget::dock_widget->stop_stats(); |
665 | // DockWidget::dock_widget->hide(); | 665 | // DockWidget::dock_widget->hide(); |
666 | 666 | ||
667 | // if(m_bQuitOnDisconnect) | 667 | // if(m_bQuitOnDisconnect) |
668 | // kapp->exit(0); | 668 | // kapp->exit(0); |
669 | // else { | 669 | // else { |
670 | this->quit_b->setFocus(); | 670 | this->quit_b->setFocus(); |
671 | this->show(); | 671 | this->show(); |
672 | // } | 672 | // } |
673 | } | 673 | } |
674 | 674 | ||
675 | 675 | ||
676 | // void KPPPWidget::helpbutton() { | 676 | // void KPPPWidget::helpbutton() { |
677 | // kapp->invokeHelp(); | 677 | // kapp->invokeHelp(); |
678 | // } | 678 | // } |
679 | 679 | ||
680 | 680 | ||
681 | void KPPPWidget::quitbutton() { | 681 | void KPPPWidget::quitbutton() { |
682 | if(_pppdata->pppdRunning()) { | 682 | if(_pppdata->pppdRunning()) { |
683 | int ok = QMessageBox::warning(this, | 683 | int ok = QMessageBox::warning(this, |
684 | QObject::tr("Exiting kPPP will close your PPP Session."), | 684 | QObject::tr("Exiting kPPP will close your PPP Session."), |
685 | QObject::tr("Quit kPPP?")); | 685 | QObject::tr("Quit kPPP?")); |
686 | if(ok == QMessageBox::Yes) { | 686 | if(ok == QMessageBox::Yes) { |
687 | Modem::modem->killPPPDaemon(); | 687 | Modem::modem->killPPPDaemon(); |
688 | QApplication::flushX(); | 688 | QApplication::flushX(); |
689 | execute_command(_pppdata->command_on_disconnect()); | 689 | execute_command(_pppdata->command_on_disconnect()); |
690 | removedns(); | 690 | removedns(); |
691 | Modem::modem->unlockdevice(); | 691 | Modem::modem->unlockdevice(); |
692 | } | 692 | } |
693 | } else { | 693 | } else { |
694 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) | 694 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) |
695 | _pppdata->setStoredPassword(""); | 695 | _pppdata->setStoredPassword(""); |
696 | } | 696 | } |
697 | _pppdata->save(); | 697 | _pppdata->save(); |
698 | qApp->quit(); | 698 | qApp->quit(); |
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | // void KPPPWidget::rulesetLoadError() { | 702 | // void KPPPWidget::rulesetLoadError() { |
703 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); | 703 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); |
704 | // } | 704 | // } |
705 | 705 | ||
706 | 706 | ||
707 | // void KPPPWidget::startAccounting() { | 707 | // void KPPPWidget::startAccounting() { |
708 | // // volume accounting | 708 | // // volume accounting |
709 | // stats->totalbytes = 0; | 709 | // stats->totalbytes = 0; |
710 | 710 | ||
711 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; | 711 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; |
712 | 712 | ||
713 | // // load the ruleset | 713 | // // load the ruleset |
714 | // if(!_pppdata->AcctEnabled()) | 714 | // if(!_pppdata->AcctEnabled()) |
715 | // return; | 715 | // return; |
716 | 716 | ||
717 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); | 717 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); |
718 | // // if(::access(d.data(), X_OK) != 0) | 718 | // // if(::access(d.data(), X_OK) != 0) |
719 | // acct = new Accounting(this, stats); | 719 | // acct = new Accounting(this, stats); |
720 | // // else | 720 | // // else |
721 | // // acct = new ExecutableAccounting(this); | 721 | // // acct = new ExecutableAccounting(this); |
722 | 722 | ||
723 | // // connect to the accounting object | 723 | // // connect to the accounting object |
724 | // connect(acct, SIGNAL(changed(QString, QString)), | 724 | // connect(acct, SIGNAL(changed(QString,QString)), |
725 | // con_win, SLOT(slotAccounting(QString, QString))); | 725 | // con_win, SLOT(slotAccounting(QString,QString))); |
726 | 726 | ||
727 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { | 727 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { |
728 | // // QString s= QObject::tr("Can not load the accounting " | 728 | // // QString s= QObject::tr("Can not load the accounting " |
729 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); | 729 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); |
730 | 730 | ||
731 | // // starting the messagebox with a timer will prevent us | 731 | // // starting the messagebox with a timer will prevent us |
732 | // // from blocking the calling function ConnectWidget::timerEvent | 732 | // // from blocking the calling function ConnectWidget::timerEvent |
733 | // ruleset_load_errmsg = s; | 733 | // ruleset_load_errmsg = s; |
734 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); | 734 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); |
735 | // return; | 735 | // return; |
736 | // } | 736 | // } |
737 | // //else | 737 | // //else |
738 | // // acct->slotStart(); | 738 | // // acct->slotStart(); |
739 | // } | 739 | // } |
740 | 740 | ||
741 | // void KPPPWidget::stopAccounting() { | 741 | // void KPPPWidget::stopAccounting() { |
742 | // // store volume accounting | 742 | // // store volume accounting |
743 | // // if(stats->totalbytes != 0) | 743 | // // if(stats->totalbytes != 0) |
744 | // // _pppdata->setTotalBytes(stats->totalbytes); | 744 | // // _pppdata->setTotalBytes(stats->totalbytes); |
745 | 745 | ||
746 | // if(!_pppdata->AcctEnabled()) | 746 | // if(!_pppdata->AcctEnabled()) |
747 | // return; | 747 | // return; |
748 | 748 | ||
749 | // // if(acct != 0) { | 749 | // // if(acct != 0) { |
750 | // // acct->slotStop(); | 750 | // // acct->slotStop(); |
751 | // // delete acct; | 751 | // // delete acct; |
752 | // // acct = 0; | 752 | // // acct = 0; |
753 | // // } | 753 | // // } |
754 | // } | 754 | // } |
755 | 755 | ||
756 | 756 | ||
757 | // void KPPPWidget::showStats() { | 757 | // void KPPPWidget::showStats() { |
758 | // if(statdlg) { | 758 | // if(statdlg) { |
759 | // statdlg->show(); | 759 | // statdlg->show(); |
760 | // statdlg->raise(); | 760 | // statdlg->raise(); |
761 | // } | 761 | // } |
762 | // } | 762 | // } |
763 | 763 | ||
764 | 764 | ||
765 | void KPPPWidget::usernameChanged(const QString &) { | 765 | void KPPPWidget::usernameChanged(const QString &) { |
766 | // store username for later use | 766 | // store username for later use |
767 | _pppdata->setStoredUsername(ID_Edit->text()); | 767 | _pppdata->setStoredUsername(ID_Edit->text()); |
768 | } | 768 | } |
769 | 769 | ||
770 | 770 | ||
771 | void KPPPWidget::passwordChanged(const QString &) { | 771 | void KPPPWidget::passwordChanged(const QString &) { |
772 | // store the password if so requested | 772 | // store the password if so requested |
773 | if(_pppdata->storePassword()) | 773 | if(_pppdata->storePassword()) |
774 | _pppdata->setStoredPassword(PW_Edit->text()); | 774 | _pppdata->setStoredPassword(PW_Edit->text()); |
775 | else | 775 | else |
776 | _pppdata->setStoredPassword(""); | 776 | _pppdata->setStoredPassword(""); |
777 | } | 777 | } |
778 | 778 | ||
779 | 779 | ||
780 | void KPPPWidget::setPW_Edit(const QString &pw) { | 780 | void KPPPWidget::setPW_Edit(const QString &pw) { |
781 | PW_Edit->setText(pw); | 781 | PW_Edit->setText(pw); |
782 | } | 782 | } |
783 | 783 | ||
784 | 784 | ||
785 | // void KPPPWidget::resetCosts(const QString &s) { | 785 | // void KPPPWidget::resetCosts(const QString &s) { |
786 | // AccountingBase::resetCosts(s); | 786 | // AccountingBase::resetCosts(s); |
787 | // } | 787 | // } |
788 | 788 | ||
789 | 789 | ||
790 | // void KPPPWidget::resetVolume(const QString &s) { | 790 | // void KPPPWidget::resetVolume(const QString &s) { |
791 | // AccountingBase::resetVolume(s); | 791 | // AccountingBase::resetVolume(s); |
792 | // } | 792 | // } |
793 | 793 | ||
794 | /** | 794 | /** |
795 | * pppd's getword() function knows about escape characters. | 795 | * pppd's getword() function knows about escape characters. |
796 | * If we write the username and password to the secrets file | 796 | * If we write the username and password to the secrets file |
797 | * we'll therefore have to escape back slashes. | 797 | * we'll therefore have to escape back slashes. |
798 | */ | 798 | */ |
799 | QString KPPPWidget::encodeWord(const QString &s) { | 799 | QString KPPPWidget::encodeWord(const QString &s) { |
800 | QString r = s; | 800 | QString r = s; |
801 | r.replace(QRegExp("\\"), "\\\\"); | 801 | r.replace(QRegExp("\\"), "\\\\"); |
802 | return r; | 802 | return r; |
803 | } | 803 | } |
804 | 804 | ||
805 | // void KPPPWidget::setQuitOnDisconnect (bool b) | 805 | // void KPPPWidget::setQuitOnDisconnect (bool b) |
806 | // { | 806 | // { |
807 | // m_bQuitOnDisconnect = b; | 807 | // m_bQuitOnDisconnect = b; |
808 | // } | 808 | // } |
809 | 809 | ||
810 | void KPPPWidget::showNews() { | 810 | void KPPPWidget::showNews() { |
811 | #ifdef KPPP_SHOW_NEWS | 811 | #ifdef KPPP_SHOW_NEWS |
812 | /* | 812 | /* |
813 | * Introduce the QuickHelp feature to new users of this version | 813 | * Introduce the QuickHelp feature to new users of this version |
814 | */ | 814 | */ |
815 | #define QUICKHELP_HINT "Hint_QuickHelp" | 815 | #define QUICKHELP_HINT "Hint_QuickHelp" |
816 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { | 816 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { |
817 | QDialog dlg(0, 0, true); | 817 | QDialog dlg(0, 0, true); |
818 | dlg.setCaption(QObject::tr("Recent Changes in KPPP")); | 818 | dlg.setCaption(QObject::tr("Recent Changes in KPPP")); |
819 | 819 | ||
820 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); | 820 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); |
821 | QHBoxLayout *l1 = new QHBoxLayout(10); | 821 | QHBoxLayout *l1 = new QHBoxLayout(10); |
822 | QVBoxLayout *l2 = new QVBoxLayout(10); | 822 | QVBoxLayout *l2 = new QVBoxLayout(10); |
823 | tl->addLayout(l1); | 823 | tl->addLayout(l1); |
824 | 824 | ||
825 | QLabel *icon = new QLabel(&dlg); | 825 | QLabel *icon = new QLabel(&dlg); |
826 | icon->setPixmap(BarIcon("exclamation")); | 826 | icon->setPixmap(BarIcon("exclamation")); |
827 | icon->setFixedSize(icon->sizeHint()); | 827 | icon->setFixedSize(icon->sizeHint()); |
828 | l1->addWidget(icon); | 828 | l1->addWidget(icon); |
829 | l1->addLayout(l2); | 829 | l1->addLayout(l2); |
830 | 830 | ||
831 | QLabel *l = new QLabel(QObject::tr("From version 1.4.8 on, kppp has a new feature\n" | 831 | QLabel *l = new QLabel(QObject::tr("From version 1.4.8 on, kppp has a new feature\n" |
832 | "called \"Quickhelp\". It's similar to a tooltip,\n" | 832 | "called \"Quickhelp\". It's similar to a tooltip,\n" |
833 | "but you can activate it whenever you want.\n" | 833 | "but you can activate it whenever you want.\n" |
834 | "\n" | 834 | "\n" |
835 | "To activate it, simply click on a control like\n" | 835 | "To activate it, simply click on a control like\n" |
836 | "a button or a label with the right mouse button.\n" | 836 | "a button or a label with the right mouse button.\n" |
837 | "If the item supports Quickhelp, a popup menu\n" | 837 | "If the item supports Quickhelp, a popup menu\n" |
838 | "will appear leading to Quickhelp.\n" | 838 | "will appear leading to Quickhelp.\n" |
839 | "\n" | 839 | "\n" |
840 | "To test it, right-click somewhere in this text."), | 840 | "To test it, right-click somewhere in this text."), |
841 | &dlg); | 841 | &dlg); |
842 | 842 | ||
843 | QCheckBox *cb = new QCheckBox(QObject::tr("Don't show this hint again"), &dlg); | 843 | QCheckBox *cb = new QCheckBox(QObject::tr("Don't show this hint again"), &dlg); |
844 | cb->setFixedSize(cb->sizeHint()); | 844 | cb->setFixedSize(cb->sizeHint()); |
845 | 845 | ||
846 | KButtonBox *bbox = new KButtonBox(&dlg); | 846 | KButtonBox *bbox = new KButtonBox(&dlg); |
847 | bbox->addStretch(1); | 847 | bbox->addStretch(1); |
848 | QPushButton *ok = bbox->addButton(QObject::tr("OK")); | 848 | QPushButton *ok = bbox->addButton(QObject::tr("OK")); |
849 | ok->setDefault(true); | 849 | ok->setDefault(true); |
850 | dlg.connect(ok, SIGNAL(clicked()), | 850 | dlg.connect(ok, SIGNAL(clicked()), |
851 | &dlg, SLOT(accept())); | 851 | &dlg, SLOT(accept())); |
852 | bbox->addStretch(1); | 852 | bbox->addStretch(1); |
853 | bbox->layout(); | 853 | bbox->layout(); |
854 | 854 | ||
855 | l2->addWidget(l); | 855 | l2->addWidget(l); |
856 | l2->addWidget(cb); | 856 | l2->addWidget(cb); |
857 | tl->addWidget(bbox); | 857 | tl->addWidget(bbox); |
858 | 858 | ||
859 | QString tmp = QObject::tr("This is an example of <b>QuickHelp</b>.\n" | 859 | QString tmp = QObject::tr("This is an example of <b>QuickHelp</b>.\n" |
860 | "This window will stay open until you\n" | 860 | "This window will stay open until you\n" |
861 | "click a mouse button or a press a key.\n"); | 861 | "click a mouse button or a press a key.\n"); |
862 | 862 | ||
863 | QWhatsThis::add(cb,tmp); | 863 | QWhatsThis::add(cb,tmp); |
864 | QWhatsThis::add(l, tmp); | 864 | QWhatsThis::add(l, tmp); |
865 | 865 | ||
866 | dlg.exec(); | 866 | dlg.exec(); |
867 | if(cb->isChecked()) { | 867 | if(cb->isChecked()) { |
868 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); | 868 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); |
869 | _pppdata->save(); | 869 | _pppdata->save(); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | #endif | 872 | #endif |
873 | } | 873 | } |
874 | 874 | ||
875 | 875 | ||
876 | //#include "kpppwidget.moc" | 876 | //#include "kpppwidget.moc" |
877 | 877 | ||
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp index 66a4d82..d6d8d88 100644 --- a/noncore/settings/networksettings/ppp/pppdargs.cpp +++ b/noncore/settings/networksettings/ppp/pppdargs.cpp | |||
@@ -1,151 +1,151 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * | 12 | * |
13 | * This library is free software; you can redistribute it and/or | 13 | * This library is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU Library General Public | 14 | * modify it under the terms of the GNU Library General Public |
15 | * License as published by the Free Software Foundation; either | 15 | * License as published by the Free Software Foundation; either |
16 | * version 2 of the License, or (at your option) any later version. | 16 | * version 2 of the License, or (at your option) any later version. |
17 | * | 17 | * |
18 | * This library is distributed in the hope that it will be useful, | 18 | * This library is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 | * Library General Public License for more details. | 21 | * Library General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU Library General Public | 23 | * You should have received a copy of the GNU Library General Public |
24 | * License along with this program; if not, write to the Free | 24 | * License along with this program; if not, write to the Free |
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include "pppdargs.h" | 31 | #include "pppdargs.h" |
32 | #include "pppdata.h" | 32 | #include "pppdata.h" |
33 | 33 | ||
34 | 34 | ||
35 | PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name) | 35 | PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name) |
36 | : QDialog(parent, name, TRUE), _pppdata(pd) | 36 | : QDialog(parent, name, TRUE), _pppdata(pd) |
37 | { | 37 | { |
38 | setCaption(tr("Customize pppd Arguments")); | 38 | setCaption(tr("Customize pppd Arguments")); |
39 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 39 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
40 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); | 40 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); |
41 | QHBoxLayout *tl = new QHBoxLayout(10); | 41 | QHBoxLayout *tl = new QHBoxLayout(10); |
42 | l->addLayout(tl); | 42 | l->addLayout(tl); |
43 | QVBoxLayout *l1 = new QVBoxLayout(); | 43 | QVBoxLayout *l1 = new QVBoxLayout(); |
44 | QVBoxLayout *l2 = new QVBoxLayout(); | 44 | QVBoxLayout *l2 = new QVBoxLayout(); |
45 | tl->addLayout(l1, 1); | 45 | tl->addLayout(l1, 1); |
46 | tl->addLayout(l2, 0); | 46 | tl->addLayout(l2, 0); |
47 | 47 | ||
48 | QHBoxLayout *l11 = new QHBoxLayout(10); | 48 | QHBoxLayout *l11 = new QHBoxLayout(10); |
49 | l1->addLayout(l11); | 49 | l1->addLayout(l11); |
50 | 50 | ||
51 | argument_label = new QLabel(tr("Argument:"), this); | 51 | argument_label = new QLabel(tr("Argument:"), this); |
52 | l11->addWidget(argument_label); | 52 | l11->addWidget(argument_label); |
53 | 53 | ||
54 | argument = new QLineEdit(this); | 54 | argument = new QLineEdit(this); |
55 | connect(argument, SIGNAL(returnPressed()), | 55 | connect(argument, SIGNAL(returnPressed()), |
56 | SLOT(addbutton())); | 56 | SLOT(addbutton())); |
57 | l11->addWidget(argument); | 57 | l11->addWidget(argument); |
58 | connect(argument, SIGNAL(textChanged(const QString &)), | 58 | connect(argument, SIGNAL(textChanged(const QString&)), |
59 | this, SLOT(textChanged(const QString &))); | 59 | this, SLOT(textChanged(const QString&))); |
60 | 60 | ||
61 | arguments = new QListBox(this); | 61 | arguments = new QListBox(this); |
62 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); | 62 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); |
63 | connect(arguments, SIGNAL(highlighted(int)), | 63 | connect(arguments, SIGNAL(highlighted(int)), |
64 | this, SLOT(itemSelected(int))); | 64 | this, SLOT(itemSelected(int))); |
65 | l1->addWidget(arguments, 1); | 65 | l1->addWidget(arguments, 1); |
66 | 66 | ||
67 | add = new QPushButton(tr("Add"), this); | 67 | add = new QPushButton(tr("Add"), this); |
68 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); | 68 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); |
69 | l2->addWidget(add); | 69 | l2->addWidget(add); |
70 | l2->addStretch(1); | 70 | l2->addStretch(1); |
71 | 71 | ||
72 | remove = new QPushButton(tr("Remove"), this); | 72 | remove = new QPushButton(tr("Remove"), this); |
73 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); | 73 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); |
74 | l2->addWidget(remove); | 74 | l2->addWidget(remove); |
75 | 75 | ||
76 | defaults = new QPushButton(tr("Defaults"), this); | 76 | defaults = new QPushButton(tr("Defaults"), this); |
77 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); | 77 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); |
78 | l2->addWidget(defaults); | 78 | l2->addWidget(defaults); |
79 | 79 | ||
80 | l->addSpacing(5); | 80 | l->addSpacing(5); |
81 | 81 | ||
82 | 82 | ||
83 | //load info from gpppdata | 83 | //load info from gpppdata |
84 | init(); | 84 | init(); |
85 | 85 | ||
86 | add->setEnabled(false); | 86 | add->setEnabled(false); |
87 | remove->setEnabled(false); | 87 | remove->setEnabled(false); |
88 | argument->setFocus(); | 88 | argument->setFocus(); |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void PPPdArguments::addbutton() { | 92 | void PPPdArguments::addbutton() { |
93 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { | 93 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { |
94 | arguments->insertItem(argument->text()); | 94 | arguments->insertItem(argument->text()); |
95 | argument->setText(""); | 95 | argument->setText(""); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void PPPdArguments::removebutton() { | 100 | void PPPdArguments::removebutton() { |
101 | if(arguments->currentItem() >= 0) | 101 | if(arguments->currentItem() >= 0) |
102 | arguments->removeItem(arguments->currentItem()); | 102 | arguments->removeItem(arguments->currentItem()); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void PPPdArguments::defaultsbutton() { | 106 | void PPPdArguments::defaultsbutton() { |
107 | // all of this is a hack | 107 | // all of this is a hack |
108 | // save current list | 108 | // save current list |
109 | QStringList arglist(_pppdata->pppdArgument()); | 109 | QStringList arglist(_pppdata->pppdArgument()); |
110 | 110 | ||
111 | // get defaults | 111 | // get defaults |
112 | _pppdata->setpppdArgumentDefaults(); | 112 | _pppdata->setpppdArgumentDefaults(); |
113 | init(); | 113 | init(); |
114 | 114 | ||
115 | // restore old list | 115 | // restore old list |
116 | _pppdata->setpppdArgument(arglist); | 116 | _pppdata->setpppdArgument(arglist); |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void PPPdArguments::accept() { | 120 | void PPPdArguments::accept() { |
121 | QStringList arglist; | 121 | QStringList arglist; |
122 | for(uint i=0; i < arguments->count(); i++) | 122 | for(uint i=0; i < arguments->count(); i++) |
123 | arglist.append(arguments->text(i)); | 123 | arglist.append(arguments->text(i)); |
124 | _pppdata->setpppdArgument(arglist); | 124 | _pppdata->setpppdArgument(arglist); |
125 | 125 | ||
126 | QDialog::accept(); | 126 | QDialog::accept(); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | void PPPdArguments::init() { | 130 | void PPPdArguments::init() { |
131 | while(arguments->count()) | 131 | while(arguments->count()) |
132 | arguments->removeItem(0); | 132 | arguments->removeItem(0); |
133 | 133 | ||
134 | QStringList &arglist = _pppdata->pppdArgument(); | 134 | QStringList &arglist = _pppdata->pppdArgument(); |
135 | for ( QStringList::Iterator it = arglist.begin(); | 135 | for ( QStringList::Iterator it = arglist.begin(); |
136 | it != arglist.end(); | 136 | it != arglist.end(); |
137 | ++it ) | 137 | ++it ) |
138 | arguments->insertItem(*it); | 138 | arguments->insertItem(*it); |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void PPPdArguments::textChanged(const QString &s) { | 142 | void PPPdArguments::textChanged(const QString &s) { |
143 | add->setEnabled(s.length() > 0); | 143 | add->setEnabled(s.length() > 0); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void PPPdArguments::itemSelected(int idx) { | 147 | void PPPdArguments::itemSelected(int idx) { |
148 | remove->setEnabled(idx != -1); | 148 | remove->setEnabled(idx != -1); |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 92339d6..dd1db28 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -1,441 +1,441 @@ | |||
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 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { | 45 | 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(); | 46 | interfaces = new Interfaces(); |
47 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 47 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
48 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 48 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
49 | 49 | ||
50 | // Check sanity - the existance of the wireless-tools if-pre-up script | 50 | // Check sanity - the existance of the wireless-tools if-pre-up script |
51 | QFile file(QString(PREUP)); | 51 | QFile file(QString(PREUP)); |
52 | if (file.exists()) { | 52 | if (file.exists()) { |
53 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); | 53 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); |
54 | } | 54 | } |
55 | 55 | ||
56 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); | 56 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); |
57 | connect( netView, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectNetwork( QListViewItem* ) ) ); | 57 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); |
58 | netView->setColumnAlignment( col_chn, AlignCenter ); | 58 | netView->setColumnAlignment( col_chn, AlignCenter ); |
59 | netView->setItemMargin( 3 ); | 59 | netView->setItemMargin( 3 ); |
60 | netView->setAllColumnsShowFocus( true ); | 60 | netView->setAllColumnsShowFocus( true ); |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | WLANImp::~WLANImp() { | 64 | WLANImp::~WLANImp() { |
65 | //FIXME: delete interfaces; | 65 | //FIXME: delete interfaces; |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Change the profile for both wireless settings and network settings. | 69 | * Change the profile for both wireless settings and network settings. |
70 | */ | 70 | */ |
71 | void WLANImp::setProfile(const QString &profile){ | 71 | void WLANImp::setProfile(const QString &profile){ |
72 | interfaceSetup->setProfile(profile); | 72 | interfaceSetup->setProfile(profile); |
73 | parseOpts(); | 73 | parseOpts(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void WLANImp::parseOpts() { | 76 | void WLANImp::parseOpts() { |
77 | bool error; | 77 | bool error; |
78 | QString opt; | 78 | QString opt; |
79 | 79 | ||
80 | if (! interfaces->isInterfaceSet()) | 80 | if (! interfaces->isInterfaceSet()) |
81 | return; | 81 | return; |
82 | 82 | ||
83 | 83 | ||
84 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 84 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
85 | if(opt == "any" || opt == "off" || opt.isNull()){ | 85 | if(opt == "any" || opt == "off" || opt.isNull()){ |
86 | essid->setEditText("any"); | 86 | essid->setEditText("any"); |
87 | } else { | 87 | } else { |
88 | essid->setEditText(opt); | 88 | essid->setEditText(opt); |
89 | } | 89 | } |
90 | 90 | ||
91 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); | 91 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); |
92 | 92 | ||
93 | for ( int i = 0; i < mode->count(); i++) | 93 | for ( int i = 0; i < mode->count(); i++) |
94 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); | 94 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); |
95 | 95 | ||
96 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); | 96 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); |
97 | if (! opt.isNull()) { | 97 | if (! opt.isNull()) { |
98 | specifyAp->setChecked(true); | 98 | specifyAp->setChecked(true); |
99 | macEdit->setText(opt); | 99 | macEdit->setText(opt); |
100 | } | 100 | } |
101 | 101 | ||
102 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 102 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
103 | if (! opt.isNull()) { | 103 | if (! opt.isNull()) { |
104 | specifyChan->setChecked(true); | 104 | specifyChan->setChecked(true); |
105 | networkChannel->setValue(opt.toInt()); | 105 | networkChannel->setValue(opt.toInt()); |
106 | } | 106 | } |
107 | 107 | ||
108 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 108 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); |
109 | if (opt.isNull()) | 109 | if (opt.isNull()) |
110 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 110 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
111 | parseKeyStr(opt); | 111 | parseKeyStr(opt); |
112 | } | 112 | } |
113 | 113 | ||
114 | void WLANImp::parseKeyStr(QString keystr) { | 114 | void WLANImp::parseKeyStr(QString keystr) { |
115 | int loc = 0; | 115 | int loc = 0; |
116 | int index = 1; | 116 | int index = 1; |
117 | QString key; | 117 | QString key; |
118 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 118 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
119 | int enc = -1; // encryption state | 119 | int enc = -1; // encryption state |
120 | 120 | ||
121 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { | 121 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { |
122 | if ((*it).left(3) == "off") { | 122 | if ((*it).left(3) == "off") { |
123 | // encryption disabled | 123 | // encryption disabled |
124 | enc = 0; | 124 | enc = 0; |
125 | } else if ((*it).left(2) == "on") { | 125 | } else if ((*it).left(2) == "on") { |
126 | // encryption enabled | 126 | // encryption enabled |
127 | enc = 1; | 127 | enc = 1; |
128 | } else if ((*it).left(4) == "open") { | 128 | } else if ((*it).left(4) == "open") { |
129 | // open mode, accept non encrypted packets | 129 | // open mode, accept non encrypted packets |
130 | acceptNonEnc->setChecked(true); | 130 | acceptNonEnc->setChecked(true); |
131 | } else if ((*it).left(10) == "restricted") { | 131 | } else if ((*it).left(10) == "restricted") { |
132 | // restricted mode, only accept encrypted packets | 132 | // restricted mode, only accept encrypted packets |
133 | rejectNonEnc->setChecked(true); | 133 | rejectNonEnc->setChecked(true); |
134 | } else if ((*it).left(3) == "key") { | 134 | } else if ((*it).left(3) == "key") { |
135 | // new set of options | 135 | // new set of options |
136 | } else if ((*it).left(1) == "[") { | 136 | } else if ((*it).left(1) == "[") { |
137 | index = (*it).mid(1, 1).toInt(); | 137 | index = (*it).mid(1, 1).toInt(); |
138 | // switch current key to index | 138 | // switch current key to index |
139 | switch (index) { | 139 | switch (index) { |
140 | case 1: | 140 | case 1: |
141 | keyRadio0->setChecked(true); | 141 | keyRadio0->setChecked(true); |
142 | break; | 142 | break; |
143 | case 2: | 143 | case 2: |
144 | keyRadio1->setChecked(true); | 144 | keyRadio1->setChecked(true); |
145 | break; | 145 | break; |
146 | case 3: | 146 | case 3: |
147 | keyRadio2->setChecked(true); | 147 | keyRadio2->setChecked(true); |
148 | break; | 148 | break; |
149 | case 4: | 149 | case 4: |
150 | keyRadio3->setChecked(true); | 150 | keyRadio3->setChecked(true); |
151 | break; | 151 | break; |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
154 | // key | 154 | // key |
155 | key = (*it); | 155 | key = (*it); |
156 | } | 156 | } |
157 | if (! key.isNull()) { | 157 | if (! key.isNull()) { |
158 | if (enc == -1) | 158 | if (enc == -1) |
159 | enc = 1; | 159 | enc = 1; |
160 | QStringList::Iterator next = ++it; | 160 | QStringList::Iterator next = ++it; |
161 | if (it == keys.end()) { | 161 | if (it == keys.end()) { |
162 | break; | 162 | break; |
163 | } | 163 | } |
164 | if ((*(next)).left(1) == "[") { | 164 | if ((*(next)).left(1) == "[") { |
165 | // set key at index | 165 | // set key at index |
166 | index = (*(next)).mid(1, 1).toInt(); | 166 | index = (*(next)).mid(1, 1).toInt(); |
167 | } else { | 167 | } else { |
168 | index = 1; | 168 | index = 1; |
169 | } | 169 | } |
170 | switch (index) { | 170 | switch (index) { |
171 | case 1: | 171 | case 1: |
172 | keyLineEdit0->setText(key); | 172 | keyLineEdit0->setText(key); |
173 | break; | 173 | break; |
174 | case 2: | 174 | case 2: |
175 | keyLineEdit1->setText(key); | 175 | keyLineEdit1->setText(key); |
176 | break; | 176 | break; |
177 | case 3: | 177 | case 3: |
178 | keyLineEdit2->setText(key); | 178 | keyLineEdit2->setText(key); |
179 | break; | 179 | break; |
180 | case 4: | 180 | case 4: |
181 | keyLineEdit3->setText(key); | 181 | keyLineEdit3->setText(key); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | key = QString::null; | 184 | key = QString::null; |
185 | } | 185 | } |
186 | } | 186 | } |
187 | if (enc == 1) { | 187 | if (enc == 1) { |
188 | wepEnabled->setChecked(true); | 188 | wepEnabled->setChecked(true); |
189 | } else { | 189 | } else { |
190 | wepEnabled->setChecked(false); | 190 | wepEnabled->setChecked(false); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | 193 | ||
194 | /** | 194 | /** |
195 | * Check to see if the current config is valid | 195 | * Check to see if the current config is valid |
196 | * Save interfaces | 196 | * Save interfaces |
197 | */ | 197 | */ |
198 | void WLANImp::accept() { | 198 | void WLANImp::accept() { |
199 | if (wepEnabled->isChecked()) { | 199 | if (wepEnabled->isChecked()) { |
200 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || | 200 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || |
201 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || | 201 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || |
202 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || | 202 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || |
203 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { | 203 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { |
204 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); | 204 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | if (essid->currentText().isEmpty()) { | 209 | if (essid->currentText().isEmpty()) { |
210 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); | 210 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); |
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | 213 | ||
214 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { | 214 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { |
215 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); | 215 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | 218 | ||
219 | // Try to save the interfaces settings. | 219 | // Try to save the interfaces settings. |
220 | writeOpts(); | 220 | writeOpts(); |
221 | 221 | ||
222 | // Close out the dialog | 222 | // Close out the dialog |
223 | // FIXME: QDialog::accept(); | 223 | // FIXME: QDialog::accept(); |
224 | } | 224 | } |
225 | 225 | ||
226 | void WLANImp::writeOpts() { | 226 | void WLANImp::writeOpts() { |
227 | // eh can't really do anything about it other then return. :-D | 227 | // eh can't really do anything about it other then return. :-D |
228 | if(!interfaces->isInterfaceSet()){ | 228 | if(!interfaces->isInterfaceSet()){ |
229 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 229 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
230 | return; | 230 | return; |
231 | } | 231 | } |
232 | bool error = false; | 232 | bool error = false; |
233 | 233 | ||
234 | qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() ); | 234 | qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() ); |
235 | 235 | ||
236 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); | 236 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); |
237 | 237 | ||
238 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); | 238 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); |
239 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); | 239 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); |
240 | 240 | ||
241 | if (specifyAp->isChecked()) { | 241 | if (specifyAp->isChecked()) { |
242 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); | 242 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); |
243 | } else { | 243 | } else { |
244 | interfaces->removeInterfaceOption(QString("wireless_ap")); | 244 | interfaces->removeInterfaceOption(QString("wireless_ap")); |
245 | } | 245 | } |
246 | 246 | ||
247 | if (specifyChan->isChecked()) { | 247 | if (specifyChan->isChecked()) { |
248 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); | 248 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); |
249 | } else { | 249 | } else { |
250 | interfaces->removeInterfaceOption(QString("wireless_channel")); | 250 | interfaces->removeInterfaceOption(QString("wireless_channel")); |
251 | } | 251 | } |
252 | 252 | ||
253 | if (wepEnabled->isChecked()) { | 253 | if (wepEnabled->isChecked()) { |
254 | QStringList keyList; | 254 | QStringList keyList; |
255 | 255 | ||
256 | if (! keyLineEdit0->text().isNull()) { | 256 | if (! keyLineEdit0->text().isNull()) { |
257 | keyList += keyLineEdit0->text(); | 257 | keyList += keyLineEdit0->text(); |
258 | keyList += "[1]"; | 258 | keyList += "[1]"; |
259 | } //else | 259 | } //else |
260 | if (! keyLineEdit1->text().isNull()) { | 260 | if (! keyLineEdit1->text().isNull()) { |
261 | keyList += keyLineEdit1->text(); | 261 | keyList += keyLineEdit1->text(); |
262 | keyList += "[2]"; | 262 | keyList += "[2]"; |
263 | } //else | 263 | } //else |
264 | if (! keyLineEdit2->text().isNull()) { | 264 | if (! keyLineEdit2->text().isNull()) { |
265 | keyList += keyLineEdit2->text(); | 265 | keyList += keyLineEdit2->text(); |
266 | keyList += "[3]"; | 266 | keyList += "[3]"; |
267 | } //else | 267 | } //else |
268 | if (! keyLineEdit3->text().isNull()) { | 268 | if (! keyLineEdit3->text().isNull()) { |
269 | keyList += keyLineEdit3->text(); | 269 | keyList += keyLineEdit3->text(); |
270 | keyList += "[4]"; | 270 | keyList += "[4]"; |
271 | } | 271 | } |
272 | if (acceptNonEnc->isChecked()) { | 272 | if (acceptNonEnc->isChecked()) { |
273 | keyList += "open"; | 273 | keyList += "open"; |
274 | } else { | 274 | } else { |
275 | keyList += "restricted"; | 275 | keyList += "restricted"; |
276 | } | 276 | } |
277 | 277 | ||
278 | keyList += "key"; | 278 | keyList += "key"; |
279 | if (keyRadio0->isChecked()) { | 279 | if (keyRadio0->isChecked()) { |
280 | keyList += "[1]"; | 280 | keyList += "[1]"; |
281 | } else if (keyRadio1->isChecked()) { | 281 | } else if (keyRadio1->isChecked()) { |
282 | keyList += "[2]"; | 282 | keyList += "[2]"; |
283 | } else if (keyRadio2->isChecked()) { | 283 | } else if (keyRadio2->isChecked()) { |
284 | keyList += "[3]"; | 284 | keyList += "[3]"; |
285 | } else if (keyRadio3->isChecked()) { | 285 | } else if (keyRadio3->isChecked()) { |
286 | keyList += "[4]"; | 286 | keyList += "[4]"; |
287 | } | 287 | } |
288 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); | 288 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); |
289 | } else { | 289 | } else { |
290 | interfaces->removeInterfaceOption(QString("wireless_key")); | 290 | interfaces->removeInterfaceOption(QString("wireless_key")); |
291 | } | 291 | } |
292 | interfaces->removeInterfaceOption(QString("wireless_enc")); | 292 | interfaces->removeInterfaceOption(QString("wireless_enc")); |
293 | 293 | ||
294 | if(!interfaceSetup->saveChanges()) | 294 | if(!interfaceSetup->saveChanges()) |
295 | return; | 295 | return; |
296 | 296 | ||
297 | QDialog::accept(); | 297 | QDialog::accept(); |
298 | } | 298 | } |
299 | 299 | ||
300 | /* | 300 | /* |
301 | * Scan for possible wireless networks around... | 301 | * Scan for possible wireless networks around... |
302 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> | 302 | * ... powered by Wellenreiter II technology (C) Michael 'Mickey' Lauer <mickeyl@handhelds.org> |
303 | */ | 303 | */ |
304 | 304 | ||
305 | void WLANImp::rescanNeighbourhood() | 305 | void WLANImp::rescanNeighbourhood() |
306 | { | 306 | { |
307 | QString name = interface->getInterfaceName(); | 307 | QString name = interface->getInterfaceName(); |
308 | qDebug( "rescanNeighbourhood via '%s'", (const char*) name ); | 308 | qDebug( "rescanNeighbourhood via '%s'", (const char*) name ); |
309 | 309 | ||
310 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); | 310 | OWirelessNetworkInterface* wiface = static_cast<OWirelessNetworkInterface*>( ONetwork::instance()->interface( name ) ); |
311 | assert( wiface ); | 311 | assert( wiface ); |
312 | 312 | ||
313 | // try to guess device type | 313 | // try to guess device type |
314 | QString devicetype; | 314 | QString devicetype; |
315 | QFile m( "/proc/modules" ); | 315 | QFile m( "/proc/modules" ); |
316 | if ( m.open( IO_ReadOnly ) ) | 316 | if ( m.open( IO_ReadOnly ) ) |
317 | { | 317 | { |
318 | QString line; | 318 | QString line; |
319 | QTextStream modules( &m ); | 319 | QTextStream modules( &m ); |
320 | while( !modules.atEnd() && !devicetype ) | 320 | while( !modules.atEnd() && !devicetype ) |
321 | { | 321 | { |
322 | modules >> line; | 322 | modules >> line; |
323 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; | 323 | if ( line.contains( "cisco" ) ) devicetype = "cisco"; |
324 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; | 324 | else if ( line.contains( "hostap" ) ) devicetype = "hostap"; |
325 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ | 325 | else if ( line.contains( "prism" ) ) devicetype = "wlan-ng"; /* puke */ |
326 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; | 326 | else if ( line.contains( "orinoco" ) ) devicetype = "orinoco"; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | if ( devicetype.isEmpty() ) | 329 | if ( devicetype.isEmpty() ) |
330 | { | 330 | { |
331 | qWarning( "rescanNeighbourhood(): couldn't guess device type :(" ); | 331 | qWarning( "rescanNeighbourhood(): couldn't guess device type :(" ); |
332 | return; | 332 | return; |
333 | } | 333 | } |
334 | else | 334 | else |
335 | { | 335 | { |
336 | qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype ); | 336 | qDebug( "rescanNeighbourhood(): device type seems to be '%s'", (const char*) devicetype ); |
337 | } | 337 | } |
338 | 338 | ||
339 | // configure interface to receive 802.11 management frames | 339 | // configure interface to receive 802.11 management frames |
340 | 340 | ||
341 | wiface->setUp( true ); | 341 | wiface->setUp( true ); |
342 | wiface->setPromiscuousMode( true ); | 342 | wiface->setPromiscuousMode( true ); |
343 | 343 | ||
344 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); | 344 | if ( devicetype == "cisco" ) wiface->setMonitoring( new OCiscoMonitoringInterface( wiface, false ) ); |
345 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); | 345 | else if ( devicetype == "hostap" ) wiface->setMonitoring( new OHostAPMonitoringInterface( wiface, false ) ); |
346 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); | 346 | else if ( devicetype == "wlan-ng" ) wiface->setMonitoring( new OWlanNGMonitoringInterface( wiface, false ) ); |
347 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); | 347 | else if ( devicetype == "orinoco" ) wiface->setMonitoring( new OOrinocoMonitoringInterface( wiface, false ) ); |
348 | else | 348 | else |
349 | { | 349 | { |
350 | qDebug( "rescanNeighbourhood(): unsupported device type for monitoring :(" ); | 350 | qDebug( "rescanNeighbourhood(): unsupported device type for monitoring :(" ); |
351 | return; | 351 | return; |
352 | } | 352 | } |
353 | 353 | ||
354 | wiface->setMode( "monitor" ); | 354 | wiface->setMode( "monitor" ); |
355 | if ( wiface->mode() != "monitor" ) | 355 | if ( wiface->mode() != "monitor" ) |
356 | { | 356 | { |
357 | qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) ); | 357 | qWarning( "rescanNeighbourhood(): Unable to bring device into monitor mode (%s).", strerror( errno ) ); |
358 | return; | 358 | return; |
359 | } | 359 | } |
360 | 360 | ||
361 | // open a packet capturer | 361 | // open a packet capturer |
362 | OPacketCapturer* cap = new OPacketCapturer(); | 362 | OPacketCapturer* cap = new OPacketCapturer(); |
363 | cap->open( name ); | 363 | cap->open( name ); |
364 | if ( !cap->isOpen() ) | 364 | if ( !cap->isOpen() ) |
365 | { | 365 | { |
366 | qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) ); | 366 | qWarning( "rescanNeighbourhood(): Unable to open libpcap (%s).", strerror( errno ) ); |
367 | return; | 367 | return; |
368 | } | 368 | } |
369 | 369 | ||
370 | // display splash screen | 370 | // display splash screen |
371 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); | 371 | QFrame* splash = new QFrame( this, "splash", false, WStyle_StaysOnTop | WStyle_DialogBorder | WStyle_Customize ); |
372 | splash->setLineWidth( 2 ); | 372 | splash->setLineWidth( 2 ); |
373 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); | 373 | splash->setFrameStyle( QFrame::Panel | QFrame::Raised ); |
374 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); | 374 | QVBoxLayout* vbox = new QVBoxLayout( splash, 4, 4 ); |
375 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); | 375 | QLabel* lab = new QLabel( "<center><b>Scanning...</b><br>Please Wait...</center>", splash ); |
376 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); | 376 | QProgressBar* pb = new QProgressBar( wiface->channels(), splash ); |
377 | vbox->addWidget( lab ); | 377 | vbox->addWidget( lab ); |
378 | vbox->addWidget( pb ); | 378 | vbox->addWidget( pb ); |
379 | pb->setCenterIndicator( true ); | 379 | pb->setCenterIndicator( true ); |
380 | pb->setFixedHeight( pb->sizeHint().height() ); | 380 | pb->setFixedHeight( pb->sizeHint().height() ); |
381 | QWidget* widgetDesktop = qApp->desktop(); | 381 | QWidget* widgetDesktop = qApp->desktop(); |
382 | int dw = widgetDesktop->width(); | 382 | int dw = widgetDesktop->width(); |
383 | int dh = widgetDesktop->height(); | 383 | int dh = widgetDesktop->height(); |
384 | int pw = vbox->sizeHint().width(); | 384 | int pw = vbox->sizeHint().width(); |
385 | int ph = vbox->sizeHint().height(); | 385 | int ph = vbox->sizeHint().height(); |
386 | splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); | 386 | splash->setGeometry((dw-pw)/2,(dh-ph)/2,pw,ph); |
387 | splash->show(); | 387 | splash->show(); |
388 | splash->raise(); | 388 | splash->raise(); |
389 | qApp->processEvents(); | 389 | qApp->processEvents(); |
390 | 390 | ||
391 | // set capturer to non-blocking mode | 391 | // set capturer to non-blocking mode |
392 | cap->setBlocking( false ); | 392 | cap->setBlocking( false ); |
393 | 393 | ||
394 | for ( int i = 1; i <= wiface->channels(); ++i ) | 394 | for ( int i = 1; i <= wiface->channels(); ++i ) |
395 | { | 395 | { |
396 | wiface->setChannel( i ); | 396 | wiface->setChannel( i ); |
397 | pb->setProgress( i ); | 397 | pb->setProgress( i ); |
398 | qApp->processEvents(); | 398 | qApp->processEvents(); |
399 | qDebug( "rescanNeighbourhood(): listening on channel %d...", i ); | 399 | qDebug( "rescanNeighbourhood(): listening on channel %d...", i ); |
400 | OPacket* p = cap->next( 1000 ); | 400 | OPacket* p = cap->next( 1000 ); |
401 | if ( !p ) | 401 | if ( !p ) |
402 | { | 402 | { |
403 | qDebug( "rescanNeighbourhood(): nothing received on channel %d", i ); | 403 | qDebug( "rescanNeighbourhood(): nothing received on channel %d", i ); |
404 | } | 404 | } |
405 | else | 405 | else |
406 | { | 406 | { |
407 | qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i ); | 407 | qDebug( "rescanNeighbourhood(): TADAA - something came in on channel %d", i ); |
408 | handlePacket( p ); | 408 | handlePacket( p ); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | cap->close(); | 412 | cap->close(); |
413 | wiface->setMode( "managed" ); // TODO: use previous mode | 413 | wiface->setMode( "managed" ); // TODO: use previous mode |
414 | wiface->setPromiscuousMode( false ); | 414 | wiface->setPromiscuousMode( false ); |
415 | 415 | ||
416 | splash->hide(); | 416 | splash->hide(); |
417 | delete splash; | 417 | delete splash; |
418 | 418 | ||
419 | } | 419 | } |
420 | 420 | ||
421 | void WLANImp::handlePacket( OPacket* p ) | 421 | void WLANImp::handlePacket( OPacket* p ) |
422 | { | 422 | { |
423 | 423 | ||
424 | // check if we received a beacon frame | 424 | // check if we received a beacon frame |
425 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 425 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
426 | if ( beacon && beacon->managementType() == "Beacon" ) | 426 | if ( beacon && beacon->managementType() == "Beacon" ) |
427 | { | 427 | { |
428 | 428 | ||
429 | QString type; | 429 | QString type; |
430 | if ( beacon->canIBSS() ) | 430 | if ( beacon->canIBSS() ) |
431 | { | 431 | { |
432 | type = "adhoc"; | 432 | type = "adhoc"; |
433 | } | 433 | } |
434 | else if ( beacon->canESS() ) | 434 | else if ( beacon->canESS() ) |
435 | { | 435 | { |
436 | type = "managed"; | 436 | type = "managed"; |
437 | } | 437 | } |
438 | else | 438 | else |
439 | { | 439 | { |
440 | qWarning( "handlePacket(): invalid frame [possibly noise] detected!" ); | 440 | qWarning( "handlePacket(): invalid frame [possibly noise] detected!" ); |
441 | return; | 441 | return; |
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp index 0da9d19..eeed398 100644 --- a/noncore/settings/packagemanager/filterdlg.cpp +++ b/noncore/settings/packagemanager/filterdlg.cpp | |||
@@ -1,179 +1,179 @@ | |||
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 "filterdlg.h" | 30 | #include "filterdlg.h" |
31 | 31 | ||
32 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, | 32 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, |
33 | const QString &server, const QString &destination, | 33 | const QString &server, const QString &destination, |
34 | OPackageManager::Status status, const QString &category ) | 34 | OPackageManager::Status status, const QString &category ) |
35 | : QDialog( parent, QString::null, true ) | 35 | : QDialog( parent, QString::null, true ) |
36 | { | 36 | { |
37 | setCaption( tr( "Filter packages" ) ); | 37 | setCaption( tr( "Filter packages" ) ); |
38 | 38 | ||
39 | QVBoxLayout *layout = new QVBoxLayout( this ); | 39 | QVBoxLayout *layout = new QVBoxLayout( this ); |
40 | QScrollView *sv = new QScrollView( this ); | 40 | QScrollView *sv = new QScrollView( this ); |
41 | layout->addWidget( sv, 0, 0 ); | 41 | layout->addWidget( sv, 0, 0 ); |
42 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 42 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
43 | sv->setFrameStyle( QFrame::NoFrame ); | 43 | sv->setFrameStyle( QFrame::NoFrame ); |
44 | QWidget *container = new QWidget( sv->viewport() ); | 44 | QWidget *container = new QWidget( sv->viewport() ); |
45 | sv->addChild( container ); | 45 | sv->addChild( container ); |
46 | layout = new QVBoxLayout( container, 4, 4 ); | 46 | layout = new QVBoxLayout( container, 4, 4 ); |
47 | 47 | ||
48 | // Category | 48 | // Category |
49 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); | 49 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); |
50 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); | 50 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); |
51 | m_category = new QComboBox( container ); | 51 | m_category = new QComboBox( container ); |
52 | m_category->insertStringList( pm->categories() ); | 52 | m_category->insertStringList( pm->categories() ); |
53 | initItem( m_category, m_categoryCB, category ); | 53 | initItem( m_category, m_categoryCB, category ); |
54 | layout->addWidget( m_categoryCB ); | 54 | layout->addWidget( m_categoryCB ); |
55 | layout->addWidget( m_category ); | 55 | layout->addWidget( m_category ); |
56 | 56 | ||
57 | // Package name | 57 | // Package name |
58 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); | 58 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); |
59 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); | 59 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); |
60 | m_name = new QLineEdit( name, container ); | 60 | m_name = new QLineEdit( name, container ); |
61 | if ( !name.isNull() ) | 61 | if ( !name.isNull() ) |
62 | m_nameCB->setChecked( true ); | 62 | m_nameCB->setChecked( true ); |
63 | m_name->setEnabled( !name.isNull() ); | 63 | m_name->setEnabled( !name.isNull() ); |
64 | layout->addWidget( m_nameCB ); | 64 | layout->addWidget( m_nameCB ); |
65 | layout->addWidget( m_name ); | 65 | layout->addWidget( m_name ); |
66 | 66 | ||
67 | // Status | 67 | // Status |
68 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); | 68 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); |
69 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); | 69 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); |
70 | m_status = new QComboBox( container ); | 70 | m_status = new QComboBox( container ); |
71 | connect( m_status, SIGNAL(activated(const QString &)), this, SLOT(slotStatusChanged(const QString &)) ); | 71 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); |
72 | QString currStatus; | 72 | QString currStatus; |
73 | switch ( status ) | 73 | switch ( status ) |
74 | { | 74 | { |
75 | case OPackageManager::All : currStatus = tr( "All" ); | 75 | case OPackageManager::All : currStatus = tr( "All" ); |
76 | break; | 76 | break; |
77 | case OPackageManager::Installed : currStatus = tr( "Installed" ); | 77 | case OPackageManager::Installed : currStatus = tr( "Installed" ); |
78 | break; | 78 | break; |
79 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); | 79 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); |
80 | break; | 80 | break; |
81 | case OPackageManager::Updated : currStatus = tr( "Updated" ); | 81 | case OPackageManager::Updated : currStatus = tr( "Updated" ); |
82 | break; | 82 | break; |
83 | default : currStatus = QString::null; | 83 | default : currStatus = QString::null; |
84 | }; | 84 | }; |
85 | m_status->insertItem( tr( "All" ) ); | 85 | m_status->insertItem( tr( "All" ) ); |
86 | m_status->insertItem( tr( "Installed" ) ); | 86 | m_status->insertItem( tr( "Installed" ) ); |
87 | m_status->insertItem( tr( "Not installed" ) ); | 87 | m_status->insertItem( tr( "Not installed" ) ); |
88 | m_status->insertItem( tr( "Updated" ) ); | 88 | m_status->insertItem( tr( "Updated" ) ); |
89 | initItem( m_status, m_statusCB, currStatus ); | 89 | initItem( m_status, m_statusCB, currStatus ); |
90 | layout->addWidget( m_statusCB ); | 90 | layout->addWidget( m_statusCB ); |
91 | layout->addWidget( m_status ); | 91 | layout->addWidget( m_status ); |
92 | 92 | ||
93 | // Server | 93 | // Server |
94 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); | 94 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); |
95 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); | 95 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); |
96 | m_server = new QComboBox( container ); | 96 | m_server = new QComboBox( container ); |
97 | m_server->insertStringList( *(pm->servers()) ); | 97 | m_server->insertStringList( *(pm->servers()) ); |
98 | initItem( m_server, m_serverCB, server ); | 98 | initItem( m_server, m_serverCB, server ); |
99 | layout->addWidget( m_serverCB ); | 99 | layout->addWidget( m_serverCB ); |
100 | layout->addWidget( m_server ); | 100 | layout->addWidget( m_server ); |
101 | 101 | ||
102 | // Destination | 102 | // Destination |
103 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); | 103 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); |
104 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); | 104 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); |
105 | m_destination = new QComboBox( container ); | 105 | m_destination = new QComboBox( container ); |
106 | m_destination->insertStringList( *(pm->destinations()) ); | 106 | m_destination->insertStringList( *(pm->destinations()) ); |
107 | initItem( m_destination, m_destCB, destination ); | 107 | initItem( m_destination, m_destCB, destination ); |
108 | layout->addWidget( m_destCB ); | 108 | layout->addWidget( m_destCB ); |
109 | layout->addWidget( m_destination ); | 109 | layout->addWidget( m_destination ); |
110 | 110 | ||
111 | //showMaximized(); | 111 | //showMaximized(); |
112 | } | 112 | } |
113 | 113 | ||
114 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) | 114 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) |
115 | { | 115 | { |
116 | if ( !selection.isNull() ) | 116 | if ( !selection.isNull() ) |
117 | { | 117 | { |
118 | checkBox->setChecked( true ); | 118 | checkBox->setChecked( true ); |
119 | 119 | ||
120 | for ( int i = 0; i < comboBox->count(); i++ ) | 120 | for ( int i = 0; i < comboBox->count(); i++ ) |
121 | { | 121 | { |
122 | if ( comboBox->text( i ) == selection ) | 122 | if ( comboBox->text( i ) == selection ) |
123 | { | 123 | { |
124 | comboBox->setCurrentItem( i ); | 124 | comboBox->setCurrentItem( i ); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | comboBox->setEnabled( !selection.isNull() ); | 129 | comboBox->setEnabled( !selection.isNull() ); |
130 | } | 130 | } |
131 | 131 | ||
132 | void FilterDlg::slotNameSelected( bool selected ) | 132 | void FilterDlg::slotNameSelected( bool selected ) |
133 | { | 133 | { |
134 | m_name->setEnabled( selected ); | 134 | m_name->setEnabled( selected ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void FilterDlg::slotServerSelected( bool selected ) | 137 | void FilterDlg::slotServerSelected( bool selected ) |
138 | { | 138 | { |
139 | m_server->setEnabled( selected ); | 139 | m_server->setEnabled( selected ); |
140 | } | 140 | } |
141 | 141 | ||
142 | void FilterDlg::slotDestSelected( bool selected ) | 142 | void FilterDlg::slotDestSelected( bool selected ) |
143 | { | 143 | { |
144 | m_destination->setEnabled( selected ); | 144 | m_destination->setEnabled( selected ); |
145 | } | 145 | } |
146 | 146 | ||
147 | void FilterDlg::slotStatusSelected( bool selected ) | 147 | void FilterDlg::slotStatusSelected( bool selected ) |
148 | { | 148 | { |
149 | m_status->setEnabled( selected ); | 149 | m_status->setEnabled( selected ); |
150 | 150 | ||
151 | if ( !selected && !m_destCB->isEnabled() ) | 151 | if ( !selected && !m_destCB->isEnabled() ) |
152 | { | 152 | { |
153 | // If status check box has been deselected and destination option was previously deselected | 153 | // If status check box has been deselected and destination option was previously deselected |
154 | // (because status == "Not installed"), re-enable destination option | 154 | // (because status == "Not installed"), re-enable destination option |
155 | m_destCB->setEnabled( true ); | 155 | m_destCB->setEnabled( true ); |
156 | m_destination->setEnabled( true ); | 156 | m_destination->setEnabled( true ); |
157 | } | 157 | } |
158 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) | 158 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) |
159 | { | 159 | { |
160 | // If status check box has been selected and status == "Not installed", disable destination option | 160 | // If status check box has been selected and status == "Not installed", disable destination option |
161 | m_destCB->setEnabled( false ); | 161 | m_destCB->setEnabled( false ); |
162 | m_destCB->setChecked( false ); | 162 | m_destCB->setChecked( false ); |
163 | m_destination->setEnabled( false ); | 163 | m_destination->setEnabled( false ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | void FilterDlg::slotStatusChanged( const QString &category ) | 167 | void FilterDlg::slotStatusChanged( const QString &category ) |
168 | { | 168 | { |
169 | bool notInstalled = ( category == tr( "Not installed" ) ); | 169 | bool notInstalled = ( category == tr( "Not installed" ) ); |
170 | m_destCB->setEnabled( !notInstalled ); | 170 | m_destCB->setEnabled( !notInstalled ); |
171 | m_destination->setEnabled( !notInstalled ); | 171 | m_destination->setEnabled( !notInstalled ); |
172 | if ( notInstalled ) | 172 | if ( notInstalled ) |
173 | m_destCB->setChecked( false ); | 173 | m_destCB->setChecked( false ); |
174 | } | 174 | } |
175 | 175 | ||
176 | void FilterDlg::slotCategorySelected( bool selected ) | 176 | void FilterDlg::slotCategorySelected( bool selected ) |
177 | { | 177 | { |
178 | m_category->setEnabled( selected ); | 178 | m_category->setEnabled( selected ); |
179 | } | 179 | } |
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 8fd960f..b334bca 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -1,538 +1,538 @@ | |||
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 <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qtoolbar.h> | 38 | #include <qtoolbar.h> |
39 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
40 | 40 | ||
41 | #include <qpe/qcopenvelope_qws.h> | 41 | #include <qpe/qcopenvelope_qws.h> |
42 | #include <qpe/qpeapplication.h> | 42 | #include <qpe/qpeapplication.h> |
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | 44 | ||
45 | #include "mainwindow.h" | 45 | #include "mainwindow.h" |
46 | #include "installdlg.h" | 46 | #include "installdlg.h" |
47 | #include "filterdlg.h" | 47 | #include "filterdlg.h" |
48 | #include "promptdlg.h" | 48 | #include "promptdlg.h" |
49 | #include "entrydlg.h" | 49 | #include "entrydlg.h" |
50 | #include "packageinfodlg.h" | 50 | #include "packageinfodlg.h" |
51 | 51 | ||
52 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | 52 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) |
53 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 53 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
54 | , m_config( "packman" ) | 54 | , m_config( "packman" ) |
55 | , m_packman( &m_config, this ) | 55 | , m_packman( &m_config, this ) |
56 | , m_menuBar( this ) | 56 | , m_menuBar( this ) |
57 | , m_toolBar( this ) | 57 | , m_toolBar( this ) |
58 | , m_findBar( this ) | 58 | , m_findBar( this ) |
59 | , m_widgetStack( this ) | 59 | , m_widgetStack( this ) |
60 | , m_packageList( this ) | 60 | , m_packageList( this ) |
61 | , m_statusWidget( this ) | 61 | , m_statusWidget( this ) |
62 | , m_statusText( &m_statusWidget ) | 62 | , m_statusText( &m_statusWidget ) |
63 | , m_statusBar( &m_statusWidget ) | 63 | , m_statusBar( &m_statusWidget ) |
64 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) | 64 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) |
65 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) | 65 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) |
66 | , m_iconNull( m_iconUpdated.size() ) | 66 | , m_iconNull( m_iconUpdated.size() ) |
67 | , m_filterName( QString::null ) | 67 | , m_filterName( QString::null ) |
68 | , m_filterServer( QString::null ) | 68 | , m_filterServer( QString::null ) |
69 | , m_filterDest( QString::null ) | 69 | , m_filterDest( QString::null ) |
70 | , m_filterStatus( OPackageManager::NotDefined ) | 70 | , m_filterStatus( OPackageManager::NotDefined ) |
71 | , m_filterCategory( QString::null ) | 71 | , m_filterCategory( QString::null ) |
72 | 72 | ||
73 | { | 73 | { |
74 | // setCaption( tr( "Package Manager" ) ); | 74 | // setCaption( tr( "Package Manager" ) ); |
75 | 75 | ||
76 | m_iconNull.fill( colorGroup().base() ); | 76 | m_iconNull.fill( colorGroup().base() ); |
77 | 77 | ||
78 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); | 78 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); |
79 | 79 | ||
80 | // Initialize widget stack, package list and status widget | 80 | // Initialize widget stack, package list and status widget |
81 | initStatusWidget(); | 81 | initStatusWidget(); |
82 | initPackageList(); | 82 | initPackageList(); |
83 | 83 | ||
84 | m_widgetStack.addWidget( &m_statusWidget, 2 ); | 84 | m_widgetStack.addWidget( &m_statusWidget, 2 ); |
85 | m_widgetStack.addWidget( &m_packageList, 1 ); | 85 | m_widgetStack.addWidget( &m_packageList, 1 ); |
86 | setCentralWidget( &m_widgetStack ); | 86 | setCentralWidget( &m_widgetStack ); |
87 | 87 | ||
88 | // Initialize remaining user interface items | 88 | // Initialize remaining user interface items |
89 | initUI(); | 89 | initUI(); |
90 | 90 | ||
91 | // Initialize package information | 91 | // Initialize package information |
92 | QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); | 92 | QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); |
93 | } | 93 | } |
94 | 94 | ||
95 | void MainWindow::closeEvent( QCloseEvent *event ) | 95 | void MainWindow::closeEvent( QCloseEvent *event ) |
96 | { | 96 | { |
97 | // Close app only if either the package or status widgets are currently active | 97 | // Close app only if either the package or status widgets are currently active |
98 | bool close = m_widgetStack.visibleWidget() == &m_packageList || | 98 | bool close = m_widgetStack.visibleWidget() == &m_packageList || |
99 | m_widgetStack.visibleWidget() == &m_statusWidget; | 99 | m_widgetStack.visibleWidget() == &m_statusWidget; |
100 | if ( close ) | 100 | if ( close ) |
101 | { | 101 | { |
102 | // TODO - write out application configuration settings | 102 | // TODO - write out application configuration settings |
103 | 103 | ||
104 | // Write out package manager configuration settings | 104 | // Write out package manager configuration settings |
105 | m_packman.saveSettings(); | 105 | m_packman.saveSettings(); |
106 | event->accept(); | 106 | event->accept(); |
107 | } | 107 | } |
108 | else | 108 | else |
109 | { | 109 | { |
110 | delete m_widgetStack.visibleWidget(); | 110 | delete m_widgetStack.visibleWidget(); |
111 | m_widgetStack.raiseWidget( &m_packageList ); | 111 | m_widgetStack.raiseWidget( &m_packageList ); |
112 | event->ignore(); | 112 | event->ignore(); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | void MainWindow::initPackageList() | 116 | void MainWindow::initPackageList() |
117 | { | 117 | { |
118 | m_packageList.addColumn( tr( "Packages" ) ); | 118 | m_packageList.addColumn( tr( "Packages" ) ); |
119 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 119 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
120 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); | 120 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); |
121 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 121 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
122 | this, SLOT(slotDisplayPackageInfo(QListViewItem *)) ); | 122 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); |
123 | } | 123 | } |
124 | 124 | ||
125 | void MainWindow::initStatusWidget() | 125 | void MainWindow::initStatusWidget() |
126 | { | 126 | { |
127 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); | 127 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); |
128 | 128 | ||
129 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 129 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
130 | layout->addWidget( &m_statusText ); | 130 | layout->addWidget( &m_statusText ); |
131 | 131 | ||
132 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); | 132 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); |
133 | connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) ); | 133 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); |
134 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); | 134 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); |
135 | 135 | ||
136 | layout->addWidget( &m_statusBar ); | 136 | layout->addWidget( &m_statusBar ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void MainWindow::initUI() | 139 | void MainWindow::initUI() |
140 | { | 140 | { |
141 | // Build menu and tool bars | 141 | // Build menu and tool bars |
142 | setToolBarsMovable( false ); | 142 | setToolBarsMovable( false ); |
143 | 143 | ||
144 | m_menuBar.setHorizontalStretchable( true ); | 144 | m_menuBar.setHorizontalStretchable( true ); |
145 | QMenuBar *mb = new QMenuBar( &m_menuBar ); | 145 | QMenuBar *mb = new QMenuBar( &m_menuBar ); |
146 | mb->setMargin( 0 ); | 146 | mb->setMargin( 0 ); |
147 | 147 | ||
148 | // Find toolbar | 148 | // Find toolbar |
149 | addToolBar( &m_findBar, QMainWindow::Top, true ); | 149 | addToolBar( &m_findBar, QMainWindow::Top, true ); |
150 | m_findBar.setHorizontalStretchable( true ); | 150 | m_findBar.setHorizontalStretchable( true ); |
151 | m_findEdit = new QLineEdit( &m_findBar ); | 151 | m_findEdit = new QLineEdit( &m_findBar ); |
152 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); | 152 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); |
153 | m_findBar.setStretchableWidget( m_findEdit ); | 153 | m_findBar.setStretchableWidget( m_findEdit ); |
154 | connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) ); | 154 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); |
155 | 155 | ||
156 | // Packages menu | 156 | // Packages menu |
157 | QPopupMenu *popup = new QPopupMenu( this ); | 157 | QPopupMenu *popup = new QPopupMenu( this ); |
158 | 158 | ||
159 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); | 159 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); |
160 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 160 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
161 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); | 161 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); |
162 | a->addTo( popup ); | 162 | a->addTo( popup ); |
163 | a->addTo( &m_toolBar ); | 163 | a->addTo( &m_toolBar ); |
164 | 164 | ||
165 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); | 165 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); |
166 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 166 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
167 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); | 167 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); |
168 | actionUpgrade->addTo( popup ); | 168 | actionUpgrade->addTo( popup ); |
169 | actionUpgrade->addTo( &m_toolBar ); | 169 | actionUpgrade->addTo( &m_toolBar ); |
170 | 170 | ||
171 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); | 171 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); |
172 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); | 172 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); |
173 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 173 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
174 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 174 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
175 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); | 175 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); |
176 | actionDownload->addTo( popup ); | 176 | actionDownload->addTo( popup ); |
177 | actionDownload->addTo( &m_toolBar ); | 177 | actionDownload->addTo( &m_toolBar ); |
178 | 178 | ||
179 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); | 179 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); |
180 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 180 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
181 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); | 181 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); |
182 | a->addTo( popup ); | 182 | a->addTo( popup ); |
183 | a->addTo( &m_toolBar ); | 183 | a->addTo( &m_toolBar ); |
184 | 184 | ||
185 | popup->insertSeparator(); | 185 | popup->insertSeparator(); |
186 | 186 | ||
187 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 187 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 188 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
189 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); | 189 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); |
190 | a->addTo( popup ); | 190 | a->addTo( popup ); |
191 | mb->insertItem( tr( "Actions" ), popup ); | 191 | mb->insertItem( tr( "Actions" ), popup ); |
192 | 192 | ||
193 | // View menu | 193 | // View menu |
194 | popup = new QPopupMenu( this ); | 194 | popup = new QPopupMenu( this ); |
195 | 195 | ||
196 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 196 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
197 | m_actionShowNotInstalled->setToggleAction( true ); | 197 | m_actionShowNotInstalled->setToggleAction( true ); |
198 | m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 198 | m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
199 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); | 199 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); |
200 | m_actionShowNotInstalled->addTo( popup ); | 200 | m_actionShowNotInstalled->addTo( popup ); |
201 | 201 | ||
202 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 202 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
203 | m_actionShowInstalled->setToggleAction( true ); | 203 | m_actionShowInstalled->setToggleAction( true ); |
204 | m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 204 | m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
205 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); | 205 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); |
206 | m_actionShowInstalled->addTo( popup ); | 206 | m_actionShowInstalled->addTo( popup ); |
207 | 207 | ||
208 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 208 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
209 | m_actionShowUpdated->setToggleAction( true ); | 209 | m_actionShowUpdated->setToggleAction( true ); |
210 | m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 210 | m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
211 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); | 211 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); |
212 | m_actionShowUpdated->addTo( popup ); | 212 | m_actionShowUpdated->addTo( popup ); |
213 | 213 | ||
214 | popup->insertSeparator(); | 214 | popup->insertSeparator(); |
215 | 215 | ||
216 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), | 216 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), |
217 | QString::null, 0, this, 0 ); | 217 | QString::null, 0, this, 0 ); |
218 | m_actionFilter->setToggleAction( true ); | 218 | m_actionFilter->setToggleAction( true ); |
219 | m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) ); | 219 | m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) ); |
220 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); | 220 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); |
221 | m_actionFilter->addTo( popup ); | 221 | m_actionFilter->addTo( popup ); |
222 | 222 | ||
223 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); | 223 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); |
224 | a->setWhatsThis( tr( "Click here to change the package filter criteria." ) ); | 224 | a->setWhatsThis( tr( "Click here to change the package filter criteria." ) ); |
225 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); | 225 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); |
226 | a->addTo( popup ); | 226 | a->addTo( popup ); |
227 | 227 | ||
228 | popup->insertSeparator(); | 228 | popup->insertSeparator(); |
229 | 229 | ||
230 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 230 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
231 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 231 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
232 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); | 232 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); |
233 | a->addTo( popup ); | 233 | a->addTo( popup ); |
234 | 234 | ||
235 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 235 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
236 | m_actionFindNext->setEnabled( false ); | 236 | m_actionFindNext->setEnabled( false ); |
237 | m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 237 | m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
238 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); | 238 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); |
239 | m_actionFindNext->addTo( popup ); | 239 | m_actionFindNext->addTo( popup ); |
240 | m_actionFindNext->addTo( &m_findBar ); | 240 | m_actionFindNext->addTo( &m_findBar ); |
241 | 241 | ||
242 | mb->insertItem( tr( "View" ), popup ); | 242 | mb->insertItem( tr( "View" ), popup ); |
243 | 243 | ||
244 | // Finish find toolbar creation | 244 | // Finish find toolbar creation |
245 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 245 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
246 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 246 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
247 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); | 247 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); |
248 | a->addTo( &m_findBar ); | 248 | a->addTo( &m_findBar ); |
249 | m_findBar.hide(); | 249 | m_findBar.hide(); |
250 | } | 250 | } |
251 | 251 | ||
252 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) | 252 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) |
253 | { | 253 | { |
254 | if ( clearList ) | 254 | if ( clearList ) |
255 | m_packageList.clear(); | 255 | m_packageList.clear(); |
256 | 256 | ||
257 | if ( packages ) | 257 | if ( packages ) |
258 | { | 258 | { |
259 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) | 259 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) |
260 | { | 260 | { |
261 | OPackage *package = packageIt.current(); | 261 | OPackage *package = packageIt.current(); |
262 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), | 262 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), |
263 | QCheckListItem::CheckBox ); | 263 | QCheckListItem::CheckBox ); |
264 | m_packageList.insertItem( item ); | 264 | m_packageList.insertItem( item ); |
265 | 265 | ||
266 | // If a different version of package is available, show update available icon | 266 | // If a different version of package is available, show update available icon |
267 | // Otherwise, show installed icon | 267 | // Otherwise, show installed icon |
268 | if ( !package->versionInstalled().isNull() ) | 268 | if ( !package->versionInstalled().isNull() ) |
269 | { | 269 | { |
270 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 270 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
271 | item->setPixmap( 0, m_iconUpdated ); | 271 | item->setPixmap( 0, m_iconUpdated ); |
272 | else | 272 | else |
273 | item->setPixmap( 0, m_iconInstalled ); | 273 | item->setPixmap( 0, m_iconInstalled ); |
274 | } | 274 | } |
275 | else | 275 | else |
276 | item->setPixmap( 0, m_iconNull ); | 276 | item->setPixmap( 0, m_iconNull ); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | void MainWindow::searchForPackage( const QString &text ) | 281 | void MainWindow::searchForPackage( const QString &text ) |
282 | { | 282 | { |
283 | if ( !text.isEmpty() ) | 283 | if ( !text.isEmpty() ) |
284 | { | 284 | { |
285 | // look through package list for text startng at current position | 285 | // look through package list for text startng at current position |
286 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); | 286 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); |
287 | if ( start == 0 ) | 287 | if ( start == 0 ) |
288 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 288 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
289 | 289 | ||
290 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; | 290 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; |
291 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; | 291 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; |
292 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 292 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
293 | { | 293 | { |
294 | if ( item->text().lower().find( text ) != -1 ) | 294 | if ( item->text().lower().find( text ) != -1 ) |
295 | { | 295 | { |
296 | m_packageList.ensureItemVisible( item ); | 296 | m_packageList.ensureItemVisible( item ); |
297 | m_packageList.setCurrentItem( item ); | 297 | m_packageList.setCurrentItem( item ); |
298 | break; | 298 | break; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void MainWindow::initPackageInfo() | 304 | void MainWindow::initPackageInfo() |
305 | { | 305 | { |
306 | m_widgetStack.raiseWidget( &m_statusWidget ); | 306 | m_widgetStack.raiseWidget( &m_statusWidget ); |
307 | 307 | ||
308 | // Load package list | 308 | // Load package list |
309 | m_packman.loadAvailablePackages(); | 309 | m_packman.loadAvailablePackages(); |
310 | m_packman.loadInstalledPackages(); | 310 | m_packman.loadInstalledPackages(); |
311 | 311 | ||
312 | OPackageList *packageList = m_packman.packages(); | 312 | OPackageList *packageList = m_packman.packages(); |
313 | if ( packageList ) | 313 | if ( packageList ) |
314 | { | 314 | { |
315 | loadPackageList( packageList, true ); | 315 | loadPackageList( packageList, true ); |
316 | delete packageList; | 316 | delete packageList; |
317 | } | 317 | } |
318 | 318 | ||
319 | m_widgetStack.raiseWidget( &m_packageList ); | 319 | m_widgetStack.raiseWidget( &m_packageList ); |
320 | } | 320 | } |
321 | 321 | ||
322 | void MainWindow::slotWidgetStackShow( QWidget *widget ) | 322 | void MainWindow::slotWidgetStackShow( QWidget *widget ) |
323 | { | 323 | { |
324 | if ( widget == &m_packageList ) | 324 | if ( widget == &m_packageList ) |
325 | { | 325 | { |
326 | setCaption( tr( "Package Manager" ) ); | 326 | setCaption( tr( "Package Manager" ) ); |
327 | 327 | ||
328 | m_menuBar.show(); | 328 | m_menuBar.show(); |
329 | m_toolBar.show(); | 329 | m_toolBar.show(); |
330 | } | 330 | } |
331 | else | 331 | else |
332 | { | 332 | { |
333 | m_menuBar.hide(); | 333 | m_menuBar.hide(); |
334 | m_toolBar.hide(); | 334 | m_toolBar.hide(); |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | void MainWindow::slotInitStatusBar( int numSteps ) | 338 | void MainWindow::slotInitStatusBar( int numSteps ) |
339 | { | 339 | { |
340 | m_statusBar.setTotalSteps( numSteps ); | 340 | m_statusBar.setTotalSteps( numSteps ); |
341 | } | 341 | } |
342 | 342 | ||
343 | void MainWindow::slotStatusText( const QString &status ) | 343 | void MainWindow::slotStatusText( const QString &status ) |
344 | { | 344 | { |
345 | m_statusText.setText( status ); | 345 | m_statusText.setText( status ); |
346 | } | 346 | } |
347 | 347 | ||
348 | void MainWindow::slotStatusBar( int currStep ) | 348 | void MainWindow::slotStatusBar( int currStep ) |
349 | { | 349 | { |
350 | m_statusBar.setProgress( currStep ); | 350 | m_statusBar.setProgress( currStep ); |
351 | } | 351 | } |
352 | 352 | ||
353 | void MainWindow::slotUpdate() | 353 | void MainWindow::slotUpdate() |
354 | { | 354 | { |
355 | // Create package manager output widget | 355 | // Create package manager output widget |
356 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, | 356 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, |
357 | OPackage::Update ); | 357 | OPackage::Update ); |
358 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 358 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
359 | 359 | ||
360 | // Display widget | 360 | // Display widget |
361 | m_widgetStack.addWidget( dlg, 3 ); | 361 | m_widgetStack.addWidget( dlg, 3 ); |
362 | m_widgetStack.raiseWidget( dlg ); | 362 | m_widgetStack.raiseWidget( dlg ); |
363 | } | 363 | } |
364 | 364 | ||
365 | void MainWindow::slotUpgrade() | 365 | void MainWindow::slotUpgrade() |
366 | { | 366 | { |
367 | // Create package manager output widget | 367 | // Create package manager output widget |
368 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, | 368 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, |
369 | OPackage::Upgrade ); | 369 | OPackage::Upgrade ); |
370 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 370 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
371 | 371 | ||
372 | // Display widget | 372 | // Display widget |
373 | m_widgetStack.addWidget( dlg, 3 ); | 373 | m_widgetStack.addWidget( dlg, 3 ); |
374 | m_widgetStack.raiseWidget( dlg ); | 374 | m_widgetStack.raiseWidget( dlg ); |
375 | } | 375 | } |
376 | 376 | ||
377 | void MainWindow::slotDownload() | 377 | void MainWindow::slotDownload() |
378 | { | 378 | { |
379 | // Retrieve list of packages selected for download (if any) | 379 | // Retrieve list of packages selected for download (if any) |
380 | QStringList *workingPackages = new QStringList(); | 380 | QStringList *workingPackages = new QStringList(); |
381 | 381 | ||
382 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 382 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
383 | item != 0 ; | 383 | item != 0 ; |
384 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 384 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
385 | { | 385 | { |
386 | if ( item->isOn() ) | 386 | if ( item->isOn() ) |
387 | workingPackages->append( item->text() ); | 387 | workingPackages->append( item->text() ); |
388 | } | 388 | } |
389 | 389 | ||
390 | if ( workingPackages->isEmpty() ) | 390 | if ( workingPackages->isEmpty() ) |
391 | { | 391 | { |
392 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 392 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
393 | return; | 393 | return; |
394 | } | 394 | } |
395 | else | 395 | else |
396 | { | 396 | { |
397 | // Download selected packages | 397 | // Download selected packages |
398 | m_config.setGroup( "settings" ); | 398 | m_config.setGroup( "settings" ); |
399 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); | 399 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); |
400 | 400 | ||
401 | bool ok = false; | 401 | bool ok = false; |
402 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); | 402 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); |
403 | if ( ok && !text.isEmpty() ) | 403 | if ( ok && !text.isEmpty() ) |
404 | workingDir = text; // user entered something and pressed ok | 404 | workingDir = text; // user entered something and pressed ok |
405 | else | 405 | else |
406 | return; // user entered nothing or pressed cancel | 406 | return; // user entered nothing or pressed cancel |
407 | 407 | ||
408 | // Store download directory in config file | 408 | // Store download directory in config file |
409 | m_config.writeEntry( "DownloadDir", workingDir ); | 409 | m_config.writeEntry( "DownloadDir", workingDir ); |
410 | 410 | ||
411 | // Get starting directory | 411 | // Get starting directory |
412 | QDir::setCurrent( workingDir ); | 412 | QDir::setCurrent( workingDir ); |
413 | 413 | ||
414 | // Create package manager output widget | 414 | // Create package manager output widget |
415 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, | 415 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, |
416 | OPackage::Download, workingPackages ); | 416 | OPackage::Download, workingPackages ); |
417 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 417 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
418 | 418 | ||
419 | // Display widget | 419 | // Display widget |
420 | m_widgetStack.addWidget( dlg, 3 ); | 420 | m_widgetStack.addWidget( dlg, 3 ); |
421 | m_widgetStack.raiseWidget( dlg ); | 421 | m_widgetStack.raiseWidget( dlg ); |
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | void MainWindow::slotApply() | 425 | void MainWindow::slotApply() |
426 | { | 426 | { |
427 | QStringList *removeList = 0x0; | 427 | QStringList *removeList = 0x0; |
428 | QStringList *installList = 0x0; | 428 | QStringList *installList = 0x0; |
429 | QStringList *upgradeList = 0x0; | 429 | QStringList *upgradeList = 0x0; |
430 | 430 | ||
431 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 431 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
432 | item != 0 ; | 432 | item != 0 ; |
433 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 433 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
434 | { | 434 | { |
435 | if ( item->isOn() ) | 435 | if ( item->isOn() ) |
436 | { | 436 | { |
437 | OPackage *package = m_packman.findPackage( item->text() ); | 437 | OPackage *package = m_packman.findPackage( item->text() ); |
438 | if ( package ) | 438 | if ( package ) |
439 | { | 439 | { |
440 | if ( !package->versionInstalled().isNull() ) | 440 | if ( !package->versionInstalled().isNull() ) |
441 | { | 441 | { |
442 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 442 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
443 | { | 443 | { |
444 | // Remove/upgrade package | 444 | // Remove/upgrade package |
445 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), | 445 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), |
446 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), | 446 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), |
447 | tr( "Remove" ), tr( "Upgrade" ), this ); | 447 | tr( "Remove" ), tr( "Upgrade" ), this ); |
448 | if ( answer == 1 ) // Remove | 448 | if ( answer == 1 ) // Remove |
449 | { | 449 | { |
450 | if ( !removeList ) | 450 | if ( !removeList ) |
451 | removeList = new QStringList(); | 451 | removeList = new QStringList(); |
452 | removeList->append( item->text() ); | 452 | removeList->append( item->text() ); |
453 | } | 453 | } |
454 | else if ( answer == 2 ) // Upgrade | 454 | else if ( answer == 2 ) // Upgrade |
455 | { | 455 | { |
456 | if ( !upgradeList ) | 456 | if ( !upgradeList ) |
457 | upgradeList = new QStringList(); | 457 | upgradeList = new QStringList(); |
458 | upgradeList->append( item->text() ); | 458 | upgradeList->append( item->text() ); |
459 | } | 459 | } |
460 | } | 460 | } |
461 | else | 461 | else |
462 | { | 462 | { |
463 | // Remove/reinstall package | 463 | // Remove/reinstall package |
464 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), | 464 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), |
465 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), | 465 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), |
466 | tr( "Remove" ), tr( "Reinstall" ), this ); | 466 | tr( "Remove" ), tr( "Reinstall" ), this ); |
467 | if ( answer == 1 ) // Remove | 467 | if ( answer == 1 ) // Remove |
468 | { | 468 | { |
469 | if ( !removeList ) | 469 | if ( !removeList ) |
470 | removeList = new QStringList(); | 470 | removeList = new QStringList(); |
471 | removeList->append( item->text() ); | 471 | removeList->append( item->text() ); |
472 | } | 472 | } |
473 | else if ( answer == 2 ) // Reinstall | 473 | else if ( answer == 2 ) // Reinstall |
474 | { | 474 | { |
475 | if ( !installList ) | 475 | if ( !installList ) |
476 | installList = new QStringList(); | 476 | installList = new QStringList(); |
477 | installList->append( item->text() ); | 477 | installList->append( item->text() ); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | } | 480 | } |
481 | else | 481 | else |
482 | { | 482 | { |
483 | // Install package | 483 | // Install package |
484 | if ( !installList ) | 484 | if ( !installList ) |
485 | installList = new QStringList(); | 485 | installList = new QStringList(); |
486 | installList->append( item->text() ); | 486 | installList->append( item->text() ); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | 491 | ||
492 | // If nothing is selected, display message and exit | 492 | // If nothing is selected, display message and exit |
493 | if ( !removeList && !installList && !upgradeList ) | 493 | if ( !removeList && !installList && !upgradeList ) |
494 | { | 494 | { |
495 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 495 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
496 | return; | 496 | return; |
497 | } | 497 | } |
498 | 498 | ||
499 | // Send command only if there are packages to process | 499 | // Send command only if there are packages to process |
500 | OPackage::Command removeCmd = OPackage::NotDefined; | 500 | OPackage::Command removeCmd = OPackage::NotDefined; |
501 | if ( removeList && !removeList->isEmpty() ) | 501 | if ( removeList && !removeList->isEmpty() ) |
502 | removeCmd = OPackage::Remove; | 502 | removeCmd = OPackage::Remove; |
503 | OPackage::Command installCmd = OPackage::NotDefined; | 503 | OPackage::Command installCmd = OPackage::NotDefined; |
504 | if ( installList && !installList->isEmpty() ) | 504 | if ( installList && !installList->isEmpty() ) |
505 | installCmd = OPackage::Install; | 505 | installCmd = OPackage::Install; |
506 | OPackage::Command upgradeCmd = OPackage::NotDefined; | 506 | OPackage::Command upgradeCmd = OPackage::NotDefined; |
507 | if ( upgradeList && !upgradeList->isEmpty() ) | 507 | if ( upgradeList && !upgradeList->isEmpty() ) |
508 | upgradeCmd = OPackage::Upgrade; | 508 | upgradeCmd = OPackage::Upgrade; |
509 | 509 | ||
510 | // Create package manager output widget | 510 | // Create package manager output widget |
511 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, | 511 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, |
512 | removeCmd, removeList, | 512 | removeCmd, removeList, |
513 | installCmd, installList, | 513 | installCmd, installList, |
514 | upgradeCmd, upgradeList ); | 514 | upgradeCmd, upgradeList ); |
515 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 515 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
516 | 516 | ||
517 | // Display widget | 517 | // Display widget |
518 | m_widgetStack.addWidget( dlg, 3 ); | 518 | m_widgetStack.addWidget( dlg, 3 ); |
519 | m_widgetStack.raiseWidget( dlg ); | 519 | m_widgetStack.raiseWidget( dlg ); |
520 | } | 520 | } |
521 | 521 | ||
522 | void MainWindow::slotCloseDlg() | 522 | void MainWindow::slotCloseDlg() |
523 | { | 523 | { |
524 | // Close install dialog | 524 | // Close install dialog |
525 | delete m_widgetStack.visibleWidget(); | 525 | delete m_widgetStack.visibleWidget(); |
526 | 526 | ||
527 | // Reload package list | 527 | // Reload package list |
528 | initPackageInfo(); | 528 | initPackageInfo(); |
529 | 529 | ||
530 | // Update Opie launcher links | 530 | // Update Opie launcher links |
531 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 531 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
532 | QString lf = QString::null; | 532 | QString lf = QString::null; |
533 | e << lf; | 533 | e << lf; |
534 | } | 534 | } |
535 | 535 | ||
536 | void MainWindow::slotConfigure() | 536 | void MainWindow::slotConfigure() |
537 | { | 537 | { |
538 | if ( m_packman.configureDlg( false ) ) | 538 | if ( m_packman.configureDlg( false ) ) |
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 086e91b..1dc23a4 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,509 +1,509 @@ | |||
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 "oipkg.h" | 32 | #include "oipkg.h" |
33 | 33 | ||
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <string.h> | 35 | #include <string.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | 41 | ||
42 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 42 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
43 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 43 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
44 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 44 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
45 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 45 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
46 | 46 | ||
47 | OIpkg *oipkg; | 47 | OIpkg *oipkg; |
48 | 48 | ||
49 | // Ipkg callback functions | 49 | // Ipkg callback functions |
50 | 50 | ||
51 | int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) | 51 | int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) |
52 | { | 52 | { |
53 | oipkg->ipkgMessage( msg ); | 53 | oipkg->ipkgMessage( msg ); |
54 | return 0; | 54 | return 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | char *fIpkgResponse( char */*question*/ ) | 57 | char *fIpkgResponse( char */*question*/ ) |
58 | { | 58 | { |
59 | return 0x0; | 59 | return 0x0; |
60 | } | 60 | } |
61 | 61 | ||
62 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 62 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
63 | { | 63 | { |
64 | oipkg->ipkgStatus( desc ); | 64 | oipkg->ipkgStatus( desc ); |
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 68 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
69 | void */*userdata*/ ) | 69 | void */*userdata*/ ) |
70 | { | 70 | { |
71 | oipkg->ipkgList( desc ); | 71 | oipkg->ipkgList( desc ); |
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 75 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
76 | : QObject( parent, name ) | 76 | : QObject( parent, name ) |
77 | , m_config( config ) | 77 | , m_config( config ) |
78 | , m_confInfo( NULL ) | 78 | , m_confInfo( NULL ) |
79 | , m_ipkgExecOptions( 0 ) | 79 | , m_ipkgExecOptions( 0 ) |
80 | , m_ipkgExecVerbosity( 1 ) | 80 | , m_ipkgExecVerbosity( 1 ) |
81 | { | 81 | { |
82 | oipkg = this; | 82 | oipkg = this; |
83 | 83 | ||
84 | // Initialize libipkg | 84 | // Initialize libipkg |
85 | if ( ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) | 85 | if ( ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) |
86 | QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) ); | 86 | QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) ); |
87 | 87 | ||
88 | // Default ipkg run-time arguments | 88 | // Default ipkg run-time arguments |
89 | m_ipkgArgs.noaction = false; | 89 | m_ipkgArgs.noaction = false; |
90 | m_ipkgArgs.force_defaults = true; | 90 | m_ipkgArgs.force_defaults = true; |
91 | } | 91 | } |
92 | 92 | ||
93 | OIpkg::~OIpkg() | 93 | OIpkg::~OIpkg() |
94 | { | 94 | { |
95 | // Upon destruction, ensure that items in config list are deleted with list | 95 | // Upon destruction, ensure that items in config list are deleted with list |
96 | if ( m_confInfo ) | 96 | if ( m_confInfo ) |
97 | m_confInfo->setAutoDelete( true ); | 97 | m_confInfo->setAutoDelete( true ); |
98 | 98 | ||
99 | // Free up libipkg resources | 99 | // Free up libipkg resources |
100 | if ( ipkg_deinit( &m_ipkgArgs ) ) | 100 | if ( ipkg_deinit( &m_ipkgArgs ) ) |
101 | QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) ); | 101 | QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) ); |
102 | } | 102 | } |
103 | 103 | ||
104 | OConfItemList *OIpkg::configItems() | 104 | OConfItemList *OIpkg::configItems() |
105 | { | 105 | { |
106 | // Retrieve all configuration items | 106 | // Retrieve all configuration items |
107 | return filterConfItems(); | 107 | return filterConfItems(); |
108 | } | 108 | } |
109 | 109 | ||
110 | OConfItemList *OIpkg::servers() | 110 | OConfItemList *OIpkg::servers() |
111 | { | 111 | { |
112 | // Retrieve only servers | 112 | // Retrieve only servers |
113 | return filterConfItems( OConfItem::Source ); | 113 | return filterConfItems( OConfItem::Source ); |
114 | } | 114 | } |
115 | 115 | ||
116 | OConfItemList *OIpkg::destinations() | 116 | OConfItemList *OIpkg::destinations() |
117 | { | 117 | { |
118 | // Retrieve only destinations | 118 | // Retrieve only destinations |
119 | return filterConfItems( OConfItem::Destination ); | 119 | return filterConfItems( OConfItem::Destination ); |
120 | } | 120 | } |
121 | 121 | ||
122 | OConfItemList *OIpkg::options() | 122 | OConfItemList *OIpkg::options() |
123 | { | 123 | { |
124 | // Retrieve only destinations | 124 | // Retrieve only destinations |
125 | return filterConfItems( OConfItem::Option ); | 125 | return filterConfItems( OConfItem::Option ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void OIpkg::setConfigItems( OConfItemList *configList ) | 128 | void OIpkg::setConfigItems( OConfItemList *configList ) |
129 | { | 129 | { |
130 | if ( m_confInfo ) | 130 | if ( m_confInfo ) |
131 | delete m_confInfo; | 131 | delete m_confInfo; |
132 | 132 | ||
133 | m_confInfo = configList; | 133 | m_confInfo = configList; |
134 | } | 134 | } |
135 | 135 | ||
136 | void OIpkg::saveSettings() | 136 | void OIpkg::saveSettings() |
137 | { | 137 | { |
138 | // Save Ipkg execution options to application configuration file | 138 | // Save Ipkg execution options to application configuration file |
139 | if ( m_config ) | 139 | if ( m_config ) |
140 | { | 140 | { |
141 | m_config->setGroup( "Ipkg" ); | 141 | m_config->setGroup( "Ipkg" ); |
142 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); | 142 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); |
143 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); | 143 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | OPackageList *OIpkg::availablePackages( const QString &server ) | 147 | OPackageList *OIpkg::availablePackages( const QString &server ) |
148 | { | 148 | { |
149 | // Load Ipkg configuration info if not already cached | 149 | // Load Ipkg configuration info if not already cached |
150 | if ( !m_confInfo ) | 150 | if ( !m_confInfo ) |
151 | loadConfiguration(); | 151 | loadConfiguration(); |
152 | 152 | ||
153 | // Build new server list (caller is responsible for deleting) | 153 | // Build new server list (caller is responsible for deleting) |
154 | OPackageList *pl = new OPackageList; | 154 | OPackageList *pl = new OPackageList; |
155 | 155 | ||
156 | // Open package list file | 156 | // Open package list file |
157 | QFile f( IPKG_PKG_PATH + "/" + server ); | 157 | QFile f( IPKG_PKG_PATH + "/" + server ); |
158 | if ( !f.open( IO_ReadOnly ) ) | 158 | if ( !f.open( IO_ReadOnly ) ) |
159 | return NULL; | 159 | return NULL; |
160 | QTextStream t( &f ); | 160 | QTextStream t( &f ); |
161 | 161 | ||
162 | // Process all information in package list file | 162 | // Process all information in package list file |
163 | OPackage *package = NULL; | 163 | OPackage *package = NULL; |
164 | QString line = t.readLine(); | 164 | QString line = t.readLine(); |
165 | while ( !t.eof() ) | 165 | while ( !t.eof() ) |
166 | { | 166 | { |
167 | // Determine key/value pair | 167 | // Determine key/value pair |
168 | int pos = line.find( ':', 0 ); | 168 | int pos = line.find( ':', 0 ); |
169 | QString key; | 169 | QString key; |
170 | if ( pos > -1 ) | 170 | if ( pos > -1 ) |
171 | key = line.mid( 0, pos ); | 171 | key = line.mid( 0, pos ); |
172 | else | 172 | else |
173 | key = QString::null; | 173 | key = QString::null; |
174 | QString value = line.mid( pos+2, line.length()-pos ); | 174 | QString value = line.mid( pos+2, line.length()-pos ); |
175 | 175 | ||
176 | // Allocate new package and insert into list | 176 | // Allocate new package and insert into list |
177 | if ( package == NULL && !key.isEmpty() ) | 177 | if ( package == NULL && !key.isEmpty() ) |
178 | { | 178 | { |
179 | package = new OPackage( value ); | 179 | package = new OPackage( value ); |
180 | package->setSource( server ); | 180 | package->setSource( server ); |
181 | pl->append( package ); | 181 | pl->append( package ); |
182 | } | 182 | } |
183 | 183 | ||
184 | // Update package data | 184 | // Update package data |
185 | if ( key == "Package" ) | 185 | if ( key == "Package" ) |
186 | package->setName( value ); | 186 | package->setName( value ); |
187 | else if ( key == "Version" ) | 187 | else if ( key == "Version" ) |
188 | package->setVersion( value ); | 188 | package->setVersion( value ); |
189 | else if ( key == "Section" ) | 189 | else if ( key == "Section" ) |
190 | package->setCategory( value ); | 190 | package->setCategory( value ); |
191 | //DataManager::setAvailableCategories( value ); | 191 | //DataManager::setAvailableCategories( value ); |
192 | else if ( key.isEmpty() && value.isEmpty() ) | 192 | else if ( key.isEmpty() && value.isEmpty() ) |
193 | package = NULL; | 193 | package = NULL; |
194 | 194 | ||
195 | // Skip past all description lines | 195 | // Skip past all description lines |
196 | if ( key == "Description" ) | 196 | if ( key == "Description" ) |
197 | { | 197 | { |
198 | line = t.readLine(); | 198 | line = t.readLine(); |
199 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 199 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
200 | line = t.readLine(); | 200 | line = t.readLine(); |
201 | } | 201 | } |
202 | else | 202 | else |
203 | line = t.readLine(); | 203 | line = t.readLine(); |
204 | } | 204 | } |
205 | 205 | ||
206 | f.close(); | 206 | f.close(); |
207 | 207 | ||
208 | return pl; | 208 | return pl; |
209 | } | 209 | } |
210 | 210 | ||
211 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 211 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
212 | { | 212 | { |
213 | // Load Ipkg configuration info if not already cached | 213 | // Load Ipkg configuration info if not already cached |
214 | if ( !m_confInfo ) | 214 | if ( !m_confInfo ) |
215 | loadConfiguration(); | 215 | loadConfiguration(); |
216 | 216 | ||
217 | // Build new server list (caller is responsible for deleting) | 217 | // Build new server list (caller is responsible for deleting) |
218 | OPackageList *pl = new OPackageList; | 218 | OPackageList *pl = new OPackageList; |
219 | 219 | ||
220 | // Open status file | 220 | // Open status file |
221 | QString path = destPath; | 221 | QString path = destPath; |
222 | if ( path.right( 1 ) != "/" ) | 222 | if ( path.right( 1 ) != "/" ) |
223 | path.append( "/" ); | 223 | path.append( "/" ); |
224 | path.append( IPKG_STATUS_PATH ); | 224 | path.append( IPKG_STATUS_PATH ); |
225 | 225 | ||
226 | QFile f( path ); | 226 | QFile f( path ); |
227 | if ( !f.open( IO_ReadOnly ) ) | 227 | if ( !f.open( IO_ReadOnly ) ) |
228 | return NULL; | 228 | return NULL; |
229 | QTextStream t( &f ); | 229 | QTextStream t( &f ); |
230 | 230 | ||
231 | // Process all information in status file | 231 | // Process all information in status file |
232 | bool newPackage = false; | 232 | bool newPackage = false; |
233 | QString line = t.readLine(); | 233 | QString line = t.readLine(); |
234 | QString name; | 234 | QString name; |
235 | QString version; | 235 | QString version; |
236 | QString status; | 236 | QString status; |
237 | 237 | ||
238 | while ( !t.eof() ) | 238 | while ( !t.eof() ) |
239 | { | 239 | { |
240 | // Determine key/value pair | 240 | // Determine key/value pair |
241 | int pos = line.find( ':', 0 ); | 241 | int pos = line.find( ':', 0 ); |
242 | QString key; | 242 | QString key; |
243 | if ( pos > -1 ) | 243 | if ( pos > -1 ) |
244 | key = line.mid( 0, pos ); | 244 | key = line.mid( 0, pos ); |
245 | else | 245 | else |
246 | key = QString::null; | 246 | key = QString::null; |
247 | QString value = line.mid( pos+2, line.length()-pos ); | 247 | QString value = line.mid( pos+2, line.length()-pos ); |
248 | 248 | ||
249 | // Allocate new package and insert into list | 249 | // Allocate new package and insert into list |
250 | if ( newPackage && !key.isEmpty() ) | 250 | if ( newPackage && !key.isEmpty() ) |
251 | { | 251 | { |
252 | // Add to list only if it has a valid name and is installed | 252 | // Add to list only if it has a valid name and is installed |
253 | if ( !name.isNull() && status.contains( " installed" ) ) | 253 | if ( !name.isNull() && status.contains( " installed" ) ) |
254 | { | 254 | { |
255 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 255 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
256 | name = QString::null; | 256 | name = QString::null; |
257 | version = QString::null; | 257 | version = QString::null; |
258 | status = QString::null; | 258 | status = QString::null; |
259 | 259 | ||
260 | newPackage = false; | 260 | newPackage = false; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | // Update package data | 264 | // Update package data |
265 | if ( key == "Package" ) | 265 | if ( key == "Package" ) |
266 | name = value; | 266 | name = value; |
267 | else if ( key == "Version" ) | 267 | else if ( key == "Version" ) |
268 | version = value; | 268 | version = value; |
269 | else if ( key == "Status" ) | 269 | else if ( key == "Status" ) |
270 | status = value; | 270 | status = value; |
271 | else if ( key.isEmpty() && value.isEmpty() ) | 271 | else if ( key.isEmpty() && value.isEmpty() ) |
272 | newPackage = true; | 272 | newPackage = true; |
273 | 273 | ||
274 | // Skip past all description lines | 274 | // Skip past all description lines |
275 | if ( key == "Description" ) | 275 | if ( key == "Description" ) |
276 | { | 276 | { |
277 | line = t.readLine(); | 277 | line = t.readLine(); |
278 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 278 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
279 | line = t.readLine(); | 279 | line = t.readLine(); |
280 | } | 280 | } |
281 | else | 281 | else |
282 | line = t.readLine(); | 282 | line = t.readLine(); |
283 | } | 283 | } |
284 | 284 | ||
285 | f.close(); | 285 | f.close(); |
286 | 286 | ||
287 | return pl; | 287 | return pl; |
288 | } | 288 | } |
289 | 289 | ||
290 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, | 290 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, |
291 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 291 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
292 | { | 292 | { |
293 | if ( command == OPackage::NotDefined ) | 293 | if ( command == OPackage::NotDefined ) |
294 | return false; | 294 | return false; |
295 | 295 | ||
296 | // Set ipkg run-time options/arguments | 296 | // Set ipkg run-time options/arguments |
297 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 297 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
298 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 298 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
299 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 299 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
300 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 300 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
301 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 301 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
302 | if ( m_ipkgArgs.dest ) | 302 | if ( m_ipkgArgs.dest ) |
303 | free( m_ipkgArgs.dest ); | 303 | free( m_ipkgArgs.dest ); |
304 | if ( !destination.isNull() ) | 304 | if ( !destination.isNull() ) |
305 | { | 305 | { |
306 | int len = destination.length() + 1; | 306 | int len = destination.length() + 1; |
307 | m_ipkgArgs.dest = (char *)malloc( len ); | 307 | m_ipkgArgs.dest = (char *)malloc( len ); |
308 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 308 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
309 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 309 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
310 | } | 310 | } |
311 | else | 311 | else |
312 | m_ipkgArgs.dest = 0x0; | 312 | m_ipkgArgs.dest = 0x0; |
313 | 313 | ||
314 | // Connect output signal to widget | 314 | // Connect output signal to widget |
315 | 315 | ||
316 | if ( rawOutput ) | 316 | if ( rawOutput ) |
317 | { | 317 | { |
318 | // if ( slotOutput ) | 318 | // if ( slotOutput ) |
319 | // connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 319 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
320 | } | 320 | } |
321 | else | 321 | else |
322 | { | 322 | { |
323 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 323 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
324 | } | 324 | } |
325 | 325 | ||
326 | switch( command ) | 326 | switch( command ) |
327 | { | 327 | { |
328 | case OPackage::Update : { | 328 | case OPackage::Update : { |
329 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 329 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
330 | ipkg_lists_update( &m_ipkgArgs ); | 330 | ipkg_lists_update( &m_ipkgArgs ); |
331 | }; | 331 | }; |
332 | break; | 332 | break; |
333 | case OPackage::Upgrade : { | 333 | case OPackage::Upgrade : { |
334 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 334 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
335 | ipkg_packages_upgrade( &m_ipkgArgs ); | 335 | ipkg_packages_upgrade( &m_ipkgArgs ); |
336 | }; | 336 | }; |
337 | break; | 337 | break; |
338 | case OPackage::Install : { | 338 | case OPackage::Install : { |
339 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 339 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
340 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 340 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
341 | { | 341 | { |
342 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 342 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
343 | } | 343 | } |
344 | }; | 344 | }; |
345 | break; | 345 | break; |
346 | case OPackage::Remove : { | 346 | case OPackage::Remove : { |
347 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 347 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
348 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 348 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
349 | { | 349 | { |
350 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 350 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
351 | } | 351 | } |
352 | }; | 352 | }; |
353 | break; | 353 | break; |
354 | case OPackage::Download : { | 354 | case OPackage::Download : { |
355 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 355 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
356 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 356 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
357 | { | 357 | { |
358 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 358 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
359 | } | 359 | } |
360 | }; | 360 | }; |
361 | break; | 361 | break; |
362 | case OPackage::Info : { | 362 | case OPackage::Info : { |
363 | connect( this, SIGNAL(signalIpkgStatus(char *)), receiver, slotOutput ); | 363 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); |
364 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); | 364 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); |
365 | }; | 365 | }; |
366 | break; | 366 | break; |
367 | case OPackage::Files : { | 367 | case OPackage::Files : { |
368 | connect( this, SIGNAL(signalIpkgList(char *)), receiver, slotOutput ); | 368 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); |
369 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); | 369 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); |
370 | }; | 370 | }; |
371 | break; | 371 | break; |
372 | default : break; | 372 | default : break; |
373 | }; | 373 | }; |
374 | 374 | ||
375 | return true; | 375 | return true; |
376 | } | 376 | } |
377 | 377 | ||
378 | void OIpkg::ipkgMessage( char *msg ) | 378 | void OIpkg::ipkgMessage( char *msg ) |
379 | { | 379 | { |
380 | emit signalIpkgMessage( msg ); | 380 | emit signalIpkgMessage( msg ); |
381 | } | 381 | } |
382 | 382 | ||
383 | void OIpkg::ipkgStatus( char *status ) | 383 | void OIpkg::ipkgStatus( char *status ) |
384 | { | 384 | { |
385 | emit signalIpkgStatus( status ); | 385 | emit signalIpkgStatus( status ); |
386 | } | 386 | } |
387 | 387 | ||
388 | void OIpkg::ipkgList( char *filelist ) | 388 | void OIpkg::ipkgList( char *filelist ) |
389 | { | 389 | { |
390 | emit signalIpkgList( filelist ); | 390 | emit signalIpkgList( filelist ); |
391 | } | 391 | } |
392 | 392 | ||
393 | void OIpkg::loadConfiguration() | 393 | void OIpkg::loadConfiguration() |
394 | { | 394 | { |
395 | if ( m_confInfo ) | 395 | if ( m_confInfo ) |
396 | delete m_confInfo; | 396 | delete m_confInfo; |
397 | 397 | ||
398 | // Load configuration item list | 398 | // Load configuration item list |
399 | m_confInfo = new OConfItemList(); | 399 | m_confInfo = new OConfItemList(); |
400 | 400 | ||
401 | QStringList confFiles; | 401 | QStringList confFiles; |
402 | QDir confDir( IPKG_CONF_DIR ); | 402 | QDir confDir( IPKG_CONF_DIR ); |
403 | if ( confDir.exists() ) | 403 | if ( confDir.exists() ) |
404 | { | 404 | { |
405 | confDir.setNameFilter( "*.conf" ); | 405 | confDir.setNameFilter( "*.conf" ); |
406 | confDir.setFilter( QDir::Files ); | 406 | confDir.setFilter( QDir::Files ); |
407 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 407 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
408 | confFiles << IPKG_CONF; | 408 | confFiles << IPKG_CONF; |
409 | 409 | ||
410 | for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) | 410 | for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) |
411 | { | 411 | { |
412 | // Create absolute file path if necessary | 412 | // Create absolute file path if necessary |
413 | QString absFile = (*it); | 413 | QString absFile = (*it); |
414 | if ( !absFile.startsWith( "/" ) ) | 414 | if ( !absFile.startsWith( "/" ) ) |
415 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 415 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
416 | 416 | ||
417 | // Read in file | 417 | // Read in file |
418 | QFile f( absFile ); | 418 | QFile f( absFile ); |
419 | if ( f.open( IO_ReadOnly ) ) | 419 | if ( f.open( IO_ReadOnly ) ) |
420 | { | 420 | { |
421 | QTextStream s( &f ); | 421 | QTextStream s( &f ); |
422 | while ( !s.eof() ) | 422 | while ( !s.eof() ) |
423 | { | 423 | { |
424 | 424 | ||
425 | QString line = s.readLine().simplifyWhiteSpace(); | 425 | QString line = s.readLine().simplifyWhiteSpace(); |
426 | 426 | ||
427 | // Parse line and save info to the conf options list | 427 | // Parse line and save info to the conf options list |
428 | if ( !line.isEmpty() ) | 428 | if ( !line.isEmpty() ) |
429 | { | 429 | { |
430 | if ( !line.startsWith( "#" ) || | 430 | if ( !line.startsWith( "#" ) || |
431 | line.startsWith( "#src" ) || | 431 | line.startsWith( "#src" ) || |
432 | line.startsWith( "#dest" ) || | 432 | line.startsWith( "#dest" ) || |
433 | line.startsWith( "#arch" ) || | 433 | line.startsWith( "#arch" ) || |
434 | line.startsWith( "#option" ) ) | 434 | line.startsWith( "#option" ) ) |
435 | { | 435 | { |
436 | int pos = line.find( ' ', 1 ); | 436 | int pos = line.find( ' ', 1 ); |
437 | 437 | ||
438 | // Type | 438 | // Type |
439 | QString typeStr = line.left( pos ); | 439 | QString typeStr = line.left( pos ); |
440 | OConfItem::Type type; | 440 | OConfItem::Type type; |
441 | if ( typeStr == "src" || typeStr == "#src" ) | 441 | if ( typeStr == "src" || typeStr == "#src" ) |
442 | type = OConfItem::Source; | 442 | type = OConfItem::Source; |
443 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 443 | else if ( typeStr == "dest" || typeStr == "#dest" ) |
444 | type = OConfItem::Destination; | 444 | type = OConfItem::Destination; |
445 | else if ( typeStr == "option" || typeStr == "#option" ) | 445 | else if ( typeStr == "option" || typeStr == "#option" ) |
446 | type = OConfItem::Option; | 446 | type = OConfItem::Option; |
447 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 447 | else if ( typeStr == "arch" || typeStr == "#arch" ) |
448 | type = OConfItem::Arch; | 448 | type = OConfItem::Arch; |
449 | else | 449 | else |
450 | type = OConfItem::NotDefined; | 450 | type = OConfItem::NotDefined; |
451 | ++pos; | 451 | ++pos; |
452 | int endpos = line.find( ' ', pos ); | 452 | int endpos = line.find( ' ', pos ); |
453 | 453 | ||
454 | // Name | 454 | // Name |
455 | QString name = line.mid( pos, endpos - pos ); | 455 | QString name = line.mid( pos, endpos - pos ); |
456 | 456 | ||
457 | // Value | 457 | // Value |
458 | QString value = ""; | 458 | QString value = ""; |
459 | if ( endpos > -1 ) | 459 | if ( endpos > -1 ) |
460 | value = line.right( line.length() - endpos - 1 ); | 460 | value = line.right( line.length() - endpos - 1 ); |
461 | 461 | ||
462 | // Active | 462 | // Active |
463 | bool active = !line.startsWith( "#" ); | 463 | bool active = !line.startsWith( "#" ); |
464 | 464 | ||
465 | // Add to list | 465 | // Add to list |
466 | m_confInfo->append( new OConfItem( absFile, type, name, value, active ) ); | 466 | m_confInfo->append( new OConfItem( absFile, type, name, value, active ) ); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | } | 469 | } |
470 | 470 | ||
471 | f.close(); | 471 | f.close(); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | // Load Ipkg execution options from application configuration file | 476 | // Load Ipkg execution options from application configuration file |
477 | if ( m_config ) | 477 | if ( m_config ) |
478 | { | 478 | { |
479 | m_config->setGroup( "Ipkg" ); | 479 | m_config->setGroup( "Ipkg" ); |
480 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 480 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
481 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 481 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
485 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 485 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
486 | { | 486 | { |
487 | // Load Ipkg configuration info if not already cached | 487 | // Load Ipkg configuration info if not already cached |
488 | if ( !m_confInfo ) | 488 | if ( !m_confInfo ) |
489 | loadConfiguration(); | 489 | loadConfiguration(); |
490 | 490 | ||
491 | // Build new server list (caller is responsible for deleting) | 491 | // Build new server list (caller is responsible for deleting) |
492 | OConfItemList *sl = new OConfItemList; | 492 | OConfItemList *sl = new OConfItemList; |
493 | 493 | ||
494 | // If typefilter is empty, retrieve all items | 494 | // If typefilter is empty, retrieve all items |
495 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 495 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
496 | 496 | ||
497 | // Parse configuration info for servers | 497 | // Parse configuration info for servers |
498 | OConfItemListIterator it( *m_confInfo ); | 498 | OConfItemListIterator it( *m_confInfo ); |
499 | for ( ; it.current(); ++it ) | 499 | for ( ; it.current(); ++it ) |
500 | { | 500 | { |
501 | OConfItem *item = it.current(); | 501 | OConfItem *item = it.current(); |
502 | if ( retrieveAll || item->type() == typefilter ) | 502 | if ( retrieveAll || item->type() == typefilter ) |
503 | { | 503 | { |
504 | sl->append( item ); | 504 | sl->append( item ); |
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | return sl; | 508 | return sl; |
509 | } | 509 | } |
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp index 4bc86fa..8ad0a3f 100644 --- a/noncore/settings/sound/soundsettings.cpp +++ b/noncore/settings/sound/soundsettings.cpp | |||
@@ -1,220 +1,220 @@ | |||
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 | // parts copyright 2002 L.J. Potter | 20 | // parts copyright 2002 L.J. Potter |
21 | 21 | ||
22 | #include "soundsettings.h" | 22 | #include "soundsettings.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/storage.h> | 27 | #include <qpe/storage.h> |
28 | 28 | ||
29 | #include <qcheckbox.h> | 29 | #include <qcheckbox.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | 32 | ||
33 | #include <sys/utsname.h> | 33 | #include <sys/utsname.h> |
34 | #include <sys/time.h> | 34 | #include <sys/time.h> |
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <stdio.h> | 37 | #include <stdio.h> |
38 | #include <sys/stat.h> | 38 | #include <sys/stat.h> |
39 | 39 | ||
40 | 40 | ||
41 | SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) | 41 | SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) |
42 | : SoundSettingsBase( parent, objname, TRUE, fl ) | 42 | : SoundSettingsBase( parent, objname, TRUE, fl ) |
43 | { | 43 | { |
44 | keyReset=FALSE; | 44 | keyReset=FALSE; |
45 | noWarning=false; | 45 | noWarning=false; |
46 | Config config( "qpe"); | 46 | Config config( "qpe"); |
47 | config.setGroup( "Volume" ); | 47 | config.setGroup( "Volume" ); |
48 | Config cfg("Vmemo"); | 48 | Config cfg("Vmemo"); |
49 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 49 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
50 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); | 50 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); |
51 | 51 | ||
52 | cfg.setGroup("Record"); | 52 | cfg.setGroup("Record"); |
53 | int rate=config.readNumEntry("SampleRate", 22050); | 53 | int rate=config.readNumEntry("SampleRate", 22050); |
54 | if(rate == 8000) | 54 | if(rate == 8000) |
55 | sampleRate->setCurrentItem(0); | 55 | sampleRate->setCurrentItem(0); |
56 | else if(rate == 11025) | 56 | else if(rate == 11025) |
57 | sampleRate->setCurrentItem(1); | 57 | sampleRate->setCurrentItem(1); |
58 | else if(rate == 22050) | 58 | else if(rate == 22050) |
59 | sampleRate->setCurrentItem(2); | 59 | sampleRate->setCurrentItem(2); |
60 | else if(rate == 33075) | 60 | else if(rate == 33075) |
61 | sampleRate->setCurrentItem(3); | 61 | sampleRate->setCurrentItem(3); |
62 | else if(rate==44100) | 62 | else if(rate==44100) |
63 | sampleRate->setCurrentItem(4); | 63 | sampleRate->setCurrentItem(4); |
64 | 64 | ||
65 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); | 65 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); |
66 | //TODO hide if zaurus- mono only | 66 | //TODO hide if zaurus- mono only |
67 | 67 | ||
68 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) | 68 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) |
69 | //since ipaq and zaurus have particular | 69 | //since ipaq and zaurus have particular |
70 | //devices | 70 | //devices |
71 | bool systemZaurus=FALSE; | 71 | bool systemZaurus=FALSE; |
72 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 72 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
73 | if (uname(&name) != -1) {// TODO change this here,... | 73 | if (uname(&name) != -1) {// TODO change this here,... |
74 | QString release=name.release; | 74 | QString release=name.release; |
75 | if( release.find("embedix",0,TRUE) != -1) { | 75 | if( release.find("embedix",0,TRUE) != -1) { |
76 | qDebug("IS System Zaurus"); | 76 | qDebug("IS System Zaurus"); |
77 | systemZaurus=TRUE; | 77 | systemZaurus=TRUE; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | if(!systemZaurus) { | 80 | if(!systemZaurus) { |
81 | stereoCheckBox->setChecked(TRUE); | 81 | stereoCheckBox->setChecked(TRUE); |
82 | } | 82 | } |
83 | stereoCheckBox->setEnabled(FALSE); | 83 | stereoCheckBox->setEnabled(FALSE); |
84 | sixteenBitCheckBox->setEnabled(FALSE); | 84 | sixteenBitCheckBox->setEnabled(FALSE); |
85 | #else | 85 | #else |
86 | #endif | 86 | #endif |
87 | int sRate=cfg.readNumEntry("SizeLimit", 30); | 87 | int sRate=cfg.readNumEntry("SizeLimit", 30); |
88 | qDebug("%d",sRate); | 88 | qDebug("%d",sRate); |
89 | 89 | ||
90 | if(sRate ==30) | 90 | if(sRate ==30) |
91 | timeLimitComboBox->setCurrentItem(0); | 91 | timeLimitComboBox->setCurrentItem(0); |
92 | else if(sRate==20) | 92 | else if(sRate==20) |
93 | timeLimitComboBox->setCurrentItem(1); | 93 | timeLimitComboBox->setCurrentItem(1); |
94 | else if(sRate == 15) | 94 | else if(sRate == 15) |
95 | timeLimitComboBox->setCurrentItem(2); | 95 | timeLimitComboBox->setCurrentItem(2); |
96 | else if(sRate == 10) | 96 | else if(sRate == 10) |
97 | timeLimitComboBox->setCurrentItem(3); | 97 | timeLimitComboBox->setCurrentItem(3); |
98 | else if(sRate == 5) | 98 | else if(sRate == 5) |
99 | timeLimitComboBox->setCurrentItem(4); | 99 | timeLimitComboBox->setCurrentItem(4); |
100 | else | 100 | else |
101 | timeLimitComboBox->setCurrentItem(5); | 101 | timeLimitComboBox->setCurrentItem(5); |
102 | 102 | ||
103 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); | 103 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); |
104 | 104 | ||
105 | cfg.setGroup("Defaults"); | 105 | cfg.setGroup("Defaults"); |
106 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); | 106 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); |
107 | 107 | ||
108 | updateStorageCombo(); | 108 | updateStorageCombo(); |
109 | 109 | ||
110 | Config vmCfg("Vmemo"); | 110 | Config vmCfg("Vmemo"); |
111 | vmCfg.setGroup("Defaults"); | 111 | vmCfg.setGroup("Defaults"); |
112 | adpcmCheckBox->setChecked( vmCfg.readBoolEntry("use_ADPCM", 0)); | 112 | adpcmCheckBox->setChecked( vmCfg.readBoolEntry("use_ADPCM", 0)); |
113 | 113 | ||
114 | connect( LocationComboBox,SIGNAL(activated(const QString &)), this, | 114 | connect( LocationComboBox,SIGNAL(activated(const QString&)), this, |
115 | SLOT( setLocation(const QString &))); | 115 | SLOT( setLocation(const QString&))); |
116 | connect( keyComboBox,SIGNAL(activated( int)), this, | 116 | connect( keyComboBox,SIGNAL(activated(int)), this, |
117 | SLOT( setKeyButton( int))); | 117 | SLOT( setKeyButton(int))); |
118 | connect( timeLimitComboBox,SIGNAL(activated( const QString &)), this, | 118 | connect( timeLimitComboBox,SIGNAL(activated(const QString&)), this, |
119 | SLOT( setSizeLimitButton(const QString &))); | 119 | SLOT( setSizeLimitButton(const QString&))); |
120 | connect( restartCheckBox,SIGNAL( toggled( bool)), this, | 120 | connect( restartCheckBox,SIGNAL( toggled(bool)), this, |
121 | SLOT( restartOpie( bool))); | 121 | SLOT( restartOpie(bool))); |
122 | connect( adpcmCheckBox,SIGNAL( toggled( bool)), this, | 122 | connect( adpcmCheckBox,SIGNAL( toggled(bool)), this, |
123 | SLOT( slotAdpcm( bool))); | 123 | SLOT( slotAdpcm(bool))); |
124 | 124 | ||
125 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 125 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void SoundSettings::updateStorageCombo() { | 128 | void SoundSettings::updateStorageCombo() { |
129 | 129 | ||
130 | Config config( "Vmemo" ); | 130 | Config config( "Vmemo" ); |
131 | config.setGroup( "System" ); | 131 | config.setGroup( "System" ); |
132 | QString loc = config.readEntry("RecLocation","/"); | 132 | QString loc = config.readEntry("RecLocation","/"); |
133 | int i=0; | 133 | int i=0; |
134 | int set=0; | 134 | int set=0; |
135 | StorageInfo storageInfo; | 135 | StorageInfo storageInfo; |
136 | QString sName, sPath; | 136 | QString sName, sPath; |
137 | QStringList list; | 137 | QStringList list; |
138 | list << "Documents : "+QPEApplication::documentDir(); | 138 | list << "Documents : "+QPEApplication::documentDir(); |
139 | list << "tmp : /tmp"; | 139 | list << "tmp : /tmp"; |
140 | 140 | ||
141 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 141 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
142 | QListIterator<FileSystem> it ( fs ); | 142 | QListIterator<FileSystem> it ( fs ); |
143 | for( ; it.current(); ++it ){ | 143 | for( ; it.current(); ++it ){ |
144 | const QString name = (*it)->name(); | 144 | const QString name = (*it)->name(); |
145 | const QString path = (*it)->path(); | 145 | const QString path = (*it)->path(); |
146 | qDebug("storage name "+name +" storage path is "+path); | 146 | qDebug("storage name "+name +" storage path is "+path); |
147 | list << name + ": " +path; | 147 | list << name + ": " +path; |
148 | if( loc.find( path,0,TRUE) != -1) | 148 | if( loc.find( path,0,TRUE) != -1) |
149 | set = i; | 149 | set = i; |
150 | // if(dit.current()->file().find(path) != -1 ) storage=name; | 150 | // if(dit.current()->file().find(path) != -1 ) storage=name; |
151 | i++; | 151 | i++; |
152 | } | 152 | } |
153 | 153 | ||
154 | LocationComboBox->insertStringList(list); | 154 | LocationComboBox->insertStringList(list); |
155 | qDebug("set item %d", set); | 155 | qDebug("set item %d", set); |
156 | LocationComboBox->setCurrentItem(set); | 156 | LocationComboBox->setCurrentItem(set); |
157 | } | 157 | } |
158 | 158 | ||
159 | void SoundSettings::setLocation(const QString & string) { | 159 | void SoundSettings::setLocation(const QString & string) { |
160 | Config config( "Vmemo" ); | 160 | Config config( "Vmemo" ); |
161 | config.setGroup( "System" ); | 161 | config.setGroup( "System" ); |
162 | config.writeEntry("RecLocation",string); | 162 | config.writeEntry("RecLocation",string); |
163 | qDebug("set location "+string); | 163 | qDebug("set location "+string); |
164 | config.write(); | 164 | config.write(); |
165 | } | 165 | } |
166 | 166 | ||
167 | void SoundSettings::cleanUp() { | 167 | void SoundSettings::cleanUp() { |
168 | Config cfg("Vmemo"); | 168 | Config cfg("Vmemo"); |
169 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); | 169 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); |
170 | 170 | ||
171 | cfg.setGroup("Record"); | 171 | cfg.setGroup("Record"); |
172 | cfg.writeEntry("SampleRate",sampleRate->currentText()); | 172 | cfg.writeEntry("SampleRate",sampleRate->currentText()); |
173 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); | 173 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); |
174 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); | 174 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); |
175 | if(keyReset && noWarning) { | 175 | if(keyReset && noWarning) { |
176 | QCopEnvelope ("QPE/System", "restart()"); | 176 | QCopEnvelope ("QPE/System", "restart()"); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | void SoundSettings::setKeyButton( int index) { | 180 | void SoundSettings::setKeyButton( int index) { |
181 | Config cfg("Vmemo"); | 181 | Config cfg("Vmemo"); |
182 | cfg.setGroup("Defaults"); | 182 | cfg.setGroup("Defaults"); |
183 | cfg.writeEntry( "toggleKey", index ); | 183 | cfg.writeEntry( "toggleKey", index ); |
184 | keyReset = TRUE; | 184 | keyReset = TRUE; |
185 | if( index == 1) { | 185 | if( index == 1) { |
186 | cfg.writeEntry( "hideIcon", 0 ); | 186 | cfg.writeEntry( "hideIcon", 0 ); |
187 | keyLabel->setText(tr("Shows icon")); | 187 | keyLabel->setText(tr("Shows icon")); |
188 | } | 188 | } |
189 | else { | 189 | else { |
190 | cfg.writeEntry( "hideIcon", 1); | 190 | cfg.writeEntry( "hideIcon", 1); |
191 | keyLabel->setText(tr("Hides icon")); | 191 | keyLabel->setText(tr("Hides icon")); |
192 | } | 192 | } |
193 | cfg.write(); | 193 | cfg.write(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void SoundSettings::updateLocationCombo() { | 196 | void SoundSettings::updateLocationCombo() { |
197 | 197 | ||
198 | } | 198 | } |
199 | 199 | ||
200 | void SoundSettings::setSizeLimitButton(const QString &index) { | 200 | void SoundSettings::setSizeLimitButton(const QString &index) { |
201 | 201 | ||
202 | Config cfg("Vmemo"); | 202 | Config cfg("Vmemo"); |
203 | cfg.setGroup("Record"); | 203 | cfg.setGroup("Record"); |
204 | if(index.find("Unlimited",0,TRUE) != -1) | 204 | if(index.find("Unlimited",0,TRUE) != -1) |
205 | cfg.writeEntry("SizeLimit", -1); | 205 | cfg.writeEntry("SizeLimit", -1); |
206 | else | 206 | else |
207 | cfg.writeEntry("SizeLimit", index); | 207 | cfg.writeEntry("SizeLimit", index); |
208 | cfg.write(); | 208 | cfg.write(); |
209 | } | 209 | } |
210 | 210 | ||
211 | void SoundSettings::restartOpie(bool b) { | 211 | void SoundSettings::restartOpie(bool b) { |
212 | noWarning=b; | 212 | noWarning=b; |
213 | } | 213 | } |
214 | 214 | ||
215 | void SoundSettings::slotAdpcm(bool b) { | 215 | void SoundSettings::slotAdpcm(bool b) { |
216 | Config vmCfg("Vmemo"); | 216 | Config vmCfg("Vmemo"); |
217 | vmCfg.setGroup("Defaults"); | 217 | vmCfg.setGroup("Defaults"); |
218 | vmCfg.writeEntry("use_ADPCM", b); | 218 | vmCfg.writeEntry("use_ADPCM", b); |
219 | vmCfg.write(); | 219 | vmCfg.write(); |
220 | } | 220 | } |
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 0aeb251..d6ecec5 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -1,468 +1,468 @@ | |||
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 | /* OPIE */ | 19 | /* OPIE */ |
20 | #include <opie2/ostorageinfo.h> | 20 | #include <opie2/ostorageinfo.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpedecoration_qws.h> | 23 | #include <qpe/qpedecoration_qws.h> |
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | 26 | ||
27 | /* QT */ | 27 | /* QT */ |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qcolor.h> | 29 | #include <qcolor.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qdirectpainter_qws.h> | 31 | #include <qdirectpainter_qws.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qfiledialog.h> | 34 | #include <qfiledialog.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | 40 | ||
41 | /* STD */ | 41 | /* STD */ |
42 | #include <time.h> | 42 | #include <time.h> |
43 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include <math.h> | 45 | #include <math.h> |
46 | 46 | ||
47 | #include "benchmarkinfo.h" | 47 | #include "benchmarkinfo.h" |
48 | 48 | ||
49 | extern "C" | 49 | extern "C" |
50 | { | 50 | { |
51 | void BenchFFT( void ); | 51 | void BenchFFT( void ); |
52 | double dhry_main( int ); | 52 | double dhry_main( int ); |
53 | } | 53 | } |
54 | 54 | ||
55 | #define DHRYSTONE_RUNS 20000000 | 55 | #define DHRYSTONE_RUNS 20000000 |
56 | #define TEST_DURATION 3 | 56 | #define TEST_DURATION 3 |
57 | 57 | ||
58 | #define BUFF_SIZE 8192 | 58 | #define BUFF_SIZE 8192 |
59 | #define FILE_SIZE 1024 * 1024 // 1Mb | 59 | #define FILE_SIZE 1024 * 1024 // 1Mb |
60 | 60 | ||
61 | //=========================================================================== | 61 | //=========================================================================== |
62 | 62 | ||
63 | class BenchmarkPaintWidget : public QWidget | 63 | class BenchmarkPaintWidget : public QWidget |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
67 | { | 67 | { |
68 | resize( QApplication::desktop()->size() ); | 68 | resize( QApplication::desktop()->size() ); |
69 | show(); | 69 | show(); |
70 | p.begin( this ); | 70 | p.begin( this ); |
71 | }; | 71 | }; |
72 | 72 | ||
73 | ~BenchmarkPaintWidget() | 73 | ~BenchmarkPaintWidget() |
74 | { | 74 | { |
75 | p.end(); | 75 | p.end(); |
76 | hide(); | 76 | hide(); |
77 | }; | 77 | }; |
78 | 78 | ||
79 | QPainter p; | 79 | QPainter p; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | //=========================================================================== | 82 | //=========================================================================== |
83 | 83 | ||
84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
85 | : QWidget( parent, name, wFlags ) | 85 | : QWidget( parent, name, wFlags ) |
86 | { | 86 | { |
87 | 87 | ||
88 | setMinimumSize( 200, 150 ); | 88 | setMinimumSize( 200, 150 ); |
89 | 89 | ||
90 | QVBoxLayout* vb = new QVBoxLayout( this ); | 90 | QVBoxLayout* vb = new QVBoxLayout( this ); |
91 | vb->setSpacing( 4 ); | 91 | vb->setSpacing( 4 ); |
92 | vb->setMargin( 4 ); | 92 | vb->setMargin( 4 ); |
93 | 93 | ||
94 | tests = new QListView( this ); | 94 | tests = new QListView( this ); |
95 | tests->setMargin( 0 ); | 95 | tests->setMargin( 0 ); |
96 | tests->addColumn( tr( "Tests" ) ); | 96 | tests->addColumn( tr( "Tests" ) ); |
97 | tests->addColumn( tr( "Results" ) ); | 97 | tests->addColumn( tr( "Results" ) ); |
98 | tests->addColumn( tr( "Comparison" ) ); | 98 | tests->addColumn( tr( "Comparison" ) ); |
99 | tests->setShowSortIndicator( true ); | 99 | tests->setShowSortIndicator( true ); |
100 | 100 | ||
101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); | 101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); |
102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); | 102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); |
103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); | 103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); |
104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); | 104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); |
105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); | 105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); |
106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); | 106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); |
107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); | 107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); |
108 | 108 | ||
109 | test_alu->setText( 1, "n/a" ); | 109 | test_alu->setText( 1, "n/a" ); |
110 | test_fpu->setText( 1, "n/a" ); | 110 | test_fpu->setText( 1, "n/a" ); |
111 | test_txt->setText( 1, "n/a" ); | 111 | test_txt->setText( 1, "n/a" ); |
112 | test_gfx->setText( 1, "n/a" ); | 112 | test_gfx->setText( 1, "n/a" ); |
113 | test_ram->setText( 1, "n/a" ); | 113 | test_ram->setText( 1, "n/a" ); |
114 | test_sd->setText( 1, "n/a" ); | 114 | test_sd->setText( 1, "n/a" ); |
115 | test_cf->setText( 1, "n/a" ); | 115 | test_cf->setText( 1, "n/a" ); |
116 | 116 | ||
117 | test_alu->setText( 2, "n/a" ); | 117 | test_alu->setText( 2, "n/a" ); |
118 | test_fpu->setText( 2, "n/a" ); | 118 | test_fpu->setText( 2, "n/a" ); |
119 | test_txt->setText( 2, "n/a" ); | 119 | test_txt->setText( 2, "n/a" ); |
120 | test_gfx->setText( 2, "n/a" ); | 120 | test_gfx->setText( 2, "n/a" ); |
121 | test_ram->setText( 2, "n/a" ); | 121 | test_ram->setText( 2, "n/a" ); |
122 | test_sd->setText( 2, "n/a" ); | 122 | test_sd->setText( 2, "n/a" ); |
123 | test_cf->setText( 2, "n/a" ); | 123 | test_cf->setText( 2, "n/a" ); |
124 | 124 | ||
125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
127 | 127 | ||
128 | vb->addWidget( tests, 2 ); | 128 | vb->addWidget( tests, 2 ); |
129 | 129 | ||
130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
131 | if ( f.open( IO_ReadOnly ) ) | 131 | if ( f.open( IO_ReadOnly ) ) |
132 | { | 132 | { |
133 | machineCombo = new QComboBox( this ); | 133 | machineCombo = new QComboBox( this ); |
134 | 134 | ||
135 | QTextStream ts( &f ); | 135 | QTextStream ts( &f ); |
136 | while( !ts.eof() ) | 136 | while( !ts.eof() ) |
137 | { | 137 | { |
138 | QString machline = ts.readLine(); | 138 | QString machline = ts.readLine(); |
139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); | 139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); |
140 | QString resline = ts.readLine(); | 140 | QString resline = ts.readLine(); |
141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
142 | machineCombo->insertItem( machline ); | 142 | machineCombo->insertItem( machline ); |
143 | } | 143 | } |
144 | 144 | ||
145 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 145 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); | 146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); |
147 | hb->addWidget( machineCombo, 2 ); | 147 | hb->addWidget( machineCombo, 2 ); |
148 | connect( machineCombo, SIGNAL( activated( int ) ), this, SLOT( machineActivated( int ) ) ); | 148 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
149 | } | 149 | } |
150 | 150 | ||
151 | vb->addWidget( startButton, 2 ); | 151 | vb->addWidget( startButton, 2 ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | BenchmarkInfo::~BenchmarkInfo() | 155 | BenchmarkInfo::~BenchmarkInfo() |
156 | {} | 156 | {} |
157 | 157 | ||
158 | 158 | ||
159 | void BenchmarkInfo::machineActivated( int index ) | 159 | void BenchmarkInfo::machineActivated( int index ) |
160 | { | 160 | { |
161 | QStringList* results = machines[ machineCombo->text( index ) ]; | 161 | QStringList* results = machines[ machineCombo->text( index ) ]; |
162 | if ( !results ) | 162 | if ( !results ) |
163 | { | 163 | { |
164 | qDebug( "sysinfo: no results available." ); | 164 | qDebug( "sysinfo: no results available." ); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | QStringList::Iterator it = results->begin(); | 167 | QStringList::Iterator it = results->begin(); |
168 | test_alu->setText( 2, *(it++) ); | 168 | test_alu->setText( 2, *(it++) ); |
169 | test_fpu->setText( 2, *(it++) ); | 169 | test_fpu->setText( 2, *(it++) ); |
170 | test_txt->setText( 2, *(it++) ); | 170 | test_txt->setText( 2, *(it++) ); |
171 | test_gfx->setText( 2, *(it++) ); | 171 | test_gfx->setText( 2, *(it++) ); |
172 | test_ram->setText( 2, *(it++) ); | 172 | test_ram->setText( 2, *(it++) ); |
173 | test_sd->setText( 2, *(it++) ); | 173 | test_sd->setText( 2, *(it++) ); |
174 | test_cf->setText( 2, *(it++) ); | 174 | test_cf->setText( 2, *(it++) ); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void BenchmarkInfo::run() | 178 | void BenchmarkInfo::run() |
179 | { | 179 | { |
180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
181 | qApp->processEvents(); | 181 | qApp->processEvents(); |
182 | QTime t; | 182 | QTime t; |
183 | 183 | ||
184 | if ( test_alu->isOn() ) | 184 | if ( test_alu->isOn() ) |
185 | { | 185 | { |
186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); | 187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
188 | test_alu->setOn( false ); | 188 | test_alu->setOn( false ); |
189 | } | 189 | } |
190 | 190 | ||
191 | if ( test_fpu->isOn() ) | 191 | if ( test_fpu->isOn() ) |
192 | { | 192 | { |
193 | t.start(); | 193 | t.start(); |
194 | BenchFFT(); | 194 | BenchFFT(); |
195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
196 | test_fpu->setOn( false ); | 196 | test_fpu->setOn( false ); |
197 | } | 197 | } |
198 | 198 | ||
199 | if ( test_txt->isOn() ) | 199 | if ( test_txt->isOn() ) |
200 | { | 200 | { |
201 | int value = textRendering( TEST_DURATION ); | 201 | int value = textRendering( TEST_DURATION ); |
202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); | 202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
203 | test_txt->setOn( false ); | 203 | test_txt->setOn( false ); |
204 | } | 204 | } |
205 | 205 | ||
206 | if ( test_gfx->isOn() ) | 206 | if ( test_gfx->isOn() ) |
207 | { | 207 | { |
208 | int value = gfxRendering( TEST_DURATION ); | 208 | int value = gfxRendering( TEST_DURATION ); |
209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests | 209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
210 | test_gfx->setOn( false ); | 210 | test_gfx->setOn( false ); |
211 | } | 211 | } |
212 | 212 | ||
213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
214 | { | 214 | { |
215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
216 | } | 216 | } |
217 | 217 | ||
218 | if ( test_cf->isOn() ) | 218 | if ( test_cf->isOn() ) |
219 | { | 219 | { |
220 | OStorageInfo storage; | 220 | OStorageInfo storage; |
221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ( test_sd->isOn() ) | 224 | if ( test_sd->isOn() ) |
225 | { | 225 | { |
226 | OStorageInfo storage; | 226 | OStorageInfo storage; |
227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
228 | } | 228 | } |
229 | 229 | ||
230 | startButton->setText( tr( "&Start Tests!" ) ); | 230 | startButton->setText( tr( "&Start Tests!" ) ); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | int BenchmarkInfo::textRendering( int seconds ) | 234 | int BenchmarkInfo::textRendering( int seconds ) |
235 | { | 235 | { |
236 | QTime t; | 236 | QTime t; |
237 | t.start(); | 237 | t.start(); |
238 | int stop = t.elapsed() + seconds * 1000; | 238 | int stop = t.elapsed() + seconds * 1000; |
239 | 239 | ||
240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
243 | const QString text( "Opie Benchmark Test" ); | 243 | const QString text( "Opie Benchmark Test" ); |
244 | 244 | ||
245 | int w = QApplication::desktop()->width(); | 245 | int w = QApplication::desktop()->width(); |
246 | int h = QApplication::desktop()->height(); | 246 | int h = QApplication::desktop()->height(); |
247 | 247 | ||
248 | srand( time( NULL ) ); | 248 | srand( time( NULL ) ); |
249 | 249 | ||
250 | BenchmarkPaintWidget bpw; | 250 | BenchmarkPaintWidget bpw; |
251 | 251 | ||
252 | int loops = 0; | 252 | int loops = 0; |
253 | 253 | ||
254 | while ( t.elapsed() < stop ) | 254 | while ( t.elapsed() < stop ) |
255 | { | 255 | { |
256 | int k = rand() % 9; | 256 | int k = rand() % 9; |
257 | int s = rand() % 100; | 257 | int s = rand() % 100; |
258 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 258 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
259 | bpw.p.setFont( QFont( "Vera", s ) ); | 259 | bpw.p.setFont( QFont( "Vera", s ) ); |
260 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); | 260 | bpw.p.drawText( rand() % w, rand() % h, text, text.length() ); |
261 | ++loops; | 261 | ++loops; |
262 | } | 262 | } |
263 | 263 | ||
264 | return loops * text.length(); | 264 | return loops * text.length(); |
265 | } | 265 | } |
266 | 266 | ||
267 | int BenchmarkInfo::gfxRendering( int seconds ) | 267 | int BenchmarkInfo::gfxRendering( int seconds ) |
268 | { | 268 | { |
269 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 269 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
270 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 270 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
271 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 271 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
272 | 272 | ||
273 | int w = QApplication::desktop()->width(); | 273 | int w = QApplication::desktop()->width(); |
274 | int h = QApplication::desktop()->height(); | 274 | int h = QApplication::desktop()->height(); |
275 | 275 | ||
276 | srand( time( NULL ) ); | 276 | srand( time( NULL ) ); |
277 | 277 | ||
278 | BenchmarkPaintWidget bpw; | 278 | BenchmarkPaintWidget bpw; |
279 | 279 | ||
280 | QTime t; | 280 | QTime t; |
281 | t.start(); | 281 | t.start(); |
282 | int stop = t.elapsed() + seconds*1000; | 282 | int stop = t.elapsed() + seconds*1000; |
283 | int loops = 0; | 283 | int loops = 0; |
284 | 284 | ||
285 | while ( t.elapsed() < stop ) | 285 | while ( t.elapsed() < stop ) |
286 | { | 286 | { |
287 | int k = rand() % 9; | 287 | int k = rand() % 9; |
288 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 288 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
289 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); | 289 | bpw.p.drawLine( rand()%w, rand()%h, rand()%w, rand()%h ); |
290 | ++loops; | 290 | ++loops; |
291 | } | 291 | } |
292 | 292 | ||
293 | t.restart(); | 293 | t.restart(); |
294 | stop = t.elapsed() + seconds*1000; | 294 | stop = t.elapsed() + seconds*1000; |
295 | 295 | ||
296 | while ( t.elapsed() < stop ) | 296 | while ( t.elapsed() < stop ) |
297 | { | 297 | { |
298 | int k = rand() % 9; | 298 | int k = rand() % 9; |
299 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 299 | bpw.p.setPen( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
300 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); | 300 | bpw.p.drawArc( rand()%w, rand()%h, rand()%w, rand()%h, 360 * 16, 360 * 16 ); |
301 | ++loops; | 301 | ++loops; |
302 | } | 302 | } |
303 | 303 | ||
304 | QBrush br1; | 304 | QBrush br1; |
305 | br1.setStyle( SolidPattern ); | 305 | br1.setStyle( SolidPattern ); |
306 | t.restart(); | 306 | t.restart(); |
307 | stop = t.elapsed() + seconds*1000; | 307 | stop = t.elapsed() + seconds*1000; |
308 | 308 | ||
309 | while ( t.elapsed() < stop ) | 309 | while ( t.elapsed() < stop ) |
310 | { | 310 | { |
311 | int k = rand() % 9; | 311 | int k = rand() % 9; |
312 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); | 312 | br1.setColor( QColor( rr[ k ], gg[ k ], bb[ k ] ) ); |
313 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); | 313 | bpw.p.fillRect( rand()%w, rand()%h, rand()%w, rand()%h, br1 ); |
314 | ++loops; | 314 | ++loops; |
315 | } | 315 | } |
316 | 316 | ||
317 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); | 317 | QPixmap p = Resource::loadPixmap( "sysinfo/pattern" ); |
318 | t.restart(); | 318 | t.restart(); |
319 | stop = t.elapsed() + seconds*1000; | 319 | stop = t.elapsed() + seconds*1000; |
320 | 320 | ||
321 | while ( t.elapsed() < stop ) | 321 | while ( t.elapsed() < stop ) |
322 | { | 322 | { |
323 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); | 323 | bpw.p.drawPixmap( rand()%w, rand()%h, p ); |
324 | ++loops; | 324 | ++loops; |
325 | } | 325 | } |
326 | 326 | ||
327 | return loops; | 327 | return loops; |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item ) | 331 | void BenchmarkInfo::performFileTest( const QString& fname, QCheckListItem* item ) |
332 | { | 332 | { |
333 | QTime time; | 333 | QTime time; |
334 | time.start(); | 334 | time.start(); |
335 | if ( writeFile( fname ) && | 335 | if ( writeFile( fname ) && |
336 | readFile( fname ) ) | 336 | readFile( fname ) ) |
337 | { | 337 | { |
338 | QFile::remove( fname ); | 338 | QFile::remove( fname ); |
339 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); | 339 | item->setText( 1, QString( "%1 kb/sec" ).arg( QString::number( 1024.0 / ( time.elapsed() / 1000.0 ) ) ) ); |
340 | item->setOn( false ); | 340 | item->setOn( false ); |
341 | } | 341 | } |
342 | else | 342 | else |
343 | { | 343 | { |
344 | item->setText( 1, tr( "error" ) ); | 344 | item->setText( 1, tr( "error" ) ); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | char FileBuf[ BUFF_SIZE + 1 ]; | 348 | char FileBuf[ BUFF_SIZE + 1 ]; |
349 | 349 | ||
350 | bool BenchmarkInfo::writeFile( const QString& w_path ) | 350 | bool BenchmarkInfo::writeFile( const QString& w_path ) |
351 | { | 351 | { |
352 | int i; | 352 | int i; |
353 | int k; | 353 | int k; |
354 | int n; | 354 | int n; |
355 | int pos; | 355 | int pos; |
356 | int len; | 356 | int len; |
357 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 | 357 | char *data = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // 62 |
358 | 358 | ||
359 | 359 | ||
360 | // /*------------------------------------ | 360 | // /*------------------------------------ |
361 | int w_len; | 361 | int w_len; |
362 | 362 | ||
363 | QFile writeFile( w_path ); | 363 | QFile writeFile( w_path ); |
364 | srand( time( NULL ) ); | 364 | srand( time( NULL ) ); |
365 | 365 | ||
366 | for ( n = 0 ; n < 20 ; n++ ) | 366 | for ( n = 0 ; n < 20 ; n++ ) |
367 | { | 367 | { |
368 | if ( ! writeFile.open( IO_WriteOnly ) ) | 368 | if ( ! writeFile.open( IO_WriteOnly ) ) |
369 | { | 369 | { |
370 | writeFile.close(); | 370 | writeFile.close(); |
371 | writeFile.remove(); | 371 | writeFile.remove(); |
372 | return ( false ); | 372 | return ( false ); |
373 | } | 373 | } |
374 | // ------------------------------------------ sequential write | 374 | // ------------------------------------------ sequential write |
375 | for ( k = 0 ; k < 256 ; k++ ) | 375 | for ( k = 0 ; k < 256 ; k++ ) |
376 | { | 376 | { |
377 | n = rand() % 30; | 377 | n = rand() % 30; |
378 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); | 378 | memcpy( &FileBuf[ k * 32 ], &data[ n ], 32 ); |
379 | } | 379 | } |
380 | 380 | ||
381 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 381 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
382 | { | 382 | { |
383 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); | 383 | w_len = writeFile.writeBlock( FileBuf, BUFF_SIZE ); |
384 | if ( w_len != BUFF_SIZE ) | 384 | if ( w_len != BUFF_SIZE ) |
385 | { | 385 | { |
386 | writeFile.close(); | 386 | writeFile.close(); |
387 | writeFile.remove(); | 387 | writeFile.remove(); |
388 | return ( false ); | 388 | return ( false ); |
389 | } | 389 | } |
390 | writeFile.flush(); | 390 | writeFile.flush(); |
391 | } | 391 | } |
392 | // ------------------------------------------ random write | 392 | // ------------------------------------------ random write |
393 | for ( i = 0 ; i < 400 ; i++ ) | 393 | for ( i = 0 ; i < 400 ; i++ ) |
394 | { | 394 | { |
395 | len = rand() % 90 + 4000; | 395 | len = rand() % 90 + 4000; |
396 | for ( k = 0 ; k < 128 ; k++ ) | 396 | for ( k = 0 ; k < 128 ; k++ ) |
397 | { | 397 | { |
398 | n = rand() % 30; | 398 | n = rand() % 30; |
399 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); | 399 | memcpy( &FileBuf[ k * 8 ], &data[ n ], 32 ); |
400 | } | 400 | } |
401 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); | 401 | pos = rand() % ( FILE_SIZE - BUFF_SIZE ); |
402 | 402 | ||
403 | writeFile.at( pos ); | 403 | writeFile.at( pos ); |
404 | w_len = writeFile.writeBlock( FileBuf, len ); | 404 | w_len = writeFile.writeBlock( FileBuf, len ); |
405 | if ( w_len != len ) | 405 | if ( w_len != len ) |
406 | { | 406 | { |
407 | writeFile.close(); | 407 | writeFile.close(); |
408 | writeFile.remove(); | 408 | writeFile.remove(); |
409 | return ( false ); | 409 | return ( false ); |
410 | } | 410 | } |
411 | writeFile.flush(); | 411 | writeFile.flush(); |
412 | } | 412 | } |
413 | writeFile.close(); | 413 | writeFile.close(); |
414 | } | 414 | } |
415 | return ( true ); | 415 | return ( true ); |
416 | 416 | ||
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | bool BenchmarkInfo::readFile( const QString& r_path ) | 420 | bool BenchmarkInfo::readFile( const QString& r_path ) |
421 | { | 421 | { |
422 | int i; | 422 | int i; |
423 | int k; | 423 | int k; |
424 | int len; | 424 | int len; |
425 | int pos; | 425 | int pos; |
426 | int r_len; | 426 | int r_len; |
427 | 427 | ||
428 | QFile readFile( r_path ); | 428 | QFile readFile( r_path ); |
429 | srand( time( NULL ) ); | 429 | srand( time( NULL ) ); |
430 | 430 | ||
431 | for ( k = 0 ; k < 200 ; k++ ) | 431 | for ( k = 0 ; k < 200 ; k++ ) |
432 | { | 432 | { |
433 | if ( ! readFile.open( IO_ReadOnly ) ) | 433 | if ( ! readFile.open( IO_ReadOnly ) ) |
434 | { | 434 | { |
435 | readFile.remove(); | 435 | readFile.remove(); |
436 | return ( false ); | 436 | return ( false ); |
437 | } | 437 | } |
438 | // ------------------------------------------ sequential read | 438 | // ------------------------------------------ sequential read |
439 | readFile.at( 0 ); | 439 | readFile.at( 0 ); |
440 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) | 440 | for ( i = 0 ; i < FILE_SIZE / BUFF_SIZE ; i++ ) |
441 | { | 441 | { |
442 | readFile.at( i * BUFF_SIZE ); | 442 | readFile.at( i * BUFF_SIZE ); |
443 | r_len = readFile.readBlock( FileBuf, BUFF_SIZE ); | 443 | r_len = readFile.readBlock( FileBuf, BUFF_SIZE ); |
444 | if ( r_len != BUFF_SIZE ) | 444 | if ( r_len != BUFF_SIZE ) |
445 | { | 445 | { |
446 | readFile.close(); | 446 | readFile.close(); |
447 | readFile.remove(); | 447 | readFile.remove(); |
448 | return ( false ); | 448 | return ( false ); |
449 | } | 449 | } |
450 | } | 450 | } |
451 | // ------------------------------------------ random read | 451 | // ------------------------------------------ random read |
452 | for ( i = 0 ; i < 1000 ; i++ ) | 452 | for ( i = 0 ; i < 1000 ; i++ ) |
453 | { | 453 | { |
454 | len = rand() % 120 + 8; | 454 | len = rand() % 120 + 8; |
455 | pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE ); | 455 | pos = rand() % ( FILE_SIZE / BUFF_SIZE - BUFF_SIZE ); |
456 | readFile.at( pos ); | 456 | readFile.at( pos ); |
457 | r_len = readFile.readBlock( FileBuf, len ); | 457 | r_len = readFile.readBlock( FileBuf, len ); |
458 | if ( r_len != len ) | 458 | if ( r_len != len ) |
459 | { | 459 | { |
460 | readFile.close(); | 460 | readFile.close(); |
461 | readFile.remove(); | 461 | readFile.remove(); |
462 | return ( false ); | 462 | return ( false ); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | readFile.close(); | 465 | readFile.close(); |
466 | } | 466 | } |
467 | return ( true ); | 467 | return ( true ); |
468 | } | 468 | } |
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 9cb8ad2..e688a29 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -1,190 +1,190 @@ | |||
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 <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | 34 | ||
35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
36 | : QWidget( parent, name, fl ) | 36 | : QWidget( parent, name, fl ) |
37 | { | 37 | { |
38 | QGridLayout *layout = new QGridLayout( this ); | 38 | QGridLayout *layout = new QGridLayout( this ); |
39 | layout->setSpacing( 4 ); | 39 | layout->setSpacing( 4 ); |
40 | layout->setMargin( 4 ); | 40 | layout->setMargin( 4 ); |
41 | 41 | ||
42 | ModulesView = new QListView( this ); | 42 | ModulesView = new QListView( this ); |
43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
44 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 44 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); | 48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
49 | ModulesView->setAllColumnsShowFocus( TRUE ); | 49 | ModulesView->setAllColumnsShowFocus( TRUE ); |
50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
51 | 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." ) ); | 51 | 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." ) ); |
52 | 52 | ||
53 | // Test if we have /sbin/modinfo, and if so, allow module detail window | 53 | // Test if we have /sbin/modinfo, and if so, allow module detail window |
54 | if ( QFile::exists( "/sbin/modinfo" ) ) | 54 | if ( QFile::exists( "/sbin/modinfo" ) ) |
55 | { | 55 | { |
56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
57 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 57 | connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
58 | this, SLOT( viewModules( QListViewItem * ) ) ); | 58 | this, SLOT( viewModules(QListViewItem*) ) ); |
59 | } | 59 | } |
60 | 60 | ||
61 | CommandCB = new QComboBox( FALSE, this ); | 61 | CommandCB = new QComboBox( FALSE, this ); |
62 | CommandCB->insertItem( "modprobe -r" ); | 62 | CommandCB->insertItem( "modprobe -r" ); |
63 | CommandCB->insertItem( "rmmod" ); | 63 | CommandCB->insertItem( "rmmod" ); |
64 | // I can't think of other useful commands yet. Anyone? | 64 | // I can't think of other useful commands yet. Anyone? |
65 | layout->addWidget( CommandCB, 1, 0 ); | 65 | layout->addWidget( CommandCB, 1, 0 ); |
66 | 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." ) ); | 66 | 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." ) ); |
67 | 67 | ||
68 | QPushButton *btn = new QPushButton( this ); | 68 | QPushButton *btn = new QPushButton( this ); |
69 | btn->setMinimumSize( QSize( 50, 24 ) ); | 69 | btn->setMinimumSize( QSize( 50, 24 ) ); |
70 | btn->setMaximumSize( QSize( 50, 24 ) ); | 70 | btn->setMaximumSize( QSize( 50, 24 ) ); |
71 | btn->setText( tr( "Send" ) ); | 71 | btn->setText( tr( "Send" ) ); |
72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
73 | layout->addWidget( btn, 1, 1 ); | 73 | layout->addWidget( btn, 1, 1 ); |
74 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 74 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
75 | 75 | ||
76 | QTimer *t = new QTimer( this ); | 76 | QTimer *t = new QTimer( this ); |
77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
78 | t->start( 5000 ); | 78 | t->start( 5000 ); |
79 | 79 | ||
80 | updateData(); | 80 | updateData(); |
81 | 81 | ||
82 | ModulesDtl = new Detail(); | 82 | ModulesDtl = new Detail(); |
83 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | 83 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | ModulesInfo::~ModulesInfo() | 86 | ModulesInfo::~ModulesInfo() |
87 | {} | 87 | {} |
88 | 88 | ||
89 | void ModulesInfo::updateData() | 89 | void ModulesInfo::updateData() |
90 | { | 90 | { |
91 | char modname[64]; | 91 | char modname[64]; |
92 | char usage[200]; | 92 | char usage[200]; |
93 | int modsize, usecount; | 93 | int modsize, usecount; |
94 | 94 | ||
95 | QString selectedmod; | 95 | QString selectedmod; |
96 | QListViewItem *curritem = ModulesView->currentItem(); | 96 | QListViewItem *curritem = ModulesView->currentItem(); |
97 | if ( curritem ) | 97 | if ( curritem ) |
98 | { | 98 | { |
99 | selectedmod = curritem->text( 0 ); | 99 | selectedmod = curritem->text( 0 ); |
100 | } | 100 | } |
101 | 101 | ||
102 | ModulesView->clear(); | 102 | ModulesView->clear(); |
103 | 103 | ||
104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
105 | 105 | ||
106 | if ( procfile ) | 106 | if ( procfile ) |
107 | { | 107 | { |
108 | QListViewItem *newitem; | 108 | QListViewItem *newitem; |
109 | QListViewItem *selecteditem = 0x0; | 109 | QListViewItem *selecteditem = 0x0; |
110 | while ( true ) | 110 | while ( true ) |
111 | { | 111 | { |
112 | modname[0] = '\0'; | 112 | modname[0] = '\0'; |
113 | usage[0] = '\0'; | 113 | usage[0] = '\0'; |
114 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 114 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
115 | 115 | ||
116 | if ( success == EOF ) | 116 | if ( success == EOF ) |
117 | break; | 117 | break; |
118 | 118 | ||
119 | QString qmodname = QString( modname ); | 119 | QString qmodname = QString( modname ); |
120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
122 | QString qusage = QString( usage ); | 122 | QString qusage = QString( usage ); |
123 | 123 | ||
124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
125 | if ( qmodname == selectedmod ) | 125 | if ( qmodname == selectedmod ) |
126 | { | 126 | { |
127 | selecteditem = newitem; | 127 | selecteditem = newitem; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | ModulesView->setCurrentItem( selecteditem ); | 130 | ModulesView->setCurrentItem( selecteditem ); |
131 | 131 | ||
132 | fclose( procfile ); | 132 | fclose( procfile ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void ModulesInfo::slotSendClicked() | 136 | void ModulesInfo::slotSendClicked() |
137 | { | 137 | { |
138 | if ( !ModulesView->currentItem() ) | 138 | if ( !ModulesView->currentItem() ) |
139 | { | 139 | { |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); | 143 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); |
144 | 144 | ||
145 | QString modname = ModulesView->currentItem()->text( 0 ); | 145 | QString modname = ModulesView->currentItem()->text( 0 ); |
146 | 146 | ||
147 | if ( QMessageBox::warning( this, modname, capstr, | 147 | if ( QMessageBox::warning( this, modname, capstr, |
148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
149 | { | 149 | { |
150 | QString command = "/sbin/"; | 150 | QString command = "/sbin/"; |
151 | command.append( CommandCB->currentText() ); | 151 | command.append( CommandCB->currentText() ); |
152 | command.append( " " ); | 152 | command.append( " " ); |
153 | command.append( modname ); | 153 | command.append( modname ); |
154 | 154 | ||
155 | FILE* stream = popen( command, "r" ); | 155 | FILE* stream = popen( command, "r" ); |
156 | if ( stream ) | 156 | if ( stream ) |
157 | pclose( stream ); | 157 | pclose( stream ); |
158 | } | 158 | } |
159 | 159 | ||
160 | } | 160 | } |
161 | 161 | ||
162 | void ModulesInfo::viewModules( QListViewItem *modules ) | 162 | void ModulesInfo::viewModules( QListViewItem *modules ) |
163 | { | 163 | { |
164 | QString modname = modules->text( 0 ); | 164 | QString modname = modules->text( 0 ); |
165 | QString capstr = "Module: "; | 165 | QString capstr = "Module: "; |
166 | capstr.append( modname ); | 166 | capstr.append( modname ); |
167 | ModulesDtl->setCaption( capstr ); | 167 | ModulesDtl->setCaption( capstr ); |
168 | QString command = "/sbin/modinfo "; | 168 | QString command = "/sbin/modinfo "; |
169 | command.append( modname ); | 169 | command.append( modname ); |
170 | FILE* modinfo = popen( command, "r" ); | 170 | FILE* modinfo = popen( command, "r" ); |
171 | 171 | ||
172 | if ( modinfo ) | 172 | if ( modinfo ) |
173 | { | 173 | { |
174 | char line[200]; | 174 | char line[200]; |
175 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); | 175 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); |
176 | 176 | ||
177 | while( true ) | 177 | while( true ) |
178 | { | 178 | { |
179 | int success = fscanf( modinfo, "%[^\n]\n", line ); | 179 | int success = fscanf( modinfo, "%[^\n]\n", line ); |
180 | if ( success == EOF ) | 180 | if ( success == EOF ) |
181 | break; | 181 | break; |
182 | ModulesDtl->detailView->append( line ); | 182 | ModulesDtl->detailView->append( line ); |
183 | } | 183 | } |
184 | 184 | ||
185 | pclose( modinfo ); | 185 | pclose( modinfo ); |
186 | } | 186 | } |
187 | 187 | ||
188 | QPEApplication::showWidget( ModulesDtl ); | 188 | QPEApplication::showWidget( ModulesDtl ); |
189 | } | 189 | } |
190 | 190 | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 2a90b0f..69b4ab5 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -1,202 +1,202 @@ | |||
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 <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | 32 | ||
33 | /* STD */ | 33 | /* STD */ |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | #include <signal.h> | 35 | #include <signal.h> |
36 | 36 | ||
37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
38 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
39 | { | 39 | { |
40 | QGridLayout *layout = new QGridLayout( this ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
41 | layout->setSpacing( 4 ); | 41 | layout->setSpacing( 4 ); |
42 | layout->setMargin( 4 ); | 42 | layout->setMargin( 4 ); |
43 | 43 | ||
44 | 44 | ||
45 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
49 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 49 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
50 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 50 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
52 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
55 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess(QListViewItem*) ) ); |
56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
57 | 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." ) ); | 57 | 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." ) ); |
58 | 58 | ||
59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
60 | SignalCB->insertItem( " 1: SIGHUP" ); | 60 | SignalCB->insertItem( " 1: SIGHUP" ); |
61 | SignalCB->insertItem( " 2: SIGINT" ); | 61 | SignalCB->insertItem( " 2: SIGINT" ); |
62 | SignalCB->insertItem( " 3: SIGQUIT" ); | 62 | SignalCB->insertItem( " 3: SIGQUIT" ); |
63 | SignalCB->insertItem( " 5: SIGTRAP" ); | 63 | SignalCB->insertItem( " 5: SIGTRAP" ); |
64 | SignalCB->insertItem( " 6: SIGABRT" ); | 64 | SignalCB->insertItem( " 6: SIGABRT" ); |
65 | SignalCB->insertItem( " 9: SIGKILL" ); | 65 | SignalCB->insertItem( " 9: SIGKILL" ); |
66 | SignalCB->insertItem( "14: SIGALRM" ); | 66 | SignalCB->insertItem( "14: SIGALRM" ); |
67 | SignalCB->insertItem( "15: SIGTERM" ); | 67 | SignalCB->insertItem( "15: SIGTERM" ); |
68 | SignalCB->insertItem( "18: SIGCONT" ); | 68 | SignalCB->insertItem( "18: SIGCONT" ); |
69 | SignalCB->insertItem( "19: SIGSTOP" ); | 69 | SignalCB->insertItem( "19: SIGSTOP" ); |
70 | layout->addWidget( SignalCB, 1, 0 ); | 70 | layout->addWidget( SignalCB, 1, 0 ); |
71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); | 71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); |
72 | 72 | ||
73 | SendButton = new QPushButton( this, "SendButton" ); | 73 | SendButton = new QPushButton( this, "SendButton" ); |
74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); | 74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); |
75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); | 75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); |
76 | SendButton->setText( tr( "Send" ) ); | 76 | SendButton->setText( tr( "Send" ) ); |
77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
78 | layout->addWidget( SendButton, 1, 1 ); | 78 | layout->addWidget( SendButton, 1, 1 ); |
79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); | 79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); |
80 | 80 | ||
81 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
83 | t->start( 5000 ); | 83 | t->start( 5000 ); |
84 | 84 | ||
85 | updateData(); | 85 | updateData(); |
86 | 86 | ||
87 | ProcessDtl = new Detail(); | 87 | ProcessDtl = new Detail(); |
88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); | 88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); |
89 | } | 89 | } |
90 | 90 | ||
91 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
92 | {} | 92 | {} |
93 | 93 | ||
94 | void ProcessInfo::updateData() | 94 | void ProcessInfo::updateData() |
95 | { | 95 | { |
96 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, | 96 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, |
97 | signal, blocked, sigignore, sigcatch; | 97 | signal, blocked, sigignore, sigcatch; |
98 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, | 98 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, |
99 | endcode, startstack, kstkesp, kstkeip, wchan; | 99 | endcode, startstack, kstkesp, kstkeip, wchan; |
100 | char state; | 100 | char state; |
101 | char comm[64]; | 101 | char comm[64]; |
102 | 102 | ||
103 | QString selectedpid; | 103 | QString selectedpid; |
104 | QListViewItem *curritem = ProcessView->currentItem(); | 104 | QListViewItem *curritem = ProcessView->currentItem(); |
105 | if ( curritem ) | 105 | if ( curritem ) |
106 | { | 106 | { |
107 | selectedpid = curritem->text( 0 ); | 107 | selectedpid = curritem->text( 0 ); |
108 | } | 108 | } |
109 | 109 | ||
110 | ProcessView->clear(); | 110 | ProcessView->clear(); |
111 | 111 | ||
112 | QListViewItem *newitem; | 112 | QListViewItem *newitem; |
113 | QListViewItem *selecteditem = 0x0; | 113 | QListViewItem *selecteditem = 0x0; |
114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
116 | if ( proclist ) | 116 | if ( proclist ) |
117 | { | 117 | { |
118 | QFileInfoListIterator it(*proclist); | 118 | QFileInfoListIterator it(*proclist); |
119 | QFileInfo *f; | 119 | QFileInfo *f; |
120 | while ( ( f = it.current() ) != 0 ) | 120 | while ( ( f = it.current() ) != 0 ) |
121 | { | 121 | { |
122 | ++it; | 122 | ++it; |
123 | QString processnum = f->fileName(); | 123 | QString processnum = f->fileName(); |
124 | if ( processnum >= "1" && processnum <= "99999" ) | 124 | if ( processnum >= "1" && processnum <= "99999" ) |
125 | { | 125 | { |
126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
127 | 127 | ||
128 | if ( procfile ) | 128 | if ( procfile ) |
129 | { | 129 | { |
130 | fscanf( procfile, | 130 | fscanf( procfile, |
131 | "%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", | 131 | "%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", |
132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
136 | processnum = processnum.rightJustify( 5, ' ' ); | 136 | processnum = processnum.rightJustify( 5, ' ' ); |
137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
138 | QString processstatus = QChar(state); | 138 | QString processstatus = QChar(state); |
139 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 139 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
140 | processtime = processtime.rightJustify( 9, ' ' ); | 140 | processtime = processtime.rightJustify( 9, ' ' ); |
141 | fclose( procfile ); | 141 | fclose( procfile ); |
142 | 142 | ||
143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
144 | if ( processnum == selectedpid ) | 144 | if ( processnum == selectedpid ) |
145 | { | 145 | { |
146 | selecteditem = newitem; | 146 | selecteditem = newitem; |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } | 149 | } |
150 | } | 150 | } |
151 | ProcessView->setCurrentItem( selecteditem ); | 151 | ProcessView->setCurrentItem( selecteditem ); |
152 | } | 152 | } |
153 | 153 | ||
154 | delete proclist; | 154 | delete proclist; |
155 | delete procdir; | 155 | delete procdir; |
156 | } | 156 | } |
157 | 157 | ||
158 | void ProcessInfo::slotSendClicked() | 158 | void ProcessInfo::slotSendClicked() |
159 | { | 159 | { |
160 | QListViewItem *currprocess = ProcessView->currentItem(); | 160 | QListViewItem *currprocess = ProcessView->currentItem(); |
161 | if ( !currprocess ) | 161 | if ( !currprocess ) |
162 | { | 162 | { |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | 165 | ||
166 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); | 166 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); |
167 | 167 | ||
168 | 168 | ||
169 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 169 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
170 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 170 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
171 | { | 171 | { |
172 | currprocess = ProcessView->currentItem(); | 172 | currprocess = ProcessView->currentItem(); |
173 | if ( currprocess ) | 173 | if ( currprocess ) |
174 | { | 174 | { |
175 | QString sigstr = SignalCB->currentText(); | 175 | QString sigstr = SignalCB->currentText(); |
176 | sigstr.truncate(2); | 176 | sigstr.truncate(2); |
177 | int sigid = sigstr.toUInt(); | 177 | int sigid = sigstr.toUInt(); |
178 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); | 178 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | void ProcessInfo::viewProcess( QListViewItem *process ) | 184 | void ProcessInfo::viewProcess( QListViewItem *process ) |
185 | { | 185 | { |
186 | QString pid= process->text( 0 ).stripWhiteSpace(); | 186 | QString pid= process->text( 0 ).stripWhiteSpace(); |
187 | QString command = process->text( 1 ); | 187 | QString command = process->text( 1 ); |
188 | ProcessDtl->setCaption( pid + " - " + command ); | 188 | ProcessDtl->setCaption( pid + " - " + command ); |
189 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 189 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
190 | if ( statfile ) | 190 | if ( statfile ) |
191 | { | 191 | { |
192 | char line[81]; | 192 | char line[81]; |
193 | fgets( line, 81, statfile ); | 193 | fgets( line, 81, statfile ); |
194 | ProcessDtl->detailView->setText( line ); | 194 | ProcessDtl->detailView->setText( line ); |
195 | while ( fgets( line, 81, statfile ) ) | 195 | while ( fgets( line, 81, statfile ) ) |
196 | { | 196 | { |
197 | ProcessDtl->detailView->append( line ); | 197 | ProcessDtl->detailView->append( line ); |
198 | } | 198 | } |
199 | fclose( statfile ); | 199 | fclose( statfile ); |
200 | } | 200 | } |
201 | QPEApplication::showWidget( ProcessDtl ); | 201 | QPEApplication::showWidget( ProcessDtl ); |
202 | } | 202 | } |
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp index ff5957c..15aeaf5 100644 --- a/noncore/settings/tabmanager/tabmanager.cpp +++ b/noncore/settings/tabmanager/tabmanager.cpp | |||
@@ -1,423 +1,423 @@ | |||
1 | #include "tabmanager.h" | 1 | #include "tabmanager.h" |
2 | #include "app.h" | 2 | #include "app.h" |
3 | #include "wait.h" | 3 | #include "wait.h" |
4 | #include "tabapplnk.h" | 4 | #include "tabapplnk.h" |
5 | 5 | ||
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qheader.h> | 11 | #include <qheader.h> |
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qlabel.h> | 14 | #include <qlabel.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <stdlib.h> | 16 | #include <stdlib.h> |
17 | #include <qpe/qcopenvelope_qws.h> | 17 | #include <qpe/qcopenvelope_qws.h> |
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | 20 | ||
21 | 21 | ||
22 | #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" | 22 | #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" |
23 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" | 23 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" |
24 | #define NEW_FOLDER "EmptyTab" | 24 | #define NEW_FOLDER "EmptyTab" |
25 | #define NEW_APPLICATION "NewApp" | 25 | #define NEW_APPLICATION "NewApp" |
26 | #define APPLICATION_EXTENSION ".desktop" | 26 | #define APPLICATION_EXTENSION ".desktop" |
27 | #define APPLICATION_EXTENSION_LENGTH 8 | 27 | #define APPLICATION_EXTENSION_LENGTH 8 |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Constructor. Sets up signals. Performs initial scan of applications | 30 | * Constructor. Sets up signals. Performs initial scan of applications |
31 | * and tabs | 31 | * and tabs |
32 | */ | 32 | */ |
33 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ | 33 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ |
34 | rescanFolder(HOME_APP_DIR); | 34 | rescanFolder(HOME_APP_DIR); |
35 | 35 | ||
36 | // Connect the signals and slots | 36 | // Connect the signals and slots |
37 | connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(editItem(QListViewItem*))); | 37 | connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*))); |
38 | (tabList->header())->hide(); | 38 | (tabList->header())->hide(); |
39 | connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); | 39 | connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*))); |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * If anything in the tab's have been changed then update the system or alert | 43 | * If anything in the tab's have been changed then update the system or alert |
44 | * the user. | 44 | * the user. |
45 | */ | 45 | */ |
46 | TabManager::~TabManager(){ | 46 | TabManager::~TabManager(){ |
47 | if(changed){ | 47 | if(changed){ |
48 | // Prompt. | 48 | // Prompt. |
49 | //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); | 49 | //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); |
50 | //if (answer) | 50 | //if (answer) |
51 | // return; | 51 | // return; |
52 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 52 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
53 | QString link; //we'll just send an empty string | 53 | QString link; //we'll just send an empty string |
54 | e << link; | 54 | e << link; |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Scans root directory for any tabs or applications. Will recursivly go down, | 59 | * Scans root directory for any tabs or applications. Will recursivly go down, |
60 | * but will not follow symlinks. | 60 | * but will not follow symlinks. |
61 | * @param directory - the directory to look in. | 61 | * @param directory - the directory to look in. |
62 | * @param parent - the parent to place any new tabs or apps into. If parent is | 62 | * @param parent - the parent to place any new tabs or apps into. If parent is |
63 | * NULL then the item is a tab and should be placed as a child of the window. | 63 | * NULL then the item is a tab and should be placed as a child of the window. |
64 | */ | 64 | */ |
65 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ | 65 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ |
66 | //qDebug(QString("rescanFolder: ") + directory.latin1()); | 66 | //qDebug(QString("rescanFolder: ") + directory.latin1()); |
67 | 67 | ||
68 | QDir d; | 68 | QDir d; |
69 | d.setPath(directory); | 69 | d.setPath(directory); |
70 | // Show hidden files for .directories | 70 | // Show hidden files for .directories |
71 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); | 71 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); |
72 | 72 | ||
73 | const QFileInfoList *list = d.entryInfoList(); | 73 | const QFileInfoList *list = d.entryInfoList(); |
74 | QFileInfoListIterator it( *list ); // create list iterator | 74 | QFileInfoListIterator it( *list ); // create list iterator |
75 | QFileInfo *fi; // pointer for traversing | 75 | QFileInfo *fi; // pointer for traversing |
76 | 76 | ||
77 | while ( (fi=it.current()) ) { // for each file... | 77 | while ( (fi=it.current()) ) { // for each file... |
78 | // If it is a dir and not .. or . then add it as a tab and go down. | 78 | // If it is a dir and not .. or . then add it as a tab and go down. |
79 | if(fi->isDir()){ | 79 | if(fi->isDir()){ |
80 | if(fi->fileName() != ".." && fi->fileName() != ".") { | 80 | if(fi->fileName() != ".." && fi->fileName() != ".") { |
81 | QListViewItem* newItem; | 81 | QListViewItem* newItem; |
82 | if(!parent) | 82 | if(!parent) |
83 | newItem = new QListViewItem(tabList, fi->fileName()); | 83 | newItem = new QListViewItem(tabList, fi->fileName()); |
84 | else | 84 | else |
85 | newItem = new QListViewItem(parent, fi->fileName()); | 85 | newItem = new QListViewItem(parent, fi->fileName()); |
86 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); | 86 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); |
87 | rescanFolder(directory + "/" + fi->fileName(), newItem); | 87 | rescanFolder(directory + "/" + fi->fileName(), newItem); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | else{ | 90 | else{ |
91 | // it is a file, if not a .directory add to parent. | 91 | // it is a file, if not a .directory add to parent. |
92 | 92 | ||
93 | // Change parents name and icon to reflect icon. | 93 | // Change parents name and icon to reflect icon. |
94 | if(fi->fileName() == ".directory"){ | 94 | if(fi->fileName() == ".directory"){ |
95 | AppLnk app(directory + "/" + fi->fileName()); | 95 | AppLnk app(directory + "/" + fi->fileName()); |
96 | if(parent){ | 96 | if(parent){ |
97 | parent->setPixmap(0,app.pixmap()); | 97 | parent->setPixmap(0,app.pixmap()); |
98 | parent->setText(0, app.name()); | 98 | parent->setText(0, app.name()); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | else{ | 101 | else{ |
102 | // Add any desktop files found. | 102 | // Add any desktop files found. |
103 | QListViewItem* newItem; | 103 | QListViewItem* newItem; |
104 | if(directory != HOME_APP_DIR){ | 104 | if(directory != HOME_APP_DIR){ |
105 | if(!parent) | 105 | if(!parent) |
106 | newItem = new QListViewItem(tabList, fi->fileName()); | 106 | newItem = new QListViewItem(tabList, fi->fileName()); |
107 | else | 107 | else |
108 | newItem = new QListViewItem(parent, fi->fileName()); | 108 | newItem = new QListViewItem(parent, fi->fileName()); |
109 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ | 109 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ |
110 | AppLnk app(directory + "/" + fi->fileName()); | 110 | AppLnk app(directory + "/" + fi->fileName()); |
111 | newItem->setPixmap(0,app.pixmap()); | 111 | newItem->setPixmap(0,app.pixmap()); |
112 | newItem->setText(0, app.name()); | 112 | newItem->setText(0, app.name()); |
113 | itemList.insert(newItem, directory + "/" + fi->fileName()); | 113 | itemList.insert(newItem, directory + "/" + fi->fileName()); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | ++it; // goto next list element | 118 | ++it; // goto next list element |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Create a new blank Tab. | 123 | * Create a new blank Tab. |
124 | * Create a physical folder with .directory file | 124 | * Create a physical folder with .directory file |
125 | * Create a item on the list | 125 | * Create a item on the list |
126 | */ | 126 | */ |
127 | void TabManager::newFolder(){ | 127 | void TabManager::newFolder(){ |
128 | QDir r; | 128 | QDir r; |
129 | r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER); | 129 | r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER); |
130 | system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); | 130 | system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); |
131 | system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); | 131 | system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); |
132 | 132 | ||
133 | QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory"; | 133 | QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory"; |
134 | QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER); | 134 | QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER); |
135 | itemList.insert(newItem, homeLocation ); | 135 | itemList.insert(newItem, homeLocation ); |
136 | 136 | ||
137 | // We have changed something. | 137 | // We have changed something. |
138 | changed = true; | 138 | changed = true; |
139 | } | 139 | } |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * Create a new blank application | 142 | * Create a new blank application |
143 | * Make sure a tab is selected | 143 | * Make sure a tab is selected |
144 | * create physical file | 144 | * create physical file |
145 | * fill file with default information (entry, name, type). | 145 | * fill file with default information (entry, name, type). |
146 | */ | 146 | */ |
147 | void TabManager::newApplication(){ | 147 | void TabManager::newApplication(){ |
148 | QListViewItem *item = tabList->currentItem(); | 148 | QListViewItem *item = tabList->currentItem(); |
149 | if(!item || item->parent()) | 149 | if(!item || item->parent()) |
150 | return; | 150 | return; |
151 | 151 | ||
152 | QString parentDir = itemList[item].mid(0,itemList[item].length()-11); | 152 | QString parentDir = itemList[item].mid(0,itemList[item].length()-11); |
153 | QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION; | 153 | QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION; |
154 | system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1()); | 154 | system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1()); |
155 | system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1()); | 155 | system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1()); |
156 | int slash = parentDir.findRev('/', -1); | 156 | int slash = parentDir.findRev('/', -1); |
157 | QString folderName = parentDir.mid(slash+1, parentDir.length()); | 157 | QString folderName = parentDir.mid(slash+1, parentDir.length()); |
158 | 158 | ||
159 | system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1()); | 159 | system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1()); |
160 | 160 | ||
161 | // Insert into the tree | 161 | // Insert into the tree |
162 | QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION); | 162 | QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION); |
163 | itemList.insert(newItem, homeLocation ); | 163 | itemList.insert(newItem, homeLocation ); |
164 | 164 | ||
165 | // We have changed something. | 165 | // We have changed something. |
166 | changed = true; | 166 | changed = true; |
167 | } | 167 | } |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Remove the item. | 170 | * Remove the item. |
171 | * Check if we can | 171 | * Check if we can |
172 | * Prompt user | 172 | * Prompt user |
173 | * Delete physical file (Dir, remove .dir, then dir. File, remove file) | 173 | * Delete physical file (Dir, remove .dir, then dir. File, remove file) |
174 | * Remove from installer if need too. | 174 | * Remove from installer if need too. |
175 | */ | 175 | */ |
176 | void TabManager::removeItem(){ | 176 | void TabManager::removeItem(){ |
177 | // Make sure we can delete | 177 | // Make sure we can delete |
178 | QListViewItem *item = tabList->currentItem(); | 178 | QListViewItem *item = tabList->currentItem(); |
179 | if(!item) | 179 | if(!item) |
180 | return; | 180 | return; |
181 | if(item->childCount() > 0){ | 181 | if(item->childCount() > 0){ |
182 | QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") ); | 182 | QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") ); |
183 | return; | 183 | return; |
184 | } | 184 | } |
185 | 185 | ||
186 | // Prompt. | 186 | // Prompt. |
187 | int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 ); | 187 | int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 ); |
188 | if (answer) | 188 | if (answer) |
189 | return; | 189 | return; |
190 | 190 | ||
191 | bool removeSuccessful = true; | 191 | bool removeSuccessful = true; |
192 | QString location = itemList[item]; | 192 | QString location = itemList[item]; |
193 | // Remove file (.directory in a Directory case) | 193 | // Remove file (.directory in a Directory case) |
194 | if(!QFile::remove(location)) | 194 | if(!QFile::remove(location)) |
195 | removeSuccessful = false; | 195 | removeSuccessful = false; |
196 | 196 | ||
197 | // Remove directory | 197 | // Remove directory |
198 | if(item->parent() == NULL){ | 198 | if(item->parent() == NULL){ |
199 | // Remove .directory file string | 199 | // Remove .directory file string |
200 | location = location.mid(0,location.length()-10); | 200 | location = location.mid(0,location.length()-10); |
201 | QDir dir; | 201 | QDir dir; |
202 | if(!dir.rmdir(location)) | 202 | if(!dir.rmdir(location)) |
203 | removeSuccessful = false; | 203 | removeSuccessful = false; |
204 | else | 204 | else |
205 | removeSuccessful = true; | 205 | removeSuccessful = true; |
206 | } | 206 | } |
207 | 207 | ||
208 | // If removing failed. | 208 | // If removing failed. |
209 | if(!removeSuccessful){ | 209 | if(!removeSuccessful){ |
210 | qDebug((QString("removeItem: ") + location).latin1()); | 210 | qDebug((QString("removeItem: ") + location).latin1()); |
211 | QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); | 211 | QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); |
212 | return; | 212 | return; |
213 | } | 213 | } |
214 | 214 | ||
215 | // Remove from the installer so it wont fail. | 215 | // Remove from the installer so it wont fail. |
216 | // Don't need to do this sense the current install uses rm -f so no error | 216 | // Don't need to do this sense the current install uses rm -f so no error |
217 | 217 | ||
218 | // Remove from the gui list. | 218 | // Remove from the gui list. |
219 | itemList.remove(item); | 219 | itemList.remove(item); |
220 | if(item->parent()) | 220 | if(item->parent()) |
221 | item->parent()->takeItem(item); | 221 | item->parent()->takeItem(item); |
222 | delete item; | 222 | delete item; |
223 | 223 | ||
224 | // We have changed something. | 224 | // We have changed something. |
225 | changed = true; | 225 | changed = true; |
226 | } | 226 | } |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * Helper function. Edits the current item. | 229 | * Helper function. Edits the current item. |
230 | * calls editItem with the currently selected item. | 230 | * calls editItem with the currently selected item. |
231 | */ | 231 | */ |
232 | void TabManager::editCurrentItem(){ | 232 | void TabManager::editCurrentItem(){ |
233 | editItem(tabList->currentItem()); | 233 | editItem(tabList->currentItem()); |
234 | } | 234 | } |
235 | 235 | ||
236 | /** | 236 | /** |
237 | * Edit the item that is passed in. | 237 | * Edit the item that is passed in. |
238 | * Show application dialog and if anything changed | 238 | * Show application dialog and if anything changed |
239 | * @param item the item to edit. | 239 | * @param item the item to edit. |
240 | */ | 240 | */ |
241 | void TabManager::editItem( QListViewItem * item){ | 241 | void TabManager::editItem( QListViewItem * item){ |
242 | if(!item) | 242 | if(!item) |
243 | return; | 243 | return; |
244 | 244 | ||
245 | TabAppLnk app(itemList[item]); | 245 | TabAppLnk app(itemList[item]); |
246 | if(!app.isValid()){ | 246 | if(!app.isValid()){ |
247 | qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1()); | 247 | qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1()); |
248 | return; | 248 | return; |
249 | } | 249 | } |
250 | 250 | ||
251 | // Fill with all of the icons | 251 | // Fill with all of the icons |
252 | if(!application){ | 252 | if(!application){ |
253 | Wait waitDialog(this, "Wait dialog"); | 253 | Wait waitDialog(this, "Wait dialog"); |
254 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 254 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
255 | waitDialog.show(); | 255 | waitDialog.show(); |
256 | qApp->processEvents(); | 256 | qApp->processEvents(); |
257 | application = new AppEdit(this, "Application edit", true); | 257 | application = new AppEdit(this, "Application edit", true); |
258 | 258 | ||
259 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 259 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
260 | d.setFilter( QDir::Files); | 260 | d.setFilter( QDir::Files); |
261 | 261 | ||
262 | const QFileInfoList *list = d.entryInfoList(); | 262 | const QFileInfoList *list = d.entryInfoList(); |
263 | QFileInfoListIterator it( *list ); // create list iterator | 263 | QFileInfoListIterator it( *list ); // create list iterator |
264 | QFileInfo *fi; // pointer for traversing | 264 | QFileInfo *fi; // pointer for traversing |
265 | 265 | ||
266 | while ( (fi=it.current()) ) { // for each file... | 266 | while ( (fi=it.current()) ) { // for each file... |
267 | QString fileName = fi->fileName(); | 267 | QString fileName = fi->fileName(); |
268 | if(fileName.right(4) == ".png"){ | 268 | if(fileName.right(4) == ".png"){ |
269 | fileName = fileName.mid(0,fileName.length()-4); | 269 | fileName = fileName.mid(0,fileName.length()-4); |
270 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 270 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
271 | QImage foo = imageOfFile.convertToImage(); | 271 | QImage foo = imageOfFile.convertToImage(); |
272 | foo = foo.smoothScale(16,16); | 272 | foo = foo.smoothScale(16,16); |
273 | imageOfFile.convertFromImage(foo); | 273 | imageOfFile.convertFromImage(foo); |
274 | application->iconLineEdit->insertItem(imageOfFile,fileName); | 274 | application->iconLineEdit->insertItem(imageOfFile,fileName); |
275 | } | 275 | } |
276 | //qDebug(fi->fileName().latin1()); | 276 | //qDebug(fi->fileName().latin1()); |
277 | ++it; | 277 | ++it; |
278 | } | 278 | } |
279 | waitDialog.hide(); | 279 | waitDialog.hide(); |
280 | } | 280 | } |
281 | int pixmap = -1; | 281 | int pixmap = -1; |
282 | QString pixmapText = app.pixmapString(); | 282 | QString pixmapText = app.pixmapString(); |
283 | QComboBox *f = application->iconLineEdit; | 283 | QComboBox *f = application->iconLineEdit; |
284 | for(int i = 0; i < application->iconLineEdit->count(); i++){ | 284 | for(int i = 0; i < application->iconLineEdit->count(); i++){ |
285 | if(f->text(i) == pixmapText){ | 285 | if(f->text(i) == pixmapText){ |
286 | pixmap = i; | 286 | pixmap = i; |
287 | break; | 287 | break; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | if(pixmap != -1) | 290 | if(pixmap != -1) |
291 | application->iconLineEdit->setCurrentItem(pixmap); | 291 | application->iconLineEdit->setCurrentItem(pixmap); |
292 | else if(pixmapText.isEmpty()){ | 292 | else if(pixmapText.isEmpty()){ |
293 | application->iconLineEdit->setCurrentItem(0); | 293 | application->iconLineEdit->setCurrentItem(0); |
294 | } | 294 | } |
295 | else{ | 295 | else{ |
296 | QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); | 296 | QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); |
297 | QImage foo = imageOfFile.convertToImage(); | 297 | QImage foo = imageOfFile.convertToImage(); |
298 | foo = foo.smoothScale(16,16); | 298 | foo = foo.smoothScale(16,16); |
299 | imageOfFile.convertFromImage(foo); | 299 | imageOfFile.convertFromImage(foo); |
300 | application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); | 300 | application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); |
301 | application->iconLineEdit->setCurrentItem(0); | 301 | application->iconLineEdit->setCurrentItem(0); |
302 | } | 302 | } |
303 | 303 | ||
304 | application->nameLineEdit->setText(app.name()); | 304 | application->nameLineEdit->setText(app.name()); |
305 | application->execLineEdit->setText(app.exec()); | 305 | application->execLineEdit->setText(app.exec()); |
306 | application->commentLineEdit->setText(app.comment()); | 306 | application->commentLineEdit->setText(app.comment()); |
307 | 307 | ||
308 | if(item->parent() == NULL){ | 308 | if(item->parent() == NULL){ |
309 | application->execLineEdit->setEnabled(false); | 309 | application->execLineEdit->setEnabled(false); |
310 | application->TextLabel3->setEnabled(false); | 310 | application->TextLabel3->setEnabled(false); |
311 | application->setCaption(tr("Tab")); | 311 | application->setCaption(tr("Tab")); |
312 | } | 312 | } |
313 | else{ | 313 | else{ |
314 | application->execLineEdit->setEnabled(true); | 314 | application->execLineEdit->setEnabled(true); |
315 | application->TextLabel3->setEnabled(true); | 315 | application->TextLabel3->setEnabled(true); |
316 | application->setCaption(tr("Application")); | 316 | application->setCaption(tr("Application")); |
317 | } | 317 | } |
318 | 318 | ||
319 | // Only do somthing if they hit OK | 319 | // Only do somthing if they hit OK |
320 | application->showMaximized(); | 320 | application->showMaximized(); |
321 | if(application->exec() == 0) | 321 | if(application->exec() == 0) |
322 | return; | 322 | return; |
323 | 323 | ||
324 | // If nothing has changed exit (hmmm why did they hit ok?) | 324 | // If nothing has changed exit (hmmm why did they hit ok?) |
325 | if(app.name() == application->nameLineEdit->text() && | 325 | if(app.name() == application->nameLineEdit->text() && |
326 | app.pixmapString() == application->iconLineEdit->currentText() && | 326 | app.pixmapString() == application->iconLineEdit->currentText() && |
327 | app.comment() == application->commentLineEdit->text() && | 327 | app.comment() == application->commentLineEdit->text() && |
328 | app.exec() == application->execLineEdit->text()) | 328 | app.exec() == application->execLineEdit->text()) |
329 | return; | 329 | return; |
330 | 330 | ||
331 | // Change the applnk file | 331 | // Change the applnk file |
332 | QString oldName = app.name(); | 332 | QString oldName = app.name(); |
333 | app.setName(application->nameLineEdit->text()); | 333 | app.setName(application->nameLineEdit->text()); |
334 | app.setIcon(application->iconLineEdit->currentText()); | 334 | app.setIcon(application->iconLineEdit->currentText()); |
335 | app.setComment(application->commentLineEdit->text()); | 335 | app.setComment(application->commentLineEdit->text()); |
336 | app.setExec(application->execLineEdit->text()); | 336 | app.setExec(application->execLineEdit->text()); |
337 | if(!app.writeLink()){ | 337 | if(!app.writeLink()){ |
338 | QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); | 338 | QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | 341 | ||
342 | // Update the gui icon and name | 342 | // Update the gui icon and name |
343 | item->setText(0,app.name()); | 343 | item->setText(0,app.name()); |
344 | item->setPixmap(0,app.pixmap()); | 344 | item->setPixmap(0,app.pixmap()); |
345 | 345 | ||
346 | // We have changed something. | 346 | // We have changed something. |
347 | changed = true; | 347 | changed = true; |
348 | 348 | ||
349 | // If we were dealing with a new folder or new application change | 349 | // If we were dealing with a new folder or new application change |
350 | // the file names. Also change the item location in itemList | 350 | // the file names. Also change the item location in itemList |
351 | if(oldName == NEW_FOLDER){ | 351 | if(oldName == NEW_FOLDER){ |
352 | QDir r; | 352 | QDir r; |
353 | QString oldName = itemList[item]; | 353 | QString oldName = itemList[item]; |
354 | oldName = oldName.mid(0,oldName.length()-11); | 354 | oldName = oldName.mid(0,oldName.length()-11); |
355 | QString newName = oldName.mid(0,oldName.length()-9); | 355 | QString newName = oldName.mid(0,oldName.length()-9); |
356 | newName = newName + "/" + app.name(); | 356 | newName = newName + "/" + app.name(); |
357 | r.rename(oldName, newName); | 357 | r.rename(oldName, newName); |
358 | itemList.remove(item); | 358 | itemList.remove(item); |
359 | itemList.insert(item, newName + "/.directory" ); | 359 | itemList.insert(item, newName + "/.directory" ); |
360 | } | 360 | } |
361 | else if(oldName == NEW_APPLICATION){ | 361 | else if(oldName == NEW_APPLICATION){ |
362 | if(!item->parent()) | 362 | if(!item->parent()) |
363 | return; | 363 | return; |
364 | QString parentDir = itemList[item->parent()]; | 364 | QString parentDir = itemList[item->parent()]; |
365 | QDir r; | 365 | QDir r; |
366 | QString oldName = itemList[item]; | 366 | QString oldName = itemList[item]; |
367 | QString newName = oldName.mid(0, parentDir.length()-10); | 367 | QString newName = oldName.mid(0, parentDir.length()-10); |
368 | newName = newName + app.name() + APPLICATION_EXTENSION; | 368 | newName = newName + app.name() + APPLICATION_EXTENSION; |
369 | r.rename(oldName, newName); | 369 | r.rename(oldName, newName); |
370 | itemList.remove(item); | 370 | itemList.remove(item); |
371 | itemList.insert(item, newName); | 371 | itemList.insert(item, newName); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | 374 | ||
375 | /** | 375 | /** |
376 | * Move an application from one directory to another. | 376 | * Move an application from one directory to another. |
377 | * Move in the gui, move in the applnk file, move in the installer. | 377 | * Move in the gui, move in the applnk file, move in the installer. |
378 | * @param item the application to move | 378 | * @param item the application to move |
379 | * @pearam newGroup the new parent of this application | 379 | * @pearam newGroup the new parent of this application |
380 | */ | 380 | */ |
381 | void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ | 381 | void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ |
382 | // Can we even move it? | 382 | // Can we even move it? |
383 | if(!item || !item->parent() || newGroup->parent()) | 383 | if(!item || !item->parent() || newGroup->parent()) |
384 | return; | 384 | return; |
385 | if(item->parent() == newGroup) | 385 | if(item->parent() == newGroup) |
386 | return; | 386 | return; |
387 | 387 | ||
388 | // Get the new folder, new file name, | 388 | // Get the new folder, new file name, |
389 | QString newFolder = itemList[newGroup]; | 389 | QString newFolder = itemList[newGroup]; |
390 | newFolder = newFolder.mid(0,newFolder.length()-11); | 390 | newFolder = newFolder.mid(0,newFolder.length()-11); |
391 | int slash = newFolder.findRev('/', -1); | 391 | int slash = newFolder.findRev('/', -1); |
392 | QString folderName = newFolder.mid(slash+1, newFolder.length()); | 392 | QString folderName = newFolder.mid(slash+1, newFolder.length()); |
393 | 393 | ||
394 | QString desktopFile = itemList[item]; | 394 | QString desktopFile = itemList[item]; |
395 | slash = desktopFile.findRev('/', -1); | 395 | slash = desktopFile.findRev('/', -1); |
396 | desktopFile = desktopFile.mid(slash, desktopFile.length()); | 396 | desktopFile = desktopFile.mid(slash, desktopFile.length()); |
397 | newFolder = newFolder + desktopFile; | 397 | newFolder = newFolder + desktopFile; |
398 | 398 | ||
399 | // Move file | 399 | // Move file |
400 | QDir r; | 400 | QDir r; |
401 | if(!r.rename(itemList[item], newFolder)){ | 401 | if(!r.rename(itemList[item], newFolder)){ |
402 | QMessageBox::critical(this, tr("Message"), "Can't move application.", tr("Ok") ); | 402 | QMessageBox::critical(this, tr("Message"), "Can't move application.", tr("Ok") ); |
403 | return; | 403 | return; |
404 | } | 404 | } |
405 | //qDebug((QString("moveApplication: ") + itemList[item]).latin1()); | 405 | //qDebug((QString("moveApplication: ") + itemList[item]).latin1()); |
406 | //qDebug((QString("moveApplication: ") + newFolder).latin1()); | 406 | //qDebug((QString("moveApplication: ") + newFolder).latin1()); |
407 | 407 | ||
408 | // Move in the gui | 408 | // Move in the gui |
409 | item->parent()->takeItem(item); | 409 | item->parent()->takeItem(item); |
410 | newGroup->insertItem(item); | 410 | newGroup->insertItem(item); |
411 | newGroup->setOpen(true); | 411 | newGroup->setOpen(true); |
412 | 412 | ||
413 | // Move file in the installer | 413 | // Move file in the installer |
414 | QString installedAppFile; | 414 | QString installedAppFile; |
415 | if(findInstalledApplication(desktopFile, installedAppFile)) | 415 | if(findInstalledApplication(desktopFile, installedAppFile)) |
416 | swapInstalledLocation(installedAppFile, desktopFile, newFolder); | 416 | swapInstalledLocation(installedAppFile, desktopFile, newFolder); |
417 | else | 417 | else |
418 | qDebug("moveApplication: No installed app found for dekstop file"); | 418 | qDebug("moveApplication: No installed app found for dekstop file"); |
419 | 419 | ||
420 | // Move application type | 420 | // Move application type |
421 | AppLnk app(newFolder); | 421 | AppLnk app(newFolder); |
422 | app.setType(folderName); | 422 | app.setType(folderName); |
423 | app.writeLink(); | 423 | app.writeLink(); |
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index 5411995..a1130d4 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -1,257 +1,257 @@ | |||
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 <qlayout.h> | 12 | #include <qlayout.h> |
13 | 13 | ||
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | #include <qfile.h> | 15 | #include <qfile.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | 17 | ||
18 | #include <qregexp.h> | 18 | #include <qregexp.h> |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * The mainwindow constructor. | 21 | * The mainwindow constructor. |
22 | * | 22 | * |
23 | * @param QWidget *parent | 23 | * @param QWidget *parent |
24 | * @param const char *name | 24 | * @param const char *name |
25 | * @ param WFlags fl | 25 | * @ param WFlags fl |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { | 28 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { |
29 | setCaption(tr("Opie User Manager")); | 29 | setCaption(tr("Opie User Manager")); |
30 | 30 | ||
31 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. | 31 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. |
32 | accounts=new Passwd(); | 32 | accounts=new Passwd(); |
33 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. | 33 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. |
34 | 34 | ||
35 | // Create the toolbar. | 35 | // Create the toolbar. |
36 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); | 36 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); |
37 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? | 37 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? |
38 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); | 38 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); |
39 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); | 39 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); |
40 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); | 40 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); |
41 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); | 41 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); |
42 | userstext->setUsesTextLabel(true); | 42 | userstext->setUsesTextLabel(true); |
43 | toolbar->addSeparator(); | 43 | toolbar->addSeparator(); |
44 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); | 44 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); |
45 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); | 45 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); |
46 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); | 46 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); |
47 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); | 47 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); |
48 | groupstext->setUsesTextLabel(true); | 48 | groupstext->setUsesTextLabel(true); |
49 | addToolBar(toolbar,"myToolBar"); | 49 | addToolBar(toolbar,"myToolBar"); |
50 | 50 | ||
51 | // Add a tabwidget and all the tabs. | 51 | // Add a tabwidget and all the tabs. |
52 | myTabWidget = new QTabWidget(this,"My Tab Widget"); | 52 | myTabWidget = new QTabWidget(this,"My Tab Widget"); |
53 | setupTabAccounts(); | 53 | setupTabAccounts(); |
54 | setupTabAllUsers(); | 54 | setupTabAllUsers(); |
55 | setupTabAllGroups(); | 55 | setupTabAllGroups(); |
56 | userPopupMenu.insertItem("Copy",0); | 56 | userPopupMenu.insertItem("Copy",0); |
57 | 57 | ||
58 | getUsers(); // Fill out the iconview & listview with all users. | 58 | getUsers(); // Fill out the iconview & listview with all users. |
59 | getGroups(); // Fill out the group listview with all groups. | 59 | getGroups(); // Fill out the group listview with all groups. |
60 | 60 | ||
61 | setCentralWidget(myTabWidget); | 61 | setCentralWidget(myTabWidget); |
62 | } | 62 | } |
63 | 63 | ||
64 | UserConfig::~UserConfig() { | 64 | UserConfig::~UserConfig() { |
65 | accounts->close(); | 65 | accounts->close(); |
66 | delete accounts; | 66 | delete accounts; |
67 | } | 67 | } |
68 | 68 | ||
69 | void UserConfig::setupTabAccounts() { | 69 | void UserConfig::setupTabAccounts() { |
70 | QWidget *tabpage = new QWidget(this); | 70 | QWidget *tabpage = new QWidget(this); |
71 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 71 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
72 | layout->setMargin(5); | 72 | layout->setMargin(5); |
73 | 73 | ||
74 | usersIconView=new QListView(tabpage,"users"); | 74 | usersIconView=new QListView(tabpage,"users"); |
75 | usersIconView->addColumn("Icon"); | 75 | usersIconView->addColumn("Icon"); |
76 | usersIconView->addColumn("Username"); | 76 | usersIconView->addColumn("Username"); |
77 | usersIconView->setAllColumnsShowFocus(true); | 77 | usersIconView->setAllColumnsShowFocus(true); |
78 | layout->addWidget(usersIconView); | 78 | layout->addWidget(usersIconView); |
79 | 79 | ||
80 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); | 80 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem*)),this,SLOT(showUserMenu(QListViewItem*))); |
81 | 81 | ||
82 | myTabWidget->addTab(tabpage,"Users"); | 82 | myTabWidget->addTab(tabpage,"Users"); |
83 | } | 83 | } |
84 | 84 | ||
85 | void UserConfig::setupTabAllUsers() { | 85 | void UserConfig::setupTabAllUsers() { |
86 | QWidget *tabpage = new QWidget(this); | 86 | QWidget *tabpage = new QWidget(this); |
87 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 87 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
88 | layout->setMargin(5); | 88 | layout->setMargin(5); |
89 | 89 | ||
90 | usersListView=new QListView(tabpage,"allusers"); | 90 | usersListView=new QListView(tabpage,"allusers"); |
91 | usersListView->addColumn("UID"); | 91 | usersListView->addColumn("UID"); |
92 | usersListView->addColumn("Login"); | 92 | usersListView->addColumn("Login"); |
93 | usersListView->addColumn("Username"); | 93 | usersListView->addColumn("Username"); |
94 | layout->addWidget(usersListView); | 94 | layout->addWidget(usersListView); |
95 | usersListView->setSorting(1,1); | 95 | usersListView->setSorting(1,1); |
96 | usersListView->setAllColumnsShowFocus(true); | 96 | usersListView->setAllColumnsShowFocus(true); |
97 | 97 | ||
98 | myTabWidget->addTab(tabpage,"All Users"); | 98 | myTabWidget->addTab(tabpage,"All Users"); |
99 | } | 99 | } |
100 | 100 | ||
101 | void UserConfig::setupTabAllGroups() { | 101 | void UserConfig::setupTabAllGroups() { |
102 | QWidget *tabpage = new QWidget(this); | 102 | QWidget *tabpage = new QWidget(this); |
103 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 103 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
104 | layout->setMargin(5); | 104 | layout->setMargin(5); |
105 | 105 | ||
106 | groupsListView=new QListView(tabpage,"groups"); | 106 | groupsListView=new QListView(tabpage,"groups"); |
107 | groupsListView->addColumn("GID"); | 107 | groupsListView->addColumn("GID"); |
108 | groupsListView->addColumn("Groupname"); | 108 | groupsListView->addColumn("Groupname"); |
109 | layout->addWidget(groupsListView); | 109 | layout->addWidget(groupsListView); |
110 | groupsListView->setSorting(1,1); | 110 | groupsListView->setSorting(1,1); |
111 | groupsListView->setAllColumnsShowFocus(true); | 111 | groupsListView->setAllColumnsShowFocus(true); |
112 | 112 | ||
113 | myTabWidget->addTab(tabpage,"All Groups"); | 113 | myTabWidget->addTab(tabpage,"All Groups"); |
114 | } | 114 | } |
115 | void UserConfig::getUsers() { | 115 | void UserConfig::getUsers() { |
116 | QString mytext; | 116 | QString mytext; |
117 | QPixmap mypixmap; | 117 | QPixmap mypixmap; |
118 | QListViewItem *listviewitem; | 118 | QListViewItem *listviewitem; |
119 | 119 | ||
120 | // Empty the iconview & the listview. | 120 | // Empty the iconview & the listview. |
121 | usersIconView->clear(); | 121 | usersIconView->clear(); |
122 | usersListView->clear(); | 122 | usersListView->clear(); |
123 | 123 | ||
124 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. | 124 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. |
125 | availableUID=500; | 125 | availableUID=500; |
126 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { | 126 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { |
127 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) | 127 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) |
128 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 128 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
129 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); | 129 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); |
130 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? | 130 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? |
131 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. | 131 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. |
132 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. | 132 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. |
133 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. | 133 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. |
134 | } | 134 | } |
135 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. | 135 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. |
136 | listviewitem->setPixmap(0,mypixmap); | 136 | listviewitem->setPixmap(0,mypixmap); |
137 | } | 137 | } |
138 | if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid. | 138 | if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid. |
139 | } | 139 | } |
140 | } | 140 | } |
141 | usersIconView->sort(); | 141 | usersIconView->sort(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void UserConfig::addUser() { | 144 | void UserConfig::addUser() { |
145 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. | 145 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. |
146 | getUsers(); // Update users views. | 146 | getUsers(); // Update users views. |
147 | getGroups(); // Update groups view. | 147 | getGroups(); // Update groups view. |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | void UserConfig::editUser() { | 151 | void UserConfig::editUser() { |
152 | QString username; | 152 | QString username; |
153 | if(myTabWidget->currentPageIndex()==0) {// Users | 153 | if(myTabWidget->currentPageIndex()==0) {// Users |
154 | if(usersIconView->currentItem()) {// Any icon selected? | 154 | if(usersIconView->currentItem()) {// Any icon selected? |
155 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. | 155 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. |
156 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 156 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
157 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 157 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
158 | // If there were any changed also update the views. | 158 | // If there were any changed also update the views. |
159 | getUsers(); | 159 | getUsers(); |
160 | getGroups(); | 160 | getGroups(); |
161 | } | 161 | } |
162 | } else { | 162 | } else { |
163 | QMessageBox::information(this,"No selection.","No user has been selected."); | 163 | QMessageBox::information(this,"No selection.","No user has been selected."); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | if(myTabWidget->currentPageIndex()==1) {// All users | 166 | if(myTabWidget->currentPageIndex()==1) {// All users |
167 | if(usersListView->currentItem()) {// Anything changed!? | 167 | if(usersListView->currentItem()) {// Anything changed!? |
168 | username=usersListView->currentItem()->text(1);// Get the username. | 168 | username=usersListView->currentItem()->text(1);// Get the username. |
169 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 169 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
170 | // And again update the views if there were any changes. | 170 | // And again update the views if there were any changes. |
171 | getUsers(); | 171 | getUsers(); |
172 | getGroups(); | 172 | getGroups(); |
173 | } | 173 | } |
174 | } else { | 174 | } else { |
175 | QMessageBox::information(this,"No selection.","No user has been selected."); | 175 | QMessageBox::information(this,"No selection.","No user has been selected."); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | void UserConfig::delUser() { | 180 | void UserConfig::delUser() { |
181 | QString username; | 181 | QString username; |
182 | 182 | ||
183 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. | 183 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. |
184 | if(usersIconView->currentItem()) {// Anything selected? | 184 | if(usersIconView->currentItem()) {// Anything selected? |
185 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. | 185 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. |
186 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 186 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
187 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 187 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
188 | if(UserDialog::delUser(username)) {// Delete the user if possible. | 188 | if(UserDialog::delUser(username)) {// Delete the user if possible. |
189 | // Update views. | 189 | // Update views. |
190 | getUsers(); | 190 | getUsers(); |
191 | getGroups(); | 191 | getGroups(); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | } else { | 194 | } else { |
195 | QMessageBox::information(this,"No selection","No user has been selected."); | 195 | QMessageBox::information(this,"No selection","No user has been selected."); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | if(myTabWidget->currentPageIndex()==1) {// All users | 198 | if(myTabWidget->currentPageIndex()==1) {// All users |
199 | if(usersListView->currentItem()) {// Anything changed!? | 199 | if(usersListView->currentItem()) {// Anything changed!? |
200 | username=usersListView->currentItem()->text(1);// Get the username. | 200 | username=usersListView->currentItem()->text(1);// Get the username. |
201 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 201 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
202 | if(UserDialog::delUser(username)) {// Try to delete the user. | 202 | if(UserDialog::delUser(username)) {// Try to delete the user. |
203 | // Update views. | 203 | // Update views. |
204 | getUsers(); | 204 | getUsers(); |
205 | getGroups(); | 205 | getGroups(); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } else { | 208 | } else { |
209 | QMessageBox::information(this,"No selection","No user has been selected."); | 209 | QMessageBox::information(this,"No selection","No user has been selected."); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | } | 213 | } |
214 | 214 | ||
215 | void UserConfig::getGroups() { | 215 | void UserConfig::getGroups() { |
216 | groupsListView->clear();// Empty the listview. | 216 | groupsListView->clear();// Empty the listview. |
217 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. | 217 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. |
218 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. | 218 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. |
219 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). | 219 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). |
220 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 220 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
221 | new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); | 221 | new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); |
222 | if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. | 222 | if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. |
223 | } | 223 | } |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | void UserConfig::addGroup() { | 227 | void UserConfig::addGroup() { |
228 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. | 228 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. |
229 | } | 229 | } |
230 | 230 | ||
231 | void UserConfig::editGroup() { | 231 | void UserConfig::editGroup() { |
232 | int gid; | 232 | int gid; |
233 | if(groupsListView->currentItem()) {// Any group selected? | 233 | if(groupsListView->currentItem()) {// Any group selected? |
234 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. | 234 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. |
235 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. | 235 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. |
236 | } else { | 236 | } else { |
237 | QMessageBox::information(this,"No selection","No group has been selected."); | 237 | QMessageBox::information(this,"No selection","No group has been selected."); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | void UserConfig::delGroup() { | 241 | void UserConfig::delGroup() { |
242 | const char *groupname; | 242 | const char *groupname; |
243 | if(groupsListView->currentItem()) {// Any group selected? | 243 | if(groupsListView->currentItem()) {// Any group selected? |
244 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. | 244 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. |
245 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { | 245 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { |
246 | // If confirmed, try to delete the group. | 246 | // If confirmed, try to delete the group. |
247 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. | 247 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. |
248 | } | 248 | } |
249 | } else { | 249 | } else { |
250 | QMessageBox::information(this,"No selection","No group has been selected."); | 250 | QMessageBox::information(this,"No selection","No group has been selected."); |
251 | } | 251 | } |
252 | } | 252 | } |
253 | 253 | ||
254 | void UserConfig::showUserMenu(QListViewItem *item) { | 254 | void UserConfig::showUserMenu(QListViewItem *item) { |
255 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); | 255 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); |
256 | qWarning("Pressed!"); | 256 | qWarning("Pressed!"); |
257 | } | 257 | } |