66 files changed, 2410 insertions, 1321 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index c376ec7..00128d3 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -1,274 +1,274 @@ | |||
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 <qbuttongroup.h> | 30 | #include <qbuttongroup.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #if QT_VERSION >= 300 | 42 | #if QT_VERSION >= 300 |
43 | #include <qstylefactory.h> | 43 | #include <qstylefactory.h> |
44 | #endif | 44 | #endif |
45 | #include <qtoolbutton.h> | 45 | #include <qtoolbutton.h> |
46 | #include <qwindowsstyle.h> | 46 | #include <qwindowsstyle.h> |
47 | #include <qlistview.h> | 47 | #include <qlistview.h> |
48 | #include <qheader.h> | 48 | #include <qheader.h> |
49 | #include <qvbox.h> | 49 | #include <qvbox.h> |
50 | #include <qwhatsthis.h> | 50 | #include <qwhatsthis.h> |
51 | 51 | ||
52 | #include <qpe/config.h> | 52 | #include <qpe/config.h> |
53 | #include <qpe/global.h> | 53 | #include <qpe/global.h> |
54 | #include <qpe/resource.h> | 54 | #include <qpe/resource.h> |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #include <qpe/qpemessagebox.h> | 56 | #include <qpe/qpemessagebox.h> |
57 | #include <qpe/qcopenvelope_qws.h> | 57 | #include <qpe/qcopenvelope_qws.h> |
58 | #include <qpe/qpestyle.h> | 58 | #include <qpe/qpestyle.h> |
59 | #include <qpe/lightstyle.h> | 59 | #include <qpe/lightstyle.h> |
60 | #include <qpe/qlibrary.h> | 60 | #include <qpe/qlibrary.h> |
61 | #include <qpe/styleinterface.h> | 61 | #include <qpe/styleinterface.h> |
62 | 62 | ||
63 | #include <opie/ofontselector.h> | 63 | #include <opie/ofontselector.h> |
64 | #include <opie/odevice.h> | 64 | #include <opie/odevice.h> |
65 | #include <opie/ofiledialog.h> | 65 | #include <opie/ofiledialog.h> |
66 | #include <opie/otabwidget.h> | 66 | #include <opie/otabwidget.h> |
67 | 67 | ||
68 | #include "appearance.h" | 68 | #include "appearance.h" |
69 | #include "editScheme.h" | 69 | #include "editScheme.h" |
70 | #include "stylelistitem.h" | 70 | #include "stylelistitem.h" |
71 | #include "decolistitem.h" | 71 | #include "decolistitem.h" |
72 | #include "colorlistitem.h" | 72 | #include "colorlistitem.h" |
73 | #include "exceptlistitem.h" | 73 | #include "exceptlistitem.h" |
74 | #include "sample.h" | 74 | #include "sample.h" |
75 | 75 | ||
76 | 76 | ||
77 | using namespace Opie; | 77 | using namespace Opie; |
78 | 78 | ||
79 | 79 | ||
80 | class DefaultWindowDecoration : public WindowDecorationInterface | 80 | class DefaultWindowDecoration : public WindowDecorationInterface |
81 | { | 81 | { |
82 | public: | 82 | public: |
83 | DefaultWindowDecoration() : ref(0) {} | 83 | DefaultWindowDecoration() : ref(0) {} |
84 | QString name() const { | 84 | QString name() const { |
85 | return "Default"; | 85 | return "Default"; |
86 | } | 86 | } |
87 | QPixmap icon() const { | 87 | QPixmap icon() const { |
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 | *iface = 0; | 91 | *iface = 0; |
92 | if ( uuid == IID_QUnknown ) | 92 | if ( uuid == IID_QUnknown ) |
93 | *iface = this; | 93 | *iface = this; |
94 | else if ( uuid == IID_WindowDecoration ) | 94 | else if ( uuid == IID_WindowDecoration ) |
95 | *iface = this; | 95 | *iface = this; |
96 | 96 | ||
97 | if ( *iface ) | 97 | if ( *iface ) |
98 | (*iface)->addRef(); | 98 | (*iface)->addRef(); |
99 | return QS_OK; | 99 | return QS_OK; |
100 | } | 100 | } |
101 | Q_REFCOUNT | 101 | Q_REFCOUNT |
102 | 102 | ||
103 | private: | 103 | private: |
104 | ulong ref; | 104 | ulong ref; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) | 113 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) |
114 | { | 114 | { |
115 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 115 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
116 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 116 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
117 | 117 | ||
118 | m_style_list = new QListBox( tab, "m_style_list" ); | 118 | m_style_list = new QListBox( tab, "m_style_list" ); |
119 | vertLayout->addWidget( m_style_list ); | 119 | vertLayout->addWidget( m_style_list ); |
120 | 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." ) ); | 120 | 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 | 121 | ||
122 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 122 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
123 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 123 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); |
124 | vertLayout-> addWidget ( m_style_settings ); | 124 | vertLayout-> addWidget ( m_style_settings ); |
125 | QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); | 125 | 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 | 126 | ||
127 | QString s = cfg. readEntry ( "Style", "Light" ); | 127 | QString s = cfg. readEntry ( "Style", "Light" ); |
128 | 128 | ||
129 | 129 | ||
130 | #if QT_VERSION >= 300 | 130 | #if QT_VERSION >= 300 |
131 | m_style_list->insertStringList(QStyleFactory::styles()); | 131 | m_style_list->insertStringList(QStyleFactory::styles()); |
132 | #else | 132 | #else |
133 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 133 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
134 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); | 134 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); |
135 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); | 135 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); |
136 | #endif | 136 | #endif |
137 | { | 137 | { |
138 | QString path = QPEApplication::qpeDir ( ); | 138 | QString path = QPEApplication::qpeDir ( ); |
139 | path.append( "/plugins/styles/" ); | 139 | path.append( "/plugins/styles/" ); |
140 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 140 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
141 | 141 | ||
142 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 142 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
143 | QString libstr = path; | 143 | QString libstr = path; |
144 | libstr.append( "/" ); | 144 | libstr.append( "/" ); |
145 | libstr.append( *it ); | 145 | libstr.append( *it ); |
146 | QLibrary *lib = new QLibrary ( libstr ); | 146 | QLibrary *lib = new QLibrary ( libstr ); |
147 | StyleInterface *iface; | 147 | StyleInterface *iface; |
148 | 148 | ||
149 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { | 149 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { |
150 | StyleListItem *slit = new StyleListItem ( lib, iface ); | 150 | StyleListItem *slit = new StyleListItem ( lib, iface ); |
151 | m_style_list-> insertItem ( slit ); | 151 | m_style_list-> insertItem ( slit ); |
152 | 152 | ||
153 | if ( slit-> key ( ) == s ) | 153 | if ( slit-> key ( ) == s ) |
154 | m_style_list-> setCurrentItem ( slit ); | 154 | m_style_list-> setCurrentItem ( slit ); |
155 | } | 155 | } |
156 | else | 156 | else |
157 | delete lib; | 157 | delete lib; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | m_original_style = m_style_list-> currentItem ( ); | 161 | m_original_style = m_style_list-> currentItem ( ); |
162 | styleClicked ( m_original_style ); | 162 | styleClicked ( m_original_style ); |
163 | 163 | ||
164 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 164 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); |
165 | 165 | ||
166 | return tab; | 166 | return tab; |
167 | } | 167 | } |
168 | 168 | ||
169 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) | 169 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) |
170 | { | 170 | { |
171 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 171 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
172 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 172 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
173 | 173 | ||
174 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 174 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
175 | vertLayout->addWidget( m_deco_list ); | 175 | vertLayout->addWidget( m_deco_list ); |
176 | 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." ) ); | 176 | 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." ) ); |
177 | 177 | ||
178 | QString s = cfg. readEntry ( "Decoration" ); | 178 | QString s = cfg. readEntry ( "Decoration", "libflat.so" ); |
179 | 179 | ||
180 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); | 180 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); |
181 | 181 | ||
182 | { | 182 | { |
183 | QString path = QPEApplication::qpeDir(); | 183 | QString path = QPEApplication::qpeDir(); |
184 | path.append( "/plugins/decorations/" ); | 184 | path.append( "/plugins/decorations/" ); |
185 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 185 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
186 | 186 | ||
187 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 187 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
188 | QString libstr = path; | 188 | QString libstr = path; |
189 | libstr.append( "/" ); | 189 | libstr.append( "/" ); |
190 | libstr.append( *it ); | 190 | libstr.append( *it ); |
191 | QLibrary *lib = new QLibrary ( libstr ); | 191 | QLibrary *lib = new QLibrary ( libstr ); |
192 | WindowDecorationInterface *iface; | 192 | WindowDecorationInterface *iface; |
193 | 193 | ||
194 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { | 194 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { |
195 | DecoListItem *dlit = new DecoListItem ( lib, iface ); | 195 | DecoListItem *dlit = new DecoListItem ( lib, iface ); |
196 | m_deco_list-> insertItem ( dlit ); | 196 | m_deco_list-> insertItem ( dlit ); |
197 | 197 | ||
198 | if ( dlit-> key ( ) == s ) | 198 | if ( dlit-> key ( ) == s ) |
199 | m_deco_list-> setCurrentItem ( dlit ); | 199 | m_deco_list-> setCurrentItem ( dlit ); |
200 | } | 200 | } |
201 | else | 201 | else |
202 | delete lib; | 202 | delete lib; |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | m_original_deco = m_deco_list-> currentItem ( ); | 206 | m_original_deco = m_deco_list-> currentItem ( ); |
207 | if ( m_deco_list-> currentItem ( ) < 0 ) | 207 | if ( m_deco_list-> currentItem ( ) < 0 ) |
208 | m_deco_list-> setCurrentItem ( 0 ); | 208 | m_deco_list-> setCurrentItem ( 0 ); |
209 | decoClicked ( m_original_deco ); | 209 | decoClicked ( m_original_deco ); |
210 | 210 | ||
211 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 211 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); |
212 | 212 | ||
213 | return tab; | 213 | return tab; |
214 | } | 214 | } |
215 | 215 | ||
216 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) | 216 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) |
217 | { | 217 | { |
218 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); | 218 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); |
219 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); | 219 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); |
220 | int size = cfg. readNumEntry ( "FontSize", 10 ); | 220 | int size = cfg. readNumEntry ( "FontSize", 10 ); |
221 | 221 | ||
222 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); | 222 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); |
223 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 223 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
224 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); | 224 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); |
225 | 225 | ||
226 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 226 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), |
227 | this, SLOT( fontClicked ( const QFont & ))); | 227 | this, SLOT( fontClicked ( const QFont & ))); |
228 | 228 | ||
229 | return m_fontselect; | 229 | return m_fontselect; |
230 | } | 230 | } |
231 | 231 | ||
232 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) | 232 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) |
233 | { | 233 | { |
234 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 234 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
235 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); | 235 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); |
236 | gridLayout->setRowStretch ( 3, 10 ); | 236 | gridLayout->setRowStretch ( 3, 10 ); |
237 | 237 | ||
238 | m_color_list = new QListBox ( tab ); | 238 | m_color_list = new QListBox ( tab ); |
239 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 239 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
240 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 240 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); |
241 | 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." ) ); | 241 | 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." ) ); |
242 | 242 | ||
243 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); | 243 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); |
244 | 244 | ||
245 | QString path = QPEApplication::qpeDir ( ); | 245 | QString path = QPEApplication::qpeDir ( ); |
246 | path.append( "/etc/colors/" ); | 246 | path.append( "/etc/colors/" ); |
247 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 247 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
248 | 248 | ||
249 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 249 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
250 | QString name = (*it). left ((*it). find ( ".scheme" )); | 250 | QString name = (*it). left ((*it). find ( ".scheme" )); |
251 | QString pathstr = path; | 251 | QString pathstr = path; |
252 | pathstr.append( *it ); | 252 | pathstr.append( *it ); |
253 | Config config ( pathstr, Config::File ); | 253 | Config config ( pathstr, Config::File ); |
254 | config. setGroup ( "Colors" ); | 254 | config. setGroup ( "Colors" ); |
255 | 255 | ||
256 | m_color_list-> insertItem ( new ColorListItem ( name, config )); | 256 | m_color_list-> insertItem ( new ColorListItem ( name, config )); |
257 | } | 257 | } |
258 | 258 | ||
259 | m_color_list-> setCurrentItem ( 0 ); | 259 | m_color_list-> setCurrentItem ( 0 ); |
260 | 260 | ||
261 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 261 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
262 | tempButton->setText( tr( "Edit..." ) ); | 262 | tempButton->setText( tr( "Edit..." ) ); |
263 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 263 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
264 | gridLayout->addWidget( tempButton, 0, 1 ); | 264 | gridLayout->addWidget( tempButton, 0, 1 ); |
265 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); | 265 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); |
266 | 266 | ||
267 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 267 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
268 | tempButton->setText( tr( "Delete" ) ); | 268 | tempButton->setText( tr( "Delete" ) ); |
269 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 269 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
270 | gridLayout->addWidget( tempButton, 1, 1 ); | 270 | gridLayout->addWidget( tempButton, 1, 1 ); |
271 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); | 271 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); |
272 | 272 | ||
273 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 273 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
274 | tempButton->setText( tr( "Save" ) ); | 274 | tempButton->setText( tr( "Save" ) ); |
@@ -309,248 +309,249 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) | |||
309 | m_except-> header ( )-> setClickEnabled ( false ); | 309 | m_except-> header ( )-> setClickEnabled ( false ); |
310 | m_except-> header ( )-> setResizeEnabled ( false ); | 310 | m_except-> header ( )-> setResizeEnabled ( false ); |
311 | m_except-> header ( )-> setMovingEnabled ( false ); | 311 | m_except-> header ( )-> setMovingEnabled ( false ); |
312 | m_except-> setSorting ( -1 ); | 312 | m_except-> setSorting ( -1 ); |
313 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); | 313 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); |
314 | 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." ) ); | 314 | 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." ) ); |
315 | 315 | ||
316 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); | 316 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); |
317 | 317 | ||
318 | QToolButton *tb = new QToolButton ( tab ); | 318 | QToolButton *tb = new QToolButton ( tab ); |
319 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); | 319 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); |
320 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 320 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
321 | lay-> addWidget ( tb, 2, 1 ); | 321 | lay-> addWidget ( tb, 2, 1 ); |
322 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); | 322 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); |
323 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); | 323 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); |
324 | 324 | ||
325 | tb = new QToolButton ( tab ); | 325 | tb = new QToolButton ( tab ); |
326 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); | 326 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); |
327 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 327 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
328 | lay-> addWidget ( tb, 3, 1 ); | 328 | lay-> addWidget ( tb, 3, 1 ); |
329 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); | 329 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); |
330 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); | 330 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); |
331 | 331 | ||
332 | tb = new QToolButton ( tab ); | 332 | tb = new QToolButton ( tab ); |
333 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); | 333 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); |
334 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 334 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
335 | lay-> addWidget ( tb, 4, 1 ); | 335 | lay-> addWidget ( tb, 4, 1 ); |
336 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); | 336 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); |
337 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); | 337 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); |
338 | 338 | ||
339 | tb = new QToolButton ( tab ); | 339 | tb = new QToolButton ( tab ); |
340 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); | 340 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); |
341 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 341 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
342 | lay-> addWidget ( tb, 5, 1 ); | 342 | lay-> addWidget ( tb, 5, 1 ); |
343 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); | 343 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); |
344 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); | 344 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); |
345 | 345 | ||
346 | lay-> setRowStretch ( 6, 10 ); | 346 | lay-> setRowStretch ( 6, 10 ); |
347 | lay-> setColStretch ( 0, 10 ); | 347 | lay-> setColStretch ( 0, 10 ); |
348 | 348 | ||
349 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); | 349 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); |
350 | QListViewItem *lvit = 0; | 350 | QListViewItem *lvit = 0; |
351 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 351 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
352 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 352 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
353 | 353 | ||
354 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); | 354 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); |
355 | } | 355 | } |
356 | 356 | ||
357 | 357 | ||
358 | vertLayout-> addSpacing ( 3 ); | 358 | vertLayout-> addSpacing ( 3 ); |
359 | QFrame *f = new QFrame ( tab ); | 359 | QFrame *f = new QFrame ( tab ); |
360 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); | 360 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); |
361 | vertLayout-> addWidget ( f ); | 361 | vertLayout-> addWidget ( f ); |
362 | vertLayout-> addSpacing ( 3 ); | 362 | vertLayout-> addSpacing ( 3 ); |
363 | 363 | ||
364 | 364 | ||
365 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 365 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
366 | 366 | ||
367 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; | 367 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; |
368 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); | 368 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); |
369 | 369 | ||
370 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 370 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
371 | gridLayout-> addWidget ( label, 0, 0 ); | 371 | gridLayout-> addWidget ( label, 0, 0 ); |
372 | 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" ) ); | 372 | 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" ) ); |
373 | 373 | ||
374 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 374 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
375 | btngrp-> hide ( ); | 375 | btngrp-> hide ( ); |
376 | btngrp-> setExclusive ( true ); | 376 | btngrp-> setExclusive ( true ); |
377 | 377 | ||
378 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 378 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
379 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 379 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
380 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 380 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
381 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 381 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
382 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 382 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
383 | m_tabstyle_list-> setCurrentItem ( style ); | 383 | m_tabstyle_list-> setCurrentItem ( style ); |
384 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 384 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
385 | 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" ) ); | 385 | 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" ) ); |
386 | 386 | ||
387 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 387 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
388 | btngrp-> insert ( m_tabstyle_top ); | 388 | btngrp-> insert ( m_tabstyle_top ); |
389 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 389 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
390 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); | 390 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); |
391 | 391 | ||
392 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 392 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
393 | btngrp-> insert ( m_tabstyle_bottom ); | 393 | btngrp-> insert ( m_tabstyle_bottom ); |
394 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 394 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
395 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); | 395 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); |
396 | 396 | ||
397 | m_tabstyle_top-> setChecked ( tabtop ); | 397 | m_tabstyle_top-> setChecked ( tabtop ); |
398 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 398 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
399 | 399 | ||
400 | m_original_tabstyle = style; | 400 | m_original_tabstyle = style; |
401 | m_original_tabpos = tabtop; | 401 | m_original_tabpos = tabtop; |
402 | 402 | ||
403 | vertLayout-> addSpacing ( 3 ); | 403 | vertLayout-> addSpacing ( 3 ); |
404 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); | 404 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); |
405 | 405 | ||
406 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); | 406 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); |
407 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); | 407 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); |
408 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); | 408 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); |
409 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); | 409 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); |
410 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); | 410 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); |
411 | QPixmap ccw1; | 411 | QPixmap ccw1; |
412 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); | 412 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); |
413 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); | 413 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); |
414 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); | 414 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); |
415 | 415 | ||
416 | rotbtngrp-> hide ( ); | 416 | rotbtngrp-> hide ( ); |
417 | rotbtngrp-> setExclusive ( true ); | 417 | rotbtngrp-> setExclusive ( true ); |
418 | rotbtngrp-> insert ( m_rotdir_cw ); | 418 | rotbtngrp-> insert ( m_rotdir_cw ); |
419 | rotbtngrp-> insert ( m_rotdir_ccw ); | 419 | rotbtngrp-> insert ( m_rotdir_ccw ); |
420 | rotbtngrp-> insert ( m_rotdir_flip ); | 420 | rotbtngrp-> insert ( m_rotdir_flip ); |
421 | 421 | ||
422 | ccw1. convertFromImage( ccwImage ); | 422 | ccw1. convertFromImage( ccwImage ); |
423 | m_rotdir_cw-> setPixmap( cw1 ); | 423 | m_rotdir_cw-> setPixmap( cw1 ); |
424 | m_rotdir_ccw-> setPixmap( ccw1 ); | 424 | m_rotdir_ccw-> setPixmap( ccw1 ); |
425 | m_rotdir_flip-> setPixmap( flip1 ); | 425 | m_rotdir_flip-> setPixmap( flip1 ); |
426 | 426 | ||
427 | rotLay-> addWidget ( rotlabel, 0 ); | 427 | rotLay-> addWidget ( rotlabel, 0 ); |
428 | rotLay-> addWidget ( m_rotdir_cw, 0 ); | 428 | rotLay-> addWidget ( m_rotdir_cw, 0 ); |
429 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); | 429 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); |
430 | rotLay-> addWidget ( m_rotdir_flip, 0 ); | 430 | rotLay-> addWidget ( m_rotdir_flip, 0 ); |
431 | 431 | ||
432 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 432 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
433 | ODirection rot = CW; | 433 | ODirection rot = CW; |
434 | 434 | ||
435 | if (rotDirection == -1) { | 435 | if (rotDirection == -1) { |
436 | rot = ODevice::inst ( )-> direction ( ); | 436 | rot = ODevice::inst ( )-> direction ( ); |
437 | } else { | 437 | } else { |
438 | rot = (ODirection)rotDirection; | 438 | rot = (ODirection)rotDirection; |
439 | } | 439 | } |
440 | 440 | ||
441 | m_rotdir_cw-> setChecked ( rot == CW ); | 441 | m_rotdir_cw-> setChecked ( rot == CW ); |
442 | m_rotdir_ccw-> setChecked ( rot == CCW ); | 442 | m_rotdir_ccw-> setChecked ( rot == CCW ); |
443 | m_rotdir_flip-> setChecked ( rot == Flip ); | 443 | m_rotdir_flip-> setChecked ( rot == Flip ); |
444 | 444 | ||
445 | return tab; | 445 | return tab; |
446 | } | 446 | } |
447 | 447 | ||
448 | 448 | ||
449 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 449 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
450 | : QDialog ( parent, name, true, WStyle_ContextHelp ) | 450 | : QDialog ( parent, name, true, WStyle_ContextHelp ) |
451 | { | 451 | { |
452 | setCaption( tr( "Appearance Settings" ) ); | 452 | setCaption( tr( "Appearance Settings" ) ); |
453 | 453 | ||
454 | Config config( "qpe" ); | 454 | Config config( "qpe" ); |
455 | config.setGroup( "Appearance" ); | 455 | config.setGroup( "Appearance" ); |
456 | 456 | ||
457 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); | 457 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); |
458 | 458 | ||
459 | m_sample = new SampleWindow ( this ); | 459 | m_sample = new SampleWindow ( this ); |
460 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 460 | |
461 | m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); | ||
461 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); | 462 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); |
462 | 463 | ||
463 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 464 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
464 | QWidget *styletab; | 465 | QWidget *styletab; |
465 | 466 | ||
466 | m_color_list = 0; | 467 | m_color_list = 0; |
467 | 468 | ||
468 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); | 469 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); |
469 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); | 470 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); |
470 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); | 471 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); |
471 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); | 472 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); |
472 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); | 473 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); |
473 | 474 | ||
474 | top-> addWidget ( tw, 10 ); | 475 | top-> addWidget ( tw, 10 ); |
475 | top-> addWidget ( m_sample, 1 ); | 476 | top-> addWidget ( m_sample, 1 ); |
476 | 477 | ||
477 | tw-> setCurrentTab ( styletab ); | 478 | tw-> setCurrentTab ( styletab ); |
478 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); | 479 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); |
479 | 480 | ||
480 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; | 481 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; |
481 | } | 482 | } |
482 | 483 | ||
483 | Appearance::~Appearance() | 484 | Appearance::~Appearance() |
484 | { | 485 | { |
485 | } | 486 | } |
486 | 487 | ||
487 | void Appearance::tabChanged ( QWidget *w ) | 488 | void Appearance::tabChanged ( QWidget *w ) |
488 | { | 489 | { |
489 | if ( w == m_advtab ) { | 490 | if ( w == m_advtab ) { |
490 | m_sample-> hide ( ); | 491 | m_sample-> hide ( ); |
491 | updateGeometry ( ); // shouldn't be necessary ... | 492 | updateGeometry ( ); // shouldn't be necessary ... |
492 | } | 493 | } |
493 | else | 494 | else |
494 | m_sample-> show ( ); | 495 | m_sample-> show ( ); |
495 | } | 496 | } |
496 | 497 | ||
497 | void Appearance::accept ( ) | 498 | void Appearance::accept ( ) |
498 | { | 499 | { |
499 | bool newtabpos = m_tabstyle_top-> isChecked ( ); | 500 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
500 | int newtabstyle = m_tabstyle_list-> currentItem ( ); | 501 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
501 | 502 | ||
502 | Config config ( "qpe" ); | 503 | Config config ( "qpe" ); |
503 | config. setGroup ( "Appearance" ); | 504 | config. setGroup ( "Appearance" ); |
504 | 505 | ||
505 | if ( m_style_changed ) { | 506 | if ( m_style_changed ) { |
506 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 507 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
507 | if ( item ) | 508 | if ( item ) |
508 | config.writeEntry( "Style", item-> key ( )); | 509 | config.writeEntry( "Style", item-> key ( )); |
509 | } | 510 | } |
510 | 511 | ||
511 | if ( m_deco_changed ) { | 512 | if ( m_deco_changed ) { |
512 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); | 513 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); |
513 | if ( item ) | 514 | if ( item ) |
514 | config.writeEntry( "Decoration", item-> key ( )); | 515 | config.writeEntry( "Decoration", item-> key ( )); |
515 | } | 516 | } |
516 | 517 | ||
517 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { | 518 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { |
518 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | 519 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); |
519 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | 520 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); |
520 | } | 521 | } |
521 | 522 | ||
522 | if ( m_font_changed ) { | 523 | if ( m_font_changed ) { |
523 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); | 524 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
524 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); | 525 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
525 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); | 526 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
526 | } | 527 | } |
527 | 528 | ||
528 | 529 | ||
529 | if ( m_color_changed ) | 530 | if ( m_color_changed ) |
530 | { | 531 | { |
531 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 532 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
532 | 533 | ||
533 | if ( item ) | 534 | if ( item ) |
534 | item-> save ( config ); | 535 | item-> save ( config ); |
535 | } | 536 | } |
536 | 537 | ||
537 | ODirection rot; | 538 | ODirection rot; |
538 | if (m_rotdir_ccw-> isChecked ( )) { | 539 | if (m_rotdir_ccw-> isChecked ( )) { |
539 | rot = CCW; | 540 | rot = CCW; |
540 | } else if (m_rotdir_cw-> isChecked ( )) { | 541 | } else if (m_rotdir_cw-> isChecked ( )) { |
541 | rot = CW; | 542 | rot = CW; |
542 | } else { | 543 | } else { |
543 | rot = Flip; | 544 | rot = Flip; |
544 | } | 545 | } |
545 | config. writeEntry ( "rotatedir", (int)rot ); | 546 | config. writeEntry ( "rotatedir", (int)rot ); |
546 | 547 | ||
547 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated | 548 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated |
548 | 549 | ||
549 | QStringList sl; | 550 | QStringList sl; |
550 | QString exceptstr; | 551 | QString exceptstr; |
551 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { | 552 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { |
552 | int fl = 0; | 553 | int fl = 0; |
553 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); | 554 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); |
554 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); | 555 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); |
555 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); | 556 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); |
556 | exceptstr = QString::number ( fl, 32 ); | 557 | exceptstr = QString::number ( fl, 32 ); |
diff --git a/noncore/settings/appearance2/colorlistitem.h b/noncore/settings/appearance2/colorlistitem.h index 10e4468..f8d5c45 100644 --- a/noncore/settings/appearance2/colorlistitem.h +++ b/noncore/settings/appearance2/colorlistitem.h | |||
@@ -31,110 +31,111 @@ | |||
31 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
32 | #include <qpalette.h> | 32 | #include <qpalette.h> |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | 34 | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | 36 | ||
37 | class Appearance; | 37 | class Appearance; |
38 | 38 | ||
39 | class ColorListItem : public QListBoxText { | 39 | class ColorListItem : public QListBoxText { |
40 | public: | 40 | public: |
41 | ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) | 41 | ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) |
42 | { | 42 | { |
43 | m_colors = new QColor [s_colorcount]; | 43 | m_colors = new QColor [s_colorcount]; |
44 | load ( cfg ); | 44 | load ( cfg ); |
45 | } | 45 | } |
46 | 46 | ||
47 | virtual ~ColorListItem ( ) | 47 | virtual ~ColorListItem ( ) |
48 | { | 48 | { |
49 | delete [] m_colors; | 49 | delete [] m_colors; |
50 | } | 50 | } |
51 | 51 | ||
52 | QPalette palette ( ) | 52 | QPalette palette ( ) |
53 | { | 53 | { |
54 | return m_palette; | 54 | return m_palette; |
55 | } | 55 | } |
56 | 56 | ||
57 | bool load ( Config &cfg ) | 57 | bool load ( Config &cfg ) |
58 | { | 58 | { |
59 | for ( int i = 0; i < s_colorcount; i++ ) | 59 | for ( int i = 0; i < s_colorcount; i++ ) |
60 | m_colors [i] = QColor ( cfg. readEntry ( s_colorlut [i]. m_key, s_colorlut [i]. m_def )); | 60 | m_colors [i] = QColor ( cfg. readEntry ( s_colorlut [i]. m_key, s_colorlut [i]. m_def )); |
61 | 61 | ||
62 | buildPalette ( ); | 62 | buildPalette ( ); |
63 | return true; | 63 | return true; |
64 | } | 64 | } |
65 | 65 | ||
66 | void buildPalette ( ) | 66 | void buildPalette ( ) |
67 | { | 67 | { |
68 | m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); | 68 | m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); |
69 | m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); | 69 | m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); |
70 | m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); | 70 | m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); |
71 | m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); | 71 | m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); |
72 | m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); | 72 | m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); |
73 | m_palette. setColor ( QColorGroup::Base, m_colors [r2i(QColorGroup::Base)] ); | 73 | m_palette. setColor ( QColorGroup::Base, m_colors [r2i(QColorGroup::Base)] ); |
74 | m_palette. setColor ( QPalette::Disabled, QColorGroup::Text, m_palette. color ( QPalette::Active, QColorGroup::Background ). dark ( )); | 74 | m_palette. setColor ( QPalette::Disabled, QColorGroup::Text, m_palette. color ( QPalette::Active, QColorGroup::Background ). dark ( )); |
75 | } | 75 | } |
76 | 76 | ||
77 | bool save ( Config &cfg ) | 77 | bool save ( Config &cfg ) |
78 | { | 78 | { |
79 | for ( int i = 0; i < s_colorcount; i++ ) | 79 | for ( int i = 0; i < s_colorcount; i++ ) |
80 | cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); | 80 | cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); |
81 | return true; | 81 | return true; |
82 | } | 82 | } |
83 | 83 | ||
84 | QColor color ( QColorGroup::ColorRole role ) | 84 | QColor color ( QColorGroup::ColorRole role ) |
85 | { | 85 | { |
86 | int i = r2i ( role ); | 86 | int i = r2i ( role ); |
87 | return i >= 0 ? m_colors [i] : QColor ( ); | 87 | return i >= 0 ? m_colors [i] : QColor ( ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void setColor ( QColorGroup::ColorRole role, QColor c ) | 90 | void setColor ( QColorGroup::ColorRole role, QColor c ) |
91 | { | 91 | { |
92 | int i = r2i ( role ); | 92 | int i = r2i ( role ); |
93 | if ( i >= 0 ) { | 93 | if ( i >= 0 ) { |
94 | m_colors [i] = c; | 94 | m_colors [i] = c; |
95 | buildPalette ( ); | 95 | buildPalette ( ); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | QString label ( QColorGroup::ColorRole role ) | 99 | QString label ( QColorGroup::ColorRole role ) |
100 | { | 100 | { |
101 | int i = r2i ( role ); | 101 | int i = r2i ( role ); |
102 | return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; | 102 | return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; |
103 | } | 103 | } |
104 | 104 | ||
105 | private: | 105 | private: |
106 | QPalette m_palette; | 106 | QPalette m_palette; |
107 | QColor *m_colors; | 107 | QColor *m_colors; |
108 | 108 | ||
109 | static struct colorlut { | 109 | static struct colorlut { |
110 | QColorGroup::ColorRole m_role; | 110 | QColorGroup::ColorRole m_role; |
111 | const char * m_key; | 111 | const char * m_key; |
112 | const char * m_def; | 112 | const char * m_def; |
113 | const char * m_label; | 113 | const char * m_label; |
114 | } const s_colorlut []; | 114 | } const s_colorlut []; |
115 | static const int s_colorcount; | 115 | static const int s_colorcount; |
116 | 116 | ||
117 | static int r2i ( QColorGroup::ColorRole role ) | 117 | static int r2i ( QColorGroup::ColorRole role ) |
118 | { | 118 | { |
119 | for ( int i = 0; i < s_colorcount; i++ ) { | 119 | for ( int i = 0; i < s_colorcount; i++ ) { |
120 | if ( s_colorlut [i]. m_role == role ) | 120 | if ( s_colorlut [i]. m_role == role ) |
121 | return i; | 121 | return i; |
122 | } | 122 | } |
123 | return -1; | 123 | return -1; |
124 | } | 124 | } |
125 | }; | 125 | }; |
126 | 126 | ||
127 | // from etc/colors/Liquid.scheme | ||
127 | const ColorListItem::colorlut ColorListItem::s_colorlut [] = { | 128 | const ColorListItem::colorlut ColorListItem::s_colorlut [] = { |
128 | { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, | 129 | { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, |
129 | { QColorGroup::Background, "Background", "#E5E1D5", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, | 130 | { QColorGroup::Background, "Background", "#E0E0E0", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, |
130 | { QColorGroup::Button, "Button", "#D6CDBB", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, | 131 | { QColorGroup::Button, "Button", "#96c8fa", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, |
131 | { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, | 132 | { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, |
132 | { QColorGroup::Highlight, "Highlight", "#800000", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, | 133 | { QColorGroup::Highlight, "Highlight", "#73adef", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, |
133 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, | 134 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, |
134 | { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } | 135 | { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } |
135 | }; | 136 | }; |
136 | 137 | ||
137 | const int ColorListItem::s_colorcount = sizeof( s_colorlut ) / sizeof ( s_colorlut [0] ); | 138 | const int ColorListItem::s_colorcount = sizeof( s_colorlut ) / sizeof ( s_colorlut [0] ); |
138 | 139 | ||
139 | 140 | ||
140 | #endif | 141 | #endif |
diff --git a/noncore/settings/appearance2/decolistitem.h b/noncore/settings/appearance2/decolistitem.h index d190ceb..da7924c 100644 --- a/noncore/settings/appearance2/decolistitem.h +++ b/noncore/settings/appearance2/decolistitem.h | |||
@@ -10,97 +10,98 @@ | |||
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This file is distributed in the hope that | 12 | .i_,=:_. -<s. This file is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
17 | ..}^=.= = ; Public License for more details. | 17 | ..}^=.= = ; Public License for more details. |
18 | ++= -. .` .: | 18 | ++= -. .` .: |
19 | : = ...= . :.=- You should have received a copy of the GNU | 19 | : = ...= . :.=- You should have received a copy of the GNU |
20 | -. .:....=;==+<; General Public License along with this file; | 20 | -. .:....=;==+<; General Public License along with this file; |
21 | -_. . . )=. = see the file COPYING. If not, write to the | 21 | -_. . . )=. = see the file COPYING. If not, write to the |
22 | -- :-=` Free Software Foundation, Inc., | 22 | -- :-=` Free Software Foundation, Inc., |
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef DECOLISTITEM_H | 28 | #ifndef DECOLISTITEM_H |
29 | #define DECOLISTITEM_H | 29 | #define DECOLISTITEM_H |
30 | 30 | ||
31 | #include <qpe/windowdecorationinterface.h> | 31 | #include <qpe/windowdecorationinterface.h> |
32 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
33 | 33 | ||
34 | class DecoListItem : public QListBoxPixmap { | 34 | class DecoListItem : public QListBoxPixmap { |
35 | public: | 35 | public: |
36 | DecoListItem ( const QString &t ) : QListBoxPixmap ( QPixmap ( ), t ) | 36 | DecoListItem ( const QString &t ) : QListBoxPixmap ( QPixmap ( ), t ) |
37 | { | 37 | { |
38 | m_lib = 0; | 38 | m_lib = 0; |
39 | m_window_if = 0; | 39 | m_window_if = 0; |
40 | // m_settings_if = 0; | 40 | // m_settings_if = 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | DecoListItem ( QLibrary *lib, WindowDecorationInterface *iface ) : QListBoxPixmap ( iface-> icon ( ), iface-> name ( )) | 43 | DecoListItem ( QLibrary *lib, WindowDecorationInterface *iface ) : QListBoxPixmap ( iface-> icon ( ), iface-> name ( )) |
44 | { | 44 | { |
45 | m_lib = lib; | 45 | m_lib = lib; |
46 | m_window_if = iface; | 46 | m_window_if = iface; |
47 | 47 | ||
48 | // iface-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &m_settings_if ); | 48 | // iface-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &m_settings_if ); |
49 | } | 49 | } |
50 | 50 | ||
51 | virtual ~DecoListItem ( ) | 51 | virtual ~DecoListItem ( ) |
52 | { | 52 | { |
53 | // if ( m_settings_if ) | 53 | // if ( m_settings_if ) |
54 | // m_settings_if-> release ( ); | 54 | // m_settings_if-> release ( ); |
55 | if ( m_window_if ) | 55 | if ( m_window_if ) |
56 | m_window_if-> release ( ); | 56 | m_window_if-> release ( ); |
57 | delete m_lib; | 57 | delete m_lib; |
58 | } | 58 | } |
59 | 59 | ||
60 | bool hasSettings ( ) const | 60 | bool hasSettings ( ) const |
61 | { | 61 | { |
62 | // return ( m_settings_if ); | 62 | // return ( m_settings_if ); |
63 | return false; | 63 | return false; |
64 | } | 64 | } |
65 | 65 | ||
66 | QWidget *settings ( QWidget * /*parent*/ ) | 66 | QWidget *settings ( QWidget * /*parent*/ ) |
67 | { | 67 | { |
68 | // return m_settings_if ? m_settings_if-> create ( parent ) : 0; | 68 | // return m_settings_if ? m_settings_if-> create ( parent ) : 0; |
69 | return 0; | 69 | return 0; |
70 | } | 70 | } |
71 | 71 | ||
72 | bool setSettings ( bool /*accepted*/ ) | 72 | bool setSettings ( bool /*accepted*/ ) |
73 | { | 73 | { |
74 | // if ( !m_settings_if ) | 74 | // if ( !m_settings_if ) |
75 | // return false; | 75 | // return false; |
76 | 76 | ||
77 | // if ( accepted ) | 77 | // if ( accepted ) |
78 | // return m_settings_if-> accept ( ); | 78 | // return m_settings_if-> accept ( ); |
79 | // else { | 79 | // else { |
80 | // m_settings_if-> reject ( ); | 80 | // m_settings_if-> reject ( ); |
81 | // return false; | 81 | // return false; |
82 | // } | 82 | // } |
83 | return false; | 83 | return false; |
84 | } | 84 | } |
85 | 85 | ||
86 | QString key ( ) | 86 | QString key ( ) |
87 | { | 87 | { |
88 | if ( m_lib ) | 88 | if ( m_lib ) |
89 | return QFileInfo ( m_lib-> library ( )). fileName ( ); | 89 | return QFileInfo ( m_lib-> library ( )). fileName ( ); |
90 | else | 90 | else |
91 | return text ( ); | 91 | return text ( ); |
92 | } | 92 | } |
93 | 93 | ||
94 | WindowDecorationInterface *interface ( ) | 94 | WindowDecorationInterface *interface ( ) |
95 | { | 95 | { |
96 | return m_window_if; | 96 | return m_window_if; |
97 | } | 97 | } |
98 | 98 | ||
99 | private: | 99 | private: |
100 | QLibrary *m_lib; | 100 | QLibrary *m_lib; |
101 | WindowDecorationInterface *m_window_if; | 101 | WindowDecorationInterface *m_window_if; |
102 | //WindowDecorationSettingsInterface *m_settings_if; | 102 | //WindowDecorationSettingsInterface *m_settings_if; |
103 | 103 | ||
104 | }; | 104 | }; |
105 | 105 | ||
106 | #endif \ No newline at end of file | 106 | #endif |
107 | |||
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 4ff6be1..922523b 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,181 +1,172 @@ | |||
1 | 1 | ||
2 | #include "backuprestore.h" | 2 | #include "backuprestore.h" |
3 | //#include "output.h" | 3 | //#include "output.h" |
4 | #include "errordialog.h" | 4 | #include "errordialog.h" |
5 | 5 | ||
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qmultilineedit.h> | 7 | #include <qmultilineedit.h> |
8 | 8 | ||
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | #include <qfileinfo.h> | 11 | #include <qfileinfo.h> |
12 | #include <qlistview.h> | 12 | #include <qlistview.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qheader.h> | 14 | #include <qheader.h> |
15 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
16 | #include <qpe/config.h> | 16 | #include <qpe/config.h> |
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
19 | #include <qlist.h> | 19 | #include <qlist.h> |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <qregexp.h> | 21 | #include <qregexp.h> |
22 | #include <qtextstream.h> | 22 | #include <qtextstream.h> |
23 | #include <qtextview.h> | 23 | #include <qtextview.h> |
24 | 24 | ||
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <dirent.h> | 29 | #include <dirent.h> |
30 | 30 | ||
31 | #define HEADER_NAME 0 | 31 | #define HEADER_NAME 0 |
32 | #define HEADER_BACKUP 1 | 32 | #define HEADER_BACKUP 1 |
33 | #define BACKUP_LOCATION 2 | 33 | #define BACKUP_LOCATION 2 |
34 | 34 | ||
35 | #define EXTENSION ".bck" | 35 | #define EXTENSION ".bck" |
36 | 36 | ||
37 | const QString tempFileName = "/tmp/backup.err"; | 37 | const QString tempFileName = "/tmp/backup.err"; |
38 | 38 | ||
39 | 39 | ||
40 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) | 40 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name) |
41 | : BackupAndRestoreBase(parent, name){ | 41 | : BackupAndRestoreBase(parent, name){ |
42 | this->showMaximized(); | 42 | this->showMaximized(); |
43 | backupList->header()->hide(); | 43 | backupList->header()->hide(); |
44 | restoreList->header()->hide(); | 44 | restoreList->header()->hide(); |
45 | connect(backupButton, SIGNAL(clicked()), | 45 | connect(backupButton, SIGNAL(clicked()), |
46 | this, SLOT(backupPressed())); | 46 | this, SLOT(backupPressed())); |
47 | connect(restoreButton, SIGNAL(clicked()), | 47 | connect(restoreButton, SIGNAL(clicked()), |
48 | this, SLOT(restore())); | 48 | this, SLOT(restore())); |
49 | connect(backupList, SIGNAL(clicked( QListViewItem * )), | 49 | connect(backupList, SIGNAL(clicked( QListViewItem * )), |
50 | this, SLOT(selectItem(QListViewItem*))); | 50 | this, SLOT(selectItem(QListViewItem*))); |
51 | connect(restoreSource, SIGNAL(activated( int )), | 51 | connect(restoreSource, SIGNAL(activated( int )), |
52 | this, SLOT(sourceDirChanged(int))); | 52 | this, SLOT(sourceDirChanged(int))); |
53 | connect(updateList, SIGNAL(clicked()), | 53 | connect(updateList, SIGNAL(clicked()), |
54 | this, SLOT( fileListUpdate())); | 54 | this, SLOT( fileListUpdate())); |
55 | 55 | ||
56 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", | 56 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", |
57 | QDir::homeDirPath() + "/Settings/"); | 57 | QDir::homeDirPath() + "/Settings/"); |
58 | selectItem(applicationSettings); | 58 | selectItem(applicationSettings); |
59 | applicationSettings = new QListViewItem(backupList, "Application Data", "", | 59 | applicationSettings = new QListViewItem(backupList, "Application Data", "", |
60 | QDir::homeDirPath() + "/Applications/"); | 60 | QDir::homeDirPath() + "/Applications/"); |
61 | selectItem(applicationSettings); | 61 | selectItem(applicationSettings); |
62 | documents= new QListViewItem(backupList, "Documents", "", | 62 | documents= new QListViewItem(backupList, "Documents", "", |
63 | QDir::homeDirPath() + "/Documents/"); | 63 | QDir::homeDirPath() + "/Documents/"); |
64 | selectItem(documents); | 64 | selectItem(documents); |
65 | 65 | ||
66 | scanForApplicationSettings(); | 66 | scanForApplicationSettings(); |
67 | 67 | ||
68 | Config config("BackupAndRestore"); | 68 | Config config("BackupAndRestore"); |
69 | config.setGroup("General"); | 69 | config.setGroup("General"); |
70 | int totalLocations = config.readNumEntry("totalLocations",0); | 70 | int totalLocations = config.readNumEntry("totalLocations",0); |
71 | 71 | ||
72 | //todo make less static here and use Storage class to get infos | 72 | //todo make less static here and use Storage class to get infos |
73 | if(totalLocations == 0){ | 73 | if(totalLocations == 0){ |
74 | |||
75 | /* Ramses has a CF-Slot, but that one is internal and you have to dismount the | ||
76 | * the case. There's also almost always a WLAN card inserted there | ||
77 | */ | ||
78 | |||
79 | backupLocations.insert("Documents", "/root/Documents"); | 74 | backupLocations.insert("Documents", "/root/Documents"); |
80 | #if defined(QT_QWS_RAMSES) | ||
81 | backupLocations.insert("MMC", "/mnt/card"); | ||
82 | #else | ||
83 | backupLocations.insert("CF", "/mnt/cf"); | 75 | backupLocations.insert("CF", "/mnt/cf"); |
84 | backupLocations.insert("SD", "/mnt/card"); | 76 | backupLocations.insert("SD", "/mnt/card"); |
85 | #endif | ||
86 | } | 77 | } |
87 | else{ | 78 | else{ |
88 | for(int i = 0; i < totalLocations; i++){ | 79 | for(int i = 0; i < totalLocations; i++){ |
89 | backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)), | 80 | backupLocations.insert(config.readEntry(QString("backupLocationName_%1").arg(i)), |
90 | config.readEntry(QString("backupLocation_%1").arg(i))); | 81 | config.readEntry(QString("backupLocation_%1").arg(i))); |
91 | } | 82 | } |
92 | } | 83 | } |
93 | QMap<QString, QString>::Iterator it; | 84 | QMap<QString, QString>::Iterator it; |
94 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){ | 85 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ){ |
95 | storeToLocation->insertItem(it.key()); | 86 | storeToLocation->insertItem(it.key()); |
96 | restoreSource->insertItem(it.key()); | 87 | restoreSource->insertItem(it.key()); |
97 | } | 88 | } |
98 | 89 | ||
99 | // Read the list of items to ignore. | 90 | // Read the list of items to ignore. |
100 | QList<QString> dontBackupList; | 91 | QList<QString> dontBackupList; |
101 | dontBackupList.setAutoDelete(true); | 92 | dontBackupList.setAutoDelete(true); |
102 | config.setGroup("DontBackup"); | 93 | config.setGroup("DontBackup"); |
103 | int total = config.readNumEntry("Total", 0); | 94 | int total = config.readNumEntry("Total", 0); |
104 | for(int i = 0; i < total; i++){ | 95 | for(int i = 0; i < total; i++){ |
105 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); | 96 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); |
106 | } | 97 | } |
107 | 98 | ||
108 | QList<QListViewItem> list; | 99 | QList<QListViewItem> list; |
109 | getAllItems(backupList->firstChild(), list); | 100 | getAllItems(backupList->firstChild(), list); |
110 | 101 | ||
111 | for(uint i = 0; i < list.count(); i++){ | 102 | for(uint i = 0; i < list.count(); i++){ |
112 | QString text = list.at(i)->text(HEADER_NAME); | 103 | QString text = list.at(i)->text(HEADER_NAME); |
113 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++){ | 104 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++){ |
114 | if(*dontBackupList.at(i2) == text){ | 105 | if(*dontBackupList.at(i2) == text){ |
115 | selectItem(list.at(i)); | 106 | selectItem(list.at(i)); |
116 | break; | 107 | break; |
117 | } | 108 | } |
118 | } | 109 | } |
119 | } | 110 | } |
120 | } | 111 | } |
121 | 112 | ||
122 | BackupAndRestore::~BackupAndRestore(){ | 113 | BackupAndRestore::~BackupAndRestore(){ |
123 | QList<QListViewItem> list; | 114 | QList<QListViewItem> list; |
124 | getAllItems(backupList->firstChild(), list); | 115 | getAllItems(backupList->firstChild(), list); |
125 | 116 | ||
126 | Config config("BackupAndRestore"); | 117 | Config config("BackupAndRestore"); |
127 | config.setGroup("DontBackup"); | 118 | config.setGroup("DontBackup"); |
128 | config.clearGroup(); | 119 | config.clearGroup(); |
129 | 120 | ||
130 | int count = 0; | 121 | int count = 0; |
131 | for(uint i = 0; i < list.count(); i++){ | 122 | for(uint i = 0; i < list.count(); i++){ |
132 | if(list.at(i)->text(HEADER_BACKUP) == ""){ | 123 | if(list.at(i)->text(HEADER_BACKUP) == ""){ |
133 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); | 124 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); |
134 | count++; | 125 | count++; |
135 | } | 126 | } |
136 | } | 127 | } |
137 | config.writeEntry("Total", count); | 128 | config.writeEntry("Total", count); |
138 | 129 | ||
139 | // Remove Temp File | 130 | // Remove Temp File |
140 | if ( QFile::exists( tempFileName ) ) | 131 | if ( QFile::exists( tempFileName ) ) |
141 | QFile::remove( tempFileName ); | 132 | QFile::remove( tempFileName ); |
142 | } | 133 | } |
143 | 134 | ||
144 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list){ | 135 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list){ |
145 | while(item){ | 136 | while(item){ |
146 | if(item->childCount() > 0) | 137 | if(item->childCount() > 0) |
147 | getAllItems(item->firstChild(), list); | 138 | getAllItems(item->firstChild(), list); |
148 | list.append(item); | 139 | list.append(item); |
149 | item = item->nextSibling(); | 140 | item = item->nextSibling(); |
150 | } | 141 | } |
151 | return list; | 142 | return list; |
152 | } | 143 | } |
153 | 144 | ||
154 | /** | 145 | /** |
155 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. | 146 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. |
156 | * and changing the icon to match | 147 | * and changing the icon to match |
157 | * @param currentItem the item to swich the selection choice. | 148 | * @param currentItem the item to swich the selection choice. |
158 | */ | 149 | */ |
159 | void BackupAndRestore::selectItem(QListViewItem *currentItem){ | 150 | void BackupAndRestore::selectItem(QListViewItem *currentItem){ |
160 | if(!currentItem) | 151 | if(!currentItem) |
161 | return; | 152 | return; |
162 | 153 | ||
163 | if(currentItem->text(HEADER_BACKUP) == "B"){ | 154 | if(currentItem->text(HEADER_BACKUP) == "B"){ |
164 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); | 155 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); |
165 | currentItem->setText(HEADER_BACKUP, ""); | 156 | currentItem->setText(HEADER_BACKUP, ""); |
166 | } | 157 | } |
167 | else{ | 158 | else{ |
168 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); | 159 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); |
169 | currentItem->setText(HEADER_BACKUP, "B"); | 160 | currentItem->setText(HEADER_BACKUP, "B"); |
170 | } | 161 | } |
171 | } | 162 | } |
172 | 163 | ||
173 | void BackupAndRestore::scanForApplicationSettings(){ | 164 | void BackupAndRestore::scanForApplicationSettings(){ |
174 | QDir d(applicationSettings->text(BACKUP_LOCATION)); | 165 | QDir d(applicationSettings->text(BACKUP_LOCATION)); |
175 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); | 166 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); |
176 | const QFileInfoList *list = d.entryInfoList(); | 167 | const QFileInfoList *list = d.entryInfoList(); |
177 | QFileInfoListIterator it( *list ); | 168 | QFileInfoListIterator it( *list ); |
178 | QFileInfo *fi; | 169 | QFileInfo *fi; |
179 | while ( (fi=it.current()) ) { | 170 | while ( (fi=it.current()) ) { |
180 | // qDebug((d.path()+fi->fileName()).latin1()); | 171 | // qDebug((d.path()+fi->fileName()).latin1()); |
181 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) { | 172 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) { |
diff --git a/noncore/settings/language/language.cpp b/noncore/settings/language/language.cpp index 8985fd5..d30a041 100644 --- a/noncore/settings/language/language.cpp +++ b/noncore/settings/language/language.cpp | |||
@@ -22,131 +22,131 @@ | |||
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/fontmanager.h> | 24 | #include <qpe/fontmanager.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/qpedialog.h> | 27 | #include <qpe/qpedialog.h> |
28 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 29 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qradiobutton.h> | 35 | #include <qradiobutton.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qslider.h> | 37 | #include <qslider.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qdatastream.h> | 40 | #include <qdatastream.h> |
41 | #include <qmessagebox.h> | 41 | #include <qmessagebox.h> |
42 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qlistbox.h> | 44 | #include <qlistbox.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #if QT_VERSION >= 300 | 46 | #if QT_VERSION >= 300 |
47 | #include <qstylefactory.h> | 47 | #include <qstylefactory.h> |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | 51 | ||
52 | 52 | ||
53 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) | 53 | LanguageSettings::LanguageSettings( QWidget* parent, const char* name, WFlags fl ) |
54 | : LanguageSettingsBase( parent, name, TRUE, fl ) | 54 | : LanguageSettingsBase( parent, name, TRUE, fl ) |
55 | { | 55 | { |
56 | if ( FontManager::hasUnicodeFont() ) | 56 | if ( FontManager::hasUnicodeFont() ) |
57 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); | 57 | languages->setFont(FontManager::unicodeFont(FontManager::Proportional)); |
58 | 58 | ||
59 | 59 | ||
60 | QString tfn = QPEApplication::qpeDir() + "/i18n/"; | 60 | QString tfn = QPEApplication::qpeDir() + "/i18n/"; |
61 | QDir langDir = tfn; | 61 | QDir langDir = tfn; |
62 | QStringList list = langDir.entryList("*", QDir::Dirs ); | 62 | QStringList list = langDir.entryList("*", QDir::Dirs ); |
63 | 63 | ||
64 | QStringList::Iterator it; | 64 | QStringList::Iterator it; |
65 | 65 | ||
66 | for ( it = list.begin(); it != list.end(); ++it ) { | 66 | for ( it = list.begin(); it != list.end(); ++it ) { |
67 | QString name = (*it); | 67 | QString name = (*it); |
68 | QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); | 68 | QFileInfo desktopFile( tfn + "/" + name + "/.directory" ); |
69 | if ( desktopFile.exists() ) { | 69 | if ( desktopFile.exists() ) { |
70 | langAvail.append(name); | 70 | langAvail.append(name); |
71 | Config conf( desktopFile.filePath(), Config::File ); | 71 | Config conf( desktopFile.filePath(), Config::File ); |
72 | QString langName = conf.readEntry( "Name" ); | 72 | QString langName = conf.readEntry( "Name" ); |
73 | QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); | 73 | QString ownName = conf.readEntryDirect( "Name[" + name + "]" ); |
74 | if ( ownName.isEmpty() ) | 74 | if ( ownName.isEmpty() ) |
75 | ownName = conf.readEntryDirect( "Name" ); | 75 | ownName = conf.readEntryDirect( "Name" ); |
76 | if ( !ownName.isEmpty() && ownName != langName ) | 76 | if ( !ownName.isEmpty() && ownName != langName ) |
77 | langName = langName + " [" + ownName + "]"; | 77 | langName = langName + " [" + ownName + "]"; |
78 | languages->insertItem( langName ); | 78 | languages->insertItem( langName ); |
79 | 79 | ||
80 | } | 80 | } |
81 | } | 81 | } |
82 | if ( langAvail. find ( "en" ) == -1 ) { | 82 | if ( langAvail. find ( "en" ) == -1 ) { |
83 | langAvail. prepend ( "" ); // no tr | 83 | langAvail. prepend ( "" ); // no tr |
84 | languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); | 84 | languages-> insertItem ( QString ( "English [%1] (%2)" /* no tr (!) */ ). arg ( tr ( "English" )). arg ( tr( "default" )), 0 ); |
85 | } | 85 | } |
86 | 86 | ||
87 | dl = new QPEDialogListener(this); | 87 | dl = new QPEDialogListener(this); |
88 | reset(); | 88 | reset(); |
89 | } | 89 | } |
90 | 90 | ||
91 | LanguageSettings::~LanguageSettings() | 91 | LanguageSettings::~LanguageSettings() |
92 | {} | 92 | {} |
93 | 93 | ||
94 | void LanguageSettings::accept() | 94 | void LanguageSettings::accept() |
95 | { | 95 | { |
96 | applyLanguage(); | 96 | applyLanguage(); |
97 | QDialog::accept(); | 97 | QDialog::accept(); |
98 | } | 98 | } |
99 | 99 | ||
100 | void LanguageSettings::applyLanguage() | 100 | void LanguageSettings::applyLanguage() |
101 | { | 101 | { |
102 | setLanguage ( langAvail. at ( languages-> currentItem ( ))); | 102 | setLanguage ( langAvail. at ( languages-> currentItem ( ))); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void LanguageSettings::reject() | 106 | void LanguageSettings::reject() |
107 | { | 107 | { |
108 | reset(); | 108 | reset(); |
109 | QDialog::reject(); | 109 | QDialog::reject(); |
110 | } | 110 | } |
111 | 111 | ||
112 | void LanguageSettings::reset() | 112 | void LanguageSettings::reset() |
113 | { | 113 | { |
114 | QString l = getenv("LANG"); | 114 | QString l = getenv("LANG"); |
115 | Config config("locale"); | 115 | Config config("locale"); |
116 | config.setGroup("Language"); | 116 | config.setGroup("Language"); |
117 | l = config.readEntry( "Language", l ); | 117 | l = config.readEntry( "Language", l ); |
118 | actualLanguage = l; | ||
118 | if (l.isEmpty()) | 119 | if (l.isEmpty()) |
119 | l = "en"; | 120 | l = "en"; |
120 | actualLanguage = l; | ||
121 | 121 | ||
122 | int n = langAvail.find( l ); | 122 | int n = langAvail.find( l ); |
123 | languages->setCurrentItem( n ); | 123 | languages->setCurrentItem( n ); |
124 | } | 124 | } |
125 | 125 | ||
126 | QString LanguageSettings::actualLanguage; | 126 | QString LanguageSettings::actualLanguage; |
127 | 127 | ||
128 | void LanguageSettings::setLanguage(const QString& lang) | 128 | void LanguageSettings::setLanguage(const QString& lang) |
129 | { | 129 | { |
130 | if ( lang != actualLanguage ) { | 130 | if ( lang != actualLanguage ) { |
131 | Config config("locale"); | 131 | Config config("locale"); |
132 | config.setGroup( "Language" ); | 132 | config.setGroup( "Language" ); |
133 | if ( lang. isEmpty ( )) | 133 | if ( lang. isEmpty ( )) |
134 | config. removeEntry ( "Language" ); | 134 | config. removeEntry ( "Language" ); |
135 | else | 135 | else |
136 | config.writeEntry( "Language", lang ); | 136 | config.writeEntry( "Language", lang ); |
137 | config.write(); | 137 | config.write(); |
138 | 138 | ||
139 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 139 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
140 | 140 | ||
141 | QCopEnvelope e("QPE/System", "language(QString)"); | 141 | QCopEnvelope e("QPE/System", "language(QString)"); |
142 | e << lang; | 142 | e << lang; |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | void LanguageSettings::done(int r) | 148 | void LanguageSettings::done(int r) |
149 | { | 149 | { |
150 | QDialog::done(r); | 150 | QDialog::done(r); |
151 | close(); | 151 | close(); |
152 | } | 152 | } |
diff --git a/noncore/settings/mediummount/mainwindow.cc b/noncore/settings/mediummount/mainwindow.cc index 6b37cff..eec786c 100644 --- a/noncore/settings/mediummount/mainwindow.cc +++ b/noncore/settings/mediummount/mainwindow.cc | |||
@@ -1,82 +1,83 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qtabwidget.h> | 3 | #include <qtabwidget.h> |
4 | #include <qlayout.h> | 4 | #include <qlayout.h> |
5 | #include <qtooltip.h> | 5 | #include <qtooltip.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | 7 | ||
8 | #include <qpe/storage.h> | 8 | #include <qpe/storage.h> |
9 | 9 | ||
10 | #include "mediumwidget.h" | 10 | #include "mediumwidget.h" |
11 | #include "mediumglobal.h" | 11 | #include "mediumglobal.h" |
12 | 12 | ||
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | 14 | ||
15 | using namespace MediumMountSetting; | 15 | using namespace MediumMountSetting; |
16 | 16 | ||
17 | /* TRANSLATOR MediumMountSetting::MainWindow */ | ||
17 | 18 | ||
18 | MainWindow::MainWindow( QWidget *parent, const char *name, bool modal, WFlags ) | 19 | MainWindow::MainWindow( QWidget *parent, const char *name, bool modal, WFlags ) |
19 | : QDialog( parent, name, modal, WStyle_ContextHelp ) | 20 | : QDialog( parent, name, modal, WStyle_ContextHelp ) |
20 | 21 | ||
21 | { | 22 | { |
22 | setCaption ( tr( "Medium Mount Settings" )); | 23 | setCaption ( tr( "Medium Mount Settings" )); |
23 | 24 | ||
24 | m_lay = new QVBoxLayout( this ); | 25 | m_lay = new QVBoxLayout( this ); |
25 | 26 | ||
26 | m_tab = new QTabWidget( this ); | 27 | m_tab = new QTabWidget( this ); |
27 | 28 | ||
28 | m_lay->addWidget( m_tab ); | 29 | m_lay->addWidget( m_tab ); |
29 | 30 | ||
30 | init(); | 31 | init(); |
31 | } | 32 | } |
32 | 33 | ||
33 | MainWindow::~MainWindow() | 34 | MainWindow::~MainWindow() |
34 | { | 35 | { |
35 | } | 36 | } |
36 | 37 | ||
37 | void MainWindow::init() | 38 | void MainWindow::init() |
38 | { | 39 | { |
39 | m_global = new MediumGlobalWidget( m_tab, "test drive" ); | 40 | m_global = new MediumGlobalWidget( m_tab, "test drive" ); |
40 | m_tab->addTab( m_global, tr("Global") ); | 41 | m_tab->addTab( m_global, tr("Global") ); |
41 | 42 | ||
42 | StorageInfo storage; | 43 | StorageInfo storage; |
43 | const QList<FileSystem> &fs = storage.fileSystems(); | 44 | const QList<FileSystem> &fs = storage.fileSystems(); |
44 | QListIterator<FileSystem> it( fs ); | 45 | QListIterator<FileSystem> it( fs ); |
45 | MediumMountWidget *wid; | 46 | MediumMountWidget *wid; |
46 | for( ; it.current(); ++it ){ | 47 | for( ; it.current(); ++it ){ |
47 | if( (*it)->isRemovable() ){ | 48 | if( (*it)->isRemovable() ){ |
48 | wid = new MediumMountWidget((*it)->path(), QPixmap(), m_tab ); | 49 | wid = new MediumMountWidget((*it)->path(), QPixmap(), m_tab ); |
49 | m_mediums.append( wid ); | 50 | m_mediums.append( wid ); |
50 | m_tab->addTab( wid, (*it)->name() ); | 51 | m_tab->addTab( wid, (*it)->name() ); |
51 | } | 52 | } |
52 | } | 53 | } |
53 | } | 54 | } |
54 | 55 | ||
55 | void MainWindow::accept() | 56 | void MainWindow::accept() |
56 | { | 57 | { |
57 | m_global->writeConfig(); | 58 | m_global->writeConfig(); |
58 | 59 | ||
59 | MediumMountWidget *confWidget; | 60 | MediumMountWidget *confWidget; |
60 | for ( confWidget = m_mediums.first(); confWidget != 0; | 61 | for ( confWidget = m_mediums.first(); confWidget != 0; |
61 | confWidget = m_mediums.next() ) { | 62 | confWidget = m_mediums.next() ) { |
62 | confWidget->writeConfig(); | 63 | confWidget->writeConfig(); |
63 | } | 64 | } |
64 | 65 | ||
65 | QDialog::accept(); | 66 | QDialog::accept(); |
66 | } | 67 | } |
67 | 68 | ||
68 | void MainWindow::done ( int r ) | 69 | void MainWindow::done ( int r ) |
69 | { | 70 | { |
70 | QDialog::done( r ); | 71 | QDialog::done( r ); |
71 | close (); | 72 | close (); |
72 | } | 73 | } |
73 | 74 | ||
74 | 75 | ||
75 | void MainWindow::slotGlobalChanged(int ) | 76 | void MainWindow::slotGlobalChanged(int ) |
76 | { | 77 | { |
77 | 78 | ||
78 | } | 79 | } |
79 | void MainWindow::slotCheckingChanged(int ) | 80 | void MainWindow::slotCheckingChanged(int ) |
80 | { | 81 | { |
81 | 82 | ||
82 | } | 83 | } |
diff --git a/noncore/settings/mediummount/mediumglobal.cc b/noncore/settings/mediummount/mediumglobal.cc index 75e3839..ab0b3af 100644 --- a/noncore/settings/mediummount/mediumglobal.cc +++ b/noncore/settings/mediummount/mediumglobal.cc | |||
@@ -1,113 +1,115 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qlineedit.h> | 3 | #include <qlineedit.h> |
4 | #include <qcheckbox.h> | 4 | #include <qcheckbox.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qabstractlayout.h> // spacer item | 6 | #include <qabstractlayout.h> // spacer item |
7 | #include <qlayout.h> | 7 | #include <qlayout.h> |
8 | #include <qframe.h> | 8 | #include <qframe.h> |
9 | #include <qgroupbox.h> | 9 | #include <qgroupbox.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | 11 | ||
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | 13 | ||
14 | #include "mediumglobal.h" | 14 | #include "mediumglobal.h" |
15 | 15 | ||
16 | using namespace MediumMountSetting; | 16 | using namespace MediumMountSetting; |
17 | 17 | ||
18 | /* TRANSLATOR MediumMountSetting::MediumGlobalWidget */ | ||
19 | |||
18 | MediumGlobalWidget::MediumGlobalWidget(QWidget *wid, const char *name ) | 20 | MediumGlobalWidget::MediumGlobalWidget(QWidget *wid, const char *name ) |
19 | : QWidget( wid, name, WStyle_ContextHelp ) | 21 | : QWidget( wid, name, WStyle_ContextHelp ) |
20 | { | 22 | { |
21 | m_config = 0; | 23 | m_config = 0; |
22 | initGUI(); | 24 | initGUI(); |
23 | readConfig(); | 25 | readConfig(); |
24 | 26 | ||
25 | } | 27 | } |
26 | void MediumGlobalWidget::initGUI() | 28 | void MediumGlobalWidget::initGUI() |
27 | { | 29 | { |
28 | m_layout = new QVBoxLayout(this ); | 30 | m_layout = new QVBoxLayout(this ); |
29 | m_layout->setMargin( 4 ); | 31 | m_layout->setMargin( 4 ); |
30 | // m_layout->setSpacing( 10 ); | 32 | // m_layout->setSpacing( 10 ); |
31 | 33 | ||
32 | 34 | ||
33 | m_label = new QLabel( this ); | 35 | m_label = new QLabel( this ); |
34 | m_label->setTextFormat( Qt::RichText ); | 36 | m_label->setTextFormat( Qt::RichText ); |
35 | m_label->setText( tr("") ); | 37 | m_label->setText( tr("") ); |
36 | QWhatsThis::add( this, tr("If a medium gets inserted into this device Opie " | 38 | QWhatsThis::add( this, tr("If a medium gets inserted into this device Opie " |
37 | "tries to search the medium for Documents. On " | 39 | "tries to search the medium for Documents. On " |
38 | "large mediums this can take some time. You can choose " | 40 | "large mediums this can take some time. You can choose " |
39 | "if Opie should scan for Documents globally or on a " | 41 | "if Opie should scan for Documents globally or on a " |
40 | "per medium level. You're also able to reconfigure " | 42 | "per medium level. You're also able to reconfigure " |
41 | "each medium.") ); | 43 | "each medium.") ); |
42 | 44 | ||
43 | m_layout->addWidget( m_label ); | 45 | m_layout->addWidget( m_label ); |
44 | 46 | ||
45 | m_check = new QCheckBox( tr("Enable medium checking" ), this ); | 47 | m_check = new QCheckBox( tr("Enable medium checking" ), this ); |
46 | connect( m_check, SIGNAL(stateChanged(int) ), | 48 | connect( m_check, SIGNAL(stateChanged(int) ), |
47 | this, SLOT(slotEnableChecking() ) ); | 49 | this, SLOT(slotEnableChecking() ) ); |
48 | m_layout->addWidget(m_check ); | 50 | m_layout->addWidget(m_check ); |
49 | 51 | ||
50 | m_frame = new QFrame(this, "Frame" ); | 52 | m_frame = new QFrame(this, "Frame" ); |
51 | m_frame->setFrameShape( QFrame::Box ); | 53 | m_frame->setFrameShape( QFrame::Box ); |
52 | m_frame->setFrameShadow( QFrame::Sunken ); | 54 | m_frame->setFrameShadow( QFrame::Sunken ); |
53 | 55 | ||
54 | m_box = new QVBoxLayout( m_frame ); | 56 | m_box = new QVBoxLayout( m_frame ); |
55 | m_box->setMargin( 5 ); | 57 | m_box->setMargin( 5 ); |
56 | m_useglobal = new QCheckBox( tr("Use global settings"), m_frame ); | 58 | m_useglobal = new QCheckBox( tr("Use global settings"), m_frame ); |
57 | connect( m_useglobal, SIGNAL( stateChanged(int) ), | 59 | connect( m_useglobal, SIGNAL( stateChanged(int) ), |
58 | this, SLOT( slotGlobalChanged() ) ); | 60 | this, SLOT( slotGlobalChanged() ) ); |
59 | 61 | ||
60 | m_box->addWidget( m_useglobal ); | 62 | m_box->addWidget( m_useglobal ); |
61 | 63 | ||
62 | m_global = new QGroupBox( tr("Which media files"), m_frame ); | 64 | m_global = new QGroupBox( tr("Which media files"), m_frame ); |
63 | m_frameLay = new QGridLayout(m_global, 4, 3 ); | 65 | m_frameLay = new QGridLayout(m_global, 4, 3 ); |
64 | m_frameLay->setMargin( 10 ); | 66 | m_frameLay->setMargin( 10 ); |
65 | 67 | ||
66 | QSpacerItem *item2 = new QSpacerItem( 5, 8, | 68 | QSpacerItem *item2 = new QSpacerItem( 5, 8, |
67 | QSizePolicy::Fixed, | 69 | QSizePolicy::Fixed, |
68 | QSizePolicy::Fixed ); | 70 | QSizePolicy::Fixed ); |
69 | m_audio = new QCheckBox( tr("Audio"), m_global ); | 71 | m_audio = new QCheckBox( tr("Audio"), m_global ); |
70 | m_all = new QCheckBox( tr("All") , m_global ); | 72 | m_all = new QCheckBox( tr("All") , m_global ); |
71 | m_image = new QCheckBox( tr("Image"), m_global ); | 73 | m_image = new QCheckBox( tr("Image"), m_global ); |
72 | m_text = new QCheckBox( tr("Text") , m_global ); | 74 | m_text = new QCheckBox( tr("Text") , m_global ); |
73 | m_video = new QCheckBox( tr("Video"), m_global ); | 75 | m_video = new QCheckBox( tr("Video"), m_global ); |
74 | 76 | ||
75 | connect(m_all, SIGNAL(stateChanged(int) ), | 77 | connect(m_all, SIGNAL(stateChanged(int) ), |
76 | this, SLOT(slotAllChanged() ) ); | 78 | this, SLOT(slotAllChanged() ) ); |
77 | 79 | ||
78 | m_frameLay->addItem( item2, 0, 0 ); | 80 | m_frameLay->addItem( item2, 0, 0 ); |
79 | 81 | ||
80 | m_frameLay->addWidget( m_audio, 1, 0 ); | 82 | m_frameLay->addWidget( m_audio, 1, 0 ); |
81 | m_frameLay->addWidget( m_image, 2, 0 ); | 83 | m_frameLay->addWidget( m_image, 2, 0 ); |
82 | m_frameLay->addWidget( m_all, 3, 0 ); | 84 | m_frameLay->addWidget( m_all, 3, 0 ); |
83 | 85 | ||
84 | m_frameLay->addWidget( m_text, 1, 2 ); | 86 | m_frameLay->addWidget( m_text, 1, 2 ); |
85 | m_frameLay->addWidget( m_video, 2, 2 ); | 87 | m_frameLay->addWidget( m_video, 2, 2 ); |
86 | 88 | ||
87 | m_frameLay->addRowSpacing( 0, 8 ); | 89 | m_frameLay->addRowSpacing( 0, 8 ); |
88 | m_frameLay->addColSpacing( 1, 2 ); | 90 | m_frameLay->addColSpacing( 1, 2 ); |
89 | 91 | ||
90 | m_box->addWidget( m_global ); | 92 | m_box->addWidget( m_global ); |
91 | 93 | ||
92 | 94 | ||
93 | m_layout->addWidget( m_frame ); | 95 | m_layout->addWidget( m_frame ); |
94 | 96 | ||
95 | QSpacerItem *item1 = new QSpacerItem( 1, 24, | 97 | QSpacerItem *item1 = new QSpacerItem( 1, 24, |
96 | QSizePolicy::Fixed, | 98 | QSizePolicy::Fixed, |
97 | QSizePolicy::Expanding ); | 99 | QSizePolicy::Expanding ); |
98 | m_layout->addItem( item1 ); | 100 | m_layout->addItem( item1 ); |
99 | } | 101 | } |
100 | void MediumGlobalWidget::readConfig() | 102 | void MediumGlobalWidget::readConfig() |
101 | { | 103 | { |
102 | if( m_config == 0 ) | 104 | if( m_config == 0 ) |
103 | m_config = new Config("medium" ); | 105 | m_config = new Config("medium" ); |
104 | 106 | ||
105 | m_config->setGroup("main"); | 107 | m_config->setGroup("main"); |
106 | m_useglobal->setChecked( m_config->readBoolEntry("global", false ) ); | 108 | m_useglobal->setChecked( m_config->readBoolEntry("global", false ) ); |
107 | m_check->setChecked( m_config->readBoolEntry("use", true ) ); | 109 | m_check->setChecked( m_config->readBoolEntry("use", true ) ); |
108 | 110 | ||
109 | m_config->setGroup("mimetypes" ); | 111 | m_config->setGroup("mimetypes" ); |
110 | m_all->setChecked ( m_config->readBoolEntry("all", false ) ); | 112 | m_all->setChecked ( m_config->readBoolEntry("all", false ) ); |
111 | m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); | 113 | m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); |
112 | m_video->setChecked( m_config->readBoolEntry("video", true ) ); | 114 | m_video->setChecked( m_config->readBoolEntry("video", true ) ); |
113 | m_text->setChecked ( m_config->readBoolEntry("text", true ) ); | 115 | m_text->setChecked ( m_config->readBoolEntry("text", true ) ); |
diff --git a/noncore/settings/mediummount/mediumwidget.cc b/noncore/settings/mediummount/mediumwidget.cc index eadf502..981e1dd 100644 --- a/noncore/settings/mediummount/mediumwidget.cc +++ b/noncore/settings/mediummount/mediumwidget.cc | |||
@@ -1,120 +1,122 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qgroupbox.h> | 4 | #include <qgroupbox.h> |
5 | #include <qhbox.h> | 5 | #include <qhbox.h> |
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qabstractlayout.h> | 7 | #include <qabstractlayout.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qpixmap.h> | 10 | #include <qpixmap.h> |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qvbox.h> | 12 | #include <qvbox.h> |
13 | #include <qwhatsthis.h> | 13 | #include <qwhatsthis.h> |
14 | 14 | ||
15 | 15 | ||
16 | #include <qpe/config.h> | 16 | #include <qpe/config.h> |
17 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
18 | 18 | ||
19 | #include "mediumwidget.h" | 19 | #include "mediumwidget.h" |
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | using namespace MediumMountSetting; | 23 | using namespace MediumMountSetting; |
24 | 24 | ||
25 | /* TRANSLATOR MediumMountSetting::MediumMountWidget */ | ||
26 | |||
25 | MediumMountWidget::MediumMountWidget(const QString &path, | 27 | MediumMountWidget::MediumMountWidget(const QString &path, |
26 | const QPixmap &pix, | 28 | const QPixmap &pix, |
27 | QWidget *parent, | 29 | QWidget *parent, |
28 | const char *name ) | 30 | const char *name ) |
29 | : QWidget( parent, name ) | 31 | : QWidget( parent, name ) |
30 | { | 32 | { |
31 | if(parent == 0){ | 33 | if(parent == 0){ |
32 | resize(QApplication::desktop()->width(), QApplication::desktop()->height() ); | 34 | resize(QApplication::desktop()->width(), QApplication::desktop()->height() ); |
33 | }else{ | 35 | }else{ |
34 | resize(parent->width(), parent->height() ); | 36 | resize(parent->width(), parent->height() ); |
35 | } | 37 | } |
36 | m_path = path; | 38 | m_path = path; |
37 | initGUI(); | 39 | initGUI(); |
38 | m_label->setPixmap(pix ); | 40 | m_label->setPixmap(pix ); |
39 | m_config = 0; | 41 | m_config = 0; |
40 | 42 | ||
41 | readConfig(); | 43 | readConfig(); |
42 | } | 44 | } |
43 | // now we fire up the GUI | 45 | // now we fire up the GUI |
44 | // if I would know what I'm doing ;) | 46 | // if I would know what I'm doing ;) |
45 | void MediumMountWidget::initGUI() | 47 | void MediumMountWidget::initGUI() |
46 | { | 48 | { |
47 | //main layout | 49 | //main layout |
48 | m_box = new QVBoxLayout( this , 5, 5 ); | 50 | m_box = new QVBoxLayout( this , 5, 5 ); |
49 | //m_box->setSpacing( 5 ); | 51 | //m_box->setSpacing( 5 ); |
50 | //m_box->addStretch( -1 ); | 52 | //m_box->addStretch( -1 ); |
51 | 53 | ||
52 | // picture + text | 54 | // picture + text |
53 | m_infoBox = new QHBox(this, "infobox" ); | 55 | m_infoBox = new QHBox(this, "infobox" ); |
54 | //m_infoBox->setSpacing( 4 ); | 56 | //m_infoBox->setSpacing( 4 ); |
55 | m_label = new QLabel(m_infoBox ); | 57 | m_label = new QLabel(m_infoBox ); |
56 | m_desc = new QLabel(m_infoBox ); | 58 | m_desc = new QLabel(m_infoBox ); |
57 | m_desc->setTextFormat( Qt::RichText ); | 59 | m_desc->setTextFormat( Qt::RichText ); |
58 | QWhatsThis::add( this, tr("Configure this medium. The changes will" | 60 | QWhatsThis::add( this, tr("Configure this medium. The changes will" |
59 | " go into effect when the application gets" | 61 | " go into effect when the application gets" |
60 | " closed. To update the Document Tab you need" | 62 | " closed. To update the Document Tab you need" |
61 | " to remove and insert this medium.")); | 63 | " to remove and insert this medium.")); |
62 | m_desc->setText("" ); | 64 | m_desc->setText("" ); |
63 | m_box->addWidget( m_infoBox ); // add the widget to the layout | 65 | m_box->addWidget( m_infoBox ); // add the widget to the layout |
64 | 66 | ||
65 | 67 | ||
66 | // groupbox | 68 | // groupbox |
67 | m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" ); | 69 | m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" ); |
68 | m_checks = new QGridLayout( m_group, 4, 3 ); | 70 | m_checks = new QGridLayout( m_group, 4, 3 ); |
69 | //m_checks->setMargin( 12 ); | 71 | //m_checks->setMargin( 12 ); |
70 | 72 | ||
71 | 73 | ||
72 | 74 | ||
73 | QSpacerItem *item2 = new QSpacerItem(5, 8, | 75 | QSpacerItem *item2 = new QSpacerItem(5, 8, |
74 | QSizePolicy::Fixed, | 76 | QSizePolicy::Fixed, |
75 | QSizePolicy::Fixed); | 77 | QSizePolicy::Fixed); |
76 | m_box->addItem( item2 ); | 78 | m_box->addItem( item2 ); |
77 | 79 | ||
78 | m_audio = new QCheckBox( tr("Audio"), m_group ); | 80 | m_audio = new QCheckBox( tr("Audio"), m_group ); |
79 | m_all = new QCheckBox( tr("All") , m_group ); | 81 | m_all = new QCheckBox( tr("All") , m_group ); |
80 | m_image = new QCheckBox( tr("Image"), m_group ); | 82 | m_image = new QCheckBox( tr("Image"), m_group ); |
81 | m_text = new QCheckBox( tr("Text") , m_group ); | 83 | m_text = new QCheckBox( tr("Text") , m_group ); |
82 | m_video = new QCheckBox( tr("Video"), m_group ); | 84 | m_video = new QCheckBox( tr("Video"), m_group ); |
83 | 85 | ||
84 | QSpacerItem *iti1b = new QSpacerItem(2, 10, QSizePolicy::Fixed, | 86 | QSpacerItem *iti1b = new QSpacerItem(2, 10, QSizePolicy::Fixed, |
85 | QSizePolicy::Fixed ); | 87 | QSizePolicy::Fixed ); |
86 | m_checks->addItem( iti1b, 0, 0 ); | 88 | m_checks->addItem( iti1b, 0, 0 ); |
87 | 89 | ||
88 | m_checks->addWidget(m_audio, 1, 0 ); | 90 | m_checks->addWidget(m_audio, 1, 0 ); |
89 | m_checks->addWidget(m_image, 2, 0 ); | 91 | m_checks->addWidget(m_image, 2, 0 ); |
90 | m_checks->addWidget(m_all , 3, 0 ); | 92 | m_checks->addWidget(m_all , 3, 0 ); |
91 | 93 | ||
92 | m_checks->addWidget(m_text, 1, 2 ); | 94 | m_checks->addWidget(m_text, 1, 2 ); |
93 | m_checks->addWidget(m_video, 2, 2 ); | 95 | m_checks->addWidget(m_video, 2, 2 ); |
94 | 96 | ||
95 | m_checks->addRowSpacing(0, 8 ); | 97 | m_checks->addRowSpacing(0, 8 ); |
96 | m_checks->addColSpacing(1, 2 ); | 98 | m_checks->addColSpacing(1, 2 ); |
97 | m_checks->setColStretch(1, -2 ); | 99 | m_checks->setColStretch(1, -2 ); |
98 | 100 | ||
99 | connect(m_all, SIGNAL(stateChanged(int) ), | 101 | connect(m_all, SIGNAL(stateChanged(int) ), |
100 | this, SLOT(slotStateChanged() ) ); | 102 | this, SLOT(slotStateChanged() ) ); |
101 | 103 | ||
102 | m_box->addWidget( m_group ); | 104 | m_box->addWidget( m_group ); |
103 | 105 | ||
104 | // label | 106 | // label |
105 | m_lblPath = new QLabel(tr("Limit search to:"), this ); | 107 | m_lblPath = new QLabel(tr("Limit search to:"), this ); |
106 | m_box->addWidget( m_lblPath ); | 108 | m_box->addWidget( m_lblPath ); |
107 | 109 | ||
108 | // add to | 110 | // add to |
109 | m_hboxAdd = new QHBox( this ); | 111 | m_hboxAdd = new QHBox( this ); |
110 | //m_hboxAdd->setSpacing( 10 ); | 112 | //m_hboxAdd->setSpacing( 10 ); |
111 | m_edit = new QLineEdit(m_hboxAdd ); | 113 | m_edit = new QLineEdit(m_hboxAdd ); |
112 | m_add = new QPushButton(m_hboxAdd ); | 114 | m_add = new QPushButton(m_hboxAdd ); |
113 | m_add->setText( tr("Add") ); | 115 | m_add->setText( tr("Add") ); |
114 | 116 | ||
115 | m_box->addWidget(m_hboxAdd ); | 117 | m_box->addWidget(m_hboxAdd ); |
116 | 118 | ||
117 | m_always = new QCheckBox( tr("Always check this medium"), this ); | 119 | m_always = new QCheckBox( tr("Always check this medium"), this ); |
118 | 120 | ||
119 | m_box->addWidget( m_always ); | 121 | m_box->addWidget( m_always ); |
120 | 122 | ||
diff --git a/noncore/settings/networksettings/interfaces/interface.cpp b/noncore/settings/networksettings/interfaces/interface.cpp index cc45525..69b55d1 100644 --- a/noncore/settings/networksettings/interfaces/interface.cpp +++ b/noncore/settings/networksettings/interfaces/interface.cpp | |||
@@ -1,302 +1,302 @@ | |||
1 | /** | 1 | /** |
2 | * $Author$ | 2 | * $Author$ |
3 | * $Date$ | 3 | * $Date$ |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "interface.h" | 6 | #include "interface.h" |
7 | #include <qdatetime.h> | 7 | #include <qdatetime.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qfileinfo.h> | 10 | #include <qfileinfo.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | 12 | ||
13 | #define IFCONFIG "/sbin/ifconfig" | 13 | #define IFCONFIG "/sbin/ifconfig" |
14 | #define DHCP_INFO_DIR "/etc/dhcpc" | 14 | #define DHCP_INFO_DIR "/etc/dhcpc" |
15 | 15 | ||
16 | #include <stdio.h> | 16 | #include <stdio.h> |
17 | #include <stdlib.h> | 17 | #include <stdlib.h> |
18 | 18 | ||
19 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){ | 19 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), hardwareName("Unknown"), moduleOwner(NULL), status(newSatus), attached(false), dhcp(false), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"){ |
20 | refresh(); | 20 | refresh(); |
21 | } | 21 | } |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * Set status | 24 | * Set status |
25 | * @param newStatus - the new status | 25 | * @param newStatus - the new status |
26 | * emit updateInterface | 26 | * emit updateInterface |
27 | */ | 27 | */ |
28 | void Interface::setStatus(bool newStatus){ | 28 | void Interface::setStatus(bool newStatus){ |
29 | if(status != newStatus){ | 29 | if(status != newStatus){ |
30 | status = newStatus; | 30 | status = newStatus; |
31 | refresh(); | 31 | refresh(); |
32 | } | 32 | } |
33 | }; | 33 | }; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Set if attached or not (802.11 card pulled out for example) | 36 | * Set if attached or not (802.11 card pulled out for example) |
37 | * @param isAttached - if attached | 37 | * @param isAttached - if attached |
38 | * emit updateInterface | 38 | * emit updateInterface |
39 | */ | 39 | */ |
40 | void Interface::setAttached(bool isAttached){ | 40 | void Interface::setAttached(bool isAttached){ |
41 | attached = isAttached; | 41 | attached = isAttached; |
42 | emit(updateInterface(this)); | 42 | emit(updateInterface(this)); |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Set Hardware name | 46 | * Set Hardware name |
47 | * @param name - the new name | 47 | * @param name - the new name |
48 | * emit updateInterface | 48 | * emit updateInterface |
49 | */ | 49 | */ |
50 | void Interface::setHardwareName(const QString &name){ | 50 | void Interface::setHardwareName(const QString &name){ |
51 | hardwareName = name; | 51 | hardwareName = name; |
52 | emit(updateInterface(this)); | 52 | emit(updateInterface(this)); |
53 | }; | 53 | }; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Set Module owner | 56 | * Set Module owner |
57 | * @param owner - the new owner | 57 | * @param owner - the new owner |
58 | * emit updateInterface | 58 | * emit updateInterface |
59 | */ | 59 | */ |
60 | void Interface::setModuleOwner(Module *owner){ | 60 | void Interface::setModuleOwner(Module *owner){ |
61 | moduleOwner = owner; | 61 | moduleOwner = owner; |
62 | emit(updateInterface(this)); | 62 | emit(updateInterface(this)); |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Try to start the interface. | 67 | * Try to start the interface. |
68 | */ | 68 | */ |
69 | void Interface::start(){ | 69 | void Interface::start(){ |
70 | // check to see if we are already running. | 70 | // check to see if we are already running. |
71 | if(true == status){ | 71 | if(true == status){ |
72 | emit (updateMessage("Unable to start interface,\n already started")); | 72 | emit (updateMessage("Unable to start interface,\n already started")); |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | 75 | ||
76 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); | 76 | int ret = system(QString("%1 %2 up").arg(IFCONFIG).arg(this->name()).latin1()); |
77 | // See if it was successfull... | 77 | // See if it was successfull... |
78 | if(ret != 0){ | 78 | if(ret != 0){ |
79 | emit (updateMessage("Starting interface failed")); | 79 | emit (updateMessage("Starting interface failed")); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | status = true; | 83 | status = true; |
84 | refresh(); | 84 | refresh(); |
85 | emit (updateMessage("Start successfull")); | 85 | emit (updateMessage("Start successfull")); |
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Try to stop the interface. | 89 | * Try to stop the interface. |
90 | */ | 90 | */ |
91 | void Interface::stop(){ | 91 | void Interface::stop(){ |
92 | // check to see if we are already stopped. | 92 | // check to see if we are already stopped. |
93 | if(false == status){ | 93 | if(false == status){ |
94 | emit (updateMessage("Unable to stop interface,\n already stopped")); | 94 | emit (updateMessage("Unable to stop interface,\n already stopped")); |
95 | return; | 95 | return; |
96 | } | 96 | } |
97 | 97 | ||
98 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); | 98 | int ret = system(QString("%1 %2 down").arg(IFCONFIG).arg(this->name()).latin1()); |
99 | if(ret != 0){ | 99 | if(ret != 0){ |
100 | emit (updateMessage("Stopping interface failed")); | 100 | emit (updateMessage("Stopping interface failed")); |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | 103 | ||
104 | status = false; | 104 | status = false; |
105 | refresh(); | 105 | refresh(); |
106 | emit (updateMessage("Stop successfull")); | 106 | emit (updateMessage("Stop successfull")); |
107 | } | 107 | } |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Try to restart the interface. | 110 | * Try to restart the interface. |
111 | */ | 111 | */ |
112 | void Interface::restart(){ | 112 | void Interface::restart(){ |
113 | stop(); | 113 | stop(); |
114 | start(); | 114 | start(); |
115 | } | 115 | } |
116 | 116 | ||
117 | /** | 117 | /** |
118 | * Try to refresh the information about the interface. | 118 | * Try to refresh the information about the interface. |
119 | * First call ifconfig, then check the dhcp-info file | 119 | * First call ifconfig, then check the dhcp-info file |
120 | * @return bool true if successfull. | 120 | * @return bool true if successfull. |
121 | */ | 121 | */ |
122 | bool Interface::refresh(){ | 122 | bool Interface::refresh(){ |
123 | // See if we are up. | 123 | // See if we are up. |
124 | if(status == false){ | 124 | if(status == false){ |
125 | macAddress = ""; | 125 | macAddress = ""; |
126 | ip = "0.0.0.0"; | 126 | ip = "0.0.0.0"; |
127 | subnetMask = "0.0.0.0"; | 127 | subnetMask = "0.0.0.0"; |
128 | broadcast = ""; | 128 | broadcast = ""; |
129 | dhcp = false; | 129 | dhcp = false; |
130 | dhcpServerIp = ""; | 130 | dhcpServerIp = ""; |
131 | leaseObtained = ""; | 131 | leaseObtained = ""; |
132 | leaseExpires = ""; | 132 | leaseExpires = ""; |
133 | emit(updateInterface(this)); | 133 | emit(updateInterface(this)); |
134 | return true; | 134 | return true; |
135 | } | 135 | } |
136 | 136 | ||
137 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); | 137 | QString fileName = QString("/tmp/%1_ifconfig_info").arg(this->name()); |
138 | int ret = system(QString("%1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); | 138 | int ret = system(QString("LANG=C %1 %2 > %3").arg(IFCONFIG).arg(this->name()).arg(fileName).latin1()); |
139 | if(ret != 0){ | 139 | if(ret != 0){ |
140 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); | 140 | qDebug(QString("Interface: Ifconfig return value: %1, is not 0").arg(ret).latin1()); |
141 | return false; | 141 | return false; |
142 | } | 142 | } |
143 | 143 | ||
144 | QFile file(fileName); | 144 | QFile file(fileName); |
145 | if (!file.open(IO_ReadOnly)){ | 145 | if (!file.open(IO_ReadOnly)){ |
146 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | 146 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); |
147 | return false; | 147 | return false; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Set to the defaults | 150 | // Set to the defaults |
151 | macAddress = ""; | 151 | macAddress = ""; |
152 | ip = "0.0.0.0"; | 152 | ip = "0.0.0.0"; |
153 | subnetMask = "0.0.0.0"; | 153 | subnetMask = "0.0.0.0"; |
154 | broadcast = ""; | 154 | broadcast = ""; |
155 | 155 | ||
156 | QTextStream stream( &file ); | 156 | QTextStream stream( &file ); |
157 | QString line; | 157 | QString line; |
158 | while ( !stream.eof() ) { | 158 | while ( !stream.eof() ) { |
159 | line = stream.readLine(); | 159 | line = stream.readLine(); |
160 | if(line.contains("HWaddr")){ | 160 | if(line.contains("HWaddr")){ |
161 | int mac = line.find("HWaddr"); | 161 | int mac = line.find("HWaddr"); |
162 | macAddress = line.mid(mac+7, line.length()); | 162 | macAddress = line.mid(mac+7, line.length()); |
163 | } | 163 | } |
164 | if(line.contains("inet addr")){ | 164 | if(line.contains("inet addr")){ |
165 | int ipl = line.find("inet addr"); | 165 | int ipl = line.find("inet addr"); |
166 | int space = line.find(" ", ipl+10); | 166 | int space = line.find(" ", ipl+10); |
167 | ip = line.mid(ipl+10, space-ipl-10); | 167 | ip = line.mid(ipl+10, space-ipl-10); |
168 | } | 168 | } |
169 | if(line.contains("Mask")){ | 169 | if(line.contains("Mask")){ |
170 | int mask = line.find("Mask"); | 170 | int mask = line.find("Mask"); |
171 | subnetMask = line.mid(mask+5, line.length()); | 171 | subnetMask = line.mid(mask+5, line.length()); |
172 | } | 172 | } |
173 | if(line.contains("Bcast")){ | 173 | if(line.contains("Bcast")){ |
174 | int mask = line.find("Bcast"); | 174 | int mask = line.find("Bcast"); |
175 | int space = line.find(" ", mask+6); | 175 | int space = line.find(" ", mask+6); |
176 | broadcast = line.mid(mask+6, space-mask-6); | 176 | broadcast = line.mid(mask+6, space-mask-6); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | file.close(); | 179 | file.close(); |
180 | QFile::remove(fileName); | 180 | QFile::remove(fileName); |
181 | 181 | ||
182 | // DHCP TESTING | 182 | // DHCP TESTING |
183 | // reset DHCP info | 183 | // reset DHCP info |
184 | dhcpServerIp = ""; | 184 | dhcpServerIp = ""; |
185 | leaseObtained = ""; | 185 | leaseObtained = ""; |
186 | leaseExpires = ""; | 186 | leaseExpires = ""; |
187 | dhcp = false; | 187 | dhcp = false; |
188 | 188 | ||
189 | QString dhcpDirectory(DHCP_INFO_DIR); | 189 | QString dhcpDirectory(DHCP_INFO_DIR); |
190 | QDir d(dhcpDirectory); | 190 | QDir d(dhcpDirectory); |
191 | if(!d.exists(dhcpDirectory)) | 191 | if(!d.exists(dhcpDirectory)) |
192 | dhcpDirectory = "/var/run"; | 192 | dhcpDirectory = "/var/run"; |
193 | 193 | ||
194 | // See if we have | 194 | // See if we have |
195 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); | 195 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); |
196 | // If there is no DHCP information then exit now with no errors. | 196 | // If there is no DHCP information then exit now with no errors. |
197 | if(!QFile::exists(dhcpFile)){ | 197 | if(!QFile::exists(dhcpFile)){ |
198 | emit(updateInterface(this)); | 198 | emit(updateInterface(this)); |
199 | return true; | 199 | return true; |
200 | } | 200 | } |
201 | 201 | ||
202 | file.setName(dhcpFile); | 202 | file.setName(dhcpFile); |
203 | if (!file.open(IO_ReadOnly)){ | 203 | if (!file.open(IO_ReadOnly)){ |
204 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 204 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
205 | return false; | 205 | return false; |
206 | } | 206 | } |
207 | 207 | ||
208 | // leaseTime and renewalTime and used if pid and deamon exe can be accessed. | 208 | // leaseTime and renewalTime and used if pid and deamon exe can be accessed. |
209 | int leaseTime = 0; | 209 | int leaseTime = 0; |
210 | int renewalTime = 0; | 210 | int renewalTime = 0; |
211 | 211 | ||
212 | stream.setDevice( &file ); | 212 | stream.setDevice( &file ); |
213 | while ( !stream.eof() ) { | 213 | while ( !stream.eof() ) { |
214 | line = stream.readLine(); | 214 | line = stream.readLine(); |
215 | if(line.contains("DHCPSIADDR=")) | 215 | if(line.contains("DHCPSIADDR=")) |
216 | dhcpServerIp = line.mid(11, line.length()); | 216 | dhcpServerIp = line.mid(11, line.length()); |
217 | if(line.contains("LEASETIME=")) | 217 | if(line.contains("LEASETIME=")) |
218 | leaseTime = line.mid(10, line.length()).toInt(); | 218 | leaseTime = line.mid(10, line.length()).toInt(); |
219 | if(line.contains("RENEWALTIME=")) | 219 | if(line.contains("RENEWALTIME=")) |
220 | renewalTime = line.mid(12, line.length()).toInt(); | 220 | renewalTime = line.mid(12, line.length()).toInt(); |
221 | } | 221 | } |
222 | file.close(); | 222 | file.close(); |
223 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); | 223 | //qDebug(QString("Interface: leaseTime: %1").arg(leaseTime).latin1()); |
224 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); | 224 | //qDebug(QString("Interface: renewalTime: %1").arg(renewalTime).latin1()); |
225 | 225 | ||
226 | // Get the pid of the deamond | 226 | // Get the pid of the deamond |
227 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); | 227 | dhcpFile = (QString(dhcpDirectory+"/dhcpcd-%1.pid").arg(this->name())); |
228 | file.setName(dhcpFile); | 228 | file.setName(dhcpFile); |
229 | if (!file.open(IO_ReadOnly)){ | 229 | if (!file.open(IO_ReadOnly)){ |
230 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); | 230 | qDebug(QString("Interface: Can't open file: %1").arg(dhcpFile).latin1()); |
231 | return false; | 231 | return false; |
232 | } | 232 | } |
233 | 233 | ||
234 | int pid = -1; | 234 | int pid = -1; |
235 | stream.setDevice( &file ); | 235 | stream.setDevice( &file ); |
236 | while ( !stream.eof() ) { | 236 | while ( !stream.eof() ) { |
237 | line = stream.readLine(); | 237 | line = stream.readLine(); |
238 | pid = line.toInt(); | 238 | pid = line.toInt(); |
239 | } | 239 | } |
240 | file.close(); | 240 | file.close(); |
241 | 241 | ||
242 | if( pid == -1){ | 242 | if( pid == -1){ |
243 | qDebug("Interface: Could not get pid of dhcpc deamon."); | 243 | qDebug("Interface: Could not get pid of dhcpc deamon."); |
244 | return false; | 244 | return false; |
245 | } | 245 | } |
246 | 246 | ||
247 | // Get the start running time of the deamon | 247 | // Get the start running time of the deamon |
248 | fileName = (QString("/proc/%1/stat").arg(pid)); | 248 | fileName = (QString("/proc/%1/stat").arg(pid)); |
249 | file.setName(fileName); | 249 | file.setName(fileName); |
250 | stream.setDevice( &file ); | 250 | stream.setDevice( &file ); |
251 | if (!file.open(IO_ReadOnly)){ | 251 | if (!file.open(IO_ReadOnly)){ |
252 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); | 252 | qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1()); |
253 | return false; | 253 | return false; |
254 | } | 254 | } |
255 | while ( !stream.eof() ) { | 255 | while ( !stream.eof() ) { |
256 | line = stream.readLine(); | 256 | line = stream.readLine(); |
257 | } | 257 | } |
258 | file.close(); | 258 | file.close(); |
259 | long time = 0; | 259 | long time = 0; |
260 | // Grab the start time | 260 | // Grab the start time |
261 | // pid com state ppid pgrp session tty_nr tpgid flags | 261 | // pid com state ppid pgrp session tty_nr tpgid flags |
262 | sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " | 262 | sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u " |
263 | // minflt cminflt majflt cmajflt utime stime cutime cstime priority | 263 | // minflt cminflt majflt cmajflt utime stime cutime cstime priority |
264 | "%*u %*u %*u %*u %*u %*u %*d %*d %*d " | 264 | "%*u %*u %*u %*u %*u %*u %*d %*d %*d " |
265 | // nice 0 itrealvalue starttime | 265 | // nice 0 itrealvalue starttime |
266 | "%*d %*d %*d %lu", (long*) &time); | 266 | "%*d %*d %*d %lu", (long*) &time); |
267 | time = time/100; | 267 | time = time/100; |
268 | 268 | ||
269 | QDateTime datetime(QDateTime::currentDateTime()); | 269 | QDateTime datetime(QDateTime::currentDateTime()); |
270 | 270 | ||
271 | // Get the uptime of the computer. | 271 | // Get the uptime of the computer. |
272 | QFile f("/proc/uptime"); | 272 | QFile f("/proc/uptime"); |
273 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 273 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
274 | QTextStream t( &f ); // use a text stream | 274 | QTextStream t( &f ); // use a text stream |
275 | int sec = 0; | 275 | int sec = 0; |
276 | t >> sec; | 276 | t >> sec; |
277 | datetime = datetime.addSecs((-1*sec)); | 277 | datetime = datetime.addSecs((-1*sec)); |
278 | f.close(); | 278 | f.close(); |
279 | } | 279 | } |
280 | else{ | 280 | else{ |
281 | qDebug("Interface: Can't open /proc/uptime to retrive uptime."); | 281 | qDebug("Interface: Can't open /proc/uptime to retrive uptime."); |
282 | return false; | 282 | return false; |
283 | } | 283 | } |
284 | 284 | ||
285 | datetime = datetime.addSecs(time); | 285 | datetime = datetime.addSecs(time); |
286 | //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); | 286 | //qDebug(QString("Interface: %1 %2").arg(datetime.toString()).arg(pid).latin1()); |
287 | 287 | ||
288 | // Calculate the start and renew times | 288 | // Calculate the start and renew times |
289 | leaseObtained= datetime.toString(); | 289 | leaseObtained= datetime.toString(); |
290 | 290 | ||
291 | // Calculate the start and renew times | 291 | // Calculate the start and renew times |
292 | datetime = datetime.addSecs(leaseTime); | 292 | datetime = datetime.addSecs(leaseTime); |
293 | leaseExpires = datetime.toString(); | 293 | leaseExpires = datetime.toString(); |
294 | 294 | ||
295 | dhcp = true; | 295 | dhcp = true; |
296 | 296 | ||
297 | emit(updateInterface(this)); | 297 | emit(updateInterface(this)); |
298 | return true; | 298 | return true; |
299 | } | 299 | } |
300 | 300 | ||
301 | // interface.cpp | 301 | // interface.cpp |
302 | 302 | ||
diff --git a/noncore/settings/networksettings/interfaces/interface.h b/noncore/settings/networksettings/interfaces/interface.h index 7e98deb..ec82851 100644 --- a/noncore/settings/networksettings/interfaces/interface.h +++ b/noncore/settings/networksettings/interfaces/interface.h | |||
@@ -1,73 +1,73 @@ | |||
1 | #ifndef INTERFACE_H | 1 | #ifndef INTERFACE_H |
2 | #define INTERFACE_H | 2 | #define INTERFACE_H |
3 | 3 | ||
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qobject.h> | 5 | #include <qobject.h> |
6 | 6 | ||
7 | class Module; | 7 | class Module; |
8 | 8 | ||
9 | class Interface : public QObject{ | 9 | class Interface : public QObject{ |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | signals: | 12 | signals: |
13 | void updateInterface(Interface *i); | 13 | void updateInterface(Interface *i); |
14 | void updateMessage(const QString &message); | 14 | void updateMessage(const QString &message); |
15 | 15 | ||
16 | public: | 16 | public: |
17 | Interface(QObject * parent=0, const char * name= "unknown", bool status = false); | 17 | Interface(QObject * parent=0, const char * name= "unknown", bool status = false); |
18 | 18 | ||
19 | QString getInterfaceName() const { QString n(this->name()); return n; }; | 19 | QString getInterfaceName() const { QString n(this->name()); return n; }; |
20 | void setInterfaceName( const QString &n ) { this->setName(n); }; | 20 | void setInterfaceName( const QString &n ) { this->setName(n); }; |
21 | 21 | ||
22 | bool getStatus() const { return status; }; | 22 | bool getStatus() const { return status; }; |
23 | void setStatus(bool newStatus); | 23 | void setStatus(bool newStatus); |
24 | 24 | ||
25 | bool isAttached() const { return attached; }; | 25 | bool isAttached() const { return attached; }; |
26 | void setAttached(bool isAttached=false); | 26 | void setAttached(bool isAttached=false); |
27 | 27 | ||
28 | QString getHardwareName() const { return hardwareName; }; | 28 | QString getHardwareName() const { return hardwareName; }; |
29 | void setHardwareName(const QString &name="Unknown"); | 29 | void setHardwareName(const QString &name="Unknown"); |
30 | 30 | ||
31 | Module* getModuleOwner() const { return moduleOwner; }; | 31 | Module* getModuleOwner() const { return moduleOwner; }; |
32 | void setModuleOwner(Module *owner=NULL); | 32 | void setModuleOwner(Module *owner=NULL); |
33 | 33 | ||
34 | // inet information. | 34 | // inet information. |
35 | QString getMacAddress() const { return macAddress; }; | 35 | QString getMacAddress() const { return macAddress; }; |
36 | QString getIp() const { return ip; }; | 36 | QString getIp() const { return ip; }; |
37 | QString getSubnetMask() const { return subnetMask; }; | 37 | QString getSubnetMask() const { return subnetMask; }; |
38 | QString getBroadcast() const { return broadcast; }; | 38 | QString getBroadcast() const { return broadcast; }; |
39 | bool isDhcp() const { return dhcp; }; | 39 | bool isDhcp() const { return dhcp; }; |
40 | QString getDhcpServerIp() const { return dhcpServerIp; }; | 40 | QString getDhcpServerIp() const { return dhcpServerIp; }; |
41 | QString getLeaseObtained() const { return leaseObtained; }; | 41 | QString getLeaseObtained() const { return leaseObtained; }; |
42 | QString getLeaseExpires() const { return leaseExpires; }; | 42 | QString getLeaseExpires() const { return leaseExpires; }; |
43 | 43 | ||
44 | public slots: | 44 | public slots: |
45 | virtual bool refresh(); | 45 | virtual bool refresh(); |
46 | virtual void start(); | 46 | virtual void start(); |
47 | virtual void stop(); | 47 | virtual void stop(); |
48 | virtual void restart(); | 48 | virtual void restart(); |
49 | 49 | ||
50 | private: | 50 | protected: |
51 | // Interface information | 51 | // Interface information |
52 | QString hardwareName; | 52 | QString hardwareName; |
53 | Module *moduleOwner; | 53 | Module *moduleOwner; |
54 | bool status; | 54 | bool status; |
55 | bool attached; | 55 | bool attached; |
56 | 56 | ||
57 | // Network information | 57 | // Network information |
58 | bool dhcp; | 58 | bool dhcp; |
59 | QString dhcpServerIp; | 59 | QString dhcpServerIp; |
60 | QString leaseObtained; | 60 | QString leaseObtained; |
61 | QString leaseExpires; | 61 | QString leaseExpires; |
62 | 62 | ||
63 | QString macAddress; | 63 | QString macAddress; |
64 | QString ip; | 64 | QString ip; |
65 | QString broadcast; | 65 | QString broadcast; |
66 | QString subnetMask; | 66 | QString subnetMask; |
67 | 67 | ||
68 | }; | 68 | }; |
69 | 69 | ||
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | // interface.h | 72 | // interface.h |
73 | 73 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfaceadvanced.ui b/noncore/settings/networksettings/interfaces/interfaceadvanced.ui index 2e106cb..12dbb1d 100644 --- a/noncore/settings/networksettings/interfaces/interfaceadvanced.ui +++ b/noncore/settings/networksettings/interfaces/interfaceadvanced.ui | |||
@@ -1,117 +1,117 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>InterfaceAdvanced</class> | 2 | <class>InterfaceAdvanced</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>InterfaceAdvanced</cstring> | 7 | <cstring>InterfaceAdvanced</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>214</width> | 14 | <width>214</width> |
15 | <height>290</height> | 15 | <height>290</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>maximumSize</name> | 19 | <name>maximumSize</name> |
20 | <size> | 20 | <size> |
21 | <width>240</width> | 21 | <width>32767</width> |
22 | <height>32767</height> | 22 | <height>32767</height> |
23 | </size> | 23 | </size> |
24 | </property> | 24 | </property> |
25 | <property stdset="1"> | 25 | <property stdset="1"> |
26 | <name>caption</name> | 26 | <name>caption</name> |
27 | <string>Advanced Interface Information</string> | 27 | <string>Advanced Interface Information</string> |
28 | </property> | 28 | </property> |
29 | <grid> | 29 | <grid> |
30 | <property stdset="1"> | 30 | <property stdset="1"> |
31 | <name>margin</name> | 31 | <name>margin</name> |
32 | <number>11</number> | 32 | <number>11</number> |
33 | </property> | 33 | </property> |
34 | <property stdset="1"> | 34 | <property stdset="1"> |
35 | <name>spacing</name> | 35 | <name>spacing</name> |
36 | <number>6</number> | 36 | <number>6</number> |
37 | </property> | 37 | </property> |
38 | <widget row="0" column="1" > | 38 | <widget row="0" column="1" > |
39 | <class>QLabel</class> | 39 | <class>QLabel</class> |
40 | <property stdset="1"> | 40 | <property stdset="1"> |
41 | <name>name</name> | 41 | <name>name</name> |
42 | <cstring>interfaceName</cstring> | 42 | <cstring>interfaceName</cstring> |
43 | </property> | 43 | </property> |
44 | <property stdset="1"> | 44 | <property stdset="1"> |
45 | <name>frameShape</name> | 45 | <name>frameShape</name> |
46 | <enum>Panel</enum> | 46 | <enum>Panel</enum> |
47 | </property> | 47 | </property> |
48 | <property stdset="1"> | 48 | <property stdset="1"> |
49 | <name>frameShadow</name> | 49 | <name>frameShadow</name> |
50 | <enum>Sunken</enum> | 50 | <enum>Sunken</enum> |
51 | </property> | 51 | </property> |
52 | <property stdset="1"> | 52 | <property stdset="1"> |
53 | <name>text</name> | 53 | <name>text</name> |
54 | <string>eth0</string> | 54 | <string>eth0</string> |
55 | </property> | 55 | </property> |
56 | </widget> | 56 | </widget> |
57 | <widget row="1" column="0" > | 57 | <widget row="1" column="0" > |
58 | <class>QLabel</class> | 58 | <class>QLabel</class> |
59 | <property stdset="1"> | 59 | <property stdset="1"> |
60 | <name>name</name> | 60 | <name>name</name> |
61 | <cstring>TextLabel3</cstring> | 61 | <cstring>TextLabel3</cstring> |
62 | </property> | 62 | </property> |
63 | <property stdset="1"> | 63 | <property stdset="1"> |
64 | <name>text</name> | 64 | <name>text</name> |
65 | <string>IP Address</string> | 65 | <string>IP Address</string> |
66 | </property> | 66 | </property> |
67 | </widget> | 67 | </widget> |
68 | <widget row="0" column="0" > | 68 | <widget row="0" column="0" > |
69 | <class>QLabel</class> | 69 | <class>QLabel</class> |
70 | <property stdset="1"> | 70 | <property stdset="1"> |
71 | <name>name</name> | 71 | <name>name</name> |
72 | <cstring>TextLabel7</cstring> | 72 | <cstring>TextLabel7</cstring> |
73 | </property> | 73 | </property> |
74 | <property stdset="1"> | 74 | <property stdset="1"> |
75 | <name>text</name> | 75 | <name>text</name> |
76 | <string>Interface</string> | 76 | <string>Interface</string> |
77 | </property> | 77 | </property> |
78 | </widget> | 78 | </widget> |
79 | <widget row="2" column="0" > | 79 | <widget row="2" column="0" > |
80 | <class>QLabel</class> | 80 | <class>QLabel</class> |
81 | <property stdset="1"> | 81 | <property stdset="1"> |
82 | <name>name</name> | 82 | <name>name</name> |
83 | <cstring>TextLabel4</cstring> | 83 | <cstring>TextLabel4</cstring> |
84 | </property> | 84 | </property> |
85 | <property stdset="1"> | 85 | <property stdset="1"> |
86 | <name>enabled</name> | 86 | <name>enabled</name> |
87 | <bool>true</bool> | 87 | <bool>true</bool> |
88 | </property> | 88 | </property> |
89 | <property stdset="1"> | 89 | <property stdset="1"> |
90 | <name>text</name> | 90 | <name>text</name> |
91 | <string>Subnet Mask</string> | 91 | <string>Subnet Mask</string> |
92 | </property> | 92 | </property> |
93 | </widget> | 93 | </widget> |
94 | <widget row="1" column="1" > | 94 | <widget row="1" column="1" > |
95 | <class>QLabel</class> | 95 | <class>QLabel</class> |
96 | <property stdset="1"> | 96 | <property stdset="1"> |
97 | <name>name</name> | 97 | <name>name</name> |
98 | <cstring>ipAddressLabel</cstring> | 98 | <cstring>ipAddressLabel</cstring> |
99 | </property> | 99 | </property> |
100 | <property stdset="1"> | 100 | <property stdset="1"> |
101 | <name>frameShape</name> | 101 | <name>frameShape</name> |
102 | <enum>Panel</enum> | 102 | <enum>Panel</enum> |
103 | </property> | 103 | </property> |
104 | <property stdset="1"> | 104 | <property stdset="1"> |
105 | <name>frameShadow</name> | 105 | <name>frameShadow</name> |
106 | <enum>Sunken</enum> | 106 | <enum>Sunken</enum> |
107 | </property> | 107 | </property> |
108 | <property stdset="1"> | 108 | <property stdset="1"> |
109 | <name>text</name> | 109 | <name>text</name> |
110 | <string>0.0.0.0</string> | 110 | <string>0.0.0.0</string> |
111 | </property> | 111 | </property> |
112 | </widget> | 112 | </widget> |
113 | <widget row="2" column="1" > | 113 | <widget row="2" column="1" > |
114 | <class>QLabel</class> | 114 | <class>QLabel</class> |
115 | <property stdset="1"> | 115 | <property stdset="1"> |
116 | <name>name</name> | 116 | <name>name</name> |
117 | <cstring>subnetMaskLabel</cstring> | 117 | <cstring>subnetMaskLabel</cstring> |
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformation.ui b/noncore/settings/networksettings/interfaces/interfaceinformation.ui index 763ad90..207200e 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformation.ui +++ b/noncore/settings/networksettings/interfaces/interfaceinformation.ui | |||
@@ -1,321 +1,338 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>InterfaceInformation</class> | 2 | <class>InterfaceInformation</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>InterfaceInformation</cstring> | 7 | <cstring>InterfaceInformation</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>219</width> | 14 | <width>219</width> |
15 | <height>255</height> | 15 | <height>323</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Interface Information</string> | 20 | <string>Interface Information</string> |
21 | </property> | 21 | </property> |
22 | <grid> | 22 | <property> |
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <vbox> | ||
23 | <property stdset="1"> | 29 | <property stdset="1"> |
24 | <name>margin</name> | 30 | <name>margin</name> |
25 | <number>11</number> | 31 | <number>4</number> |
26 | </property> | 32 | </property> |
27 | <property stdset="1"> | 33 | <property stdset="1"> |
28 | <name>spacing</name> | 34 | <name>spacing</name> |
29 | <number>6</number> | 35 | <number>3</number> |
30 | </property> | 36 | </property> |
31 | <widget row="4" column="0" rowspan="1" colspan="2" > | 37 | <widget> |
32 | <class>QLayoutWidget</class> | ||
33 | <property stdset="1"> | ||
34 | <name>name</name> | ||
35 | <cstring>Layout1</cstring> | ||
36 | </property> | ||
37 | <grid> | ||
38 | <property stdset="1"> | ||
39 | <name>margin</name> | ||
40 | <number>0</number> | ||
41 | </property> | ||
42 | <property stdset="1"> | ||
43 | <name>spacing</name> | ||
44 | <number>6</number> | ||
45 | </property> | ||
46 | <widget row="1" column="0" > | ||
47 | <class>QPushButton</class> | ||
48 | <property stdset="1"> | ||
49 | <name>name</name> | ||
50 | <cstring>refreshButton</cstring> | ||
51 | </property> | ||
52 | <property stdset="1"> | ||
53 | <name>text</name> | ||
54 | <string>&Refresh</string> | ||
55 | </property> | ||
56 | </widget> | ||
57 | <widget row="0" column="1" > | ||
58 | <class>QPushButton</class> | ||
59 | <property stdset="1"> | ||
60 | <name>name</name> | ||
61 | <cstring>stopButton</cstring> | ||
62 | </property> | ||
63 | <property stdset="1"> | ||
64 | <name>text</name> | ||
65 | <string>S&top</string> | ||
66 | </property> | ||
67 | </widget> | ||
68 | <widget row="1" column="1" > | ||
69 | <class>QPushButton</class> | ||
70 | <property stdset="1"> | ||
71 | <name>name</name> | ||
72 | <cstring>restartButton</cstring> | ||
73 | </property> | ||
74 | <property stdset="1"> | ||
75 | <name>text</name> | ||
76 | <string>R&estart</string> | ||
77 | </property> | ||
78 | </widget> | ||
79 | <widget row="0" column="0" > | ||
80 | <class>QPushButton</class> | ||
81 | <property stdset="1"> | ||
82 | <name>name</name> | ||
83 | <cstring>startButton</cstring> | ||
84 | </property> | ||
85 | <property stdset="1"> | ||
86 | <name>text</name> | ||
87 | <string>&Start</string> | ||
88 | </property> | ||
89 | </widget> | ||
90 | </grid> | ||
91 | </widget> | ||
92 | <widget row="0" column="0" > | ||
93 | <class>Line</class> | ||
94 | <property stdset="1"> | ||
95 | <name>name</name> | ||
96 | <cstring>Line1</cstring> | ||
97 | </property> | ||
98 | <property stdset="1"> | ||
99 | <name>orientation</name> | ||
100 | <enum>Horizontal</enum> | ||
101 | </property> | ||
102 | </widget> | ||
103 | <widget row="0" column="0" > | ||
104 | <class>QLabel</class> | 38 | <class>QLabel</class> |
105 | <property stdset="1"> | 39 | <property stdset="1"> |
106 | <name>name</name> | 40 | <name>name</name> |
107 | <cstring>TextLabel22</cstring> | 41 | <cstring>TextLabel22</cstring> |
108 | </property> | 42 | </property> |
109 | <property stdset="1"> | 43 | <property stdset="1"> |
110 | <name>text</name> | 44 | <name>text</name> |
111 | <string>IP Address</string> | 45 | <string>IP Address</string> |
112 | </property> | 46 | </property> |
113 | </widget> | 47 | </widget> |
114 | <widget row="1" column="0" > | 48 | <widget> |
115 | <class>QLabel</class> | 49 | <class>QLabel</class> |
116 | <property stdset="1"> | 50 | <property stdset="1"> |
117 | <name>name</name> | 51 | <name>name</name> |
118 | <cstring>TextLabel23</cstring> | 52 | <cstring>ipAddressLabel</cstring> |
119 | </property> | 53 | </property> |
120 | <property stdset="1"> | 54 | <property stdset="1"> |
121 | <name>text</name> | 55 | <name>frameShape</name> |
122 | <string>Subnet Mask</string> | 56 | <enum>Panel</enum> |
123 | </property> | 57 | </property> |
124 | </widget> | ||
125 | <widget row="2" column="0" > | ||
126 | <class>QLabel</class> | ||
127 | <property stdset="1"> | 58 | <property stdset="1"> |
128 | <name>name</name> | 59 | <name>frameShadow</name> |
129 | <cstring>TextLabel21</cstring> | 60 | <enum>Sunken</enum> |
130 | </property> | 61 | </property> |
131 | <property stdset="1"> | 62 | <property stdset="1"> |
132 | <name>text</name> | 63 | <name>text</name> |
133 | <string>MAC Address</string> | 64 | <string>0.0.0.0</string> |
134 | </property> | 65 | </property> |
135 | </widget> | 66 | </widget> |
136 | <widget row="3" column="0" > | 67 | <widget> |
137 | <class>QLabel</class> | 68 | <class>Line</class> |
138 | <property stdset="1"> | 69 | <property stdset="1"> |
139 | <name>name</name> | 70 | <name>name</name> |
140 | <cstring>TextLabel24</cstring> | 71 | <cstring>Line1</cstring> |
141 | </property> | 72 | </property> |
142 | <property stdset="1"> | 73 | <property stdset="1"> |
143 | <name>frameShape</name> | 74 | <name>orientation</name> |
144 | <enum>MShape</enum> | 75 | <enum>Horizontal</enum> |
145 | </property> | 76 | </property> |
77 | </widget> | ||
78 | <widget> | ||
79 | <class>QLabel</class> | ||
146 | <property stdset="1"> | 80 | <property stdset="1"> |
147 | <name>frameShadow</name> | 81 | <name>name</name> |
148 | <enum>MShadow</enum> | 82 | <cstring>TextLabel23</cstring> |
149 | </property> | 83 | </property> |
150 | <property stdset="1"> | 84 | <property stdset="1"> |
151 | <name>text</name> | 85 | <name>text</name> |
152 | <string>Broadcast</string> | 86 | <string>Subnet Mask</string> |
153 | </property> | 87 | </property> |
154 | </widget> | 88 | </widget> |
155 | <widget row="1" column="1" > | 89 | <widget> |
156 | <class>QLabel</class> | 90 | <class>QLabel</class> |
157 | <property stdset="1"> | 91 | <property stdset="1"> |
158 | <name>name</name> | 92 | <name>name</name> |
159 | <cstring>subnetMaskLabel</cstring> | 93 | <cstring>subnetMaskLabel</cstring> |
160 | </property> | 94 | </property> |
161 | <property stdset="1"> | 95 | <property stdset="1"> |
162 | <name>frameShape</name> | 96 | <name>frameShape</name> |
163 | <enum>Panel</enum> | 97 | <enum>Panel</enum> |
164 | </property> | 98 | </property> |
165 | <property stdset="1"> | 99 | <property stdset="1"> |
166 | <name>frameShadow</name> | 100 | <name>frameShadow</name> |
167 | <enum>Sunken</enum> | 101 | <enum>Sunken</enum> |
168 | </property> | 102 | </property> |
169 | <property stdset="1"> | 103 | <property stdset="1"> |
170 | <name>text</name> | 104 | <name>text</name> |
171 | <string>0.0.0.0</string> | 105 | <string>0.0.0.0</string> |
172 | </property> | 106 | </property> |
173 | </widget> | 107 | </widget> |
174 | <widget row="2" column="1" > | 108 | <widget> |
175 | <class>QLabel</class> | 109 | <class>QLabel</class> |
176 | <property stdset="1"> | 110 | <property stdset="1"> |
177 | <name>name</name> | 111 | <name>name</name> |
178 | <cstring>macAddressLabel</cstring> | 112 | <cstring>macAddressLabel</cstring> |
179 | </property> | 113 | </property> |
180 | <property stdset="1"> | 114 | <property stdset="1"> |
181 | <name>frameShape</name> | 115 | <name>frameShape</name> |
182 | <enum>Panel</enum> | 116 | <enum>Panel</enum> |
183 | </property> | 117 | </property> |
184 | <property stdset="1"> | 118 | <property stdset="1"> |
185 | <name>frameShadow</name> | 119 | <name>frameShadow</name> |
186 | <enum>Sunken</enum> | 120 | <enum>Sunken</enum> |
187 | </property> | 121 | </property> |
188 | <property stdset="1"> | 122 | <property stdset="1"> |
189 | <name>text</name> | 123 | <name>text</name> |
190 | <string>00:00:00:00:00:00</string> | 124 | <string>00:00:00:00:00:00</string> |
191 | </property> | 125 | </property> |
192 | </widget> | 126 | </widget> |
193 | <widget row="3" column="1" > | 127 | <widget> |
128 | <class>QLabel</class> | ||
129 | <property stdset="1"> | ||
130 | <name>name</name> | ||
131 | <cstring>TextLabel21</cstring> | ||
132 | </property> | ||
133 | <property stdset="1"> | ||
134 | <name>text</name> | ||
135 | <string>MAC Address</string> | ||
136 | </property> | ||
137 | </widget> | ||
138 | <widget> | ||
194 | <class>QLabel</class> | 139 | <class>QLabel</class> |
195 | <property stdset="1"> | 140 | <property stdset="1"> |
196 | <name>name</name> | 141 | <name>name</name> |
197 | <cstring>broadcastLabel</cstring> | 142 | <cstring>broadcastLabel</cstring> |
198 | </property> | 143 | </property> |
199 | <property stdset="1"> | 144 | <property stdset="1"> |
200 | <name>frameShape</name> | 145 | <name>frameShape</name> |
201 | <enum>Panel</enum> | 146 | <enum>Panel</enum> |
202 | </property> | 147 | </property> |
203 | <property stdset="1"> | 148 | <property stdset="1"> |
204 | <name>frameShadow</name> | 149 | <name>frameShadow</name> |
205 | <enum>Sunken</enum> | 150 | <enum>Sunken</enum> |
206 | </property> | 151 | </property> |
207 | <property stdset="1"> | 152 | <property stdset="1"> |
208 | <name>text</name> | 153 | <name>text</name> |
209 | <string></string> | 154 | <string></string> |
210 | </property> | 155 | </property> |
211 | </widget> | 156 | </widget> |
212 | <widget row="0" column="1" > | 157 | <widget> |
213 | <class>QLabel</class> | 158 | <class>QLabel</class> |
214 | <property stdset="1"> | 159 | <property stdset="1"> |
215 | <name>name</name> | 160 | <name>name</name> |
216 | <cstring>ipAddressLabel</cstring> | 161 | <cstring>TextLabel24</cstring> |
217 | </property> | 162 | </property> |
218 | <property stdset="1"> | 163 | <property stdset="1"> |
219 | <name>frameShape</name> | 164 | <name>frameShape</name> |
220 | <enum>Panel</enum> | 165 | <enum>MShape</enum> |
221 | </property> | 166 | </property> |
222 | <property stdset="1"> | 167 | <property stdset="1"> |
223 | <name>frameShadow</name> | 168 | <name>frameShadow</name> |
224 | <enum>Sunken</enum> | 169 | <enum>MShadow</enum> |
225 | </property> | 170 | </property> |
226 | <property stdset="1"> | 171 | <property stdset="1"> |
227 | <name>text</name> | 172 | <name>text</name> |
228 | <string>0.0.0.0</string> | 173 | <string>Broadcast</string> |
229 | </property> | 174 | </property> |
230 | </widget> | 175 | </widget> |
231 | <spacer row="7" column="1" > | 176 | <widget> |
232 | <property> | 177 | <class>QLayoutWidget</class> |
178 | <property stdset="1"> | ||
233 | <name>name</name> | 179 | <name>name</name> |
234 | <cstring>Spacer18</cstring> | 180 | <cstring>Layout1</cstring> |
235 | </property> | 181 | </property> |
182 | <grid> | ||
183 | <property stdset="1"> | ||
184 | <name>margin</name> | ||
185 | <number>0</number> | ||
186 | </property> | ||
187 | <property stdset="1"> | ||
188 | <name>spacing</name> | ||
189 | <number>6</number> | ||
190 | </property> | ||
191 | <widget row="1" column="0" > | ||
192 | <class>QPushButton</class> | ||
193 | <property stdset="1"> | ||
194 | <name>name</name> | ||
195 | <cstring>refreshButton</cstring> | ||
196 | </property> | ||
197 | <property stdset="1"> | ||
198 | <name>text</name> | ||
199 | <string>&Refresh</string> | ||
200 | </property> | ||
201 | </widget> | ||
202 | <widget row="0" column="1" > | ||
203 | <class>QPushButton</class> | ||
204 | <property stdset="1"> | ||
205 | <name>name</name> | ||
206 | <cstring>stopButton</cstring> | ||
207 | </property> | ||
208 | <property stdset="1"> | ||
209 | <name>text</name> | ||
210 | <string>S&top</string> | ||
211 | </property> | ||
212 | </widget> | ||
213 | <widget row="1" column="1" > | ||
214 | <class>QPushButton</class> | ||
215 | <property stdset="1"> | ||
216 | <name>name</name> | ||
217 | <cstring>restartButton</cstring> | ||
218 | </property> | ||
219 | <property stdset="1"> | ||
220 | <name>text</name> | ||
221 | <string>R&estart</string> | ||
222 | </property> | ||
223 | </widget> | ||
224 | <widget row="0" column="0" > | ||
225 | <class>QPushButton</class> | ||
226 | <property stdset="1"> | ||
227 | <name>name</name> | ||
228 | <cstring>startButton</cstring> | ||
229 | </property> | ||
230 | <property stdset="1"> | ||
231 | <name>text</name> | ||
232 | <string>&Start</string> | ||
233 | </property> | ||
234 | </widget> | ||
235 | </grid> | ||
236 | </widget> | ||
237 | <widget> | ||
238 | <class>Line</class> | ||
236 | <property stdset="1"> | 239 | <property stdset="1"> |
237 | <name>orientation</name> | 240 | <name>name</name> |
238 | <enum>Vertical</enum> | 241 | <cstring>Line5</cstring> |
239 | </property> | 242 | </property> |
240 | <property stdset="1"> | 243 | <property stdset="1"> |
241 | <name>sizeType</name> | 244 | <name>orientation</name> |
242 | <enum>Expanding</enum> | 245 | <enum>Horizontal</enum> |
243 | </property> | ||
244 | <property> | ||
245 | <name>sizeHint</name> | ||
246 | <size> | ||
247 | <width>20</width> | ||
248 | <height>20</height> | ||
249 | </size> | ||
250 | </property> | 246 | </property> |
251 | </spacer> | 247 | </widget> |
252 | <widget row="6" column="0" rowspan="1" colspan="2" > | 248 | <widget> |
253 | <class>QLayoutWidget</class> | 249 | <class>QLayoutWidget</class> |
254 | <property stdset="1"> | 250 | <property stdset="1"> |
255 | <name>name</name> | 251 | <name>name</name> |
256 | <cstring>Layout2</cstring> | 252 | <cstring>Layout2</cstring> |
257 | </property> | 253 | </property> |
258 | <hbox> | 254 | <hbox> |
259 | <property stdset="1"> | 255 | <property stdset="1"> |
260 | <name>margin</name> | 256 | <name>margin</name> |
261 | <number>0</number> | 257 | <number>0</number> |
262 | </property> | 258 | </property> |
263 | <property stdset="1"> | 259 | <property stdset="1"> |
264 | <name>spacing</name> | 260 | <name>spacing</name> |
265 | <number>6</number> | 261 | <number>6</number> |
266 | </property> | 262 | </property> |
267 | <spacer> | 263 | <spacer> |
268 | <property> | 264 | <property> |
269 | <name>name</name> | 265 | <name>name</name> |
270 | <cstring>Spacer10</cstring> | 266 | <cstring>Spacer10</cstring> |
271 | </property> | 267 | </property> |
272 | <property stdset="1"> | 268 | <property stdset="1"> |
273 | <name>orientation</name> | 269 | <name>orientation</name> |
274 | <enum>Horizontal</enum> | 270 | <enum>Horizontal</enum> |
275 | </property> | 271 | </property> |
276 | <property stdset="1"> | 272 | <property stdset="1"> |
277 | <name>sizeType</name> | 273 | <name>sizeType</name> |
278 | <enum>Expanding</enum> | 274 | <enum>Expanding</enum> |
279 | </property> | 275 | </property> |
280 | <property> | 276 | <property> |
281 | <name>sizeHint</name> | 277 | <name>sizeHint</name> |
282 | <size> | 278 | <size> |
283 | <width>20</width> | 279 | <width>20</width> |
284 | <height>20</height> | 280 | <height>20</height> |
285 | </size> | 281 | </size> |
286 | </property> | 282 | </property> |
287 | </spacer> | 283 | </spacer> |
288 | <widget> | 284 | <widget> |
289 | <class>QPushButton</class> | 285 | <class>QPushButton</class> |
290 | <property stdset="1"> | 286 | <property stdset="1"> |
291 | <name>name</name> | 287 | <name>name</name> |
292 | <cstring>advancedButton</cstring> | 288 | <cstring>advancedButton</cstring> |
293 | </property> | 289 | </property> |
294 | <property stdset="1"> | 290 | <property stdset="1"> |
295 | <name>text</name> | 291 | <name>text</name> |
296 | <string>&View Advanced Information</string> | 292 | <string>&View Advanced Information</string> |
297 | </property> | 293 | </property> |
298 | </widget> | 294 | </widget> |
299 | </hbox> | 295 | </hbox> |
300 | </widget> | 296 | </widget> |
301 | <widget row="5" column="0" rowspan="1" colspan="2" > | 297 | <spacer> |
302 | <class>Line</class> | 298 | <property> |
303 | <property stdset="1"> | ||
304 | <name>name</name> | 299 | <name>name</name> |
305 | <cstring>Line5</cstring> | 300 | <cstring>Spacer18</cstring> |
306 | </property> | 301 | </property> |
307 | <property stdset="1"> | 302 | <property stdset="1"> |
308 | <name>orientation</name> | 303 | <name>orientation</name> |
309 | <enum>Horizontal</enum> | 304 | <enum>Vertical</enum> |
305 | </property> | ||
306 | <property stdset="1"> | ||
307 | <name>sizeType</name> | ||
308 | <enum>Expanding</enum> | ||
309 | </property> | ||
310 | <property> | ||
311 | <name>sizeHint</name> | ||
312 | <size> | ||
313 | <width>20</width> | ||
314 | <height>20</height> | ||
315 | </size> | ||
316 | </property> | ||
317 | </spacer> | ||
318 | <widget> | ||
319 | <class>QCheckBox</class> | ||
320 | <property stdset="1"> | ||
321 | <name>name</name> | ||
322 | <cstring>CheckBoxSilent</cstring> | ||
323 | </property> | ||
324 | <property stdset="1"> | ||
325 | <name>text</name> | ||
326 | <string>be &silent</string> | ||
310 | </property> | 327 | </property> |
311 | </widget> | 328 | </widget> |
312 | </grid> | 329 | </vbox> |
313 | </widget> | 330 | </widget> |
314 | <tabstops> | 331 | <tabstops> |
315 | <tabstop>startButton</tabstop> | 332 | <tabstop>startButton</tabstop> |
316 | <tabstop>stopButton</tabstop> | 333 | <tabstop>stopButton</tabstop> |
317 | <tabstop>refreshButton</tabstop> | 334 | <tabstop>refreshButton</tabstop> |
318 | <tabstop>restartButton</tabstop> | 335 | <tabstop>restartButton</tabstop> |
319 | <tabstop>advancedButton</tabstop> | 336 | <tabstop>advancedButton</tabstop> |
320 | </tabstops> | 337 | </tabstops> |
321 | </UI> | 338 | </UI> |
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp index e00dcce..37c3a91 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp | |||
@@ -1,79 +1,93 @@ | |||
1 | #include "interfaceinformationimp.h" | 1 | #include "interfaceinformationimp.h" |
2 | #include "interfaceadvanced.h" | 2 | #include "interfaceadvanced.h" |
3 | 3 | ||
4 | #include <qcheckbox.h> | ||
4 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
5 | #include <qlabel.h> | 6 | #include <qlabel.h> |
6 | #include <qgroupbox.h> | 7 | #include <qgroupbox.h> |
7 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
8 | 9 | ||
9 | #ifdef QWS | 10 | #include <qpe/config.h> |
11 | |||
12 | #ifdef QWS | ||
10 | #else | 13 | #else |
11 | #define showMaximized show | 14 | #define showMaximized show |
12 | #endif | 15 | #endif |
13 | 16 | ||
14 | /** | 17 | /** |
15 | * Constructor for the InterfaceInformationImp class. This class pretty much | 18 | * Constructor for the InterfaceInformationImp class. This class pretty much |
16 | * just display's information about the interface that is passed to it. | 19 | * just display's information about the interface that is passed to it. |
17 | */ | 20 | */ |
18 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){ | 21 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){ |
19 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 22 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
20 | connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); | 23 | connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); |
21 | updateInterface(interface); | 24 | updateInterface(interface); |
22 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); | 25 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); |
23 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); | 26 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); |
24 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); | 27 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); |
25 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); | 28 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); |
26 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); | 29 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); |
30 | Config cfg("networksettings", Config::User); | ||
31 | cfg.setGroup("interface"); | ||
32 | CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) ); | ||
33 | } | ||
34 | |||
35 | InterfaceInformationImp::~InterfaceInformationImp() | ||
36 | { | ||
37 | Config cfg("networksettings", Config::User); | ||
38 | cfg.setGroup("interface"); | ||
39 | cfg.writeEntry("silent", CheckBoxSilent->isChecked() ); | ||
27 | } | 40 | } |
28 | 41 | ||
29 | /** | 42 | /** |
30 | * Update the interface information and buttons. | 43 | * Update the interface information and buttons. |
31 | * @param Intarface *i the interface to update (should be the one we already | 44 | * @param Intarface *i the interface to update (should be the one we already |
32 | * know about). | 45 | * know about). |
33 | */ | 46 | */ |
34 | void InterfaceInformationImp::updateInterface(Interface *){ | 47 | void InterfaceInformationImp::updateInterface(Interface *){ |
35 | if(interface->getStatus()){ | 48 | if(interface->getStatus()){ |
36 | startButton->setEnabled(false); | 49 | startButton->setEnabled(false); |
37 | stopButton->setEnabled(true); | 50 | stopButton->setEnabled(true); |
38 | restartButton->setEnabled(true); | 51 | restartButton->setEnabled(true); |
39 | } | 52 | } |
40 | else{ | 53 | else{ |
41 | startButton->setEnabled(true); | 54 | startButton->setEnabled(true); |
42 | stopButton->setEnabled(false); | 55 | stopButton->setEnabled(false); |
43 | restartButton->setEnabled(false); | 56 | restartButton->setEnabled(false); |
44 | } | 57 | } |
45 | macAddressLabel->setText(interface->getMacAddress()); | 58 | macAddressLabel->setText(interface->getMacAddress()); |
46 | ipAddressLabel->setText(interface->getIp()); | 59 | ipAddressLabel->setText(interface->getIp()); |
47 | subnetMaskLabel->setText(interface->getSubnetMask()); | 60 | subnetMaskLabel->setText(interface->getSubnetMask()); |
48 | broadcastLabel->setText(interface->getBroadcast()); | 61 | broadcastLabel->setText(interface->getBroadcast()); |
49 | } | 62 | } |
50 | 63 | ||
51 | /** | 64 | /** |
52 | * Create the advanced widget. Fill it with the current interface's information. | 65 | * Create the advanced widget. Fill it with the current interface's information. |
53 | * Display it. | 66 | * Display it. |
54 | */ | 67 | */ |
55 | void InterfaceInformationImp::advanced(){ | 68 | void InterfaceInformationImp::advanced(){ |
56 | InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); | 69 | InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); |
57 | a->interfaceName->setText(interface->getInterfaceName()); | 70 | a->interfaceName->setText(interface->getInterfaceName()); |
58 | a->macAddressLabel->setText(interface->getMacAddress()); | 71 | a->macAddressLabel->setText(interface->getMacAddress()); |
59 | a->ipAddressLabel->setText(interface->getIp()); | 72 | a->ipAddressLabel->setText(interface->getIp()); |
60 | a->subnetMaskLabel->setText(interface->getSubnetMask()); | 73 | a->subnetMaskLabel->setText(interface->getSubnetMask()); |
61 | a->broadcastLabel->setText(interface->getBroadcast()); | 74 | a->broadcastLabel->setText(interface->getBroadcast()); |
62 | a->dhcpServerLabel->setText(interface->getDhcpServerIp()); | 75 | a->dhcpServerLabel->setText(interface->getDhcpServerIp()); |
63 | a->leaseObtainedLabel->setText(interface->getLeaseObtained()); | 76 | a->leaseObtainedLabel->setText(interface->getLeaseObtained()); |
64 | a->leaseExpiresLabel->setText(interface->getLeaseExpires()); | 77 | a->leaseExpiresLabel->setText(interface->getLeaseExpires()); |
65 | a->dhcpInformation->setEnabled(interface->isDhcp()); | 78 | a->dhcpInformation->setEnabled(interface->isDhcp()); |
66 | a->showMaximized(); | 79 | a->showMaximized(); |
67 | } | 80 | } |
68 | 81 | ||
69 | /** | 82 | /** |
70 | * Messages from the interface if start/stop went as planned. | 83 | * Messages from the interface if start/stop went as planned. |
71 | * Purly for user feedback. | 84 | * Purly for user feedback. |
72 | * @param message the message to display. | 85 | * @param message the message to display. |
73 | */ | 86 | */ |
74 | void InterfaceInformationImp::showMessage(const QString &message){ | 87 | void InterfaceInformationImp::showMessage(const QString &message){ |
88 | if (CheckBoxSilent->isChecked()) return; | ||
75 | QMessageBox::information(this, "Message", message, QMessageBox::Ok); | 89 | QMessageBox::information(this, "Message", message, QMessageBox::Ok); |
76 | } | 90 | } |
77 | 91 | ||
78 | // infoimp.cpp | 92 | // infoimp.cpp |
79 | 93 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h index 65cdfe0..9c93d1d 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h +++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h | |||
@@ -1,28 +1,28 @@ | |||
1 | #ifndef INTERFACEINFORMATIONIMP_H | 1 | #ifndef INTERFACEINFORMATIONIMP_H |
2 | #define INTERFACEINFORMATIONIMP_H | 2 | #define INTERFACEINFORMATIONIMP_H |
3 | 3 | ||
4 | #include "interfaceinformation.h" | 4 | #include "interfaceinformation.h" |
5 | #include "interface.h" | 5 | #include "interface.h" |
6 | 6 | ||
7 | class InterfaceInformationImp : public InterfaceInformation { | 7 | class InterfaceInformationImp : public InterfaceInformation { |
8 | 8 | ||
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | 10 | ||
11 | public: | 11 | public: |
12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); | 12 | InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); |
13 | ~InterfaceInformationImp(){}; | 13 | ~InterfaceInformationImp(); |
14 | 14 | ||
15 | private slots: | 15 | private slots: |
16 | void advanced(); | 16 | void advanced(); |
17 | void updateInterface(Interface *i); | 17 | void updateInterface(Interface *i); |
18 | void showMessage(const QString &message); | 18 | void showMessage(const QString &message); |
19 | 19 | ||
20 | private: | 20 | private: |
21 | Interface *interface; | 21 | Interface *interface; |
22 | 22 | ||
23 | }; | 23 | }; |
24 | 24 | ||
25 | #endif | 25 | #endif |
26 | 26 | ||
27 | // addserviceimp.h | 27 | // addserviceimp.h |
28 | 28 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index 71d0cf5..436e449 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp | |||
@@ -1,678 +1,712 @@ | |||
1 | #include "interfaces.h" | 1 | #include "interfaces.h" |
2 | 2 | ||
3 | #include <qcheckbox.h> | ||
3 | #include <qfile.h> | 4 | #include <qfile.h> |
4 | #include <qtextstream.h> | 5 | #include <qtextstream.h> |
5 | #include <qregexp.h> | 6 | #include <qregexp.h> |
6 | 7 | ||
7 | // The three stanza's | 8 | // The three stanza's |
8 | #define AUTO "auto" | 9 | #define AUTO "auto" |
9 | #define IFACE "iface" | 10 | #define IFACE "iface" |
10 | #define MAPPING "mapping" | 11 | #define MAPPING "mapping" |
11 | 12 | ||
12 | /** | 13 | /** |
13 | * Constructor. Reads in the interfaces file and then split the file up by | 14 | * Constructor. Reads in the interfaces file and then split the file up by |
14 | * the \n for interfaces variable. | 15 | * the \n for interfaces variable. |
15 | * @param useInterfacesFile if an interface file other then the default is | 16 | * @param useInterfacesFile if an interface file other then the default is |
16 | * desired to be used it should be passed in. | 17 | * desired to be used it should be passed in. |
17 | */ | 18 | */ |
18 | Interfaces::Interfaces(QString useInterfacesFile){ | 19 | Interfaces::Interfaces(QString useInterfacesFile){ |
19 | acceptedFamily.append(INTERFACES_FAMILY_INET); | 20 | acceptedFamily.append(INTERFACES_FAMILY_INET); |
20 | acceptedFamily.append(INTERFACES_FAMILY_IPX); | 21 | acceptedFamily.append(INTERFACES_FAMILY_IPX); |
21 | acceptedFamily.append(INTERFACES_FAMILY_INET6); | 22 | acceptedFamily.append(INTERFACES_FAMILY_INET6); |
22 | 23 | ||
23 | interfacesFile = useInterfacesFile; | 24 | interfacesFile = useInterfacesFile; |
24 | QFile file(interfacesFile); | 25 | QFile file(interfacesFile); |
25 | if (!file.open(IO_ReadOnly)){ | 26 | if (!file.open(IO_ReadOnly)){ |
26 | qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); | 27 | qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); |
27 | currentIface = interfaces.end(); | 28 | currentIface = interfaces.end(); |
28 | currentMapping = interfaces.end(); | 29 | currentMapping = interfaces.end(); |
29 | return; | 30 | return; |
30 | } | 31 | } |
31 | QTextStream stream( &file ); | 32 | QTextStream stream( &file ); |
32 | QString line; | 33 | QString line; |
33 | while ( !stream.eof() ) { | 34 | while ( !stream.eof() ) { |
34 | line += stream.readLine(); | 35 | line += stream.readLine(); |
35 | line += "\n"; | 36 | line += "\n"; |
36 | } | 37 | } |
37 | file.close(); | 38 | file.close(); |
38 | interfaces = QStringList::split("\n", line, true); | 39 | interfaces = QStringList::split("\n", line, true); |
39 | 40 | ||
40 | currentIface = interfaces.end(); | 41 | currentIface = interfaces.end(); |
41 | currentMapping = interfaces.end(); | 42 | currentMapping = interfaces.end(); |
42 | } | 43 | } |
43 | 44 | ||
44 | 45 | ||
45 | /** | 46 | /** |
46 | * Get a list of all interfaces in the interface file. Usefull for | 47 | * Get a list of all interfaces in the interface file. Usefull for |
47 | * hardware that is not currently connected such as an 802.11b card | 48 | * hardware that is not currently connected such as an 802.11b card |
48 | * not plugged in, but configured for when it is plugged in. | 49 | * not plugged in, but configured for when it is plugged in. |
49 | * @return Return string list of interfaces. | 50 | * @return Return string list of interfaces. |
50 | **/ | 51 | **/ |
51 | QStringList Interfaces::getInterfaceList(){ | 52 | QStringList Interfaces::getInterfaceList(){ |
52 | QStringList list; | 53 | QStringList list; |
53 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 54 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
54 | QString line = (*it).simplifyWhiteSpace(); | 55 | QString line = (*it).simplifyWhiteSpace(); |
55 | if(line.contains(IFACE) && line.at(0) != '#'){ | 56 | if(line.contains(IFACE) && line.at(0) != '#'){ |
56 | line = line.mid(QString(IFACE).length() +1, line.length()); | 57 | line = line.mid(QString(IFACE).length() +1, line.length()); |
57 | line = line.simplifyWhiteSpace(); | 58 | line = line.simplifyWhiteSpace(); |
58 | int findSpace = line.find(" "); | 59 | int findSpace = line.find(" "); |
59 | if( findSpace >= 0){ | 60 | if( findSpace >= 0){ |
60 | line = line.mid(0, findSpace); | 61 | line = line.mid(0, findSpace); |
61 | list.append(line); | 62 | list.append(line); |
62 | } | 63 | } |
63 | } | 64 | } |
64 | } | 65 | } |
65 | return list; | 66 | return list; |
66 | } | 67 | } |
67 | 68 | ||
68 | /** | 69 | /** |
69 | * Find out if interface is in an "auto" group or not. | 70 | * Find out if interface is in an "auto" group or not. |
70 | * Report any duplicates such as eth0 being in two differnt auto's | 71 | * Report any duplicates such as eth0 being in two differnt auto's |
71 | * @param interface interface to check to see if it is on or not. | 72 | * @param interface interface to check to see if it is on or not. |
72 | * @return true is interface is in auto | 73 | * @return true is interface is in auto |
73 | */ | 74 | */ |
74 | bool Interfaces::isAuto(const QString &interface) const { | 75 | bool Interfaces::isAuto(const QString &interface) const { |
75 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | 76 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); |
76 | QStringList awi = autoLines.grep(QRegExp(interface)); | 77 | QStringList awi = autoLines.grep(QRegExp(interface)); |
77 | if(awi.count() > 1) | 78 | if(awi.count() > 1) |
78 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); | 79 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); |
79 | return awi.count() > 0; | 80 | return awi.count() > 0; |
80 | } | 81 | } |
81 | 82 | ||
82 | /** | 83 | /** |
83 | * Attempt to set the auto option for interface to setAuto. | 84 | * Attempt to set the auto option for interface to setAuto. |
84 | * @param interface the interface to set | 85 | * @param interface the interface to set |
85 | * @param setAuto the value to set interface to. | 86 | * @param setAuto the value to set interface to. |
86 | * @return false if already set to setAuto. | 87 | * @return false if already set to setAuto. |
87 | * */ | 88 | * */ |
88 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ | 89 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ |
89 | // Don't need to set it if it is already set. | 90 | // Don't need to set it if it is already set. |
90 | if(isAuto(interface) == setAuto) | 91 | if(isAuto(interface) == setAuto) |
91 | return false; | 92 | return false; |
92 | 93 | ||
93 | bool changed = false; | 94 | bool changed = false; |
94 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 95 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
95 | if((*it).contains(AUTO)){ | 96 | if((*it).contains(AUTO)){ |
96 | //We know that they are not in any group so let add to this auto. | 97 | //We know that they are not in any group so let add to this auto. |
97 | if(setAuto){ | 98 | if(setAuto){ |
98 | (*it) = (*it) += " " + interface; | 99 | (*it) = (*it) += " " + interface; |
99 | // Don't care to have such thins as: auto eth0 lo usb0 | 100 | // Don't care to have such thins as: auto eth0 lo usb0 |
100 | (*it) = (*it).simplifyWhiteSpace(); | 101 | (*it) = (*it).simplifyWhiteSpace(); |
101 | changed = true; | 102 | changed = true; |
102 | break; | 103 | break; |
103 | } | 104 | } |
104 | // else see if we need to remove from this one | 105 | // else see if we need to remove from this one |
105 | else{ | 106 | else{ |
106 | if((*it).contains(interface)){ | 107 | if((*it).contains(interface)){ |
107 | (*it) = (*it).replace(QRegExp(interface), ""); | 108 | (*it) = (*it).replace(QRegExp(interface), ""); |
108 | // if AUTO is the only thing left clear the line | 109 | // if AUTO is the only thing left clear the line |
109 | if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) | 110 | if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) |
110 | (*it) = ""; | 111 | (*it) = ""; |
111 | changed = true; | 112 | changed = true; |
112 | // Don't break because we want to make sure we remove all cases. | 113 | // Don't break because we want to make sure we remove all cases. |
113 | } | 114 | } |
114 | } | 115 | } |
115 | } | 116 | } |
116 | } | 117 | } |
117 | // In the case where there is no AUTO field add one. | 118 | // In the case where there is no AUTO field add one. |
118 | if(!changed && setAuto) | 119 | if(!changed && setAuto) |
119 | interfaces.append(QString(AUTO" %1").arg(interface)); | 120 | interfaces.append(QString(AUTO" %1").arg(interface)); |
120 | return true; | 121 | return true; |
121 | } | 122 | } |
122 | 123 | ||
123 | /** | 124 | /** |
124 | * Set the current interface to interface. This needs to be done before you | 125 | * Set the current interface to interface. This needs to be done before you |
125 | * can call getFamily(), getMethod, and get/setOption(). | 126 | * can call getFamily(), getMethod, and get/setOption(). |
126 | * @param interface the name of the interface to set. All whitespace is | 127 | * @param interface the name of the interface to set. All whitespace is |
127 | * removed from the interface name. | 128 | * removed from the interface name. |
128 | * @return bool true if it is successfull. | 129 | * @return bool true if it is successfull. |
129 | */ | 130 | */ |
130 | bool Interfaces::setInterface(QString interface){ | 131 | bool Interfaces::setInterface(QString interface){ |
131 | interface = interface.simplifyWhiteSpace(); | 132 | interface = interface.simplifyWhiteSpace(); |
132 | interface = interface.replace(QRegExp(" "), ""); | 133 | interface = interface.replace(QRegExp(" "), ""); |
133 | return setStanza(IFACE, interface, currentIface); | 134 | return setStanza(IFACE, interface, currentIface); |
134 | } | 135 | } |
135 | 136 | ||
136 | /** | 137 | /** |
137 | * A quick helper funtion to see if the current interface is set. | 138 | * A quick helper funtion to see if the current interface is set. |
138 | * @return bool true if set, false otherwise. | 139 | * @return bool true if set, false otherwise. |
139 | */ | 140 | */ |
140 | bool Interfaces::isInterfaceSet() const { | 141 | bool Interfaces::isInterfaceSet() const { |
141 | return (interfaces.end() != currentIface); | 142 | return (interfaces.end() != currentIface); |
142 | } | 143 | } |
143 | 144 | ||
144 | /** | 145 | /** |
145 | * Add a new interface of with the settings - family and method | 146 | * Add a new interface of with the settings - family and method |
146 | * @param interface the name of the interface to set. All whitespace is | 147 | * @param interface the name of the interface to set. All whitespace is |
147 | * removed from the interface name. | 148 | * removed from the interface name. |
148 | * @param family the family of this interface inet or inet, ipx or inet6 | 149 | * @param family the family of this interface inet or inet, ipx or inet6 |
149 | * Must of one of the families defined in interfaces.h | 150 | * Must of one of the families defined in interfaces.h |
150 | * @param method for the family. see interfaces man page for family methods. | 151 | * @param method for the family. see interfaces man page for family methods. |
151 | * @return true if successfull. | 152 | * @return true if successfull. |
152 | */ | 153 | */ |
153 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ | 154 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ |
155 | qDebug("Interfaces::addInterface(%s)",interface.latin1()); | ||
154 | if(0 == acceptedFamily.contains(family)) | 156 | if(0 == acceptedFamily.contains(family)) |
155 | return false; | 157 | return false; |
156 | QString newInterface = interface.simplifyWhiteSpace(); | 158 | QString newInterface = interface.simplifyWhiteSpace(); |
157 | newInterface = newInterface.replace(QRegExp(" "), ""); | 159 | newInterface = newInterface.replace(QRegExp(" "), ""); |
158 | interfaces.append(""); | 160 | interfaces.append(""); |
159 | interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); | 161 | interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); |
160 | return true; | 162 | return true; |
161 | } | 163 | } |
162 | 164 | ||
163 | /** | 165 | /** |
164 | * Copies interface with name interface to name newInterface | 166 | * Copies interface with name interface to name newInterface |
165 | * @param newInterface name of the new interface. | 167 | * @param newInterface name of the new interface. |
166 | * @return bool true if successfull | 168 | * @return bool true if successfull |
167 | */ | 169 | */ |
168 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ | 170 | bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ |
171 | qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1()); | ||
169 | if(!setInterface(interface)) | 172 | if(!setInterface(interface)) |
170 | return false; | 173 | return false; |
171 | 174 | ||
172 | // Store the old interface and bump past the stanza line. | 175 | // Store the old interface and bump past the stanza line. |
173 | QStringList::Iterator it = currentIface; | 176 | QStringList::Iterator it = currentIface; |
174 | it++; | 177 | it++; |
175 | 178 | ||
176 | // Add the new interface | 179 | // Add the new interface |
177 | bool error; | 180 | bool error; |
178 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); | 181 | addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); |
179 | if(!setInterface(newInterface)) | 182 | if(!setInterface(newInterface)) |
180 | return false; | 183 | return false; |
181 | 184 | ||
182 | QStringList::Iterator newIface = currentIface; | 185 | QStringList::Iterator newIface = currentIface; |
183 | newIface++; | 186 | newIface++; |
184 | 187 | ||
185 | // Copy all of the lines | 188 | // Copy all of the lines |
186 | for ( ; it != interfaces.end(); ++it ){ | 189 | for ( ; it != interfaces.end(); ++it ){ |
187 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) | 190 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) |
188 | break; | 191 | break; |
189 | newIface = interfaces.insert(newIface, *it); | 192 | newIface = interfaces.insert(newIface, *it); |
190 | } | 193 | } |
191 | 194 | ||
192 | return true; | 195 | return true; |
193 | } | 196 | } |
194 | 197 | ||
195 | /** | 198 | /** |
196 | * Remove the currently selected interface and all of its options. | 199 | * Remove the currently selected interface and all of its options. |
197 | * @return bool if successfull or not. | 200 | * @return bool if successfull or not. |
198 | */ | 201 | */ |
199 | bool Interfaces::removeInterface(){ | 202 | bool Interfaces::removeInterface(){ |
200 | return removeStanza(currentIface); | 203 | return removeStanza(currentIface); |
201 | } | 204 | } |
202 | 205 | ||
203 | /** | 206 | /** |
204 | * Gets the hardware name of the interface that is currently selected. | 207 | * Gets the hardware name of the interface that is currently selected. |
205 | * @return QString name of the hardware interface (eth0, usb2, wlan1...). | 208 | * @return QString name of the hardware interface (eth0, usb2, wlan1...). |
206 | * @param error set to true if any error occurs, false otherwise. | 209 | * @param error set to true if any error occurs, false otherwise. |
207 | */ | 210 | */ |
208 | QString Interfaces::getInterfaceName(bool &error){ | 211 | QString Interfaces::getInterfaceName(bool &error){ |
209 | if(currentIface == interfaces.end()){ | 212 | if(currentIface == interfaces.end()){ |
210 | error = true; | 213 | error = true; |
211 | return QString(); | 214 | return QString(); |
212 | } | 215 | } |
213 | QString line = (*currentIface); | 216 | QString line = (*currentIface); |
214 | line = line.mid(QString(IFACE).length() +1, line.length()); | 217 | line = line.mid(QString(IFACE).length() +1, line.length()); |
215 | line = line.simplifyWhiteSpace(); | 218 | line = line.simplifyWhiteSpace(); |
216 | int findSpace = line.find(" "); | 219 | int findSpace = line.find(" "); |
217 | if( findSpace < 0){ | 220 | if( findSpace < 0){ |
218 | error = true; | 221 | error = true; |
219 | return QString(); | 222 | return QString(); |
220 | } | 223 | } |
221 | error = false; | 224 | error = false; |
222 | return line.mid(0, findSpace); | 225 | return line.mid(0, findSpace); |
223 | } | 226 | } |
224 | 227 | ||
225 | /** | 228 | /** |
226 | * Gets the family name of the interface that is currently selected. | 229 | * Gets the family name of the interface that is currently selected. |
227 | * @return QString name of the family (inet, inet6, ipx). | 230 | * @return QString name of the family (inet, inet6, ipx). |
228 | * @param error set to true if any error occurs, false otherwise. | 231 | * @param error set to true if any error occurs, false otherwise. |
229 | */ | 232 | */ |
230 | QString Interfaces::getInterfaceFamily(bool &error){ | 233 | QString Interfaces::getInterfaceFamily(bool &error){ |
231 | QString name = getInterfaceName(error); | 234 | QString name = getInterfaceName(error); |
232 | if(error) | 235 | if(error) |
233 | return QString(); | 236 | return QString(); |
234 | QString line = (*currentIface); | 237 | QString line = (*currentIface); |
235 | line = line.mid(QString(IFACE).length() +1, line.length()); | 238 | line = line.mid(QString(IFACE).length() +1, line.length()); |
236 | line = line.mid(name.length()+1, line.length()); | 239 | line = line.mid(name.length()+1, line.length()); |
237 | line = line.simplifyWhiteSpace(); | 240 | line = line.simplifyWhiteSpace(); |
238 | int findSpace = line.find(" "); | 241 | int findSpace = line.find(" "); |
239 | if( findSpace < 0){ | 242 | if( findSpace < 0){ |
240 | error = true; | 243 | error = true; |
241 | return QString(); | 244 | return QString(); |
242 | } | 245 | } |
243 | error = false; | 246 | error = false; |
244 | return line.mid(0, findSpace); | 247 | return line.mid(0, findSpace); |
245 | } | 248 | } |
246 | 249 | ||
247 | /** | 250 | /** |
248 | * Gets the method of the interface that is currently selected. | 251 | * Gets the method of the interface that is currently selected. |
249 | * @return QString name of the method such as staic or dhcp. | 252 | * @return QString name of the method such as staic or dhcp. |
250 | * See the man page of interfaces for possible methods depending on the family. | 253 | * See the man page of interfaces for possible methods depending on the family. |
251 | * @param error set to true if any error occurs, false otherwise. | 254 | * @param error set to true if any error occurs, false otherwise. |
252 | */ | 255 | */ |
253 | QString Interfaces::getInterfaceMethod(bool &error){ | 256 | QString Interfaces::getInterfaceMethod(bool &error){ |
254 | QString name = getInterfaceName(error); | 257 | QString name = getInterfaceName(error); |
255 | if(error) | 258 | if(error) |
256 | return QString(); | 259 | return QString(); |
257 | QString family = getInterfaceFamily(error); | 260 | QString family = getInterfaceFamily(error); |
258 | if(error) | 261 | if(error) |
259 | return QString(); | 262 | return QString(); |
260 | QString line = (*currentIface); | 263 | QString line = (*currentIface); |
261 | line = line.mid(QString(IFACE).length()+1, line.length()); | 264 | line = line.mid(QString(IFACE).length()+1, line.length()); |
262 | line = line.mid(name.length()+1, line.length()); | 265 | line = line.mid(name.length()+1, line.length()); |
263 | line = line.mid(family.length()+1, line.length()); | 266 | line = line.mid(family.length()+1, line.length()); |
264 | line = line.simplifyWhiteSpace(); | 267 | line = line.simplifyWhiteSpace(); |
265 | error = false; | 268 | error = false; |
266 | return line; | 269 | return line; |
267 | } | 270 | } |
268 | 271 | ||
269 | /** | 272 | /** |
270 | * Sets the interface name to newName. | 273 | * Sets the interface name to newName. |
271 | * @param newName the new name of the interface. All whitespace is removed. | 274 | * @param newName the new name of the interface. All whitespace is removed. |
272 | * @return bool true if successfull. | 275 | * @return bool true if successfull. |
273 | */ | 276 | */ |
274 | bool Interfaces::setInterfaceName(const QString &newName){ | 277 | bool Interfaces::setInterfaceName(const QString &newName){ |
278 | qDebug("setInterfaceName %s", newName.latin1()); | ||
275 | if(currentIface == interfaces.end()) | 279 | if(currentIface == interfaces.end()) |
276 | return false; | 280 | return false; |
277 | QString name = newName.simplifyWhiteSpace(); | 281 | QString name = newName.simplifyWhiteSpace(); |
278 | name = name.replace(QRegExp(" "), ""); | 282 | name = name.replace(QRegExp(" "), ""); |
279 | bool returnValue = false; | 283 | bool returnValue = false; |
280 | (*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); | 284 | QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); |
285 | qDebug("setting %s",tmp.latin1()); | ||
286 | |||
287 | (*currentIface) = tmp; | ||
281 | return !returnValue; | 288 | return !returnValue; |
282 | } | 289 | } |
283 | 290 | ||
284 | /** | 291 | /** |
285 | * Sets the interface family to newName. | 292 | * Sets the interface family to newName. |
286 | * @param newName the new name of the interface. Must be one of the families | 293 | * @param newName the new name of the interface. Must be one of the families |
287 | * defined in the interfaces.h file. | 294 | * defined in the interfaces.h file. |
288 | * @return bool true if successfull. | 295 | * @return bool true if successfull. |
289 | */ | 296 | */ |
290 | bool Interfaces::setInterfaceFamily(const QString &newName){ | 297 | bool Interfaces::setInterfaceFamily(const QString &newName){ |
291 | if(currentIface == interfaces.end()) | 298 | if(currentIface == interfaces.end()) |
292 | return false; | 299 | return false; |
293 | if(acceptedFamily.contains(newName)==0) | 300 | if(acceptedFamily.contains(newName)==0) |
294 | return false; | 301 | return false; |
295 | bool returnValue = false; | 302 | bool returnValue = false; |
296 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); | 303 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); |
297 | return !returnValue; | 304 | return !returnValue; |
298 | } | 305 | } |
299 | 306 | ||
300 | /** | 307 | /** |
301 | * Sets the interface method to newName | 308 | * Sets the interface method to newName |
302 | * @param newName the new name of the interface | 309 | * @param newName the new name of the interface |
303 | * @return bool true if successfull. | 310 | * @return bool true if successfull. |
304 | */ | 311 | */ |
305 | bool Interfaces::setInterfaceMethod(const QString &newName){ | 312 | bool Interfaces::setInterfaceMethod(const QString &newName){ |
306 | if(currentIface == interfaces.end()) | 313 | if(currentIface == interfaces.end()) |
307 | return false; | 314 | return false; |
308 | bool returnValue = false; | 315 | bool returnValue = false; |
309 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); | 316 | (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); |
310 | return !returnValue; | 317 | return !returnValue; |
311 | } | 318 | } |
312 | 319 | ||
313 | /** | 320 | /** |
314 | * Get a value for an option in the currently selected interface. For example | 321 | * Get a value for an option in the currently selected interface. For example |
315 | * calling getInterfaceOption("address") on the following stanza would | 322 | * calling getInterfaceOption("address") on the following stanza would |
316 | * return 192.168.1.1. | 323 | * return 192.168.1.1. |
317 | * iface eth0 static | 324 | * iface eth0 static |
318 | * address 192.168.1.1 | 325 | * address 192.168.1.1 |
319 | * @param option the options to get the value. | 326 | * @param option the options to get the value. |
320 | * @param error set to true if any error occurs, false otherwise. | 327 | * @param error set to true if any error occurs, false otherwise. |
321 | * @return QString the options value. QString::null if error == true | 328 | * @return QString the options value. QString::null if error == true |
322 | */ | 329 | */ |
323 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ | 330 | QString Interfaces::getInterfaceOption(const QString &option, bool &error){ |
324 | return getOption(currentIface, option, error); | 331 | return getOption(currentIface, option, error); |
325 | } | 332 | } |
326 | 333 | ||
327 | /** | 334 | /** |
328 | * Set a value for an option in the currently selected interface. If option | 335 | * Set a value for an option in the currently selected interface. If option |
329 | * doesn't exist then it is added along with the value. | 336 | * doesn't exist then it is added along with the value. |
337 | * If value isEmpty() then we will remove the option | ||
338 | * | ||
330 | * @param option the options to set the value. | 339 | * @param option the options to set the value. |
331 | * @param value the value that option should be set to. | 340 | * @param value the value that option should be set to. |
332 | * @param error set to true if any error occurs, false otherwise. | 341 | * @param error set to true if any error occurs, false otherwise. |
333 | * @return QString the options value. QString::null if error == true | 342 | * @return QString the options value. QString::null if error == true |
334 | */ | 343 | */ |
335 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ | 344 | bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ |
336 | return setOption(currentIface, option, value); | 345 | if( value.stripWhiteSpace().isEmpty() ) |
346 | return removeInterfaceOption( option ); | ||
347 | |||
348 | qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1()); | ||
349 | return setOption(currentIface, option, value); | ||
337 | } | 350 | } |
338 | 351 | ||
339 | /** | 352 | /** |
340 | * Removes a value for an option in the currently selected interface. | 353 | * Removes a value for an option in the currently selected interface. |
341 | * @param option the options to set the value. | 354 | * @param option the options to set the value. |
342 | * @param error set to true if any error occurs, false otherwise. | 355 | * @param error set to true if any error occurs, false otherwise. |
343 | * @return QString the options value. QString::null if error == true | 356 | * @return QString the options value. QString::null if error == true |
344 | */ | 357 | */ |
345 | bool Interfaces::removeInterfaceOption(const QString &option){ | 358 | bool Interfaces::removeInterfaceOption(const QString &option){ |
346 | return removeOption(currentIface, option); | 359 | return removeOption(currentIface, option); |
347 | } | 360 | } |
348 | 361 | ||
349 | /** | 362 | /** |
350 | * Removes a value for an option in the currently selected interface. | 363 | * Removes a value for an option in the currently selected interface. |
351 | * @param option the options to set the value. | 364 | * @param option the options to set the value. |
352 | * @param value the value that option should be set to. | 365 | * @param value the value that option should be set to. |
353 | * @param error set to true if any error occurs, false otherwise. | 366 | * @param error set to true if any error occurs, false otherwise. |
354 | * @return QString the options value. QString::null if error == true | 367 | * @return QString the options value. QString::null if error == true |
355 | */ | 368 | */ |
356 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ | 369 | bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ |
357 | return removeOption(currentIface, option, value); | 370 | return removeOption(currentIface, option, value); |
358 | } | 371 | } |
359 | 372 | ||
360 | /** | 373 | /** |
361 | * Removes all of the options from the currently selected interface. | 374 | * Removes all of the options from the currently selected interface. |
362 | * @return bool error if if successfull | 375 | * @return bool error if if successfull |
363 | */ | 376 | */ |
364 | bool Interfaces::removeAllInterfaceOptions(){ | 377 | bool Interfaces::removeAllInterfaceOptions(){ |
365 | return removeAllOptions(currentIface); | 378 | return removeAllOptions(currentIface); |
366 | } | 379 | } |
367 | 380 | ||
368 | /** | 381 | /** |
369 | * Set the current map to interface's map. This needs to be done before you | 382 | * Set the current map to interface's map. This needs to be done before you |
370 | * can call addMapping(), set/getMap(), and get/setScript(). | 383 | * can call addMapping(), set/getMap(), and get/setScript(). |
371 | * @param interface the name of the interface to set. All whitespace is | 384 | * @param interface the name of the interface to set. All whitespace is |
372 | * removed from the interface name. | 385 | * removed from the interface name. |
373 | * @return bool true if it is successfull. | 386 | * @return bool true if it is successfull. |
374 | */ | 387 | */ |
375 | bool Interfaces::setMapping(const QString &interface){ | 388 | bool Interfaces::setMapping(const QString &interface){ |
376 | QString interfaceName = interface.simplifyWhiteSpace(); | 389 | QString interfaceName = interface.simplifyWhiteSpace(); |
377 | interfaceName = interfaceName.replace(QRegExp(" "), ""); | 390 | interfaceName = interfaceName.replace(QRegExp(" "), ""); |
378 | return setStanza(MAPPING, interfaceName, currentMapping); | 391 | return setStanza(MAPPING, interfaceName, currentMapping); |
379 | } | 392 | } |
380 | 393 | ||
381 | /** | 394 | /** |
382 | * Adds a new Mapping to the interfaces file with interfaces. | 395 | * Adds a new Mapping to the interfaces file with interfaces. |
383 | * @param interface the name(s) of the interfaces to set to this mapping | 396 | * @param interface the name(s) of the interfaces to set to this mapping |
384 | */ | 397 | */ |
385 | void Interfaces::addMapping(const QString &option){ | 398 | void Interfaces::addMapping(const QString &option){ |
386 | interfaces.append(""); | 399 | interfaces.append(""); |
387 | interfaces.append(QString(MAPPING " %1").arg(option)); | 400 | interfaces.append(QString(MAPPING " %1").arg(option)); |
388 | } | 401 | } |
389 | 402 | ||
390 | /** | 403 | /** |
391 | * Remove the currently selected map and all of its options. | 404 | * Remove the currently selected map and all of its options. |
392 | * @return bool if successfull or not. | 405 | * @return bool if successfull or not. |
393 | */ | 406 | */ |
394 | bool Interfaces::removeMapping(){ | 407 | bool Interfaces::removeMapping(){ |
395 | return removeStanza(currentMapping); | 408 | return removeStanza(currentMapping); |
396 | } | 409 | } |
397 | 410 | ||
398 | /** | 411 | /** |
399 | * Set a map option within a mapping. | 412 | * Set a map option within a mapping. |
400 | * @param map map to use | 413 | * @param map map to use |
401 | * @param value value to go with map | 414 | * @param value value to go with map |
402 | * @return bool true if it is successfull. | 415 | * @return bool true if it is successfull. |
403 | */ | 416 | */ |
404 | bool Interfaces::setMap(const QString &map, const QString &value){ | 417 | bool Interfaces::setMap(const QString &map, const QString &value){ |
405 | return setOption(currentMapping, map, value); | 418 | return setOption(currentMapping, map, value); |
406 | } | 419 | } |
407 | 420 | ||
408 | /** | 421 | /** |
409 | * Removes a map option within a mapping. | 422 | * Removes a map option within a mapping. |
410 | * @param map map to use | 423 | * @param map map to use |
411 | * @param value value to go with map | 424 | * @param value value to go with map |
412 | * @return bool true if it is successfull. | 425 | * @return bool true if it is successfull. |
413 | */ | 426 | */ |
414 | bool Interfaces::removeMap(const QString &map, const QString &value){ | 427 | bool Interfaces::removeMap(const QString &map, const QString &value){ |
415 | return removeOption(currentMapping, map, value); | 428 | return removeOption(currentMapping, map, value); |
416 | } | 429 | } |
417 | 430 | ||
418 | /** | 431 | /** |
419 | * Get a map value within a mapping. | 432 | * Get a map value within a mapping. |
420 | * @param map map to get value of | 433 | * @param map map to get value of |
421 | * @param bool true if it is successfull. | 434 | * @param bool true if it is successfull. |
422 | * @return value that goes to the map | 435 | * @return value that goes to the map |
423 | */ | 436 | */ |
424 | QString Interfaces::getMap(const QString &map, bool &error){ | 437 | QString Interfaces::getMap(const QString &map, bool &error){ |
425 | return getOption(currentMapping, map, error); | 438 | return getOption(currentMapping, map, error); |
426 | } | 439 | } |
427 | 440 | ||
428 | /** | 441 | /** |
429 | * Sets a script value of the current mapping to argument. | 442 | * Sets a script value of the current mapping to argument. |
430 | * @param argument the script name. | 443 | * @param argument the script name. |
431 | * @return true if successfull. | 444 | * @return true if successfull. |
432 | */ | 445 | */ |
433 | bool Interfaces::setScript(const QString &argument){ | 446 | bool Interfaces::setScript(const QString &argument){ |
434 | return setOption(currentMapping, "script", argument); | 447 | return setOption(currentMapping, "script", argument); |
435 | } | 448 | } |
436 | 449 | ||
437 | /** | 450 | /** |
438 | * @param error true if could not retrieve the current script argument. | 451 | * @param error true if could not retrieve the current script argument. |
439 | * @return QString the argument of the script for the current mapping. | 452 | * @return QString the argument of the script for the current mapping. |
440 | */ | 453 | */ |
441 | QString Interfaces::getScript(bool &error){ | 454 | QString Interfaces::getScript(bool &error){ |
442 | return getOption(currentMapping, "script", error); | 455 | return getOption(currentMapping, "script", error); |
443 | } | 456 | } |
444 | 457 | ||
445 | 458 | ||
446 | 459 | ||
447 | /** | 460 | /** |
448 | * Helper function used to parse through the QStringList and put pointers in | 461 | * Helper function used to parse through the QStringList and put pointers in |
449 | * the correct place. | 462 | * the correct place. |
450 | * @param stanza The stanza (auto, iface, mapping) to look for. | 463 | * @param stanza The stanza (auto, iface, mapping) to look for. |
451 | * @param option string that must be in the stanza's main line. | 464 | * @param option string that must be in the stanza's main line. |
452 | * @param interator interator to place at location of stanza if successfull. | 465 | * @param interator interator to place at location of stanza if successfull. |
453 | * @return bool true if the stanza is found. | 466 | * @return bool true if the stanza is found. |
454 | */ | 467 | */ |
455 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ | 468 | bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ |
456 | bool found = false; | 469 | bool found = false; |
457 | iterator = interfaces.end(); | 470 | iterator = interfaces.end(); |
458 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 471 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
459 | QString line = (*it).simplifyWhiteSpace(); | 472 | QString line = (*it).simplifyWhiteSpace(); |
460 | if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ | 473 | if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ |
461 | uint point = line.find(option); | 474 | uint point = line.find(option); |
462 | bool valid = true; | 475 | bool valid = true; |
463 | if(point > 0){ | 476 | if(point > 0){ |
464 | // There are more chars in the line. check +1 | 477 | // There are more chars in the line. check +1 |
465 | if(line.at(point-1) != ' ') | 478 | if(line.at(point-1) != ' ') |
466 | valid = false; | 479 | valid = false; |
467 | } | 480 | } |
468 | point += option.length(); | 481 | point += option.length(); |
469 | if(point < line.length()-1){ | 482 | if(point < line.length()-1){ |
470 | // There are more chars in the line. check -1 | 483 | // There are more chars in the line. check -1 |
471 | if(line.at(point) != ' ') | 484 | if(line.at(point) != ' ') |
472 | valid = false; | 485 | valid = false; |
473 | } | 486 | } |
474 | if(valid){ | 487 | if(valid){ |
475 | if(found == true){ | 488 | if(found == true){ |
476 | qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); | 489 | qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); |
477 | } | 490 | } |
478 | found = true; | 491 | found = true; |
479 | iterator = it; | 492 | iterator = it; |
480 | } | 493 | } |
481 | } | 494 | } |
482 | } | 495 | } |
483 | return found; | 496 | return found; |
484 | } | 497 | } |
485 | 498 | ||
486 | /** | 499 | /** |
487 | * Sets a value of an option in a stanza | 500 | * Sets a value of an option in a stanza |
488 | * @param start the start of the stanza | 501 | * @param start the start of the stanza |
489 | * @param option the option to use when setting value. | 502 | * @param option the option to use when setting value. |
490 | * @return bool true if successfull, false otherwise. | 503 | * @return bool true if successfull, false otherwise. |
491 | */ | 504 | */ |
492 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 505 | bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
493 | if(start == interfaces.end()) | 506 | if(start == interfaces.end()) |
494 | return false; | 507 | return false; |
495 | 508 | qDebug("setting option"); | |
496 | bool found = false; | 509 | bool found = false; |
510 | bool replaced = false; | ||
511 | QStringList::Iterator insertAt = NULL; | ||
497 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 512 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
498 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 513 | qDebug(" Interfaces::setOption got line >%s<",(*it).latin1()); |
499 | if(!found && value != ""){ | 514 | // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line |
500 | // Got to the end of the stanza without finding it, so append it. | 515 | // but since it works with an empty interfaces file I (tille) will not do anything more |
501 | interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); | 516 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){ |
502 | } | 517 | if (found) break; |
503 | found = true; | 518 | // && it != start){ |
504 | break; | 519 | // if(!found && value != ""){ |
505 | } | 520 | // // Got to the end of the stanza without finding it, so append it. |
521 | // qDebug(" Got to the end of the stanza without finding it, so append it."); | ||
522 | // interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); | ||
523 | // } | ||
524 | qDebug("found 1"); | ||
525 | // interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value)); | ||
526 | found = true; | ||
527 | insertAt = it; | ||
528 | |||
529 | } | ||
506 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ | 530 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ |
507 | // Found it in stanza so replace it. | 531 | // Found it in stanza so replace it. |
532 | qDebug("found 2"); | ||
508 | if(found) | 533 | if(found) |
509 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 534 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
510 | found = true; | 535 | found = true; |
536 | replaced = true; | ||
511 | (*it) = QString("\t%1 %2").arg(option).arg(value); | 537 | (*it) = QString("\t%1 %2").arg(option).arg(value); |
512 | } | 538 | } |
513 | } | 539 | } |
514 | if(!found){ | 540 | if(!found){ |
541 | qDebug("! found insert anyway"); | ||
515 | QStringList::Iterator p = start; | 542 | QStringList::Iterator p = start; |
516 | interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); | 543 | interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); |
517 | found = true; | 544 | found = true; |
518 | } | 545 | } |
546 | |||
547 | if(found && !replaced){ | ||
548 | qDebug("found iface but not the option so insert it here..."); | ||
549 | interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value)); | ||
550 | } | ||
519 | return found; | 551 | return found; |
520 | } | 552 | } |
521 | 553 | ||
522 | /** | 554 | /** |
523 | * Removes a stanza and all of its options | 555 | * Removes a stanza and all of its options |
524 | * @param stanza the stanza to remove | 556 | * @param stanza the stanza to remove |
525 | * @return bool true if successfull. | 557 | * @return bool true if successfull. |
526 | */ | 558 | */ |
527 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ | 559 | bool Interfaces::removeStanza(QStringList::Iterator &stanza){ |
528 | if(stanza == interfaces.end()) | 560 | if(stanza == interfaces.end()) |
529 | return false; | 561 | return false; |
530 | (*stanza) = ""; | 562 | (*stanza) = ""; |
531 | return removeAllOptions(stanza); | 563 | return removeAllOptions(stanza); |
532 | } | 564 | } |
533 | 565 | ||
534 | /** | 566 | /** |
535 | * Removes a option in a stanza | 567 | * Removes a option in a stanza |
536 | * @param start the start of the stanza | 568 | * @param start the start of the stanza |
537 | * @param option the option to remove | 569 | * @param option the option to remove |
538 | * @return bool true if successfull, false otherwise. | 570 | * @return bool true if successfull, false otherwise. |
539 | */ | 571 | */ |
540 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ | 572 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ |
541 | if(start == interfaces.end()) | 573 | if(start == interfaces.end()) |
542 | return false; | 574 | return false; |
543 | 575 | ||
544 | bool found = false; | 576 | bool found = false; |
545 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 577 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
546 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 578 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
547 | // got to the end without finding it | 579 | // got to the end without finding it |
548 | break; | 580 | break; |
549 | } | 581 | } |
550 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ | 582 | if((*it).contains(option) && it != start && (*it).at(0) != '#'){ |
551 | // Found it in stanza so replace it. | 583 | // Found it in stanza so replace it. |
552 | if(found) | 584 | if(found) |
553 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 585 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
554 | found = true; | 586 | found = true; |
555 | (*it) = ""; | 587 | it = interfaces.remove( it ); // we really want to remove the line |
588 | --it; // we do ++it later in the head of the for loop | ||
556 | } | 589 | } |
557 | } | 590 | } |
558 | return found; | 591 | return found; |
559 | } | 592 | } |
560 | 593 | ||
561 | /** | 594 | /** |
562 | * Removes a option in a stanza | 595 | * Removes a option in a stanza |
563 | * @param start the start of the stanza | 596 | * @param start the start of the stanza |
564 | * @param option the option to use when setting value. | 597 | * @param option the option to use when setting value. |
565 | * @return bool true if successfull, false otherwise. | 598 | * @return bool true if successfull, false otherwise. |
566 | */ | 599 | */ |
567 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ | 600 | bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ |
568 | if(start == interfaces.end()) | 601 | if(start == interfaces.end()) |
569 | return false; | 602 | return false; |
570 | 603 | ||
571 | bool found = false; | 604 | bool found = false; |
572 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 605 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
573 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 606 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
574 | // got to the end without finding it | 607 | // got to the end without finding it |
575 | break; | 608 | break; |
576 | } | 609 | } |
577 | if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ | 610 | if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ |
578 | // Found it in stanza so replace it. | 611 | // Found it in stanza so replace it. |
579 | if(found) | 612 | if(found) |
580 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); | 613 | qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); |
581 | found = true; | 614 | found = true; |
582 | (*it) = ""; | 615 | it = interfaces.remove( it ); // we really want to remove the line |
616 | --it; // we do ++it later in the head of the for loop | ||
583 | } | 617 | } |
584 | } | 618 | } |
585 | return found; | 619 | return found; |
586 | } | 620 | } |
587 | 621 | ||
588 | /** | 622 | /** |
589 | * Removes all options in a stanza | 623 | * Removes all options in a stanza |
590 | * @param start the start of the stanza | 624 | * @param start the start of the stanza |
591 | * @return bool true if successfull, false otherwise. | 625 | * @return bool true if successfull, false otherwise. |
592 | */ | 626 | */ |
593 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ | 627 | bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ |
594 | if(start == interfaces.end()) | 628 | if(start == interfaces.end()) |
595 | return false; | 629 | return false; |
596 | 630 | ||
597 | QStringList::Iterator it = start; | 631 | QStringList::Iterator it = start; |
598 | it = ++it; | 632 | it = ++it; |
599 | for (; it != interfaces.end(); ++it ) { | 633 | for (; it != interfaces.end(); ++it ) { |
600 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 634 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
601 | break; | 635 | break; |
602 | } | 636 | } |
603 | it = interfaces.remove(it); | 637 | it = interfaces.remove(it); |
604 | it = --it; | 638 | it = --it; |
605 | } | 639 | } |
606 | // Leave a space between this interface and the next. | 640 | // Leave a space between this interface and the next. |
607 | interfaces.insert(it, QString("")); | 641 | interfaces.insert(it, QString("")); |
608 | return true; | 642 | return true; |
609 | } | 643 | } |
610 | 644 | ||
611 | /** | 645 | /** |
612 | * Gets a value of an option in a stanza | 646 | * Gets a value of an option in a stanza |
613 | * @param start the start of the stanza | 647 | * @param start the start of the stanza |
614 | * @param option the option to use when getting the value. | 648 | * @param option the option to use when getting the value. |
615 | * @param bool true if errors false otherwise. | 649 | * @param bool true if errors false otherwise. |
616 | * @return QString the value of option QString::null() if error == true. | 650 | * @return QString the value of option QString::null() if error == true. |
617 | */ | 651 | */ |
618 | QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ | 652 | QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ |
619 | if(start == interfaces.end()){ | 653 | if(start == interfaces.end()){ |
620 | error = false; | 654 | error = false; |
621 | return QString(); | 655 | return QString(); |
622 | } | 656 | } |
623 | 657 | ||
624 | QString value; | 658 | QString value; |
625 | bool found = false; | 659 | bool found = false; |
626 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { | 660 | for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { |
627 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ | 661 | if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ |
628 | break; | 662 | break; |
629 | } | 663 | } |
630 | if((*it).contains(option) && (*it).at(0) != '#'){ | 664 | if((*it).contains(option) && (*it).at(0) != '#'){ |
631 | if(found) | 665 | if(found) |
632 | qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); | 666 | qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); |
633 | found = true; | 667 | found = true; |
634 | QString line = (*it).simplifyWhiteSpace(); | 668 | QString line = (*it).simplifyWhiteSpace(); |
635 | int space = line.find(" ", option.length()); | 669 | int space = line.find(" ", option.length()); |
636 | if(space != -1){ | 670 | if(space != -1){ |
637 | value = line.mid(space+1, line.length()); | 671 | value = line.mid(space+1, line.length()); |
638 | break; | 672 | break; |
639 | } | 673 | } |
640 | } | 674 | } |
641 | } | 675 | } |
642 | error = !found; | 676 | error = !found; |
643 | return value; | 677 | return value; |
644 | } | 678 | } |
645 | 679 | ||
646 | /** | 680 | /** |
647 | * Write out the interfaces file to the file passed into the constructor. | 681 | * Write out the interfaces file to the file passed into the constructor. |
648 | * Removes any excess blank lines over 1 line long. | 682 | * Removes any excess blank lines over 1 line long. |
649 | * @return bool true if successfull, false if not. | 683 | * @return bool true if successfull, false if not. |
650 | */ | 684 | */ |
651 | bool Interfaces::write(){ | 685 | bool Interfaces::write(){ |
652 | QFile::remove(interfacesFile); | 686 | QFile::remove(interfacesFile); |
653 | QFile file(interfacesFile); | 687 | QFile file(interfacesFile); |
654 | 688 | ||
655 | if (!file.open(IO_ReadWrite)){ | 689 | if (!file.open(IO_ReadWrite)){ |
656 | qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); | 690 | qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); |
657 | return false; | 691 | return false; |
658 | } | 692 | } |
659 | QTextStream stream( &file ); | 693 | QTextStream stream( &file ); |
660 | int whiteSpaceCount = 0; | 694 | int whiteSpaceCount = 0; |
661 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 695 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
662 | QString line = (*it).simplifyWhiteSpace(); | 696 | QString line = (*it).simplifyWhiteSpace(); |
663 | line = line.replace(QRegExp(" "),""); | 697 | line = line.replace(QRegExp(" "),""); |
664 | if(line.length() == 0) | 698 | if(line.length() == 0) |
665 | whiteSpaceCount++; | 699 | whiteSpaceCount++; |
666 | else | 700 | else |
667 | whiteSpaceCount = 0; | 701 | whiteSpaceCount = 0; |
668 | if(whiteSpaceCount < 2){ | 702 | if(whiteSpaceCount < 2){ |
669 | qDebug((*it).latin1()); | 703 | qDebug((*it).latin1()); |
670 | stream << (*it) << '\n'; | 704 | stream << (*it) << '\n'; |
671 | } | 705 | } |
672 | } | 706 | } |
673 | file.close(); | 707 | file.close(); |
674 | return true; | 708 | return true; |
675 | } | 709 | } |
676 | 710 | ||
677 | // interfaces.cpp | 711 | // interfaces.cpp |
678 | 712 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index b40d101..e844d8a 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -1,202 +1,206 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | 3 | ||
4 | #include <qcheckbox.h> | 4 | #include <qcheckbox.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qspinbox.h> | 6 | #include <qspinbox.h> |
7 | #include <qgroupbox.h> | 7 | #include <qgroupbox.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | 9 | ||
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | 11 | ||
12 | #include <opie/oprocess.h> | 12 | #include <opie/oprocess.h> |
13 | 13 | ||
14 | #ifdef QWS | 14 | #ifdef QWS |
15 | #include <opie/owait.h> | 15 | #include <opie/owait.h> |
16 | #include <qpe/global.h> | 16 | #include <qpe/global.h> |
17 | #include <qapplication.h> | 17 | #include <qapplication.h> |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | #define DNSSCRIPT "changedns" | 20 | #define DNSSCRIPT "changedns" |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Constuctor. Set up the connection. A profile must be set. | 23 | * Constuctor. Set up the connection. A profile must be set. |
24 | */ | 24 | */ |
25 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ | 25 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, Interfaces *j, WFlags fl) : InterfaceSetup(parent, name, fl), interface(i), interfaces(j), delInterfaces(false){ |
26 | if (j == 0) { | 26 | if (j == 0) { |
27 | delInterfaces = true; | 27 | delInterfaces = true; |
28 | interfaces = new Interfaces; | 28 | interfaces = new Interfaces; |
29 | } | 29 | } |
30 | } | 30 | } |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Destructor | 33 | * Destructor |
34 | */ | 34 | */ |
35 | InterfaceSetupImp::~InterfaceSetupImp(){ | 35 | InterfaceSetupImp::~InterfaceSetupImp(){ |
36 | if(delInterfaces) { | 36 | if(delInterfaces) { |
37 | delete interfaces; | 37 | delete interfaces; |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Save the current settings, then write out the interfaces file and close. | 42 | * Save the current settings, then write out the interfaces file and close. |
43 | */ | 43 | */ |
44 | bool InterfaceSetupImp::saveChanges(){ | 44 | bool InterfaceSetupImp::saveChanges(){ |
45 | bool error; | 45 | bool error; |
46 | QString iface = interfaces->getInterfaceName(error); | 46 | QString iface = interfaces->getInterfaceName(error); |
47 | qDebug("InterfaceSetupImp::saveChanges saves interface %s", iface.latin1() ); | ||
47 | if(!saveSettings()) | 48 | if(!saveSettings()) |
48 | return false; | 49 | return false; |
49 | 50 | ||
50 | interfaces->write(); | 51 | interfaces->write(); |
51 | 52 | ||
52 | if (interface->getStatus()) { | 53 | if (interface->getStatus()) { |
53 | QString ifup; | 54 | QString ifup; |
54 | ifup += "ifdown "; | 55 | ifup += "ifdown "; |
55 | ifup += iface; | 56 | ifup += iface; |
56 | ifup += "; ifup "; | 57 | ifup += "; ifup "; |
57 | ifup += iface; | 58 | ifup += iface; |
58 | ifup += ";"; | 59 | ifup += ";"; |
59 | 60 | ||
60 | OProcess restart; | 61 | OProcess restart; |
61 | restart << "sh"; | 62 | restart << "sh"; |
62 | restart << "-c"; | 63 | restart << "-c"; |
63 | restart << ifup; | 64 | restart << ifup; |
64 | 65 | ||
65 | OWait *owait = new OWait(); | 66 | OWait *owait = new OWait(); |
66 | Global::statusMessage( tr( "Restarting interface" ) ); | 67 | Global::statusMessage( tr( "Restarting interface" ) ); |
67 | 68 | ||
68 | owait->show(); | 69 | owait->show(); |
69 | qApp->processEvents(); | 70 | qApp->processEvents(); |
70 | 71 | ||
71 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { | 72 | if (!restart.start(OProcess::Block, OProcess::NoCommunication) ) { |
72 | qWarning("unstable to spawn ifdown/ifup"); | 73 | qWarning("unstable to spawn ifdown/ifup"); |
73 | } | 74 | } |
74 | 75 | ||
75 | owait->hide(); | 76 | owait->hide(); |
76 | delete owait; | 77 | delete owait; |
77 | 78 | ||
78 | interface->refresh(); | 79 | interface->refresh(); |
79 | } | 80 | } |
80 | return true; | 81 | return true; |
81 | } | 82 | } |
82 | 83 | ||
83 | /** | 84 | /** |
84 | * Save the settings for the current Interface. | 85 | * Save the settings for the current Interface. |
85 | * @return bool true if successfull, false otherwise | 86 | * @return bool true if successfull, false otherwise |
86 | */ | 87 | */ |
87 | bool InterfaceSetupImp::saveSettings(){ | 88 | bool InterfaceSetupImp::saveSettings(){ |
88 | // eh can't really do anything about it other then return. :-D | 89 | // eh can't really do anything about it other then return. :-D |
89 | if(!interfaces->isInterfaceSet()) | 90 | if(!interfaces->isInterfaceSet()) |
90 | return true; | 91 | return true; |
91 | 92 | ||
92 | bool error = false; | 93 | bool error = false; |
93 | // Loopback case | 94 | // Loopback case |
94 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 95 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
95 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 96 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
96 | return true; | 97 | return true; |
97 | } | 98 | } |
98 | 99 | ||
99 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ | 100 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty())){ |
100 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); | 101 | QMessageBox::information(this, "Not Saved.", "Please fill in the IP address and\n subnet entries.", QMessageBox::Ok); |
101 | return false; | 102 | return false; |
102 | } | 103 | } |
103 | // DHCP | 104 | // DHCP |
104 | if(dhcpCheckBox->isChecked()) { | 105 | if(dhcpCheckBox->isChecked()) { |
105 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 106 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
106 | interfaces->removeInterfaceOption("address"); | 107 | interfaces->removeInterfaceOption("address"); |
107 | interfaces->removeInterfaceOption("netmask"); | 108 | interfaces->removeInterfaceOption("netmask"); |
108 | interfaces->removeInterfaceOption("gateway"); | 109 | interfaces->removeInterfaceOption("gateway"); |
109 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | 110 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); |
110 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); | 111 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r "); |
111 | } else{ | 112 | } else{ |
112 | interfaces->setInterfaceMethod("static"); | 113 | interfaces->setInterfaceMethod("static"); |
113 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 114 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
114 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 115 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
115 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 116 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
116 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ | 117 | if(!firstDNSLineEdit->text().isEmpty() || !secondDNSLineEdit->text().isEmpty()){ |
117 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 118 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
118 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 119 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
119 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 120 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
121 | }else{ | ||
122 | interfaces->removeInterfaceOption("up "DNSSCRIPT" -a "); | ||
123 | interfaces->removeInterfaceOption("down "DNSSCRIPT" -r"); | ||
120 | } | 124 | } |
121 | } | 125 | } |
122 | 126 | ||
123 | // IP Information | 127 | // IP Information |
124 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 128 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
125 | return true; | 129 | return true; |
126 | } | 130 | } |
127 | 131 | ||
128 | /** | 132 | /** |
129 | * The Profile has changed. | 133 | * The Profile has changed. |
130 | * @param QString profile the new profile. | 134 | * @param QString profile the new profile. |
131 | */ | 135 | */ |
132 | void InterfaceSetupImp::setProfile(const QString &profile){ | 136 | void InterfaceSetupImp::setProfile(const QString &profile){ |
133 | /* | 137 | /* |
134 | bool error = false; | 138 | bool error = false; |
135 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 139 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
136 | staticGroupBox->hide(); | 140 | staticGroupBox->hide(); |
137 | dhcpCheckBox->hide(); | 141 | dhcpCheckBox->hide(); |
138 | leaseTime->hide(); | 142 | leaseTime->hide(); |
139 | leaseHoursLabel->hide(); | 143 | leaseHoursLabel->hide(); |
140 | } | 144 | } |
141 | */ | 145 | */ |
142 | 146 | ||
143 | QString newInterfaceName = interface->getInterfaceName(); | 147 | QString newInterfaceName = interface->getInterfaceName(); |
144 | if(profile.length() > 0) | 148 | if(profile.length() > 0) |
145 | newInterfaceName += "_" + profile; | 149 | newInterfaceName += "_" + profile; |
146 | // See if we have to make a interface. | 150 | // See if we have to make a interface. |
147 | if(!interfaces->setInterface(newInterfaceName)){ | 151 | if(!interfaces->setInterface(newInterfaceName)){ |
148 | // Add making for this new interface if need too | 152 | // Add making for this new interface if need too |
149 | if(profile != ""){ | 153 | if(profile != ""){ |
150 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 154 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
151 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 155 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
152 | interfaces->addMapping(interface->getInterfaceName()); | 156 | interfaces->addMapping(interface->getInterfaceName()); |
153 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 157 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
154 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); | 158 | qDebug("InterfaceSetupImp: Added Mapping, but still can't setInterface."); |
155 | return; | 159 | return; |
156 | } | 160 | } |
157 | } | 161 | } |
158 | interfaces->setMap("map", newInterfaceName); | 162 | interfaces->setMap("map", newInterfaceName); |
159 | interfaces->setScript("getprofile.sh"); | 163 | interfaces->setScript("getprofile.sh"); |
160 | } | 164 | } |
161 | else{ | 165 | else{ |
162 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 166 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
163 | if(!interfaces->setInterface(newInterfaceName)){ | 167 | if(!interfaces->setInterface(newInterfaceName)){ |
164 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); | 168 | qDebug("InterfaceSetupImp: Added interface, but still can't setInterface."); |
165 | return; | 169 | return; |
166 | } | 170 | } |
167 | } | 171 | } |
168 | } | 172 | } |
169 | 173 | ||
170 | // We must have a valid interface to get this far so read some settings. | 174 | // We must have a valid interface to get this far so read some settings. |
171 | 175 | ||
172 | // DHCP | 176 | // DHCP |
173 | bool error = false; | 177 | bool error = false; |
174 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 178 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
175 | dhcpCheckBox->setChecked(true); | 179 | dhcpCheckBox->setChecked(true); |
176 | else | 180 | else |
177 | dhcpCheckBox->setChecked(false); | 181 | dhcpCheckBox->setChecked(false); |
178 | 182 | ||
179 | // IP Information | 183 | // IP Information |
180 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 184 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
181 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); | 185 | QString dns = interfaces->getInterfaceOption("up "DNSSCRIPT" -a", error); |
182 | qDebug("dns >%s<",dns.latin1()); | 186 | qDebug("dns >%s<",dns.latin1()); |
183 | if(dns.contains(" ")){ | 187 | if(dns.contains(" ")){ |
184 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 188 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
185 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 189 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
186 | }else firstDNSLineEdit->setText(dns); | 190 | }else firstDNSLineEdit->setText(dns); |
187 | 191 | ||
188 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 192 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
189 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 193 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
190 | if (subnetMaskEdit->text().isEmpty()) | 194 | if (subnetMaskEdit->text().isEmpty()) |
191 | subnetMaskEdit->setText( "255.255.255.0" ); | 195 | subnetMaskEdit->setText( "255.255.255.0" ); |
192 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 196 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
193 | 197 | ||
194 | 198 | ||
195 | 199 | ||
196 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); | 200 | qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1()); |
197 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); | 201 | qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1()); |
198 | 202 | ||
199 | } | 203 | } |
200 | 204 | ||
201 | // interfacesetup.cpp | 205 | // interfacesetup.cpp |
202 | 206 | ||
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 2d714ca..f74cf87 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -1,665 +1,678 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 2 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | #include "interfacesetupimp.h" | 4 | #include "interfacesetupimp.h" |
5 | #include "interfaces.h" | 5 | #include "interfaces.h" |
6 | #include "module.h" | 6 | #include "module.h" |
7 | 7 | ||
8 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
9 | #include <qlistbox.h> | 9 | #include <qlistbox.h> |
10 | #include <qlineedit.h> | 10 | #include <qlineedit.h> |
11 | #include <qlistview.h> | 11 | #include <qlistview.h> |
12 | #include <qheader.h> | 12 | #include <qheader.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qpe/qcopenvelope_qws.h> | 14 | #include <qpe/qcopenvelope_qws.h> |
15 | #include <qtabwidget.h> // in order to disable the profiles tab | 15 | #include <qtabwidget.h> // in order to disable the profiles tab |
16 | #include <qpe/qpeapplication.h> | ||
16 | 17 | ||
17 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
18 | 19 | ||
19 | #ifdef QWS | 20 | #ifdef QWS |
20 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
21 | #include <qpe/qlibrary.h> | 22 | #include <qpe/qlibrary.h> |
22 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | #else | 25 | #else |
25 | #include <klibloader.h> | 26 | #include <klibloader.h> |
26 | #define QLibrary KLibrary | 27 | #define QLibrary KLibrary |
27 | #include <kconfig.h> | 28 | #include <kconfig.h> |
28 | #define Config KConfig | 29 | #define Config KConfig |
29 | #include <kapplication.h> | 30 | #include <kapplication.h> |
30 | #include <kstandarddirs.h> | 31 | #include <kstandarddirs.h> |
31 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
32 | #define showMaximized show | 33 | #define showMaximized show |
33 | #endif | 34 | #endif |
34 | 35 | ||
35 | #if QT_VERSION < 300 | 36 | #if QT_VERSION < 300 |
36 | #include <qlist.h> | 37 | #include <qlist.h> |
37 | #else | 38 | #else |
38 | #include <qptrlist.h> | 39 | #include <qptrlist.h> |
39 | #endif | 40 | #endif |
40 | #include <qdir.h> | 41 | #include <qdir.h> |
41 | #include <qfile.h> | 42 | #include <qfile.h> |
42 | #include <qtextstream.h> | 43 | #include <qtextstream.h> |
43 | #include <qregexp.h> | 44 | #include <qregexp.h> |
44 | 45 | ||
45 | #include <net/if.h> | 46 | #include <net/if.h> |
46 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
47 | #include <sys/socket.h> | 48 | #include <sys/socket.h> |
48 | 49 | ||
49 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 50 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
50 | #define _PROCNETDEV "/proc/net/dev" | 51 | #define _PROCNETDEV "/proc/net/dev" |
51 | 52 | ||
52 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ | 53 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){ |
53 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 54 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
54 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 55 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
55 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 56 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
56 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 57 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
57 | 58 | ||
58 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 59 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
59 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 60 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
60 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 61 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
61 | 62 | ||
62 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 63 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
63 | 64 | ||
64 | //FIXME: disable profiles for the moment: | 65 | //FIXME: disable profiles for the moment: |
65 | // tabWidget->setTabEnabled( tab, false ); | 66 | tabWidget->setTabEnabled( tab, false ); |
66 | 67 | ||
67 | // Load connections. | 68 | // Load connections. |
68 | // /usr/local/kde/lib/libinterfaces.la | 69 | // /usr/local/kde/lib/libinterfaces.la |
69 | #ifdef QWS | 70 | #ifdef QWS |
70 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 71 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
71 | #else | 72 | #else |
72 | loader = KLibLoader::self(); | 73 | loader = KLibLoader::self(); |
73 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 74 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
74 | #endif | 75 | #endif |
75 | getAllInterfaces(); | 76 | getAllInterfaces(); |
76 | 77 | ||
77 | Interfaces i; | 78 | Interfaces i; |
78 | QStringList list = i.getInterfaceList(); | 79 | QStringList list = i.getInterfaceList(); |
79 | QMap<QString, Interface*>::Iterator it; | 80 | QMap<QString, Interface*>::Iterator it; |
80 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 81 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
82 | /* | ||
83 | * we skipped it in getAllInterfaces now | ||
84 | * we need to ignore it as well | ||
85 | */ | ||
86 | if (m_handledIfaces.contains( *ni) ) { | ||
87 | qDebug("Not up iface handled by module"); | ||
88 | continue; | ||
89 | } | ||
81 | bool found = false; | 90 | bool found = false; |
82 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 91 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
83 | if(it.key() == (*ni)) | 92 | if(it.key() == (*ni)) |
84 | found = true; | 93 | found = true; |
85 | } | 94 | } |
86 | if(!found){ | 95 | if(!found){ |
87 | if(!(*ni).contains("_")){ | 96 | if(!(*ni).contains("_")){ |
88 | Interface *i = new Interface(this, *ni, false); | 97 | Interface *i = new Interface(this, *ni, false); |
89 | i->setAttached(false); | 98 | i->setAttached(false); |
90 | i->setHardwareName(tr("Disconnected")); | 99 | i->setHardwareName(tr("Disconnected")); |
91 | interfaceNames.insert(i->getInterfaceName(), i); | 100 | interfaceNames.insert(i->getInterfaceName(), i); |
92 | updateInterface(i); | 101 | updateInterface(i); |
93 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 102 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
94 | } | 103 | } |
95 | } | 104 | } |
96 | } | 105 | } |
97 | 106 | ||
98 | //getInterfaceList(); | 107 | //getInterfaceList(); |
99 | connectionList->header()->hide(); | 108 | connectionList->header()->hide(); |
100 | 109 | ||
101 | Config cfg("NetworkSetup"); | 110 | Config cfg("NetworkSetup"); |
102 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 111 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
103 | for ( QStringList::Iterator it = profiles.begin(); | 112 | for ( QStringList::Iterator it = profiles.begin(); |
104 | it != profiles.end(); ++it) | 113 | it != profiles.end(); ++it) |
105 | profilesList->insertItem((*it)); | 114 | profilesList->insertItem((*it)); |
106 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 115 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
107 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 116 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
108 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 117 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
109 | 118 | ||
110 | QFile file(scheme); | 119 | QFile file(scheme); |
111 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 120 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
112 | QTextStream stream( &file ); // use a text stream | 121 | QTextStream stream( &file ); // use a text stream |
113 | while ( !stream.eof() ) { // until end of file... | 122 | while ( !stream.eof() ) { // until end of file... |
114 | QString line = stream.readLine(); // line of text excluding '\n' | 123 | QString line = stream.readLine(); // line of text excluding '\n' |
115 | if(line.contains("SCHEME")){ | 124 | if(line.contains("SCHEME")){ |
116 | line = line.mid(7, line.length()); | 125 | line = line.mid(7, line.length()); |
117 | currentProfileLabel->setText(line); | 126 | currentProfileLabel->setText(line); |
118 | break; | 127 | break; |
119 | } | 128 | } |
120 | } | 129 | } |
121 | file.close(); | 130 | file.close(); |
122 | } | 131 | } |
123 | makeChannel(); | 132 | makeChannel(); |
124 | } | 133 | } |
125 | 134 | ||
126 | /** | 135 | /** |
127 | * Deconstructor. Save profiles. Delete loaded libraries. | 136 | * Deconstructor. Save profiles. Delete loaded libraries. |
128 | */ | 137 | */ |
129 | MainWindowImp::~MainWindowImp(){ | 138 | MainWindowImp::~MainWindowImp(){ |
130 | // Save profiles. | 139 | // Save profiles. |
131 | Config cfg("NetworkSetup"); | 140 | Config cfg("NetworkSetup"); |
132 | cfg.setGroup("General"); | 141 | cfg.setGroup("General"); |
133 | cfg.writeEntry("Profiles", profiles.join(" ")); | 142 | cfg.writeEntry("Profiles", profiles.join(" ")); |
134 | 143 | ||
135 | // Delete all interfaces that don't have owners. | 144 | // Delete all interfaces that don't have owners. |
136 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 145 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
137 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 146 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
138 | if(iIt.key()->getModuleOwner() == NULL) | 147 | if(iIt.key()->getModuleOwner() == NULL) |
139 | delete iIt.key(); | 148 | delete iIt.key(); |
140 | } | 149 | } |
141 | 150 | ||
142 | #ifdef QWS | 151 | #ifdef QWS |
143 | // Delete Modules and Libraries | 152 | // Delete Modules and Libraries |
144 | QMap<Module*, QLibrary*>::Iterator it; | 153 | QMap<Module*, QLibrary*>::Iterator it; |
145 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 154 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
146 | delete it.key(); | 155 | delete it.key(); |
147 | // I wonder why I can't delete the libraries | 156 | // I wonder why I can't delete the libraries |
148 | // What fucking shit this is. | 157 | // What fucking shit this is. |
149 | //delete it.data(); | 158 | //delete it.data(); |
150 | } | 159 | } |
151 | #else | 160 | #else |
152 | // klibloader automaticly deletes the libraries for us... | 161 | // klibloader automaticly deletes the libraries for us... |
153 | #endif | 162 | #endif |
154 | } | 163 | } |
155 | 164 | ||
156 | /** | 165 | /** |
157 | * Query the kernel for all of the interfaces. | 166 | * Query the kernel for all of the interfaces. |
158 | */ | 167 | */ |
159 | void MainWindowImp::getAllInterfaces(){ | 168 | void MainWindowImp::getAllInterfaces(){ |
160 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 169 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
161 | if(sockfd == -1) | 170 | if(sockfd == -1) |
162 | return; | 171 | return; |
163 | 172 | ||
164 | struct ifreq ifr; | 173 | struct ifreq ifr; |
165 | QStringList ifaces; | 174 | QStringList ifaces; |
166 | QFile procFile(QString(_PROCNETDEV)); | 175 | QFile procFile(QString(_PROCNETDEV)); |
167 | int result; | 176 | int result; |
168 | Interface *i; | 177 | Interface *i; |
169 | 178 | ||
170 | if (! procFile.exists()) { | 179 | if (! procFile.exists()) { |
171 | struct ifreq ifrs[100]; | 180 | struct ifreq ifrs[100]; |
172 | struct ifconf ifc; | 181 | struct ifconf ifc; |
173 | ifc.ifc_len = sizeof(ifrs); | 182 | ifc.ifc_len = sizeof(ifrs); |
174 | ifc.ifc_req = ifrs; | 183 | ifc.ifc_req = ifrs; |
175 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 184 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
176 | 185 | ||
177 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { | 186 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { |
178 | struct ifreq *pifr = &ifrs[i]; | 187 | struct ifreq *pifr = &ifrs[i]; |
179 | 188 | ||
180 | ifaces += pifr->ifr_name; | 189 | ifaces += pifr->ifr_name; |
181 | } | 190 | } |
182 | } else { | 191 | } else { |
183 | procFile.open(IO_ReadOnly); | 192 | procFile.open(IO_ReadOnly); |
184 | QString line; | 193 | QString line; |
185 | QTextStream procTs(&procFile); | 194 | QTextStream procTs(&procFile); |
186 | int loc = -1; | 195 | int loc = -1; |
187 | 196 | ||
188 | procTs.readLine(); // eat a line | 197 | procTs.readLine(); // eat a line |
189 | procTs.readLine(); // eat a line | 198 | procTs.readLine(); // eat a line |
190 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | 199 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { |
191 | if((loc = line.find(":")) != -1) { | 200 | if((loc = line.find(":")) != -1) { |
192 | ifaces += line.left(loc); | 201 | ifaces += line.left(loc); |
193 | } | 202 | } |
194 | } | 203 | } |
195 | } | 204 | } |
196 | 205 | ||
197 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { | 206 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { |
198 | int flags = 0; | 207 | int flags = 0; |
208 | if ( m_handledIfaces.contains( (*it) ) ) { | ||
209 | qDebug(" %s is handled by a module", (*it).latin1() ); | ||
210 | continue; | ||
211 | } | ||
199 | // int family; | 212 | // int family; |
200 | i = NULL; | 213 | i = NULL; |
201 | 214 | ||
202 | strcpy(ifr.ifr_name, (*it).latin1()); | 215 | strcpy(ifr.ifr_name, (*it).latin1()); |
203 | 216 | ||
204 | struct ifreq ifcopy; | 217 | struct ifreq ifcopy; |
205 | ifcopy = ifr; | 218 | ifcopy = ifr; |
206 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 219 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
207 | flags = ifcopy.ifr_flags; | 220 | flags = ifcopy.ifr_flags; |
208 | i = new Interface(this, ifr.ifr_name, false); | 221 | i = new Interface(this, ifr.ifr_name, false); |
209 | i->setAttached(true); | 222 | i->setAttached(true); |
210 | if ((flags & IFF_UP) == IFF_UP) | 223 | if ((flags & IFF_UP) == IFF_UP) |
211 | i->setStatus(true); | 224 | i->setStatus(true); |
212 | else | 225 | else |
213 | i->setStatus(false); | 226 | i->setStatus(false); |
214 | 227 | ||
215 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 228 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
216 | i->setHardwareName("Ethernet"); | 229 | i->setHardwareName("Ethernet"); |
217 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 230 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
218 | i->setHardwareName("Point to Point"); | 231 | i->setHardwareName("Point to Point"); |
219 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 232 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
220 | i->setHardwareName("Multicast"); | 233 | i->setHardwareName("Multicast"); |
221 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 234 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
222 | i->setHardwareName("Loopback"); | 235 | i->setHardwareName("Loopback"); |
223 | else | 236 | else |
224 | i->setHardwareName("Unknown"); | 237 | i->setHardwareName("Unknown"); |
225 | 238 | ||
226 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); | 239 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); |
227 | interfaceNames.insert(i->getInterfaceName(), i); | 240 | interfaceNames.insert(i->getInterfaceName(), i); |
228 | updateInterface(i); | 241 | updateInterface(i); |
229 | connect(i, SIGNAL(updateInterface(Interface *)), | 242 | connect(i, SIGNAL(updateInterface(Interface *)), |
230 | this, SLOT(updateInterface(Interface *))); | 243 | this, SLOT(updateInterface(Interface *))); |
231 | } | 244 | } |
232 | // now lets ask the plugins too ;) | 245 | // now lets ask the plugins too ;) |
233 | QMap<Module*, QLibrary*>::Iterator it; | 246 | QMap<Module*, QLibrary*>::Iterator it; |
234 | QList<Interface> ilist; | 247 | QList<Interface> ilist; |
235 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 248 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
236 | if(it.key()){ | 249 | if(it.key()){ |
237 | ilist = it.key()->getInterfaces(); | 250 | ilist = it.key()->getInterfaces(); |
238 | for( i = ilist.first(); i != 0; i = ilist.next() ){ | 251 | for( i = ilist.first(); i != 0; i = ilist.next() ){ |
239 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | 252 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); |
240 | interfaceNames.insert(i->getInterfaceName(), i); | 253 | interfaceNames.insert(i->getInterfaceName(), i); |
241 | updateInterface(i); | 254 | updateInterface(i); |
242 | connect(i, SIGNAL(updateInterface(Interface *)), | 255 | connect(i, SIGNAL(updateInterface(Interface *)), |
243 | this, SLOT(updateInterface(Interface *))); | 256 | this, SLOT(updateInterface(Interface *))); |
244 | } | 257 | } |
245 | } | 258 | } |
246 | } | 259 | } |
247 | } | 260 | } |
248 | 261 | ||
249 | /** | 262 | /** |
250 | * Load all modules that are found in the path | 263 | * Load all modules that are found in the path |
251 | * @param path a directory that is scaned for any plugins that can be loaded | 264 | * @param path a directory that is scaned for any plugins that can be loaded |
252 | * and attempts to load them | 265 | * and attempts to load them |
253 | */ | 266 | */ |
254 | void MainWindowImp::loadModules(const QString &path){ | 267 | void MainWindowImp::loadModules(const QString &path){ |
255 | #ifdef DEBUG | 268 | #ifdef DEBUG |
256 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); | 269 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); |
257 | #endif | 270 | #endif |
258 | QDir d(path); | 271 | QDir d(path); |
259 | if(!d.exists()) | 272 | if(!d.exists()) |
260 | return; | 273 | return; |
261 | 274 | ||
262 | // Don't want sym links | 275 | // Don't want sym links |
263 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 276 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
264 | const QFileInfoList *list = d.entryInfoList(); | 277 | const QFileInfoList *list = d.entryInfoList(); |
265 | QFileInfoListIterator it( *list ); | 278 | QFileInfoListIterator it( *list ); |
266 | QFileInfo *fi; | 279 | QFileInfo *fi; |
267 | while ( (fi=it.current()) ) { | 280 | while ( (fi=it.current()) ) { |
268 | #ifdef QWS | 281 | #ifdef QWS |
269 | if(fi->fileName().contains(".so")){ | 282 | if(fi->fileName().contains(".so")){ |
270 | #else | 283 | #else |
271 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ | 284 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ |
272 | #endif | 285 | #endif |
273 | loadPlugin(path + "/" + fi->fileName()); | 286 | loadPlugin(path + "/" + fi->fileName()); |
274 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); | 287 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); |
275 | } | 288 | } |
276 | ++it; | 289 | ++it; |
277 | } | 290 | } |
278 | } | 291 | } |
279 | 292 | ||
280 | /** | 293 | /** |
281 | * Attempt to load a function and resolve a function. | 294 | * Attempt to load a function and resolve a function. |
282 | * @param pluginFileName - the name of the file in which to attempt to load | 295 | * @param pluginFileName - the name of the file in which to attempt to load |
283 | * @param resolveString - function pointer to resolve | 296 | * @param resolveString - function pointer to resolve |
284 | * @return pointer to the function with name resolveString or NULL | 297 | * @return pointer to the function with name resolveString or NULL |
285 | */ | 298 | */ |
286 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ | 299 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ |
287 | #ifdef DEBUG | 300 | #ifdef DEBUG |
288 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); | 301 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); |
289 | #endif | 302 | #endif |
290 | #ifdef QWS | 303 | #ifdef QWS |
291 | QLibrary *lib = new QLibrary(pluginFileName); | 304 | QLibrary *lib = new QLibrary(pluginFileName); |
292 | void *functionPointer = lib->resolve(resolveString); | 305 | void *functionPointer = lib->resolve(resolveString); |
293 | if( !functionPointer ){ | 306 | if( !functionPointer ){ |
294 | #ifdef DEBUG | 307 | #ifdef DEBUG |
295 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); | 308 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); |
296 | #endif | 309 | #endif |
297 | delete lib; | 310 | delete lib; |
298 | return NULL; | 311 | return NULL; |
299 | } | 312 | } |
300 | // Try to get an object. | 313 | // Try to get an object. |
301 | Module *object = ((Module* (*)()) functionPointer)(); | 314 | Module *object = ((Module* (*)()) functionPointer)(); |
302 | if(object == NULL){ | 315 | if(object == NULL){ |
303 | #ifdef DEBUG | 316 | #ifdef DEBUG |
304 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 317 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
305 | #endif | 318 | #endif |
306 | delete lib; | 319 | delete lib; |
307 | return NULL; | 320 | return NULL; |
308 | } | 321 | } |
309 | 322 | ||
323 | m_handledIfaces += object->handledInterfaceNames(); | ||
310 | // Store for deletion later | 324 | // Store for deletion later |
311 | libraries.insert(object, lib); | 325 | libraries.insert(object, lib); |
312 | return object; | 326 | return object; |
313 | 327 | ||
314 | #else | 328 | #else |
315 | QLibrary *lib = loader->library(pluginFileName); | 329 | QLibrary *lib = loader->library(pluginFileName); |
316 | if( !lib || !lib->hasSymbol(resolveString) ){ | 330 | if( !lib || !lib->hasSymbol(resolveString) ){ |
317 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 331 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
318 | return NULL; | 332 | return NULL; |
319 | } | 333 | } |
320 | // Try to get an object. | 334 | // Try to get an object. |
321 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); | 335 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); |
322 | if(object == NULL){ | 336 | if(object == NULL){ |
323 | #ifdef DEBUG | 337 | #ifdef DEBUG |
324 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 338 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
325 | #endif | 339 | #endif |
326 | return NULL; | 340 | return NULL; |
327 | } | 341 | } |
328 | #ifdef DEBUG | 342 | #ifdef DEBUG |
329 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); | 343 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); |
330 | #endif | 344 | #endif |
331 | // Store for deletion later | 345 | // Store for deletion later |
332 | libraries.insert(object, lib); | 346 | libraries.insert(object, lib); |
333 | return object; | 347 | return object; |
334 | #endif | 348 | #endif |
335 | } | 349 | } |
336 | 350 | ||
337 | /** | 351 | /** |
338 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 352 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
339 | * load the plugin and append it to the list | 353 | * load the plugin and append it to the list |
340 | */ | 354 | */ |
341 | void MainWindowImp::addClicked(){ | 355 | void MainWindowImp::addClicked(){ |
342 | QMap<Module*, QLibrary*>::Iterator it; | 356 | QMap<Module*, QLibrary*>::Iterator it; |
343 | QMap<QString, QString> list; | 357 | QMap<QString, QString> list; |
344 | QMap<QString, Module*> newInterfaceOwners; | 358 | QMap<QString, Module*> newInterfaceOwners; |
345 | 359 | ||
346 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 360 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
347 | if(it.key()){ | 361 | if(it.key()){ |
348 | (it.key())->possibleNewInterfaces(list); | 362 | (it.key())->possibleNewInterfaces(list); |
349 | } | 363 | } |
350 | } | 364 | } |
351 | // See if the list has anything that we can add. | 365 | // See if the list has anything that we can add. |
352 | if(list.count() == 0){ | 366 | if(list.count() == 0){ |
353 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 367 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
354 | return; | 368 | return; |
355 | } | 369 | } |
356 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 370 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
357 | addNewConnection.addConnections(list); | 371 | addNewConnection.addConnections(list); |
358 | addNewConnection.showMaximized(); | 372 | addNewConnection.showMaximized(); |
359 | if(QDialog::Accepted == addNewConnection.exec()){ | 373 | if(QDialog::Accepted == addNewConnection.exec()){ |
360 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 374 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
361 | if(!item) | 375 | if(!item) |
362 | return; | 376 | return; |
363 | 377 | ||
364 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 378 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
365 | if(it.key()){ | 379 | if(it.key()){ |
366 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 380 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
367 | if(i){ | 381 | if(i){ |
368 | qDebug("iface name %s",i->getInterfaceName().latin1()); | 382 | qDebug("iface name %s",i->getInterfaceName().latin1()); |
369 | interfaceNames.insert(i->getInterfaceName(), i); | 383 | interfaceNames.insert(i->getInterfaceName(), i); |
370 | updateInterface(i); | 384 | updateInterface(i); |
371 | } | 385 | } |
372 | } | 386 | } |
373 | } | 387 | } |
374 | } | 388 | } |
375 | } | 389 | } |
376 | 390 | ||
377 | /** | 391 | /** |
378 | * Prompt the user to see if they really want to do this. | 392 | * Prompt the user to see if they really want to do this. |
379 | * If they do then remove from the list and unload. | 393 | * If they do then remove from the list and unload. |
380 | */ | 394 | */ |
381 | void MainWindowImp::removeClicked(){ | 395 | void MainWindowImp::removeClicked(){ |
382 | QListViewItem *item = connectionList->currentItem(); | 396 | QListViewItem *item = connectionList->currentItem(); |
383 | if(!item) { | 397 | if(!item) { |
384 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 398 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
385 | return; | 399 | return; |
386 | } | 400 | } |
387 | 401 | ||
388 | Interface *i = interfaceItems[item]; | 402 | Interface *i = interfaceItems[item]; |
389 | if(i->getModuleOwner() == NULL){ | 403 | if(i->getModuleOwner() == NULL){ |
390 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 404 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
391 | } | 405 | } |
392 | else{ | 406 | else{ |
393 | if(!i->getModuleOwner()->remove(i)) | 407 | if(!i->getModuleOwner()->remove(i)) |
394 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 408 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
395 | else{ | 409 | else{ |
396 | delete item; | 410 | delete item; |
397 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 411 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
398 | } | 412 | } |
399 | } | 413 | } |
400 | } | 414 | } |
401 | 415 | ||
402 | /** | 416 | /** |
403 | * Pull up the configure about the currently selected interface. | 417 | * Pull up the configure about the currently selected interface. |
404 | * Report an error if no interface is selected. | 418 | * Report an error if no interface is selected. |
405 | * If the interface has a module owner then request its configure. | 419 | * If the interface has a module owner then request its configure. |
406 | */ | 420 | */ |
407 | void MainWindowImp::configureClicked(){ | 421 | void MainWindowImp::configureClicked(){ |
408 | QListViewItem *item = connectionList->currentItem(); | 422 | QListViewItem *item = connectionList->currentItem(); |
409 | if(!item){ | 423 | if(!item){ |
410 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 424 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
411 | return; | 425 | return; |
412 | } | 426 | } |
413 | 427 | ||
414 | QString currentProfileText = currentProfileLabel->text(); | 428 | QString currentProfileText = currentProfileLabel->text(); |
415 | if(currentProfileText.upper() == "ALL"); | 429 | if(currentProfileText.upper() == "ALL"); |
416 | currentProfileText = ""; | 430 | currentProfileText = ""; |
417 | 431 | ||
418 | Interface *i = interfaceItems[item]; | 432 | Interface *i = interfaceItems[item]; |
419 | 433 | ||
420 | if(i->getModuleOwner()){ | 434 | if(i->getModuleOwner()){ |
421 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 435 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
422 | if(moduleConfigure != NULL){ | 436 | if(moduleConfigure != NULL){ |
423 | i->getModuleOwner()->setProfile(currentProfileText); | 437 | i->getModuleOwner()->setProfile(currentProfileText); |
424 | moduleConfigure->showMaximized(); | 438 | moduleConfigure->showMaximized(); |
425 | return; | 439 | return; |
426 | } | 440 | } |
427 | } | 441 | } |
428 | 442 | ||
429 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); | 443 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
430 | configure->setProfile(currentProfileText); | 444 | configure->setProfile(currentProfileText); |
431 | configure->showMaximized(); | 445 | configure->showMaximized(); |
432 | } | 446 | } |
433 | 447 | ||
434 | /** | 448 | /** |
435 | * Pull up the information about the currently selected interface. | 449 | * Pull up the information about the currently selected interface. |
436 | * Report an error if no interface is selected. | 450 | * Report an error if no interface is selected. |
437 | * If the interface has a module owner then request its configure. | 451 | * If the interface has a module owner then request its configure. |
438 | */ | 452 | */ |
439 | void MainWindowImp::informationClicked(){ | 453 | void MainWindowImp::informationClicked(){ |
440 | QListViewItem *item = connectionList->currentItem(); | 454 | QListViewItem *item = connectionList->currentItem(); |
441 | if(!item){ | 455 | if(!item){ |
442 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 456 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
443 | return; | 457 | return; |
444 | } | 458 | } |
445 | 459 | ||
446 | Interface *i = interfaceItems[item]; | 460 | Interface *i = interfaceItems[item]; |
447 | // if(!i->isAttached()){ | 461 | // if(!i->isAttached()){ |
448 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 462 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
449 | // return; | 463 | // return; |
450 | // } | 464 | // } |
451 | 465 | ||
452 | if(i->getModuleOwner()){ | 466 | if(i->getModuleOwner()){ |
453 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 467 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
454 | if(moduleInformation != NULL){ | 468 | if(moduleInformation != NULL){ |
455 | moduleInformation->showMaximized(); | 469 | moduleInformation->showMaximized(); |
456 | #ifdef DEBUG | 470 | #ifdef DEBUG |
457 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 471 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
458 | #endif | 472 | #endif |
459 | return; | 473 | return; |
460 | } | 474 | } |
461 | } | 475 | } |
462 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); | 476 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); |
463 | information->showMaximized(); | 477 | information->showMaximized(); |
464 | } | 478 | } |
465 | 479 | ||
466 | /** | 480 | /** |
467 | * Update this interface. If no QListViewItem exists create one. | 481 | * Update this interface. If no QListViewItem exists create one. |
468 | * @param Interface* pointer to the interface that needs to be updated. | 482 | * @param Interface* pointer to the interface that needs to be updated. |
469 | */ | 483 | */ |
470 | void MainWindowImp::updateInterface(Interface *i){ | 484 | void MainWindowImp::updateInterface(Interface *i){ |
471 | if(!advancedUserMode){ | 485 | if(!advancedUserMode){ |
472 | if(i->getInterfaceName() == "lo") | 486 | if(i->getInterfaceName() == "lo") |
473 | return; | 487 | return; |
474 | } | 488 | } |
475 | 489 | ||
476 | QListViewItem *item = NULL; | 490 | QListViewItem *item = NULL; |
477 | 491 | ||
478 | // Find the interface, making it if needed. | 492 | // Find the interface, making it if needed. |
479 | if(items.find(i) == items.end()){ | 493 | if(items.find(i) == items.end()){ |
480 | item = new QListViewItem(connectionList, "", "", ""); | 494 | item = new QListViewItem(connectionList, "", "", ""); |
481 | // See if you can't find a module owner for this interface | 495 | // See if you can't find a module owner for this interface |
482 | QMap<Module*, QLibrary*>::Iterator it; | 496 | QMap<Module*, QLibrary*>::Iterator it; |
483 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 497 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
484 | if(it.key()->isOwner(i)) | 498 | if(it.key()->isOwner(i)) |
485 | i->setModuleOwner(it.key()); | 499 | i->setModuleOwner(it.key()); |
486 | } | 500 | } |
487 | items.insert(i, item); | 501 | items.insert(i, item); |
488 | interfaceItems.insert(item, i); | 502 | interfaceItems.insert(item, i); |
489 | } | 503 | } |
490 | else | 504 | else |
491 | item = items[i]; | 505 | item = items[i]; |
492 | 506 | ||
493 | // Update the icons and information | 507 | // Update the icons and information |
494 | #ifdef QWS | 508 | #ifdef QWS |
495 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 509 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
496 | #else | 510 | #else |
497 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 511 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
498 | #endif | 512 | #endif |
499 | 513 | ||
500 | QString typeName = "lan"; | 514 | QString typeName = "lan"; |
501 | if(i->getInterfaceName() == "lo") | 515 | if(i->getInterfaceName() == "lo") |
502 | typeName = "lo"; | 516 | typeName = "lo"; |
503 | if(i->getInterfaceName().contains("irda")) | 517 | if(i->getInterfaceName().contains("irda")) |
504 | typeName = "irda"; | 518 | typeName = "irda"; |
505 | if(i->getInterfaceName().contains("wlan")) | 519 | if(i->getInterfaceName().contains("wlan")) |
506 | typeName = "wlan"; | 520 | typeName = "wlan"; |
507 | if(i->getInterfaceName().contains("usb")) | 521 | if(i->getInterfaceName().contains("usb")) |
508 | typeName = "usb"; | 522 | typeName = "usb"; |
509 | 523 | ||
510 | if(!i->isAttached()) | 524 | if(!i->isAttached()) |
511 | typeName = "connect_no"; | 525 | typeName = "connect_no"; |
512 | // Actually try to use the Module | 526 | // Actually try to use the Module |
513 | if(i->getModuleOwner() != NULL) | 527 | if(i->getModuleOwner() != NULL) |
514 | typeName = i->getModuleOwner()->getPixmapName(i); | 528 | typeName = i->getModuleOwner()->getPixmapName(i); |
515 | 529 | ||
516 | #ifdef QWS | 530 | #ifdef QWS |
517 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 531 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
518 | #else | 532 | #else |
519 | item->setPixmap(1, (SmallIcon(typeName))); | 533 | item->setPixmap(1, (SmallIcon(typeName))); |
520 | #endif | 534 | #endif |
521 | item->setText(2, i->getHardwareName()); | 535 | item->setText(2, i->getHardwareName()); |
522 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 536 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
523 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 537 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
524 | } | 538 | } |
525 | 539 | ||
526 | void MainWindowImp::newProfileChanged(const QString& newText){ | 540 | void MainWindowImp::newProfileChanged(const QString& newText){ |
527 | if(newText.length() > 0) | 541 | if(newText.length() > 0) |
528 | newProfileButton->setEnabled(true); | 542 | newProfileButton->setEnabled(true); |
529 | else | 543 | else |
530 | newProfileButton->setEnabled(false); | 544 | newProfileButton->setEnabled(false); |
531 | } | 545 | } |
532 | 546 | ||
533 | /** | 547 | /** |
534 | * Adds a new profile to the list of profiles. | 548 | * Adds a new profile to the list of profiles. |
535 | * Don't add profiles that already exists. | 549 | * Don't add profiles that already exists. |
536 | * Appends to the list and QStringList | 550 | * Appends to the list and QStringList |
537 | */ | 551 | */ |
538 | void MainWindowImp::addProfile(){ | 552 | void MainWindowImp::addProfile(){ |
539 | QString newProfileName = newProfile->text(); | 553 | QString newProfileName = newProfile->text(); |
540 | if(profiles.grep(newProfileName).count() > 0){ | 554 | if(profiles.grep(newProfileName).count() > 0){ |
541 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 555 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
542 | return; | 556 | return; |
543 | } | 557 | } |
544 | profiles.append(newProfileName); | 558 | profiles.append(newProfileName); |
545 | profilesList->insertItem(newProfileName); | 559 | profilesList->insertItem(newProfileName); |
546 | } | 560 | } |
547 | 561 | ||
548 | /** | 562 | /** |
549 | * Removes the currently selected profile in the combo. | 563 | * Removes the currently selected profile in the combo. |
550 | * Doesn't delete if there are less then 2 profiles. | 564 | * Doesn't delete if there are less then 2 profiles. |
551 | */ | 565 | */ |
552 | void MainWindowImp::removeProfile(){ | 566 | void MainWindowImp::removeProfile(){ |
553 | if(profilesList->count() <= 1){ | 567 | if(profilesList->count() <= 1){ |
554 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 568 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
555 | return; | 569 | return; |
556 | } | 570 | } |
557 | QString profileToRemove = profilesList->currentText(); | 571 | QString profileToRemove = profilesList->currentText(); |
558 | if(profileToRemove == "All"){ | 572 | if(profileToRemove == "All"){ |
559 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 573 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
560 | return; | 574 | return; |
561 | } | 575 | } |
562 | // Can't remove the curent profile | 576 | // Can't remove the curent profile |
563 | if(profileToRemove == currentProfileLabel->text()){ | 577 | if(profileToRemove == currentProfileLabel->text()){ |
564 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 578 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
565 | return; | 579 | return; |
566 | 580 | ||
567 | } | 581 | } |
568 | 582 | ||
569 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 583 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
570 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 584 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
571 | profilesList->clear(); | 585 | profilesList->clear(); |
572 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 586 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
573 | profilesList->insertItem((*it)); | 587 | profilesList->insertItem((*it)); |
574 | 588 | ||
575 | // Remove any interface settings and mappings. | 589 | // Remove any interface settings and mappings. |
576 | Interfaces interfaces; | 590 | Interfaces interfaces; |
577 | // Go through them one by one | 591 | // Go through them one by one |
578 | QMap<Interface*, QListViewItem*>::Iterator it; | 592 | QMap<Interface*, QListViewItem*>::Iterator it; |
579 | for( it = items.begin(); it != items.end(); ++it ){ | 593 | for( it = items.begin(); it != items.end(); ++it ){ |
580 | QString interfaceName = it.key()->getInterfaceName(); | 594 | QString interfaceName = it.key()->getInterfaceName(); |
581 | qDebug(interfaceName.latin1()); | 595 | qDebug(interfaceName.latin1()); |
582 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 596 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
583 | interfaces.removeInterface(); | 597 | interfaces.removeInterface(); |
584 | if(interfaces.setMapping(interfaceName)){ | 598 | if(interfaces.setMapping(interfaceName)){ |
585 | if(profilesList->count() == 1) | 599 | if(profilesList->count() == 1) |
586 | interfaces.removeMapping(); | 600 | interfaces.removeMapping(); |
587 | else{ | 601 | else{ |
588 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 602 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
589 | } | 603 | } |
590 | } | 604 | } |
591 | interfaces.write(); | 605 | interfaces.write(); |
592 | break; | 606 | break; |
593 | } | 607 | } |
594 | } | 608 | } |
595 | } | 609 | } |
596 | } | 610 | } |
597 | 611 | ||
598 | /** | 612 | /** |
599 | * A new profile has been selected, change. | 613 | * A new profile has been selected, change. |
600 | * @param newProfile the new profile. | 614 | * @param newProfile the new profile. |
601 | */ | 615 | */ |
602 | void MainWindowImp::changeProfile(){ | 616 | void MainWindowImp::changeProfile(){ |
603 | if(profilesList->currentItem() == -1){ | 617 | if(profilesList->currentItem() == -1){ |
604 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 618 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
605 | return; | 619 | return; |
606 | } | 620 | } |
607 | QString newProfile = profilesList->text(profilesList->currentItem()); | 621 | QString newProfile = profilesList->text(profilesList->currentItem()); |
608 | if(newProfile != currentProfileLabel->text()){ | 622 | if(newProfile != currentProfileLabel->text()){ |
609 | currentProfileLabel->setText(newProfile); | 623 | currentProfileLabel->setText(newProfile); |
610 | QFile::remove(scheme); | 624 | QFile::remove(scheme); |
611 | QFile file(scheme); | 625 | QFile file(scheme); |
612 | if ( file.open(IO_ReadWrite) ) { | 626 | if ( file.open(IO_ReadWrite) ) { |
613 | QTextStream stream( &file ); | 627 | QTextStream stream( &file ); |
614 | stream << QString("SCHEME=%1").arg(newProfile); | 628 | stream << QString("SCHEME=%1").arg(newProfile); |
615 | file.close(); | 629 | file.close(); |
616 | } | 630 | } |
617 | // restart all up devices? | 631 | // restart all up devices? |
618 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 632 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
619 | // Go through them one by one | 633 | // Go through them one by one |
620 | QMap<Interface*, QListViewItem*>::Iterator it; | 634 | QMap<Interface*, QListViewItem*>::Iterator it; |
621 | for( it = items.begin(); it != items.end(); ++it ){ | 635 | for( it = items.begin(); it != items.end(); ++it ){ |
622 | if(it.key()->getStatus() == true) | 636 | if(it.key()->getStatus() == true) |
623 | it.key()->restart(); | 637 | it.key()->restart(); |
624 | } | 638 | } |
625 | } | 639 | } |
626 | } | 640 | } |
627 | // TODO change the profile in the modules | 641 | // TODO change the profile in the modules |
628 | } | 642 | } |
629 | 643 | ||
630 | 644 | ||
631 | void MainWindowImp::makeChannel() | 645 | void MainWindowImp::makeChannel() |
632 | { | 646 | { |
633 | channel = new QCopChannel( "QPE/Application/networksettings", this ); | 647 | channel = new QCopChannel( "QPE/Application/networksettings", this ); |
634 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 648 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
635 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 649 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
636 | } | 650 | } |
637 | 651 | ||
638 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | 652 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) |
639 | { | 653 | { |
640 | bool found = false; | 654 | bool found = false; |
641 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); | 655 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); |
642 | |||
643 | if (msg == "raise") { | 656 | if (msg == "raise") { |
644 | raise(); | 657 | raise(); |
645 | return; | 658 | return; |
646 | } | 659 | } |
647 | 660 | ||
648 | QString dest = msg.left(msg.find("(")); | 661 | QString dest = msg.left(msg.find("(")); |
649 | QCString param = msg.right(msg.length() - msg.find("(") - 1); | 662 | QCString param = msg.right(msg.length() - msg.find("(") - 1); |
650 | param = param.left( param.length() - 1 ); | 663 | param = param.left( param.length() - 1 ); |
651 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); | 664 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); |
652 | 665 | ||
653 | QMap<Module*, QLibrary*>::Iterator it; | 666 | QMap<Module*, QLibrary*>::Iterator it; |
654 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 667 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
655 | qDebug("plugin >%s<", it.key()->type().latin1() ); | 668 | qDebug("plugin >%s<", it.key()->type().latin1() ); |
656 | if(it.key()->type() == dest){ | 669 | if(it.key()->type() == dest){ |
657 | it.key()->receive( param, arg ); | 670 | it.key()->receive( param, arg ); |
658 | found = true; | 671 | found = true; |
659 | } | 672 | } |
660 | } | 673 | } |
661 | 674 | ||
662 | 675 | ||
663 | if (found) QPEApplication::setKeepRunning(); | 676 | if (found) QPEApplication::setKeepRunning(); |
664 | else qDebug("Huh what do ya want"); | 677 | else qDebug("Huh what do ya want"); |
665 | } | 678 | } |
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h index a553f75..451835b 100644 --- a/noncore/settings/networksettings/mainwindowimp.h +++ b/noncore/settings/networksettings/mainwindowimp.h | |||
@@ -1,73 +1,74 @@ | |||
1 | #ifndef MAINWINOWIMP_H | 1 | #ifndef MAINWINOWIMP_H |
2 | #define MAINWINOWIMP_H | 2 | #define MAINWINOWIMP_H |
3 | 3 | ||
4 | #include "mainwindow.h" | 4 | #include "mainwindow.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | 7 | ||
8 | class Module; | 8 | class Module; |
9 | class Interface; | 9 | class Interface; |
10 | class QLibrary; | 10 | class QLibrary; |
11 | class KProcess; | 11 | class KProcess; |
12 | class QCopChannel; | 12 | class QCopChannel; |
13 | #ifdef QWS | 13 | #ifdef QWS |
14 | class QLibrary; | 14 | class QLibrary; |
15 | #else | 15 | #else |
16 | class KLibrary; | 16 | class KLibrary; |
17 | class KLibLoader; | 17 | class KLibLoader; |
18 | #define QLibrary KLibrary | 18 | #define QLibrary KLibrary |
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | 21 | ||
22 | class MainWindowImp : public MainWindow { | 22 | class MainWindowImp : public MainWindow { |
23 | Q_OBJECT | 23 | Q_OBJECT |
24 | 24 | ||
25 | public: | 25 | public: |
26 | MainWindowImp(QWidget *parent=0, const char *name=0); | 26 | MainWindowImp(QWidget *parent=0, const char *name=0); |
27 | ~MainWindowImp(); | 27 | ~MainWindowImp(); |
28 | 28 | ||
29 | QCopChannel *channel; | 29 | QCopChannel *channel; |
30 | 30 | ||
31 | private slots: | 31 | private slots: |
32 | void getAllInterfaces(); | 32 | void getAllInterfaces(); |
33 | 33 | ||
34 | void addClicked(); | 34 | void addClicked(); |
35 | void removeClicked(); | 35 | void removeClicked(); |
36 | void configureClicked(); | 36 | void configureClicked(); |
37 | void informationClicked(); | 37 | void informationClicked(); |
38 | 38 | ||
39 | void addProfile(); | 39 | void addProfile(); |
40 | void removeProfile(); | 40 | void removeProfile(); |
41 | void changeProfile(); | 41 | void changeProfile(); |
42 | 42 | ||
43 | void updateInterface(Interface *i); | 43 | void updateInterface(Interface *i); |
44 | void newProfileChanged(const QString& newText); | 44 | void newProfileChanged(const QString& newText); |
45 | 45 | ||
46 | void receive (const QCString &, const QByteArray &); | 46 | void receive (const QCString &, const QByteArray &); |
47 | 47 | ||
48 | private: | 48 | private: |
49 | void makeChannel(); | 49 | void makeChannel(); |
50 | void loadModules(const QString &path); | 50 | void loadModules(const QString &path); |
51 | 51 | ||
52 | Module* loadPlugin(const QString &pluginFileName, | 52 | Module* loadPlugin(const QString &pluginFileName, |
53 | const QString &resolveString = "create_plugin"); | 53 | const QString &resolveString = "create_plugin"); |
54 | 54 | ||
55 | // For our local list of names | 55 | // For our local list of names |
56 | QMap<QString, Interface*> interfaceNames; | 56 | QMap<QString, Interface*> interfaceNames; |
57 | 57 | ||
58 | QMap<Module*, QLibrary*> libraries; | 58 | QMap<Module*, QLibrary*> libraries; |
59 | QMap<Interface*, QListViewItem*> items; | 59 | QMap<Interface*, QListViewItem*> items; |
60 | QMap<QListViewItem*, Interface*> interfaceItems; | 60 | QMap<QListViewItem*, Interface*> interfaceItems; |
61 | 61 | QStringList m_handledIfaces; | |
62 | |||
62 | QMap<KProcess*, QString> threads; | 63 | QMap<KProcess*, QString> threads; |
63 | QStringList profiles; | 64 | QStringList profiles; |
64 | 65 | ||
65 | bool advancedUserMode; | 66 | bool advancedUserMode; |
66 | QString scheme; | 67 | QString scheme; |
67 | #ifndef QWS | 68 | #ifndef QWS |
68 | KLibLoader *loader; | 69 | KLibLoader *loader; |
69 | #endif | 70 | #endif |
70 | }; | 71 | }; |
71 | 72 | ||
72 | #endif // MAINWINOWIMP_H | 73 | #endif // MAINWINOWIMP_H |
73 | 74 | ||
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h index db74394..f7d8046 100644 --- a/noncore/settings/networksettings/module.h +++ b/noncore/settings/networksettings/module.h | |||
@@ -1,102 +1,113 @@ | |||
1 | #ifndef NETCONF_MODULE_H | 1 | #ifndef NETCONF_MODULE_H |
2 | #define NETCONF_MODULE_H | 2 | #define NETCONF_MODULE_H |
3 | 3 | ||
4 | #include <qobject.h> | 4 | #include <qobject.h> |
5 | #if QT_VERSION < 300 | 5 | #if QT_VERSION < 300 |
6 | #include <qlist.h> | 6 | #include <qlist.h> |
7 | #else | 7 | #else |
8 | #include <qptrlist.h> | 8 | #include <qptrlist.h> |
9 | #endif | 9 | #endif |
10 | #include <qmap.h> | 10 | #include <qmap.h> |
11 | #include "interface.h" | 11 | #include "interface.h" |
12 | 12 | ||
13 | class QWidget; | 13 | class QWidget; |
14 | class QTabWidget; | 14 | class QTabWidget; |
15 | 15 | ||
16 | class Module : QObject{ | 16 | class Module : QObject{ |
17 | 17 | ||
18 | signals: | 18 | signals: |
19 | void updateInterface(Interface *i); | 19 | void updateInterface(Interface *i); |
20 | 20 | ||
21 | 21 | ||
22 | public: | 22 | public: |
23 | Module(){}; | 23 | Module(){}; |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * The type of the plugin | 26 | * The type of the plugin |
27 | * and the name of the dcop call | 27 | * and the name of the dcop call |
28 | */ | 28 | */ |
29 | virtual const QString type() = 0; | 29 | virtual const QString type() = 0; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * The current profile has been changed and the module should do any | 32 | * The current profile has been changed and the module should do any |
33 | * neccesary changes also. | 33 | * neccesary changes also. |
34 | * @param newProfile what the profile should be changed to. | 34 | * @param newProfile what the profile should be changed to. |
35 | */ | 35 | */ |
36 | virtual void setProfile(const QString &newProfile) = 0; | 36 | virtual void setProfile(const QString &newProfile) = 0; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * get the icon name for this device. | 39 | * get the icon name for this device. |
40 | * @param Interface* can be used in determining the icon. | 40 | * @param Interface* can be used in determining the icon. |
41 | * @return QString the icon name (minus .png, .gif etc) | 41 | * @return QString the icon name (minus .png, .gif etc) |
42 | */ | 42 | */ |
43 | virtual QString getPixmapName(Interface *) = 0; | 43 | virtual QString getPixmapName(Interface *) = 0; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Check to see if the interface i is owned by this module. | 46 | * Check to see if the interface i is owned by this module. |
47 | * @param Interface* interface to check against | 47 | * @param Interface* interface to check against |
48 | * @return bool true if i is owned by this module, false otherwise. | 48 | * @return bool true if i is owned by this module, false otherwise. |
49 | */ | 49 | */ |
50 | virtual bool isOwner(Interface *){ return false; }; | 50 | virtual bool isOwner(Interface *){ return false; }; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Create and return the WLANConfigure Module | 53 | * Create and return the WLANConfigure Module |
54 | * @param Interface *i the interface to configure. | 54 | * @param Interface *i the interface to configure. |
55 | * @return QWidget* pointer to this modules configure. | 55 | * @return QWidget* pointer to this modules configure. |
56 | */ | 56 | */ |
57 | virtual QWidget *configure(Interface *){ return NULL; } ; | 57 | virtual QWidget *configure(Interface *){ return NULL; } ; |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * Create, and return the Information Module | 60 | * Create, and return the Information Module |
61 | * @param Interface *i the interface to get info on. | 61 | * @param Interface *i the interface to get info on. |
62 | * @return QWidget* pointer to this modules info. | 62 | * @return QWidget* pointer to this modules info. |
63 | */ | 63 | */ |
64 | virtual QWidget *information(Interface *){ return NULL; }; | 64 | virtual QWidget *information(Interface *){ return NULL; }; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Get all active (up or down) interfaces | 67 | * Get all active (up or down) interfaces |
68 | * @return QList<Interface> A list of interfaces that exsist that havn't | 68 | * @return QList<Interface> A list of interfaces that exsist that havn't |
69 | * been called by isOwner() | 69 | * been called by isOwner() |
70 | */ | 70 | */ |
71 | virtual QList<Interface> getInterfaces() = 0; | 71 | virtual QList<Interface> getInterfaces() = 0; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), | 74 | * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), |
75 | * modem ppp) | 75 | * modem ppp) |
76 | */ | 76 | */ |
77 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; | 77 | virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Attempts to create a new interface from name | 80 | * Attempts to create a new interface from name |
81 | * @return Interface* NULL if it was unable to be created. | 81 | * @return Interface* NULL if it was unable to be created. |
82 | * @param name the type of interface to create | 82 | * @param name the type of interface to create |
83 | */ | 83 | */ |
84 | virtual Interface *addNewInterface(const QString &name) = 0; | 84 | virtual Interface *addNewInterface(const QString &name) = 0; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Attempts to remove the interface, doesn't delete i | 87 | * Attempts to remove the interface, doesn't delete i |
88 | * @return bool true if successfull, false otherwise. | 88 | * @return bool true if successfull, false otherwise. |
89 | */ | 89 | */ |
90 | virtual bool remove(Interface* i) = 0; | 90 | virtual bool remove(Interface* i) = 0; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * get dcop calls | 93 | * get dcop calls |
94 | */ | 94 | */ |
95 | virtual void receive(const QCString &msg, const QByteArray &arg) = 0; | 95 | virtual void receive(const QCString &msg, const QByteArray &arg) = 0; |
96 | 96 | ||
97 | QStringList handledInterfaceNames()const { return m_inter; } | ||
98 | protected: | ||
99 | /** | ||
100 | * set which interfaceNames should not be shown cause they're handled | ||
101 | * internally of this module.. An already running ppp link or | ||
102 | * a tunnel... | ||
103 | */ | ||
104 | void setHandledInterfaceNames( const QStringList& in) { m_inter = in; } | ||
105 | |||
106 | private: | ||
107 | QStringList m_inter; | ||
97 | }; | 108 | }; |
98 | 109 | ||
99 | #endif | 110 | #endif |
100 | 111 | ||
101 | // module.h | 112 | // module.h |
102 | 113 | ||
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO index 80fc5a6..14a1b3f 100644 --- a/noncore/settings/networksettings/ppp/TODO +++ b/noncore/settings/networksettings/ppp/TODO | |||
@@ -1,9 +1,3 @@ | |||
1 | - ask for password is non is set | 1 | - impl. PPPData::copyaccount |
2 | |||
3 | - stop pppd, i.e. fix interfaceinformationppp | ||
4 | |||
5 | - update modem attribute inputs when modem has changed | ||
6 | - impl. PPPData::copyaccount & PPPData::deleteAccount | ||
7 | |||
8 | - check if the same interface device combination allready exists | 2 | - check if the same interface device combination allready exists |
9 | - fix layout of edit account, i.e. get it shown maximised | 3 | - check if a deleted account or device exists in a config and ask the user |
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index fa1c43b..28d8732 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -1,357 +1,323 @@ | |||
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 <qdir.h> | 27 | #include <qdir.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qtabdialog.h> | 31 | #include <qtabdialog.h> |
32 | #include <qwhatsthis.h> | 32 | #include <qwhatsthis.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | 34 | ||
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <qbuttongroup.h> | 36 | #include <qbuttongroup.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qvgroupbox.h> | 38 | #include <qvgroupbox.h> |
39 | 39 | ||
40 | #include "accounts.h" | 40 | #include "accounts.h" |
41 | #include "authwidget.h" | 41 | #include "authwidget.h" |
42 | #include "pppdata.h" | 42 | #include "pppdata.h" |
43 | #include "edit.h" | 43 | #include "edit.h" |
44 | 44 | ||
45 | void parseargs(char* buf, char** args); | 45 | void parseargs(char* buf, char** args); |
46 | 46 | ||
47 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) | 47 | |
48 | : QWidget( parent, name )//, _pppdata(pd) | 48 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) |
49 | : ChooserWidget( pd, parent, name, f ) | ||
49 | { | 50 | { |
50 | _pppdata = pd; | ||
51 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | ||
52 | accountlist_l = new QListBox(this); | ||
53 | |||
54 | connect(accountlist_l, SIGNAL(highlighted(int)), | ||
55 | this, SLOT(slotListBoxSelect(int))); | ||
56 | connect(accountlist_l, SIGNAL(selected(int)), | ||
57 | this, SLOT(editaccount())); | ||
58 | l1->addWidget(accountlist_l, 10); | ||
59 | |||
60 | edit_b = new QPushButton(tr("&Edit..."), this); | ||
61 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); | ||
62 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); | ||
63 | l1->addWidget(edit_b); | ||
64 | 51 | ||
65 | new_b = new QPushButton(tr("&New..."), this); | 52 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); |
66 | connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); | ||
67 | l1->addWidget(new_b); | ||
68 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" | 53 | QWhatsThis::add(new_b, tr("Create a new dialup connection\n" |
69 | "to the Internet")); | 54 | "to the Internet")); |
70 | |||
71 | copy_b = new QPushButton(tr("Co&py"), this); | ||
72 | connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); | ||
73 | l1->addWidget(copy_b); | ||
74 | QWhatsThis::add(copy_b, | 55 | QWhatsThis::add(copy_b, |
75 | tr("Makes a copy of the selected account. All\n" | 56 | tr("Makes a copy of the selected account. All\n" |
76 | "settings of the selected account are copied\n" | 57 | "settings of the selected account are copied\n" |
77 | "to a new account, that you can modify to fit your\n" | 58 | "to a new account, that you can modify to fit your\n" |
78 | "needs")); | 59 | "needs")); |
79 | |||
80 | delete_b = new QPushButton(tr("De&lete"), this); | ||
81 | connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); | ||
82 | l1->addWidget(delete_b); | ||
83 | QWhatsThis::add(delete_b, | 60 | QWhatsThis::add(delete_b, |
84 | tr("<p>Deletes the selected account\n\n" | 61 | tr("<p>Deletes the selected account\n\n" |
85 | "<font color=\"red\"><b>Use with care!</b></font>")); | 62 | "<font color=\"red\"><b>Use with care!</b></font>")); |
86 | 63 | ||
87 | QHBoxLayout *l12 = new QHBoxLayout; | ||
88 | l1->addStretch(1); | ||
89 | l1->addLayout(l12); | ||
90 | 64 | ||
91 | int currAccId = _pppdata->currentAccountID(); | ||
92 | qDebug("currentAccountID %i", currAccId); | ||
93 | 65 | ||
94 | //load up account list from gppdata to the list box | 66 | copy_b->setEnabled( false ); //FIXME |
95 | if(_pppdata->count() > 0) { | 67 | // delete_b->setEnabled( false ); //FIXME |
96 | for(int i=0; i <= _pppdata->count()-1; i++) { | ||
97 | _pppdata->setAccountbyIndex(i); | ||
98 | accountlist_l->insertItem(_pppdata->accname()); | ||
99 | } | ||
100 | } | ||
101 | _pppdata->setAccountbyIndex( currAccId ); | ||
102 | 68 | ||
103 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); | 69 | listListbox->insertStringList(_pppdata->getAccountList()); |
104 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); | ||
105 | slotListBoxSelect( _pppdata->currentAccountID() ); | ||
106 | 70 | ||
107 | l1->activate(); | 71 | for (uint i = 0; i < listListbox->count(); i++){ |
72 | if ( listListbox->text(i) == _pppdata->accname() ) | ||
73 | listListbox->setCurrentItem( i ); | ||
74 | } | ||
108 | } | 75 | } |
109 | 76 | ||
110 | 77 | ||
111 | 78 | ||
112 | void AccountWidget::slotListBoxSelect(int idx) { | 79 | void AccountWidget::slotListBoxSelect(int idx) { |
113 | delete_b->setEnabled((bool)(idx != -1)); | 80 | bool ok = _pppdata->setAccount( listListbox->text(idx) ); |
114 | edit_b->setEnabled((bool)(idx != -1)); | 81 | ok = (bool)(idx != -1); |
115 | copy_b->setEnabled((bool)(idx != -1)); | 82 | delete_b->setEnabled(ok); |
116 | if(idx!=-1) { | 83 | edit_b->setEnabled(ok); |
117 | qDebug("setting account to %i", idx); | 84 | //FIXME copy_b->setEnabled(ok); |
118 | QString account = _pppdata->accname(); | ||
119 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); | ||
120 | } | ||
121 | } | 85 | } |
122 | 86 | ||
123 | void AccountWidget::editaccount() { | 87 | void AccountWidget::edit() { |
124 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); | 88 | _pppdata->setAccount(listListbox->text(listListbox->currentItem())); |
125 | 89 | ||
126 | int result = doTab(); | 90 | int result = doTab(); |
127 | 91 | ||
128 | if(result == QDialog::Accepted) { | 92 | if(result == QDialog::Accepted) { |
129 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); | 93 | listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); |
130 | // emit resetaccounts(); | 94 | // emit resetaccounts(); |
131 | _pppdata->save(); | 95 | _pppdata->save(); |
132 | } | 96 | } |
133 | } | 97 | } |
134 | 98 | ||
135 | 99 | ||
136 | void AccountWidget::newaccount() { | 100 | void AccountWidget::create() { |
137 | 101 | ||
138 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 102 | // if(listListbox->count() == MAX_ACCOUNTS) { |
139 | QMessageBox::information(this, "sorry", | 103 | // QMessageBox::information(this, "sorry", |
140 | tr("Maximum number of accounts reached.")); | 104 | // tr("Maximum number of accounts reached.")); |
141 | return; | 105 | // return; |
142 | } | 106 | // } |
143 | 107 | ||
144 | int result; | 108 | int result; |
145 | if (_pppdata->newaccount() == -1){ | 109 | if (_pppdata->newaccount() == -1){ |
146 | qDebug("_pppdata->newaccount() == -1"); | 110 | qDebug("_pppdata->newaccount() == -1"); |
147 | return; | 111 | return; |
148 | } | 112 | } |
149 | result = doTab(); | 113 | result = doTab(); |
150 | 114 | ||
151 | if(result == QDialog::Accepted) { | 115 | if(result == QDialog::Accepted) { |
152 | accountlist_l->insertItem(_pppdata->accname()); | 116 | listListbox->insertItem(_pppdata->accname()); |
153 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true); | 117 | listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); |
154 | 118 | ||
155 | _pppdata->save(); | 119 | _pppdata->save(); |
156 | } else | 120 | } else |
157 | _pppdata->deleteAccount(); | 121 | _pppdata->deleteAccount(); |
158 | } | 122 | } |
159 | 123 | ||
160 | 124 | ||
161 | void AccountWidget::copyaccount() { | 125 | void AccountWidget::copy() { |
162 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 126 | // if(listListbox->count() == MAX_ACCOUNTS) { |
163 | QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | 127 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); |
164 | return; | 128 | // return; |
165 | } | 129 | // } |
166 | 130 | ||
167 | if(accountlist_l->currentItem()<0) { | 131 | if(listListbox->currentItem()<0) { |
168 | QMessageBox::information(this, "sorry", tr("No account selected.")); | 132 | QMessageBox::information(this, "sorry", tr("No account selected.")); |
169 | return; | 133 | return; |
170 | } | 134 | } |
171 | 135 | ||
172 | _pppdata->copyaccount(accountlist_l->currentItem()); | 136 | _pppdata->copyaccount(listListbox->currentText()); |
173 | 137 | ||
174 | accountlist_l->insertItem(_pppdata->accname()); | 138 | listListbox->insertItem(_pppdata->accname()); |
175 | // emit resetaccounts(); | 139 | // emit resetaccounts(); |
176 | _pppdata->save(); | 140 | _pppdata->save(); |
177 | } | 141 | } |
178 | 142 | ||
179 | 143 | ||
180 | void AccountWidget::deleteaccount() { | 144 | void AccountWidget::remove() { |
181 | 145 | ||
182 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") | 146 | QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") |
183 | .arg(accountlist_l->text(accountlist_l->currentItem())); | 147 | .arg(listListbox->text(listListbox->currentItem())); |
184 | 148 | ||
185 | if(QMessageBox::warning(this,tr("Confirm"),s, | 149 | if(QMessageBox::warning(this,tr("Confirm"),s, |
186 | QMessageBox::Yes,QMessageBox::No | 150 | QMessageBox::Yes,QMessageBox::No |
187 | ) != QMessageBox::Yes) | 151 | ) != QMessageBox::Yes) |
188 | return; | 152 | return; |
189 | 153 | ||
190 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) | 154 | if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem()))) |
191 | accountlist_l->removeItem(accountlist_l->currentItem()); | 155 | listListbox->removeItem(listListbox->currentItem()); |
192 | 156 | ||
193 | emit resetaccounts(); | ||
194 | _pppdata->save(); | ||
195 | 157 | ||
196 | slotListBoxSelect(accountlist_l->currentItem()); | 158 | // emit resetaccounts(); |
159 | // _pppdata->save(); | ||
160 | |||
161 | |||
162 | slotListBoxSelect(listListbox->currentItem()); | ||
197 | 163 | ||
198 | } | 164 | } |
199 | 165 | ||
200 | 166 | ||
201 | int AccountWidget::doTab(){ | 167 | int AccountWidget::doTab(){ |
202 | QDialog *dlg = new QDialog( 0, "newAccount", true ); | 168 | QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp ); |
203 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | 169 | QVBoxLayout *layout = new QVBoxLayout( dlg ); |
204 | layout->setSpacing( 0 ); | 170 | layout->setSpacing( 0 ); |
205 | layout->setMargin( 1 ); | 171 | layout->setMargin( 1 ); |
206 | 172 | ||
207 | tabWindow = new QTabWidget( dlg, "tabWindow" ); | 173 | QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); |
208 | layout->addWidget( tabWindow ); | 174 | layout->addWidget( tabWindow ); |
209 | 175 | ||
210 | bool isnewaccount; | 176 | bool isnewaccount; |
211 | 177 | ||
212 | if(_pppdata->accname().isEmpty()) { | 178 | if(_pppdata->accname().isEmpty()) { |
213 | dlg->setCaption(tr("New Account")); | 179 | dlg->setCaption(tr("New Account")); |
214 | isnewaccount = true; | 180 | isnewaccount = true; |
215 | } else { | 181 | } else { |
216 | QString tit = tr("Edit Account: "); | 182 | QString tit = tr("Edit Account: "); |
217 | tit += _pppdata->accname(); | 183 | tit += _pppdata->accname(); |
218 | dlg->setCaption(tit); | 184 | dlg->setCaption(tit); |
219 | isnewaccount = false; | 185 | isnewaccount = false; |
220 | } | 186 | } |
221 | 187 | ||
222 | // // DIAL WIDGET | 188 | // // DIAL WIDGET |
223 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); | 189 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); |
224 | tabWindow->addTab( dial_w, tr("Dial") ); | 190 | tabWindow->addTab( dial_w, tr("Dial") ); |
225 | 191 | ||
226 | // // AUTH WIDGET | 192 | // // AUTH WIDGET |
227 | auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); | 193 | auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); |
228 | tabWindow->addTab( auth_w, tr("Authentication") ); | 194 | tabWindow->addTab( auth_w, tr("Authentication") ); |
229 | 195 | ||
230 | // // IP WIDGET | 196 | // // IP WIDGET |
231 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); | 197 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); |
232 | tabWindow->addTab( ip_w, tr("IP") ); | 198 | tabWindow->addTab( ip_w, tr("IP") ); |
233 | 199 | ||
234 | // // GATEWAY WIDGET | 200 | // // GATEWAY WIDGET |
235 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); | 201 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); |
236 | tabWindow->addTab( gateway_w, tr("Gateway") ); | 202 | tabWindow->addTab( gateway_w, tr("Gateway") ); |
237 | 203 | ||
238 | // // DNS WIDGET | 204 | // // DNS WIDGET |
239 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); | 205 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); |
240 | tabWindow->addTab( dns_w, tr("DNS") ); | 206 | tabWindow->addTab( dns_w, tr("DNS") ); |
241 | 207 | ||
242 | // // EXECUTE WIDGET | 208 | // // EXECUTE WIDGET |
243 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); | 209 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); |
244 | tabWindow->addTab( exec_w, tr("Execute") ); | 210 | tabWindow->addTab( exec_w, tr("Execute") ); |
245 | 211 | ||
246 | int result = 0; | 212 | int result = 0; |
247 | bool ok = false; | 213 | bool ok = false; |
248 | 214 | ||
249 | while (!ok){ | 215 | while (!ok){ |
250 | dlg->showMaximized(); | 216 | dlg->showMaximized(); |
251 | result = dlg->exec(); | 217 | result = dlg->exec(); |
252 | ok = true; | 218 | ok = true; |
253 | 219 | ||
254 | if(result == QDialog::Accepted) { | 220 | if(result == QDialog::Accepted) { |
255 | if (!auth_w->check()){ | 221 | if (!auth_w->check()){ |
256 | ok = false; | 222 | ok = false; |
257 | } else if(!dial_w->save()) { | 223 | } else if(!dial_w->save()) { |
258 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); | 224 | QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); |
259 | ok = false; | 225 | ok = false; |
260 | }else{ | 226 | }else{ |
261 | ip_w->save(); | 227 | ip_w->save(); |
262 | dns_w->save(); | 228 | dns_w->save(); |
263 | gateway_w->save(); | 229 | gateway_w->save(); |
264 | auth_w->save(); | 230 | auth_w->save(); |
265 | exec_w->save(); | 231 | exec_w->save(); |
266 | } | 232 | } |
267 | } | 233 | } |
268 | } | 234 | } |
269 | 235 | ||
270 | delete dlg; | 236 | delete dlg; |
271 | 237 | ||
272 | return result; | 238 | return result; |
273 | } | 239 | } |
274 | 240 | ||
275 | 241 | ||
276 | QString AccountWidget::prettyPrintVolume(unsigned int n) { | 242 | // QString AccountWidget::prettyPrintVolume(unsigned int n) { |
277 | int idx = 0; | 243 | // int idx = 0; |
278 | const QString quant[] = {tr("Byte"), tr("KB"), | 244 | // const QString quant[] = {tr("Byte"), tr("KB"), |
279 | tr("MB"), tr("GB"), QString::null}; | 245 | // tr("MB"), tr("GB"), QString::null}; |
280 | 246 | ||
281 | float n1 = n; | 247 | // float n1 = n; |
282 | while(n >= 1024 && quant[idx] != QString::null) { | 248 | // while(n >= 1024 && quant[idx] != QString::null) { |
283 | idx++; | 249 | // idx++; |
284 | n /= 1024; | 250 | // n /= 1024; |
285 | } | 251 | // } |
286 | 252 | ||
287 | int i = idx; | 253 | // int i = idx; |
288 | while(i--) | 254 | // while(i--) |
289 | n1 = n1 / 1024.0; | 255 | // n1 = n1 / 1024.0; |
290 | 256 | ||
291 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); | 257 | // QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); |
292 | s += " " + quant[idx]; | 258 | // s += " " + quant[idx]; |
293 | return s; | 259 | // return s; |
294 | } | 260 | // } |
295 | 261 | ||
296 | 262 | ||
297 | ///////////////////////////////////////////////////////////////////////////// | 263 | ///////////////////////////////////////////////////////////////////////////// |
298 | // | 264 | // |
299 | // Queries the user what to reset: costs, volume or both | 265 | // Queries the user what to reset: costs, volume or both |
300 | // | 266 | // |
301 | ///////////////////////////////////////////////////////////////////////////// | 267 | ///////////////////////////////////////////////////////////////////////////// |
302 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { | 268 | // QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { |
303 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 269 | // // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
304 | // setCaption(tr("Reset Accounting")); | 270 | // setCaption(tr("Reset Accounting")); |
305 | 271 | ||
306 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 272 | // QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
307 | // QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); | 273 | // QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this); |
308 | 274 | ||
309 | // QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 275 | // QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
310 | // // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); | 276 | // // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f); |
311 | // // costs->setChecked(true); | 277 | // // costs->setChecked(true); |
312 | // // l1->addWidget(costs); | 278 | // // l1->addWidget(costs); |
313 | // // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" | 279 | // // QWhatsThis::add(costs, tr("Check this to set the phone costs\n" |
314 | // // "to zero. Typically you'll want to\n" | 280 | // // "to zero. Typically you'll want to\n" |
315 | // // "do this once a month.")); | 281 | // // "do this once a month.")); |
316 | 282 | ||
317 | // // volume = new QCheckBox(tr("Reset volume accounting"), f); | 283 | // // volume = new QCheckBox(tr("Reset volume accounting"), f); |
318 | // // volume->setChecked(true); | 284 | // // volume->setChecked(true); |
319 | // // l1->addWidget(volume); | 285 | // // l1->addWidget(volume); |
320 | // // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" | 286 | // // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n" |
321 | // // "to zero. Typically you'll want to do this\n" | 287 | // // "to zero. Typically you'll want to do this\n" |
322 | // // "once a month.")); | 288 | // // "once a month.")); |
323 | 289 | ||
324 | // l1->activate(); | 290 | // l1->activate(); |
325 | 291 | ||
326 | // // this activates the f-layout and sets minimumSize() | 292 | // // this activates the f-layout and sets minimumSize() |
327 | // f->show(); | 293 | // f->show(); |
328 | 294 | ||
329 | // tl->addWidget(f); | 295 | // tl->addWidget(f); |
330 | 296 | ||
331 | // QButtonGroup *bbox = new QButtonGroup(this); | 297 | // QButtonGroup *bbox = new QButtonGroup(this); |
332 | // // bbox->addStretch(1); | 298 | // // bbox->addStretch(1); |
333 | // QPushButton *ok = new QPushButton( bbox, tr("OK") ); | 299 | // QPushButton *ok = new QPushButton( bbox, tr("OK") ); |
334 | // bbox->insert(ok); | 300 | // bbox->insert(ok); |
335 | // ok->setDefault(true); | 301 | // ok->setDefault(true); |
336 | // QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); | 302 | // QPushButton *cancel = new QPushButton( bbox, tr("Cancel") ); |
337 | // bbox->insert(cancel); | 303 | // bbox->insert(cancel); |
338 | 304 | ||
339 | // connect(ok, SIGNAL(clicked()), | 305 | // connect(ok, SIGNAL(clicked()), |
340 | // this, SLOT(accepted())); | 306 | // this, SLOT(accepted())); |
341 | // connect(cancel, SIGNAL(clicked()), | 307 | // connect(cancel, SIGNAL(clicked()), |
342 | // this, SLOT(reject())); | 308 | // this, SLOT(reject())); |
343 | 309 | ||
344 | // bbox->layout(); | 310 | // bbox->layout(); |
345 | // tl->addWidget(bbox); | 311 | // tl->addWidget(bbox); |
346 | 312 | ||
347 | // } | 313 | // } |
348 | 314 | ||
349 | 315 | ||
350 | // void QueryReset::accepted() { | 316 | // void QueryReset::accepted() { |
351 | // int result = costs->isChecked() ? COSTS : 0; | 317 | // int result = costs->isChecked() ? COSTS : 0; |
352 | // result += volume->isChecked() ? VOLUME : 0; | 318 | // result += volume->isChecked() ? VOLUME : 0; |
353 | 319 | ||
354 | // done(result); | 320 | // done(result); |
355 | // } | 321 | // } |
356 | 322 | ||
357 | 323 | ||
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h index 8c16a7c..7f31513 100644 --- a/noncore/settings/networksettings/ppp/accounts.h +++ b/noncore/settings/networksettings/ppp/accounts.h | |||
@@ -1,86 +1,80 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
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 | #ifndef _ACCOUNTS_H_ | 27 | #ifndef _ACCOUNTS_H_ |
28 | #define _ACCOUNTS_H_ | 28 | #define _ACCOUNTS_H_ |
29 | 29 | ||
30 | #include <qwidget.h> | ||
31 | #include <qdialog.h> | 30 | #include <qdialog.h> |
32 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
33 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
34 | //#include "acctselect.h" | 33 | #include "chooserwidget.h" |
35 | 34 | ||
36 | class QDialog; | ||
37 | class QCheckBox; | 35 | class QCheckBox; |
38 | class QLineEdit; | 36 | class QLineEdit; |
39 | class QTabWidget; | 37 | class QTabWidget; |
38 | class ModemWidget; | ||
39 | class ModemWidget2; | ||
40 | |||
41 | |||
40 | class DialWidget; | 42 | class DialWidget; |
41 | class AuthWidget; | 43 | class AuthWidget; |
42 | class IPWidget; | 44 | class IPWidget; |
43 | class DNSWidget; | 45 | class DNSWidget; |
44 | class GatewayWidget; | 46 | class GatewayWidget; |
45 | class PPPData; | 47 | class PPPData; |
46 | 48 | ||
47 | class AccountWidget : public QWidget { | 49 | |
50 | class AccountWidget : public ChooserWidget { | ||
51 | |||
48 | Q_OBJECT | 52 | Q_OBJECT |
49 | public: | 53 | public: |
50 | AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 ); | 54 | AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0, WFlags f=0 ); |
51 | ~AccountWidget() {} | 55 | ~AccountWidget() {} |
52 | 56 | ||
53 | private slots: | ||
54 | void editaccount(); | ||
55 | void copyaccount(); | ||
56 | void newaccount(); | ||
57 | void deleteaccount(); | ||
58 | void slotListBoxSelect(int); | ||
59 | 57 | ||
60 | private: | 58 | private slots: |
59 | virtual void edit(); | ||
60 | virtual void copy(); | ||
61 | virtual void remove(); | ||
62 | virtual void create(); | ||
63 | virtual void slotListBoxSelect(int); | ||
61 | int doTab(); | 64 | int doTab(); |
62 | 65 | ||
63 | signals: | 66 | signals: |
64 | void resetaccounts(); | 67 | void resetaccounts(); |
65 | 68 | ||
66 | private: | 69 | private: |
67 | QString prettyPrintVolume(unsigned int); | ||
68 | |||
69 | PPPData *_pppdata; | ||
70 | QTabWidget *tabWindow; | ||
71 | DialWidget *dial_w; | 70 | DialWidget *dial_w; |
72 | IPWidget *ip_w; | 71 | IPWidget *ip_w; |
73 | DNSWidget *dns_w; | 72 | DNSWidget *dns_w; |
74 | GatewayWidget *gateway_w; | 73 | GatewayWidget *gateway_w; |
75 | AuthWidget *auth_w; | 74 | AuthWidget *auth_w; |
76 | 75 | ||
77 | QListBox *accountlist_l; | ||
78 | QPushButton *edit_b; | ||
79 | QPushButton *copy_b; | ||
80 | QPushButton *new_b; | ||
81 | QPushButton *delete_b; | ||
82 | }; | 76 | }; |
83 | 77 | ||
84 | 78 | ||
85 | #endif | 79 | #endif |
86 | 80 | ||
diff --git a/noncore/settings/networksettings/ppp/chooserwidget.cpp b/noncore/settings/networksettings/ppp/chooserwidget.cpp new file mode 100644 index 0000000..a32b2b8 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/chooserwidget.cpp | |||
@@ -0,0 +1,85 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
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 | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <qdir.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qtabwidget.h> | ||
31 | #include <qtabdialog.h> | ||
32 | #include <qwhatsthis.h> | ||
33 | #include <qmessagebox.h> | ||
34 | |||
35 | #include <qapplication.h> | ||
36 | #include <qbuttongroup.h> | ||
37 | #include <qmessagebox.h> | ||
38 | #include <qvgroupbox.h> | ||
39 | #include <qwidget.h> | ||
40 | |||
41 | #include "accounts.h" | ||
42 | #include "authwidget.h" | ||
43 | #include "pppdata.h" | ||
44 | #include "edit.h" | ||
45 | |||
46 | void parseargs(char* buf, char** args); | ||
47 | |||
48 | ChooserWidget::ChooserWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) | ||
49 | : QWidget( parent, name, f ) | ||
50 | { | ||
51 | _pppdata = pd; | ||
52 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | ||
53 | listListbox = new QListBox(this); | ||
54 | |||
55 | connect(listListbox, SIGNAL(highlighted(int)), | ||
56 | this, SLOT(slotListBoxSelect(int))); | ||
57 | connect(listListbox, SIGNAL(selected(int)),this, SLOT(edit())); | ||
58 | l1->addWidget(listListbox, 10); | ||
59 | |||
60 | edit_b = new QPushButton(tr("&Edit..."), this); | ||
61 | connect(edit_b, SIGNAL(clicked()), SLOT(edit())); | ||
62 | l1->addWidget(edit_b); | ||
63 | |||
64 | new_b = new QPushButton(tr("&New..."), this); | ||
65 | connect(new_b, SIGNAL(clicked()), SLOT(create())); | ||
66 | l1->addWidget(new_b); | ||
67 | |||
68 | |||
69 | copy_b = new QPushButton(tr("Co&py"), this); | ||
70 | connect(copy_b, SIGNAL(clicked()), SLOT(copy())); | ||
71 | l1->addWidget(copy_b); | ||
72 | |||
73 | delete_b = new QPushButton(tr("De&lete"), this); | ||
74 | connect(delete_b, SIGNAL(clicked()), SLOT(remove())); | ||
75 | l1->addWidget(delete_b); | ||
76 | |||
77 | |||
78 | QHBoxLayout *l12 = new QHBoxLayout; | ||
79 | l1->addStretch(1); | ||
80 | l1->addLayout(l12); | ||
81 | |||
82 | l1->activate(); | ||
83 | |||
84 | } | ||
85 | |||
diff --git a/noncore/settings/networksettings/ppp/chooserwidget.h b/noncore/settings/networksettings/ppp/chooserwidget.h new file mode 100644 index 0000000..ac3f4cb --- a/dev/null +++ b/noncore/settings/networksettings/ppp/chooserwidget.h | |||
@@ -0,0 +1,73 @@ | |||
1 | /* -*- C++ -*- | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
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 | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #ifndef _CHOOSERWIDGET_H_ | ||
28 | #define _CHOOSERWIDGET_H_ | ||
29 | |||
30 | #include <qwidget.h> | ||
31 | #include <qdialog.h> | ||
32 | #include <qpushbutton.h> | ||
33 | #include <qlistbox.h> | ||
34 | //#include "acctselect.h" | ||
35 | |||
36 | class QDialog; | ||
37 | class QCheckBox; | ||
38 | class QLineEdit; | ||
39 | class QTabWidget; | ||
40 | class DialWidget; | ||
41 | class AuthWidget; | ||
42 | class IPWidget; | ||
43 | class DNSWidget; | ||
44 | class GatewayWidget; | ||
45 | class PPPData; | ||
46 | |||
47 | class ChooserWidget : public QWidget { | ||
48 | Q_OBJECT | ||
49 | public: | ||
50 | ChooserWidget( PPPData *pd, QWidget *parent=0, const char *name=0, WFlags f=0 ); | ||
51 | ~ChooserWidget() {} | ||
52 | |||
53 | private slots: | ||
54 | virtual void edit() = 0; | ||
55 | virtual void copy() = 0; | ||
56 | virtual void create()= 0; | ||
57 | virtual void remove()= 0; | ||
58 | virtual void slotListBoxSelect(int) = 0; | ||
59 | |||
60 | |||
61 | protected: | ||
62 | PPPData *_pppdata; | ||
63 | |||
64 | QListBox *listListbox; | ||
65 | QPushButton *edit_b; | ||
66 | QPushButton *copy_b; | ||
67 | QPushButton *new_b; | ||
68 | QPushButton *delete_b; | ||
69 | }; | ||
70 | |||
71 | |||
72 | #endif | ||
73 | |||
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index 2400d7b..e3fab24 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp | |||
@@ -1,1347 +1,1371 @@ | |||
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 | * | 4 | * |
5 | * Copyright (C) 1997 Bernd Johannes Wuebben | 5 | * Copyright (C) 1997 Bernd Johannes Wuebben |
6 | * wuebben@math.cornell.edu | 6 | * wuebben@math.cornell.edu |
7 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> | 7 | * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> |
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 <config.h> | 27 | //#include <config.h> |
28 | 28 | ||
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qregexp.h> | 30 | #include <qregexp.h> |
31 | 31 | ||
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <kdebug.h> | 33 | //#include <kdebug.h> |
34 | //#include <klocale.h> | 34 | //#include <klocale.h> |
35 | #define i18n QObject::tr | ||
36 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
37 | #include <qpushbutton.h> | 36 | #include <qpushbutton.h> |
38 | 37 | ||
39 | #include <unistd.h> | 38 | #include <unistd.h> |
40 | #include <stdlib.h> | 39 | #include <stdlib.h> |
41 | #include <string.h> | 40 | #include <string.h> |
42 | #include <fcntl.h> | 41 | #include <fcntl.h> |
43 | #include <netdb.h> | 42 | #include <netdb.h> |
44 | #include <sys/types.h> | 43 | #include <sys/types.h> |
45 | #include <sys/socket.h> | 44 | #include <sys/socket.h> |
46 | #include <arpa/inet.h> | 45 | #include <arpa/inet.h> |
47 | #include <netinet/in.h> | 46 | #include <netinet/in.h> |
48 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
49 | #include <assert.h> | 48 | #include <assert.h> |
50 | 49 | ||
51 | #ifdef _XPG4_2 | 50 | #ifdef _XPG4_2 |
52 | #define __xnet_connectconnect | 51 | #define __xnet_connectconnect |
53 | #endif | 52 | #endif |
54 | 53 | ||
55 | #include <errno.h> | 54 | #include <errno.h> |
56 | 55 | ||
57 | #ifdef HAVE_SYS_PARAM_H | 56 | #ifdef HAVE_SYS_PARAM_H |
58 | #include <sys/param.h> | 57 | #include <sys/param.h> |
59 | #endif | 58 | #endif |
60 | 59 | ||
61 | #ifdef __linux__ | 60 | #ifdef __linux__ |
62 | #include "runtests.h" | 61 | #include "runtests.h" |
63 | #endif | 62 | #endif |
64 | 63 | ||
65 | #include "auth.h" | 64 | #include "auth.h" |
66 | #include "connect.h" | 65 | #include "connect.h" |
67 | //#include "docking.h" | 66 | //#include "docking.h" |
68 | #include "interfaceppp.h" | 67 | #include "interfaceppp.h" |
69 | #include "modem.h" | 68 | #include "modem.h" |
70 | #include "kpppconfig.h" | 69 | #include "kpppconfig.h" |
71 | #include "pppdata.h" | 70 | #include "pppdata.h" |
72 | #include "kpppwidget.h" | 71 | #include "kpppwidget.h" |
73 | //#include "requester.h" | 72 | //#include "requester.h" |
74 | //#include "utils.h" | 73 | //#include "utils.h" |
75 | #define execute_command system | 74 | #define execute_command system |
76 | 75 | ||
77 | QString old_hostname; | 76 | QString old_hostname; |
78 | bool modified_hostname; | 77 | bool modified_hostname; |
79 | 78 | ||
80 | 79 | ||
81 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) | 80 | ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) |
82 | : QWidget(parent, name), | 81 | : QWidget(parent, name), |
83 | myreadbuffer(""), | 82 | myreadbuffer(""), |
84 | main_timer_ID(0), | 83 | main_timer_ID(0), |
85 | vmain(0), | 84 | vmain(0), |
86 | substate(-1), | 85 | substate(-1), |
87 | scriptindex(0), | 86 | scriptindex(0), |
88 | loopnest(0), | 87 | loopnest(0), |
89 | loopend(false), | 88 | loopend(false), |
90 | semaphore(false), | 89 | semaphore(false), |
91 | expecting(false), | 90 | expecting(false), |
92 | readbuffer(""), | 91 | readbuffer(""), |
93 | scanvar(""), | 92 | scanvar(""), |
94 | scanning(false), | 93 | scanning(false), |
95 | pausing(false), | 94 | pausing(false), |
96 | dialnumber(0), | 95 | dialnumber(0), |
97 | _ifaceppp(ifp) | 96 | _ifaceppp(ifp) |
98 | { | 97 | { |
99 | modified_hostname = false; | 98 | modified_hostname = false; |
100 | 99 | ||
101 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); | 100 | QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); |
102 | QString tit = i18n("Connecting to: "); | 101 | QString tit = QObject::tr("Connecting to: "); |
103 | setCaption(tit); | 102 | setCaption(tit); |
104 | 103 | ||
105 | QHBoxLayout *l0 = new QHBoxLayout(10); | 104 | QHBoxLayout *l0 = new QHBoxLayout(10); |
106 | tl->addLayout(l0); | 105 | tl->addLayout(l0); |
107 | l0->addSpacing(10); | 106 | l0->addSpacing(10); |
108 | messg = new QLabel(this, "messg"); | 107 | messg = new QLabel(this, "messg"); |
109 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 108 | messg->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
110 | messg->setAlignment(AlignCenter); | 109 | messg->setAlignment(AlignCenter); |
111 | messg->setText(i18n("Unable to create modem lock file.")); | 110 | messg->setText(QObject::tr("Unable to create modem lock file.")); |
112 | messg->setMinimumHeight(messg->sizeHint().height() + 5); | 111 | messg->setMinimumHeight(messg->sizeHint().height() + 5); |
113 | // int messw = (messg->sizeHint().width() * 12) / 10; | 112 | // int messw = (messg->sizeHint().width() * 12) / 10; |
114 | // messw = QMAX(messw,280); | 113 | // messw = QMAX(messw,280); |
115 | // messg->setMinimumWidth(messw); | 114 | // messg->setMinimumWidth(messw); |
116 | if (_ifaceppp->getStatus()) | 115 | if (_ifaceppp->getStatus()) |
117 | messg->setText(i18n("Online")); | 116 | messg->setText(QObject::tr("Online")); |
118 | else | 117 | else |
119 | messg->setText(i18n("Offline")); | 118 | messg->setText(QObject::tr("Offline")); |
120 | l0->addSpacing(10); | 119 | l0->addSpacing(10); |
121 | l0->addWidget(messg); | 120 | l0->addWidget(messg); |
122 | l0->addSpacing(10); | 121 | l0->addSpacing(10); |
123 | 122 | ||
124 | QHBoxLayout *l1 = new QHBoxLayout(10); | 123 | QHBoxLayout *l1 = new QHBoxLayout(10); |
125 | tl->addLayout(l1); | 124 | tl->addLayout(l1); |
126 | l1->addStretch(1); | 125 | l1->addStretch(1); |
127 | 126 | ||
128 | debug = new QPushButton(i18n("Log"), this); | 127 | debug = new QPushButton(QObject::tr("Log"), this); |
129 | debug->setToggleButton(true); | 128 | debug->setToggleButton(true); |
130 | debug->setEnabled( false ); // FIXME: disable the log button | 129 | debug->setEnabled( false ); // FIXME: disable the log button |
131 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); | 130 | connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); |
132 | 131 | ||
133 | cancel = new QPushButton(i18n("Cancel"), this); | 132 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
134 | cancel->setFocus(); | 133 | cancel->setFocus(); |
135 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 134 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
136 | 135 | ||
137 | // int maxw = QMAX(cancel->sizeHint().width(), | 136 | // int maxw = QMAX(cancel->sizeHint().width(), |
138 | // debug->sizeHint().width()); | 137 | // debug->sizeHint().width()); |
139 | // maxw = QMAX(maxw,65); | 138 | // maxw = QMAX(maxw,65); |
140 | // debug->setFixedWidth(maxw); | 139 | // debug->setFixedWidth(maxw); |
141 | // cancel->setFixedWidth(maxw); | 140 | // cancel->setFixedWidth(maxw); |
142 | l1->addWidget(debug); | 141 | l1->addWidget(debug); |
143 | l1->addWidget(cancel); | 142 | l1->addWidget(cancel); |
144 | 143 | ||
145 | // setFixedSize(sizeHint()); | 144 | // setFixedSize(sizeHint()); |
146 | 145 | ||
147 | pausetimer = new QTimer(this); | 146 | pausetimer = new QTimer(this); |
148 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); | 147 | connect(pausetimer, SIGNAL(timeout()), SLOT(pause())); |
149 | 148 | ||
150 | qApp->processEvents(); | 149 | qApp->processEvents(); |
151 | 150 | ||
152 | timeout_timer = new QTimer(this); | 151 | timeout_timer = new QTimer(this); |
153 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); | 152 | connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out())); |
154 | 153 | ||
155 | inittimer = new QTimer(this); | 154 | inittimer = new QTimer(this); |
156 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); | 155 | connect(inittimer, SIGNAL(timeout()), SLOT(init())); |
157 | 156 | ||
158 | if_timeout_timer = new QTimer(this); | 157 | if_timeout_timer = new QTimer(this); |
159 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); | 158 | connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); |
160 | 159 | ||
161 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); | 160 | connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); |
162 | 161 | ||
163 | prompt = new PWEntry( this, "pw" ); | 162 | prompt = new PWEntry( this, "pw" ); |
164 | if_timer = new QTimer(this); | 163 | if_timer = new QTimer(this); |
165 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); | 164 | connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); |
166 | } | 165 | } |
167 | 166 | ||
168 | 167 | ||
169 | ConnectWidget::~ConnectWidget() { | 168 | ConnectWidget::~ConnectWidget() { |
170 | } | 169 | } |
171 | 170 | ||
172 | 171 | ||
173 | void ConnectWidget::preinit() { | 172 | void ConnectWidget::preinit() { |
174 | // this is all just to keep the GUI nice and snappy .... | 173 | // this is all just to keep the GUI nice and snappy .... |
175 | // you have to see to believe ... | 174 | // you have to see to believe ... |
176 | messg->setText(i18n("Looking for modem...")); | 175 | messg->setText(QObject::tr("Looking for modem...")); |
177 | inittimer->start(100); | 176 | inittimer->start(100); |
178 | } | 177 | } |
179 | 178 | ||
180 | 179 | ||
181 | void ConnectWidget::init() { | 180 | void ConnectWidget::init() { |
182 | _ifaceppp->data()->setpppdError(0); | 181 | _ifaceppp->data()->setpppdError(0); |
183 | inittimer->stop(); | 182 | inittimer->stop(); |
184 | vmain = 0; | 183 | vmain = 0; |
185 | substate = -1; | 184 | substate = -1; |
186 | expecting = false; | 185 | expecting = false; |
187 | pausing = false; | 186 | pausing = false; |
188 | scriptindex = 0; | 187 | scriptindex = 0; |
189 | myreadbuffer = ""; | 188 | myreadbuffer = ""; |
190 | scanning = false; | 189 | scanning = false; |
191 | scanvar = ""; | 190 | scanvar = ""; |
192 | firstrunID = true; | 191 | firstrunID = true; |
193 | firstrunPW = true; | 192 | firstrunPW = true; |
194 | // stats->totalbytes = 0; | 193 | // stats->totalbytes = 0; |
195 | dialnumber = 0; | 194 | dialnumber = 0; |
196 | 195 | ||
197 | // p_kppp->con_speed = ""; | 196 | // p_kppp->con_speed = ""; |
198 | 197 | ||
199 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); | 198 | // p_kppp->setQuitOnDisconnect (p_kppp->quitOnDisconnect() || _ifaceppp->data()->quit_on_disconnect()); |
200 | 199 | ||
201 | comlist = &_ifaceppp->data()->scriptType(); | 200 | comlist = &_ifaceppp->data()->scriptType(); |
202 | arglist = &_ifaceppp->data()->script(); | 201 | arglist = &_ifaceppp->data()->script(); |
203 | 202 | ||
204 | QString tit = i18n("Connecting to: %1").arg(_ifaceppp->data()->accname()); | 203 | QString tit = QObject::tr("Connecting to: %1").arg(_ifaceppp->data()->accname()); |
205 | setCaption(tit); | 204 | setCaption(tit); |
206 | 205 | ||
207 | qApp->processEvents(); | 206 | qApp->processEvents(); |
208 | 207 | ||
209 | // run the "before-connect" command | 208 | // run the "before-connect" command |
210 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { | 209 | if (!_ifaceppp->data()->command_before_connect().isEmpty()) { |
211 | messg->setText(i18n("Running pre-startup command...")); | 210 | messg->setText(QObject::tr("Running pre-startup command...")); |
212 | emit debugMessage(i18n("Running pre-startup command...")); | 211 | emit debugMessage(QObject::tr("Running pre-startup command...")); |
213 | 212 | ||
214 | qApp->processEvents(); | 213 | qApp->processEvents(); |
215 | QApplication::flushX(); | 214 | QApplication::flushX(); |
216 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); | 215 | pid_t id = execute_command(_ifaceppp->data()->command_before_connect()); |
217 | // int i, status; | 216 | // int i, status; |
218 | 217 | ||
219 | // do { | 218 | // do { |
220 | // qApp->processEvents(); | 219 | // qApp->processEvents(); |
221 | // i = waitpid(id, &status, WNOHANG); | 220 | // i = waitpid(id, &status, WNOHANG); |
222 | // usleep(100000); | 221 | // usleep(100000); |
223 | // } while (i == 0 && errno == 0); | 222 | // } while (i == 0 && errno == 0); |
224 | } | 223 | } |
225 | 224 | ||
226 | int lock = _ifaceppp->modem()->lockdevice(); | 225 | int lock = _ifaceppp->modem()->lockdevice(); |
227 | 226 | ||
228 | if (lock == 1) { | 227 | if (lock == 1) { |
229 | messg->setText(i18n("Modem device is locked.")); | 228 | messg->setText(QObject::tr("Modem device is locked.")); |
230 | vmain = 20; // wait until cancel is pressed | 229 | vmain = 20; // wait until cancel is pressed |
231 | return; | 230 | return; |
232 | } | 231 | } |
233 | 232 | ||
234 | if (lock == -1) { | 233 | if (lock == -1) { |
235 | messg->setText(i18n("Unable to create modem lock file.")); | 234 | messg->setText(QObject::tr("Unable to create modem lock file.")); |
236 | vmain = 20; // wait until cancel is pressed | 235 | vmain = 20; // wait until cancel is pressed |
237 | return; | 236 | return; |
238 | } | 237 | } |
239 | 238 | ||
240 | if(_ifaceppp->modem()->opentty()) { | 239 | if(_ifaceppp->modem()->opentty()) { |
241 | messg->setText(_ifaceppp->modem()->modemMessage()); | 240 | messg->setText(_ifaceppp->modem()->modemMessage()); |
242 | qApp->processEvents(); | 241 | qApp->processEvents(); |
243 | if(_ifaceppp->modem()->hangup()) { | 242 | if(_ifaceppp->modem()->hangup()) { |
244 | 243 | ||
245 | qApp->processEvents(); | 244 | qApp->processEvents(); |
246 | 245 | ||
247 | semaphore = false; | 246 | semaphore = false; |
248 | 247 | ||
249 | _ifaceppp->modem()->stop(); | 248 | _ifaceppp->modem()->stop(); |
250 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); | 249 | _ifaceppp->modem()->notify(this, SLOT(readChar(unsigned char))); |
251 | 250 | ||
252 | // if we are stuck anywhere we will time out | 251 | // if we are stuck anywhere we will time out |
253 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 252 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
254 | 253 | ||
255 | // this timer will run the script etc. | 254 | // this timer will run the script etc. |
256 | main_timer_ID = startTimer(10); | 255 | main_timer_ID = startTimer(10); |
257 | 256 | ||
258 | return; | 257 | return; |
259 | } | 258 | } |
260 | } | 259 | } |
261 | 260 | ||
262 | // initialization failed | 261 | // initialization failed |
263 | messg->setText(_ifaceppp->modem()->modemMessage()); | 262 | messg->setText(_ifaceppp->modem()->modemMessage()); |
264 | vmain = 20; // wait until cancel is pressed | 263 | vmain = 20; // wait until cancel is pressed |
265 | _ifaceppp->modem()->unlockdevice(); | 264 | _ifaceppp->modem()->unlockdevice(); |
266 | } | 265 | } |
267 | 266 | ||
268 | 267 | ||
269 | void ConnectWidget::timerEvent(QTimerEvent *) { | 268 | void ConnectWidget::timerEvent(QTimerEvent *) { |
270 | if (semaphore || pausing) | 269 | if (semaphore || pausing) |
271 | return; | 270 | return; |
272 | 271 | ||
273 | if(vmain == 0) { | 272 | if(vmain == 0) { |
274 | #ifdef DEBUG_WO_DIALING | 273 | #ifdef DEBUG_WO_DIALING |
275 | vmain = 10; | 274 | vmain = 10; |
276 | return; | 275 | return; |
277 | #endif | 276 | #endif |
278 | 277 | ||
279 | assert(PPPData::NumInitStrings > 0); | 278 | assert(PPPData::NumInitStrings > 0); |
280 | // first init string ? | 279 | // first init string ? |
281 | if(substate == -1) { | 280 | if(substate == -1) { |
282 | messg->setText(i18n("Initializing modem...")); | 281 | messg->setText(QObject::tr("Initializing modem...")); |
283 | emit debugMessage(i18n("Initializing modem...")); | 282 | emit debugMessage(QObject::tr("Initializing modem...")); |
284 | substate = 0; | 283 | substate = 0; |
285 | } | 284 | } |
286 | 285 | ||
287 | QString initStr = _ifaceppp->data()->modemInitStr(substate); | 286 | QString initStr = _ifaceppp->data()->modemInitStr(substate); |
288 | if (!initStr.isEmpty()) { | 287 | if (!initStr.isEmpty()) { |
289 | // send a carriage return and then wait a bit so that the modem will | 288 | // send a carriage return and then wait a bit so that the modem will |
290 | // let us issue commands. | 289 | // let us issue commands. |
291 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { | 290 | if(_ifaceppp->data()->modemPreInitDelay() > 0) { |
292 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 291 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
293 | writeline(""); | 292 | writeline(""); |
294 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); | 293 | usleep(_ifaceppp->data()->modemPreInitDelay() * 5000); |
295 | } | 294 | } |
296 | setExpect(_ifaceppp->data()->modemInitResp()); | 295 | setExpect(_ifaceppp->data()->modemInitResp()); |
297 | writeline(initStr); | 296 | writeline(initStr); |
298 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 297 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
299 | } | 298 | } |
300 | 299 | ||
301 | substate++; | 300 | substate++; |
302 | 301 | ||
303 | /* | 302 | /* |
304 | * FIXME after 3.0: Make it possible to disable ATS11 since it | 303 | * FIXME after 3.0: Make it possible to disable ATS11 since it |
305 | * seems to be incompatible with some ISDN adapters (e.g. DataBox | 304 | * seems to be incompatible with some ISDN adapters (e.g. DataBox |
306 | * Speed Dragon). Even better would be to detect this when doing | 305 | * Speed Dragon). Even better would be to detect this when doing |
307 | * a "Modem Query" | 306 | * a "Modem Query" |
308 | */ | 307 | */ |
309 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) | 308 | if (MODEM_TONEDURATION != _ifaceppp->data()->modemToneDuration()) |
310 | vmain = 5; | 309 | vmain = 5; |
311 | else | 310 | else |
312 | vmain = 3; | 311 | vmain = 3; |
313 | 312 | ||
314 | return; | 313 | return; |
315 | } | 314 | } |
316 | 315 | ||
317 | if (vmain == 5) { | 316 | if (vmain == 5) { |
318 | if(!expecting) { | 317 | if(!expecting) { |
319 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); | 318 | QString sToneDuration = "ATS11=" + QString::number(_ifaceppp->data()->modemToneDuration()); |
320 | QString msg = i18n("Setting ") + sToneDuration; | 319 | QString msg = QObject::tr("Setting ") + sToneDuration; |
321 | messg->setText(msg); | 320 | messg->setText(msg); |
322 | emit debugMessage(msg); | 321 | emit debugMessage(msg); |
323 | setExpect(_ifaceppp->data()->modemInitResp()); | 322 | setExpect(_ifaceppp->data()->modemInitResp()); |
324 | writeline(sToneDuration); | 323 | writeline(sToneDuration); |
325 | } | 324 | } |
326 | vmain = 3; | 325 | vmain = 3; |
327 | return; | 326 | return; |
328 | } | 327 | } |
329 | 328 | ||
330 | if(vmain == 3) { | 329 | if(vmain == 3) { |
331 | if(!expecting) { | 330 | if(!expecting) { |
332 | // done with all init strings ? | 331 | // done with all init strings ? |
333 | if(substate < PPPData::NumInitStrings) { | 332 | if(substate < PPPData::NumInitStrings) { |
334 | vmain = 0; | 333 | vmain = 0; |
335 | return; | 334 | return; |
336 | } | 335 | } |
337 | substate = -1; | 336 | substate = -1; |
338 | // skip setting the volume if command is empty | 337 | // skip setting the volume if command is empty |
339 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { | 338 | if(_ifaceppp->data()->volumeInitString().isEmpty()) { |
340 | vmain = 4; | 339 | vmain = 4; |
341 | return; | 340 | return; |
342 | } | 341 | } |
343 | messg->setText(i18n("Setting speaker volume...")); | 342 | messg->setText(QObject::tr("Setting speaker volume...")); |
344 | emit debugMessage(i18n("Setting speaker volume...")); | 343 | emit debugMessage(QObject::tr("Setting speaker volume...")); |
345 | 344 | ||
346 | setExpect(_ifaceppp->data()->modemInitResp()); | 345 | setExpect(_ifaceppp->data()->modemInitResp()); |
347 | QString vol("AT"); | 346 | QString vol("AT"); |
348 | vol += _ifaceppp->data()->volumeInitString(); | 347 | vol += _ifaceppp->data()->volumeInitString(); |
349 | writeline(vol); | 348 | writeline(vol); |
350 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 349 | usleep(_ifaceppp->data()->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
351 | vmain = 4; | 350 | vmain = 4; |
352 | return; | 351 | return; |
353 | } | 352 | } |
354 | } | 353 | } |
355 | 354 | ||
356 | if(vmain == 4) { | 355 | if(vmain == 4) { |
357 | if(!expecting) { | 356 | if(!expecting) { |
358 | if(!_ifaceppp->data()->waitForDialTone()) { | 357 | if(!_ifaceppp->data()->waitForDialTone()) { |
359 | QString msg = i18n("Turning off dial tone waiting..."); | 358 | QString msg = QObject::tr("Turning off dial tone waiting..."); |
360 | messg->setText(msg); | 359 | messg->setText(msg); |
361 | emit debugMessage(msg); | 360 | emit debugMessage(msg); |
362 | setExpect(_ifaceppp->data()->modemInitResp()); | 361 | setExpect(_ifaceppp->data()->modemInitResp()); |
363 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); | 362 | writeline(_ifaceppp->data()->modemNoDialToneDetectionStr()); |
364 | } | 363 | } |
365 | vmain = 1; | 364 | vmain = 1; |
366 | return; | 365 | return; |
367 | } | 366 | } |
368 | } | 367 | } |
369 | 368 | ||
370 | // dial the number and wait to connect | 369 | // dial the number and wait to connect |
371 | if(vmain == 1) { | 370 | if(vmain == 1) { |
372 | if(!expecting) { | 371 | if(!expecting) { |
373 | 372 | ||
374 | timeout_timer->stop(); | 373 | timeout_timer->stop(); |
375 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 374 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
376 | 375 | ||
377 | QStringList &plist = _ifaceppp->data()->phonenumbers(); | 376 | QStringList &plist = _ifaceppp->data()->phonenumbers(); |
378 | QString bmarg= _ifaceppp->data()->dialPrefix(); | 377 | QString bmarg= _ifaceppp->data()->dialPrefix(); |
379 | bmarg += *plist.at(dialnumber); | 378 | bmarg += *plist.at(dialnumber); |
380 | QString bm = i18n("Dialing %1").arg(bmarg); | 379 | QString bm = QObject::tr("Dialing %1").arg(bmarg); |
381 | messg->setText(bm); | 380 | messg->setText(bm); |
382 | emit debugMessage(bm); | 381 | emit debugMessage(bm); |
383 | 382 | ||
384 | QString pn = _ifaceppp->data()->modemDialStr(); | 383 | QString pn = _ifaceppp->data()->modemDialStr(); |
385 | pn += _ifaceppp->data()->dialPrefix(); | 384 | pn += _ifaceppp->data()->dialPrefix(); |
386 | pn += *plist.at(dialnumber); | 385 | pn += *plist.at(dialnumber); |
387 | if(++dialnumber >= plist.count()) | 386 | if(++dialnumber >= plist.count()) |
388 | dialnumber = 0; | 387 | dialnumber = 0; |
389 | writeline(pn); | 388 | writeline(pn); |
390 | 389 | ||
391 | setExpect(_ifaceppp->data()->modemConnectResp()); | 390 | setExpect(_ifaceppp->data()->modemConnectResp()); |
392 | vmain = 100; | 391 | vmain = 100; |
393 | return; | 392 | return; |
394 | } | 393 | } |
395 | } | 394 | } |
396 | 395 | ||
397 | // wait for connect, but redial if BUSY or wait for user cancel | 396 | // wait for connect, but redial if BUSY or wait for user cancel |
398 | // if NO CARRIER or NO DIALTONE | 397 | // if NO CARRIER or NO DIALTONE |
399 | if(vmain == 100) { | 398 | if(vmain == 100) { |
400 | if(!expecting) { | 399 | if(!expecting) { |
401 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); | 400 | myreadbuffer = _ifaceppp->data()->modemConnectResp(); |
402 | setExpect("\n"); | 401 | setExpect("\n"); |
403 | vmain = 101; | 402 | vmain = 101; |
404 | return; | 403 | return; |
405 | } | 404 | } |
406 | 405 | ||
407 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { | 406 | if(readbuffer.contains(_ifaceppp->data()->modemBusyResp())) { |
408 | timeout_timer->stop(); | 407 | timeout_timer->stop(); |
409 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); | 408 | timeout_timer->start(_ifaceppp->data()->modemTimeout()*1000); |
410 | 409 | ||
411 | messg->setText(i18n("Line busy. Hanging up...")); | 410 | messg->setText(QObject::tr("Line busy. Hanging up...")); |
412 | emit debugPutChar('\n'); | 411 | emit debugPutChar('\n'); |
413 | _ifaceppp->modem()->hangup(); | 412 | _ifaceppp->modem()->hangup(); |
414 | 413 | ||
415 | if(_ifaceppp->data()->busyWait() > 0) { | 414 | if(_ifaceppp->data()->busyWait() > 0) { |
416 | QString bm = i18n("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); | 415 | QString bm = QObject::tr("Line busy. Waiting: %1 seconds").arg(_ifaceppp->data()->busyWait()); |
417 | messg->setText(bm); | 416 | messg->setText(bm); |
418 | emit debugMessage(bm); | 417 | emit debugMessage(bm); |
419 | 418 | ||
420 | pausing = true; | 419 | pausing = true; |
421 | 420 | ||
422 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); | 421 | pausetimer->start(_ifaceppp->data()->busyWait()*1000, true); |
423 | timeout_timer->stop(); | 422 | timeout_timer->stop(); |
424 | } | 423 | } |
425 | 424 | ||
426 | _ifaceppp->modem()->setDataMode(false); | 425 | _ifaceppp->modem()->setDataMode(false); |
427 | vmain = 0; | 426 | vmain = 0; |
428 | substate = -1; | 427 | substate = -1; |
429 | return; | 428 | return; |
430 | } | 429 | } |
431 | 430 | ||
432 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { | 431 | if(readbuffer.contains(_ifaceppp->data()->modemNoDialtoneResp())) { |
433 | timeout_timer->stop(); | 432 | timeout_timer->stop(); |
434 | 433 | ||
435 | messg->setText(i18n("No Dialtone")); | 434 | messg->setText(QObject::tr("No Dialtone")); |
436 | vmain = 20; | 435 | vmain = 20; |
437 | _ifaceppp->modem()->unlockdevice(); | 436 | _ifaceppp->modem()->unlockdevice(); |
438 | return; | 437 | return; |
439 | } | 438 | } |
440 | 439 | ||
441 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { | 440 | if(readbuffer.contains(_ifaceppp->data()->modemNoCarrierResp())) { |
442 | timeout_timer->stop(); | 441 | timeout_timer->stop(); |
443 | 442 | ||
444 | messg->setText(i18n("No Carrier")); | 443 | messg->setText(QObject::tr("No Carrier")); |
445 | vmain = 20; | 444 | vmain = 20; |
446 | _ifaceppp->modem()->unlockdevice(); | 445 | _ifaceppp->modem()->unlockdevice(); |
447 | return; | 446 | return; |
448 | } | 447 | } |
449 | } | 448 | } |
450 | 449 | ||
451 | // wait for newline after CONNECT response (so we get the speed) | 450 | // wait for newline after CONNECT response (so we get the speed) |
452 | if(vmain == 101) { | 451 | if(vmain == 101) { |
453 | if(!expecting) { | 452 | if(!expecting) { |
454 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands | 453 | _ifaceppp->modem()->setDataMode(true); // modem will no longer respond to AT commands |
455 | 454 | ||
456 | emit startAccounting(); | 455 | emit startAccounting(); |
457 | // p_kppp->con_win->startClock(); | 456 | // p_kppp->con_win->startClock(); |
458 | 457 | ||
459 | vmain = 2; | 458 | vmain = 2; |
460 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; | 459 | scriptTimeout=_ifaceppp->data()->modemTimeout()*1000; |
461 | return; | 460 | return; |
462 | } | 461 | } |
463 | } | 462 | } |
464 | 463 | ||
465 | // execute the script | 464 | // execute the script |
466 | if(vmain == 2) { | 465 | if(vmain == 2) { |
467 | if(!expecting && !pausing && !scanning) { | 466 | if(!expecting && !pausing && !scanning) { |
468 | 467 | ||
469 | timeout_timer->stop(); | 468 | timeout_timer->stop(); |
470 | timeout_timer->start(scriptTimeout); | 469 | timeout_timer->start(scriptTimeout); |
471 | 470 | ||
472 | if((unsigned) scriptindex < comlist->count()) { | 471 | if((unsigned) scriptindex < comlist->count()) { |
473 | scriptCommand = *(comlist->at(scriptindex)); | 472 | scriptCommand = *(comlist->at(scriptindex)); |
474 | scriptArgument = *(arglist->at(scriptindex)); | 473 | scriptArgument = *(arglist->at(scriptindex)); |
475 | } else { | 474 | } else { |
476 | qDebug( "End of script" ); | 475 | qDebug( "End of script" ); |
477 | vmain = 10; | 476 | vmain = 10; |
478 | return; | 477 | return; |
479 | } | 478 | } |
480 | 479 | ||
481 | if (scriptCommand == "Scan") { | 480 | if (scriptCommand == "Scan") { |
482 | QString bm = i18n("Scanning %1").arg(scriptArgument); | 481 | QString bm = QObject::tr("Scanning %1").arg(scriptArgument); |
483 | messg->setText(bm); | 482 | messg->setText(bm); |
484 | emit debugMessage(bm); | 483 | emit debugMessage(bm); |
485 | 484 | ||
486 | setScan(scriptArgument); | 485 | setScan(scriptArgument); |
487 | scriptindex++; | 486 | scriptindex++; |
488 | return; | 487 | return; |
489 | } | 488 | } |
490 | 489 | ||
491 | if (scriptCommand == "Save") { | 490 | if (scriptCommand == "Save") { |
492 | QString bm = i18n("Saving %1").arg(scriptArgument); | 491 | QString bm = QObject::tr("Saving %1").arg(scriptArgument); |
493 | messg->setText(bm); | 492 | messg->setText(bm); |
494 | emit debugMessage(bm); | 493 | emit debugMessage(bm); |
495 | 494 | ||
496 | if (scriptArgument.lower() == "password") { | 495 | if (scriptArgument.lower() == "password") { |
497 | _ifaceppp->data()->setPassword(scanvar); | 496 | _ifaceppp->data()->setPassword(scanvar); |
498 | // p_kppp->setPW_Edit(scanvar); | 497 | // p_kppp->setPW_Edit(scanvar); |
499 | if(_ifaceppp->data()->storePassword()) | 498 | if(_ifaceppp->data()->storePassword()) |
500 | _ifaceppp->data()->setStoredPassword(scanvar); | 499 | _ifaceppp->data()->setStoredPassword(scanvar); |
501 | firstrunPW = true; | 500 | firstrunPW = true; |
502 | } | 501 | } |
503 | 502 | ||
504 | scriptindex++; | 503 | scriptindex++; |
505 | return; | 504 | return; |
506 | } | 505 | } |
507 | 506 | ||
508 | 507 | ||
509 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { | 508 | if (scriptCommand == "Send" || scriptCommand == "SendNoEcho") { |
510 | QString bm = i18n("Sending %1"); | 509 | QString bm = QObject::tr("Sending %1"); |
511 | 510 | ||
512 | // replace %USERNAME% and %PASSWORD% | 511 | // replace %USERNAME% and %PASSWORD% |
513 | QString arg = scriptArgument; | 512 | QString arg = scriptArgument; |
514 | QRegExp re1("%USERNAME%"); | 513 | QRegExp re1("%USERNAME%"); |
515 | QRegExp re2("%PASSWORD%"); | 514 | QRegExp re2("%PASSWORD%"); |
516 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); | 515 | arg = arg.replace(re1, _ifaceppp->data()->storedUsername()); |
517 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); | 516 | arg = arg.replace(re2, _ifaceppp->data()->storedPassword()); |
518 | 517 | ||
519 | if (scriptCommand == "Send") | 518 | if (scriptCommand == "Send") |
520 | bm = bm.arg(scriptArgument); | 519 | bm = bm.arg(scriptArgument); |
521 | else { | 520 | else { |
522 | for(uint i = 0; i < scriptArgument.length(); i++) | 521 | for(uint i = 0; i < scriptArgument.length(); i++) |
523 | bm = bm.arg("*"); | 522 | bm = bm.arg("*"); |
524 | } | 523 | } |
525 | 524 | ||
526 | messg->setText(bm); | 525 | messg->setText(bm); |
527 | emit debugMessage(bm); | 526 | emit debugMessage(bm); |
528 | 527 | ||
529 | writeline(scriptArgument); | 528 | writeline(scriptArgument); |
530 | scriptindex++; | 529 | scriptindex++; |
531 | return; | 530 | return; |
532 | } | 531 | } |
533 | 532 | ||
534 | if (scriptCommand == "Expect") { | 533 | if (scriptCommand == "Expect") { |
535 | QString bm = i18n("Expecting %1").arg(scriptArgument); | 534 | QString bm = QObject::tr("Expecting %1").arg(scriptArgument); |
536 | messg->setText(bm); | 535 | messg->setText(bm); |
537 | emit debugMessage(bm); | 536 | emit debugMessage(bm); |
538 | 537 | ||
539 | // The incrementing of the scriptindex MUST be before the | 538 | // The incrementing of the scriptindex MUST be before the |
540 | // call to setExpect otherwise the expect will miss a string that is | 539 | // call to setExpect otherwise the expect will miss a string that is |
541 | // already in the buffer. | 540 | // already in the buffer. |
542 | scriptindex++; | 541 | scriptindex++; |
543 | setExpect(scriptArgument); | 542 | setExpect(scriptArgument); |
544 | return; | 543 | return; |
545 | } | 544 | } |
546 | 545 | ||
547 | 546 | ||
548 | if (scriptCommand == "Pause") { | 547 | if (scriptCommand == "Pause") { |
549 | QString bm = i18n("Pause %1 seconds").arg(scriptArgument); | 548 | QString bm = QObject::tr("Pause %1 seconds").arg(scriptArgument); |
550 | messg->setText(bm); | 549 | messg->setText(bm); |
551 | emit debugMessage(bm); | 550 | emit debugMessage(bm); |
552 | 551 | ||
553 | pausing = true; | 552 | pausing = true; |
554 | 553 | ||
555 | pausetimer->start(scriptArgument.toInt()*1000, true); | 554 | pausetimer->start(scriptArgument.toInt()*1000, true); |
556 | timeout_timer->stop(); | 555 | timeout_timer->stop(); |
557 | 556 | ||
558 | scriptindex++; | 557 | scriptindex++; |
559 | return; | 558 | return; |
560 | } | 559 | } |
561 | 560 | ||
562 | if (scriptCommand == "Timeout") { | 561 | if (scriptCommand == "Timeout") { |
563 | 562 | ||
564 | timeout_timer->stop(); | 563 | timeout_timer->stop(); |
565 | 564 | ||
566 | QString bm = i18n("Timeout %1 seconds").arg(scriptArgument); | 565 | QString bm = QObject::tr("Timeout %1 seconds").arg(scriptArgument); |
567 | messg->setText(bm); | 566 | messg->setText(bm); |
568 | emit debugMessage(bm); | 567 | emit debugMessage(bm); |
569 | 568 | ||
570 | scriptTimeout=scriptArgument.toInt()*1000; | 569 | scriptTimeout=scriptArgument.toInt()*1000; |
571 | timeout_timer->start(scriptTimeout); | 570 | timeout_timer->start(scriptTimeout); |
572 | 571 | ||
573 | scriptindex++; | 572 | scriptindex++; |
574 | return; | 573 | return; |
575 | } | 574 | } |
576 | 575 | ||
577 | if (scriptCommand == "Hangup") { | 576 | if (scriptCommand == "Hangup") { |
578 | messg->setText(i18n("Hangup")); | 577 | messg->setText(QObject::tr("Hangup")); |
579 | emit debugMessage(i18n("Hangup")); | 578 | emit debugMessage(QObject::tr("Hangup")); |
580 | 579 | ||
581 | writeline(_ifaceppp->data()->modemHangupStr()); | 580 | writeline(_ifaceppp->data()->modemHangupStr()); |
582 | setExpect(_ifaceppp->data()->modemHangupResp()); | 581 | setExpect(_ifaceppp->data()->modemHangupResp()); |
583 | 582 | ||
584 | scriptindex++; | 583 | scriptindex++; |
585 | return; | 584 | return; |
586 | } | 585 | } |
587 | 586 | ||
588 | if (scriptCommand == "Answer") { | 587 | if (scriptCommand == "Answer") { |
589 | 588 | ||
590 | timeout_timer->stop(); | 589 | timeout_timer->stop(); |
591 | 590 | ||
592 | messg->setText(i18n("Answer")); | 591 | messg->setText(QObject::tr("Answer")); |
593 | emit debugMessage(i18n("Answer")); | 592 | emit debugMessage(QObject::tr("Answer")); |
594 | 593 | ||
595 | setExpect(_ifaceppp->data()->modemRingResp()); | 594 | setExpect(_ifaceppp->data()->modemRingResp()); |
596 | vmain = 150; | 595 | vmain = 150; |
597 | return; | 596 | return; |
598 | } | 597 | } |
599 | 598 | ||
600 | if (scriptCommand == "ID") { | 599 | if (scriptCommand == "ID") { |
601 | QString bm = i18n("ID %1").arg(scriptArgument); | 600 | QString bm = QObject::tr("ID %1").arg(scriptArgument); |
602 | messg->setText(bm); | 601 | messg->setText(bm); |
603 | emit debugMessage(bm); | 602 | emit debugMessage(bm); |
604 | 603 | ||
605 | QString idstring = _ifaceppp->data()->password(); | 604 | QString idstring = _ifaceppp->data()->password(); |
606 | 605 | ||
607 | if(!idstring.isEmpty() && firstrunID) { | 606 | if(!idstring.isEmpty() && firstrunID) { |
608 | // the user entered an Id on the main kppp dialog | 607 | // the user entered an Id on the main kppp dialog |
609 | writeline(idstring); | 608 | writeline(idstring); |
610 | firstrunID = false; | 609 | firstrunID = false; |
611 | scriptindex++; | 610 | scriptindex++; |
612 | } | 611 | } |
613 | else { | 612 | else { |
614 | // the user didn't enter and Id on the main kppp dialog | 613 | // the user didn't enter and Id on the main kppp dialog |
615 | // let's query for an ID | 614 | // let's query for an ID |
616 | /* if not around yet, then post window... */ | 615 | /* if not around yet, then post window... */ |
617 | if (prompt->Consumed()) { | 616 | if (prompt->Consumed()) { |
618 | if (!(prompt->isVisible())) { | 617 | if (!(prompt->isVisible())) { |
619 | prompt->setPrompt(scriptArgument); | 618 | prompt->setPrompt(scriptArgument); |
620 | prompt->setEchoModeNormal(); | 619 | prompt->setEchoModeNormal(); |
621 | prompt->show(); | 620 | prompt->show(); |
622 | } | 621 | } |
623 | } else { | 622 | } else { |
624 | /* if prompt withdrawn ... then, */ | 623 | /* if prompt withdrawn ... then, */ |
625 | if(!(prompt->isVisible())) { | 624 | if(!(prompt->isVisible())) { |
626 | writeline(prompt->text()); | 625 | writeline(prompt->text()); |
627 | prompt->setConsumed(); | 626 | prompt->setConsumed(); |
628 | scriptindex++; | 627 | scriptindex++; |
629 | return; | 628 | return; |
630 | } | 629 | } |
631 | /* replace timeout value */ | 630 | /* replace timeout value */ |
632 | } | 631 | } |
633 | } | 632 | } |
634 | } | 633 | } |
635 | 634 | ||
636 | if (scriptCommand == "Password") { | 635 | if (scriptCommand == "Password") { |
637 | QString bm = i18n("Password %1").arg(scriptArgument); | 636 | QString bm = QObject::tr("Password %1").arg(scriptArgument); |
638 | messg->setText(bm); | 637 | messg->setText(bm); |
639 | emit debugMessage(bm); | 638 | emit debugMessage(bm); |
640 | 639 | ||
641 | QString pwstring = _ifaceppp->data()->password(); | 640 | QString pwstring = _ifaceppp->data()->password(); |
642 | 641 | ||
643 | if(!pwstring.isEmpty() && firstrunPW) { | 642 | if(!pwstring.isEmpty() && firstrunPW) { |
644 | // the user entered a password on the main kppp dialog | 643 | // the user entered a password on the main kppp dialog |
645 | writeline(pwstring); | 644 | writeline(pwstring); |
646 | firstrunPW = false; | 645 | firstrunPW = false; |
647 | scriptindex++; | 646 | scriptindex++; |
648 | } | 647 | } |
649 | else { | 648 | else { |
650 | // the user didn't enter a password on the main kppp dialog | 649 | // the user didn't enter a password on the main kppp dialog |
651 | // let's query for a password | 650 | // let's query for a password |
652 | /* if not around yet, then post window... */ | 651 | /* if not around yet, then post window... */ |
653 | if (prompt->Consumed()) { | 652 | if (prompt->Consumed()) { |
654 | if (!(prompt->isVisible())) { | 653 | if (!(prompt->isVisible())) { |
655 | prompt->setPrompt(scriptArgument); | 654 | prompt->setPrompt(scriptArgument); |
656 | prompt->setEchoModePassword(); | 655 | prompt->setEchoModePassword(); |
657 | prompt->show(); | 656 | prompt->show(); |
658 | } | 657 | } |
659 | } else { | 658 | } else { |
660 | /* if prompt withdrawn ... then, */ | 659 | /* if prompt withdrawn ... then, */ |
661 | if(!(prompt->isVisible())) { | 660 | if(!(prompt->isVisible())) { |
662 | // p_kppp->setPW_Edit(prompt->text()); | 661 | // p_kppp->setPW_Edit(prompt->text()); |
663 | writeline(prompt->text()); | 662 | writeline(prompt->text()); |
664 | prompt->setConsumed(); | 663 | prompt->setConsumed(); |
665 | scriptindex++; | 664 | scriptindex++; |
666 | return; | 665 | return; |
667 | } | 666 | } |
668 | /* replace timeout value */ | 667 | /* replace timeout value */ |
669 | } | 668 | } |
670 | } | 669 | } |
671 | } | 670 | } |
672 | 671 | ||
673 | if (scriptCommand == "Prompt") { | 672 | if (scriptCommand == "Prompt") { |
674 | QString bm = i18n("Prompting %1"); | 673 | QString bm = QObject::tr("Prompting %1"); |
675 | 674 | ||
676 | // if the scriptindex (aka the prompt text) includes a ## marker | 675 | // if the scriptindex (aka the prompt text) includes a ## marker |
677 | // this marker should get substituted with the contents of our stored | 676 | // this marker should get substituted with the contents of our stored |
678 | // variable (from the subsequent scan). | 677 | // variable (from the subsequent scan). |
679 | 678 | ||
680 | QString ts = scriptArgument; | 679 | QString ts = scriptArgument; |
681 | int vstart = ts.find( "##" ); | 680 | int vstart = ts.find( "##" ); |
682 | if( vstart != -1 ) { | 681 | if( vstart != -1 ) { |
683 | ts.remove( vstart, 2 ); | 682 | ts.remove( vstart, 2 ); |
684 | ts.insert( vstart, scanvar ); | 683 | ts.insert( vstart, scanvar ); |
685 | } | 684 | } |
686 | 685 | ||
687 | bm = bm.arg(ts); | 686 | bm = bm.arg(ts); |
688 | messg->setText(bm); | 687 | messg->setText(bm); |
689 | emit debugMessage(bm); | 688 | emit debugMessage(bm); |
690 | 689 | ||
691 | /* if not around yet, then post window... */ | 690 | /* if not around yet, then post window... */ |
692 | if (prompt->Consumed()) { | 691 | if (prompt->Consumed()) { |
693 | if (!(prompt->isVisible())) { | 692 | if (!(prompt->isVisible())) { |
694 | prompt->setPrompt( ts ); | 693 | prompt->setPrompt( ts ); |
695 | prompt->setEchoModeNormal(); | 694 | prompt->setEchoModeNormal(); |
696 | prompt->show(); | 695 | prompt->show(); |
697 | } | 696 | } |
698 | } else { | 697 | } else { |
699 | /* if prompt withdrawn ... then, */ | 698 | /* if prompt withdrawn ... then, */ |
700 | if (!(prompt->isVisible())) { | 699 | if (!(prompt->isVisible())) { |
701 | writeline(prompt->text()); | 700 | writeline(prompt->text()); |
702 | prompt->setConsumed(); | 701 | prompt->setConsumed(); |
703 | scriptindex++; | 702 | scriptindex++; |
704 | return; | 703 | return; |
705 | } | 704 | } |
706 | /* replace timeout value */ | 705 | /* replace timeout value */ |
707 | } | 706 | } |
708 | } | 707 | } |
709 | 708 | ||
710 | if (scriptCommand == "PWPrompt") { | 709 | if (scriptCommand == "PWPrompt") { |
711 | QString bm = i18n("PW Prompt %1").arg(scriptArgument); | 710 | QString bm = QObject::tr("PW Prompt %1").arg(scriptArgument); |
712 | messg->setText(bm); | 711 | messg->setText(bm); |
713 | emit debugMessage(bm); | 712 | emit debugMessage(bm); |
714 | 713 | ||
715 | /* if not around yet, then post window... */ | 714 | /* if not around yet, then post window... */ |
716 | if (prompt->Consumed()) { | 715 | if (prompt->Consumed()) { |
717 | if (!(prompt->isVisible())) { | 716 | if (!(prompt->isVisible())) { |
718 | prompt->setPrompt(scriptArgument); | 717 | prompt->setPrompt(scriptArgument); |
719 | prompt->setEchoModePassword(); | 718 | prompt->setEchoModePassword(); |
720 | prompt->show(); | 719 | prompt->show(); |
721 | } | 720 | } |
722 | } else { | 721 | } else { |
723 | /* if prompt withdrawn ... then, */ | 722 | /* if prompt withdrawn ... then, */ |
724 | if (!(prompt->isVisible())) { | 723 | if (!(prompt->isVisible())) { |
725 | writeline(prompt->text()); | 724 | writeline(prompt->text()); |
726 | prompt->setConsumed(); | 725 | prompt->setConsumed(); |
727 | scriptindex++; | 726 | scriptindex++; |
728 | return; | 727 | return; |
729 | } | 728 | } |
730 | /* replace timeout value */ | 729 | /* replace timeout value */ |
731 | } | 730 | } |
732 | } | 731 | } |
733 | 732 | ||
734 | if (scriptCommand == "LoopStart") { | 733 | if (scriptCommand == "LoopStart") { |
735 | 734 | ||
736 | QString bm = i18n("Loop Start %1").arg(scriptArgument); | 735 | QString bm = QObject::tr("Loop Start %1").arg(scriptArgument); |
737 | 736 | ||
738 | // The incrementing of the scriptindex MUST be before the | 737 | // The incrementing of the scriptindex MUST be before the |
739 | // call to setExpect otherwise the expect will miss a string that is | 738 | // call to setExpect otherwise the expect will miss a string that is |
740 | // already in the buffer. | 739 | // already in the buffer. |
741 | scriptindex++; | 740 | scriptindex++; |
742 | 741 | ||
743 | if ( loopnest > (MAXLOOPNEST-2) ) { | 742 | if ( loopnest > (MAXLOOPNEST-2) ) { |
744 | bm += i18n("ERROR: Nested too deep, ignored."); | 743 | bm += QObject::tr("ERROR: Nested too deep, ignored."); |
745 | vmain=20; | 744 | vmain=20; |
746 | cancelbutton(); | 745 | cancelbutton(); |
747 | QMessageBox::critical(0, "error", i18n("Loops nested too deeply!")); | 746 | QMessageBox::critical(0, "error", QObject::tr("Loops nested too deeply!")); |
748 | } else { | 747 | } else { |
749 | setExpect(scriptArgument); | 748 | setExpect(scriptArgument); |
750 | loopstartindex[loopnest] = scriptindex; | 749 | loopstartindex[loopnest] = scriptindex; |
751 | loopstr[loopnest] = scriptArgument; | 750 | loopstr[loopnest] = scriptArgument; |
752 | loopend = false; | 751 | loopend = false; |
753 | loopnest++; | 752 | loopnest++; |
754 | } | 753 | } |
755 | messg->setText(bm); | 754 | messg->setText(bm); |
756 | emit debugMessage(bm); | 755 | emit debugMessage(bm); |
757 | 756 | ||
758 | } | 757 | } |
759 | 758 | ||
760 | if (scriptCommand == "LoopEnd") { | 759 | if (scriptCommand == "LoopEnd") { |
761 | QString bm = i18n("Loop End %1").arg(scriptArgument); | 760 | QString bm = QObject::tr("Loop End %1").arg(scriptArgument); |
762 | if ( loopnest <= 0 ) { | 761 | if ( loopnest <= 0 ) { |
763 | bm = i18n("LoopEnd without matching Start! Line: %1").arg(bm); | 762 | bm = QObject::tr("LoopEnd without matching Start! Line: %1").arg(bm); |
764 | vmain=20; | 763 | vmain=20; |
765 | cancelbutton(); | 764 | cancelbutton(); |
766 | QMessageBox::critical(0, "error", bm); | 765 | QMessageBox::critical(0, "error", bm); |
767 | return; | 766 | return; |
768 | } else { | 767 | } else { |
769 | // NB! The incrementing of the scriptindex MUST be before the | 768 | // NB! The incrementing of the scriptindex MUST be before the |
770 | // call to setExpect otherwise the expect will miss a string | 769 | // call to setExpect otherwise the expect will miss a string |
771 | // that is already in the buffer. | 770 | // that is already in the buffer. |
772 | scriptindex++; | 771 | scriptindex++; |
773 | setExpect(scriptArgument); | 772 | setExpect(scriptArgument); |
774 | loopnest--; | 773 | loopnest--; |
775 | loopend = true; | 774 | loopend = true; |
776 | } | 775 | } |
777 | messg->setText(bm); | 776 | messg->setText(bm); |
778 | emit debugMessage(bm); | 777 | emit debugMessage(bm); |
779 | 778 | ||
780 | } | 779 | } |
781 | } | 780 | } |
782 | } | 781 | } |
783 | 782 | ||
784 | // this is a subroutine for the "Answer" script option | 783 | // this is a subroutine for the "Answer" script option |
785 | 784 | ||
786 | if(vmain == 150) { | 785 | if(vmain == 150) { |
787 | if(!expecting) { | 786 | if(!expecting) { |
788 | writeline(_ifaceppp->data()->modemAnswerStr()); | 787 | writeline(_ifaceppp->data()->modemAnswerStr()); |
789 | setExpect(_ifaceppp->data()->modemAnswerResp()); | 788 | setExpect(_ifaceppp->data()->modemAnswerResp()); |
790 | 789 | ||
791 | vmain = 2; | 790 | vmain = 2; |
792 | scriptindex++; | 791 | scriptindex++; |
793 | return; | 792 | return; |
794 | } | 793 | } |
795 | } | 794 | } |
796 | 795 | ||
797 | if(vmain == 30) { | 796 | if(vmain == 30) { |
798 | // if (termwindow->isVisible()) | 797 | // if (termwindow->isVisible()) |
799 | // return; | 798 | // return; |
800 | // if (termwindow->pressedContinue()) | 799 | // if (termwindow->pressedContinue()) |
801 | // vmain = 10; | 800 | // vmain = 10; |
802 | // else | 801 | // else |
803 | cancelbutton(); | 802 | cancelbutton(); |
804 | } | 803 | } |
805 | 804 | ||
806 | if(vmain == 10) { | 805 | if(vmain == 10) { |
807 | if(!expecting) { | 806 | if(!expecting) { |
808 | 807 | ||
809 | int result; | 808 | int result; |
810 | 809 | ||
811 | timeout_timer->stop(); | 810 | timeout_timer->stop(); |
812 | if_timeout_timer->stop(); // better be sure. | 811 | if_timeout_timer->stop(); // better be sure. |
813 | 812 | ||
814 | // stop reading of data | 813 | // stop reading of data |
815 | _ifaceppp->modem()->stop(); | 814 | _ifaceppp->modem()->stop(); |
816 | 815 | ||
817 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { | 816 | if(_ifaceppp->data()->authMethod() == AUTH_TERMINAL) { |
818 | // if (termwindow) { | 817 | // if (termwindow) { |
819 | // delete termwindow; | 818 | // delete termwindow; |
820 | // termwindow = 0L; | 819 | // termwindow = 0L; |
821 | // this->show(); | 820 | // this->show(); |
822 | // } else { | 821 | // } else { |
823 | // termwindow = new LoginTerm(0L, 0L); | 822 | // termwindow = new LoginTerm(0L, 0L); |
824 | // hide(); | 823 | // hide(); |
825 | // termwindow->show(); | 824 | // termwindow->show(); |
826 | // vmain = 30; | 825 | // vmain = 30; |
827 | // return; | 826 | // return; |
828 | // } | 827 | // } |
829 | } | 828 | } |
830 | 829 | ||
831 | // Close the tty. This prevents the QTimer::singleShot() in | 830 | // Close the tty. This prevents the QTimer::singleShot() in |
832 | // Modem::readtty() from re-enabling the socket notifier. | 831 | // Modem::readtty() from re-enabling the socket notifier. |
833 | // The port is still held open by the helper process. | 832 | // The port is still held open by the helper process. |
834 | 833 | ||
835 | /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), | 834 | /* Er, there _is_ not QTimer::singleShot() in Modem::readtty(), |
836 | and closing the thing prevents pppd from using it later. */ | 835 | and closing the thing prevents pppd from using it later. */ |
837 | //_ifaceppp->modem()->closetty(); | 836 | //_ifaceppp->modem()->closetty(); |
838 | 837 | ||
839 | killTimer( main_timer_ID ); | 838 | killTimer( main_timer_ID ); |
840 | 839 | ||
841 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); | 840 | if_timeout_timer->start(_ifaceppp->data()->pppdTimeout()*1000); |
842 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); | 841 | qDebug( "started if timeout timer with %i", _ifaceppp->data()->pppdTimeout()*1000); |
843 | 842 | ||
844 | // find out PPP interface and notify the stats module | 843 | // find out PPP interface and notify the stats module |
845 | // stats->setUnit(pppInterfaceNumber()); | 844 | // stats->setUnit(pppInterfaceNumber()); |
846 | 845 | ||
847 | qApp->flushX(); | 846 | qApp->flushX(); |
848 | semaphore = true; | 847 | semaphore = true; |
849 | result = execppp(); | 848 | result = execppp(); |
850 | 849 | ||
851 | emit debugMessage(i18n("Starting pppd...")); | 850 | emit debugMessage(QObject::tr("Starting pppd...")); |
852 | qDebug("execppp() returned with return-code %i", result ); | 851 | qDebug("execppp() returned with return-code %i", result ); |
853 | 852 | ||
854 | if(result) { | 853 | if(result) { |
855 | if(!_ifaceppp->data()->autoDNS()) | 854 | if(!_ifaceppp->data()->autoDNS()) |
856 | adddns( _ifaceppp ); | 855 | adddns( _ifaceppp ); |
857 | 856 | ||
858 | // O.K we are done here, let's change over to the if_waiting loop | 857 | // O.K we are done here, let's change over to the if_waiting loop |
859 | // where we wait for the ppp if (interface) to come up. | 858 | // where we wait for the ppp if (interface) to come up. |
860 | 859 | ||
861 | emit if_waiting_signal(); | 860 | emit if_waiting_signal(); |
862 | } else { | 861 | } else { |
863 | 862 | ||
864 | // starting pppd wasn't successful. Error messages were | 863 | // starting pppd wasn't successful. Error messages were |
865 | // handled by execppp(); | 864 | // handled by execppp(); |
866 | if_timeout_timer->stop(); | 865 | if_timeout_timer->stop(); |
867 | this->hide(); | 866 | this->hide(); |
868 | messg->setText(""); | 867 | messg->setText(""); |
869 | //p_kppp->quit_b->setFocus(); | 868 | //p_kppp->quit_b->setFocus(); |
870 | //p_kppp->show(); | 869 | //p_kppp->show(); |
871 | qApp->processEvents(); | 870 | qApp->processEvents(); |
872 | _ifaceppp->modem()->hangup(); | 871 | _ifaceppp->modem()->hangup(); |
873 | emit stopAccounting(); | 872 | emit stopAccounting(); |
874 | //p_kppp->con_win->stopClock(); | 873 | //p_kppp->con_win->stopClock(); |
875 | _ifaceppp->modem()->closetty(); | 874 | _ifaceppp->modem()->closetty(); |
876 | _ifaceppp->modem()->unlockdevice(); | 875 | _ifaceppp->modem()->unlockdevice(); |
877 | 876 | ||
878 | } | 877 | } |
879 | 878 | ||
880 | return; | 879 | return; |
881 | } | 880 | } |
882 | } | 881 | } |
883 | 882 | ||
884 | // this is a "wait until cancel" entry | 883 | // this is a "wait until cancel" entry |
885 | 884 | ||
886 | if(vmain == 20) { | 885 | if(vmain == 20) { |
887 | } | 886 | } |
888 | } | 887 | } |
889 | 888 | ||
890 | 889 | ||
891 | void ConnectWidget::set_con_speed_string() { | 890 | void ConnectWidget::set_con_speed_string() { |
892 | // Here we are trying to determine the speed at which we are connected. | 891 | // Here we are trying to determine the speed at which we are connected. |
893 | // Usually the modem responds after connect with something like | 892 | // Usually the modem responds after connect with something like |
894 | // CONNECT 115200, so all we need to do is find the number after CONNECT | 893 | // CONNECT 115200, so all we need to do is find the number after CONNECT |
895 | // or whatever the modemConnectResp() is. | 894 | // or whatever the modemConnectResp() is. |
896 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); | 895 | // p_kppp->con_speed = _ifaceppp->modem()->parseModemSpeed(myreadbuffer); |
897 | } | 896 | } |
898 | 897 | ||
899 | 898 | ||
900 | 899 | ||
901 | void ConnectWidget::readChar(unsigned char c) { | 900 | void ConnectWidget::readChar(unsigned char c) { |
902 | if(semaphore) | 901 | if(semaphore) |
903 | return; | 902 | return; |
904 | 903 | ||
905 | readbuffer += c; | 904 | readbuffer += c; |
906 | myreadbuffer += c; | 905 | myreadbuffer += c; |
907 | 906 | ||
908 | // While in scanning mode store each char to the scan buffer | 907 | // While in scanning mode store each char to the scan buffer |
909 | // for use in the prompt command | 908 | // for use in the prompt command |
910 | if( scanning ) | 909 | if( scanning ) |
911 | scanbuffer += c; | 910 | scanbuffer += c; |
912 | 911 | ||
913 | // add to debug window | 912 | // add to debug window |
914 | emit debugPutChar(c); | 913 | emit debugPutChar(c); |
915 | 914 | ||
916 | checkBuffers(); | 915 | checkBuffers(); |
917 | } | 916 | } |
918 | 917 | ||
919 | 918 | ||
920 | void ConnectWidget::checkBuffers() { | 919 | void ConnectWidget::checkBuffers() { |
921 | // Let's check if we are finished with scanning: | 920 | // Let's check if we are finished with scanning: |
922 | // The scanstring have to be in the buffer and the latest character | 921 | // The scanstring have to be in the buffer and the latest character |
923 | // was a carriage return or an linefeed (depending on modem setup) | 922 | // was a carriage return or an linefeed (depending on modem setup) |
924 | if( scanning && scanbuffer.contains(scanstr) && | 923 | if( scanning && scanbuffer.contains(scanstr) && |
925 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { | 924 | ( scanbuffer.right(1) == "\n" || scanbuffer.right(1) == "\r") ) { |
926 | scanning = false; | 925 | scanning = false; |
927 | 926 | ||
928 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); | 927 | int vstart = scanbuffer.find( scanstr ) + scanstr.length(); |
929 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); | 928 | scanvar = scanbuffer.mid( vstart, scanbuffer.length() - vstart); |
930 | scanvar = scanvar.stripWhiteSpace(); | 929 | scanvar = scanvar.stripWhiteSpace(); |
931 | 930 | ||
932 | // Show the Variabel content in the debug window | 931 | // Show the Variabel content in the debug window |
933 | QString sv = i18n("Scan Var: %1").arg(scanvar); | 932 | QString sv = QObject::tr("Scan Var: %1").arg(scanvar); |
934 | emit debugMessage(sv); | 933 | emit debugMessage(sv); |
935 | } | 934 | } |
936 | 935 | ||
937 | if(expecting) { | 936 | if(expecting) { |
938 | if(readbuffer.contains(expectstr)) { | 937 | if(readbuffer.contains(expectstr)) { |
939 | expecting = false; | 938 | expecting = false; |
940 | // keep everything after the expected string | 939 | // keep everything after the expected string |
941 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); | 940 | readbuffer.remove(0, readbuffer.find(expectstr) + expectstr.length()); |
942 | 941 | ||
943 | QString ts = i18n("Found: %1").arg(expectstr); | 942 | QString ts = QObject::tr("Found: %1").arg(expectstr); |
944 | emit debugMessage(ts); | 943 | emit debugMessage(ts); |
945 | 944 | ||
946 | if (loopend) { | 945 | if (loopend) { |
947 | loopend=false; | 946 | loopend=false; |
948 | } | 947 | } |
949 | } | 948 | } |
950 | 949 | ||
951 | if (loopend && readbuffer.contains(loopstr[loopnest])) { | 950 | if (loopend && readbuffer.contains(loopstr[loopnest])) { |
952 | expecting = false; | 951 | expecting = false; |
953 | readbuffer = ""; | 952 | readbuffer = ""; |
954 | QString ts = i18n("Looping: %1").arg(loopstr[loopnest]); | 953 | QString ts = QObject::tr("Looping: %1").arg(loopstr[loopnest]); |
955 | emit debugMessage(ts); | 954 | emit debugMessage(ts); |
956 | scriptindex = loopstartindex[loopnest]; | 955 | scriptindex = loopstartindex[loopnest]; |
957 | loopend = false; | 956 | loopend = false; |
958 | loopnest++; | 957 | loopnest++; |
959 | } | 958 | } |
960 | // notify event loop if expected string was found | 959 | // notify event loop if expected string was found |
961 | if(!expecting) | 960 | if(!expecting) |
962 | timerEvent((QTimerEvent *) 0); | 961 | timerEvent((QTimerEvent *) 0); |
963 | } | 962 | } |
964 | } | 963 | } |
965 | 964 | ||
966 | 965 | ||
967 | 966 | ||
968 | void ConnectWidget::pause() { | 967 | void ConnectWidget::pause() { |
969 | pausing = false; | 968 | pausing = false; |
970 | pausetimer->stop(); | 969 | pausetimer->stop(); |
971 | } | 970 | } |
972 | 971 | ||
973 | 972 | ||
974 | void ConnectWidget::cancelbutton() { | 973 | void ConnectWidget::cancelbutton() { |
975 | _ifaceppp->modem()->stop(); | 974 | _ifaceppp->modem()->stop(); |
976 | killTimer(main_timer_ID); | 975 | killTimer(main_timer_ID); |
977 | timeout_timer->stop(); | 976 | timeout_timer->stop(); |
978 | if_timer->stop(); | 977 | if_timer->stop(); |
979 | if_timeout_timer->stop(); | 978 | if_timeout_timer->stop(); |
980 | 979 | ||
981 | // if (termwindow) { | 980 | // if (termwindow) { |
982 | // delete termwindow; | 981 | // delete termwindow; |
983 | // termwindow = 0L; | 982 | // termwindow = 0L; |
984 | // this->show(); | 983 | // this->show(); |
985 | // } | 984 | // } |
986 | 985 | ||
987 | messg->setText(i18n("One moment please...")); | 986 | messg->setText(QObject::tr("One moment please...")); |
988 | 987 | ||
989 | // just to be sure | 988 | // just to be sure |
990 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 989 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
991 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 990 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
992 | removedns(_ifaceppp); | 991 | removedns(_ifaceppp); |
993 | 992 | ||
994 | qApp->processEvents(); | 993 | qApp->processEvents(); |
995 | 994 | ||
996 | _ifaceppp->modem()->killPPPDaemon(); | 995 | _ifaceppp->modem()->killPPPDaemon(); |
997 | _ifaceppp->modem()->hangup(); | 996 | _ifaceppp->modem()->hangup(); |
998 | 997 | ||
999 | 998 | ||
1000 | // p_kppp->quit_b->setFocus(); | 999 | // p_kppp->quit_b->setFocus(); |
1001 | // p_kppp->show(); | 1000 | // p_kppp->show(); |
1002 | // emit stopAccounting();// just to be sure | 1001 | // emit stopAccounting();// just to be sure |
1003 | // p_kppp->con_win->stopClock(); | 1002 | // p_kppp->con_win->stopClock(); |
1004 | _ifaceppp->modem()->closetty(); | 1003 | _ifaceppp->modem()->closetty(); |
1005 | _ifaceppp->modem()->unlockdevice(); | 1004 | _ifaceppp->modem()->unlockdevice(); |
1006 | 1005 | ||
1007 | //abort prompt window... | 1006 | //abort prompt window... |
1008 | if (prompt->isVisible()) { | 1007 | if (prompt->isVisible()) { |
1009 | prompt->hide(); | 1008 | prompt->hide(); |
1010 | } | 1009 | } |
1011 | prompt->setConsumed(); | 1010 | prompt->setConsumed(); |
1012 | 1011 | ||
1013 | messg->setText(tr("offline")); | 1012 | _ifaceppp->setStatus( false ); |
1013 | _ifaceppp->refresh(); | ||
1014 | // messg->setText(tr("offline")); | ||
1015 | refresh(); | ||
1014 | } | 1016 | } |
1015 | 1017 | ||
1016 | 1018 | ||
1017 | void ConnectWidget::script_timed_out() { | 1019 | void ConnectWidget::script_timed_out() { |
1018 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state | 1020 | if(vmain == 20) { // we are in the 'wait for the user to cancel' state |
1019 | timeout_timer->stop(); | 1021 | timeout_timer->stop(); |
1020 | emit stopAccounting(); | 1022 | emit stopAccounting(); |
1021 | // p_kppp->con_win->stopClock(); | 1023 | // p_kppp->con_win->stopClock(); |
1022 | return; | 1024 | return; |
1023 | } | 1025 | } |
1024 | 1026 | ||
1025 | if (prompt->isVisible()) | 1027 | if (prompt->isVisible()) |
1026 | prompt->hide(); | 1028 | prompt->hide(); |
1027 | 1029 | ||
1028 | prompt->setConsumed(); | 1030 | prompt->setConsumed(); |
1029 | messg->setText(i18n("Script timed out!")); | 1031 | messg->setText(QObject::tr("Script timed out!")); |
1030 | _ifaceppp->modem()->hangup(); | 1032 | _ifaceppp->modem()->hangup(); |
1031 | emit stopAccounting(); | 1033 | emit stopAccounting(); |
1032 | // p_kppp->con_win->stopClock(); | 1034 | // p_kppp->con_win->stopClock(); |
1033 | 1035 | ||
1034 | vmain = 0; // let's try again. | 1036 | vmain = 0; // let's try again. |
1035 | substate = -1; | 1037 | substate = -1; |
1036 | } | 1038 | } |
1037 | 1039 | ||
1038 | 1040 | ||
1039 | void ConnectWidget::setScan(const QString &n) { | 1041 | void ConnectWidget::setScan(const QString &n) { |
1040 | scanning = true; | 1042 | scanning = true; |
1041 | scanstr = n; | 1043 | scanstr = n; |
1042 | scanbuffer = ""; | 1044 | scanbuffer = ""; |
1043 | 1045 | ||
1044 | QString ts = i18n("Scanning: %1").arg(n); | 1046 | QString ts = QObject::tr("Scanning: %1").arg(n); |
1045 | emit debugMessage(ts); | 1047 | emit debugMessage(ts); |
1046 | } | 1048 | } |
1047 | 1049 | ||
1048 | 1050 | ||
1049 | void ConnectWidget::setExpect(const QString &n) { | 1051 | void ConnectWidget::setExpect(const QString &n) { |
1050 | expecting = true; | 1052 | expecting = true; |
1051 | expectstr = n; | 1053 | expectstr = n; |
1052 | 1054 | ||
1053 | QString ts = i18n("Expecting: %1").arg(n); | 1055 | QString ts = QObject::tr("Expecting: %1").arg(n); |
1054 | ts.replace(QRegExp("\n"), "<LF>"); | 1056 | ts.replace(QRegExp("\n"), "<LF>"); |
1055 | emit debugMessage(ts); | 1057 | emit debugMessage(ts); |
1056 | 1058 | ||
1057 | // check if the expected string is in the read buffer already. | 1059 | // check if the expected string is in the read buffer already. |
1058 | checkBuffers(); | 1060 | checkBuffers(); |
1059 | } | 1061 | } |
1060 | 1062 | ||
1061 | 1063 | ||
1062 | void ConnectWidget::if_waiting_timed_out() { | 1064 | void ConnectWidget::if_waiting_timed_out() { |
1063 | if_timer->stop(); | 1065 | if_timer->stop(); |
1064 | if_timeout_timer->stop(); | 1066 | if_timeout_timer->stop(); |
1065 | qDebug("if_waiting_timed_out()"); | 1067 | qDebug("if_waiting_timed_out()"); |
1066 | 1068 | ||
1067 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); | 1069 | _ifaceppp->data()->setpppdError(E_IF_TIMEOUT); |
1068 | 1070 | ||
1069 | // let's kill the stuck pppd | 1071 | // let's kill the stuck pppd |
1070 | _ifaceppp->modem()->killPPPDaemon(); | 1072 | _ifaceppp->modem()->killPPPDaemon(); |
1071 | 1073 | ||
1072 | emit stopAccounting(); | 1074 | emit stopAccounting(); |
1073 | // p_kppp->con_win->stopClock(); | 1075 | // p_kppp->con_win->stopClock(); |
1074 | 1076 | ||
1075 | 1077 | ||
1076 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() | 1078 | // killing ppp will generate a SIGCHLD which will be caught in pppdie() |
1077 | // in main.cpp what happens next will depend on the boolean | 1079 | // in main.cpp what happens next will depend on the boolean |
1078 | // reconnect_on_disconnect which is set in ConnectWidget::init(); | 1080 | // reconnect_on_disconnect which is set in ConnectWidget::init(); |
1079 | } | 1081 | } |
1080 | 1082 | ||
1081 | void ConnectWidget::pppdDied() | 1083 | void ConnectWidget::pppdDied() |
1082 | { | 1084 | { |
1083 | if_timer->stop(); | 1085 | if_timer->stop(); |
1084 | if_timeout_timer->stop(); | 1086 | if_timeout_timer->stop(); |
1085 | } | 1087 | } |
1086 | 1088 | ||
1087 | void ConnectWidget::if_waiting_slot() { | 1089 | void ConnectWidget::if_waiting_slot() { |
1088 | messg->setText(i18n("Logging on to network...")); | 1090 | messg->setText(QObject::tr("Logging on to network...")); |
1089 | 1091 | ||
1090 | // if(!stats->ifIsUp()) { | 1092 | // if(!stats->ifIsUp()) { |
1091 | 1093 | ||
1092 | // if(_ifaceppp->data()->pppdError() != 0) { | 1094 | // if(_ifaceppp->data()->pppdError() != 0) { |
1093 | // // we are here if pppd died immediately after starting it. | 1095 | // // we are here if pppd died immediately after starting it. |
1094 | // pppdDied(); | 1096 | // pppdDied(); |
1095 | // // error message handled in main.cpp: sigPPPDDied() | 1097 | // // error message handled in main.cpp: sigPPPDDied() |
1096 | // return; | 1098 | // return; |
1097 | // } | 1099 | // } |
1098 | 1100 | ||
1099 | // if_timer->start(100, TRUE); // single shot | 1101 | // if_timer->start(100, TRUE); // single shot |
1100 | // return; | 1102 | // return; |
1101 | // } | 1103 | // } |
1102 | 1104 | ||
1103 | // O.K the ppp interface is up and running | 1105 | // O.K the ppp interface is up and running |
1104 | // give it a few time to come up completly (0.2 seconds) | 1106 | // give it a few time to come up completly (0.2 seconds) |
1105 | if_timeout_timer->stop(); | 1107 | if_timeout_timer->stop(); |
1106 | if_timer->stop(); | 1108 | if_timer->stop(); |
1107 | usleep(200000); | 1109 | usleep(200000); |
1108 | 1110 | ||
1109 | if(_ifaceppp->data()->autoDNS()) | 1111 | if(_ifaceppp->data()->autoDNS()) |
1110 | addpeerdns( _ifaceppp ); | 1112 | addpeerdns( _ifaceppp ); |
1111 | 1113 | ||
1112 | // Close the debugging window. If we are connected, we | 1114 | // Close the debugging window. If we are connected, we |
1113 | // are not really interested in debug output | 1115 | // are not really interested in debug output |
1114 | emit closeDebugWindow(); | 1116 | emit closeDebugWindow(); |
1115 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics | 1117 | // p_kppp->statdlg->take_stats(); // start taking ppp statistics |
1116 | auto_hostname(_ifaceppp); | 1118 | auto_hostname(_ifaceppp); |
1117 | 1119 | ||
1118 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { | 1120 | if(!_ifaceppp->data()->command_on_connect().isEmpty()) { |
1119 | messg->setText(i18n("Running startup command...")); | 1121 | messg->setText(QObject::tr("Running startup command...")); |
1120 | 1122 | ||
1121 | // make sure that we don't get any async errors | 1123 | // make sure that we don't get any async errors |
1122 | qApp->flushX(); | 1124 | qApp->flushX(); |
1123 | execute_command(_ifaceppp->data()->command_on_connect()); | 1125 | execute_command(_ifaceppp->data()->command_on_connect()); |
1124 | messg->setText(i18n("Done")); | 1126 | messg->setText(QObject::tr("Done")); |
1125 | } | 1127 | } |
1126 | 1128 | ||
1127 | // remove the authentication file | 1129 | // remove the authentication file |
1128 | _ifaceppp->modem()->removeSecret(AUTH_PAP); | 1130 | _ifaceppp->modem()->removeSecret(AUTH_PAP); |
1129 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); | 1131 | _ifaceppp->modem()->removeSecret(AUTH_CHAP); |
1130 | 1132 | ||
1131 | emit debugMessage(i18n("Done")); | 1133 | emit debugMessage(QObject::tr("Done")); |
1132 | set_con_speed_string(); | 1134 | set_con_speed_string(); |
1133 | 1135 | ||
1134 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); | 1136 | // p_kppp->con_win->setConnectionSpeed(p_kppp->con_speed); |
1135 | this->hide(); | 1137 | // this->hide(); |
1136 | messg->setText(""); | 1138 | // messg->setText(""); |
1137 | 1139 | ||
1138 | _ifaceppp->setStatus( true ); | 1140 | _ifaceppp->setStatus( true ); |
1141 | |||
1142 | m_refreshTimer = new QTimer( this ); | ||
1143 | connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); | ||
1144 | m_refreshTimer->start( 3000 ); | ||
1145 | //_ifaceppp->refresh(); | ||
1139 | // emit _ifaceppp->updateInterface(_ifaceppp); | 1146 | // emit _ifaceppp->updateInterface(_ifaceppp); |
1140 | 1147 | ||
1141 | // prepare the con_win so as to have the right size for | 1148 | // prepare the con_win so as to have the right size for |
1142 | // accounting / non-accounting mode | 1149 | // accounting / non-accounting mode |
1143 | // if(p_kppp->acct != 0) | 1150 | // if(p_kppp->acct != 0) |
1144 | // p_kppp->con_win->accounting(p_kppp->acct->running()); | 1151 | // p_kppp->con_win->accounting(p_kppp->acct->running()); |
1145 | // else | 1152 | // else |
1146 | // p_kppp->con_win->accounting(false); | 1153 | // p_kppp->con_win->accounting(false); |
1147 | 1154 | ||
1148 | // if (_ifaceppp->data()->get_dock_into_panel()) { | 1155 | // if (_ifaceppp->data()->get_dock_into_panel()) { |
1149 | // // DockWidget::dock_widget->show(); | 1156 | // // DockWidget::dock_widget->show(); |
1150 | // // DockWidget::dock_widget->take_stats(); | 1157 | // // DockWidget::dock_widget->take_stats(); |
1151 | // // this->hide(); | 1158 | // // this->hide(); |
1152 | // } | 1159 | // } |
1153 | // else { | 1160 | // else { |
1154 | // // p_kppp->con_win->show(); | 1161 | // // p_kppp->con_win->show(); |
1155 | 1162 | ||
1156 | // if(_ifaceppp->data()->get_iconify_on_connect()) { | 1163 | // if(_ifaceppp->data()->get_iconify_on_connect()) { |
1157 | // // p_kppp->con_win->showMinimized(); | 1164 | // // p_kppp->con_win->showMinimized(); |
1158 | // } | 1165 | // } |
1159 | // } | 1166 | // } |
1160 | 1167 | ||
1161 | _ifaceppp->modem()->closetty(); | 1168 | _ifaceppp->modem()->closetty(); |
1162 | } | 1169 | } |
1163 | 1170 | ||
1171 | void ConnectWidget::refresh() { | ||
1172 | _ifaceppp->refresh(); | ||
1173 | if ( _ifaceppp->getStatus() ) { | ||
1174 | messg->setText(QObject::tr("Online")); | ||
1175 | } else { | ||
1176 | messg->setText(QObject::tr("Offline")); | ||
1177 | } | ||
1178 | } | ||
1179 | |||
1164 | 1180 | ||
1165 | bool ConnectWidget::execppp() { | 1181 | bool ConnectWidget::execppp() { |
1166 | QString command; | 1182 | QString command; |
1167 | 1183 | ||
1168 | command = "pppd"; | 1184 | command = "pppd"; |
1169 | 1185 | ||
1170 | // as of version 2.3.6 pppd falls back to the real user rights when | 1186 | // as of version 2.3.6 pppd falls back to the real user rights when |
1171 | // opening a device given in a command line. To avoid permission conflicts | 1187 | // opening a device given in a command line. To avoid permission conflicts |
1172 | // we'll simply leave this argument away. pppd will then use the default tty | 1188 | // we'll simply leave this argument away. pppd will then use the default tty |
1173 | // which is the serial port we connected stdin/stdout to in opener.cpp. | 1189 | // which is the serial port we connected stdin/stdout to in opener.cpp. |
1174 | // command += " "; | 1190 | // command += " "; |
1175 | // command += _ifaceppp->data()->modemDevice(); | 1191 | // command += _ifaceppp->data()->modemDevice(); |
1176 | 1192 | ||
1177 | command += " " + _ifaceppp->data()->speed(); | 1193 | command += " " + _ifaceppp->data()->speed(); |
1178 | 1194 | ||
1179 | command += " -detach"; | 1195 | command += " -detach"; |
1180 | 1196 | ||
1181 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || | 1197 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0" || |
1182 | _ifaceppp->data()->gateway() != "0.0.0.0") { | 1198 | _ifaceppp->data()->gateway() != "0.0.0.0") { |
1183 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { | 1199 | if(_ifaceppp->data()->ipaddr() != "0.0.0.0") { |
1184 | command += " "; | 1200 | command += " "; |
1185 | command += _ifaceppp->data()->ipaddr(); | 1201 | command += _ifaceppp->data()->ipaddr(); |
1186 | command += ":"; | 1202 | command += ":"; |
1187 | } | 1203 | } |
1188 | else { | 1204 | else { |
1189 | command += " "; | 1205 | command += " "; |
1190 | command += ":"; | 1206 | command += ":"; |
1191 | } | 1207 | } |
1192 | 1208 | ||
1193 | if(_ifaceppp->data()->gateway() != "0.0.0.0") | 1209 | if(_ifaceppp->data()->gateway() != "0.0.0.0") |
1194 | command += _ifaceppp->data()->gateway(); | 1210 | command += _ifaceppp->data()->gateway(); |
1195 | } | 1211 | } |
1196 | 1212 | ||
1197 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") | 1213 | if(_ifaceppp->data()->subnetmask() != "0.0.0.0") |
1198 | command += " netmask " + _ifaceppp->data()->subnetmask(); | 1214 | command += " netmask " + _ifaceppp->data()->subnetmask(); |
1199 | 1215 | ||
1200 | if(_ifaceppp->data()->flowcontrol() != "None") { | 1216 | if(_ifaceppp->data()->flowcontrol() != "None") { |
1201 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") | 1217 | if(_ifaceppp->data()->flowcontrol() == "CRTSCTS") |
1202 | command += " crtscts"; | 1218 | command += " crtscts"; |
1203 | else | 1219 | else |
1204 | command += " xonxoff"; | 1220 | command += " xonxoff"; |
1205 | } | 1221 | } |
1206 | 1222 | ||
1207 | if(_ifaceppp->data()->defaultroute()) | 1223 | if(_ifaceppp->data()->defaultroute()) |
1208 | command += " defaultroute"; | 1224 | command += " defaultroute"; |
1209 | 1225 | ||
1210 | if(_ifaceppp->data()->autoDNS()) | 1226 | if(_ifaceppp->data()->autoDNS()) |
1211 | command += " usepeerdns"; | 1227 | command += " usepeerdns"; |
1212 | 1228 | ||
1213 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | ||
1214 | for ( QStringList::Iterator it = arglist.begin(); | ||
1215 | it != arglist.end(); | ||
1216 | ++it ) | ||
1217 | { | ||
1218 | command += " " + *it; | ||
1219 | } | ||
1220 | 1229 | ||
1221 | // PAP settings | 1230 | // PAP settings |
1222 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { | 1231 | if(_ifaceppp->data()->authMethod() == AUTH_PAP) { |
1223 | command += " -chap user "; | 1232 | command += " -chap user "; |
1224 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1233 | command = command + _ifaceppp->data()->storedUsername(); |
1225 | } | 1234 | } |
1226 | 1235 | ||
1227 | // CHAP settings | 1236 | // CHAP settings |
1228 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { | 1237 | if(_ifaceppp->data()->authMethod() == AUTH_CHAP) { |
1229 | command += " -pap user "; | 1238 | command += " -pap user "; |
1230 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1239 | command = command + _ifaceppp->data()->storedUsername(); |
1231 | } | 1240 | } |
1232 | 1241 | ||
1233 | // PAP/CHAP settings | 1242 | // PAP/CHAP settings |
1234 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { | 1243 | if(_ifaceppp->data()->authMethod() == AUTH_PAPCHAP) { |
1235 | command += " user "; | 1244 | QString tmpName = _ifaceppp->data()->storedUsername(); |
1236 | command = command + "\"" + _ifaceppp->data()->storedUsername() + "\""; | 1245 | if ( !tmpName.isEmpty() ) { |
1246 | command += " user "; | ||
1247 | command = command + tmpName; | ||
1248 | } | ||
1237 | } | 1249 | } |
1238 | 1250 | ||
1239 | // check for debug | 1251 | // check for debug |
1240 | if(_ifaceppp->data()->getPPPDebug()) | 1252 | if(_ifaceppp->data()->getPPPDebug()) |
1241 | command += " debug"; | 1253 | command += " debug"; |
1242 | 1254 | ||
1255 | QStringList &arglist = _ifaceppp->data()->pppdArgument(); | ||
1256 | for ( QStringList::Iterator it = arglist.begin(); | ||
1257 | it != arglist.end(); | ||
1258 | ++it ) | ||
1259 | { | ||
1260 | command += " " + *it; | ||
1261 | } | ||
1262 | |||
1263 | command += " call opie-kppp logfd 11"; | ||
1264 | |||
1243 | if (command.length() > MAX_CMDLEN) { | 1265 | if (command.length() > MAX_CMDLEN) { |
1244 | QMessageBox::critical(this, "error", i18n( | 1266 | QMessageBox::critical(this, "error", QObject::tr( |
1245 | "pppd command + command-line arguments exceed " | 1267 | "pppd command + command-line arguments exceed " |
1246 | "2024 characters in length." | 1268 | "2024 characters in length." |
1247 | )); | 1269 | )); |
1248 | 1270 | ||
1249 | return false; // nonsensically long command which would bust my buffer buf. | 1271 | return false; // nonsensically long command which would bust my buffer buf. |
1250 | } | 1272 | } |
1251 | 1273 | ||
1274 | qWarning("Command IS: %s",command.latin1() ); | ||
1275 | |||
1252 | qApp->flushX(); | 1276 | qApp->flushX(); |
1253 | 1277 | ||
1254 | return _ifaceppp->modem()->execPPPDaemon(command); | 1278 | return _ifaceppp->modem()->execPPPDaemon(command); |
1255 | } | 1279 | } |
1256 | 1280 | ||
1257 | 1281 | ||
1258 | void ConnectWidget::closeEvent( QCloseEvent *e ) { | 1282 | void ConnectWidget::closeEvent( QCloseEvent *e ) { |
1259 | e->ignore(); | 1283 | e->ignore(); |
1260 | emit cancelbutton(); | 1284 | emit cancelbutton(); |
1261 | } | 1285 | } |
1262 | 1286 | ||
1263 | 1287 | ||
1264 | void ConnectWidget::setMsg(const QString &msg) { | 1288 | void ConnectWidget::setMsg(const QString &msg) { |
1265 | messg->setText(msg); | 1289 | messg->setText(msg); |
1266 | } | 1290 | } |
1267 | 1291 | ||
1268 | void ConnectWidget::writeline(const QString &s) { | 1292 | void ConnectWidget::writeline(const QString &s) { |
1269 | _ifaceppp->modem()->writeLine(s.local8Bit()); | 1293 | _ifaceppp->modem()->writeLine(s.local8Bit()); |
1270 | } | 1294 | } |
1271 | 1295 | ||
1272 | // Set the hostname and domain from DNS Server | 1296 | // Set the hostname and domain from DNS Server |
1273 | void auto_hostname(InterfacePPP *_ifaceppp) { | 1297 | void auto_hostname(InterfacePPP *_ifaceppp) { |
1274 | struct in_addr local_ip; | 1298 | struct in_addr local_ip; |
1275 | struct hostent *hostname_entry; | 1299 | struct hostent *hostname_entry; |
1276 | QString new_hostname; | 1300 | QString new_hostname; |
1277 | int dot; | 1301 | int dot; |
1278 | char tmp_str[100]; // buffer overflow safe | 1302 | char tmp_str[100]; // buffer overflow safe |
1279 | 1303 | ||
1280 | gethostname(tmp_str, sizeof(tmp_str)); | 1304 | gethostname(tmp_str, sizeof(tmp_str)); |
1281 | tmp_str[sizeof(tmp_str)-1]=0; // panic | 1305 | tmp_str[sizeof(tmp_str)-1]=0; // panic |
1282 | old_hostname=tmp_str; // copy to QString | 1306 | old_hostname=tmp_str; // copy to QString |
1283 | 1307 | ||
1284 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { | 1308 | // if (!p_kppp->stats->local_ip_address.isEmpty() && _ifaceppp->data()->autoname()) { |
1285 | if ( _ifaceppp->data()->autoname()) { | 1309 | if ( _ifaceppp->data()->autoname()) { |
1286 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); | 1310 | // local_ip.s_addr=inet_addr(p_kppp->stats->local_ip_address.ascii()); |
1287 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); | 1311 | hostname_entry=gethostbyaddr((const char *)&local_ip,sizeof(in_addr),AF_INET); |
1288 | 1312 | ||
1289 | if (hostname_entry != 0L) { | 1313 | if (hostname_entry != 0L) { |
1290 | new_hostname=hostname_entry->h_name; | 1314 | new_hostname=hostname_entry->h_name; |
1291 | dot=new_hostname.find('.'); | 1315 | dot=new_hostname.find('.'); |
1292 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); | 1316 | new_hostname=new_hostname.remove(dot,new_hostname.length()-dot); |
1293 | _ifaceppp->modem()->setHostname(new_hostname); | 1317 | _ifaceppp->modem()->setHostname(new_hostname); |
1294 | modified_hostname = TRUE; | 1318 | modified_hostname = TRUE; |
1295 | 1319 | ||
1296 | new_hostname=hostname_entry->h_name; | 1320 | new_hostname=hostname_entry->h_name; |
1297 | new_hostname.remove(0,dot+1); | 1321 | new_hostname.remove(0,dot+1); |
1298 | 1322 | ||
1299 | add_domain(new_hostname, _ifaceppp); | 1323 | add_domain(new_hostname, _ifaceppp); |
1300 | } | 1324 | } |
1301 | } | 1325 | } |
1302 | 1326 | ||
1303 | } | 1327 | } |
1304 | 1328 | ||
1305 | // Replace the DNS domain entry in the /etc/resolv.conf file and | 1329 | // Replace the DNS domain entry in the /etc/resolv.conf file and |
1306 | // disable the nameserver entries if option is enabled | 1330 | // disable the nameserver entries if option is enabled |
1307 | void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { | 1331 | void add_domain(const QString &domain, InterfacePPP *_ifaceppp) { |
1308 | 1332 | ||
1309 | int fd; | 1333 | int fd; |
1310 | char c; | 1334 | char c; |
1311 | QString resolv[MAX_RESOLVCONF_LINES]; | 1335 | QString resolv[MAX_RESOLVCONF_LINES]; |
1312 | 1336 | ||
1313 | if (domain.isEmpty()) | 1337 | if (domain.isEmpty()) |
1314 | return; | 1338 | return; |
1315 | 1339 | ||
1316 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { | 1340 | if((fd = _ifaceppp->modem()->openResolv(O_RDONLY)) >= 0) { |
1317 | 1341 | ||
1318 | int i=0; | 1342 | int i=0; |
1319 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { | 1343 | while((read(fd, &c, 1) == 1) && (i < MAX_RESOLVCONF_LINES)) { |
1320 | if(c == '\n') { | 1344 | if(c == '\n') { |
1321 | i++; | 1345 | i++; |
1322 | } | 1346 | } |
1323 | else { | 1347 | else { |
1324 | resolv[i] += c; | 1348 | resolv[i] += c; |
1325 | } | 1349 | } |
1326 | } | 1350 | } |
1327 | close(fd); | 1351 | close(fd); |
1328 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; | 1352 | if ((c != '\n') && (i < MAX_RESOLVCONF_LINES)) i++; |
1329 | 1353 | ||
1330 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { | 1354 | if((fd = _ifaceppp->modem()->openResolv(O_WRONLY|O_TRUNC)) >= 0) { |
1331 | QCString tmp = "domain " + domain.local8Bit() + | 1355 | QCString tmp = "domain " + domain.local8Bit() + |
1332 | " \t\t#kppp temp entry\n"; | 1356 | " \t\t#kppp temp entry\n"; |
1333 | write(fd, tmp.data(), tmp.length()); | 1357 | write(fd, tmp.data(), tmp.length()); |
1334 | 1358 | ||
1335 | for(int j=0; j < i; j++) { | 1359 | for(int j=0; j < i; j++) { |
1336 | if((resolv[j].contains("domain") || | 1360 | if((resolv[j].contains("domain") || |
1337 | ( resolv[j].contains("nameserver") | 1361 | ( resolv[j].contains("nameserver") |
1338 | && !resolv[j].contains("#kppp temp entry") | 1362 | && !resolv[j].contains("#kppp temp entry") |
1339 | && _ifaceppp->data()->exDNSDisabled())) | 1363 | && _ifaceppp->data()->exDNSDisabled())) |
1340 | && !resolv[j].contains("#entry disabled by kppp")) { | 1364 | && !resolv[j].contains("#entry disabled by kppp")) { |
1341 | QCString tmp = "# " + resolv[j].local8Bit() + | 1365 | QCString tmp = "# " + resolv[j].local8Bit() + |
1342 | " \t#entry disabled by kppp\n"; | 1366 | " \t#entry disabled by kppp\n"; |
1343 | write(fd, tmp, tmp.length()); | 1367 | write(fd, tmp, tmp.length()); |
1344 | } | 1368 | } |
1345 | else { | 1369 | else { |
1346 | QCString tmp = resolv[j].local8Bit() + "\n"; | 1370 | QCString tmp = resolv[j].local8Bit() + "\n"; |
1347 | write(fd, tmp, tmp.length()); | 1371 | write(fd, tmp, tmp.length()); |
diff --git a/noncore/settings/networksettings/ppp/connect.h b/noncore/settings/networksettings/ppp/connect.h index e7ae5e0..b225ff5 100644 --- a/noncore/settings/networksettings/ppp/connect.h +++ b/noncore/settings/networksettings/ppp/connect.h | |||
@@ -1,152 +1,154 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * based on EzPPP: | 10 | * based on EzPPP: |
11 | * Copyright (C) 1997 Jay Painter | 11 | * Copyright (C) 1997 Jay Painter |
12 | * | 12 | * |
13 | * | 13 | * |
14 | * This program is free software; you can redistribute it and/or | 14 | * This program is free software; you can redistribute it and/or |
15 | * modify it under the terms of the GNU Library General Public | 15 | * modify it under the terms of the GNU Library General Public |
16 | * License as published by the Free Software Foundation; either | 16 | * License as published by the Free Software Foundation; either |
17 | * version 2 of the License, or (at your option) any later version. | 17 | * version 2 of the License, or (at your option) any later version. |
18 | * | 18 | * |
19 | * This program is distributed in the hope that it will be useful, | 19 | * This program is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 | * Library General Public License for more details. | 22 | * Library General Public License for more details. |
23 | * | 23 | * |
24 | * You should have received a copy of the GNU Library General Public | 24 | * You should have received a copy of the GNU Library General Public |
25 | * License along with this program; if not, write to the Free | 25 | * License along with this program; if not, write to the Free |
26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef _CONNECT_H_ | 29 | #ifndef _CONNECT_H_ |
30 | #define _CONNECT_H_ | 30 | #define _CONNECT_H_ |
31 | 31 | ||
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qevent.h> | 35 | #include <qevent.h> |
36 | 36 | ||
37 | #include "kpppconfig.h" | 37 | #include "kpppconfig.h" |
38 | #include "pwentry.h" | 38 | #include "pwentry.h" |
39 | 39 | ||
40 | 40 | ||
41 | #define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2) | 41 | #define MAXLOOPNEST (MAX_SCRIPT_ENTRIES/2) |
42 | 42 | ||
43 | class InterfacePPP; | 43 | class InterfacePPP; |
44 | class PPPData; | 44 | class PPPData; |
45 | 45 | ||
46 | class ConnectWidget : public QWidget { | 46 | class ConnectWidget : public QWidget { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | ConnectWidget(InterfacePPP*, QWidget *parent, const char *name); | 49 | ConnectWidget(InterfacePPP*, QWidget *parent, const char *name); |
50 | ~ConnectWidget(); | 50 | ~ConnectWidget(); |
51 | 51 | ||
52 | public: | 52 | public: |
53 | void set_con_speed_string(); | 53 | void set_con_speed_string(); |
54 | void setMsg(const QString &); | 54 | void setMsg(const QString &); |
55 | void pppdDied(); | 55 | void pppdDied(); |
56 | 56 | ||
57 | protected: | 57 | protected: |
58 | void timerEvent(QTimerEvent *); | 58 | void timerEvent(QTimerEvent *); |
59 | void closeEvent( QCloseEvent *e ); | 59 | void closeEvent( QCloseEvent *e ); |
60 | 60 | ||
61 | private slots: | 61 | private slots: |
62 | void readChar(unsigned char); | 62 | void readChar(unsigned char); |
63 | void pause(); | 63 | void pause(); |
64 | void if_waiting_slot(); | 64 | void if_waiting_slot(); |
65 | void refresh(); | ||
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | void init(); | 68 | void init(); |
68 | void preinit(); | 69 | void preinit(); |
69 | void script_timed_out(); | 70 | void script_timed_out(); |
70 | void if_waiting_timed_out(); | 71 | void if_waiting_timed_out(); |
71 | void cancelbutton(); | 72 | void cancelbutton(); |
72 | 73 | ||
73 | signals: | 74 | signals: |
74 | void if_waiting_signal(); | 75 | void if_waiting_signal(); |
75 | void debugMessage(const QString &); | 76 | void debugMessage(const QString &); |
76 | void toggleDebugWindow(); | 77 | void toggleDebugWindow(); |
77 | void closeDebugWindow(); | 78 | void closeDebugWindow(); |
78 | void debugPutChar(unsigned char); | 79 | void debugPutChar(unsigned char); |
79 | void startAccounting(); | 80 | void startAccounting(); |
80 | void stopAccounting(); | 81 | void stopAccounting(); |
81 | 82 | ||
82 | public: | 83 | public: |
83 | QString myreadbuffer; // we want to keep every thing in order to fish for the | 84 | QString myreadbuffer; // we want to keep every thing in order to fish for the |
84 | 85 | ||
85 | // connection speed later on | 86 | // connection speed later on |
86 | QPushButton *debug; | 87 | QPushButton *debug; |
87 | int main_timer_ID; | 88 | int main_timer_ID; |
88 | 89 | ||
89 | private: | 90 | private: |
90 | int vmain; | 91 | int vmain; |
91 | int substate; | 92 | int substate; |
92 | int scriptindex; | 93 | int scriptindex; |
93 | QString scriptCommand, scriptArgument; | 94 | QString scriptCommand, scriptArgument; |
94 | QStringList *comlist, *arglist; | 95 | QStringList *comlist, *arglist; |
95 | 96 | ||
96 | // static const int maxloopnest=(MAX_SCRIPT_ENTRIES/2); | 97 | // static const int maxloopnest=(MAX_SCRIPT_ENTRIES/2); |
97 | int loopnest; | 98 | int loopnest; |
98 | int loopstartindex[MAXLOOPNEST]; | 99 | int loopstartindex[MAXLOOPNEST]; |
99 | bool loopend; | 100 | bool loopend; |
100 | QString loopstr[MAXLOOPNEST]; | 101 | QString loopstr[MAXLOOPNEST]; |
101 | 102 | ||
102 | bool semaphore; | 103 | bool semaphore; |
103 | QTimer *inittimer; | 104 | QTimer *inittimer; |
104 | 105 | ||
105 | QTimer *timeout_timer; | 106 | QTimer *timeout_timer; |
106 | bool execppp(); | 107 | bool execppp(); |
107 | void writeline(const QString &); | 108 | void writeline(const QString &); |
108 | void checkBuffers(); | 109 | void checkBuffers(); |
109 | 110 | ||
110 | void setExpect(const QString &); | 111 | void setExpect(const QString &); |
111 | bool expecting; | 112 | bool expecting; |
112 | QString expectstr; | 113 | QString expectstr; |
113 | 114 | ||
114 | QString readbuffer; | 115 | QString readbuffer; |
115 | 116 | ||
116 | void setScan(const QString &); | 117 | void setScan(const QString &); |
117 | QString scanvar; | 118 | QString scanvar; |
118 | QString scanstr; | 119 | QString scanstr; |
119 | QString scanbuffer; | 120 | QString scanbuffer; |
120 | bool scanning; | 121 | bool scanning; |
121 | 122 | ||
122 | bool pausing; | 123 | bool pausing; |
123 | PWEntry *prompt; | 124 | PWEntry *prompt; |
124 | // LoginTerm *termwindow; | 125 | // LoginTerm *termwindow; |
125 | 126 | ||
126 | int scriptTimeout; | 127 | int scriptTimeout; |
127 | QTimer *pausetimer; | 128 | QTimer *pausetimer; |
128 | QTimer *if_timer; | 129 | QTimer *if_timer; |
129 | QTimer *if_timeout_timer; | 130 | QTimer *if_timeout_timer; |
131 | QTimer *m_refreshTimer; | ||
130 | 132 | ||
131 | QLabel *messg; | 133 | QLabel *messg; |
132 | QPushButton *cancel; | 134 | QPushButton *cancel; |
133 | 135 | ||
134 | bool firstrunID; | 136 | bool firstrunID; |
135 | bool firstrunPW; | 137 | bool firstrunPW; |
136 | 138 | ||
137 | unsigned int dialnumber; // the current number to dial | 139 | unsigned int dialnumber; // the current number to dial |
138 | 140 | ||
139 | InterfacePPP *_ifaceppp; | 141 | InterfacePPP *_ifaceppp; |
140 | }; | 142 | }; |
141 | 143 | ||
142 | 144 | ||
143 | // non-member function to kill&wait on the pppd child process | 145 | // non-member function to kill&wait on the pppd child process |
144 | extern void killppp(PPPData*); | 146 | extern void killppp(PPPData*); |
145 | void adddns(InterfacePPP*); | 147 | void adddns(InterfacePPP*); |
146 | void addpeerdns(InterfacePPP*); | 148 | void addpeerdns(InterfacePPP*); |
147 | void removedns(InterfacePPP*); | 149 | void removedns(InterfacePPP*); |
148 | void add_domain(const QString & newdomain, InterfacePPP*); | 150 | void add_domain(const QString & newdomain, InterfacePPP*); |
149 | void auto_hostname(InterfacePPP*); | 151 | void auto_hostname(InterfacePPP*); |
150 | 152 | ||
151 | #endif | 153 | #endif |
152 | 154 | ||
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp index 9136ca0..7641bbe 100644 --- a/noncore/settings/networksettings/ppp/conwindow.cpp +++ b/noncore/settings/networksettings/ppp/conwindow.cpp | |||
@@ -1,338 +1,333 @@ | |||
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 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
10 | * modify it under the terms of the GNU Library General Public | 10 | * modify it under the terms of the GNU Library General Public |
11 | * License as published by the Free Software Foundation; either | 11 | * License as published by the Free Software Foundation; either |
12 | * version 2 of the License, or (at your option) any later version. | 12 | * version 2 of the License, or (at your option) any later version. |
13 | * | 13 | * |
14 | * This program is distributed in the hope that it will be useful, | 14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | * Library General Public License for more details. | 17 | * Library General Public License for more details. |
18 | * | 18 | * |
19 | * You should have received a copy of the GNU Library General Public | 19 | * You should have received a copy of the GNU Library General Public |
20 | * License along with this program; if not, write to the Free | 20 | * License along with this program; if not, write to the Free |
21 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qdialog.h> | 25 | #include <qdialog.h> |
26 | #include "conwindow.h" | 26 | #include "conwindow.h" |
27 | //#include "docking.h" | ||
28 | #include "pppdata.h" | 27 | #include "pppdata.h" |
29 | // #include "pppstats.h" | ||
30 | // #include <klocale.h> | ||
31 | #define i18n QObject::tr | ||
32 | // #include <kglobal.h> | ||
33 | 28 | ||
34 | 29 | ||
35 | ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, | 30 | ConWindow::ConWindow(PPPData *pd, QWidget *parent, const char *name, |
36 | QDialog *mainwidget ) | 31 | QDialog *mainwidget ) |
37 | : QWidget(parent, name, 0), | 32 | : QWidget(parent, name, 0), |
38 | minutes(0), | 33 | minutes(0), |
39 | seconds(0), | 34 | seconds(0), |
40 | hours(0), | 35 | hours(0), |
41 | days(0), | 36 | days(0), |
42 | tl1(0), | 37 | tl1(0), |
43 | _pppdata(pd) | 38 | _pppdata(pd) |
44 | { | 39 | { |
45 | info1 = new QLabel(i18n("Connected at:"), this); | 40 | info1 = new QLabel(QObject::tr("Connected at:"), this); |
46 | info2 = new QLabel("", this); | 41 | info2 = new QLabel("", this); |
47 | 42 | ||
48 | timelabel1 = new QLabel(i18n("Time connected:"), this); | 43 | timelabel1 = new QLabel(QObject::tr("Time connected:"), this); |
49 | timelabel2 = new QLabel("000:00:00", this); | 44 | timelabel2 = new QLabel("000:00:00", this); |
50 | 45 | ||
51 | vollabel = new QLabel(i18n("Volume:"), this); | 46 | vollabel = new QLabel(QObject::tr("Volume:"), this); |
52 | volinfo = new QLabel("", this); | 47 | volinfo = new QLabel("", this); |
53 | 48 | ||
54 | // now the stuff for accounting | 49 | // now the stuff for accounting |
55 | session_bill_l = new QLabel(i18n("Session Bill:"), this); | 50 | session_bill_l = new QLabel(QObject::tr("Session Bill:"), this); |
56 | session_bill = new QLabel("", this); | 51 | session_bill = new QLabel("", this); |
57 | total_bill_l = new QLabel(i18n("Total Bill:"), this); | 52 | total_bill_l = new QLabel(QObject::tr("Total Bill:"), this); |
58 | total_bill = new QLabel("", this); | 53 | total_bill = new QLabel("", this); |
59 | 54 | ||
60 | this->setCaption("kppp"); | 55 | this->setCaption("kppp"); |
61 | 56 | ||
62 | cancelbutton = new QPushButton(this); | 57 | cancelbutton = new QPushButton(this); |
63 | cancelbutton->setText(i18n("Disconnect")); | 58 | cancelbutton->setText(QObject::tr("Disconnect")); |
64 | connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); | 59 | connect(cancelbutton, SIGNAL(clicked()), mainwidget, SLOT(disconnect())); |
65 | 60 | ||
66 | // statsbutton = new QPushButton(this); | 61 | // statsbutton = new QPushButton(this); |
67 | // statsbutton->setText(i18n("Details")); | 62 | // statsbutton->setText(QObject::tr("Details")); |
68 | // statsbutton->setFocus(); | 63 | // statsbutton->setFocus(); |
69 | // connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); | 64 | // connect(statsbutton, SIGNAL(clicked()), mainwidget, SLOT(showStats())); |
70 | 65 | ||
71 | clocktimer = new QTimer(this); | 66 | clocktimer = new QTimer(this); |
72 | connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); | 67 | connect(clocktimer, SIGNAL(timeout()), SLOT(timeclick())); |
73 | 68 | ||
74 | // read window position from config file | 69 | // read window position from config file |
75 | // int p_x, p_y; | 70 | // int p_x, p_y; |
76 | // PPPData::data()->winPosConWin(p_x, p_y); | 71 | // PPPData::data()->winPosConWin(p_x, p_y); |
77 | // setGeometry(p_x, p_y, 320, 110); | 72 | // setGeometry(p_x, p_y, 320, 110); |
78 | } | 73 | } |
79 | 74 | ||
80 | ConWindow::~ConWindow() { | 75 | ConWindow::~ConWindow() { |
81 | stopClock(); | 76 | stopClock(); |
82 | } | 77 | } |
83 | 78 | ||
84 | // save window position when window was closed | 79 | // save window position when window was closed |
85 | bool ConWindow::event(QEvent *e) { | 80 | bool ConWindow::event(QEvent *e) { |
86 | if (e->type() == QEvent::Hide) | 81 | if (e->type() == QEvent::Hide) |
87 | { | 82 | { |
88 | // PPPData::data()->setWinPosConWin(x(), y()); | 83 | // PPPData::data()->setWinPosConWin(x(), y()); |
89 | return true; | 84 | return true; |
90 | } | 85 | } |
91 | else | 86 | else |
92 | return QWidget::event(e); | 87 | return QWidget::event(e); |
93 | } | 88 | } |
94 | 89 | ||
95 | QString ConWindow::prettyPrintVolume(unsigned int n) { | 90 | QString ConWindow::prettyPrintVolume(unsigned int n) { |
96 | int idx = 0; | 91 | int idx = 0; |
97 | const QString quant[] = {i18n("Byte"), i18n("KB"), | 92 | const QString quant[] = {QObject::tr("Byte"), QObject::tr("KB"), |
98 | i18n("MB"), i18n("GB"), QString::null}; | 93 | QObject::tr("MB"), QObject::tr("GB"), QString::null}; |
99 | 94 | ||
100 | float n1 = n; | 95 | float n1 = n; |
101 | while(n >= 1024 && quant[idx] != QString::null) { | 96 | while(n >= 1024 && quant[idx] != QString::null) { |
102 | idx++; | 97 | idx++; |
103 | n /= 1024; | 98 | n /= 1024; |
104 | } | 99 | } |
105 | 100 | ||
106 | int i = idx; | 101 | int i = idx; |
107 | while(i--) | 102 | while(i--) |
108 | n1 = n1 / 1024.0; | 103 | n1 = n1 / 1024.0; |
109 | 104 | ||
110 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); | 105 | QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); //KGlobal::locale()->formatNumber( n1, idx==0 ? 0 : 1 ); |
111 | s += " " + quant[idx]; | 106 | s += " " + quant[idx]; |
112 | return s; | 107 | return s; |
113 | } | 108 | } |
114 | 109 | ||
115 | // void ConWindow::accounting(bool on) { | 110 | // void ConWindow::accounting(bool on) { |
116 | // // cache accounting settings | 111 | // // cache accounting settings |
117 | // accountingEnabled = on; | 112 | // accountingEnabled = on; |
118 | // // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); | 113 | // // volumeAccountingEnabled = PPPData::data()->VolAcctEnabled(); |
119 | 114 | ||
120 | // // delete old layout | 115 | // // delete old layout |
121 | // if(tl1 != 0) | 116 | // if(tl1 != 0) |
122 | // delete tl1; | 117 | // delete tl1; |
123 | 118 | ||
124 | // // add layout now | 119 | // // add layout now |
125 | // tl1 = new QVBoxLayout(this, 10, 10); | 120 | // tl1 = new QVBoxLayout(this, 10, 10); |
126 | // tl1->addSpacing(5); | 121 | // tl1->addSpacing(5); |
127 | // QHBoxLayout *tl = new QHBoxLayout; | 122 | // QHBoxLayout *tl = new QHBoxLayout; |
128 | // tl1->addLayout(tl); | 123 | // tl1->addLayout(tl); |
129 | // tl->addSpacing(20); | 124 | // tl->addSpacing(20); |
130 | // QGridLayout *l1; | 125 | // QGridLayout *l1; |
131 | 126 | ||
132 | // int vol_lines = 0; | 127 | // int vol_lines = 0; |
133 | // // if(_pppdata->VolAcctEnabled()) | 128 | // // if(_pppdata->VolAcctEnabled()) |
134 | // // vol_lines = 1; | 129 | // // vol_lines = 1; |
135 | 130 | ||
136 | // if(accountingEnabled) | 131 | // if(accountingEnabled) |
137 | // l1 = new QGridLayout(4 + vol_lines, 2, 5); | 132 | // l1 = new QGridLayout(4 + vol_lines, 2, 5); |
138 | // else | 133 | // else |
139 | // l1 = new QGridLayout(2 + vol_lines, 2, 5); | 134 | // l1 = new QGridLayout(2 + vol_lines, 2, 5); |
140 | // tl->addLayout(l1); | 135 | // tl->addLayout(l1); |
141 | // l1->setColStretch(0, 0); | 136 | // l1->setColStretch(0, 0); |
142 | // l1->setColStretch(1, 1); | 137 | // l1->setColStretch(1, 1); |
143 | 138 | ||
144 | // info2->setAlignment(AlignRight|AlignVCenter); | 139 | // info2->setAlignment(AlignRight|AlignVCenter); |
145 | // timelabel2->setAlignment(AlignRight|AlignVCenter); | 140 | // timelabel2->setAlignment(AlignRight|AlignVCenter); |
146 | // session_bill->setAlignment(AlignRight|AlignVCenter); | 141 | // session_bill->setAlignment(AlignRight|AlignVCenter); |
147 | // total_bill->setAlignment(AlignRight|AlignVCenter); | 142 | // total_bill->setAlignment(AlignRight|AlignVCenter); |
148 | // volinfo->setAlignment(AlignRight|AlignVCenter); | 143 | // volinfo->setAlignment(AlignRight|AlignVCenter); |
149 | // // make sure that there's enough space for the bills | 144 | // // make sure that there's enough space for the bills |
150 | // QString s1 = session_bill->text(); | 145 | // QString s1 = session_bill->text(); |
151 | // QString s2 = total_bill->text(); | 146 | // QString s2 = total_bill->text(); |
152 | // QString s3 = volinfo->text(); | 147 | // QString s3 = volinfo->text(); |
153 | 148 | ||
154 | // session_bill->setText("888888.88 XXX"); | 149 | // session_bill->setText("888888.88 XXX"); |
155 | // total_bill->setText("888888.88 XXX"); | 150 | // total_bill->setText("888888.88 XXX"); |
156 | // volinfo->setText("8888.8 MB"); | 151 | // volinfo->setText("8888.8 MB"); |
157 | // session_bill->setFixedSize(session_bill->sizeHint()); | 152 | // session_bill->setFixedSize(session_bill->sizeHint()); |
158 | // total_bill->setFixedSize(total_bill->sizeHint()); | 153 | // total_bill->setFixedSize(total_bill->sizeHint()); |
159 | // volinfo->setFixedSize(volinfo->sizeHint()); | 154 | // volinfo->setFixedSize(volinfo->sizeHint()); |
160 | // session_bill->setText(s1); | 155 | // session_bill->setText(s1); |
161 | // total_bill->setText(s2); | 156 | // total_bill->setText(s2); |
162 | // volinfo->setText(s3); | 157 | // volinfo->setText(s3); |
163 | 158 | ||
164 | // l1->addWidget(info1, 0, 0); | 159 | // l1->addWidget(info1, 0, 0); |
165 | // l1->addWidget(info2, 0, 1); | 160 | // l1->addWidget(info2, 0, 1); |
166 | // l1->addWidget(timelabel1, 1, 0); | 161 | // l1->addWidget(timelabel1, 1, 0); |
167 | // l1->addWidget(timelabel2, 1, 1); | 162 | // l1->addWidget(timelabel2, 1, 1); |
168 | // if(accountingEnabled) { | 163 | // if(accountingEnabled) { |
169 | // session_bill_l->show(); | 164 | // session_bill_l->show(); |
170 | // session_bill->show(); | 165 | // session_bill->show(); |
171 | // total_bill_l->show(); | 166 | // total_bill_l->show(); |
172 | // total_bill->show(); | 167 | // total_bill->show(); |
173 | // l1->addWidget(session_bill_l, 2, 0); | 168 | // l1->addWidget(session_bill_l, 2, 0); |
174 | // l1->addWidget(session_bill, 2, 1); | 169 | // l1->addWidget(session_bill, 2, 1); |
175 | // l1->addWidget(total_bill_l, 3, 0); | 170 | // l1->addWidget(total_bill_l, 3, 0); |
176 | // l1->addWidget(total_bill, 3, 1); | 171 | // l1->addWidget(total_bill, 3, 1); |
177 | 172 | ||
178 | // if(volumeAccountingEnabled) { | 173 | // if(volumeAccountingEnabled) { |
179 | // vollabel->show(); | 174 | // vollabel->show(); |
180 | // volinfo->show(); | 175 | // volinfo->show(); |
181 | // l1->addWidget(vollabel, 4, 0); | 176 | // l1->addWidget(vollabel, 4, 0); |
182 | // l1->addWidget(volinfo, 4, 1); | 177 | // l1->addWidget(volinfo, 4, 1); |
183 | // } else { | 178 | // } else { |
184 | // vollabel->hide(); | 179 | // vollabel->hide(); |
185 | // volinfo->hide(); | 180 | // volinfo->hide(); |
186 | // } | 181 | // } |
187 | 182 | ||
188 | // } else { | 183 | // } else { |
189 | // session_bill_l->hide(); | 184 | // session_bill_l->hide(); |
190 | // session_bill->hide(); | 185 | // session_bill->hide(); |
191 | // total_bill_l->hide(); | 186 | // total_bill_l->hide(); |
192 | // total_bill->hide(); | 187 | // total_bill->hide(); |
193 | 188 | ||
194 | // if(volumeAccountingEnabled) { | 189 | // if(volumeAccountingEnabled) { |
195 | // vollabel->show(); | 190 | // vollabel->show(); |
196 | // volinfo->show(); | 191 | // volinfo->show(); |
197 | // l1->addWidget(vollabel, 2, 0); | 192 | // l1->addWidget(vollabel, 2, 0); |
198 | // l1->addWidget(volinfo, 2, 1); | 193 | // l1->addWidget(volinfo, 2, 1); |
199 | // } else { | 194 | // } else { |
200 | // vollabel->hide(); | 195 | // vollabel->hide(); |
201 | // volinfo->hide(); | 196 | // volinfo->hide(); |
202 | // } | 197 | // } |
203 | // } | 198 | // } |
204 | 199 | ||
205 | // tl->addSpacing(10); | 200 | // tl->addSpacing(10); |
206 | // QVBoxLayout *l2 = new QVBoxLayout(5); | 201 | // QVBoxLayout *l2 = new QVBoxLayout(5); |
207 | // tl->addLayout(l2); | 202 | // tl->addLayout(l2); |
208 | // l2->addStretch(1); | 203 | // l2->addStretch(1); |
209 | // // l2->addWidget(statsbutton); | 204 | // // l2->addWidget(statsbutton); |
210 | // l2->addWidget(cancelbutton); | 205 | // l2->addWidget(cancelbutton); |
211 | 206 | ||
212 | // l2->addStretch(1); | 207 | // l2->addStretch(1); |
213 | 208 | ||
214 | // tl1->addSpacing(5); | 209 | // tl1->addSpacing(5); |
215 | 210 | ||
216 | // setFixedSize(sizeHint()); | 211 | // setFixedSize(sizeHint()); |
217 | // /* | 212 | // /* |
218 | // do not overwrite position read from config | 213 | // do not overwrite position read from config |
219 | // setGeometry((QApplication::desktop()->width() - width()) / 2, | 214 | // setGeometry((QApplication::desktop()->width() - width()) / 2, |
220 | // (QApplication::desktop()->height() - height())/2, | 215 | // (QApplication::desktop()->height() - height())/2, |
221 | // width(), | 216 | // width(), |
222 | // height()); | 217 | // height()); |
223 | // */ | 218 | // */ |
224 | // } | 219 | // } |
225 | 220 | ||
226 | 221 | ||
227 | // void ConWindow::dock() { | 222 | // void ConWindow::dock() { |
228 | // // DockWidget::dock_widget->show(); | 223 | // // DockWidget::dock_widget->show(); |
229 | // this->hide(); | 224 | // this->hide(); |
230 | // } | 225 | // } |
231 | 226 | ||
232 | 227 | ||
233 | void ConWindow::startClock() { | 228 | void ConWindow::startClock() { |
234 | minutes = 0; | 229 | minutes = 0; |
235 | seconds = 0; | 230 | seconds = 0; |
236 | hours = 0; | 231 | hours = 0; |
237 | QString title ; | 232 | QString title ; |
238 | 233 | ||
239 | title = _pppdata->accname(); | 234 | title = _pppdata->accname(); |
240 | 235 | ||
241 | if(_pppdata->get_show_clock_on_caption()){ | 236 | if(_pppdata->get_show_clock_on_caption()){ |
242 | title += " 00:00" ; | 237 | title += " 00:00" ; |
243 | } | 238 | } |
244 | this->setCaption(title); | 239 | this->setCaption(title); |
245 | 240 | ||
246 | timelabel2->setText("00:00:00"); | 241 | timelabel2->setText("00:00:00"); |
247 | clocktimer->start(1000); | 242 | clocktimer->start(1000); |
248 | } | 243 | } |
249 | 244 | ||
250 | 245 | ||
251 | void ConWindow::setConnectionSpeed(const QString &speed) { | 246 | void ConWindow::setConnectionSpeed(const QString &speed) { |
252 | info2->setText(speed); | 247 | info2->setText(speed); |
253 | } | 248 | } |
254 | 249 | ||
255 | 250 | ||
256 | void ConWindow::stopClock() { | 251 | void ConWindow::stopClock() { |
257 | clocktimer->stop(); | 252 | clocktimer->stop(); |
258 | } | 253 | } |
259 | 254 | ||
260 | 255 | ||
261 | void ConWindow::timeclick() { | 256 | void ConWindow::timeclick() { |
262 | // QString tooltip = i18n("Connection: %1\n" | 257 | // QString tooltip = QObject::tr("Connection: %1\n" |
263 | // "Connected at: %2\n" | 258 | // "Connected at: %2\n" |
264 | // "Time connected: %3") | 259 | // "Time connected: %3") |
265 | // .arg(_pppdata->accname()).arg(info2->text()) | 260 | // .arg(_pppdata->accname()).arg(info2->text()) |
266 | // .arg(time_string2); | 261 | // .arg(time_string2); |
267 | 262 | ||
268 | // if(accountingEnabled) | 263 | // if(accountingEnabled) |
269 | // tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2") | 264 | // tooltip += QObject::tr("\nSession Bill: %1\nTotal Bill: %2") |
270 | // .arg(session_bill->text()).arg(total_bill->text()); | 265 | // .arg(session_bill->text()).arg(total_bill->text()); |
271 | // // volume accounting | 266 | // // volume accounting |
272 | // if(volumeAccountingEnabled) { | 267 | // if(volumeAccountingEnabled) { |
273 | 268 | ||
274 | // volinfo->setEnabled(TRUE); | 269 | // volinfo->setEnabled(TRUE); |
275 | // int bytes = _pppdata->totalBytes(); | 270 | // int bytes = _pppdata->totalBytes(); |
276 | // volinfo->setText(prettyPrintVolume(bytes)); | 271 | // volinfo->setText(prettyPrintVolume(bytes)); |
277 | // } | 272 | // } |
278 | 273 | ||
279 | // seconds++; | 274 | // seconds++; |
280 | 275 | ||
281 | // if(seconds >= 60 ) { | 276 | // if(seconds >= 60 ) { |
282 | // minutes ++; | 277 | // minutes ++; |
283 | // seconds = 0; | 278 | // seconds = 0; |
284 | // } | 279 | // } |
285 | 280 | ||
286 | // if (minutes >= 60){ | 281 | // if (minutes >= 60){ |
287 | // minutes = 0; | 282 | // minutes = 0; |
288 | // hours ++; | 283 | // hours ++; |
289 | // } | 284 | // } |
290 | 285 | ||
291 | // if( hours >= 24){ | 286 | // if( hours >= 24){ |
292 | // days ++; | 287 | // days ++; |
293 | // hours = 0; | 288 | // hours = 0; |
294 | // } | 289 | // } |
295 | 290 | ||
296 | // time_string.sprintf("%02d:%02d",hours,minutes); | 291 | // time_string.sprintf("%02d:%02d",hours,minutes); |
297 | // time_string2 = ""; | 292 | // time_string2 = ""; |
298 | // if (days) | 293 | // if (days) |
299 | // time_string2.sprintf("%d d %02d:%02d:%02d", | 294 | // time_string2.sprintf("%d d %02d:%02d:%02d", |
300 | // days,hours,minutes,seconds); | 295 | // days,hours,minutes,seconds); |
301 | 296 | ||
302 | // else | 297 | // else |
303 | // time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); | 298 | // time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds); |
304 | 299 | ||
305 | // caption_string = _pppdata->accname(); | 300 | // caption_string = _pppdata->accname(); |
306 | // caption_string += " "; | 301 | // caption_string += " "; |
307 | // caption_string += time_string; | 302 | // caption_string += time_string; |
308 | 303 | ||
309 | 304 | ||
310 | // timelabel2->setText(time_string2); | 305 | // timelabel2->setText(time_string2); |
311 | 306 | ||
312 | // if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){ | 307 | // if(_pppdata->get_show_clock_on_caption() && (seconds == 1)){ |
313 | // // we update the Caption only once per minute not every second | 308 | // // we update the Caption only once per minute not every second |
314 | // // otherwise I get a flickering icon | 309 | // // otherwise I get a flickering icon |
315 | // this->setCaption(caption_string); | 310 | // this->setCaption(caption_string); |
316 | // } | 311 | // } |
317 | 312 | ||
318 | // QToolTip::add(DockWidget::dock_widget, tooltip); | 313 | // QToolTip::add(DockWidget::dock_widget, tooltip); |
319 | } | 314 | } |
320 | 315 | ||
321 | 316 | ||
322 | void ConWindow::closeEvent( QCloseEvent *e ){ | 317 | void ConWindow::closeEvent( QCloseEvent *e ){ |
323 | // we don't want to lose the | 318 | // we don't want to lose the |
324 | // conwindow since this is our last connection kppp. | 319 | // conwindow since this is our last connection kppp. |
325 | // if we lost it we could only kill the program by hand to get on with life. | 320 | // if we lost it we could only kill the program by hand to get on with life. |
326 | e->ignore(); | 321 | e->ignore(); |
327 | 322 | ||
328 | // if(_pppdata->get_dock_into_panel()) | 323 | // if(_pppdata->get_dock_into_panel()) |
329 | // dock(); | 324 | // dock(); |
330 | } | 325 | } |
331 | 326 | ||
332 | 327 | ||
333 | void ConWindow::slotAccounting(QString total, QString session) { | 328 | void ConWindow::slotAccounting(QString total, QString session) { |
334 | total_bill->setText(total); | 329 | total_bill->setText(total); |
335 | session_bill->setText(session); | 330 | session_bill->setText(session); |
336 | } | 331 | } |
337 | 332 | ||
338 | 333 | ||
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp new file mode 100644 index 0000000..e94904b --- a/dev/null +++ b/noncore/settings/networksettings/ppp/devices.cpp | |||
@@ -0,0 +1,212 @@ | |||
1 | /* | ||
2 | * kPPP: A pppd front end for the KDE project | ||
3 | * | ||
4 | * $Id$ | ||
5 | * | ||
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | ||
7 | * wuebben@math.cornell.edu | ||
8 | * | ||
9 | * based on EzPPP: | ||
10 | * Copyright (C) 1997 Jay Painter | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU Library General Public | ||
14 | * License as published by the Free Software Foundation; either | ||
15 | * version 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
20 | * Library General Public License for more details. | ||
21 | * | ||
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 | ||
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <qdir.h> | ||
28 | #include <stdlib.h> | ||
29 | #include <qlayout.h> | ||
30 | #include <qtabwidget.h> | ||
31 | #include <qtabdialog.h> | ||
32 | #include <qwhatsthis.h> | ||
33 | #include <qmessagebox.h> | ||
34 | |||
35 | #include <qapplication.h> | ||
36 | #include <qbuttongroup.h> | ||
37 | #include <qmessagebox.h> | ||
38 | #include <qvgroupbox.h> | ||
39 | |||
40 | #include "interfaceppp.h" | ||
41 | #include "devices.h" | ||
42 | #include "authwidget.h" | ||
43 | #include "pppdata.h" | ||
44 | #include "edit.h" | ||
45 | #include "general.h" | ||
46 | |||
47 | void parseargs(char* buf, char** args); | ||
48 | |||
49 | DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) | ||
50 | : ChooserWidget(ip->data(), parent, name, f) | ||
51 | { | ||
52 | _ifaceppp = ip; | ||
53 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); | ||
54 | QWhatsThis::add(new_b, tr("Create a new device") ); | ||
55 | |||
56 | QWhatsThis::add(copy_b, | ||
57 | tr("Makes a copy of the selected device. All\n" | ||
58 | "settings of the selected device are copied\n" | ||
59 | "to a new device, that you can modify to fit your\n" | ||
60 | "needs")); | ||
61 | QWhatsThis::add(delete_b, | ||
62 | tr("<p>Deletes the selected device\n\n" | ||
63 | "<font color=\"red\"><b>Use with care!</b></font>")); | ||
64 | |||
65 | copy_b->setEnabled( false ); //FIXME | ||
66 | // delete_b->setEnabled( false ); //FIXME | ||
67 | |||
68 | QStringList tmp = _pppdata->getDevicesNamesList(); | ||
69 | qDebug("DevicesWidget::DevicesWidget got devices %s",tmp.join("--").latin1()); | ||
70 | listListbox->insertStringList(tmp); | ||
71 | |||
72 | for (uint i = 0; i < listListbox->count(); i++){ | ||
73 | qDebug("listListbox->text(i) %s == _pppdata->devname() %s",listListbox->text(i).latin1(), _pppdata->devname().latin1()); | ||
74 | if ( listListbox->text(i) == _pppdata->devname() ) | ||
75 | listListbox->setCurrentItem( i ); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | |||
80 | |||
81 | void DevicesWidget::slotListBoxSelect(int idx) { | ||
82 | bool ok = _pppdata->setDevice( listListbox->text(idx) ); | ||
83 | delete_b->setEnabled((bool)(idx != -1)); | ||
84 | edit_b->setEnabled((bool)(idx != -1)); | ||
85 | //FIXME copy_b->setEnabled((bool)(idx != -1)); | ||
86 | } | ||
87 | |||
88 | void DevicesWidget::edit() { | ||
89 | _pppdata->setDevice(listListbox->text(listListbox->currentItem())); | ||
90 | |||
91 | int result = doTab(); | ||
92 | |||
93 | if(result == QDialog::Accepted) { | ||
94 | listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); | ||
95 | _pppdata->save(); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | |||
100 | void DevicesWidget::create() { | ||
101 | |||
102 | // if(listListbox->count() == MAX_ACCOUNTS) { | ||
103 | // QMessageBox::information(this, "sorry", | ||
104 | // tr("Maximum number of accounts reached.")); | ||
105 | // return; | ||
106 | // } | ||
107 | |||
108 | int result; | ||
109 | if (_pppdata->newdevice() == -1){ | ||
110 | return; | ||
111 | } | ||
112 | result = doTab(); | ||
113 | |||
114 | if(result == QDialog::Accepted) { | ||
115 | listListbox->insertItem(_pppdata->devname()); | ||
116 | listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true ); | ||
117 | |||
118 | _pppdata->save(); | ||
119 | } else | ||
120 | _pppdata->deleteDevice(); | ||
121 | } | ||
122 | |||
123 | |||
124 | void DevicesWidget::copy() { | ||
125 | // if(listListbox->count() == MAX_ACCOUNTS) { | ||
126 | // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); | ||
127 | // return; | ||
128 | // } | ||
129 | |||
130 | if(listListbox->currentItem()<0) { | ||
131 | QMessageBox::information(this, "sorry", tr("No devices selected.")); | ||
132 | return; | ||
133 | } | ||
134 | |||
135 | _pppdata->copydevice(listListbox->currentText()); | ||
136 | |||
137 | listListbox->insertItem(_pppdata->devname()); | ||
138 | _pppdata->save(); | ||
139 | } | ||
140 | |||
141 | |||
142 | void DevicesWidget::remove() { | ||
143 | |||
144 | QString s = tr("Are you sure you want to delete\nthe device \"%1\"?") | ||
145 | .arg(listListbox->text(listListbox->currentItem())); | ||
146 | |||
147 | if(QMessageBox::warning(this,tr("Confirm"),s, | ||
148 | QMessageBox::Yes,QMessageBox::No | ||
149 | ) != QMessageBox::Yes) | ||
150 | return; | ||
151 | |||
152 | if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem()))) | ||
153 | listListbox->removeItem(listListbox->currentItem()); | ||
154 | |||
155 | |||
156 | // _pppdata->save(); | ||
157 | |||
158 | |||
159 | slotListBoxSelect(listListbox->currentItem()); | ||
160 | |||
161 | } | ||
162 | |||
163 | |||
164 | int DevicesWidget::doTab(){ | ||
165 | QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp ); | ||
166 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | ||
167 | layout->setSpacing( 0 ); | ||
168 | layout->setMargin( 1 ); | ||
169 | |||
170 | QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); | ||
171 | layout->addWidget( tabWindow ); | ||
172 | |||
173 | bool isnew; | ||
174 | |||
175 | if(_pppdata->devname().isEmpty()) { | ||
176 | dlg->setCaption(tr("New Device")); | ||
177 | isnew = true; | ||
178 | } else { | ||
179 | QString tit = tr("Edit Device: "); | ||
180 | tit += _pppdata->devname(); | ||
181 | dlg->setCaption(tit); | ||
182 | isnew = false; | ||
183 | } | ||
184 | |||
185 | modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" ); | ||
186 | tabWindow->addTab( modem1, tr("&Device") ); | ||
187 | modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); | ||
188 | tabWindow->addTab( modem2, tr("&Modem") ); | ||
189 | |||
190 | int result = 0; | ||
191 | bool ok = false; | ||
192 | |||
193 | while (!ok){ | ||
194 | dlg->showMaximized(); | ||
195 | result = dlg->exec(); | ||
196 | ok = true; | ||
197 | |||
198 | if(result == QDialog::Accepted) { | ||
199 | if (!modem1->save()){ | ||
200 | QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); | ||
201 | ok = false; | ||
202 | }else{ | ||
203 | modem2->save(); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | delete dlg; | ||
209 | |||
210 | return result; | ||
211 | } | ||
212 | |||
diff --git a/noncore/settings/networksettings/ppp/devices.h b/noncore/settings/networksettings/ppp/devices.h index d46d5b4..c2679c8 100644 --- a/noncore/settings/networksettings/ppp/devices.h +++ b/noncore/settings/networksettings/ppp/devices.h | |||
@@ -1,60 +1,51 @@ | |||
1 | #ifndef _DEVICES_H_ | 1 | #ifndef _DEVICES_H_ |
2 | #define _DEVICES_H_ | 2 | #define _DEVICES_H_ |
3 | 3 | ||
4 | #include "kpppconfig.h" | 4 | #include "kpppconfig.h" |
5 | 5 | ||
6 | static const char *devices[] = { | 6 | #include <qwidget.h> |
7 | #ifdef __FreeBSD__ | 7 | #include <qdialog.h> |
8 | "/dev/cuaa0", | 8 | #include <qpushbutton.h> |
9 | "/dev/cuaa1", | 9 | #include <qlistbox.h> |
10 | "/dev/cuaa2", | 10 | #include "chooserwidget.h" |
11 | "/dev/cuaa3", | 11 | |
12 | "/dev/cuaa4", | 12 | class QCheckBox; |
13 | #elif defined(__NetBSD__) | 13 | class QLineEdit; |
14 | "/dev/tty00", /* "normal" modem lines */ | 14 | class QTabWidget; |
15 | "/dev/tty01", | 15 | class DialWidget; |
16 | "/dev/tty02", | 16 | class AuthWidget; |
17 | "/dev/tty03", | 17 | class IPWidget; |
18 | "/dev/dty00", /* Dial out devices */ | 18 | class DNSWidget; |
19 | "/dev/dty01", | 19 | class GatewayWidget; |
20 | "/dev/dty02", | 20 | class InterfacePPP; |
21 | "/dev/dty03", | 21 | class PPPData; |
22 | "/dev/ttyU0", /* USB stuff modems */ | 22 | class ModemWidget; |
23 | "/dev/ttyU1", | 23 | class ModemWidget2; |
24 | "/dev/ttyU2", | 24 | |
25 | "/dev/ttyU3", | 25 | class DevicesWidget : public ChooserWidget { |
26 | "/dev/dtyU0", /* USB stuff, too (dial out device) */ | 26 | Q_OBJECT |
27 | "/dev/dtyU1", | 27 | public: |
28 | "/dev/dtyU2", | 28 | DevicesWidget( InterfacePPP* ip, QWidget *parent=0, const char *name=0, WFlags f=0 ); |
29 | "/dev/dtyU3", | 29 | ~DevicesWidget() {} |
30 | #elif defined (__linux__) | 30 | |
31 | "/dev/modem", | 31 | |
32 | "/dev/ttyS0", | 32 | private slots: |
33 | "/dev/ttyS1", | 33 | virtual void edit(); |
34 | "/dev/ttyS2", | 34 | virtual void copy(); |
35 | "/dev/ttyS3", | 35 | virtual void remove(); |
36 | #ifdef ISDNSUPPORT | 36 | virtual void create(); |
37 | "/dev/ttyI0", | 37 | virtual void slotListBoxSelect(int); |
38 | "/dev/ttyI1", | 38 | int doTab(); |
39 | "/dev/ttyI2", | 39 | |
40 | "/dev/ttyI3", | 40 | // signals: |
41 | #endif | 41 | // void resetaccounts(); |
42 | "/dev/usb/ttyACM0", /* USB stuff modems */ | 42 | |
43 | "/dev/usb/ttyACM1", | 43 | private: |
44 | "/dev/usb/ttyACM2", | 44 | ModemWidget *modem1; |
45 | "/dev/usb/ttyACM3", | 45 | ModemWidget2 *modem2; |
46 | "/dev/ircomm0", | 46 | InterfacePPP *_ifaceppp; |
47 | "/dev/rfcomm0", | 47 | |
48 | "/dev/rfcomm1", | 48 | }; |
49 | #elif defined(__svr4__) | ||
50 | "/dev/cua/a", | ||
51 | "/dev/cua/b", | ||
52 | "/dev/ttya", | ||
53 | "/dev/ttyb", | ||
54 | #endif | ||
55 | 0}; | ||
56 | 49 | ||
57 | // default device number from the list above | ||
58 | const int DEV_DEFAULT = 0; | ||
59 | 50 | ||
60 | #endif | 51 | #endif |
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 0c96253..ceac90c 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -1,177 +1,177 @@ | |||
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 | * Copyright (C) 1997 Bernd Johannes Wuebben | 5 | * Copyright (C) 1997 Bernd Johannes Wuebben |
6 | * wuebben@math.cornell.edu | 6 | * wuebben@math.cornell.edu |
7 | * | 7 | * |
8 | * based on EzPPP: | 8 | * based on EzPPP: |
9 | * Copyright (C) 1997 Jay Painter | 9 | * Copyright (C) 1997 Jay Painter |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Library General Public | 12 | * modify it under the terms of the GNU Library General Public |
13 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <termios.h> | 27 | #include <termios.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qbuttongroup.h> | 33 | #include <qbuttongroup.h> |
34 | #include <qvgroupbox.h> | 34 | #include <qvgroupbox.h> |
35 | #include <qhbox.h> | 35 | #include <qhbox.h> |
36 | #include <qdialog.h> | 36 | #include <qdialog.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | 38 | ||
39 | #include "edit.h" | 39 | #include "edit.h" |
40 | #include "pppdata.h" | 40 | #include "pppdata.h" |
41 | #include "iplined.h" | 41 | #include "iplined.h" |
42 | #include "auth.h" | 42 | #include "auth.h" |
43 | 43 | ||
44 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | 44 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
45 | , const char *name ) | 45 | , const char *name ) |
46 | : QWidget(parent, name), _pppdata(pd) | 46 | : QWidget(parent, name), _pppdata(pd) |
47 | { | 47 | { |
48 | const int GRIDROWS = 6; | 48 | const int GRIDROWS = 6; |
49 | 49 | ||
50 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); | 50 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); |
51 | 51 | ||
52 | connect_label = new QLabel(tr("Connection name:"), this); | 52 | connect_label = new QLabel(tr("Connection name:"), this); |
53 | tl->addWidget(connect_label, 0, 0); | 53 | tl->addWidget(connect_label, 0, 0); |
54 | 54 | ||
55 | connectname_l = new QLineEdit(this); | 55 | connectname_l = new QLineEdit(this); |
56 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 56 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
57 | tl->addWidget(connectname_l, 0, 1); | 57 | tl->addWidget(connectname_l, 0, 1); |
58 | QString tmp = tr("Type in a unique name for this connection"); | 58 | QString tmp = tr("Type in a unique name for this connection"); |
59 | 59 | ||
60 | QWhatsThis::add(connect_label,tmp); | 60 | QWhatsThis::add(connect_label,tmp); |
61 | QWhatsThis::add(connectname_l,tmp); | 61 | QWhatsThis::add(connectname_l,tmp); |
62 | 62 | ||
63 | 63 | ||
64 | number_label = new QLabel(tr("Phone number:"), this); | 64 | number_label = new QLabel(tr("Phone number:"), this); |
65 | number_label->setAlignment(AlignTop|AlignLeft); | 65 | number_label->setAlignment(AlignTop|AlignLeft); |
66 | tl->addWidget(number_label, 1, 0); | 66 | tl->addWidget(number_label, 1, 0); |
67 | 67 | ||
68 | QHBoxLayout *lpn = new QHBoxLayout(5); | 68 | QHBoxLayout *lpn = new QHBoxLayout(5); |
69 | tl->addLayout(lpn, 1, 1); | 69 | tl->addLayout(lpn, 1, 1); |
70 | numbers = new QListBox(this); | 70 | numbers = new QListBox(this); |
71 | // numbers->setMinimumSize(120, 70); | 71 | // numbers->setMinimumSize(120, 70); |
72 | lpn->addWidget(numbers); | 72 | lpn->addWidget(numbers); |
73 | QVBoxLayout *lpn1 = new QVBoxLayout; | 73 | QVBoxLayout *lpn1 = new QVBoxLayout; |
74 | lpn->addLayout(lpn1); | 74 | lpn->addLayout(lpn1); |
75 | add = new QPushButton(tr("&Add..."), this); | 75 | add = new QPushButton(tr("&Add..."), this); |
76 | del = new QPushButton(tr("&Remove"), this); | 76 | del = new QPushButton(tr("&Remove"), this); |
77 | 77 | ||
78 | up = new QPushButton(this); | 78 | up = new QPushButton(this); |
79 | up->setPixmap( Resource::loadPixmap("inline/up") ); | 79 | up->setPixmap( Resource::loadPixmap("up") ); |
80 | down = new QPushButton(this); | 80 | down = new QPushButton(this); |
81 | down->setPixmap( Resource::loadPixmap("inline/down") ); | 81 | down->setPixmap( Resource::loadPixmap("down") ); |
82 | lpn1->addWidget(add); | 82 | lpn1->addWidget(add); |
83 | lpn1->addWidget(del); | 83 | lpn1->addWidget(del); |
84 | lpn1->addStretch(1); | 84 | lpn1->addStretch(1); |
85 | lpn1->addWidget(up); | 85 | lpn1->addWidget(up); |
86 | lpn1->addWidget(down); | 86 | lpn1->addWidget(down); |
87 | connect(add, SIGNAL(clicked()), | 87 | connect(add, SIGNAL(clicked()), |
88 | this, SLOT(addNumber())); | 88 | this, SLOT(addNumber())); |
89 | connect(del, SIGNAL(clicked()), | 89 | connect(del, SIGNAL(clicked()), |
90 | this, SLOT(delNumber())); | 90 | this, SLOT(delNumber())); |
91 | connect(up, SIGNAL(clicked()), | 91 | connect(up, SIGNAL(clicked()), |
92 | this, SLOT(upNumber())); | 92 | this, SLOT(upNumber())); |
93 | connect(down, SIGNAL(clicked()), | 93 | connect(down, SIGNAL(clicked()), |
94 | this, SLOT(downNumber())); | 94 | this, SLOT(downNumber())); |
95 | connect(numbers, SIGNAL(highlighted(int)), | 95 | connect(numbers, SIGNAL(highlighted(int)), |
96 | this, SLOT(selectionChanged(int))); | 96 | this, SLOT(selectionChanged(int))); |
97 | numbersChanged(); | 97 | numbersChanged(); |
98 | 98 | ||
99 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" | 99 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" |
100 | "can supply multiple numbers here, simply\n" | 100 | "can supply multiple numbers here, simply\n" |
101 | "click on \"Add\". You can arrange the\n" | 101 | "click on \"Add\". You can arrange the\n" |
102 | "order the numbers are tried by using the\n" | 102 | "order the numbers are tried by using the\n" |
103 | "arrow buttons.\n\n" | 103 | "arrow buttons.\n\n" |
104 | "When a number is busy or fails, <i>kppp</i> will \n" | 104 | "When a number is busy or fails, <i>kppp</i> will \n" |
105 | "try the next number and so on"); | 105 | "try the next number and so on"); |
106 | 106 | ||
107 | QWhatsThis::add(number_label,tmp); | 107 | QWhatsThis::add(number_label,tmp); |
108 | QWhatsThis::add(numbers,tmp); | 108 | QWhatsThis::add(numbers,tmp); |
109 | 109 | ||
110 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | 110 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); |
111 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | 111 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); |
112 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | 112 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); |
113 | 113 | ||
114 | // Set defaults if editing an existing connection | 114 | // Set defaults if editing an existing connection |
115 | if(!isnewaccount) { | 115 | if(!isnewaccount) { |
116 | connectname_l->setText(_pppdata->accname()); | 116 | connectname_l->setText(_pppdata->accname()); |
117 | 117 | ||
118 | // insert the phone numbers into the listbox | 118 | // insert the phone numbers into the listbox |
119 | QString n = _pppdata->phonenumber(); | 119 | QString n = _pppdata->phonenumber(); |
120 | QString tmp = ""; | 120 | QString tmp = ""; |
121 | uint idx = 0; | 121 | uint idx = 0; |
122 | while(idx != n.length()) { | 122 | while(idx != n.length()) { |
123 | if(n[idx] == ':') { | 123 | if(n[idx] == ':') { |
124 | if(tmp.length() > 0) | 124 | if(tmp.length() > 0) |
125 | numbers->insertItem(tmp); | 125 | numbers->insertItem(tmp); |
126 | tmp = ""; | 126 | tmp = ""; |
127 | } else | 127 | } else |
128 | tmp += n[idx]; | 128 | tmp += n[idx]; |
129 | idx++; | 129 | idx++; |
130 | } | 130 | } |
131 | if(tmp.length() > 0) | 131 | if(tmp.length() > 0) |
132 | numbers->insertItem(tmp); | 132 | numbers->insertItem(tmp); |
133 | 133 | ||
134 | } | 134 | } |
135 | 135 | ||
136 | numbersChanged(); | 136 | numbersChanged(); |
137 | tl->activate(); | 137 | tl->activate(); |
138 | } | 138 | } |
139 | 139 | ||
140 | bool DialWidget::save() { | 140 | bool DialWidget::save() { |
141 | //first check to make sure that the account name is unique! | 141 | //first check to make sure that the account name is unique! |
142 | if(connectname_l->text().isEmpty() || | 142 | if(connectname_l->text().isEmpty() || |
143 | !_pppdata->isUniqueAccname(connectname_l->text())) { | 143 | !_pppdata->isUniqueAccname(connectname_l->text())) { |
144 | return false; | 144 | return false; |
145 | } else { | 145 | } else { |
146 | _pppdata->setAccname(connectname_l->text()); | 146 | _pppdata->setAccname(connectname_l->text()); |
147 | 147 | ||
148 | QString number = ""; | 148 | QString number = ""; |
149 | for(uint i = 0; i < numbers->count(); i++) { | 149 | for(uint i = 0; i < numbers->count(); i++) { |
150 | if(i != 0) | 150 | if(i != 0) |
151 | number += ":"; | 151 | number += ":"; |
152 | number += numbers->text(i); | 152 | number += numbers->text(i); |
153 | } | 153 | } |
154 | 154 | ||
155 | _pppdata->setPhonenumber(number); | 155 | _pppdata->setPhonenumber(number); |
156 | return true; | 156 | return true; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | void DialWidget::numbersChanged() { | 161 | void DialWidget::numbersChanged() { |
162 | int sel = numbers->currentItem(); | 162 | int sel = numbers->currentItem(); |
163 | 163 | ||
164 | del->setEnabled(sel != -1); | 164 | del->setEnabled(sel != -1); |
165 | up->setEnabled(sel != -1 && sel != 0); | 165 | up->setEnabled(sel != -1 && sel != 0); |
166 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 166 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | void DialWidget::selectionChanged(int) { | 170 | void DialWidget::selectionChanged(int) { |
171 | numbersChanged(); | 171 | numbersChanged(); |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | void DialWidget::addNumber() { | 175 | void DialWidget::addNumber() { |
176 | PhoneNumberDialog dlg(this); | 176 | PhoneNumberDialog dlg(this); |
177 | if(dlg.exec()) { | 177 | if(dlg.exec()) { |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index f735e49..5540946 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -1,441 +1,518 @@ | |||
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 <termios.h> | 27 | #include <termios.h> |
28 | #include <string.h> | 28 | #include <string.h> |
29 | 29 | ||
30 | #include <qcheckbox.h> | 30 | #include <qcheckbox.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qslider.h> | 35 | #include <qslider.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qwhatsthis.h> | 37 | #include <qwhatsthis.h> |
38 | 38 | #include <qpe/config.h> | |
39 | // #include <qgroupbox.h> | 39 | // #include <qgroupbox.h> |
40 | 40 | ||
41 | |||
41 | #include "general.h" | 42 | #include "general.h" |
42 | #include "interfaceppp.h" | 43 | #include "interfaceppp.h" |
43 | //#include "miniterm.h" | 44 | //#include "miniterm.h" |
44 | #include "modeminfo.h" | 45 | #include "modeminfo.h" |
45 | #include "modemcmds.h" | 46 | #include "modemcmds.h" |
46 | #include "devices.h" | 47 | //#include "devices.h" |
47 | #include "pppdata.h" | 48 | #include "pppdata.h" |
48 | //#include <klocale.h> | 49 | //#include <klocale.h> |
49 | #define i18n QObject::tr | ||
50 | 50 | ||
51 | 51 | ||
52 | 52 | ||
53 | ModemWidget::ModemWidget( InterfacePPP *ifppp, QWidget *parent, const char *name ) | 53 | |
54 | : QWidget(parent, name), _ifaceppp(ifppp) | 54 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) |
55 | : QWidget(parent, name), _pppdata(pd) | ||
55 | { | 56 | { |
56 | int k; | 57 | int k; |
57 | 58 | ||
58 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); | 59 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); |
59 | 60 | ||
60 | QLabel *label1; | 61 | QLabel *label1; |
61 | label1 = new QLabel(i18n("Modem de&vice:"), this); | 62 | |
63 | label1 = new QLabel(tr("Modem &name:"), this); | ||
62 | tl->addWidget(label1, 0, 0); | 64 | tl->addWidget(label1, 0, 0); |
63 | 65 | ||
66 | modemname = new QLineEdit(this, "modemName"); | ||
67 | modemname->setText( _pppdata->devname() ); | ||
68 | label1->setBuddy(modemname); | ||
69 | tl->addWidget(modemname, 0, 1); | ||
70 | |||
71 | label1 = new QLabel(tr("Modem de&vice:"), this); | ||
72 | tl->addWidget(label1, 1, 0); | ||
73 | |||
64 | modemdevice = new QComboBox(false, this); | 74 | modemdevice = new QComboBox(false, this); |
75 | modemdevice->setEditable( true ); | ||
76 | modemdevice->setDuplicatesEnabled ( false ); | ||
77 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); | ||
65 | label1->setBuddy(modemdevice); | 78 | label1->setBuddy(modemdevice); |
66 | 79 | ||
67 | for(k = 0; devices[k]; k++) | 80 | Config cfg("NetworkSetupPPP"); |
68 | modemdevice->insertItem(devices[k]); | 81 | cfg.setGroup("Devices_General"); |
82 | QStringList devs = cfg.readListEntry("devices",','); | ||
83 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; | ||
84 | modemdevice->insertStringList( devs ); | ||
85 | tl->addWidget(modemdevice, 1, 1); | ||
86 | |||
87 | // connect(modemdevice, SIGNAL(activated(int)), | ||
88 | // SLOT(setmodemdc(int))); | ||
89 | // connect(modemdevice, SIGNAL(textChanged( const QString & ) ), | ||
90 | // SLOT( setmodemdc( const QString &) ) ); | ||
69 | 91 | ||
70 | tl->addWidget(modemdevice, 0, 1); | 92 | QString tmp = tr("This specifies the serial port your modem is attached \n" |
71 | connect(modemdevice, SIGNAL(activated(int)), | ||
72 | SLOT(setmodemdc(int))); | ||
73 | QString tmp = i18n("This specifies the serial port your modem is attached \n" | ||
74 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" | 93 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" |
75 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" | 94 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" |
76 | "\n" | 95 | "\n" |
77 | "If you have an internal ISDN card with AT command\n" | 96 | "If you have an internal ISDN card with AT command\n" |
78 | "emulation (most cards under Linux support this), you\n" | 97 | "emulation (most cards under Linux support this), you\n" |
79 | "should select one of the /dev/ttyIx devices."); | 98 | "should select one of the /dev/ttyIx devices."); |
80 | 99 | ||
81 | QWhatsThis::add(label1,tmp); | 100 | QWhatsThis::add(label1,tmp); |
82 | QWhatsThis::add(modemdevice,tmp); | 101 | QWhatsThis::add(modemdevice,tmp); |
83 | 102 | ||
84 | 103 | ||
85 | label1 = new QLabel(i18n("&Flow control:"), this); | 104 | label1 = new QLabel(tr("&Flow control:"), this); |
86 | tl->addWidget(label1, 1, 0); | 105 | tl->addWidget(label1, 2, 0); |
87 | 106 | ||
88 | flowcontrol = new QComboBox(false, this); | 107 | flowcontrol = new QComboBox(false, this); |
89 | label1->setBuddy(flowcontrol); | 108 | label1->setBuddy(flowcontrol); |
90 | flowcontrol->insertItem(i18n("Hardware [CRTSCTS]")); | 109 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); |
91 | flowcontrol->insertItem(i18n("Software [XON/XOFF]")); | 110 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); |
92 | flowcontrol->insertItem(i18n("None")); | 111 | flowcontrol->insertItem(tr("None")); |
93 | tl->addWidget(flowcontrol, 1, 1); | 112 | tl->addWidget(flowcontrol, 2, 1); |
94 | connect(flowcontrol, SIGNAL(activated(int)), | 113 | // connect(flowcontrol, SIGNAL(activated(int)), |
95 | SLOT(setflowcontrol(int))); | 114 | // SLOT(setflowcontrol(int))); |
96 | 115 | ||
97 | tmp = i18n("<p>Specifies how the serial port and modem\n" | 116 | tmp = tr("<p>Specifies how the serial port and modem\n" |
98 | "communicate. You should not change this unless\n" | 117 | "communicate. You should not change this unless\n" |
99 | "you know what you are doing.\n" | 118 | "you know what you are doing.\n" |
100 | "\n" | 119 | "\n" |
101 | "<b>Default</b>: CRTSCTS"); | 120 | "<b>Default</b>: CRTSCTS"); |
102 | 121 | ||
103 | QWhatsThis::add(label1,tmp); | 122 | QWhatsThis::add(label1,tmp); |
104 | QWhatsThis::add(flowcontrol,tmp); | 123 | QWhatsThis::add(flowcontrol,tmp); |
105 | 124 | ||
106 | QLabel *labelenter = new QLabel(i18n("&Line termination:"), this); | 125 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); |
107 | tl->addWidget(labelenter, 2, 0); | 126 | tl->addWidget(labelenter, 3, 0); |
108 | 127 | ||
109 | enter = new QComboBox(false, this); | 128 | enter = new QComboBox(false, this); |
110 | labelenter->setBuddy(enter); | 129 | labelenter->setBuddy(enter); |
111 | enter->insertItem("CR"); | 130 | enter->insertItem("CR"); |
112 | enter->insertItem("LF"); | 131 | enter->insertItem("LF"); |
113 | enter->insertItem("CR/LF"); | 132 | enter->insertItem("CR/LF"); |
114 | tl->addWidget(enter, 2, 1); | 133 | tl->addWidget(enter, 3, 1); |
115 | connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); | 134 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); |
116 | tmp = i18n("<p>Specifies how AT commands are sent to your\n" | 135 | tmp = tr("<p>Specifies how AT commands are sent to your\n" |
117 | "modem. Most modems will work fine with the\n" | 136 | "modem. Most modems will work fine with the\n" |
118 | "default <i>CR/LF</i>. If your modem does not react\n" | 137 | "default <i>CR/LF</i>. If your modem does not react\n" |
119 | "to the init string, you should try different\n" | 138 | "to the init string, you should try different\n" |
120 | "settings here\n" | 139 | "settings here\n" |
121 | "\n" | 140 | "\n" |
122 | "<b>Default</b>: CR/LF"); | 141 | "<b>Default</b>: CR/LF"); |
123 | 142 | ||
124 | QWhatsThis::add(labelenter,tmp); | 143 | QWhatsThis::add(labelenter,tmp); |
125 | QWhatsThis::add(enter, tmp); | 144 | QWhatsThis::add(enter, tmp); |
126 | 145 | ||
127 | QLabel *baud_label = new QLabel(i18n("Co&nnection speed:"), this); | 146 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); |
128 | tl->addWidget(baud_label, 3, 0); | 147 | tl->addWidget(baud_label, 4, 0); |
129 | baud_c = new QComboBox(this); | 148 | baud_c = new QComboBox(this); |
130 | baud_label->setBuddy(baud_c); | 149 | baud_label->setBuddy(baud_c); |
131 | 150 | ||
132 | static const char *baudrates[] = { | 151 | static const char *baudrates[] = { |
133 | 152 | ||
134 | #ifdef B460800 | 153 | #ifdef B460800 |
135 | "460800", | 154 | "460800", |
136 | #endif | 155 | #endif |
137 | 156 | ||
138 | #ifdef B230400 | 157 | #ifdef B230400 |
139 | "230400", | 158 | "230400", |
140 | #endif | 159 | #endif |
141 | 160 | ||
142 | #ifdef B115200 | 161 | #ifdef B115200 |
143 | "115200", | 162 | "115200", |
144 | #endif | 163 | #endif |
145 | 164 | ||
146 | #ifdef B57600 | 165 | #ifdef B57600 |
147 | "57600", | 166 | "57600", |
148 | #endif | 167 | #endif |
149 | 168 | ||
150 | "38400", | 169 | "38400", |
151 | "19200", | 170 | "19200", |
152 | "9600", | 171 | "9600", |
153 | "2400", | 172 | "2400", |
154 | 0}; | 173 | 0}; |
155 | 174 | ||
156 | for(k = 0; baudrates[k]; k++) | 175 | for(k = 0; baudrates[k]; k++) |
157 | baud_c->insertItem(baudrates[k]); | 176 | baud_c->insertItem(baudrates[k]); |
158 | 177 | ||
159 | baud_c->setCurrentItem(3); | 178 | baud_c->setCurrentItem(3); |
160 | connect(baud_c, SIGNAL(activated(int)), | 179 | // connect(baud_c, SIGNAL(activated(int)), |
161 | this, SLOT(speed_selection(int))); | 180 | // this, SLOT(speed_selection(int))); |
162 | tl->addWidget(baud_c, 3, 1); | 181 | tl->addWidget(baud_c, 4, 1); |
163 | 182 | ||
164 | tmp = i18n("Specifies the speed your modem and the serial\n" | 183 | tmp = tr("Specifies the speed your modem and the serial\n" |
165 | "port talk to each other. You should begin with\n" | 184 | "port talk to each other. You should begin with\n" |
166 | "the default of 38400 bits/sec. If everything\n" | 185 | "the default of 38400 bits/sec. If everything\n" |
167 | "works you can try to increase this value, but to\n" | 186 | "works you can try to increase this value, but to\n" |
168 | "no more than 115200 bits/sec (unless you know\n" | 187 | "no more than 115200 bits/sec (unless you know\n" |
169 | "that your serial port supports higher speeds)."); | 188 | "that your serial port supports higher speeds)."); |
170 | 189 | ||
171 | QWhatsThis::add(baud_label,tmp); | 190 | QWhatsThis::add(baud_label,tmp); |
172 | QWhatsThis::add(baud_c,tmp); | 191 | QWhatsThis::add(baud_c,tmp); |
173 | 192 | ||
174 | for(int i=0; i <= enter->count()-1; i++) { | 193 | for(int i=0; i <= enter->count()-1; i++) { |
175 | if(_ifaceppp->data()->enter() == enter->text(i)) | 194 | if(_pppdata->enter() == enter->text(i)) |
176 | enter->setCurrentItem(i); | 195 | enter->setCurrentItem(i); |
177 | } | 196 | } |
178 | 197 | ||
179 | tl->addRowSpacing(4, 10); | 198 | tl->addRowSpacing(5, 10); |
180 | 199 | ||
181 | //Modem Lock File | 200 | //Modem Lock File |
182 | modemlockfile = new QCheckBox(i18n("&Use lock file"), this); | 201 | modemlockfile = new QCheckBox(tr("&Use lock file"), this); |
183 | 202 | ||
184 | modemlockfile->setChecked(_ifaceppp->data()->modemLockFile()); | 203 | modemlockfile->setChecked(_pppdata->modemLockFile()); |
185 | connect(modemlockfile, SIGNAL(toggled(bool)), | 204 | // connect(modemlockfile, SIGNAL(toggled(bool)), |
186 | SLOT(modemlockfilechanged(bool))); | 205 | // SLOT(modemlockfilechanged(bool))); |
187 | tl->addMultiCellWidget(modemlockfile, 5, 5, 0, 1); | 206 | tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1); |
188 | // l12->addStretch(1); | 207 | // l12->addStretch(1); |
189 | QWhatsThis::add(modemlockfile, | 208 | QWhatsThis::add(modemlockfile, |
190 | i18n("<p>To prevent other programs from accessing the\n" | 209 | tr("<p>To prevent other programs from accessing the\n" |
191 | "modem while a connection is established, a\n" | 210 | "modem while a connection is established, a\n" |
192 | "file can be created to indicate that the modem\n" | 211 | "file can be created to indicate that the modem\n" |
193 | "is in use. On Linux an example file would be\n" | 212 | "is in use. On Linux an example file would be\n" |
194 | "<tt>/var/lock/LCK..ttyS1</tt>\n" | 213 | "<tt>/var/lock/LCK..ttyS1</tt>\n" |
195 | "Here you can select whether this locking will\n" | 214 | "Here you can select whether this locking will\n" |
196 | "be done.\n" | 215 | "be done.\n" |
197 | "\n" | 216 | "\n" |
198 | "<b>Default</b>: On")); | 217 | "<b>Default</b>: On")); |
199 | 218 | ||
200 | // Modem Timeout Line Edit Box | 219 | // Modem Timeout Line Edit Box |
201 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); | 220 | QHBoxLayout *timeoutLayout = new QHBoxLayout( this ); |
202 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); | 221 | QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" ); |
203 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); | 222 | modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" ); |
204 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); | 223 | // modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this); |
205 | // modemtimeout->setLabel(i18n("Modem &timeout:")); | 224 | // modemtimeout->setLabel(tr("Modem &timeout:")); |
206 | // modemtimeout->setRange(1, 120, 1); | 225 | // modemtimeout->setRange(1, 120, 1); |
207 | modemtimeout->setSuffix(i18n(" sec")); | 226 | modemtimeout->setSuffix(tr(" sec")); |
208 | modemtimeout->setValue( _ifaceppp->data()->modemTimeout() ); | 227 | modemtimeout->setValue( _pppdata->modemTimeout() ); |
209 | connect(modemtimeout, SIGNAL(valueChanged(int)), | 228 | // connect(modemtimeout, SIGNAL(valueChanged(int)), |
210 | SLOT(modemtimeoutchanged(int))); | 229 | // SLOT(modemtimeoutchanged(int))); |
211 | timeoutLayout->addWidget(timeoutlabel); | 230 | timeoutLayout->addWidget(timeoutlabel); |
212 | timeoutLayout->addWidget(modemtimeout); | 231 | timeoutLayout->addWidget(modemtimeout); |
213 | tl->addMultiCellLayout(timeoutLayout, 6, 6, 0, 1); | 232 | tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); |
214 | 233 | ||
215 | QWhatsThis::add(modemtimeout, | 234 | QWhatsThis::add(modemtimeout, |
216 | i18n("This specifies how long <i>kppp</i> waits for a\n" | 235 | tr("This specifies how long <i>kppp</i> waits for a\n" |
217 | "<i>CONNECT</i> response from your modem. The\n" | 236 | "<i>CONNECT</i> response from your modem. The\n" |
218 | "recommended value is 30 seconds.")); | 237 | "recommended value is 30 seconds.")); |
219 | 238 | ||
220 | //set stuff from gpppdata | 239 | //set stuff from gpppdata |
221 | for(int i=0; i <= enter->count()-1; i++) { | 240 | for(int i=0; i <= enter->count()-1; i++) { |
222 | if(_ifaceppp->data()->enter() == enter->text(i)) | 241 | if(_pppdata->enter() == enter->text(i)) |
223 | enter->setCurrentItem(i); | 242 | enter->setCurrentItem(i); |
224 | } | 243 | } |
225 | 244 | ||
226 | for(int i=0; i <= modemdevice->count()-1; i++) { | 245 | for(int i=0; i <= modemdevice->count()-1; i++) { |
227 | if(_ifaceppp->data()->modemDevice() == modemdevice->text(i)) | 246 | if(_pppdata->modemDevice() == modemdevice->text(i)) |
228 | modemdevice->setCurrentItem(i); | 247 | modemdevice->setCurrentItem(i); |
229 | } | 248 | } |
230 | 249 | ||
231 | for(int i=0; i <= flowcontrol->count()-1; i++) { | 250 | for(int i=0; i <= flowcontrol->count()-1; i++) { |
232 | if(_ifaceppp->data()->flowcontrol() == flowcontrol->text(i)) | 251 | if(_pppdata->flowcontrol() == flowcontrol->text(i)) |
233 | flowcontrol->setCurrentItem(i); | 252 | flowcontrol->setCurrentItem(i); |
234 | } | 253 | } |
235 | 254 | ||
236 | //set the modem speed | 255 | //set the modem speed |
237 | for(int i=0; i < baud_c->count(); i++) | 256 | for(int i=0; i < baud_c->count(); i++) |
238 | if(baud_c->text(i) == _ifaceppp->data()->speed()) | 257 | if(baud_c->text(i) == _pppdata->speed()) |
239 | baud_c->setCurrentItem(i); | 258 | baud_c->setCurrentItem(i); |
240 | 259 | ||
241 | tl->setRowStretch(7, 1); | 260 | tl->setRowStretch(1, 1); |
242 | } | 261 | } |
243 | 262 | ||
263 | ModemWidget::~ModemWidget() | ||
264 | { | ||
265 | QStringList devs; | ||
244 | 266 | ||
245 | void ModemWidget::speed_selection(int) { | 267 | for (int i=0;i<modemdevice->count();i++) |
246 | _ifaceppp->data()->setSpeed(baud_c->text(baud_c->currentItem())); | 268 | { |
247 | } | 269 | QString s = modemdevice->text(i); |
270 | s.simplifyWhiteSpace(); | ||
271 | if (! s.isEmpty() ) devs << s; | ||
272 | } | ||
248 | 273 | ||
249 | 274 | ||
250 | void ModemWidget::setenter(int ) { | 275 | QString edited = modemdevice->currentText(); |
251 | _ifaceppp->data()->setEnter(enter->text(enter->currentItem())); | 276 | if ( !( edited ).isEmpty() ) { |
252 | } | 277 | edited.simplifyWhiteSpace(); |
278 | if ( devs.contains( edited ) == 0 ) { | ||
279 | devs << edited; | ||
280 | } | ||
281 | _pppdata->setModemDevice( edited ); | ||
282 | } | ||
283 | |||
253 | 284 | ||
285 | Config cfg("NetworkSetupPPP"); | ||
286 | cfg.setGroup("Devices_General"); | ||
287 | cfg.writeEntry("devices",devs,','); | ||
254 | 288 | ||
255 | void ModemWidget::setmodemdc(int i) { | ||
256 | _ifaceppp->data()->setModemDevice(modemdevice->text(i)); | ||
257 | } | 289 | } |
258 | 290 | ||
291 | // void ModemWidget::speed_selection(int) { | ||
292 | // _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); | ||
293 | // } | ||
259 | 294 | ||
260 | void ModemWidget::setflowcontrol(int i) { | ||
261 | _ifaceppp->data()->setFlowcontrol(flowcontrol->text(i)); | ||
262 | } | ||
263 | 295 | ||
296 | // void ModemWidget::setenter(int ) { | ||
297 | // _pppdata->setEnter(enter->text(enter->currentItem())); | ||
298 | // } | ||
264 | 299 | ||
265 | void ModemWidget::modemlockfilechanged(bool set) { | ||
266 | _ifaceppp->data()->setModemLockFile(set); | ||
267 | } | ||
268 | 300 | ||
301 | // void ModemWidget::setmodemdc(int i) { | ||
302 | // _pppdata->setModemDevice(modemdevice->text(i)); | ||
303 | // } | ||
269 | 304 | ||
270 | void ModemWidget::modemtimeoutchanged(int n) { | 305 | // void ModemWidget::setmodemdc( const QString &string ) { |
271 | _ifaceppp->data()->setModemTimeout(n); | 306 | // _pppdata->setModemDevice( string ); |
272 | } | 307 | // } |
308 | |||
309 | // void ModemWidget::setflowcontrol(int i) { | ||
310 | // _pppdata->setFlowcontrol(flowcontrol->text(i)); | ||
311 | // } | ||
273 | 312 | ||
274 | 313 | ||
275 | ModemWidget2::ModemWidget2( InterfacePPP* ifp, QWidget *parent, | 314 | // void ModemWidget::modemlockfilechanged(bool set) { |
315 | // _pppdata->setModemLockFile(set); | ||
316 | // } | ||
317 | |||
318 | |||
319 | // void ModemWidget::modemtimeoutchanged(int n) { | ||
320 | // _pppdata->setModemTimeout(n); | ||
321 | // } | ||
322 | |||
323 | |||
324 | |||
325 | bool ModemWidget::save() | ||
326 | { | ||
327 | //first check to make sure that the device name is unique! | ||
328 | if(modemname->text().isEmpty() || | ||
329 | !_pppdata->isUniqueDevname(modemname->text())) | ||
330 | return false; | ||
331 | |||
332 | qDebug("ModemWidget::save saving modem1 data"); | ||
333 | _pppdata->setDevname( modemname->text() ); | ||
334 | _pppdata->setModemDevice( modemdevice->currentText() ); | ||
335 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | ||
336 | _pppdata->setFlowcontrol(flowcontrol->currentText()); | ||
337 | _pppdata->setSpeed(baud_c->currentText()); | ||
338 | _pppdata->setModemLockFile( modemlockfile->isChecked()); | ||
339 | _pppdata->setModemTimeout( modemtimeout->value() ); | ||
340 | return true; | ||
341 | |||
342 | } | ||
343 | |||
344 | ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, | ||
276 | const char *name) | 345 | const char *name) |
277 | : QWidget(parent, name), _ifaceppp(ifp) | 346 | : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) |
278 | { | 347 | { |
279 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 348 | QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
280 | 349 | ||
281 | 350 | ||
282 | waitfordt = new QCheckBox(i18n("&Wait for dial tone before dialing"), this); | 351 | waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); |
283 | waitfordt->setChecked(_ifaceppp->data()->waitForDialTone()); | 352 | waitfordt->setChecked(_pppdata->waitForDialTone()); |
284 | connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); | 353 | // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); |
285 | l1->addWidget(waitfordt); | 354 | l1->addWidget(waitfordt); |
286 | QWhatsThis::add(waitfordt, | 355 | QWhatsThis::add(waitfordt, |
287 | i18n("<p>Normally the modem waits for a dial tone\n" | 356 | tr("<p>Normally the modem waits for a dial tone\n" |
288 | "from your phone line, indicating that it can\n" | 357 | "from your phone line, indicating that it can\n" |
289 | "start to dial a number. If your modem does not\n" | 358 | "start to dial a number. If your modem does not\n" |
290 | "recognize this sound, or your local phone system\n" | 359 | "recognize this sound, or your local phone system\n" |
291 | "does not emit such a tone, uncheck this option\n" | 360 | "does not emit such a tone, uncheck this option\n" |
292 | "\n" | 361 | "\n" |
293 | "<b>Default:</b>: On")); | 362 | "<b>Default:</b>: On")); |
294 | 363 | ||
295 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); | 364 | QHBoxLayout *waitLayout = new QHBoxLayout( this ); |
296 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); | 365 | QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); |
297 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); | 366 | busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); |
298 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); | 367 | // busywait = new KIntNumInput(_pppdata->busyWait(), this); |
299 | // busywait->setLabel(i18n("B&usy wait:")); | 368 | // busywait->setLabel(tr("B&usy wait:")); |
300 | // busywait->setRange(0, 300, 5, true); | 369 | // busywait->setRange(0, 300, 5, true); |
301 | busywait->setSuffix(i18n(" sec")); | 370 | busywait->setSuffix(tr(" sec")); |
302 | connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); | 371 | // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); |
303 | waitLayout->addWidget(waitLabel); | 372 | waitLayout->addWidget(waitLabel); |
304 | waitLayout->addWidget(busywait); | 373 | waitLayout->addWidget(busywait); |
305 | l1->addLayout( waitLayout ); | 374 | l1->addLayout( waitLayout ); |
306 | 375 | ||
307 | QWhatsThis::add(busywait, | 376 | QWhatsThis::add(busywait, |
308 | i18n("Specifies the number of seconds to wait before\n" | 377 | tr("Specifies the number of seconds to wait before\n" |
309 | "redial if all dialed numbers are busy. This is\n" | 378 | "redial if all dialed numbers are busy. This is\n" |
310 | "necessary because some modems get stuck if the\n" | 379 | "necessary because some modems get stuck if the\n" |
311 | "same number is busy too often.\n" | 380 | "same number is busy too often.\n" |
312 | "\n" | 381 | "\n" |
313 | "The default is 0 seconds, you should not change\n" | 382 | "The default is 0 seconds, you should not change\n" |
314 | "this unless you need to.")); | 383 | "this unless you need to.")); |
315 | 384 | ||
316 | l1->addSpacing(10); | 385 | l1->addSpacing(10); |
317 | 386 | ||
318 | QHBoxLayout *hbl = new QHBoxLayout; | 387 | QHBoxLayout *hbl = new QHBoxLayout; |
319 | hbl->setSpacing(2);//KDialog::spacingHint()); | 388 | hbl->setSpacing(2);//KDialog::spacingHint()); |
320 | 389 | ||
321 | QLabel *volumeLabel = new QLabel(i18n("Modem &volume:"), this); | 390 | QLabel *volumeLabel = new QLabel(tr("Modem &volume:"), this); |
322 | hbl->addWidget(volumeLabel); | 391 | hbl->addWidget(volumeLabel); |
323 | volume = new QSlider(0, 2, 1, _ifaceppp->data()->volume(), | 392 | volume = new QSlider(0, 2, 1, _pppdata->volume(), |
324 | QSlider::Horizontal, this); | 393 | QSlider::Horizontal, this); |
325 | volumeLabel->setBuddy(volume); | 394 | volumeLabel->setBuddy(volume); |
326 | volume->setTickmarks(QSlider::Below); | 395 | volume->setTickmarks(QSlider::Below); |
327 | hbl->addWidget(volume); | 396 | hbl->addWidget(volume); |
328 | 397 | ||
329 | l1->addLayout(hbl); | 398 | l1->addLayout(hbl); |
330 | 399 | ||
331 | connect(volume, SIGNAL(valueChanged(int)), | 400 | // connect(volume, SIGNAL(valueChanged(int)), |
332 | this, SLOT(volumeChanged(int))); | 401 | // this, SLOT(volumeChanged(int))); |
333 | QString tmp = i18n("Most modems have a speaker which makes\n" | 402 | QString tmp = tr("Most modems have a speaker which makes\n" |
334 | "a lot of noise when dialing. Here you can\n" | 403 | "a lot of noise when dialing. Here you can\n" |
335 | "either turn this completely off or select a\n" | 404 | "either turn this completely off or select a\n" |
336 | "lower volume.\n" | 405 | "lower volume.\n" |
337 | "\n" | 406 | "\n" |
338 | "If this does not work for your modem,\n" | 407 | "If this does not work for your modem,\n" |
339 | "you must modify the modem volume command."); | 408 | "you must modify the modem volume command."); |
340 | 409 | ||
341 | QWhatsThis::add(volumeLabel,tmp); | 410 | QWhatsThis::add(volumeLabel,tmp); |
342 | QWhatsThis::add(volume, tmp); | 411 | QWhatsThis::add(volume, tmp); |
343 | 412 | ||
344 | l1->addSpacing(20); | 413 | l1->addSpacing(20); |
345 | 414 | ||
346 | #if 0 | 415 | #if 0 |
347 | chkbox1 = new QCheckBox(i18n("Modem asserts CD line"), this); | 416 | chkbox1 = new QCheckBox(tr("Modem asserts CD line"), this); |
348 | chkbox1->setChecked(_ifaceppp->data()->UseCDLine()); | 417 | chkbox1->setChecked(_pppdata->UseCDLine()); |
349 | connect(chkbox1,SIGNAL(toggled(bool)), | 418 | connect(chkbox1,SIGNAL(toggled(bool)), |
350 | this,SLOT(use_cdline_toggled(bool))); | 419 | this,SLOT(use_cdline_toggled(bool))); |
351 | l12->addWidget(chkbox1); | 420 | l12->addWidget(chkbox1); |
352 | l12->addStretch(1); | 421 | l12->addStretch(1); |
353 | l1->addStretch(1); | 422 | l1->addStretch(1); |
354 | QWhatsThis::add(chkbox1, | 423 | QWhatsThis::add(chkbox1, |
355 | i18n("This controls how <i>kppp</i> detects that the modem\n" | 424 | tr("This controls how <i>kppp</i> detects that the modem\n" |
356 | "is not responding. Unless you are having\n" | 425 | "is not responding. Unless you are having\n" |
357 | "problems with this, do not modify this setting.\n" | 426 | "problems with this, do not modify this setting.\n" |
358 | "\n" | 427 | "\n" |
359 | "<b>Default</b>: Off")); | 428 | "<b>Default</b>: Off")); |
360 | #endif | 429 | #endif |
361 | 430 | ||
362 | modemcmds = new QPushButton(i18n("Mod&em Commands..."), this); | 431 | modemcmds = new QPushButton(tr("Mod&em Commands..."), this); |
363 | QWhatsThis::add(modemcmds, | 432 | QWhatsThis::add(modemcmds, |
364 | i18n("Allows you to change the AT command for\n" | 433 | tr("Allows you to change the AT command for\n" |
365 | "your modem.")); | 434 | "your modem.")); |
366 | 435 | ||
367 | modeminfo_button = new QPushButton(i18n("&Query Modem..."), this); | 436 | modeminfo_button = new QPushButton(tr("&Query Modem..."), this); |
368 | QWhatsThis::add(modeminfo_button, | 437 | QWhatsThis::add(modeminfo_button, |
369 | i18n("Most modems support the ATI command set to\n" | 438 | tr("Most modems support the ATI command set to\n" |
370 | "find out vendor and revision of your modem.\n" | 439 | "find out vendor and revision of your modem.\n" |
371 | "\n" | 440 | "\n" |
372 | "Press this button to query your modem for\n" | 441 | "Press this button to query your modem for\n" |
373 | "this information. It can be useful to help\n" | 442 | "this information. It can be useful to help\n" |
374 | "you setup the modem")); | 443 | "you setup the modem")); |
375 | 444 | ||
376 | // terminal_button = new QPushButton(i18n("&Terminal..."), this); | 445 | // terminal_button = new QPushButton(tr("&Terminal..."), this); |
377 | // QWhatsThis::add(terminal_button, | 446 | // QWhatsThis::add(terminal_button, |
378 | // i18n("Opens the built-in terminal program. You\n" | 447 | // tr("Opens the built-in terminal program. You\n" |
379 | // "can use this if you want to play around\n" | 448 | // "can use this if you want to play around\n" |
380 | // "with your modem's AT command set")); | 449 | // "with your modem's AT command set")); |
381 | 450 | ||
382 | QHBoxLayout *hbox = new QHBoxLayout(); | 451 | QHBoxLayout *hbox = new QHBoxLayout(); |
383 | l1->addLayout(hbox); | 452 | l1->addLayout(hbox); |
384 | hbox->addStretch(1); | 453 | hbox->addStretch(1); |
385 | QVBoxLayout *vbox = new QVBoxLayout(); | 454 | QVBoxLayout *vbox = new QVBoxLayout(); |
386 | hbox->addLayout(vbox); | 455 | hbox->addLayout(vbox); |
387 | 456 | ||
388 | vbox->addWidget(modemcmds); | 457 | vbox->addWidget(modemcmds); |
389 | vbox->addWidget(modeminfo_button); | 458 | vbox->addWidget(modeminfo_button); |
390 | // vbox->addWidget(terminal_button); | 459 | // vbox->addWidget(terminal_button); |
391 | 460 | ||
392 | hbox->addStretch(1); | 461 | hbox->addStretch(1); |
393 | l1->addStretch(1); | 462 | l1->addStretch(1); |
394 | 463 | ||
395 | connect(modemcmds, SIGNAL(clicked()), | 464 | connect(modemcmds, SIGNAL(clicked()), |
396 | SLOT(modemcmdsbutton())); | 465 | SLOT(modemcmdsbutton())); |
397 | connect(modeminfo_button, SIGNAL(clicked()), | 466 | connect(modeminfo_button, SIGNAL(clicked()), |
398 | SLOT(query_modem())); | 467 | SLOT(query_modem())); |
399 | // connect(terminal_button, SIGNAL(clicked()), | 468 | // connect(terminal_button, SIGNAL(clicked()), |
400 | // SLOT(terminal())); | 469 | // SLOT(terminal())); |
401 | } | 470 | } |
402 | 471 | ||
403 | 472 | ||
404 | void ModemWidget2::modemcmdsbutton() { | 473 | void ModemWidget2::modemcmdsbutton() { |
405 | ModemCommands mc(_ifaceppp->data(), this); | 474 | ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); |
406 | mc.showMaximized(); | 475 | mc.showMaximized(); |
407 | mc.exec(); | 476 | mc.exec(); |
408 | } | 477 | } |
409 | 478 | ||
410 | 479 | ||
411 | void ModemWidget2::query_modem() { | 480 | void ModemWidget2::query_modem() { |
412 | ModemTransfer mt(_ifaceppp->modem(), this); | 481 | ModemTransfer mt(_ifaceppp->modem(), this); |
413 | mt.exec(); | 482 | mt.exec(); |
414 | } | 483 | } |
415 | 484 | ||
416 | 485 | ||
417 | // void ModemWidget2::terminal() { | 486 | // void ModemWidget2::terminal() { |
418 | // MiniTerm terminal(NULL,NULL); | 487 | // MiniTerm terminal(NULL,NULL); |
419 | // terminal.exec(); | 488 | // terminal.exec(); |
420 | // } | 489 | // } |
421 | 490 | ||
422 | 491 | ||
423 | #if 0 | 492 | // #if 0 |
424 | void ModemWidget2::use_cdline_toggled(bool on) { | 493 | // void ModemWidget2::use_cdline_toggled(bool on) { |
425 | _ifaceppp->data()->setUseCDLine(on); | 494 | // _pppdata->setUseCDLine(on); |
426 | } | 495 | // } |
427 | #endif | 496 | // #endif |
428 | 497 | ||
429 | void ModemWidget2::waitfordtchanged(bool b) { | 498 | // void ModemWidget2::waitfordtchanged(bool b) { |
430 | _ifaceppp->data()->setWaitForDialTone((int)b); | 499 | // _pppdata->setWaitForDialTone((int)b); |
431 | } | 500 | // } |
432 | 501 | ||
433 | void ModemWidget2::busywaitchanged(int n) { | 502 | // void ModemWidget2::busywaitchanged(int n) { |
434 | _ifaceppp->data()->setbusyWait(n); | 503 | // _pppdata->setbusyWait(n); |
435 | } | 504 | // } |
436 | 505 | ||
437 | 506 | ||
438 | void ModemWidget2::volumeChanged(int v) { | 507 | // void ModemWidget2::volumeChanged(int v) { |
439 | _ifaceppp->data()->setVolume(v); | 508 | // _pppdata->setVolume(v); |
509 | // } | ||
510 | |||
511 | bool ModemWidget2::save() | ||
512 | { | ||
513 | _pppdata->setWaitForDialTone(waitfordt->isChecked()); | ||
514 | _pppdata->setbusyWait(busywait->value()); | ||
515 | _pppdata->setVolume(volume->value()); | ||
516 | return true; | ||
440 | } | 517 | } |
441 | 518 | ||
diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h index 3e59b46..f43f241 100644 --- a/noncore/settings/networksettings/ppp/general.h +++ b/noncore/settings/networksettings/ppp/general.h | |||
@@ -1,100 +1,108 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Library General Public | 12 | * modify it under the terms of the GNU Library General Public |
13 | * License as published by the Free Software Foundation; either | 13 | * License as published by the Free Software Foundation; either |
14 | * version 2 of the License, or (at your option) any later version. | 14 | * version 2 of the License, or (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #ifndef _GENERAL_H_ | 26 | #ifndef _GENERAL_H_ |
27 | #define _GENERAL_H_ | 27 | #define _GENERAL_H_ |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | 30 | ||
31 | class QSlider; | 31 | class QSlider; |
32 | class QSpinBox; | 32 | class QSpinBox; |
33 | class QCombobox; | 33 | class QCombobox; |
34 | class QLabel; | 34 | class QLabel; |
35 | class QCheckBox; | 35 | class QCheckBox; |
36 | class QComboBox; | 36 | class QComboBox; |
37 | class PPPData; | 37 | class PPPData; |
38 | class InterfacePPP; | 38 | class InterfacePPP; |
39 | class QLineEdit; | ||
39 | 40 | ||
40 | class ModemWidget : public QWidget { | 41 | class ModemWidget : public QWidget { |
41 | Q_OBJECT | 42 | Q_OBJECT |
42 | public: | 43 | public: |
43 | ModemWidget( InterfacePPP*, QWidget *parent=0, const char *name=0 ); | 44 | ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 ); |
45 | ~ModemWidget(); | ||
44 | 46 | ||
45 | private slots: | 47 | bool save(); |
46 | void setmodemdc(int); | 48 | |
47 | void setflowcontrol(int); | 49 | /* private slots: */ |
48 | void modemtimeoutchanged(int); | 50 | /* void setmodemdc(int); */ |
49 | void modemlockfilechanged(bool); | 51 | /* void setmodemdc(const QString &); */ |
50 | void setenter(int); | 52 | /* void setflowcontrol(int); */ |
51 | void speed_selection(int); | 53 | /* void modemtimeoutchanged(int); */ |
54 | /* void modemlockfilechanged(bool); */ | ||
55 | /* void setenter(int); */ | ||
56 | /* void speed_selection(int); */ | ||
52 | 57 | ||
53 | private: | 58 | private: |
54 | QComboBox *enter; | 59 | QComboBox *enter; |
55 | /* QLabel *label1; */ | 60 | /* QLabel *label1; */ |
56 | /* QLabel *label2; */ | 61 | /* QLabel *label2; */ |
57 | /* QLabel *labeltmp; */ | 62 | /* QLabel *labeltmp; */ |
58 | /* QLabel *labelenter; */ | 63 | /* QLabel *labelenter; */ |
64 | QLineEdit *modemname; | ||
59 | QComboBox *modemdevice; | 65 | QComboBox *modemdevice; |
60 | QComboBox *flowcontrol; | 66 | QComboBox *flowcontrol; |
61 | 67 | ||
62 | QComboBox *baud_c; | 68 | QComboBox *baud_c; |
63 | QLabel *baud_label; | 69 | QLabel *baud_label; |
64 | 70 | ||
65 | QSpinBox *modemtimeout; | 71 | QSpinBox *modemtimeout; |
66 | QCheckBox *modemlockfile; | 72 | QCheckBox *modemlockfile; |
67 | InterfacePPP *_ifaceppp; | 73 | PPPData *_pppdata; |
68 | }; | 74 | }; |
69 | 75 | ||
70 | 76 | ||
71 | class ModemWidget2 : public QWidget { | 77 | class ModemWidget2 : public QWidget { |
72 | Q_OBJECT | 78 | Q_OBJECT |
73 | public: | 79 | public: |
74 | ModemWidget2( InterfacePPP*, QWidget *parent=0, const char *name=0 ); | 80 | ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 ); |
81 | bool save(); | ||
75 | 82 | ||
76 | private slots: | 83 | private slots: |
77 | void waitfordtchanged(bool); | 84 | /* void waitfordtchanged(bool); */ |
78 | void busywaitchanged(int); | 85 | /* void busywaitchanged(int); */ |
79 | // void use_cdline_toggled(bool); | 86 | // void use_cdline_toggled(bool); |
80 | void modemcmdsbutton(); | 87 | void modemcmdsbutton(); |
81 | // void terminal(); | 88 | // void terminal(); |
82 | void query_modem(); | 89 | void query_modem(); |
83 | void volumeChanged(int); | 90 | // void volumeChanged(int); |
84 | 91 | ||
85 | private: | 92 | private: |
86 | QLabel *labeltmp; | 93 | QLabel *labeltmp; |
87 | QPushButton *modemcmds; | 94 | QPushButton *modemcmds; |
88 | QPushButton *modeminfo_button; | 95 | QPushButton *modeminfo_button; |
89 | // QPushButton *terminal_button; | 96 | // QPushButton *terminal_button; |
90 | // QFrame *fline; | 97 | // QFrame *fline; |
91 | QCheckBox *waitfordt; | 98 | QCheckBox *waitfordt; |
92 | QSpinBox *busywait; | 99 | QSpinBox *busywait; |
93 | QCheckBox *chkbox1; | 100 | QCheckBox *chkbox1; |
94 | QSlider *volume; | 101 | QSlider *volume; |
102 | PPPData *_pppdata; | ||
95 | InterfacePPP *_ifaceppp; | 103 | InterfacePPP *_ifaceppp; |
96 | }; | 104 | }; |
97 | 105 | ||
98 | #endif | 106 | #endif |
99 | 107 | ||
100 | 108 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index 553daa2..6b158b9 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp | |||
@@ -1,37 +1,41 @@ | |||
1 | #include "interfaceinformationppp.h" | 1 | #include "interfaceinformationppp.h" |
2 | 2 | ||
3 | |||
4 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
5 | #include <qlabel.h> | 4 | #include <qlabel.h> |
6 | //#include <qgroupbox.h> | ||
7 | #include <qmessagebox.h> | 5 | #include <qmessagebox.h> |
8 | #include <qabstractlayout.h> | 6 | #include <qabstractlayout.h> |
9 | 7 | ||
10 | #include "connect.h" | 8 | #include "connect.h" |
11 | #include "conwindow.h" | 9 | #include "conwindow.h" |
12 | 10 | ||
13 | #ifdef QWS | 11 | #ifdef QWS |
14 | #else | 12 | #else |
15 | #define showMaximized show | 13 | #define showMaximized show |
16 | #endif | 14 | #endif |
17 | 15 | ||
18 | /** | 16 | /** |
19 | * Constructor for the InterfaceInformationImp class. This class pretty much | 17 | * Constructor for the InterfaceInformationImp class. This class pretty much |
20 | * just display's information about the interface that is passed to it. | 18 | * just display's information about the interface that is passed to it. |
21 | */ | 19 | */ |
22 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) | 20 | InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f) |
23 | :InterfaceInformationImp(parent, name, i, f) | 21 | :InterfaceInformationImp(parent, name, i, Qt::WStyle_ContextHelp) |
24 | { | 22 | { |
25 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP"); | 23 | qDebug("InterfaceInformationPPP::InterfaceInformationPPP %s", name); |
26 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); | 24 | con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); |
27 | con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, | 25 | con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, |
28 | QSizePolicy::Fixed) ); | 26 | QSizePolicy::Fixed) ); |
29 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); | 27 | |
30 | InterfaceInformationLayout->addItem( spacer, 7, 0 ); | 28 | macAddressLabel->hide(); |
31 | InterfaceInformationLayout->addMultiCellWidget( con, 8, 8, 0, 1 ); | 29 | subnetMaskLabel->hide(); |
32 | // InterfaceInformationLayout->addWidget( con, 7, 0 ); | 30 | broadcastLabel->hide(); |
31 | TextLabel23->hide(); | ||
32 | TextLabel21->hide(); | ||
33 | TextLabel24->hide(); | ||
34 | |||
35 | InterfaceInformationLayout->addWidget( con, 1, 0 ); | ||
33 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); | 36 | connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); |
37 | connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); | ||
34 | } | 38 | } |
35 | 39 | ||
36 | 40 | ||
37 | 41 | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index 9ec30bc..f443f3c 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp | |||
@@ -1,142 +1,174 @@ | |||
1 | 1 | ||
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #define i18n QObject::tr | 3 | #include <qlayout.h> |
4 | #include <qlineedit.h> | ||
5 | #include <qlabel.h> | ||
4 | 6 | ||
5 | #include "auth.h" | 7 | #include "auth.h" |
6 | #include "interfaceppp.h" | 8 | #include "interfaceppp.h" |
7 | #include "modem.h" | 9 | #include "modem.h" |
8 | #include "pppdata.h" | 10 | #include "pppdata.h" |
9 | 11 | ||
10 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) | 12 | InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) |
11 | : Interface(parent, name, status), | 13 | : Interface(parent, name, status), |
12 | _modemPtr(0), | 14 | _modemPtr(0), |
13 | _dataPtr(0) | 15 | _dataPtr(0) |
14 | { | 16 | { |
15 | qDebug("InterfacePPP::InterfacePPP("); | 17 | qDebug("InterfacePPP::InterfacePPP("); |
16 | } | 18 | } |
17 | 19 | ||
18 | PPPData* InterfacePPP::data() | 20 | PPPData* InterfacePPP::data()const |
19 | { | 21 | { |
20 | if (!_dataPtr){ | 22 | if (!_dataPtr){ |
21 | qDebug("creating new Data obj"); | 23 | qDebug("creating new Data obj"); |
22 | _dataPtr = new PPPData(); | 24 | _dataPtr = new PPPData(); |
23 | _dataPtr->setModemDevice( getInterfaceName() ); | 25 | _dataPtr->setDevice( getInterfaceName() ); |
24 | _dataPtr->setAccount( getHardwareName() ); | 26 | _dataPtr->setAccount( getHardwareName() ); |
25 | } | 27 | } |
26 | return _dataPtr; | 28 | return _dataPtr; |
27 | } | 29 | } |
28 | 30 | ||
29 | Modem* InterfacePPP::modem() | 31 | Modem* InterfacePPP::modem()const |
30 | { | 32 | { |
31 | if (!_modemPtr){ | 33 | if (!_modemPtr){ |
32 | qDebug("creating new modem obj"); | 34 | qDebug("creating new modem obj"); |
33 | _modemPtr = new Modem( data() ); | 35 | _modemPtr = new Modem( data() ); |
34 | } | 36 | } |
35 | return _modemPtr; | 37 | return _modemPtr; |
36 | } | 38 | } |
37 | 39 | ||
38 | bool InterfacePPP::refresh() | 40 | bool InterfacePPP::refresh() |
39 | { | 41 | { |
40 | qDebug("InterfacePPP::refresh()"); | 42 | qDebug("InterfacePPP::refresh()"); |
41 | updateInterface(this); | 43 | QString old = getInterfaceName(); |
42 | QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-("); | 44 | setInterfaceName( modem()->pppDevice() ); |
43 | return false; | 45 | |
46 | (void)Interface::refresh(); | ||
47 | |||
48 | setInterfaceName( old ); | ||
49 | emit updateInterface(this); | ||
50 | |||
51 | return true; | ||
44 | } | 52 | } |
45 | 53 | ||
46 | void InterfacePPP::start() | 54 | void InterfacePPP::start() |
47 | { | 55 | { |
48 | qDebug("InterfacePPP::start"); | 56 | qDebug("InterfacePPP::start"); |
49 | // should work... | ||
50 | // if (data()->password().isEmpty() ){ | ||
51 | // //FIXME: ask for password | ||
52 | // qDebug("using dummy password"); | ||
53 | // QMessageBox::critical( 0, "no password", "you should be prompted for a password, but you are not! ;-)"); | ||
54 | // } | ||
55 | 57 | ||
58 | if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { | ||
59 | |||
60 | QDialog mb( 0, "Dialog", true ); | ||
61 | mb.setCaption( tr( "No password" ) ); | ||
62 | QVBoxLayout layout( &mb ); | ||
63 | QLabel text ( &mb ); | ||
64 | text.setText( tr("Username defined but no password\n Please enter a password") ); | ||
65 | QLineEdit lineedit( &mb ); | ||
66 | lineedit.setEchoMode( QLineEdit::Password ); | ||
67 | layout.addWidget( &text ); | ||
68 | layout.addWidget( &lineedit ); | ||
69 | if ( mb.exec() == QDialog::Accepted ) { | ||
70 | data()->setPassword( lineedit.text() ); | ||
71 | } | ||
72 | } | ||
56 | 73 | ||
57 | QFileInfo info(pppdPath()); | 74 | QFileInfo info(pppdPath()); |
58 | 75 | ||
59 | if(!info.exists()){ | 76 | if(!info.exists()){ |
60 | QMessageBox::warning(0, tr("Error"), | 77 | QMessageBox::warning(0, tr("Error"), |
61 | i18n("<qt>Cannot find the PPP daemon!<br>" | 78 | QObject::tr("<qt>Cannot find the PPP daemon!<br>" |
62 | "Make sure that pppd is installed and " | 79 | "Make sure that pppd is installed and " |
63 | "that you have entered the correct path.</qt>")); | 80 | "that you have entered the correct path.</qt>")); |
64 | return; | 81 | return; |
65 | } | 82 | } |
66 | //#if 0 | 83 | //#if 0 |
67 | if(!info.isExecutable()){ | 84 | if(!info.isExecutable()){ |
68 | 85 | ||
69 | QString string; | 86 | QString string; |
70 | string = i18n( "<qt>Cannot execute:<br> %1<br>" | 87 | string = QObject::tr( "<qt>Cannot execute:<br> %1<br>" |
71 | "Please make sure that you have given " | 88 | "Please make sure that you have given " |
72 | "setuid permission and that " | 89 | "setuid permission and that " |
73 | "pppd is executable.<br>").arg(pppdPath()); | 90 | "pppd is executable.<br>").arg(pppdPath()); |
74 | QMessageBox::warning(0, tr("Error"), string); | 91 | QMessageBox::warning(0, tr("Error"), string); |
75 | return; | 92 | return; |
76 | 93 | ||
77 | } | 94 | } |
78 | //#endif | 95 | //#endif |
79 | 96 | ||
80 | QFileInfo info2(data()->modemDevice()); | 97 | QFileInfo info2(data()->modemDevice()); |
81 | 98 | ||
82 | if(!info2.exists()){ | 99 | if(!info2.exists()){ |
83 | QString string; | 100 | QString string; |
84 | string = i18n( "<qt>Cannot find:<br> %1<br>" | 101 | string = QObject::tr( "<qt>Cannot find:<br> %1<br>" |
85 | "Please make sure you have setup " | 102 | "Please make sure you have setup " |
86 | "your modem device properly " | 103 | "your modem device properly " |
87 | "and/or adjust the location of the modem device on " | 104 | "and/or adjust the location of the modem device on " |
88 | "the modem tab of " | 105 | "the modem tab of " |
89 | "the setup dialog.</qt>").arg(data()->modemDevice()); | 106 | "the setup dialog.</qt>").arg(data()->modemDevice()); |
90 | QMessageBox::warning(0, tr("Error"), string); | 107 | QMessageBox::warning(0, tr("Error"), string); |
91 | return; | 108 | return; |
92 | } | 109 | } |
93 | 110 | ||
94 | // if this is a PAP or CHAP account, ensure that username is | 111 | // if this is a PAP or CHAP account, ensure that username is |
95 | // supplied | 112 | // supplied |
96 | if(data()->authMethod() == AUTH_PAP || | 113 | if(data()->authMethod() == AUTH_PAP || |
97 | data()->authMethod() == AUTH_CHAP || | 114 | data()->authMethod() == AUTH_CHAP || |
98 | data()->authMethod() == AUTH_PAPCHAP ) { | 115 | data()->authMethod() == AUTH_PAPCHAP ) { |
99 | if(false){ //FIXME: ID_Edit->text().isEmpty()) { | 116 | if(false){ //FIXME: ID_Edit->text().isEmpty()) { |
100 | QMessageBox::warning(0,tr("Error"), | 117 | QMessageBox::warning(0,tr("Error"), |
101 | i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); | 118 | QObject::tr("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>")); |
102 | // FIXME: return; | 119 | // FIXME: return; |
103 | } else { | 120 | } else { |
104 | if(!modem()->setSecret(data()->authMethod(), | 121 | if(!modem()->setSecret(data()->authMethod(), |
105 | PPPData::encodeWord(data()->storedUsername()), | 122 | PPPData::encodeWord(data()->storedUsername()), |
106 | PPPData::encodeWord(data()->password())) | 123 | PPPData::encodeWord(data()->password())) |
107 | ) { | 124 | ) { |
108 | QString s; | 125 | QString s; |
109 | s = i18n("<qt>Cannot create PAP/CHAP authentication<br>" | 126 | s = QObject::tr("<qt>Cannot create PAP/CHAP authentication<br>" |
110 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); | 127 | "file \"%1\"</qt>").arg(PAP_AUTH_FILE); |
111 | QMessageBox::warning(0, tr("Error"), s); | 128 | QMessageBox::warning(0, tr("Error"), s); |
112 | return; | 129 | return; |
113 | } | 130 | } |
114 | } | 131 | } |
115 | } | 132 | } |
116 | 133 | ||
117 | if (data()->phonenumber().isEmpty()) { | 134 | if (data()->phonenumber().isEmpty()) { |
118 | QString s = i18n("You must specify a telephone number!"); | 135 | QString s = QObject::tr("You must specify a telephone number!"); |
119 | QMessageBox::warning(0, tr("Error"), s); | 136 | QMessageBox::warning(0, tr("Error"), s); |
120 | return; | 137 | return; |
121 | } | 138 | } |
122 | 139 | ||
123 | // SEGFAULTS: | 140 | // SEGFAULTS: |
124 | // setStatus( true ); | 141 | // setStatus( true ); |
125 | // emit updateInterface((Interface*) this); | 142 | // emit updateInterface((Interface*) this); |
126 | 143 | ||
127 | emit begin_connect(); | 144 | emit begin_connect(); |
128 | 145 | ||
129 | qDebug("InterfacePPP::start END"); | 146 | qDebug("InterfacePPP::start END"); |
130 | } | 147 | } |
131 | 148 | ||
132 | void InterfacePPP::stop() | 149 | void InterfacePPP::stop() |
133 | { | 150 | { |
134 | qDebug("InterfacePPP::stop"); | 151 | qDebug("InterfacePPP::stop"); |
152 | // emit hangup_now(); | ||
153 | status = false; // not connected | ||
154 | setStatus( false ); | ||
155 | emit hangup_now(); | ||
156 | refresh(); | ||
135 | 157 | ||
136 | } | 158 | } |
137 | 159 | ||
138 | void InterfacePPP::save() | 160 | void InterfacePPP::save() |
139 | { | 161 | { |
140 | data()->save(); | 162 | data()->save(); |
141 | emit updateInterface((Interface*) this); | 163 | emit updateInterface((Interface*) this); |
142 | } | 164 | } |
165 | QString InterfacePPP::pppDev()const { | ||
166 | return modem()->pppDevice(); | ||
167 | } | ||
168 | pid_t InterfacePPP::pppPID()const{ | ||
169 | return modem()->pppPID(); | ||
170 | } | ||
171 | void InterfacePPP::setPPPDpid( pid_t pid) { | ||
172 | setStatus( true ); | ||
173 | modem()->setPPPDPid( pid ); | ||
174 | } | ||
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h index 6eb6a69..39495c2 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.h +++ b/noncore/settings/networksettings/ppp/interfaceppp.h | |||
@@ -1,34 +1,40 @@ | |||
1 | #ifndef INTERFACEPPP_H | 1 | #ifndef INTERFACEPPP_H |
2 | #define INTERFACEPPP_H | 2 | #define INTERFACEPPP_H |
3 | 3 | ||
4 | #include <sys/types.h> | ||
5 | |||
4 | #include "interface.h" | 6 | #include "interface.h" |
5 | 7 | ||
6 | class PPPData; | 8 | class PPPData; |
7 | class Modem; | 9 | class Modem; |
8 | 10 | ||
9 | class InterfacePPP : public Interface | 11 | class InterfacePPP : public Interface |
10 | { | 12 | { |
11 | Q_OBJECT | 13 | Q_OBJECT |
12 | 14 | ||
13 | public: | 15 | public: |
14 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); | 16 | InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false); |
15 | 17 | ||
16 | PPPData* data(); | 18 | PPPData* data()const; |
17 | Modem* modem(); | 19 | Modem* modem()const; |
20 | QString pppDev()const; // returns the ppp device.... /dev/ppp0... | ||
21 | pid_t pppPID()const; | ||
18 | 22 | ||
19 | signals: | 23 | signals: |
20 | void begin_connect(); | 24 | void begin_connect(); |
25 | void hangup_now(); | ||
21 | 26 | ||
22 | public slots: | 27 | public slots: |
23 | virtual bool refresh(); | 28 | virtual bool refresh(); |
24 | virtual void start(); | 29 | virtual void start(); |
25 | virtual void stop(); | 30 | virtual void stop(); |
26 | void save(); | 31 | void save(); |
32 | void setPPPDpid( pid_t ); // sets the pppd pid for modem... | ||
27 | 33 | ||
28 | private: | 34 | private: |
29 | Modem *_modemPtr; | 35 | mutable Modem *_modemPtr; |
30 | PPPData *_dataPtr; | 36 | mutable PPPData *_dataPtr; |
31 | }; | 37 | }; |
32 | 38 | ||
33 | 39 | ||
34 | #endif | 40 | #endif |
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index 7b5c74d..e466358 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp | |||
@@ -1,385 +1,374 @@ | |||
1 | /* | 1 | /* |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> | 10 | * Copyright (C) 1998-2002 Harri Porten <porten@kde.org> |
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 "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 <kcmdlineargs.h> | ||
46 | //#include <kconfig.h> | ||
47 | //#include <kdebug.h> | ||
48 | #define i18n QObject::tr | ||
49 | //#include <kiconloader.h> // For BarIcon | ||
50 | //#include <klocale.h> | ||
51 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
52 | // #include <kseparator.h> | ||
53 | // #include <kstandarddirs.h> | ||
54 | // #include <kwin.h> | ||
55 | // #include <khelpmenu.h> | ||
56 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
57 | //#include <kguiitem.h> | ||
58 | 47 | ||
59 | #include <stdlib.h> | 48 | #include <stdlib.h> |
60 | #include <errno.h> | 49 | #include <errno.h> |
61 | #include <signal.h> | 50 | #include <signal.h> |
62 | 51 | ||
63 | #include "runtests.h" | 52 | #include "runtests.h" |
64 | 53 | ||
65 | //#include "main.h" | 54 | //#include "main.h" |
66 | #include "auth.h" | 55 | #include "auth.h" |
67 | #include "modem.h" | 56 | #include "modem.h" |
68 | //#include "ppplog.h" | 57 | //#include "ppplog.h" |
69 | //#include "opener.h" | 58 | //#include "opener.h" |
70 | //#include "requester.h" | 59 | //#include "requester.h" |
71 | //#include "pppstats.h" | 60 | //#include "pppstats.h" |
72 | #include "pppdata.h" | 61 | #include "pppdata.h" |
73 | #include "general.h" | 62 | #include "general.h" |
74 | #include "interface.h" | 63 | #include "interface.h" |
75 | 64 | ||
76 | #define execute_command system | 65 | #define execute_command system |
77 | 66 | ||
78 | KPPPWidget *p_kppp = 0; | 67 | KPPPWidget *p_kppp = 0; |
79 | 68 | ||
80 | 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 ) |
81 | : QDialog(parent, name, modal, fl), _pppdata(pd) | 70 | : QDialog(parent, name, modal, Qt::WStyle_ContextHelp ), _pppdata(pd) |
82 | { | 71 | { |
83 | // tabWindow = 0; | 72 | // tabWindow = 0; |
84 | p_kppp = this; | 73 | p_kppp = this; |
85 | // before doing anything else, run a few tests | 74 | // before doing anything else, run a few tests |
86 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) | 75 | if (!_pppdata->setModemDevice( i->getInterfaceName() )) |
87 | _pppdata->setModemDevice("/dev/modem"); | 76 | _pppdata->setModemDevice("/dev/modem"); |
88 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 77 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
89 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); | 78 | qDebug(" interface->getHardwareName >%s<", i->getHardwareName().latin1()); |
90 | if (!_pppdata->setAccount( i->getHardwareName() )) | 79 | if (!_pppdata->setAccount( i->getHardwareName() )) |
91 | _pppdata->setAccount( 0 ); | 80 | _pppdata->setAccount( 0 ); |
92 | 81 | ||
93 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); | 82 | qDebug(" _pppdata->accname >%s<",_pppdata->accname().latin1()); |
94 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); | 83 | qDebug(" _pppdata->currentAccountID() >%i<",_pppdata->currentAccountID()); |
95 | 84 | ||
96 | int result = runTests(); | 85 | int result = runTests(); |
97 | if(result == TEST_CRITICAL) | 86 | if(result == TEST_CRITICAL) |
98 | exit(4); | 87 | exit(4); |
99 | 88 | ||
100 | // installEventFilter(this); | 89 | // installEventFilter(this); |
101 | 90 | ||
102 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 91 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
103 | 92 | ||
104 | QGridLayout *l1 = new QGridLayout(3, 4); | 93 | QGridLayout *l1 = new QGridLayout(3, 4); |
105 | tl->addLayout(l1); | 94 | tl->addLayout(l1); |
106 | l1->addColSpacing(0, 10); | 95 | l1->addColSpacing(0, 10); |
107 | l1->addColSpacing(3, 10); | 96 | l1->addColSpacing(3, 10); |
108 | l1->setColStretch(1, 3); | 97 | l1->setColStretch(1, 3); |
109 | l1->setColStretch(2, 4); | 98 | l1->setColStretch(2, 4); |
110 | 99 | ||
111 | label1 = new QLabel(i18n("C&onnect to: "), this); | 100 | label1 = new QLabel(QObject::tr("C&onnect to: "), this); |
112 | l1->addWidget(label1, 0, 1); | 101 | l1->addWidget(label1, 0, 1); |
113 | 102 | ||
114 | connectto_c = new QComboBox(false, this); | 103 | connectto_c = new QComboBox(false, this); |
115 | label1->setBuddy(connectto_c); | 104 | label1->setBuddy(connectto_c); |
116 | 105 | ||
117 | connect(connectto_c, SIGNAL(activated(int)), | 106 | connect(connectto_c, SIGNAL(activated(int)), |
118 | SLOT(newdefaultaccount(int))); | 107 | SLOT(newdefaultaccount(int))); |
119 | l1->addWidget(connectto_c, 0, 2); | 108 | l1->addWidget(connectto_c, 0, 2); |
120 | 109 | ||
121 | ID_Label = new QLabel(i18n("&Login ID:"), this); | 110 | ID_Label = new QLabel(QObject::tr("&Login ID:"), this); |
122 | l1->addWidget(ID_Label, 1, 1); | 111 | l1->addWidget(ID_Label, 1, 1); |
123 | 112 | ||
124 | // the entry line for usernames | 113 | // the entry line for usernames |
125 | ID_Edit = new QLineEdit(this); | 114 | ID_Edit = new QLineEdit(this); |
126 | ID_Label->setBuddy(ID_Edit); | 115 | ID_Label->setBuddy(ID_Edit); |
127 | l1->addWidget(ID_Edit, 1, 2); | 116 | l1->addWidget(ID_Edit, 1, 2); |
128 | connect(ID_Edit, SIGNAL(returnPressed()), | 117 | connect(ID_Edit, SIGNAL(returnPressed()), |
129 | this, SLOT(enterPressedInID())); | 118 | this, SLOT(enterPressedInID())); |
130 | QString tmp = i18n("<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" |
131 | "ISP. This is especially important for PAP\n" | 120 | "ISP. This is especially important for PAP\n" |
132 | "and CHAP. You may omit this when you use\n" | 121 | "and CHAP. You may omit this when you use\n" |
133 | "terminal-based or script-based authentication.\n" | 122 | "terminal-based or script-based authentication.\n" |
134 | "\n" | 123 | "\n" |
135 | "<b>Important</b>: case is important here:\n" | 124 | "<b>Important</b>: case is important here:\n" |
136 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); | 125 | "<i>myusername</i> is not the same as <i>MyUserName</i>!"); |
137 | 126 | ||
138 | QWhatsThis::add(ID_Label,tmp); | 127 | QWhatsThis::add(ID_Label,tmp); |
139 | QWhatsThis::add(ID_Edit,tmp); | 128 | QWhatsThis::add(ID_Edit,tmp); |
140 | 129 | ||
141 | PW_Label = new QLabel(i18n("&Password:"), this); | 130 | PW_Label = new QLabel(QObject::tr("&Password:"), this); |
142 | l1->addWidget(PW_Label, 2, 1); | 131 | l1->addWidget(PW_Label, 2, 1); |
143 | 132 | ||
144 | PW_Edit= new QLineEdit(this); | 133 | PW_Edit= new QLineEdit(this); |
145 | PW_Label->setBuddy(PW_Edit); | 134 | PW_Label->setBuddy(PW_Edit); |
146 | PW_Edit->setEchoMode(QLineEdit::Password); | 135 | PW_Edit->setEchoMode(QLineEdit::Password); |
147 | l1->addWidget(PW_Edit, 2, 2); | 136 | l1->addWidget(PW_Edit, 2, 2); |
148 | connect(PW_Edit, SIGNAL(returnPressed()), | 137 | connect(PW_Edit, SIGNAL(returnPressed()), |
149 | this, SLOT(enterPressedInPW())); | 138 | this, SLOT(enterPressedInPW())); |
150 | 139 | ||
151 | tmp = i18n("<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" |
152 | "ISP. This is especially important for PAP\n" | 141 | "ISP. This is especially important for PAP\n" |
153 | "and CHAP. You may omit this when you use\n" | 142 | "and CHAP. You may omit this when you use\n" |
154 | "terminal-based or script-based authentication.\n" | 143 | "terminal-based or script-based authentication.\n" |
155 | "\n" | 144 | "\n" |
156 | "<b>Important</b>: case is important here:\n" | 145 | "<b>Important</b>: case is important here:\n" |
157 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); | 146 | "<i>mypassword</i> is not the same as <i>MyPassword</i>!"); |
158 | 147 | ||
159 | QWhatsThis::add(PW_Label,tmp); | 148 | QWhatsThis::add(PW_Label,tmp); |
160 | QWhatsThis::add(PW_Edit,tmp); | 149 | QWhatsThis::add(PW_Edit,tmp); |
161 | 150 | ||
162 | QHBoxLayout *l3 = new QHBoxLayout; | 151 | QHBoxLayout *l3 = new QHBoxLayout; |
163 | tl->addSpacing(5); | 152 | tl->addSpacing(5); |
164 | tl->addLayout(l3); | 153 | tl->addLayout(l3); |
165 | tl->addSpacing(5); | 154 | tl->addSpacing(5); |
166 | l3->addSpacing(10); | 155 | l3->addSpacing(10); |
167 | log = new QCheckBox(i18n("Show lo&g window"), this); | 156 | log = new QCheckBox(QObject::tr("Show lo&g window"), this); |
168 | connect(log, SIGNAL(toggled(bool)), | 157 | connect(log, SIGNAL(toggled(bool)), |
169 | this, SLOT(log_window_toggled(bool))); | 158 | this, SLOT(log_window_toggled(bool))); |
170 | log->setChecked(_pppdata->get_show_log_window()); | 159 | log->setChecked(_pppdata->get_show_log_window()); |
171 | l3->addWidget(log); | 160 | l3->addWidget(log); |
172 | 161 | ||
173 | QWhatsThis::add(log, | 162 | QWhatsThis::add(log, |
174 | i18n("<p>This controls whether a log window is shown.\n" | 163 | QObject::tr("<p>This controls whether a log window is shown.\n" |
175 | "A log window shows the communication between\n" | 164 | "A log window shows the communication between\n" |
176 | "<i>kppp</i> and your modem. This will help you\n" | 165 | "<i>kppp</i> and your modem. This will help you\n" |
177 | "in tracking down problems.\n" | 166 | "in tracking down problems.\n" |
178 | "\n" | 167 | "\n" |
179 | "Turn it off if <i>kppp</i> routinely connects without\n" | 168 | "Turn it off if <i>kppp</i> routinely connects without\n" |
180 | "problems")); | 169 | "problems")); |
181 | 170 | ||
182 | // fline = new QSeparator( KSeparator::HLine, this); | 171 | // fline = new QSeparator( KSeparator::HLine, this); |
183 | // tl->addWidget(fline); | 172 | // tl->addWidget(fline); |
184 | 173 | ||
185 | QHBoxLayout *l2 = new QHBoxLayout(this); | 174 | QHBoxLayout *l2 = new QHBoxLayout(this); |
186 | tl->addLayout(l2); | 175 | tl->addLayout(l2); |
187 | 176 | ||
188 | int minw = 0; | 177 | int minw = 0; |
189 | quit_b = new QPushButton(i18n("&Quit"), this); | 178 | quit_b = new QPushButton(QObject::tr("&Quit"), this); |
190 | // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) ); | 179 | // quit_b-> setGuiItem (KGuiItem(QObject::tr("&Quit"), "exit" ) ); |
191 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); | 180 | connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton())); |
192 | if(quit_b->sizeHint().width() > minw) | 181 | if(quit_b->sizeHint().width() > minw) |
193 | minw = quit_b->sizeHint().width(); | 182 | minw = quit_b->sizeHint().width(); |
194 | 183 | ||
195 | setup_b = new QPushButton(i18n("&Setup..."), this); | 184 | setup_b = new QPushButton(QObject::tr("&Setup..."), this); |
196 | // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) ); | 185 | // setup_b->setGuiItem (KGuiItem(QObject::tr("&Setup...")) ); |
197 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); | 186 | connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); |
198 | if(setup_b->sizeHint().width() > minw) | 187 | if(setup_b->sizeHint().width() > minw) |
199 | minw = setup_b->sizeHint().width(); | 188 | minw = setup_b->sizeHint().width(); |
200 | 189 | ||
201 | 190 | ||
202 | 191 | ||
203 | // if(_pppdata->access() != KConfig::ReadWrite) | 192 | // if(_pppdata->access() != KConfig::ReadWrite) |
204 | // setup_b->setEnabled(false); | 193 | // setup_b->setEnabled(false); |
205 | 194 | ||
206 | // help_b = new QPushButton(i18n("&Help"), this); | 195 | // help_b = new QPushButton(QObject::tr("&Help"), this); |
207 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); | 196 | // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); |
208 | 197 | ||
209 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); | 198 | // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); |
210 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); | 199 | // help_b->setPopup((QPopupMenu*)helpMenu->menu()); |
211 | // help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) ); | 200 | // help_b->setGuiItem (KGuiItem(QObject::tr("&Help"), "help" ) ); |
212 | 201 | ||
213 | // if(help_b->sizeHint().width() > minw) | 202 | // if(help_b->sizeHint().width() > minw) |
214 | // minw = help_b->sizeHint().width(); | 203 | // minw = help_b->sizeHint().width(); |
215 | 204 | ||
216 | connect_b = new QPushButton(i18n("&Connect"), this); | 205 | connect_b = new QPushButton(QObject::tr("&Connect"), this); |
217 | connect_b->setDefault(true); | 206 | connect_b->setDefault(true); |
218 | connect_b->setFocus(); | 207 | connect_b->setFocus(); |
219 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); | 208 | connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect())); |
220 | if(connect_b->sizeHint().width() > minw) | 209 | if(connect_b->sizeHint().width() > minw) |
221 | minw = connect_b->sizeHint().width(); | 210 | minw = connect_b->sizeHint().width(); |
222 | 211 | ||
223 | quit_b->setFixedWidth(minw); | 212 | quit_b->setFixedWidth(minw); |
224 | setup_b->setFixedWidth(minw); | 213 | setup_b->setFixedWidth(minw); |
225 | // help_b->setFixedWidth(help_b->sizeHint().width()); | 214 | // help_b->setFixedWidth(help_b->sizeHint().width()); |
226 | connect_b->setFixedWidth(minw); | 215 | connect_b->setFixedWidth(minw); |
227 | 216 | ||
228 | l2->addWidget(quit_b); | 217 | l2->addWidget(quit_b); |
229 | l2->addWidget(setup_b); | 218 | l2->addWidget(setup_b); |
230 | // l2->addWidget(help_b); | 219 | // l2->addWidget(help_b); |
231 | l2->addSpacing(20); | 220 | l2->addSpacing(20); |
232 | l2->addWidget(connect_b); | 221 | l2->addWidget(connect_b); |
233 | 222 | ||
234 | setFixedSize(sizeHint()); | 223 | setFixedSize(sizeHint()); |
235 | 224 | ||
236 | (void)new Modem(_pppdata); | 225 | (void)new Modem(_pppdata); |
237 | 226 | ||
238 | // 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 |
239 | // the dialer through a command line argument | 228 | // the dialer through a command line argument |
240 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); | 229 | connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect())); |
241 | 230 | ||
242 | // stats = new PPPStats; | 231 | // stats = new PPPStats; |
243 | 232 | ||
244 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 233 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
245 | 234 | ||
246 | // constructor of con_win reads position from config file | 235 | // constructor of con_win reads position from config file |
247 | con_win = new ConWindow(_pppdata, 0, "conw", this); | 236 | con_win = new ConWindow(_pppdata, 0, "conw", this); |
248 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); | 237 | // KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon()); |
249 | 238 | ||
250 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); | 239 | // statdlg = new PPPStatsDlg(0, "stats", this, stats); |
251 | // statdlg->hide(); | 240 | // statdlg->hide(); |
252 | 241 | ||
253 | // load up the accounts combo box | 242 | // load up the accounts combo box |
254 | 243 | ||
255 | // resetaccounts(); | 244 | // resetaccounts(); |
256 | con = new ConnectWidget(_pppdata, 0, "con"); | 245 | con = new ConnectWidget(_pppdata, 0, "con"); |
257 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); | 246 | //KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() ); |
258 | connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); | 247 | connect(this, SIGNAL(begin_connect()),con, SLOT(preinit())); |
259 | // 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. |
260 | // QRect desk = QApplication::desktop()->screenGeometry( | 249 | // QRect desk = QApplication::desktop()->screenGeometry( |
261 | // QApplication::desktop()->screenNumber(topLevelWidget())); | 250 | // QApplication::desktop()->screenNumber(topLevelWidget())); |
262 | // 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); |
263 | 252 | ||
264 | // connect the ConnectWidgets various signals | 253 | // connect the ConnectWidgets various signals |
265 | connect(con, SIGNAL(startAccounting()), | 254 | connect(con, SIGNAL(startAccounting()), |
266 | this, SLOT(startAccounting())); | 255 | this, SLOT(startAccounting())); |
267 | connect(con, SIGNAL(stopAccounting()), | 256 | connect(con, SIGNAL(stopAccounting()), |
268 | this, SLOT(stopAccounting())); | 257 | this, SLOT(stopAccounting())); |
269 | connect(qApp, SIGNAL(saveYourself()), | 258 | connect(qApp, SIGNAL(saveYourself()), |
270 | this, SLOT(saveMyself())); | 259 | this, SLOT(saveMyself())); |
271 | connect(qApp, SIGNAL(shutDown()), | 260 | connect(qApp, SIGNAL(shutDown()), |
272 | this, SLOT(shutDown())); | 261 | this, SLOT(shutDown())); |
273 | 262 | ||
274 | 263 | ||
275 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 264 | // KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
276 | 265 | ||
277 | // m_strCmdlAccount = args->getOption("c"); | 266 | // m_strCmdlAccount = args->getOption("c"); |
278 | // m_bQuitOnDisconnect = args->isSet("q"); | 267 | // m_bQuitOnDisconnect = args->isSet("q"); |
279 | 268 | ||
280 | // if(!m_strCmdlAccount.isEmpty()) { | 269 | // if(!m_strCmdlAccount.isEmpty()) { |
281 | // m_bCmdlAccount = true; | 270 | // m_bCmdlAccount = true; |
282 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; | 271 | // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; |
283 | // } | 272 | // } |
284 | 273 | ||
285 | // if(m_bCmdlAccount){ | 274 | // if(m_bCmdlAccount){ |
286 | // bool result = _pppdata->setAccount(m_strCmdlAccount); | 275 | // bool result = _pppdata->setAccount(m_strCmdlAccount); |
287 | // if (!result){ | 276 | // if (!result){ |
288 | // QString string; | 277 | // QString string; |
289 | // string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); | 278 | // string = QObject::tr("No such Account:\n%1").arg(m_strCmdlAccount); |
290 | // KMessageBox::error(this, string); | 279 | // KMessageBox::error(this, string); |
291 | // m_bCmdlAccount = false; | 280 | // m_bCmdlAccount = false; |
292 | // this->show(); | 281 | // this->show(); |
293 | // } else { | 282 | // } else { |
294 | // beginConnect(); | 283 | // beginConnect(); |
295 | // } | 284 | // } |
296 | // } else | 285 | // } else |
297 | // expandbutton(); | 286 | // expandbutton(); |
298 | // show(); | 287 | // show(); |
299 | 288 | ||
300 | 289 | ||
301 | //#define KPPP_SHOW_NEWS | 290 | //#define KPPP_SHOW_NEWS |
302 | #ifdef KPPP_SHOW_NEWS | 291 | #ifdef KPPP_SHOW_NEWS |
303 | // keep user informed about recent changes | 292 | // keep user informed about recent changes |
304 | if(!m_bCmdlAccount) | 293 | if(!m_bCmdlAccount) |
305 | showNews(); | 294 | showNews(); |
306 | #endif | 295 | #endif |
307 | } | 296 | } |
308 | 297 | ||
309 | KPPPWidget::~KPPPWidget() | 298 | KPPPWidget::~KPPPWidget() |
310 | { | 299 | { |
311 | p_kppp = 0; | 300 | p_kppp = 0; |
312 | // delete stats; | 301 | // delete stats; |
313 | } | 302 | } |
314 | 303 | ||
315 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { | 304 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { |
316 | // if(e->type() == QEvent::User) { | 305 | // if(e->type() == QEvent::User) { |
317 | // switch(((SignalEvent*)e)->sigType()) { | 306 | // switch(((SignalEvent*)e)->sigType()) { |
318 | // case SIGINT: | 307 | // case SIGINT: |
319 | // qDebug( "Received a SIGINT" ); | 308 | // qDebug( "Received a SIGINT" ); |
320 | // interruptConnection(); | 309 | // interruptConnection(); |
321 | // break; | 310 | // break; |
322 | // case SIGCHLD: | 311 | // case SIGCHLD: |
323 | // sigChld(); | 312 | // sigChld(); |
324 | // break; | 313 | // break; |
325 | // case SIGUSR1: | 314 | // case SIGUSR1: |
326 | // sigPPPDDied(); | 315 | // sigPPPDDied(); |
327 | // break; | 316 | // break; |
328 | // } | 317 | // } |
329 | // return true; | 318 | // return true; |
330 | // } | 319 | // } |
331 | 320 | ||
332 | // if(o == connect_b) { | 321 | // if(o == connect_b) { |
333 | // if(e->type() == QEvent::KeyPress) { | 322 | // if(e->type() == QEvent::KeyPress) { |
334 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { | 323 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { |
335 | // beginConnect(); | 324 | // beginConnect(); |
336 | // return true; | 325 | // return true; |
337 | // } | 326 | // } |
338 | // } | 327 | // } |
339 | // } | 328 | // } |
340 | 329 | ||
341 | // return false; | 330 | // return false; |
342 | // } | 331 | // } |
343 | 332 | ||
344 | 333 | ||
345 | 334 | ||
346 | 335 | ||
347 | void KPPPWidget::enterPressedInID() { | 336 | void KPPPWidget::enterPressedInID() { |
348 | PW_Edit->setFocus(); | 337 | PW_Edit->setFocus(); |
349 | } | 338 | } |
350 | 339 | ||
351 | 340 | ||
352 | void KPPPWidget::enterPressedInPW() { | 341 | void KPPPWidget::enterPressedInPW() { |
353 | connect_b->setFocus(); | 342 | connect_b->setFocus(); |
354 | } | 343 | } |
355 | 344 | ||
356 | // triggered by the session manager | 345 | // triggered by the session manager |
357 | void KPPPWidget::saveMyself() { | 346 | void KPPPWidget::saveMyself() { |
358 | _pppdata->save(); | 347 | _pppdata->save(); |
359 | } | 348 | } |
360 | 349 | ||
361 | void KPPPWidget::shutDown() { | 350 | void KPPPWidget::shutDown() { |
362 | interruptConnection(); | 351 | interruptConnection(); |
363 | saveMyself(); | 352 | saveMyself(); |
364 | } | 353 | } |
365 | 354 | ||
366 | void KPPPWidget::log_window_toggled(bool on) { | 355 | void KPPPWidget::log_window_toggled(bool on) { |
367 | _pppdata->set_show_log_window(on); | 356 | _pppdata->set_show_log_window(on); |
368 | } | 357 | } |
369 | 358 | ||
370 | 359 | ||
371 | 360 | ||
372 | 361 | ||
373 | // void KPPPWidget::resetaccounts() { | 362 | // void KPPPWidget::resetaccounts() { |
374 | // connectto_c->clear(); | 363 | // connectto_c->clear(); |
375 | 364 | ||
376 | // int count = _pppdata->count(); | 365 | // int count = _pppdata->count(); |
377 | 366 | ||
378 | // // enable/disable controls | 367 | // // enable/disable controls |
379 | // connectto_c->setEnabled(count > 0); | 368 | // connectto_c->setEnabled(count > 0); |
380 | // connect_b->setEnabled(count > 0); | 369 | // connect_b->setEnabled(count > 0); |
381 | // log->setEnabled(count > 0); | 370 | // log->setEnabled(count > 0); |
382 | // ID_Edit->setEnabled(count > 0); | 371 | // ID_Edit->setEnabled(count > 0); |
383 | // PW_Edit->setEnabled(count > 0); | 372 | // PW_Edit->setEnabled(count > 0); |
384 | 373 | ||
385 | // //load the accounts | 374 | // //load the accounts |
@@ -389,500 +378,500 @@ void KPPPWidget::log_window_toggled(bool on) { | |||
389 | // } | 378 | // } |
390 | 379 | ||
391 | // //set the default account | 380 | // //set the default account |
392 | // if(!_pppdata->defaultAccount().isEmpty()) { | 381 | // if(!_pppdata->defaultAccount().isEmpty()) { |
393 | // for(int i=0; i < count; i++) | 382 | // for(int i=0; i < count; i++) |
394 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { | 383 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { |
395 | // connectto_c->setCurrentItem(i); | 384 | // connectto_c->setCurrentItem(i); |
396 | // _pppdata->setAccountbyIndex(i); | 385 | // _pppdata->setAccountbyIndex(i); |
397 | 386 | ||
398 | // ID_Edit->setText(_pppdata->storedUsername()); | 387 | // ID_Edit->setText(_pppdata->storedUsername()); |
399 | // PW_Edit->setText(_pppdata->storedPassword()); | 388 | // PW_Edit->setText(_pppdata->storedPassword()); |
400 | // } | 389 | // } |
401 | // } | 390 | // } |
402 | // else | 391 | // else |
403 | // if(count > 0) { | 392 | // if(count > 0) { |
404 | // _pppdata->setDefaultAccount(connectto_c->text(0)); | 393 | // _pppdata->setDefaultAccount(connectto_c->text(0)); |
405 | // _pppdata->save(); | 394 | // _pppdata->save(); |
406 | // ID_Edit->setText(_pppdata->storedUsername()); | 395 | // ID_Edit->setText(_pppdata->storedUsername()); |
407 | // PW_Edit->setText(_pppdata->storedPassword()); | 396 | // PW_Edit->setText(_pppdata->storedPassword()); |
408 | // } | 397 | // } |
409 | 398 | ||
410 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), | 399 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), |
411 | // this, SLOT(usernameChanged(const QString &))); | 400 | // this, SLOT(usernameChanged(const QString &))); |
412 | 401 | ||
413 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), | 402 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), |
414 | // this, SLOT(passwordChanged(const QString &))); | 403 | // this, SLOT(passwordChanged(const QString &))); |
415 | 404 | ||
416 | // if (ID_Edit->text().isEmpty()) | 405 | // if (ID_Edit->text().isEmpty()) |
417 | // ID_Edit->setFocus(); | 406 | // ID_Edit->setFocus(); |
418 | // else if (PW_Edit->text().isEmpty()) | 407 | // else if (PW_Edit->text().isEmpty()) |
419 | // PW_Edit->setFocus(); | 408 | // PW_Edit->setFocus(); |
420 | // } | 409 | // } |
421 | 410 | ||
422 | 411 | ||
423 | void KPPPWidget::interruptConnection() { | 412 | void KPPPWidget::interruptConnection() { |
424 | // interrupt dial up | 413 | // interrupt dial up |
425 | // | 414 | // |
426 | 415 | ||
427 | if (con->isVisible()) | 416 | if (con->isVisible()) |
428 | emit con->cancelbutton(); | 417 | emit con->cancelbutton(); |
429 | 418 | ||
430 | // disconnect if online | 419 | // disconnect if online |
431 | if (_pppdata->pppdRunning()) | 420 | if (_pppdata->pppdRunning()) |
432 | emit disconnect(); | 421 | emit disconnect(); |
433 | } | 422 | } |
434 | 423 | ||
435 | 424 | ||
436 | void KPPPWidget::sigPPPDDied() { | 425 | void KPPPWidget::sigPPPDDied() { |
437 | qDebug( "Received a SIGUSR1" ); | 426 | qDebug( "Received a SIGUSR1" ); |
438 | 427 | ||
439 | // 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 |
440 | // 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 |
441 | // 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. |
442 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { | 431 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { |
443 | qDebug( "It was pppd that died" ); | 432 | qDebug( "It was pppd that died" ); |
444 | 433 | ||
445 | // when we killpppd() on Cancel in ConnectWidget | 434 | // when we killpppd() on Cancel in ConnectWidget |
446 | // we set pppid to -1 so we won't | 435 | // we set pppid to -1 so we won't |
447 | // enter this block | 436 | // enter this block |
448 | 437 | ||
449 | // just to be sure | 438 | // just to be sure |
450 | 439 | ||
451 | Modem::modem->removeSecret(AUTH_PAP); | 440 | Modem::modem->removeSecret(AUTH_PAP); |
452 | Modem::modem->removeSecret(AUTH_CHAP); | 441 | Modem::modem->removeSecret(AUTH_CHAP); |
453 | 442 | ||
454 | _pppdata->setpppdRunning(false); | 443 | _pppdata->setpppdRunning(false); |
455 | 444 | ||
456 | qDebug( "Executing command on disconnect since pppd has died." ); | 445 | qDebug( "Executing command on disconnect since pppd has died." ); |
457 | QApplication::flushX(); | 446 | QApplication::flushX(); |
458 | execute_command(_pppdata->command_on_disconnect()); | 447 | execute_command(_pppdata->command_on_disconnect()); |
459 | 448 | ||
460 | // stopAccounting(); | 449 | // stopAccounting(); |
461 | 450 | ||
462 | con_win->stopClock(); | 451 | con_win->stopClock(); |
463 | // DockWidget::dock_widget->stop_stats(); | 452 | // DockWidget::dock_widget->stop_stats(); |
464 | // DockWidget::dock_widget->hide(); | 453 | // DockWidget::dock_widget->hide(); |
465 | 454 | ||
466 | if(!_pppdata->pppdError()) | 455 | if(!_pppdata->pppdError()) |
467 | _pppdata->setpppdError(E_PPPD_DIED); | 456 | _pppdata->setpppdError(E_PPPD_DIED); |
468 | removedns(); | 457 | removedns(); |
469 | Modem::modem->unlockdevice(); | 458 | Modem::modem->unlockdevice(); |
470 | // | 459 | // |
471 | con->pppdDied(); | 460 | con->pppdDied(); |
472 | 461 | ||
473 | if(!_pppdata->automatic_redial()) { | 462 | if(!_pppdata->automatic_redial()) { |
474 | quit_b->setFocus(); | 463 | quit_b->setFocus(); |
475 | show(); | 464 | show(); |
476 | con_win->stopClock(); | 465 | con_win->stopClock(); |
477 | //stopAccounting(); | 466 | //stopAccounting(); |
478 | con_win->hide(); | 467 | con_win->hide(); |
479 | con->hide(); | 468 | con->hide(); |
480 | 469 | ||
481 | _pppdata->setpppdRunning(false); | 470 | _pppdata->setpppdRunning(false); |
482 | // // not in a signal handler !!! KNotifyClient::beep(); | 471 | // // not in a signal handler !!! KNotifyClient::beep(); |
483 | QString msg; | 472 | QString msg; |
484 | if (_pppdata->pppdError() == E_IF_TIMEOUT) | 473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) |
485 | msg = i18n("Timeout expired while waiting for the PPP interface " | 474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " |
486 | "to come up!"); | 475 | "to come up!"); |
487 | else { | 476 | else { |
488 | msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); | 477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); |
489 | Modem::modem->pppdExitStatus(); | 478 | Modem::modem->pppdExitStatus(); |
490 | if (Modem::modem->lastStatus != 99) {// more recent pppds only | 479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only |
491 | msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus); | 480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); |
492 | msg += i18n("</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 " |
493 | "codes or take a look at the kppp FAQ on " | 482 | "codes or take a look at the kppp FAQ on " |
494 | " <a href=http://devel-home.kde.org/~kppp/index.html>" | 483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" |
495 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); | 484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); |
496 | } | 485 | } |
497 | } | 486 | } |
498 | 487 | ||
499 | // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) | 488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) |
500 | // // PPPL_ShowLog(); | 489 | // // PPPL_ShowLog(); |
501 | // } else { /* reconnect on disconnect */ | 490 | // } else { /* reconnect on disconnect */ |
502 | if (false){ | 491 | if (false){ |
503 | qDebug( "Trying to reconnect... " ); | 492 | qDebug( "Trying to reconnect... " ); |
504 | 493 | ||
505 | if(_pppdata->authMethod() == AUTH_PAP || | 494 | if(_pppdata->authMethod() == AUTH_PAP || |
506 | _pppdata->authMethod() == AUTH_CHAP || | 495 | _pppdata->authMethod() == AUTH_CHAP || |
507 | _pppdata->authMethod() == AUTH_PAPCHAP) | 496 | _pppdata->authMethod() == AUTH_PAPCHAP) |
508 | Modem::modem->setSecret(_pppdata->authMethod(), | 497 | Modem::modem->setSecret(_pppdata->authMethod(), |
509 | encodeWord(_pppdata->storedUsername()), | 498 | encodeWord(_pppdata->storedUsername()), |
510 | encodeWord(_pppdata->password())); | 499 | encodeWord(_pppdata->password())); |
511 | 500 | ||
512 | con_win->hide(); | 501 | con_win->hide(); |
513 | con_win->stopClock(); | 502 | con_win->stopClock(); |
514 | //stopAccounting(); | 503 | //stopAccounting(); |
515 | _pppdata->setpppdRunning(false); | 504 | _pppdata->setpppdRunning(false); |
516 | // not in a signal handler !!!KNotifyClient::beep(); | 505 | // not in a signal handler !!!KNotifyClient::beep(); |
517 | emit cmdl_start(); | 506 | emit cmdl_start(); |
518 | } | 507 | } |
519 | } | 508 | } |
520 | _pppdata->setpppdError(0); | 509 | _pppdata->setpppdError(0); |
521 | } | 510 | } |
522 | } | 511 | } |
523 | 512 | ||
524 | // void KPPPWidget::sigChld() { | 513 | // void KPPPWidget::sigChld() { |
525 | // qDebug( "sigchld()" ); | 514 | // qDebug( "sigchld()" ); |
526 | // // pid_t id = wait(0L); | 515 | // // pid_t id = wait(0L); |
527 | // // if(id == helperPid && helperPid != -1) { | 516 | // // if(id == helperPid && helperPid != -1) { |
528 | // // kdDebug(5002) << "It was the setuid child that died" << endl; | 517 | // // kdDebug(5002) << "It was the setuid child that died" << endl; |
529 | // // helperPid = -1; | 518 | // // helperPid = -1; |
530 | // QString msg = i18n("kppp's helper process just died.\n" | 519 | // QString msg = QObject::tr("kppp's helper process just died.\n" |
531 | // "Since a further execution would be pointless, " | 520 | // "Since a further execution would be pointless, " |
532 | // "kppp will shut down now."); | 521 | // "kppp will shut down now."); |
533 | // QMessageBox::warning(0L,"error", msg); | 522 | // QMessageBox::warning(0L,"error", msg); |
534 | // //remove_pidfile(); | 523 | // //remove_pidfile(); |
535 | // exit(1); | 524 | // exit(1); |
536 | // // } | 525 | // // } |
537 | // } | 526 | // } |
538 | 527 | ||
539 | 528 | ||
540 | void KPPPWidget::newdefaultaccount(int i) { | 529 | void KPPPWidget::newdefaultaccount(int i) { |
541 | _pppdata->setDefaultAccount(connectto_c->text(i)); | 530 | _pppdata->setDefaultAccount(connectto_c->text(i)); |
542 | _pppdata->save(); | 531 | _pppdata->save(); |
543 | ID_Edit->setText(_pppdata->storedUsername()); | 532 | ID_Edit->setText(_pppdata->storedUsername()); |
544 | PW_Edit->setText(_pppdata->storedPassword()); | 533 | PW_Edit->setText(_pppdata->storedPassword()); |
545 | } | 534 | } |
546 | 535 | ||
547 | 536 | ||
548 | 537 | ||
549 | 538 | ||
550 | void KPPPWidget::beginConnect() { | 539 | void KPPPWidget::beginConnect() { |
551 | // 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 |
552 | // (exeption: an account given by a command line argument) | 541 | // (exeption: an account given by a command line argument) |
553 | // if(!m_bCmdlAccount) { | 542 | // if(!m_bCmdlAccount) { |
554 | // _pppdata->setAccount(connectto_c->currentText()); | 543 | // _pppdata->setAccount(connectto_c->currentText()); |
555 | // _pppdata->setPassword(PW_Edit->text()); | 544 | // _pppdata->setPassword(PW_Edit->text()); |
556 | // } else { | 545 | // } else { |
557 | _pppdata->setPassword(_pppdata->storedPassword()); | 546 | _pppdata->setPassword(_pppdata->storedPassword()); |
558 | // } | 547 | // } |
559 | 548 | ||
560 | QFileInfo info(pppdPath()); | 549 | QFileInfo info(pppdPath()); |
561 | 550 | ||
562 | if(!info.exists()){ | 551 | if(!info.exists()){ |
563 | QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" | 552 | QMessageBox::warning(this, "error", QObject::tr("Cannot find the PPP daemon!\n" |
564 | "Make sure that pppd is installed and " | 553 | "Make sure that pppd is installed and " |
565 | "that you have entered the correct path.")); | 554 | "that you have entered the correct path.")); |
566 | return; | 555 | return; |
567 | } | 556 | } |
568 | #if 0 | 557 | #if 0 |
569 | if(!info.isExecutable()){ | 558 | if(!info.isExecutable()){ |
570 | 559 | ||
571 | QString string; | 560 | QString string; |
572 | string = i18n("kppp cannot execute:\n %1\n" | 561 | string = QObject::tr("kppp cannot execute:\n %1\n" |
573 | "Please make sure that you have given kppp " | 562 | "Please make sure that you have given kppp " |
574 | "setuid permission and that " | 563 | "setuid permission and that " |
575 | "pppd is executable.").arg(_pppdata->pppdPath()); | 564 | "pppd is executable.").arg(_pppdata->pppdPath()); |
576 | KMessageBox::error(this, string); | 565 | KMessageBox::error(this, string); |
577 | return; | 566 | return; |
578 | 567 | ||
579 | } | 568 | } |
580 | #endif | 569 | #endif |
581 | 570 | ||
582 | QFileInfo info2(_pppdata->modemDevice()); | 571 | QFileInfo info2(_pppdata->modemDevice()); |
583 | 572 | ||
584 | if(!info2.exists()){ | 573 | if(!info2.exists()){ |
585 | QString string; | 574 | QString string; |
586 | string = i18n("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 " |
587 | "your modem device properly " | 576 | "your modem device properly " |
588 | "and/or adjust the location of the modem device on " | 577 | "and/or adjust the location of the modem device on " |
589 | "the modem tab of " | 578 | "the modem tab of " |
590 | "the setup dialog.").arg(_pppdata->modemDevice()); | 579 | "the setup dialog.").arg(_pppdata->modemDevice()); |
591 | QMessageBox::warning(this, "error", string); | 580 | QMessageBox::warning(this, "error", string); |
592 | return; | 581 | return; |
593 | } | 582 | } |
594 | 583 | ||
595 | // 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 |
596 | // supplied | 585 | // supplied |
597 | if(_pppdata->authMethod() == AUTH_PAP || | 586 | if(_pppdata->authMethod() == AUTH_PAP || |
598 | _pppdata->authMethod() == AUTH_CHAP || | 587 | _pppdata->authMethod() == AUTH_CHAP || |
599 | _pppdata->authMethod() == AUTH_PAPCHAP ) { | 588 | _pppdata->authMethod() == AUTH_PAPCHAP ) { |
600 | if(ID_Edit->text().isEmpty()) { | 589 | if(ID_Edit->text().isEmpty()) { |
601 | QMessageBox::warning(this,"error", | 590 | QMessageBox::warning(this,"error", |
602 | i18n("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!")); |
603 | return; | 592 | return; |
604 | } else { | 593 | } else { |
605 | if(!Modem::modem->setSecret(_pppdata->authMethod(), | 594 | if(!Modem::modem->setSecret(_pppdata->authMethod(), |
606 | encodeWord(_pppdata->storedUsername()), | 595 | encodeWord(_pppdata->storedUsername()), |
607 | encodeWord(_pppdata->password()))) { | 596 | encodeWord(_pppdata->password()))) { |
608 | QString s; | 597 | QString s; |
609 | s = i18n("Cannot create PAP/CHAP authentication\n" | 598 | s = QObject::tr("Cannot create PAP/CHAP authentication\n" |
610 | "file \"%1\"").arg(PAP_AUTH_FILE); | 599 | "file \"%1\"").arg(PAP_AUTH_FILE); |
611 | QMessageBox::warning(this, "error", s); | 600 | QMessageBox::warning(this, "error", s); |
612 | return; | 601 | return; |
613 | } | 602 | } |
614 | } | 603 | } |
615 | } | 604 | } |
616 | 605 | ||
617 | if (_pppdata->phonenumber().isEmpty()) { | 606 | if (_pppdata->phonenumber().isEmpty()) { |
618 | QString s = i18n("You must specify a telephone number!"); | 607 | QString s = QObject::tr("You must specify a telephone number!"); |
619 | QMessageBox::warning(this, "error", s); | 608 | QMessageBox::warning(this, "error", s); |
620 | return; | 609 | return; |
621 | } | 610 | } |
622 | 611 | ||
623 | this->hide(); | 612 | this->hide(); |
624 | 613 | ||
625 | QString tit = i18n("Connecting to: %1").arg(_pppdata->accname()); | 614 | QString tit = QObject::tr("Connecting to: %1").arg(_pppdata->accname()); |
626 | // con->setCaption(tit); | 615 | // con->setCaption(tit); |
627 | 616 | ||
628 | // con->show(); | 617 | // con->show(); |
629 | 618 | ||
630 | 619 | ||
631 | emit begin_connect(); | 620 | emit begin_connect(); |
632 | } | 621 | } |
633 | 622 | ||
634 | 623 | ||
635 | void KPPPWidget::disconnect() { | 624 | void KPPPWidget::disconnect() { |
636 | if (!_pppdata->command_before_disconnect().isEmpty()) { | 625 | if (!_pppdata->command_before_disconnect().isEmpty()) { |
637 | con_win->hide(); | 626 | con_win->hide(); |
638 | con->show(); | 627 | con->show(); |
639 | con->setCaption(i18n("Disconnecting...")); | 628 | con->setCaption(QObject::tr("Disconnecting...")); |
640 | con->setMsg(i18n("Executing command before disconnection.")); | 629 | con->setMsg(QObject::tr("Executing command before disconnection.")); |
641 | 630 | ||
642 | qApp->processEvents(); | 631 | qApp->processEvents(); |
643 | QApplication::flushX(); | 632 | QApplication::flushX(); |
644 | // pid_t id = | 633 | // pid_t id = |
645 | execute_command(_pppdata->command_before_disconnect()); | 634 | execute_command(_pppdata->command_before_disconnect()); |
646 | // int i, status; | 635 | // int i, status; |
647 | 636 | ||
648 | // do { | 637 | // do { |
649 | // kapp->processEvents(); | 638 | // kapp->processEvents(); |
650 | // i = waitpid(id, &status, WNOHANG); | 639 | // i = waitpid(id, &status, WNOHANG); |
651 | // usleep(500000); | 640 | // usleep(500000); |
652 | // } while (i == 0 && errno == 0); | 641 | // } while (i == 0 && errno == 0); |
653 | 642 | ||
654 | con->hide(); | 643 | con->hide(); |
655 | } | 644 | } |
656 | 645 | ||
657 | qApp->processEvents(); | 646 | qApp->processEvents(); |
658 | 647 | ||
659 | // statdlg->stop_stats(); | 648 | // statdlg->stop_stats(); |
660 | Modem::modem->killPPPDaemon(); | 649 | Modem::modem->killPPPDaemon(); |
661 | 650 | ||
662 | QApplication::flushX(); | 651 | QApplication::flushX(); |
663 | execute_command(_pppdata->command_on_disconnect()); | 652 | execute_command(_pppdata->command_on_disconnect()); |
664 | 653 | ||
665 | Modem::modem->removeSecret(AUTH_PAP); | 654 | Modem::modem->removeSecret(AUTH_PAP); |
666 | Modem::modem->removeSecret(AUTH_CHAP); | 655 | Modem::modem->removeSecret(AUTH_CHAP); |
667 | 656 | ||
668 | removedns(); | 657 | removedns(); |
669 | Modem::modem->unlockdevice(); | 658 | Modem::modem->unlockdevice(); |
670 | 659 | ||
671 | con_win->stopClock(); | 660 | con_win->stopClock(); |
672 | // p_kppp->stopAccounting(); | 661 | // p_kppp->stopAccounting(); |
673 | con_win->hide(); | 662 | con_win->hide(); |
674 | 663 | ||
675 | // DockWidget::dock_widget->stop_stats(); | 664 | // DockWidget::dock_widget->stop_stats(); |
676 | // DockWidget::dock_widget->hide(); | 665 | // DockWidget::dock_widget->hide(); |
677 | 666 | ||
678 | // if(m_bQuitOnDisconnect) | 667 | // if(m_bQuitOnDisconnect) |
679 | // kapp->exit(0); | 668 | // kapp->exit(0); |
680 | // else { | 669 | // else { |
681 | this->quit_b->setFocus(); | 670 | this->quit_b->setFocus(); |
682 | this->show(); | 671 | this->show(); |
683 | // } | 672 | // } |
684 | } | 673 | } |
685 | 674 | ||
686 | 675 | ||
687 | // void KPPPWidget::helpbutton() { | 676 | // void KPPPWidget::helpbutton() { |
688 | // kapp->invokeHelp(); | 677 | // kapp->invokeHelp(); |
689 | // } | 678 | // } |
690 | 679 | ||
691 | 680 | ||
692 | void KPPPWidget::quitbutton() { | 681 | void KPPPWidget::quitbutton() { |
693 | if(_pppdata->pppdRunning()) { | 682 | if(_pppdata->pppdRunning()) { |
694 | int ok = QMessageBox::warning(this, | 683 | int ok = QMessageBox::warning(this, |
695 | i18n("Exiting kPPP will close your PPP Session."), | 684 | QObject::tr("Exiting kPPP will close your PPP Session."), |
696 | i18n("Quit kPPP?")); | 685 | QObject::tr("Quit kPPP?")); |
697 | if(ok == QMessageBox::Yes) { | 686 | if(ok == QMessageBox::Yes) { |
698 | Modem::modem->killPPPDaemon(); | 687 | Modem::modem->killPPPDaemon(); |
699 | QApplication::flushX(); | 688 | QApplication::flushX(); |
700 | execute_command(_pppdata->command_on_disconnect()); | 689 | execute_command(_pppdata->command_on_disconnect()); |
701 | removedns(); | 690 | removedns(); |
702 | Modem::modem->unlockdevice(); | 691 | Modem::modem->unlockdevice(); |
703 | } | 692 | } |
704 | } else { | 693 | } else { |
705 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) | 694 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) |
706 | _pppdata->setStoredPassword(""); | 695 | _pppdata->setStoredPassword(""); |
707 | } | 696 | } |
708 | _pppdata->save(); | 697 | _pppdata->save(); |
709 | qApp->quit(); | 698 | qApp->quit(); |
710 | } | 699 | } |
711 | 700 | ||
712 | 701 | ||
713 | // void KPPPWidget::rulesetLoadError() { | 702 | // void KPPPWidget::rulesetLoadError() { |
714 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); | 703 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); |
715 | // } | 704 | // } |
716 | 705 | ||
717 | 706 | ||
718 | // void KPPPWidget::startAccounting() { | 707 | // void KPPPWidget::startAccounting() { |
719 | // // volume accounting | 708 | // // volume accounting |
720 | // stats->totalbytes = 0; | 709 | // stats->totalbytes = 0; |
721 | 710 | ||
722 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; | 711 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; |
723 | 712 | ||
724 | // // load the ruleset | 713 | // // load the ruleset |
725 | // if(!_pppdata->AcctEnabled()) | 714 | // if(!_pppdata->AcctEnabled()) |
726 | // return; | 715 | // return; |
727 | 716 | ||
728 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); | 717 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); |
729 | // // if(::access(d.data(), X_OK) != 0) | 718 | // // if(::access(d.data(), X_OK) != 0) |
730 | // acct = new Accounting(this, stats); | 719 | // acct = new Accounting(this, stats); |
731 | // // else | 720 | // // else |
732 | // // acct = new ExecutableAccounting(this); | 721 | // // acct = new ExecutableAccounting(this); |
733 | 722 | ||
734 | // // connect to the accounting object | 723 | // // connect to the accounting object |
735 | // connect(acct, SIGNAL(changed(QString, QString)), | 724 | // connect(acct, SIGNAL(changed(QString, QString)), |
736 | // con_win, SLOT(slotAccounting(QString, QString))); | 725 | // con_win, SLOT(slotAccounting(QString, QString))); |
737 | 726 | ||
738 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { | 727 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { |
739 | // // QString s= i18n("Can not load the accounting " | 728 | // // QString s= QObject::tr("Can not load the accounting " |
740 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); | 729 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); |
741 | 730 | ||
742 | // // starting the messagebox with a timer will prevent us | 731 | // // starting the messagebox with a timer will prevent us |
743 | // // from blocking the calling function ConnectWidget::timerEvent | 732 | // // from blocking the calling function ConnectWidget::timerEvent |
744 | // ruleset_load_errmsg = s; | 733 | // ruleset_load_errmsg = s; |
745 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); | 734 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); |
746 | // return; | 735 | // return; |
747 | // } | 736 | // } |
748 | // //else | 737 | // //else |
749 | // // acct->slotStart(); | 738 | // // acct->slotStart(); |
750 | // } | 739 | // } |
751 | 740 | ||
752 | // void KPPPWidget::stopAccounting() { | 741 | // void KPPPWidget::stopAccounting() { |
753 | // // store volume accounting | 742 | // // store volume accounting |
754 | // // if(stats->totalbytes != 0) | 743 | // // if(stats->totalbytes != 0) |
755 | // // _pppdata->setTotalBytes(stats->totalbytes); | 744 | // // _pppdata->setTotalBytes(stats->totalbytes); |
756 | 745 | ||
757 | // if(!_pppdata->AcctEnabled()) | 746 | // if(!_pppdata->AcctEnabled()) |
758 | // return; | 747 | // return; |
759 | 748 | ||
760 | // // if(acct != 0) { | 749 | // // if(acct != 0) { |
761 | // // acct->slotStop(); | 750 | // // acct->slotStop(); |
762 | // // delete acct; | 751 | // // delete acct; |
763 | // // acct = 0; | 752 | // // acct = 0; |
764 | // // } | 753 | // // } |
765 | // } | 754 | // } |
766 | 755 | ||
767 | 756 | ||
768 | // void KPPPWidget::showStats() { | 757 | // void KPPPWidget::showStats() { |
769 | // if(statdlg) { | 758 | // if(statdlg) { |
770 | // statdlg->show(); | 759 | // statdlg->show(); |
771 | // statdlg->raise(); | 760 | // statdlg->raise(); |
772 | // } | 761 | // } |
773 | // } | 762 | // } |
774 | 763 | ||
775 | 764 | ||
776 | void KPPPWidget::usernameChanged(const QString &) { | 765 | void KPPPWidget::usernameChanged(const QString &) { |
777 | // store username for later use | 766 | // store username for later use |
778 | _pppdata->setStoredUsername(ID_Edit->text()); | 767 | _pppdata->setStoredUsername(ID_Edit->text()); |
779 | } | 768 | } |
780 | 769 | ||
781 | 770 | ||
782 | void KPPPWidget::passwordChanged(const QString &) { | 771 | void KPPPWidget::passwordChanged(const QString &) { |
783 | // store the password if so requested | 772 | // store the password if so requested |
784 | if(_pppdata->storePassword()) | 773 | if(_pppdata->storePassword()) |
785 | _pppdata->setStoredPassword(PW_Edit->text()); | 774 | _pppdata->setStoredPassword(PW_Edit->text()); |
786 | else | 775 | else |
787 | _pppdata->setStoredPassword(""); | 776 | _pppdata->setStoredPassword(""); |
788 | } | 777 | } |
789 | 778 | ||
790 | 779 | ||
791 | void KPPPWidget::setPW_Edit(const QString &pw) { | 780 | void KPPPWidget::setPW_Edit(const QString &pw) { |
792 | PW_Edit->setText(pw); | 781 | PW_Edit->setText(pw); |
793 | } | 782 | } |
794 | 783 | ||
795 | 784 | ||
796 | // void KPPPWidget::resetCosts(const QString &s) { | 785 | // void KPPPWidget::resetCosts(const QString &s) { |
797 | // AccountingBase::resetCosts(s); | 786 | // AccountingBase::resetCosts(s); |
798 | // } | 787 | // } |
799 | 788 | ||
800 | 789 | ||
801 | // void KPPPWidget::resetVolume(const QString &s) { | 790 | // void KPPPWidget::resetVolume(const QString &s) { |
802 | // AccountingBase::resetVolume(s); | 791 | // AccountingBase::resetVolume(s); |
803 | // } | 792 | // } |
804 | 793 | ||
805 | /** | 794 | /** |
806 | * pppd's getword() function knows about escape characters. | 795 | * pppd's getword() function knows about escape characters. |
807 | * If we write the username and password to the secrets file | 796 | * If we write the username and password to the secrets file |
808 | * we'll therefore have to escape back slashes. | 797 | * we'll therefore have to escape back slashes. |
809 | */ | 798 | */ |
810 | QString KPPPWidget::encodeWord(const QString &s) { | 799 | QString KPPPWidget::encodeWord(const QString &s) { |
811 | QString r = s; | 800 | QString r = s; |
812 | r.replace(QRegExp("\\"), "\\\\"); | 801 | r.replace(QRegExp("\\"), "\\\\"); |
813 | return r; | 802 | return r; |
814 | } | 803 | } |
815 | 804 | ||
816 | // void KPPPWidget::setQuitOnDisconnect (bool b) | 805 | // void KPPPWidget::setQuitOnDisconnect (bool b) |
817 | // { | 806 | // { |
818 | // m_bQuitOnDisconnect = b; | 807 | // m_bQuitOnDisconnect = b; |
819 | // } | 808 | // } |
820 | 809 | ||
821 | void KPPPWidget::showNews() { | 810 | void KPPPWidget::showNews() { |
822 | #ifdef KPPP_SHOW_NEWS | 811 | #ifdef KPPP_SHOW_NEWS |
823 | /* | 812 | /* |
824 | * Introduce the QuickHelp feature to new users of this version | 813 | * Introduce the QuickHelp feature to new users of this version |
825 | */ | 814 | */ |
826 | #define QUICKHELP_HINT "Hint_QuickHelp" | 815 | #define QUICKHELP_HINT "Hint_QuickHelp" |
827 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { | 816 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { |
828 | QDialog dlg(0, 0, true); | 817 | QDialog dlg(0, 0, true); |
829 | dlg.setCaption(i18n("Recent Changes in KPPP")); | 818 | dlg.setCaption(QObject::tr("Recent Changes in KPPP")); |
830 | 819 | ||
831 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); | 820 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); |
832 | QHBoxLayout *l1 = new QHBoxLayout(10); | 821 | QHBoxLayout *l1 = new QHBoxLayout(10); |
833 | QVBoxLayout *l2 = new QVBoxLayout(10); | 822 | QVBoxLayout *l2 = new QVBoxLayout(10); |
834 | tl->addLayout(l1); | 823 | tl->addLayout(l1); |
835 | 824 | ||
836 | QLabel *icon = new QLabel(&dlg); | 825 | QLabel *icon = new QLabel(&dlg); |
837 | icon->setPixmap(BarIcon("exclamation")); | 826 | icon->setPixmap(BarIcon("exclamation")); |
838 | icon->setFixedSize(icon->sizeHint()); | 827 | icon->setFixedSize(icon->sizeHint()); |
839 | l1->addWidget(icon); | 828 | l1->addWidget(icon); |
840 | l1->addLayout(l2); | 829 | l1->addLayout(l2); |
841 | 830 | ||
842 | QLabel *l = new QLabel(i18n("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" |
843 | "called \"Quickhelp\". It's similar to a tooltip,\n" | 832 | "called \"Quickhelp\". It's similar to a tooltip,\n" |
844 | "but you can activate it whenever you want.\n" | 833 | "but you can activate it whenever you want.\n" |
845 | "\n" | 834 | "\n" |
846 | "To activate it, simply click on a control like\n" | 835 | "To activate it, simply click on a control like\n" |
847 | "a button or a label with the right mouse button.\n" | 836 | "a button or a label with the right mouse button.\n" |
848 | "If the item supports Quickhelp, a popup menu\n" | 837 | "If the item supports Quickhelp, a popup menu\n" |
849 | "will appear leading to Quickhelp.\n" | 838 | "will appear leading to Quickhelp.\n" |
850 | "\n" | 839 | "\n" |
851 | "To test it, right-click somewhere in this text."), | 840 | "To test it, right-click somewhere in this text."), |
852 | &dlg); | 841 | &dlg); |
853 | 842 | ||
854 | QCheckBox *cb = new QCheckBox(i18n("Don't show this hint again"), &dlg); | 843 | QCheckBox *cb = new QCheckBox(QObject::tr("Don't show this hint again"), &dlg); |
855 | cb->setFixedSize(cb->sizeHint()); | 844 | cb->setFixedSize(cb->sizeHint()); |
856 | 845 | ||
857 | KButtonBox *bbox = new KButtonBox(&dlg); | 846 | KButtonBox *bbox = new KButtonBox(&dlg); |
858 | bbox->addStretch(1); | 847 | bbox->addStretch(1); |
859 | QPushButton *ok = bbox->addButton(i18n("OK")); | 848 | QPushButton *ok = bbox->addButton(QObject::tr("OK")); |
860 | ok->setDefault(true); | 849 | ok->setDefault(true); |
861 | dlg.connect(ok, SIGNAL(clicked()), | 850 | dlg.connect(ok, SIGNAL(clicked()), |
862 | &dlg, SLOT(accept())); | 851 | &dlg, SLOT(accept())); |
863 | bbox->addStretch(1); | 852 | bbox->addStretch(1); |
864 | bbox->layout(); | 853 | bbox->layout(); |
865 | 854 | ||
866 | l2->addWidget(l); | 855 | l2->addWidget(l); |
867 | l2->addWidget(cb); | 856 | l2->addWidget(cb); |
868 | tl->addWidget(bbox); | 857 | tl->addWidget(bbox); |
869 | 858 | ||
870 | QString tmp = i18n("This is an example of <b>QuickHelp</b>.\n" | 859 | QString tmp = QObject::tr("This is an example of <b>QuickHelp</b>.\n" |
871 | "This window will stay open until you\n" | 860 | "This window will stay open until you\n" |
872 | "click a mouse button or a press a key.\n"); | 861 | "click a mouse button or a press a key.\n"); |
873 | 862 | ||
874 | QWhatsThis::add(cb,tmp); | 863 | QWhatsThis::add(cb,tmp); |
875 | QWhatsThis::add(l, tmp); | 864 | QWhatsThis::add(l, tmp); |
876 | 865 | ||
877 | dlg.exec(); | 866 | dlg.exec(); |
878 | if(cb->isChecked()) { | 867 | if(cb->isChecked()) { |
879 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); | 868 | _pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); |
880 | _pppdata->save(); | 869 | _pppdata->save(); |
881 | } | 870 | } |
882 | } | 871 | } |
883 | #endif | 872 | #endif |
884 | } | 873 | } |
885 | 874 | ||
886 | 875 | ||
887 | //#include "kpppwidget.moc" | 876 | //#include "kpppwidget.moc" |
888 | 877 | ||
diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index d23fee4..3dbc8c3 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp | |||
@@ -1,654 +1,651 @@ | |||
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 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
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 <errno.h> | 27 | #include <errno.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <fcntl.h> | 30 | #include <fcntl.h> |
31 | #include <signal.h> | 31 | #include <signal.h> |
32 | #include <sys/ioctl.h> | 32 | #include <sys/ioctl.h> |
33 | #include <sys/types.h> | 33 | #include <sys/types.h> |
34 | #include <sys/stat.h> | 34 | #include <sys/stat.h> |
35 | #include <setjmp.h> | 35 | #include <setjmp.h> |
36 | #include <regex.h> | 36 | #include <regex.h> |
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | #include <assert.h> | 38 | #include <assert.h> |
39 | #include <string.h> | 39 | #include <string.h> |
40 | 40 | ||
41 | #ifdef HAVE_RESOLV_H | 41 | #ifdef HAVE_RESOLV_H |
42 | # include <arpa/nameser.h> | 42 | # include <arpa/nameser.h> |
43 | # include <resolv.h> | 43 | # include <resolv.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #ifndef _PATH_RESCONF | 46 | #ifndef _PATH_RESCONF |
47 | #define _PATH_RESCONF "/etc/resolv.conf" | 47 | #define _PATH_RESCONF "/etc/resolv.conf" |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #define strlcpy strcpy | 50 | #define strlcpy strcpy |
51 | #include "auth.h" | 51 | #include "auth.h" |
52 | #include "modem.h" | 52 | #include "modem.h" |
53 | #include "pppdata.h" | 53 | #include "pppdata.h" |
54 | //#include <klocale.h> | ||
55 | #define i18n QObject::tr | ||
56 | #define qError qDebug | 54 | #define qError qDebug |
57 | //#include <kdebug.h> | 55 | |
58 | //#include <config.h> | ||
59 | 56 | ||
60 | #define MY_ASSERT(x) if (!(x)) { \ | 57 | #define MY_ASSERT(x) if (!(x)) { \ |
61 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ | 58 | qFatal( "ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__); \ |
62 | exit(1); } | 59 | exit(1); } |
63 | 60 | ||
64 | 61 | ||
65 | static sigjmp_buf jmp_buffer; | 62 | static sigjmp_buf jmp_buffer; |
66 | 63 | ||
67 | //Modem *Modem::modem = 0; | 64 | //Modem *Modem::modem = 0; |
68 | 65 | ||
69 | 66 | ||
70 | const char* pppdPath() { | 67 | const char* pppdPath() { |
71 | // wasting a few bytes | 68 | // wasting a few bytes |
72 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; | 69 | static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; |
73 | static char *pppdPath = 0L; | 70 | static char *pppdPath = 0L; |
74 | char *p; | 71 | char *p; |
75 | 72 | ||
76 | if(pppdPath == 0L) { | 73 | if(pppdPath == 0L) { |
77 | const char *c = PPPDSEARCHPATH; | 74 | const char *c = PPPDSEARCHPATH; |
78 | while(*c != '\0') { | 75 | while(*c != '\0') { |
79 | while(*c == ':') | 76 | while(*c == ':') |
80 | c++; | 77 | c++; |
81 | p = buffer; | 78 | p = buffer; |
82 | while(*c != '\0' && *c != ':') | 79 | while(*c != '\0' && *c != ':') |
83 | *p++ = *c++; | 80 | *p++ = *c++; |
84 | *p = '\0'; | 81 | *p = '\0'; |
85 | strcat(p, "/"); | 82 | strcat(p, "/"); |
86 | strcat(p, PPPDNAME); | 83 | strcat(p, PPPDNAME); |
87 | if(access(buffer, F_OK) == 0) | 84 | if(access(buffer, F_OK) == 0) |
88 | return (pppdPath = buffer); | 85 | return (pppdPath = buffer); |
89 | } | 86 | } |
90 | } | 87 | } |
91 | 88 | ||
92 | return pppdPath; | 89 | return pppdPath; |
93 | } | 90 | } |
94 | 91 | ||
95 | 92 | ||
96 | Modem::Modem( PPPData* pd ) | 93 | Modem::Modem( PPPData* pd ) |
97 | { | 94 | { |
98 | _pppdata = pd; | 95 | _pppdata = pd; |
99 | modemfd = -1; | 96 | modemfd = -1; |
100 | _pppdExitStatus = -1; | 97 | _pppdExitStatus = -1; |
101 | pppdPid = -1; | 98 | pppdPid = -1; |
102 | sn = 0L; | 99 | sn = m_modemDebug = 0L; |
103 | data_mode = false; | 100 | data_mode = false; |
104 | modem_is_locked = false; | 101 | modem_is_locked = false; |
105 | lockfile[0] = '\0'; | 102 | lockfile[0] = '\0'; |
106 | device = "/dev/modem"; | 103 | device = "/dev/modem"; |
107 | } | 104 | } |
108 | 105 | ||
109 | 106 | ||
110 | Modem::~Modem() | 107 | Modem::~Modem() |
111 | { | 108 | { |
112 | } | 109 | } |
113 | 110 | ||
114 | 111 | ||
115 | speed_t Modem::modemspeed() { | 112 | speed_t Modem::modemspeed() { |
116 | // convert the string modem speed int the gpppdata object to a t_speed type | 113 | // convert the string modem speed int the gpppdata object to a t_speed type |
117 | // to set the modem. The constants here should all be ifdef'd because | 114 | // to set the modem. The constants here should all be ifdef'd because |
118 | // other systems may not have them | 115 | // other systems may not have them |
119 | int i = _pppdata->speed().toInt()/100; | 116 | int i = _pppdata->speed().toInt()/100; |
120 | 117 | ||
121 | switch(i) { | 118 | switch(i) { |
122 | case 24: | 119 | case 24: |
123 | return B2400; | 120 | return B2400; |
124 | break; | 121 | break; |
125 | case 96: | 122 | case 96: |
126 | return B9600; | 123 | return B9600; |
127 | break; | 124 | break; |
128 | case 192: | 125 | case 192: |
129 | return B19200; | 126 | return B19200; |
130 | break; | 127 | break; |
131 | case 384: | 128 | case 384: |
132 | return B38400; | 129 | return B38400; |
133 | break; | 130 | break; |
134 | #ifdef B57600 | 131 | #ifdef B57600 |
135 | case 576: | 132 | case 576: |
136 | return B57600; | 133 | return B57600; |
137 | break; | 134 | break; |
138 | #endif | 135 | #endif |
139 | 136 | ||
140 | #ifdef B115200 | 137 | #ifdef B115200 |
141 | case 1152: | 138 | case 1152: |
142 | return B115200; | 139 | return B115200; |
143 | break; | 140 | break; |
144 | #endif | 141 | #endif |
145 | 142 | ||
146 | #ifdef B230400 | 143 | #ifdef B230400 |
147 | case 2304: | 144 | case 2304: |
148 | return B230400; | 145 | return B230400; |
149 | break; | 146 | break; |
150 | #endif | 147 | #endif |
151 | 148 | ||
152 | #ifdef B460800 | 149 | #ifdef B460800 |
153 | case 4608: | 150 | case 4608: |
154 | return B460800; | 151 | return B460800; |
155 | break; | 152 | break; |
156 | #endif | 153 | #endif |
157 | 154 | ||
158 | default: | 155 | default: |
159 | return B38400; | 156 | return B38400; |
160 | break; | 157 | break; |
161 | } | 158 | } |
162 | } | 159 | } |
163 | 160 | ||
164 | bool Modem::opentty() { | 161 | bool Modem::opentty() { |
165 | // int flags; | 162 | // int flags; |
166 | 163 | ||
167 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 164 | //begin if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
168 | close(modemfd); | 165 | close(modemfd); |
169 | device = _pppdata->modemDevice(); | 166 | device = _pppdata->modemDevice(); |
170 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { | 167 | if ((modemfd = open(device, O_RDWR|O_NDELAY|O_NOCTTY)) == -1) { |
171 | qDebug("error opening modem device !"); | 168 | qDebug("error opening modem device !"); |
172 | errmsg = i18n("Unable to open modem."); | 169 | errmsg = QObject::tr("Unable to open modem."); |
173 | return false; | 170 | return false; |
174 | } | 171 | } |
175 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { | 172 | //bend if((modemfd = Requester::rq->openModem(gpppdata.modemDevice()))<0) { |
176 | //} | 173 | //} |
177 | 174 | ||
178 | #if 0 | 175 | #if 0 |
179 | if(_pppdata->UseCDLine()) { | 176 | if(_pppdata->UseCDLine()) { |
180 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { | 177 | if(ioctl(modemfd, TIOCMGET, &flags) == -1) { |
181 | errmsg = i18n("Unable to detect state of CD line."); | 178 | errmsg = QObject::tr("Unable to detect state of CD line."); |
182 | ::close(modemfd); | 179 | ::close(modemfd); |
183 | modemfd = -1; | 180 | modemfd = -1; |
184 | return false; | 181 | return false; |
185 | } | 182 | } |
186 | if ((flags&TIOCM_CD) == 0) { | 183 | if ((flags&TIOCM_CD) == 0) { |
187 | errmsg = i18n("The modem is not ready."); | 184 | errmsg = QObject::tr("The modem is not ready."); |
188 | ::close(modemfd); | 185 | ::close(modemfd); |
189 | modemfd = -1; | 186 | modemfd = -1; |
190 | return false; | 187 | return false; |
191 | } | 188 | } |
192 | } | 189 | } |
193 | #endif | 190 | #endif |
194 | 191 | ||
195 | tcdrain (modemfd); | 192 | tcdrain (modemfd); |
196 | tcflush (modemfd, TCIOFLUSH); | 193 | tcflush (modemfd, TCIOFLUSH); |
197 | 194 | ||
198 | if(tcgetattr(modemfd, &tty) < 0){ | 195 | if(tcgetattr(modemfd, &tty) < 0){ |
199 | // this helps in some cases | 196 | // this helps in some cases |
200 | tcsendbreak(modemfd, 0); | 197 | tcsendbreak(modemfd, 0); |
201 | sleep(1); | 198 | sleep(1); |
202 | if(tcgetattr(modemfd, &tty) < 0){ | 199 | if(tcgetattr(modemfd, &tty) < 0){ |
203 | errmsg = i18n("The modem is busy."); | 200 | errmsg = QObject::tr("The modem is busy."); |
204 | ::close(modemfd); | 201 | ::close(modemfd); |
205 | modemfd = -1; | 202 | modemfd = -1; |
206 | return false; | 203 | return false; |
207 | } | 204 | } |
208 | } | 205 | } |
209 | 206 | ||
210 | memset(&initial_tty,'\0',sizeof(initial_tty)); | 207 | memset(&initial_tty,'\0',sizeof(initial_tty)); |
211 | 208 | ||
212 | initial_tty = tty; | 209 | initial_tty = tty; |
213 | 210 | ||
214 | tty.c_cc[VMIN] = 0; // nonblocking | 211 | tty.c_cc[VMIN] = 0; // nonblocking |
215 | tty.c_cc[VTIME] = 0; | 212 | tty.c_cc[VTIME] = 0; |
216 | tty.c_oflag = 0; | 213 | tty.c_oflag = 0; |
217 | tty.c_lflag = 0; | 214 | tty.c_lflag = 0; |
218 | 215 | ||
219 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); | 216 | tty.c_cflag &= ~(CSIZE | CSTOPB | PARENB); |
220 | tty.c_cflag |= CS8 | CREAD; | 217 | tty.c_cflag |= CS8 | CREAD; |
221 | tty.c_cflag |= CLOCAL; // ignore modem status lines | 218 | tty.c_cflag |= CLOCAL; // ignore modem status lines |
222 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; | 219 | tty.c_iflag = IGNBRK | IGNPAR /* | ISTRIP */ ; |
223 | tty.c_lflag &= ~ICANON; // non-canonical mode | 220 | tty.c_lflag &= ~ICANON; // non-canonical mode |
224 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); | 221 | tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHOKE); |
225 | 222 | ||
226 | 223 | ||
227 | if(_pppdata->flowcontrol() != "None") { | 224 | if(_pppdata->flowcontrol() != "None") { |
228 | if(_pppdata->flowcontrol() == "CRTSCTS") { | 225 | if(_pppdata->flowcontrol() == "CRTSCTS") { |
229 | tty.c_cflag |= CRTSCTS; | 226 | tty.c_cflag |= CRTSCTS; |
230 | } | 227 | } |
231 | else { | 228 | else { |
232 | tty.c_iflag |= IXON | IXOFF; | 229 | tty.c_iflag |= IXON | IXOFF; |
233 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ | 230 | tty.c_cc[VSTOP] = 0x13; /* DC3 = XOFF = ^S */ |
234 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ | 231 | tty.c_cc[VSTART] = 0x11; /* DC1 = XON = ^Q */ |
235 | } | 232 | } |
236 | } | 233 | } |
237 | else { | 234 | else { |
238 | tty.c_cflag &= ~CRTSCTS; | 235 | tty.c_cflag &= ~CRTSCTS; |
239 | tty.c_iflag &= ~(IXON | IXOFF); | 236 | tty.c_iflag &= ~(IXON | IXOFF); |
240 | } | 237 | } |
241 | 238 | ||
242 | cfsetospeed(&tty, modemspeed()); | 239 | cfsetospeed(&tty, modemspeed()); |
243 | cfsetispeed(&tty, modemspeed()); | 240 | cfsetispeed(&tty, modemspeed()); |
244 | 241 | ||
245 | tcdrain(modemfd); | 242 | tcdrain(modemfd); |
246 | 243 | ||
247 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ | 244 | if(tcsetattr(modemfd, TCSANOW, &tty) < 0){ |
248 | errmsg = i18n("The modem is busy."); | 245 | errmsg = QObject::tr("The modem is busy."); |
249 | ::close(modemfd); | 246 | ::close(modemfd); |
250 | modemfd=-1; | 247 | modemfd=-1; |
251 | return false; | 248 | return false; |
252 | } | 249 | } |
253 | 250 | ||
254 | errmsg = i18n("Modem Ready."); | 251 | errmsg = QObject::tr("Modem Ready."); |
255 | return true; | 252 | return true; |
256 | } | 253 | } |
257 | 254 | ||
258 | 255 | ||
259 | bool Modem::closetty() { | 256 | bool Modem::closetty() { |
260 | if(modemfd >=0 ) { | 257 | if(modemfd >=0 ) { |
261 | stop(); | 258 | stop(); |
262 | /* discard data not read or transmitted */ | 259 | /* discard data not read or transmitted */ |
263 | tcflush(modemfd, TCIOFLUSH); | 260 | tcflush(modemfd, TCIOFLUSH); |
264 | 261 | ||
265 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ | 262 | if(tcsetattr(modemfd, TCSANOW, &initial_tty) < 0){ |
266 | errmsg = i18n("Can't restore tty settings: tcsetattr()\n"); | 263 | errmsg = QObject::tr("Can't restore tty settings: tcsetattr()\n"); |
267 | ::close(modemfd); | 264 | ::close(modemfd); |
268 | modemfd = -1; | 265 | modemfd = -1; |
269 | return false; | 266 | return false; |
270 | } | 267 | } |
271 | ::close(modemfd); | 268 | ::close(modemfd); |
272 | modemfd = -1; | 269 | modemfd = -1; |
273 | } | 270 | } |
274 | 271 | ||
275 | return true; | 272 | return true; |
276 | } | 273 | } |
277 | 274 | ||
278 | 275 | ||
279 | void Modem::readtty(int) { | 276 | void Modem::readtty(int) { |
280 | char buffer[200]; | 277 | char buffer[200]; |
281 | unsigned char c; | 278 | unsigned char c; |
282 | int len; | 279 | int len; |
283 | 280 | ||
284 | // read data in chunks of up to 200 bytes | 281 | // read data in chunks of up to 200 bytes |
285 | if((len = ::read(modemfd, buffer, 200)) > 0) { | 282 | if((len = ::read(modemfd, buffer, 200)) > 0) { |
286 | // split buffer into single characters for further processing | 283 | // split buffer into single characters for further processing |
287 | for(int i = 0; i < len; i++) { | 284 | for(int i = 0; i < len; i++) { |
288 | c = buffer[i] & 0x7F; | 285 | c = buffer[i] & 0x7F; |
289 | emit charWaiting(c); | 286 | emit charWaiting(c); |
290 | } | 287 | } |
291 | } | 288 | } |
292 | } | 289 | } |
293 | 290 | ||
294 | 291 | ||
295 | void Modem::notify(const QObject *receiver, const char *member) { | 292 | void Modem::notify(const QObject *receiver, const char *member) { |
296 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); | 293 | connect(this, SIGNAL(charWaiting(unsigned char)), receiver, member); |
297 | startNotifier(); | 294 | startNotifier(); |
298 | } | 295 | } |
299 | 296 | ||
300 | 297 | ||
301 | void Modem::stop() { | 298 | void Modem::stop() { |
302 | disconnect(SIGNAL(charWaiting(unsigned char))); | 299 | disconnect(SIGNAL(charWaiting(unsigned char))); |
303 | stopNotifier(); | 300 | stopNotifier(); |
304 | } | 301 | } |
305 | 302 | ||
306 | 303 | ||
307 | void Modem::startNotifier() { | 304 | void Modem::startNotifier() { |
308 | if(modemfd >= 0) { | 305 | if(modemfd >= 0) { |
309 | if(sn == 0) { | 306 | if(sn == 0) { |
310 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); | 307 | sn = new QSocketNotifier(modemfd, QSocketNotifier::Read, this); |
311 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); | 308 | connect(sn, SIGNAL(activated(int)), SLOT(readtty(int))); |
312 | qDebug("QSocketNotifier started!"); | 309 | qDebug("QSocketNotifier started!"); |
313 | } else { | 310 | } else { |
314 | qDebug("QSocketNotifier re-enabled!"); | 311 | qDebug("QSocketNotifier re-enabled!"); |
315 | sn->setEnabled(true); | 312 | sn->setEnabled(true); |
316 | } | 313 | } |
317 | } | 314 | } |
318 | } | 315 | } |
319 | 316 | ||
320 | 317 | ||
321 | void Modem::stopNotifier() { | 318 | void Modem::stopNotifier() { |
322 | if(sn != 0) { | 319 | if(sn != 0) { |
323 | sn->setEnabled(false); | 320 | sn->setEnabled(false); |
324 | disconnect(sn); | 321 | disconnect(sn); |
325 | delete sn; | 322 | delete sn; |
326 | sn = 0; | 323 | sn = 0; |
327 | qDebug( "QSocketNotifier stopped!" ); | 324 | qDebug( "QSocketNotifier stopped!" ); |
328 | } | 325 | } |
329 | } | 326 | } |
330 | 327 | ||
331 | 328 | ||
332 | void Modem::flush() { | 329 | void Modem::flush() { |
333 | char c; | 330 | char c; |
334 | while(read(modemfd, &c, 1) == 1); | 331 | while(read(modemfd, &c, 1) == 1); |
335 | } | 332 | } |
336 | 333 | ||
337 | 334 | ||
338 | bool Modem::writeChar(unsigned char c) { | 335 | bool Modem::writeChar(unsigned char c) { |
339 | int s; | 336 | int s; |
340 | do { | 337 | do { |
341 | s = write(modemfd, &c, 1); | 338 | s = write(modemfd, &c, 1); |
342 | if (s < 0) { | 339 | if (s < 0) { |
343 | qError( "write() in Modem::writeChar failed" ); | 340 | qError( "write() in Modem::writeChar failed" ); |
344 | return false; | 341 | return false; |
345 | } | 342 | } |
346 | } while(s == 0); | 343 | } while(s == 0); |
347 | 344 | ||
348 | return true; | 345 | return true; |
349 | } | 346 | } |
350 | 347 | ||
351 | 348 | ||
352 | bool Modem::writeLine(const char *buf) { | 349 | bool Modem::writeLine(const char *buf) { |
353 | int len = strlen(buf); | 350 | int len = strlen(buf); |
354 | char *b = new char[len+2]; | 351 | char *b = new char[len+2]; |
355 | memcpy(b, buf, len); | 352 | memcpy(b, buf, len); |
356 | // different modems seem to need different line terminations | 353 | // different modems seem to need different line terminations |
357 | QString term = _pppdata->enter(); | 354 | QString term = _pppdata->enter(); |
358 | if(term == "LF") | 355 | if(term == "LF") |
359 | b[len++]='\n'; | 356 | b[len++]='\n'; |
360 | else if(term == "CR") | 357 | else if(term == "CR") |
361 | b[len++]='\r'; | 358 | b[len++]='\r'; |
362 | else if(term == "CR/LF") { | 359 | else if(term == "CR/LF") { |
363 | b[len++]='\r'; | 360 | b[len++]='\r'; |
364 | b[len++]='\n'; | 361 | b[len++]='\n'; |
365 | } | 362 | } |
366 | int l = len; | 363 | int l = len; |
367 | while(l) { | 364 | while(l) { |
368 | int wr = write(modemfd, &b[len-l], l); | 365 | int wr = write(modemfd, &b[len-l], l); |
369 | if(wr < 0) { | 366 | if(wr < 0) { |
370 | // TODO do something meaningful with the error code (or ignore it | 367 | // TODO do something meaningful with the error code (or ignore it |
371 | qError( "write() in Modem::writeLine failed" ); | 368 | qError( "write() in Modem::writeLine failed" ); |
372 | delete[] b; | 369 | delete[] b; |
373 | return false; | 370 | return false; |
374 | } | 371 | } |
375 | l -= wr; | 372 | l -= wr; |
376 | } | 373 | } |
377 | delete[] b; | 374 | delete[] b; |
378 | return true; | 375 | return true; |
379 | } | 376 | } |
380 | 377 | ||
381 | 378 | ||
382 | bool Modem::hangup() { | 379 | bool Modem::hangup() { |
383 | // this should really get the modem to hang up and go into command mode | 380 | // this should really get the modem to hang up and go into command mode |
384 | // If anyone sees a fault in the following please let me know, since | 381 | // If anyone sees a fault in the following please let me know, since |
385 | // this is probably the most imporant snippet of code in the whole of | 382 | // this is probably the most imporant snippet of code in the whole of |
386 | // kppp. If people complain about kppp being stuck, this piece of code | 383 | // kppp. If people complain about kppp being stuck, this piece of code |
387 | // is most likely the reason. | 384 | // is most likely the reason. |
388 | struct termios temptty; | 385 | struct termios temptty; |
389 | 386 | ||
390 | if(modemfd >= 0) { | 387 | if(modemfd >= 0) { |
391 | 388 | ||
392 | // is this Escape & HangupStr stuff really necessary ? (Harri) | 389 | // is this Escape & HangupStr stuff really necessary ? (Harri) |
393 | 390 | ||
394 | if (data_mode) escape_to_command_mode(); | 391 | if (data_mode) escape_to_command_mode(); |
395 | 392 | ||
396 | // Then hangup command | 393 | // Then hangup command |
397 | writeLine(_pppdata->modemHangupStr().local8Bit()); | 394 | writeLine(_pppdata->modemHangupStr().local8Bit()); |
398 | 395 | ||
399 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec | 396 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 sec |
400 | 397 | ||
401 | #ifndef DEBUG_WO_DIALING | 398 | #ifndef DEBUG_WO_DIALING |
402 | if (sigsetjmp(jmp_buffer, 1) == 0) { | 399 | if (sigsetjmp(jmp_buffer, 1) == 0) { |
403 | // set alarm in case tcsendbreak() hangs | 400 | // set alarm in case tcsendbreak() hangs |
404 | signal(SIGALRM, alarm_handler); | 401 | signal(SIGALRM, alarm_handler); |
405 | alarm(2); | 402 | alarm(2); |
406 | 403 | ||
407 | tcsendbreak(modemfd, 0); | 404 | tcsendbreak(modemfd, 0); |
408 | 405 | ||
409 | alarm(0); | 406 | alarm(0); |
410 | signal(SIGALRM, SIG_IGN); | 407 | signal(SIGALRM, SIG_IGN); |
411 | } else { | 408 | } else { |
412 | // we reach this point if the alarm handler got called | 409 | // we reach this point if the alarm handler got called |
413 | closetty(); | 410 | closetty(); |
414 | close(modemfd); | 411 | close(modemfd); |
415 | modemfd = -1; | 412 | modemfd = -1; |
416 | errmsg = i18n("The modem does not respond."); | 413 | errmsg = QObject::tr("The modem does not respond."); |
417 | return false; | 414 | return false; |
418 | } | 415 | } |
419 | 416 | ||
420 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. | 417 | #ifndef __svr4__ // drops DTR but doesn't set it afterwards again. not good for init. |
421 | tcgetattr(modemfd, &temptty); | 418 | tcgetattr(modemfd, &temptty); |
422 | cfsetospeed(&temptty, B0); | 419 | cfsetospeed(&temptty, B0); |
423 | cfsetispeed(&temptty, B0); | 420 | cfsetispeed(&temptty, B0); |
424 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 421 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
425 | #else | 422 | #else |
426 | int modemstat; | 423 | int modemstat; |
427 | ioctl(modemfd, TIOCMGET, &modemstat); | 424 | ioctl(modemfd, TIOCMGET, &modemstat); |
428 | modemstat &= ~TIOCM_DTR; | 425 | modemstat &= ~TIOCM_DTR; |
429 | ioctl(modemfd, TIOCMSET, &modemstat); | 426 | ioctl(modemfd, TIOCMSET, &modemstat); |
430 | ioctl(modemfd, TIOCMGET, &modemstat); | 427 | ioctl(modemfd, TIOCMGET, &modemstat); |
431 | modemstat |= TIOCM_DTR; | 428 | modemstat |= TIOCM_DTR; |
432 | ioctl(modemfd, TIOCMSET, &modemstat); | 429 | ioctl(modemfd, TIOCMSET, &modemstat); |
433 | #endif | 430 | #endif |
434 | 431 | ||
435 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs | 432 | usleep(_pppdata->modemInitDelay() * 10000); // 0.01 - 3.0 secs |
436 | 433 | ||
437 | cfsetospeed(&temptty, modemspeed()); | 434 | cfsetospeed(&temptty, modemspeed()); |
438 | cfsetispeed(&temptty, modemspeed()); | 435 | cfsetispeed(&temptty, modemspeed()); |
439 | tcsetattr(modemfd, TCSAFLUSH, &temptty); | 436 | tcsetattr(modemfd, TCSAFLUSH, &temptty); |
440 | #endif | 437 | #endif |
441 | return true; | 438 | return true; |
442 | } else | 439 | } else |
443 | return false; | 440 | return false; |
444 | } | 441 | } |
445 | 442 | ||
446 | 443 | ||
447 | void Modem::escape_to_command_mode() { | 444 | void Modem::escape_to_command_mode() { |
448 | // Send Properly bracketed escape code to put the modem back into command state. | 445 | // Send Properly bracketed escape code to put the modem back into command state. |
449 | // A modem will accept AT commands only when it is in command state. | 446 | // A modem will accept AT commands only when it is in command state. |
450 | // When a modem sends the host the CONNECT string, that signals | 447 | // When a modem sends the host the CONNECT string, that signals |
451 | // that the modem is now in the connect state (no long accepts AT commands.) | 448 | // that the modem is now in the connect state (no long accepts AT commands.) |
452 | // Need to send properly timed escape sequence to put modem in command state. | 449 | // Need to send properly timed escape sequence to put modem in command state. |
453 | // Escape codes and guard times are controlled by S2 and S12 values. | 450 | // Escape codes and guard times are controlled by S2 and S12 values. |
454 | // | 451 | // |
455 | tcflush(modemfd, TCIOFLUSH); | 452 | tcflush(modemfd, TCIOFLUSH); |
456 | 453 | ||
457 | // +3 because quiet time must be greater than guard time. | 454 | // +3 because quiet time must be greater than guard time. |
458 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); | 455 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
459 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); | 456 | QCString tmp = _pppdata->modemEscapeStr().local8Bit(); |
460 | write(modemfd, tmp.data(), tmp.length()); | 457 | write(modemfd, tmp.data(), tmp.length()); |
461 | tcflush(modemfd, TCIOFLUSH); | 458 | tcflush(modemfd, TCIOFLUSH); |
462 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); | 459 | usleep((_pppdata->modemEscapeGuardTime()+3)*20000); |
463 | 460 | ||
464 | data_mode = false; | 461 | data_mode = false; |
465 | } | 462 | } |
466 | 463 | ||
467 | 464 | ||
468 | const QString Modem::modemMessage() { | 465 | const QString Modem::modemMessage() { |
469 | return errmsg; | 466 | return errmsg; |
470 | } | 467 | } |
471 | 468 | ||
472 | 469 | ||
473 | QString Modem::parseModemSpeed(const QString &s) { | 470 | QString Modem::parseModemSpeed(const QString &s) { |
474 | // this is a small (and bad) parser for modem speeds | 471 | // this is a small (and bad) parser for modem speeds |
475 | int rx = -1; | 472 | int rx = -1; |
476 | int tx = -1; | 473 | int tx = -1; |
477 | int i; | 474 | int i; |
478 | QString result; | 475 | QString result; |
479 | 476 | ||
480 | qDebug( "Modem reported result string: %s", s.latin1()); | 477 | qDebug( "Modem reported result string: %s", s.latin1()); |
481 | 478 | ||
482 | const int RXMAX = 7; | 479 | const int RXMAX = 7; |
483 | const int TXMAX = 2; | 480 | const int TXMAX = 2; |
484 | QRegExp rrx[RXMAX] = { | 481 | QRegExp rrx[RXMAX] = { |
485 | QRegExp("[0-9]+[:/ ]RX", false), | 482 | QRegExp("[0-9]+[:/ ]RX", false), |
486 | QRegExp("[0-9]+RX", false), | 483 | QRegExp("[0-9]+RX", false), |
487 | QRegExp("[/: -][0-9]+[/: ]", false), | 484 | QRegExp("[/: -][0-9]+[/: ]", false), |
488 | QRegExp("[/: -][0-9]+$", false), | 485 | QRegExp("[/: -][0-9]+$", false), |
489 | QRegExp("CARRIER [^0-9]*[0-9]+", false), | 486 | QRegExp("CARRIER [^0-9]*[0-9]+", false), |
490 | QRegExp("CONNECT [^0-9]*[0-9]+", false), | 487 | QRegExp("CONNECT [^0-9]*[0-9]+", false), |
491 | QRegExp("[0-9]+") // panic mode | 488 | QRegExp("[0-9]+") // panic mode |
492 | }; | 489 | }; |
493 | 490 | ||
494 | QRegExp trx[TXMAX] = { | 491 | QRegExp trx[TXMAX] = { |
495 | QRegExp("[0-9]+[:/ ]TX", false), | 492 | QRegExp("[0-9]+[:/ ]TX", false), |
496 | QRegExp("[0-9]+TX", false) | 493 | QRegExp("[0-9]+TX", false) |
497 | }; | 494 | }; |
498 | 495 | ||
499 | for(i = 0; i < RXMAX; i++) { | 496 | for(i = 0; i < RXMAX; i++) { |
500 | int len, idx, result; | 497 | int len, idx, result; |
501 | if((idx = rrx[i].match(s,0,&len)) > -1) { | 498 | if((idx = rrx[i].match(s,0,&len)) > -1) { |
502 | // if((idx = rrx[i].search(s)) > -1) { | 499 | // if((idx = rrx[i].search(s)) > -1) { |
503 | // len = rrx[i].matchedLength(); | 500 | // len = rrx[i].matchedLength(); |
504 | 501 | ||
505 | // | 502 | // |
506 | // rrx[i] has been matched, idx contains the start of the match | 503 | // rrx[i] has been matched, idx contains the start of the match |
507 | // and len contains how long the match is. Extract the match. | 504 | // and len contains how long the match is. Extract the match. |
508 | // | 505 | // |
509 | QString sub = s.mid(idx, len); | 506 | QString sub = s.mid(idx, len); |
510 | 507 | ||
511 | // | 508 | // |
512 | // Now extract the digits only from the match, which will | 509 | // Now extract the digits only from the match, which will |
513 | // then be converted to an int. | 510 | // then be converted to an int. |
514 | // | 511 | // |
515 | if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { | 512 | if ((idx = rrx[RXMAX-1].match( sub,0,&len )) > -1) { |
516 | // if ((idx = rrx[RXMAX-1].search( sub )) > -1) { | 513 | // if ((idx = rrx[RXMAX-1].search( sub )) > -1) { |
517 | // len = rrx[RXMAX-1].matchedLength(); | 514 | // len = rrx[RXMAX-1].matchedLength(); |
518 | sub = sub.mid(idx, len); | 515 | sub = sub.mid(idx, len); |
519 | result = sub.toInt(); | 516 | result = sub.toInt(); |
520 | if(result > 0) { | 517 | if(result > 0) { |
521 | rx = result; | 518 | rx = result; |
522 | break; | 519 | break; |
523 | } | 520 | } |
524 | } | 521 | } |
525 | } | 522 | } |
526 | } | 523 | } |
527 | 524 | ||
528 | for(i = 0; i < TXMAX; i++) { | 525 | for(i = 0; i < TXMAX; i++) { |
529 | int len, idx, result; | 526 | int len, idx, result; |
530 | if((idx = trx[i].match(s,0,&len)) > -1) { | 527 | if((idx = trx[i].match(s,0,&len)) > -1) { |
531 | // if((idx = trx[i].search(s)) > -1) { | 528 | // if((idx = trx[i].search(s)) > -1) { |
532 | // len = trx[i].matchedLength(); | 529 | // len = trx[i].matchedLength(); |
533 | 530 | ||
534 | // | 531 | // |
535 | // trx[i] has been matched, idx contains the start of the match | 532 | // trx[i] has been matched, idx contains the start of the match |
536 | // and len contains how long the match is. Extract the match. | 533 | // and len contains how long the match is. Extract the match. |
537 | // | 534 | // |
538 | QString sub = s.mid(idx, len); | 535 | QString sub = s.mid(idx, len); |
539 | 536 | ||
540 | // | 537 | // |
541 | // Now extract the digits only from the match, which will then | 538 | // Now extract the digits only from the match, which will then |
542 | // be converted to an int. | 539 | // be converted to an int. |
543 | // | 540 | // |
544 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { | 541 | if((idx = rrx[RXMAX-1].match(sub,0,&len)) > -1) { |
545 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { | 542 | // if((idx = rrx[RXMAX-1].search(sub)) > -1) { |
546 | // len = rrx[RXMAX-1].matchedLength(); | 543 | // len = rrx[RXMAX-1].matchedLength(); |
547 | sub = sub.mid(idx, len); | 544 | sub = sub.mid(idx, len); |
548 | result = sub.toInt(); | 545 | result = sub.toInt(); |
549 | if(result > 0) { | 546 | if(result > 0) { |
550 | tx = result; | 547 | tx = result; |
551 | break; | 548 | break; |
552 | } | 549 | } |
553 | } | 550 | } |
554 | } | 551 | } |
555 | } | 552 | } |
556 | 553 | ||
557 | if(rx == -1 && tx == -1) | 554 | if(rx == -1 && tx == -1) |
558 | result = i18n("Unknown speed"); | 555 | result = QObject::tr("Unknown speed"); |
559 | else if(tx == -1) | 556 | else if(tx == -1) |
560 | result.setNum(rx); | 557 | result.setNum(rx); |
561 | else if(rx == -1) // should not happen | 558 | else if(rx == -1) // should not happen |
562 | result.setNum(tx); | 559 | result.setNum(tx); |
563 | else | 560 | else |
564 | result.sprintf("%d/%d", rx, tx); | 561 | result.sprintf("%d/%d", rx, tx); |
565 | 562 | ||
566 | qDebug( "The parsed result is: %s", result.latin1()); | 563 | qDebug( "The parsed result is: %s", result.latin1()); |
567 | 564 | ||
568 | return result; | 565 | return result; |
569 | } | 566 | } |
570 | 567 | ||
571 | 568 | ||
572 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if | 569 | // Lock modem device. Returns 0 on success 1 if the modem is locked and -1 if |
573 | // a lock file can't be created ( permission problem ) | 570 | // a lock file can't be created ( permission problem ) |
574 | int Modem::lockdevice() { | 571 | int Modem::lockdevice() { |
575 | int fd; | 572 | int fd; |
576 | char newlock[80]=""; // safe | 573 | char newlock[80]=""; // safe |
577 | 574 | ||
578 | if(!_pppdata->modemLockFile()) { | 575 | if(!_pppdata->modemLockFile()) { |
579 | qDebug("The user doesn't want a lockfile."); | 576 | qDebug("The user doesn't want a lockfile."); |
580 | return 0; | 577 | return 0; |
581 | } | 578 | } |
582 | 579 | ||
583 | if (modem_is_locked) | 580 | if (modem_is_locked) |
584 | return 1; | 581 | return 1; |
585 | 582 | ||
586 | QString lockfile = LOCK_DIR"/LCK.."; | 583 | QString lockfile = LOCK_DIR"/LCK.."; |
587 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ | 584 | lockfile += _pppdata->modemDevice().mid(5); // append everything after /dev/ |
588 | 585 | ||
589 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { | 586 | if(access(QFile::encodeName(lockfile), F_OK) == 0) { |
590 | // if ((fd = Requester::rq-> | 587 | // if ((fd = Requester::rq-> |
591 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { | 588 | if ((fd = openLockfile(QFile::encodeName(lockfile), O_RDONLY)) >= 0) { |
592 | // Mario: it's not necessary to read more than lets say 32 bytes. If | 589 | // Mario: it's not necessary to read more than lets say 32 bytes. If |
593 | // file has more than 32 bytes, skip the rest | 590 | // file has more than 32 bytes, skip the rest |
594 | char oldlock[33]; // safe | 591 | char oldlock[33]; // safe |
595 | int sz = read(fd, &oldlock, 32); | 592 | int sz = read(fd, &oldlock, 32); |
596 | close (fd); | 593 | close (fd); |
597 | if (sz <= 0) | 594 | if (sz <= 0) |
598 | return 1; | 595 | return 1; |
599 | oldlock[sz] = '\0'; | 596 | oldlock[sz] = '\0'; |
600 | 597 | ||
601 | qDebug( "Device is locked by: %s", oldlock); | 598 | qDebug( "Device is locked by: %s", oldlock); |
602 | 599 | ||
603 | int oldpid; | 600 | int oldpid; |
604 | int match = sscanf(oldlock, "%d", &oldpid); | 601 | int match = sscanf(oldlock, "%d", &oldpid); |
605 | 602 | ||
606 | // found a pid in lockfile ? | 603 | // found a pid in lockfile ? |
607 | if (match < 1 || oldpid <= 0) | 604 | if (match < 1 || oldpid <= 0) |
608 | return 1; | 605 | return 1; |
609 | 606 | ||
610 | // check if process exists | 607 | // check if process exists |
611 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) | 608 | if (kill((pid_t)oldpid, 0) == 0 || errno != ESRCH) |
612 | return 1; | 609 | return 1; |
613 | 610 | ||
614 | qDebug( "lockfile is stale" ); | 611 | qDebug( "lockfile is stale" ); |
615 | } | 612 | } |
616 | } | 613 | } |
617 | 614 | ||
618 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); | 615 | fd = openLockfile(_pppdata->modemDevice(),O_WRONLY|O_TRUNC|O_CREAT); |
619 | if(fd >= 0) { | 616 | if(fd >= 0) { |
620 | sprintf(newlock,"%010d\n", getpid()); | 617 | sprintf(newlock,"%010d\n", getpid()); |
621 | qDebug("Locking Device: %s", newlock); | 618 | qDebug("Locking Device: %s", newlock); |
622 | 619 | ||
623 | write(fd, newlock, strlen(newlock)); | 620 | write(fd, newlock, strlen(newlock)); |
624 | close(fd); | 621 | close(fd); |
625 | modem_is_locked=true; | 622 | modem_is_locked=true; |
626 | 623 | ||
627 | return 0; | 624 | return 0; |
628 | } | 625 | } |
629 | 626 | ||
630 | return -1; | 627 | return -1; |
631 | 628 | ||
632 | } | 629 | } |
633 | 630 | ||
634 | 631 | ||
635 | // UnLock modem device | 632 | // UnLock modem device |
636 | void Modem::unlockdevice() { | 633 | void Modem::unlockdevice() { |
637 | if (modem_is_locked) { | 634 | if (modem_is_locked) { |
638 | qDebug( "UnLocking Modem Device" ); | 635 | qDebug( "UnLocking Modem Device" ); |
639 | close(modemfd); | 636 | close(modemfd); |
640 | modemfd = -1; | 637 | modemfd = -1; |
641 | unlink(lockfile); | 638 | unlink(lockfile); |
642 | lockfile[0] = '\0'; | 639 | lockfile[0] = '\0'; |
643 | modem_is_locked=false; | 640 | modem_is_locked=false; |
644 | } | 641 | } |
645 | } | 642 | } |
646 | 643 | ||
647 | int Modem::openLockfile( QString lockfile, int flags) | 644 | int Modem::openLockfile( QString lockfile, int flags) |
648 | { | 645 | { |
649 | int fd; | 646 | int fd; |
650 | int mode; | 647 | int mode; |
651 | flags = O_RDONLY; | 648 | flags = O_RDONLY; |
652 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) | 649 | if(flags == O_WRONLY|O_TRUNC|O_CREAT) |
653 | mode = 0644; | 650 | mode = 0644; |
654 | else | 651 | else |
@@ -784,240 +781,300 @@ bool Modem::removeAuthFile(Auth method) { | |||
784 | } else | 781 | } else |
785 | return false; | 782 | return false; |
786 | } | 783 | } |
787 | 784 | ||
788 | 785 | ||
789 | bool Modem::setSecret(int method, const char* name, const char* password) | 786 | bool Modem::setSecret(int method, const char* name, const char* password) |
790 | { | 787 | { |
791 | 788 | ||
792 | Auth auth; | 789 | Auth auth; |
793 | if(method == AUTH_PAPCHAP) | 790 | if(method == AUTH_PAPCHAP) |
794 | return setSecret(AUTH_PAP, name, password) && | 791 | return setSecret(AUTH_PAP, name, password) && |
795 | setSecret(AUTH_CHAP, name, password); | 792 | setSecret(AUTH_CHAP, name, password); |
796 | 793 | ||
797 | switch(method) { | 794 | switch(method) { |
798 | case AUTH_PAP: | 795 | case AUTH_PAP: |
799 | auth = Modem::PAP; | 796 | auth = Modem::PAP; |
800 | break; | 797 | break; |
801 | case AUTH_CHAP: | 798 | case AUTH_CHAP: |
802 | auth = Modem::CHAP; | 799 | auth = Modem::CHAP; |
803 | break; | 800 | break; |
804 | default: | 801 | default: |
805 | return false; | 802 | return false; |
806 | } | 803 | } |
807 | 804 | ||
808 | return createAuthFile(auth, name, password); | 805 | return createAuthFile(auth, name, password); |
809 | 806 | ||
810 | } | 807 | } |
811 | 808 | ||
812 | bool Modem::removeSecret(int method) | 809 | bool Modem::removeSecret(int method) |
813 | { | 810 | { |
814 | Auth auth; | 811 | Auth auth; |
815 | 812 | ||
816 | switch(method) { | 813 | switch(method) { |
817 | case AUTH_PAP: | 814 | case AUTH_PAP: |
818 | auth = Modem::PAP; | 815 | auth = Modem::PAP; |
819 | break; | 816 | break; |
820 | case AUTH_CHAP: | 817 | case AUTH_CHAP: |
821 | auth = Modem::CHAP; | 818 | auth = Modem::CHAP; |
822 | break; | 819 | break; |
823 | default: | 820 | default: |
824 | return false; | 821 | return false; |
825 | } | 822 | } |
826 | return removeAuthFile( auth ); | 823 | return removeAuthFile( auth ); |
827 | } | 824 | } |
828 | 825 | ||
829 | int checkForInterface() | 826 | int checkForInterface() |
830 | { | 827 | { |
831 | // I don't know if Linux needs more initialization to get the ioctl to | 828 | // I don't know if Linux needs more initialization to get the ioctl to |
832 | // work, pppd seems to hint it does. But BSD doesn't, and the following | 829 | // work, pppd seems to hint it does. But BSD doesn't, and the following |
833 | // code should compile. | 830 | // code should compile. |
834 | #if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) | 831 | #if (defined(HAVE_NET_IF_PPP_H) || defined(HAVE_LINUX_IF_PPP_H)) && !defined(__svr4__) |
835 | int s, ok; | 832 | int s, ok; |
836 | struct ifreq ifr; | 833 | struct ifreq ifr; |
837 | // extern char *no_ppp_msg; | 834 | // extern char *no_ppp_msg; |
838 | 835 | ||
839 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | 836 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) |
840 | return 1; /* can't tell */ | 837 | return 1; /* can't tell */ |
841 | 838 | ||
842 | strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); | 839 | strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); |
843 | ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; | 840 | ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; |
844 | close(s); | 841 | close(s); |
845 | 842 | ||
846 | if (ok == -1) { | 843 | if (ok == -1) { |
847 | // This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports | 844 | // This is ifdef'd FreeBSD, because FreeBSD is the only BSD that supports |
848 | // KLDs, the old LKM interface couldn't handle loading devices | 845 | // KLDs, the old LKM interface couldn't handle loading devices |
849 | // dynamically, and thus can't load ppp support on the fly | 846 | // dynamically, and thus can't load ppp support on the fly |
850 | #ifdef __FreeBSD__ | 847 | #ifdef __FreeBSD__ |
851 | // If we failed to load ppp support and don't have it already. | 848 | // If we failed to load ppp support and don't have it already. |
852 | if (kldload("if_ppp") == -1) { | 849 | if (kldload("if_ppp") == -1) { |
853 | return -1; | 850 | return -1; |
854 | } | 851 | } |
855 | return 0; | 852 | return 0; |
856 | #else | 853 | #else |
857 | return -1; | 854 | return -1; |
858 | #endif | 855 | #endif |
859 | } | 856 | } |
860 | return 0; | 857 | return 0; |
861 | #else | 858 | #else |
862 | // We attempt to use the SunOS/SysVr4 method and stat /dev/ppp | 859 | // We attempt to use the SunOS/SysVr4 method and stat /dev/ppp |
863 | struct stat buf; | 860 | struct stat buf; |
864 | 861 | ||
865 | memset(&buf, 0, sizeof(buf)); | 862 | memset(&buf, 0, sizeof(buf)); |
866 | return stat("/dev/ppp", &buf); | 863 | return stat("/dev/ppp", &buf); |
867 | #endif | 864 | #endif |
868 | } | 865 | } |
869 | 866 | ||
870 | bool Modem::execpppd(const char *arguments) { | 867 | bool Modem::execpppd(const char *arguments) { |
871 | char buf[MAX_CMDLEN]; | 868 | char buf[MAX_CMDLEN]; |
872 | char *args[MaxArgs]; | 869 | char *args[MaxArgs]; |
873 | pid_t pgrpid; | 870 | pid_t pgrpid; |
874 | 871 | ||
875 | if(modemfd<0) | 872 | if(modemfd<0) |
876 | return false; | 873 | return false; |
877 | 874 | ||
878 | _pppdExitStatus = -1; | 875 | _pppdExitStatus = -1; |
879 | 876 | ||
877 | (void)::pipe( m_pppdLOG ); | ||
878 | |||
880 | switch(pppdPid = fork()) | 879 | switch(pppdPid = fork()) |
881 | { | 880 | { |
882 | case -1: | 881 | case -1: |
883 | fprintf(stderr,"In parent: fork() failed\n"); | 882 | fprintf(stderr,"In parent: fork() failed\n"); |
883 | ::close( m_pppdLOG[0] ); | ||
884 | ::close( m_pppdLOG[1] ); | ||
884 | return false; | 885 | return false; |
885 | break; | 886 | break; |
886 | 887 | ||
887 | case 0: | 888 | case 0: |
888 | // let's parse the arguments the user supplied into UNIX suitable form | 889 | // let's parse the arguments the user supplied into UNIX suitable form |
889 | // that is a list of pointers each pointing to exactly one word | 890 | // that is a list of pointers each pointing to exactly one word |
890 | strlcpy(buf, arguments); | 891 | strlcpy(buf, arguments); |
891 | parseargs(buf, args); | 892 | parseargs(buf, args); |
892 | // become a session leader and let /dev/ttySx | 893 | // become a session leader and let /dev/ttySx |
893 | // be the controlling terminal. | 894 | // be the controlling terminal. |
894 | pgrpid = setsid(); | 895 | pgrpid = setsid(); |
895 | #ifdef TIOCSCTTY | 896 | #ifdef TIOCSCTTY |
896 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) | 897 | if(ioctl(modemfd, TIOCSCTTY, 0)<0) |
897 | fprintf(stderr, "ioctl() failed.\n"); | 898 | fprintf(stderr, "ioctl() failed.\n"); |
898 | #elif defined (TIOCSPGRP) | 899 | #elif defined (TIOCSPGRP) |
899 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) | 900 | if(ioctl(modemfd, TIOCSPGRP, &pgrpid)<0) |
900 | fprintf(stderr, "ioctl() failed.\n"); | 901 | fprintf(stderr, "ioctl() failed.\n"); |
901 | #endif | 902 | #endif |
902 | if(tcsetpgrp(modemfd, pgrpid)<0) | 903 | if(tcsetpgrp(modemfd, pgrpid)<0) |
903 | fprintf(stderr, "tcsetpgrp() failed.\n"); | 904 | fprintf(stderr, "tcsetpgrp() failed.\n"); |
904 | 905 | ||
906 | ::close( m_pppdLOG[0] ); | ||
907 | ::setenv( "LANG", "C", 1 ); // overwrite | ||
908 | dup2(m_pppdLOG[1], 11 ); // for logfd 11 | ||
905 | dup2(modemfd, 0); | 909 | dup2(modemfd, 0); |
906 | dup2(modemfd, 1); | 910 | dup2(modemfd, 1); |
907 | 911 | ||
912 | |||
908 | switch (checkForInterface()) { | 913 | switch (checkForInterface()) { |
909 | case 1: | 914 | case 1: |
910 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); | 915 | fprintf(stderr, "Cannot determine if kernel supports ppp.\n"); |
911 | break; | 916 | break; |
912 | case -1: | 917 | case -1: |
913 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); | 918 | fprintf(stderr, "Kernel does not support ppp, oops.\n"); |
914 | break; | 919 | break; |
915 | case 0: | 920 | case 0: |
916 | fprintf(stderr, "Kernel supports ppp alright.\n"); | 921 | fprintf(stderr, "Kernel supports ppp alright.\n"); |
917 | break; | 922 | break; |
918 | } | 923 | } |
919 | 924 | ||
920 | execve(pppdPath(), args, 0L); | 925 | execve(pppdPath(), args, 0L); |
921 | _exit(0); | 926 | _exit(0); |
922 | break; | 927 | break; |
923 | 928 | ||
924 | default: | 929 | default: |
925 | qDebug("In parent: pppd pid %d\n",pppdPid); | 930 | qDebug("In parent: pppd pid %d\n",pppdPid); |
926 | close(modemfd); | 931 | close(modemfd); |
932 | |||
933 | ::close( m_pppdLOG[1] ); | ||
934 | // set it to nonblocking io | ||
935 | int flag = ::fcntl( m_pppdLOG[0], F_GETFL ); | ||
936 | |||
937 | if ( !(flag & O_NONBLOCK) ) { | ||
938 | qDebug("Setting nonblocking io"); | ||
939 | flag |= O_NONBLOCK; | ||
940 | ::fcntl(m_pppdLOG[0], F_SETFL, flag ); | ||
941 | } | ||
942 | |||
943 | delete m_modemDebug; | ||
944 | m_modemDebug = new QSocketNotifier(m_pppdLOG[0], QSocketNotifier::Read, this ); | ||
945 | connect(m_modemDebug, SIGNAL(activated(int) ), | ||
946 | this, SLOT(slotModemDebug(int) ) ); | ||
947 | |||
927 | modemfd = -1; | 948 | modemfd = -1; |
949 | m_pppdDev = QString::fromLatin1("ppp0"); | ||
928 | return true; | 950 | return true; |
929 | break; | 951 | break; |
930 | } | 952 | } |
931 | } | 953 | } |
932 | 954 | ||
933 | 955 | ||
934 | bool Modem::killpppd() { | 956 | bool Modem::killpppd() { |
957 | qDebug("In killpppd and pid is %d", pppdPid ); | ||
935 | if(pppdPid > 0) { | 958 | if(pppdPid > 0) { |
959 | delete m_modemDebug; | ||
960 | m_modemDebug = 0; | ||
936 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); | 961 | qDebug("In killpppd(): Sending SIGTERM to %d\n", pppdPid); |
937 | if(kill(pppdPid, SIGTERM) < 0) { | 962 | if(kill(pppdPid, SIGTERM) < 0) { |
938 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); | 963 | qDebug("Error terminating %d. Sending SIGKILL\n", pppdPid); |
939 | if(kill(pppdPid, SIGKILL) < 0) { | 964 | if(kill(pppdPid, SIGKILL) < 0) { |
940 | qDebug("Error killing %d\n", pppdPid); | 965 | qDebug("Error killing %d\n", pppdPid); |
941 | return false; | 966 | return false; |
942 | } | 967 | } |
943 | } | 968 | } |
944 | } | 969 | } |
945 | return true; | 970 | return true; |
946 | } | 971 | } |
947 | 972 | ||
948 | 973 | ||
949 | void Modem::parseargs(char* buf, char** args) { | 974 | void Modem::parseargs(char* buf, char** args) { |
950 | int nargs = 0; | 975 | int nargs = 0; |
951 | int quotes; | 976 | int quotes; |
952 | 977 | ||
953 | while(nargs < MaxArgs-1 && *buf != '\0') { | 978 | while(nargs < MaxArgs-1 && *buf != '\0') { |
954 | 979 | ||
955 | quotes = 0; | 980 | quotes = 0; |
956 | 981 | ||
957 | // Strip whitespace. Use nulls, so that the previous argument is | 982 | // Strip whitespace. Use nulls, so that the previous argument is |
958 | // terminated automatically. | 983 | // terminated automatically. |
959 | 984 | ||
960 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) | 985 | while ((*buf == ' ' ) || (*buf == '\t' ) || (*buf == '\n' ) ) |
961 | *buf++ = '\0'; | 986 | *buf++ = '\0'; |
962 | 987 | ||
963 | // detect begin of quoted argument | 988 | // detect begin of quoted argument |
964 | if (*buf == '"' || *buf == '\'') { | 989 | if (*buf == '"' || *buf == '\'') { |
965 | quotes = *buf; | 990 | quotes = *buf; |
966 | *buf++ = '\0'; | 991 | *buf++ = '\0'; |
967 | } | 992 | } |
968 | 993 | ||
969 | // save the argument | 994 | // save the argument |
970 | if(*buf != '\0') { | 995 | if(*buf != '\0') { |
971 | *args++ = buf; | 996 | *args++ = buf; |
972 | nargs++; | 997 | nargs++; |
973 | } | 998 | } |
974 | 999 | ||
975 | if (!quotes) | 1000 | if (!quotes) |
976 | while ((*buf != '\0') && (*buf != '\n') && | 1001 | while ((*buf != '\0') && (*buf != '\n') && |
977 | (*buf != '\t') && (*buf != ' ')) | 1002 | (*buf != '\t') && (*buf != ' ')) |
978 | buf++; | 1003 | buf++; |
979 | else { | 1004 | else { |
980 | while ((*buf != '\0') && (*buf != quotes)) | 1005 | while ((*buf != '\0') && (*buf != quotes)) |
981 | buf++; | 1006 | buf++; |
982 | *buf++ = '\0'; | 1007 | *buf++ = '\0'; |
983 | } | 1008 | } |
984 | } | 1009 | } |
985 | 1010 | ||
986 | *args = 0L; | 1011 | *args = 0L; |
987 | } | 1012 | } |
988 | 1013 | ||
989 | bool Modem::execPPPDaemon(const QString & arguments) | 1014 | bool Modem::execPPPDaemon(const QString & arguments) |
990 | { | 1015 | { |
991 | if(execpppd(arguments)) { | 1016 | if(execpppd(arguments)) { |
992 | _pppdata->setpppdRunning(true); | 1017 | _pppdata->setpppdRunning(true); |
993 | return true; | 1018 | return true; |
994 | } else | 1019 | } else |
995 | return false; | 1020 | return false; |
996 | } | 1021 | } |
997 | 1022 | ||
998 | void Modem::killPPPDaemon() | 1023 | void Modem::killPPPDaemon() |
999 | { | 1024 | { |
1000 | _pppdata->setpppdRunning(false); | 1025 | _pppdata->setpppdRunning(false); |
1001 | killpppd(); | 1026 | killpppd(); |
1002 | } | 1027 | } |
1003 | 1028 | ||
1004 | int Modem::pppdExitStatus() | 1029 | int Modem::pppdExitStatus() |
1005 | { | 1030 | { |
1006 | return _pppdExitStatus; | 1031 | return _pppdExitStatus; |
1007 | } | 1032 | } |
1008 | 1033 | ||
1009 | int Modem::openResolv(int flags) | 1034 | int Modem::openResolv(int flags) |
1010 | { | 1035 | { |
1011 | int fd; | 1036 | int fd; |
1012 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { | 1037 | if ((fd = open(_PATH_RESCONF, flags)) == -1) { |
1013 | qDebug("error opening resolv.conf!"); | 1038 | qDebug("error opening resolv.conf!"); |
1014 | fd = open(DEVNULL, O_RDONLY); | 1039 | fd = open(DEVNULL, O_RDONLY); |
1015 | } | 1040 | } |
1016 | return fd; | 1041 | return fd; |
1017 | } | 1042 | } |
1018 | 1043 | ||
1019 | bool Modem::setHostname(const QString & name) | 1044 | bool Modem::setHostname(const QString & name) |
1020 | { | 1045 | { |
1021 | return sethostname(name, name.length()) == 0; | 1046 | return sethostname(name, name.length()) == 0; |
1022 | } | 1047 | } |
1023 | 1048 | ||
1049 | QString Modem::pppDevice()const { | ||
1050 | return m_pppdDev; | ||
1051 | } | ||
1052 | void Modem::setPPPDevice( const QString& dev ) { | ||
1053 | m_pppdDev = dev; | ||
1054 | } | ||
1055 | pid_t Modem::pppPID()const { | ||
1056 | return pppdPid; | ||
1057 | } | ||
1058 | void Modem::setPPPDPid( pid_t pid ) { | ||
1059 | qDebug("Modem setting pid"); | ||
1060 | _pppdExitStatus = -1; | ||
1061 | pppdPid = pid; | ||
1062 | modemfd = -1; | ||
1063 | } | ||
1064 | void Modem::slotModemDebug(int fd) { | ||
1065 | char buf[2049]; | ||
1066 | int len; | ||
1067 | |||
1068 | // read in pppd data look for Using interface | ||
1069 | // then read the interface | ||
1070 | // we limit to 10 device now 0-9 | ||
1071 | if((len = ::read(fd, buf, 2048)) > 0) { | ||
1072 | buf[len+1] = '\0'; | ||
1073 | char *found; | ||
1074 | if ( (found = ::strstr(buf, "Using interface ") ) ) { | ||
1075 | found += 16; | ||
1076 | m_pppdDev = QString::fromLatin1(found, 5 ); | ||
1077 | m_pppdDev = m_pppdDev.simplifyWhiteSpace(); | ||
1078 | } | ||
1079 | } | ||
1080 | } | ||
diff --git a/noncore/settings/networksettings/ppp/modem.h b/noncore/settings/networksettings/ppp/modem.h index 103cbeb..8ecc354 100644 --- a/noncore/settings/networksettings/ppp/modem.h +++ b/noncore/settings/networksettings/ppp/modem.h | |||
@@ -1,120 +1,131 @@ | |||
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 | * This file was added by Harri Porten <porten@tu-harburg.de> | 9 | * This file was added by Harri Porten <porten@tu-harburg.de> |
10 | * | 10 | * |
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 | #ifndef _MODEM_H_ | 27 | #ifndef _MODEM_H_ |
28 | #define _MODEM_H_ | 28 | #define _MODEM_H_ |
29 | 29 | ||
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | 31 | ||
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #include <termios.h> | 33 | #include <termios.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | 35 | ||
36 | #include <qsocketnotifier.h> | 36 | #include <qsocketnotifier.h> |
37 | 37 | ||
38 | class PPPData; | 38 | class PPPData; |
39 | 39 | ||
40 | void alarm_handler(int); | 40 | void alarm_handler(int); |
41 | const char *pppdPath(); | 41 | const char *pppdPath(); |
42 | 42 | ||
43 | class Modem : public QObject { | 43 | class Modem : public QObject { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | Modem(PPPData*); | 46 | Modem(PPPData*); |
47 | ~Modem(); | 47 | ~Modem(); |
48 | 48 | ||
49 | const QString getDevice() {return device;}; | 49 | const QString getDevice() {return device;}; |
50 | void setDevice(const QString dev) {device = dev;}; | 50 | void setDevice(const QString dev) {device = dev;}; |
51 | |||
52 | void save(); | ||
51 | 53 | ||
52 | bool opentty(); | 54 | bool opentty(); |
53 | bool closetty(); | 55 | bool closetty(); |
54 | bool hangup(); | 56 | bool hangup(); |
55 | bool writeChar(unsigned char); | 57 | bool writeChar(unsigned char); |
56 | bool writeLine(const char *); | 58 | bool writeLine(const char *); |
57 | bool dataMode() const { return data_mode; } | 59 | bool dataMode() const { return data_mode; } |
58 | void setDataMode(bool set) { data_mode = set; } | 60 | void setDataMode(bool set) { data_mode = set; } |
59 | const QString modemMessage(); | 61 | const QString modemMessage(); |
60 | speed_t modemspeed(); | 62 | speed_t modemspeed(); |
61 | static QString parseModemSpeed(const QString &); | 63 | static QString parseModemSpeed(const QString &); |
62 | void notify(const QObject *, const char *); | 64 | void notify(const QObject *, const char *); |
63 | void stop(); | 65 | void stop(); |
64 | void flush(); | 66 | void flush(); |
65 | 67 | ||
66 | int lockdevice(); | 68 | int lockdevice(); |
67 | void unlockdevice(); | 69 | void unlockdevice(); |
68 | 70 | ||
69 | bool setSecret(int,const char*,const char*); | 71 | bool setSecret(int,const char*,const char*); |
70 | bool removeSecret(int); | 72 | bool removeSecret(int); |
71 | void killPPPDaemon(); | 73 | void killPPPDaemon(); |
72 | int pppdExitStatus(); | 74 | int pppdExitStatus(); |
73 | bool execPPPDaemon(const QString & arguments); | 75 | bool execPPPDaemon(const QString & arguments); |
74 | int openResolv(int flags); | 76 | int openResolv(int flags); |
75 | bool setHostname(const QString & name); | 77 | bool setHostname(const QString & name); |
76 | 78 | ||
79 | QString pppDevice()const; | ||
80 | void setPPPDevice( const QString& ); | ||
81 | pid_t pppPID()const; | ||
82 | void setPPPDPid( pid_t ); | ||
83 | |||
77 | public: | 84 | public: |
78 | enum Auth { PAP = 1, CHAP }; | 85 | enum Auth { PAP = 1, CHAP }; |
79 | // static Modem *modem; | 86 | // static Modem *modem; |
80 | int lastStatus; | 87 | int lastStatus; |
81 | 88 | ||
82 | signals: | 89 | signals: |
83 | void charWaiting(unsigned char); | 90 | void charWaiting(unsigned char); |
84 | 91 | ||
85 | private slots: | 92 | private slots: |
86 | void startNotifier(); | 93 | void startNotifier(); |
87 | void stopNotifier(); | 94 | void stopNotifier(); |
88 | void readtty(int); | 95 | void readtty(int); |
96 | void slotModemDebug(int); | ||
89 | 97 | ||
90 | private: | 98 | private: |
91 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; | 99 | enum { MaxPathLen = 30, MaxStrLen = 40, MaxArgs = 100 }; |
92 | enum { Original=0x100, New=0x200, Old=0x400 } Version; | 100 | enum { Original=0x100, New=0x200, Old=0x400 } Version; |
93 | 101 | ||
94 | const char* authFile(Auth method, int version = Original ); | 102 | const char* authFile(Auth method, int version = Original ); |
95 | bool createAuthFile(Auth method,const char *username,const char *password); | 103 | bool createAuthFile(Auth method,const char *username,const char *password); |
96 | bool removeAuthFile(Auth method); | 104 | bool removeAuthFile(Auth method); |
97 | bool execpppd(const char *arguments); | 105 | bool execpppd(const char *arguments); |
98 | bool killpppd(); | 106 | bool killpppd(); |
99 | void parseargs(char* buf, char** args); | 107 | void parseargs(char* buf, char** args); |
100 | void escape_to_command_mode(); | 108 | void escape_to_command_mode(); |
101 | int openLockfile(QString,int); | 109 | int openLockfile(QString,int); |
102 | 110 | ||
103 | private: | 111 | private: |
104 | QString device; | 112 | QString device; |
105 | QString lockfile; | 113 | QString lockfile; |
106 | int modemfd; | 114 | int modemfd; |
107 | int pppdPid; | 115 | int pppdPid; |
108 | int _pppdExitStatus; | 116 | int _pppdExitStatus; |
109 | QSocketNotifier *sn; | 117 | QSocketNotifier *sn; |
118 | QSocketNotifier *m_modemDebug; | ||
110 | bool data_mode; | 119 | bool data_mode; |
111 | QString errmsg; | 120 | QString errmsg; |
112 | struct termios initial_tty; | 121 | struct termios initial_tty; |
113 | struct termios tty; | 122 | struct termios tty; |
114 | bool modem_is_locked; | 123 | bool modem_is_locked; |
115 | PPPData *_pppdata; | 124 | PPPData *_pppdata; |
125 | int m_pppdLOG[2]; | ||
126 | QString m_pppdDev; | ||
116 | }; | 127 | }; |
117 | 128 | ||
118 | #endif | 129 | #endif |
119 | 130 | ||
120 | 131 | ||
diff --git a/noncore/settings/networksettings/ppp/modemcmds.cpp b/noncore/settings/networksettings/ppp/modemcmds.cpp index 1d9db6e..e797795 100644 --- a/noncore/settings/networksettings/ppp/modemcmds.cpp +++ b/noncore/settings/networksettings/ppp/modemcmds.cpp | |||
@@ -1,318 +1,333 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A front end for pppd for the KDE project | 2 | * kPPP: A front end for pppd 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 library is free software; you can redistribute it and/or | 12 | * This library 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 library is distributed in the hope that it will be useful, | 17 | * This library 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 dummyWidget program; if not, write to the Free | 23 | * License along with dummyWidget 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 <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qslider.h> | 28 | #include <qslider.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | #include <qscrollview.h> | ||
31 | #include <qapplication.h> | ||
30 | #include <stdlib.h> | 32 | #include <stdlib.h> |
31 | //#include <kapplication.h> // for getMiniIcon() | ||
32 | //#include <klocale.h> | ||
33 | #define i18n QObject::tr | ||
34 | #include "modemcmds.h" | 33 | #include "modemcmds.h" |
35 | #include "pppdata.h" | 34 | #include "pppdata.h" |
36 | //#include <kwin.h> | ||
37 | 35 | ||
38 | #define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); | 36 | #define ADJUSTEDIT(e) //e->setText("XXXXXXXXqy"); e->setMinimumSize(e->sizeHint()); /*e->setFixedHeight(e->sizeHint().height());*/ e->setText(""); e->setMaxLength(MODEMSTR_SIZE); |
39 | 37 | ||
40 | // a little trick to make the label look like a disabled lineedit | 38 | // a little trick to make the label look like a disabled lineedit |
41 | #define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2); | 39 | #define FORMATSLIDERLABEL(l) //l->setFixedWidth(l->sizeHint().width()); l->setFixedHeight(QLineEdit(dummyWidget).sizeHint().height()); l->setAlignment(AlignCenter); l->setFrameStyle(QFrame::WinPanel|QFrame::Sunken); l->setLineWidth(2); |
42 | 40 | ||
43 | ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name) | 41 | ModemCommands::ModemCommands(PPPData *pd, QWidget *parent, const char *name , bool modal, WFlags f) |
44 | : QDialog(parent, name, true ), _pppdata(pd) | 42 | : QDialog( parent, name, modal, f ), _pppdata(pd) |
45 | { | 43 | { |
46 | setCaption(i18n("Edit Modem Commands")); | 44 | setCaption(QObject::tr("Edit Modem Commands")); |
47 | 45 | ||
48 | const int GRIDROWS = 22; | 46 | const int GRIDROWS = 22; |
49 | int row = 0; | 47 | int row = 0; |
50 | 48 | ||
49 | QVBoxLayout *main = new QVBoxLayout( this ); | ||
50 | QScrollView *sv = new QScrollView( this ); | ||
51 | QWidget *mainW = new QWidget( sv->viewport() ); | ||
52 | sv->setResizePolicy( QScrollView::AutoOneFit ); | ||
53 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | ||
54 | sv->setFrameShape( QFrame::NoFrame ); | ||
55 | sv->addChild( mainW ); | ||
56 | main->addWidget( sv ); | ||
57 | // evil hack | ||
58 | mainW->setMaximumWidth( QApplication::desktop()->width() - 10 ); | ||
59 | |||
51 | // toplevel layout | 60 | // toplevel layout |
52 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 4); | 61 | QVBoxLayout *tl = new QVBoxLayout( mainW, 10, 4); |
53 | 62 | ||
54 | // add grid + frame | 63 | // add grid + frame |
55 | QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); | 64 | QGridLayout *l1 = new QGridLayout(GRIDROWS, 4); |
56 | tl->addLayout(l1); | 65 | tl->addLayout(l1); |
57 | box = new QGroupBox(this, "box"); | 66 | box = new QGroupBox(mainW, "box"); |
67 | box->setMargin( 0 ); | ||
58 | l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); | 68 | l1->addMultiCellWidget(box, row++, GRIDROWS, 0, 3); |
59 | 69 | ||
60 | // put slider and label into a separate H-Box | 70 | // put slider and label into a separate H-Box |
61 | QHBoxLayout *l2 = new QHBoxLayout; | 71 | QHBoxLayout *l2 = new QHBoxLayout; |
62 | l1->addLayout(l2, row, 2); | 72 | l1->addLayout(l2, row, 2); |
63 | lpreinitslider = new QLabel("MMMM", this); | 73 | lpreinitslider = new QLabel("MMMM", mainW); |
64 | FORMATSLIDERLABEL(lpreinitslider); | 74 | FORMATSLIDERLABEL(lpreinitslider); |
65 | 75 | ||
66 | QSlider *preinitslider = new QSlider(0, 300, 1, 0, | 76 | QSlider *preinitslider = new QSlider(0, 300, 1, 0, |
67 | QSlider::Horizontal, this); | 77 | QSlider::Horizontal, mainW); |
68 | // preinitslider->setFixedHeight(preinitslider->sizeHint().height()); | 78 | // preinitslider->setFixedHeight(preinitslider->sizeHint().height()); |
69 | connect(preinitslider, SIGNAL(valueChanged(int)), | 79 | connect(preinitslider, SIGNAL(valueChanged(int)), |
70 | lpreinitslider, SLOT(setNum(int))); | 80 | lpreinitslider, SLOT(setNum(int))); |
71 | l2->addWidget(lpreinitslider, 0); | 81 | l2->addWidget(lpreinitslider, 0); |
72 | l2->addWidget(preinitslider, 1); | 82 | l2->addWidget(preinitslider, 1); |
73 | 83 | ||
74 | lpreinit = new QLabel(i18n("Pre-init delay (sec/100):"), this); | 84 | lpreinit = new QLabel(QObject::tr("Pre-init delay (sec/100):"), mainW); |
75 | l1->addWidget(lpreinit, row++, 1); | 85 | l1->addWidget(lpreinit, row++, 1); |
76 | 86 | ||
77 | for(int i = 0; i < PPPData::NumInitStrings; i++) { | 87 | for(int i = 0; i < PPPData::NumInitStrings; i++) { |
78 | initstr[i] = new QLineEdit(this); | 88 | initstr[i] = new QLineEdit(mainW); |
79 | QLabel *initLabel = new QLabel(i18n("Initialization string %1:").arg(i + 1), | 89 | QLabel *initLabel = new QLabel(QObject::tr("Initialization string %1:").arg(i + 1), |
80 | this); | 90 | mainW); |
81 | ADJUSTEDIT(initstr[i]); | 91 | ADJUSTEDIT(initstr[i]); |
82 | l1->addWidget(initLabel, row, 1); | 92 | l1->addWidget(initLabel, row, 1); |
83 | l1->addWidget(initstr[i], row++, 2); | 93 | l1->addWidget(initstr[i], row++, 2); |
84 | } | 94 | } |
85 | 95 | ||
86 | QHBoxLayout *l3 = new QHBoxLayout; | 96 | QHBoxLayout *l3 = new QHBoxLayout; |
87 | l1->addLayout(l3, row, 2); | 97 | l1->addLayout(l3, row, 2); |
88 | linitslider = new QLabel("MMMM", this); | 98 | linitslider = new QLabel("MMMM", mainW); |
89 | FORMATSLIDERLABEL(linitslider); | 99 | FORMATSLIDERLABEL(linitslider); |
90 | QSlider *initslider = new QSlider(1, 300, 1, 0, | 100 | QSlider *initslider = new QSlider(1, 300, 1, 0, |
91 | QSlider::Horizontal, this); | 101 | QSlider::Horizontal, mainW); |
92 | // initslider->setFixedHeight(initslider->sizeHint().height()); | 102 | // initslider->setFixedHeight(initslider->sizeHint().height()); |
93 | connect(initslider, SIGNAL(valueChanged(int)), | 103 | connect(initslider, SIGNAL(valueChanged(int)), |
94 | linitslider, SLOT(setNum(int))); | 104 | linitslider, SLOT(setNum(int))); |
95 | l3->addWidget(linitslider, 0); | 105 | l3->addWidget(linitslider, 0); |
96 | l3->addWidget(initslider, 1); | 106 | l3->addWidget(initslider, 1); |
97 | 107 | ||
98 | label3 = new QLabel(i18n("Post-init delay (sec/100):"), this); | 108 | label3 = new QLabel(QObject::tr("Post-init delay (sec/100):"), mainW); |
99 | l1->addWidget(label3, row++, 1); | 109 | l1->addWidget(label3, row++, 1); |
100 | 110 | ||
101 | /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ | 111 | /* Set ATS11 (Dial tone duration) between 0-255 (Default ~ 70) */ |
102 | QHBoxLayout *l4 = new QHBoxLayout; | 112 | QHBoxLayout *l4 = new QHBoxLayout; |
103 | l1->addLayout(l4, row, 2); | 113 | l1->addLayout(l4, row, 2); |
104 | ldurationslider = new QLabel("MMMM", this); | 114 | ldurationslider = new QLabel("MMMM", mainW); |
105 | FORMATSLIDERLABEL(ldurationslider); | 115 | FORMATSLIDERLABEL(ldurationslider); |
106 | QSlider *durationslider = new QSlider(1, 255, 1, 0, | 116 | QSlider *durationslider = new QSlider(1, 255, 1, 0, |
107 | QSlider::Horizontal, this); | 117 | QSlider::Horizontal, mainW); |
108 | // durationslider->setFixedHeight(durationslider->sizeHint().height()); | 118 | // durationslider->setFixedHeight(durationslider->sizeHint().height()); |
109 | connect(durationslider, SIGNAL(valueChanged(int)), | 119 | connect(durationslider, SIGNAL(valueChanged(int)), |
110 | ldurationslider, SLOT(setNum(int))); | 120 | ldurationslider, SLOT(setNum(int))); |
111 | l4->addWidget(ldurationslider, 0); | 121 | l4->addWidget(ldurationslider, 0); |
112 | l4->addWidget(durationslider, 1); | 122 | l4->addWidget(durationslider, 1); |
113 | 123 | ||
114 | lduration = new QLabel(i18n("Dialing speed (sec/100):"), this); | 124 | lduration = new QLabel(QObject::tr("Dialing speed (sec/100):"), mainW); |
115 | l1->addWidget(lduration, row++, 1); | 125 | l1->addWidget(lduration, row++, 1); |
116 | 126 | ||
117 | 127 | ||
118 | initresp = new QLineEdit(this); | 128 | initresp = new QLineEdit(mainW); |
119 | label2 = new QLabel(i18n("Init response:"), this); | 129 | label2 = new QLabel(QObject::tr("Init response:"), mainW); |
120 | ADJUSTEDIT(initresp); | 130 | ADJUSTEDIT(initresp); |
121 | l1->addWidget(label2, row, 1); | 131 | l1->addWidget(label2, row, 1); |
122 | l1->addWidget(initresp, row++, 2); | 132 | l1->addWidget(initresp, row++, 2); |
123 | 133 | ||
124 | nodetectdialtone = new QLineEdit(this); | 134 | nodetectdialtone = new QLineEdit(mainW); |
125 | lnodetectdialtone = new QLabel(i18n("No dial tone detection:"), this); | 135 | lnodetectdialtone = new QLabel(QObject::tr("No dial tone detection:"), mainW); |
126 | ADJUSTEDIT(nodetectdialtone); | 136 | ADJUSTEDIT(nodetectdialtone); |
127 | l1->addWidget(lnodetectdialtone, row, 1); | 137 | l1->addWidget(lnodetectdialtone, row, 1); |
128 | l1->addWidget(nodetectdialtone, row++, 2); | 138 | l1->addWidget(nodetectdialtone, row++, 2); |
129 | 139 | ||
130 | dialstr = new QLineEdit(this); | 140 | dialstr = new QLineEdit(mainW); |
131 | label4 = new QLabel(i18n("Dial string:"),this); | 141 | label4 = new QLabel(QObject::tr("Dial string:"),mainW); |
132 | ADJUSTEDIT(dialstr); | 142 | ADJUSTEDIT(dialstr); |
133 | l1->addWidget(label4, row, 1); | 143 | l1->addWidget(label4, row, 1); |
134 | l1->addWidget(dialstr, row++, 2); | 144 | l1->addWidget(dialstr, row++, 2); |
135 | 145 | ||
136 | connectresp = new QLineEdit(this); | 146 | connectresp = new QLineEdit(mainW); |
137 | label5 = new QLabel(i18n("Connect response:"), this); | 147 | label5 = new QLabel(QObject::tr("Connect response:"), mainW); |
138 | ADJUSTEDIT(connectresp); | 148 | ADJUSTEDIT(connectresp); |
139 | l1->addWidget(label5, row, 1); | 149 | l1->addWidget(label5, row, 1); |
140 | l1->addWidget(connectresp, row++, 2); | 150 | l1->addWidget(connectresp, row++, 2); |
141 | 151 | ||
142 | busyresp = new QLineEdit(this); | 152 | busyresp = new QLineEdit(mainW); |
143 | label6 = new QLabel(i18n("Busy response:"), this); | 153 | label6 = new QLabel(QObject::tr("Busy response:"), mainW); |
144 | ADJUSTEDIT(busyresp); | 154 | ADJUSTEDIT(busyresp); |
145 | l1->addWidget(label6, row, 1); | 155 | l1->addWidget(label6, row, 1); |
146 | l1->addWidget(busyresp, row++, 2); | 156 | l1->addWidget(busyresp, row++, 2); |
147 | 157 | ||
148 | nocarrierresp = new QLineEdit(this); | 158 | nocarrierresp = new QLineEdit(mainW); |
149 | label7 = new QLabel(i18n("No carrier response:"), this); | 159 | label7 = new QLabel(QObject::tr("No carrier response:"), mainW); |
150 | ADJUSTEDIT(nocarrierresp); | 160 | ADJUSTEDIT(nocarrierresp); |
151 | l1->addWidget(label7, row, 1); | 161 | l1->addWidget(label7, row, 1); |
152 | l1->addWidget(nocarrierresp, row++, 2); | 162 | l1->addWidget(nocarrierresp, row++, 2); |
153 | 163 | ||
154 | nodialtoneresp = new QLineEdit(this); | 164 | nodialtoneresp = new QLineEdit(mainW); |
155 | label8 = new QLabel(i18n("No dial tone response:"), this); | 165 | label8 = new QLabel(QObject::tr("No dial tone response:"), mainW); |
156 | ADJUSTEDIT(nodialtoneresp); | 166 | ADJUSTEDIT(nodialtoneresp); |
157 | l1->addWidget(label8, row, 1); | 167 | l1->addWidget(label8, row, 1); |
158 | l1->addWidget(nodialtoneresp, row++, 2); | 168 | l1->addWidget(nodialtoneresp, row++, 2); |
159 | 169 | ||
160 | hangupstr = new QLineEdit(this); | 170 | hangupstr = new QLineEdit(mainW); |
161 | label9 = new QLabel(i18n("Hangup string:"), this); | 171 | label9 = new QLabel(QObject::tr("Hangup string:"), mainW); |
162 | ADJUSTEDIT(hangupstr); | 172 | ADJUSTEDIT(hangupstr); |
163 | l1->addWidget(label9, row, 1); | 173 | l1->addWidget(label9, row, 1); |
164 | l1->addWidget(hangupstr, row++, 2); | 174 | l1->addWidget(hangupstr, row++, 2); |
165 | 175 | ||
166 | hangupresp = new QLineEdit(this); | 176 | hangupresp = new QLineEdit(mainW); |
167 | label10 = new QLabel(i18n("Hangup response:"), this); | 177 | label10 = new QLabel(QObject::tr("Hangup response:"), mainW); |
168 | ADJUSTEDIT(hangupresp); | 178 | ADJUSTEDIT(hangupresp); |
169 | l1->addWidget(label10, row, 1); | 179 | l1->addWidget(label10, row, 1); |
170 | l1->addWidget(hangupresp, row++, 2); | 180 | l1->addWidget(hangupresp, row++, 2); |
171 | 181 | ||
172 | answerstr = new QLineEdit(this); | 182 | answerstr = new QLineEdit(mainW); |
173 | label11 = new QLabel(i18n("Answer string:"), this); | 183 | label11 = new QLabel(QObject::tr("Answer string:"), mainW); |
174 | ADJUSTEDIT(answerstr); | 184 | ADJUSTEDIT(answerstr); |
175 | l1->addWidget(label11, row, 1); | 185 | l1->addWidget(label11, row, 1); |
176 | l1->addWidget(answerstr, row++, 2); | 186 | l1->addWidget(answerstr, row++, 2); |
177 | 187 | ||
178 | ringresp = new QLineEdit(this); | 188 | ringresp = new QLineEdit(mainW); |
179 | label12 = new QLabel(i18n("Ring response:"), this); | 189 | label12 = new QLabel(QObject::tr("Ring response:"), mainW); |
180 | ADJUSTEDIT(ringresp); | 190 | ADJUSTEDIT(ringresp); |
181 | l1->addWidget(label12, row, 1); | 191 | l1->addWidget(label12, row, 1); |
182 | l1->addWidget(ringresp, row++, 2); | 192 | l1->addWidget(ringresp, row++, 2); |
183 | 193 | ||
184 | answerresp = new QLineEdit(this); | 194 | answerresp = new QLineEdit(mainW); |
185 | label13 = new QLabel(i18n("Answer response:"), this); | 195 | label13 = new QLabel(QObject::tr("Answer response:"), mainW); |
186 | ADJUSTEDIT(answerresp); | 196 | ADJUSTEDIT(answerresp); |
187 | l1->addWidget(label13, row, 1); | 197 | l1->addWidget(label13, row, 1); |
188 | l1->addWidget(answerresp, row++, 2); | 198 | l1->addWidget(answerresp, row++, 2); |
189 | 199 | ||
190 | escapestr = new QLineEdit(this); | 200 | escapestr = new QLineEdit(mainW); |
191 | label14 = new QLabel(i18n("Escape string:"), this); | 201 | label14 = new QLabel(QObject::tr("Escape string:"), mainW); |
192 | ADJUSTEDIT(escapestr); | 202 | ADJUSTEDIT(escapestr); |
193 | l1->addWidget(label14, row, 1); | 203 | l1->addWidget(label14, row, 1); |
194 | l1->addWidget(escapestr, row++, 2); | 204 | l1->addWidget(escapestr, row++, 2); |
195 | 205 | ||
196 | escaperesp = new QLineEdit(this); | 206 | escaperesp = new QLineEdit(mainW); |
197 | label15 = new QLabel(i18n("Escape response:"), this); | 207 | label15 = new QLabel(QObject::tr("Escape response:"), mainW); |
198 | ADJUSTEDIT(escaperesp); | 208 | ADJUSTEDIT(escaperesp); |
199 | l1->addWidget(label15, row, 1); | 209 | l1->addWidget(label15, row, 1); |
200 | l1->addWidget(escaperesp, row++, 2); | 210 | l1->addWidget(escaperesp, row++, 2); |
201 | 211 | ||
202 | QHBoxLayout *l5 = new QHBoxLayout; | 212 | QHBoxLayout *l5 = new QHBoxLayout; |
203 | l1->addLayout(l5, row, 2); | 213 | l1->addLayout(l5, row, 2); |
204 | lslider = new QLabel("MMMM", this); | 214 | lslider = new QLabel("MMMM", mainW); |
205 | FORMATSLIDERLABEL(lslider); | 215 | FORMATSLIDERLABEL(lslider); |
206 | 216 | ||
207 | QSlider *slider = new QSlider(0, 255, 1, 0, | 217 | QSlider *slider = new QSlider(0, 255, 1, 0, |
208 | QSlider::Horizontal, this); | 218 | QSlider::Horizontal, mainW); |
209 | // slider->setFixedHeight(slider->sizeHint().height()); | 219 | // slider->setFixedHeight(slider->sizeHint().height()); |
210 | connect(slider, SIGNAL(valueChanged(int)), | 220 | connect(slider, SIGNAL(valueChanged(int)), |
211 | lslider, SLOT(setNum(int))); | 221 | lslider, SLOT(setNum(int))); |
212 | l5->addWidget(lslider, 0); | 222 | l5->addWidget(lslider, 0); |
213 | l5->addWidget(slider, 1); | 223 | l5->addWidget(slider, 1); |
214 | 224 | ||
215 | label16 = new QLabel(i18n("Guard time (sec/50):"), this); | 225 | label16 = new QLabel(QObject::tr("Guard time (sec/50):"), mainW); |
216 | l1->addWidget(label16, row++, 1); | 226 | l1->addWidget(label16, row++, 1); |
217 | 227 | ||
218 | QLabel *l = new QLabel(i18n("Volume off/low/high:"), this); | 228 | QLabel *l = new QLabel(QObject::tr("Volume off/low/high:"), mainW); |
219 | l1->addWidget(l, row, 1); | 229 | l1->addWidget(l, row, 1); |
220 | QHBoxLayout *l6 = new QHBoxLayout; | 230 | QHBoxLayout *l6 = new QHBoxLayout; |
221 | l1->addLayout(l6, row++, 2); | 231 | l1->addLayout(l6, row++, 2); |
222 | volume_off = new QLineEdit(this); | 232 | volume_off = new QLineEdit(mainW); |
223 | // volume_off->setFixedHeight(volume_off->sizeHint().height()); | 233 | // volume_off->setFixedHeight(volume_off->sizeHint().height()); |
224 | // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); | 234 | // volume_off->setMinimumWidth((int)(volume_off->sizeHint().width() / 2)); |
225 | volume_medium = new QLineEdit(this); | 235 | volume_medium = new QLineEdit(mainW); |
226 | // volume_medium->setFixedHeight(volume_medium->sizeHint().height()); | 236 | // volume_medium->setFixedHeight(volume_medium->sizeHint().height()); |
227 | // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); | 237 | // volume_medium->setMinimumWidth((int)(volume_medium->sizeHint().width() / 2)); |
228 | volume_high = new QLineEdit(this); | 238 | volume_high = new QLineEdit(mainW); |
229 | // volume_high->setFixedHeight(volume_high->sizeHint().height()); | 239 | // volume_high->setFixedHeight(volume_high->sizeHint().height()); |
230 | // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); | 240 | // volume_high->setMinimumWidth((int)(volume_high->sizeHint().width() / 2)); |
231 | l6->addWidget(volume_off); | 241 | l6->addWidget(volume_off); |
232 | l6->addWidget(volume_medium); | 242 | l6->addWidget(volume_medium); |
233 | l6->addWidget(volume_high); | 243 | l6->addWidget(volume_high); |
234 | 244 | ||
235 | initstr[0]->setFocus(); | 245 | initstr[0]->setFocus(); |
236 | 246 | ||
237 | l1->addColSpacing(0, 10); | 247 | l1->addColSpacing(0, 10); |
238 | l1->addColSpacing(3, 10); | 248 | l1->addColSpacing(3, 10); |
239 | l1->addRowSpacing(0, 5); | 249 | l1->addRowSpacing(0, 5); |
240 | l1->addRowSpacing(GRIDROWS, 5); | 250 | l1->addRowSpacing(GRIDROWS, 5); |
241 | 251 | ||
242 | //set stuff from gpppdata | 252 | //set stuff from gpppdata |
243 | preinitslider->setValue(_pppdata->modemPreInitDelay()); | 253 | preinitslider->setValue(_pppdata->modemPreInitDelay()); |
244 | lpreinitslider->setNum(_pppdata->modemPreInitDelay()); | 254 | lpreinitslider->setNum(_pppdata->modemPreInitDelay()); |
245 | for(int i = 0; i < PPPData::NumInitStrings; i++) | 255 | for(int i = 0; i < PPPData::NumInitStrings; i++) |
246 | initstr[i]->setText(_pppdata->modemInitStr(i)); | 256 | initstr[i]->setText(_pppdata->modemInitStr(i)); |
247 | initslider->setValue(_pppdata->modemInitDelay()); | 257 | initslider->setValue(_pppdata->modemInitDelay()); |
248 | linitslider->setNum(_pppdata->modemInitDelay()); | 258 | linitslider->setNum(_pppdata->modemInitDelay()); |
249 | initresp->setText(_pppdata->modemInitResp()); | 259 | initresp->setText(_pppdata->modemInitResp()); |
250 | 260 | ||
251 | durationslider->setValue(_pppdata->modemToneDuration()); | 261 | durationslider->setValue(_pppdata->modemToneDuration()); |
252 | ldurationslider->setNum(_pppdata->modemToneDuration()); | 262 | ldurationslider->setNum(_pppdata->modemToneDuration()); |
253 | 263 | ||
254 | nodetectdialtone->setText(_pppdata->modemNoDialToneDetectionStr()); | 264 | nodetectdialtone->setText(_pppdata->modemNoDialToneDetectionStr()); |
255 | dialstr->setText(_pppdata->modemDialStr()); | 265 | dialstr->setText(_pppdata->modemDialStr()); |
256 | connectresp->setText(_pppdata->modemConnectResp()); | 266 | connectresp->setText(_pppdata->modemConnectResp()); |
257 | busyresp->setText(_pppdata->modemBusyResp()); | 267 | busyresp->setText(_pppdata->modemBusyResp()); |
258 | nocarrierresp->setText(_pppdata->modemNoCarrierResp()); | 268 | nocarrierresp->setText(_pppdata->modemNoCarrierResp()); |
259 | nodialtoneresp->setText(_pppdata->modemNoDialtoneResp()); | 269 | nodialtoneresp->setText(_pppdata->modemNoDialtoneResp()); |
260 | 270 | ||
261 | escapestr->setText(_pppdata->modemEscapeStr()); | 271 | escapestr->setText(_pppdata->modemEscapeStr()); |
262 | escaperesp->setText(_pppdata->modemEscapeResp()); | 272 | escaperesp->setText(_pppdata->modemEscapeResp()); |
263 | 273 | ||
264 | hangupstr->setText(_pppdata->modemHangupStr()); | 274 | hangupstr->setText(_pppdata->modemHangupStr()); |
265 | hangupresp->setText(_pppdata->modemHangupResp()); | 275 | hangupresp->setText(_pppdata->modemHangupResp()); |
266 | 276 | ||
267 | answerstr->setText(_pppdata->modemAnswerStr()); | 277 | answerstr->setText(_pppdata->modemAnswerStr()); |
268 | ringresp->setText(_pppdata->modemRingResp()); | 278 | ringresp->setText(_pppdata->modemRingResp()); |
269 | answerresp->setText(_pppdata->modemAnswerResp()); | 279 | answerresp->setText(_pppdata->modemAnswerResp()); |
270 | 280 | ||
271 | slider->setValue(_pppdata->modemEscapeGuardTime()); | 281 | slider->setValue(_pppdata->modemEscapeGuardTime()); |
272 | lslider->setNum(_pppdata->modemEscapeGuardTime()); | 282 | lslider->setNum(_pppdata->modemEscapeGuardTime()); |
273 | 283 | ||
274 | volume_off->setText(_pppdata->volumeOff()); | 284 | volume_off->setText(_pppdata->volumeOff()); |
275 | volume_medium->setText(_pppdata->volumeMedium()); | 285 | volume_medium->setText(_pppdata->volumeMedium()); |
276 | volume_high->setText(_pppdata->volumeHigh()); | 286 | volume_high->setText(_pppdata->volumeHigh()); |
277 | } | 287 | } |
278 | 288 | ||
279 | 289 | ||
280 | void ModemCommands::slotOk() { | 290 | void ModemCommands::slotOk() { |
281 | _pppdata->setModemPreInitDelay(lpreinitslider->text().toInt()); | 291 | _pppdata->setModemPreInitDelay(lpreinitslider->text().toInt()); |
282 | for(int i = 0; i < PPPData::NumInitStrings; i++) | 292 | for(int i = 0; i < PPPData::NumInitStrings; i++) |
283 | _pppdata->setModemInitStr(i, initstr[i]->text()); | 293 | _pppdata->setModemInitStr(i, initstr[i]->text()); |
284 | _pppdata->setModemInitResp(initresp->text()); | 294 | _pppdata->setModemInitResp(initresp->text()); |
285 | _pppdata->setModemInitDelay(linitslider->text().toInt()); | 295 | _pppdata->setModemInitDelay(linitslider->text().toInt()); |
286 | 296 | ||
287 | _pppdata->setModemToneDuration(ldurationslider->text().toInt()); | 297 | _pppdata->setModemToneDuration(ldurationslider->text().toInt()); |
288 | _pppdata->setModemNoDialToneDetectionStr(nodetectdialtone->text()); | 298 | _pppdata->setModemNoDialToneDetectionStr(nodetectdialtone->text()); |
289 | _pppdata->setModemDialStr(dialstr->text()); | 299 | _pppdata->setModemDialStr(dialstr->text()); |
290 | _pppdata->setModemConnectResp(connectresp->text()); | 300 | _pppdata->setModemConnectResp(connectresp->text()); |
291 | _pppdata->setModemBusyResp(busyresp->text()); | 301 | _pppdata->setModemBusyResp(busyresp->text()); |
292 | _pppdata->setModemNoCarrierResp(nocarrierresp->text()); | 302 | _pppdata->setModemNoCarrierResp(nocarrierresp->text()); |
293 | _pppdata->setModemNoDialtoneResp(nodialtoneresp->text()); | 303 | _pppdata->setModemNoDialtoneResp(nodialtoneresp->text()); |
294 | 304 | ||
295 | _pppdata->setModemEscapeStr(escapestr->text()); | 305 | _pppdata->setModemEscapeStr(escapestr->text()); |
296 | _pppdata->setModemEscapeResp(escaperesp->text()); | 306 | _pppdata->setModemEscapeResp(escaperesp->text()); |
297 | _pppdata->setModemEscapeGuardTime(lslider->text().toInt()); | 307 | _pppdata->setModemEscapeGuardTime(lslider->text().toInt()); |
298 | _pppdata->setModemHangupStr(hangupstr->text()); | 308 | _pppdata->setModemHangupStr(hangupstr->text()); |
299 | _pppdata->setModemHangupResp(hangupresp->text()); | 309 | _pppdata->setModemHangupResp(hangupresp->text()); |
300 | 310 | ||
301 | _pppdata->setModemAnswerStr(answerstr->text()); | 311 | _pppdata->setModemAnswerStr(answerstr->text()); |
302 | _pppdata->setModemRingResp(ringresp->text()); | 312 | _pppdata->setModemRingResp(ringresp->text()); |
303 | _pppdata->setModemAnswerResp(answerresp->text()); | 313 | _pppdata->setModemAnswerResp(answerresp->text()); |
304 | 314 | ||
305 | _pppdata->setVolumeHigh(volume_high->text()); | 315 | _pppdata->setVolumeHigh(volume_high->text()); |
306 | _pppdata->setVolumeMedium(volume_medium->text()); | 316 | _pppdata->setVolumeMedium(volume_medium->text()); |
307 | _pppdata->setVolumeOff(volume_off->text()); | 317 | _pppdata->setVolumeOff(volume_off->text()); |
308 | 318 | ||
309 | _pppdata->save(); | 319 | _pppdata->save(); |
310 | accept(); | 320 | QDialog::accept(); |
321 | } | ||
322 | |||
323 | void ModemCommands::accept() | ||
324 | { | ||
325 | slotOk(); | ||
311 | } | 326 | } |
312 | 327 | ||
313 | 328 | ||
314 | void ModemCommands::slotCancel() { | 329 | void ModemCommands::slotCancel() { |
315 | reject(); | 330 | reject(); |
316 | } | 331 | } |
317 | 332 | ||
318 | //#include "modemcmds.moc" | 333 | //#include "modemcmds.moc" |
diff --git a/noncore/settings/networksettings/ppp/modemcmds.h b/noncore/settings/networksettings/ppp/modemcmds.h index ef69fec..81d67f4 100644 --- a/noncore/settings/networksettings/ppp/modemcmds.h +++ b/noncore/settings/networksettings/ppp/modemcmds.h | |||
@@ -1,120 +1,121 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | * | 3 | * |
4 | * kPPP: A front end for pppd for the KDE project | 4 | * kPPP: A front end for pppd for the KDE project |
5 | * | 5 | * |
6 | * $Id$ | 6 | * $Id$ |
7 | * | 7 | * |
8 | * Copyright (C) 1997 Bernd Johannes Wuebben | 8 | * Copyright (C) 1997 Bernd Johannes Wuebben |
9 | * wuebben@math.cornell.edu | 9 | * wuebben@math.cornell.edu |
10 | * | 10 | * |
11 | * based on EzPPP: | 11 | * based on EzPPP: |
12 | * Copyright (C) 1997 Jay Painter | 12 | * Copyright (C) 1997 Jay Painter |
13 | * | 13 | * |
14 | * This library is free software; you can redistribute it and/or | 14 | * This library is free software; you can redistribute it and/or |
15 | * modify it under the terms of the GNU Library General Public | 15 | * modify it under the terms of the GNU Library General Public |
16 | * License as published by the Free Software Foundation; either | 16 | * License as published by the Free Software Foundation; either |
17 | * version 2 of the License, or (at your option) any later version. | 17 | * version 2 of the License, or (at your option) any later version. |
18 | * | 18 | * |
19 | * This library is distributed in the hope that it will be useful, | 19 | * This library is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22 | * Library General Public License for more details. | 22 | * Library General Public License for more details. |
23 | * | 23 | * |
24 | * You should have received a copy of the GNU Library General Public | 24 | * You should have received a copy of the GNU Library General Public |
25 | * License along with this program; if not, write to the Free | 25 | * License along with this program; if not, write to the Free |
26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | #ifndef _MODEMCMDS_H_ | 31 | #ifndef _MODEMCMDS_H_ |
32 | #define _MODEMCMDS_H_ | 32 | #define _MODEMCMDS_H_ |
33 | 33 | ||
34 | #include <qgroupbox.h> | 34 | #include <qgroupbox.h> |
35 | #include <qdialog.h> | 35 | #include <qdialog.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include "pppdata.h" | 39 | #include "pppdata.h" |
40 | 40 | ||
41 | class ModemCommands : public QDialog { | 41 | class ModemCommands : public QDialog { |
42 | 42 | ||
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | 46 | ||
47 | ModemCommands(PPPData*, QWidget *parent=0, const char *name=0); | 47 | ModemCommands(PPPData*, QWidget *parent=0, const char *name=0, bool modal=0, WFlags f = 0); |
48 | ~ModemCommands() {} | 48 | ~ModemCommands() {} |
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | virtual void accept(); | ||
51 | void slotCancel(); | 52 | void slotCancel(); |
52 | void slotOk(); | 53 | void slotOk(); |
53 | 54 | ||
54 | private: | 55 | private: |
55 | PPPData *_pppdata; | 56 | PPPData *_pppdata; |
56 | 57 | ||
57 | QGroupBox *box; | 58 | QGroupBox *box; |
58 | 59 | ||
59 | QLineEdit *initstr[int(PPPData::NumInitStrings)]; | 60 | QLineEdit *initstr[int(PPPData::NumInitStrings)]; |
60 | 61 | ||
61 | QLineEdit *initresp; | 62 | QLineEdit *initresp; |
62 | QLabel *label2; | 63 | QLabel *label2; |
63 | 64 | ||
64 | QLabel *lpreinitslider; | 65 | QLabel *lpreinitslider; |
65 | QLabel *lpreinit; | 66 | QLabel *lpreinit; |
66 | 67 | ||
67 | QLabel *linitslider; | 68 | QLabel *linitslider; |
68 | QLabel *label3; | 69 | QLabel *label3; |
69 | 70 | ||
70 | QLabel *ldurationslider; | 71 | QLabel *ldurationslider; |
71 | QLabel *lduration; | 72 | QLabel *lduration; |
72 | 73 | ||
73 | QLineEdit *nodetectdialtone; | 74 | QLineEdit *nodetectdialtone; |
74 | QLabel *lnodetectdialtone; | 75 | QLabel *lnodetectdialtone; |
75 | 76 | ||
76 | QLineEdit *dialstr; | 77 | QLineEdit *dialstr; |
77 | QLabel *label4; | 78 | QLabel *label4; |
78 | 79 | ||
79 | QLineEdit *connectresp; | 80 | QLineEdit *connectresp; |
80 | QLabel *label5; | 81 | QLabel *label5; |
81 | 82 | ||
82 | QLineEdit *busyresp; | 83 | QLineEdit *busyresp; |
83 | QLabel *label6; | 84 | QLabel *label6; |
84 | 85 | ||
85 | QLineEdit *nocarrierresp; | 86 | QLineEdit *nocarrierresp; |
86 | QLabel *label7; | 87 | QLabel *label7; |
87 | 88 | ||
88 | QLineEdit *nodialtoneresp; | 89 | QLineEdit *nodialtoneresp; |
89 | QLabel *label8; | 90 | QLabel *label8; |
90 | 91 | ||
91 | QLineEdit *hangupstr; | 92 | QLineEdit *hangupstr; |
92 | QLabel *label9; | 93 | QLabel *label9; |
93 | 94 | ||
94 | QLineEdit *hangupresp; | 95 | QLineEdit *hangupresp; |
95 | QLabel *label10; | 96 | QLabel *label10; |
96 | 97 | ||
97 | QLineEdit *answerstr; | 98 | QLineEdit *answerstr; |
98 | QLabel *label11; | 99 | QLabel *label11; |
99 | 100 | ||
100 | QLineEdit *ringresp; | 101 | QLineEdit *ringresp; |
101 | QLabel *label12; | 102 | QLabel *label12; |
102 | 103 | ||
103 | QLineEdit *answerresp; | 104 | QLineEdit *answerresp; |
104 | QLabel *label13; | 105 | QLabel *label13; |
105 | 106 | ||
106 | QLineEdit *escapestr; | 107 | QLineEdit *escapestr; |
107 | QLabel *label14; | 108 | QLabel *label14; |
108 | 109 | ||
109 | QLineEdit *escaperesp; | 110 | QLineEdit *escaperesp; |
110 | QLabel *label15; | 111 | QLabel *label15; |
111 | 112 | ||
112 | QLabel *lslider; | 113 | QLabel *lslider; |
113 | QLabel *label16; | 114 | QLabel *label16; |
114 | 115 | ||
115 | QLineEdit *volume_off, *volume_medium, *volume_high; | 116 | QLineEdit *volume_off, *volume_medium, *volume_high; |
116 | }; | 117 | }; |
117 | #endif | 118 | #endif |
118 | 119 | ||
119 | 120 | ||
120 | 121 | ||
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp index 0bec186..dbb26db 100644 --- a/noncore/settings/networksettings/ppp/modeminfo.cpp +++ b/noncore/settings/networksettings/ppp/modeminfo.cpp | |||
@@ -1,296 +1,294 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A front end for pppd for the KDE project | 2 | * kPPP: A front end for pppd 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 | * This file contributed by: Markus Wuebben, mwuebben@fiwi02.wiwi.uni-tuebingen.de | 9 | * This file contributed by: Markus Wuebben, mwuebben@fiwi02.wiwi.uni-tuebingen.de |
10 | * | 10 | * |
11 | * | 11 | * |
12 | * This library is free software; you can redistribute it and/or | 12 | * This library 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 library is distributed in the hope that it will be useful, | 17 | * This library 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 <unistd.h> | 27 | #include <unistd.h> |
28 | #include <qregexp.h> | 28 | #include <qregexp.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | // #include <kwin.h> | 30 | // #include <kwin.h> |
31 | // #include <kmessagebox.h> | 31 | // #include <kmessagebox.h> |
32 | // #include <kapplication.h> | 32 | // #include <kapplication.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include "modeminfo.h" | 35 | #include "modeminfo.h" |
36 | #include "modem.h" | 36 | #include "modem.h" |
37 | //#include <klocale.h> | ||
38 | #define i18n QObject::tr | ||
39 | 37 | ||
40 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) | 38 | ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) |
41 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), | 39 | : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), |
42 | _modem(mo) | 40 | _modem(mo) |
43 | { | 41 | { |
44 | setCaption(i18n("ATI Query")); | 42 | setCaption(QObject::tr("ATI Query")); |
45 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 43 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
46 | 44 | ||
47 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 45 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
48 | 46 | ||
49 | progressBar = new QProgressBar(this, "bar"); | 47 | progressBar = new QProgressBar(this, "bar"); |
50 | progressBar->setTotalSteps(8); | 48 | progressBar->setTotalSteps(8); |
51 | 49 | ||
52 | statusBar = new QLabel(this,"sBar"); | 50 | statusBar = new QLabel(this,"sBar"); |
53 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 51 | statusBar->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
54 | statusBar->setAlignment(AlignCenter); | 52 | statusBar->setAlignment(AlignCenter); |
55 | 53 | ||
56 | // This is a rather complicated case. Since we do not know which | 54 | // This is a rather complicated case. Since we do not know which |
57 | // message is the widest in the national language, we'd to | 55 | // message is the widest in the national language, we'd to |
58 | // search all these messages. This is a little overkill, so I take | 56 | // search all these messages. This is a little overkill, so I take |
59 | // the longest english message, translate it and give it additional | 57 | // the longest english message, translate it and give it additional |
60 | // 20 percent space. Hope this is enough. | 58 | // 20 percent space. Hope this is enough. |
61 | statusBar->setText(i18n("Unable to create modem lock file.")); | 59 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
62 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); | 60 | statusBar->setFixedWidth((statusBar->sizeHint().width() * 12) / 10); |
63 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); | 61 | statusBar->setFixedHeight(statusBar->sizeHint().height() + 4); |
64 | 62 | ||
65 | // set original text | 63 | // set original text |
66 | statusBar->setText(i18n("Looking for modem...")); | 64 | statusBar->setText(QObject::tr("Looking for modem...")); |
67 | progressBar->setFixedHeight(statusBar->minimumSize().height()); | 65 | progressBar->setFixedHeight(statusBar->minimumSize().height()); |
68 | tl->addWidget(progressBar); | 66 | tl->addWidget(progressBar); |
69 | tl->addWidget(statusBar); | 67 | tl->addWidget(statusBar); |
70 | 68 | ||
71 | cancel = new QPushButton(i18n("Cancel"), this); | 69 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
72 | cancel->setFocus(); | 70 | cancel->setFocus(); |
73 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); | 71 | connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton())); |
74 | 72 | ||
75 | QHBoxLayout *l1 = new QHBoxLayout; | 73 | QHBoxLayout *l1 = new QHBoxLayout; |
76 | tl->addLayout(l1); | 74 | tl->addLayout(l1); |
77 | l1->addStretch(1); | 75 | l1->addStretch(1); |
78 | l1->addWidget(cancel); | 76 | l1->addWidget(cancel); |
79 | 77 | ||
80 | setFixedSize(sizeHint()); | 78 | setFixedSize(sizeHint()); |
81 | 79 | ||
82 | step = 0; | 80 | step = 0; |
83 | 81 | ||
84 | //////////////////////////////////////////////// | 82 | //////////////////////////////////////////////// |
85 | 83 | ||
86 | timeout_timer = new QTimer(this); | 84 | timeout_timer = new QTimer(this); |
87 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); | 85 | connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); |
88 | 86 | ||
89 | scripttimer = new QTimer(this); | 87 | scripttimer = new QTimer(this); |
90 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); | 88 | connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); |
91 | 89 | ||
92 | timeout_timer->start(15000,TRUE); // 15 secs single shot | 90 | timeout_timer->start(15000,TRUE); // 15 secs single shot |
93 | QTimer::singleShot(500, this, SLOT(init())); | 91 | QTimer::singleShot(500, this, SLOT(init())); |
94 | 92 | ||
95 | } | 93 | } |
96 | 94 | ||
97 | 95 | ||
98 | void ModemTransfer::ati_done() { | 96 | void ModemTransfer::ati_done() { |
99 | scripttimer->stop(); | 97 | scripttimer->stop(); |
100 | timeout_timer->stop(); | 98 | timeout_timer->stop(); |
101 | _modem->closetty(); | 99 | _modem->closetty(); |
102 | _modem->unlockdevice(); | 100 | _modem->unlockdevice(); |
103 | hide(); | 101 | hide(); |
104 | 102 | ||
105 | // open the result window | 103 | // open the result window |
106 | ModemInfo *mi = new ModemInfo(this); | 104 | ModemInfo *mi = new ModemInfo(this); |
107 | for(int i = 0; i < NUM_OF_ATI; i++) | 105 | for(int i = 0; i < NUM_OF_ATI; i++) |
108 | mi->setAtiString(i, ati_query_strings[i]); | 106 | mi->setAtiString(i, ati_query_strings[i]); |
109 | mi->showMaximized(); | 107 | mi->showMaximized(); |
110 | mi->exec(); | 108 | mi->exec(); |
111 | delete mi; | 109 | delete mi; |
112 | 110 | ||
113 | accept(); | 111 | accept(); |
114 | } | 112 | } |
115 | 113 | ||
116 | 114 | ||
117 | void ModemTransfer::time_out_slot() { | 115 | void ModemTransfer::time_out_slot() { |
118 | timeout_timer->stop(); | 116 | timeout_timer->stop(); |
119 | scripttimer->stop(); | 117 | scripttimer->stop(); |
120 | 118 | ||
121 | QMessageBox::warning(this, tr("Error"), i18n("Modem Query timed out.")); | 119 | QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out.")); |
122 | reject(); | 120 | reject(); |
123 | } | 121 | } |
124 | 122 | ||
125 | 123 | ||
126 | void ModemTransfer::init() { | 124 | void ModemTransfer::init() { |
127 | 125 | ||
128 | qApp->processEvents(); | 126 | qApp->processEvents(); |
129 | 127 | ||
130 | int lock = _modem->lockdevice(); | 128 | int lock = _modem->lockdevice(); |
131 | if (lock == 1) { | 129 | if (lock == 1) { |
132 | 130 | ||
133 | statusBar->setText(i18n("Modem device is locked.")); | 131 | statusBar->setText(QObject::tr("Modem device is locked.")); |
134 | return; | 132 | return; |
135 | } | 133 | } |
136 | 134 | ||
137 | if (lock == -1) { | 135 | if (lock == -1) { |
138 | 136 | ||
139 | statusBar->setText(i18n("Unable to create modem lock file.")); | 137 | statusBar->setText(QObject::tr("Unable to create modem lock file.")); |
140 | return; | 138 | return; |
141 | } | 139 | } |
142 | 140 | ||
143 | 141 | ||
144 | if(_modem->opentty()) { | 142 | if(_modem->opentty()) { |
145 | if(_modem->hangup()) { | 143 | if(_modem->hangup()) { |
146 | usleep(100000); // wait 0.1 secs | 144 | usleep(100000); // wait 0.1 secs |
147 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... | 145 | _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... |
148 | 146 | ||
149 | statusBar->setText(i18n("Modem Ready")); | 147 | statusBar->setText(QObject::tr("Modem Ready")); |
150 | qApp->processEvents(); | 148 | qApp->processEvents(); |
151 | usleep(100000); // wait 0.1 secs | 149 | usleep(100000); // wait 0.1 secs |
152 | qApp->processEvents(); | 150 | qApp->processEvents(); |
153 | scripttimer->start(1000); // this one does the ati query | 151 | scripttimer->start(1000); // this one does the ati query |
154 | 152 | ||
155 | // clear modem buffer | 153 | // clear modem buffer |
156 | _modem->flush(); | 154 | _modem->flush(); |
157 | 155 | ||
158 | _modem->notify(this, SLOT(readChar(unsigned char))); | 156 | _modem->notify(this, SLOT(readChar(unsigned char))); |
159 | return; | 157 | return; |
160 | } | 158 | } |
161 | } | 159 | } |
162 | 160 | ||
163 | // opentty() or hangup() failed | 161 | // opentty() or hangup() failed |
164 | statusBar->setText(_modem->modemMessage()); | 162 | statusBar->setText(_modem->modemMessage()); |
165 | step = 99; // wait until cancel is pressed | 163 | step = 99; // wait until cancel is pressed |
166 | _modem->unlockdevice(); | 164 | _modem->unlockdevice(); |
167 | } | 165 | } |
168 | 166 | ||
169 | 167 | ||
170 | void ModemTransfer::do_script() { | 168 | void ModemTransfer::do_script() { |
171 | QString msg; | 169 | QString msg; |
172 | QString query; | 170 | QString query; |
173 | 171 | ||
174 | switch(step) { | 172 | switch(step) { |
175 | case 0: | 173 | case 0: |
176 | readtty(); | 174 | readtty(); |
177 | statusBar->setText("ATI..."); | 175 | statusBar->setText("ATI..."); |
178 | progressBar->setProgress( progressBar->progress() + 1); | 176 | progressBar->setProgress( progressBar->progress() + 1); |
179 | _modem->writeLine("ATI\n"); | 177 | _modem->writeLine("ATI\n"); |
180 | break; | 178 | break; |
181 | 179 | ||
182 | case 1: | 180 | case 1: |
183 | case 2: | 181 | case 2: |
184 | case 3: | 182 | case 3: |
185 | case 4: | 183 | case 4: |
186 | case 5: | 184 | case 5: |
187 | case 6: | 185 | case 6: |
188 | case 7: | 186 | case 7: |
189 | readtty(); | 187 | readtty(); |
190 | msg.sprintf("ATI %d ...", step); | 188 | msg.sprintf("ATI %d ...", step); |
191 | query.sprintf("ATI%d\n", step); | 189 | query.sprintf("ATI%d\n", step); |
192 | statusBar->setText(msg); | 190 | statusBar->setText(msg); |
193 | progressBar->setProgress( progressBar->progress() + 1); | 191 | progressBar->setProgress( progressBar->progress() + 1); |
194 | _modem->writeLine(query.local8Bit()); | 192 | _modem->writeLine(query.local8Bit()); |
195 | break; | 193 | break; |
196 | 194 | ||
197 | default: | 195 | default: |
198 | readtty(); | 196 | readtty(); |
199 | ati_done(); | 197 | ati_done(); |
200 | } | 198 | } |
201 | step++; | 199 | step++; |
202 | } | 200 | } |
203 | 201 | ||
204 | void ModemTransfer::readChar(unsigned char c) { | 202 | void ModemTransfer::readChar(unsigned char c) { |
205 | if(readbuffer.length() < 255) | 203 | if(readbuffer.length() < 255) |
206 | readbuffer += c; | 204 | readbuffer += c; |
207 | } | 205 | } |
208 | 206 | ||
209 | void ModemTransfer::readtty() { | 207 | void ModemTransfer::readtty() { |
210 | 208 | ||
211 | if (step == 0) | 209 | if (step == 0) |
212 | return; | 210 | return; |
213 | 211 | ||
214 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r | 212 | readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r |
215 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white | 213 | readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white |
216 | // space | 214 | // space |
217 | 215 | ||
218 | if(step <= NUM_OF_ATI) | 216 | if(step <= NUM_OF_ATI) |
219 | ati_query_strings[step-1] = readbuffer.copy(); | 217 | ati_query_strings[step-1] = readbuffer.copy(); |
220 | 218 | ||
221 | readbuffer = ""; | 219 | readbuffer = ""; |
222 | } | 220 | } |
223 | 221 | ||
224 | 222 | ||
225 | void ModemTransfer::cancelbutton() { | 223 | void ModemTransfer::cancelbutton() { |
226 | scripttimer->stop(); | 224 | scripttimer->stop(); |
227 | _modem->stop(); | 225 | _modem->stop(); |
228 | timeout_timer->stop(); | 226 | timeout_timer->stop(); |
229 | 227 | ||
230 | statusBar->setText(i18n("One moment please...")); | 228 | statusBar->setText(QObject::tr("One moment please...")); |
231 | qApp->processEvents(); | 229 | qApp->processEvents(); |
232 | 230 | ||
233 | _modem->hangup(); | 231 | _modem->hangup(); |
234 | 232 | ||
235 | _modem->closetty(); | 233 | _modem->closetty(); |
236 | _modem->unlockdevice(); | 234 | _modem->unlockdevice(); |
237 | reject(); | 235 | reject(); |
238 | } | 236 | } |
239 | 237 | ||
240 | 238 | ||
241 | void ModemTransfer::closeEvent( QCloseEvent *e ) { | 239 | void ModemTransfer::closeEvent( QCloseEvent *e ) { |
242 | cancelbutton(); | 240 | cancelbutton(); |
243 | e->accept(); | 241 | e->accept(); |
244 | } | 242 | } |
245 | 243 | ||
246 | 244 | ||
247 | ModemInfo::ModemInfo(QWidget *parent, const char* name) | 245 | ModemInfo::ModemInfo(QWidget *parent, const char* name) |
248 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) | 246 | : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) |
249 | { | 247 | { |
250 | QString label_text; | 248 | QString label_text; |
251 | 249 | ||
252 | setCaption(i18n("Modem Query Results")); | 250 | setCaption(QObject::tr("Modem Query Results")); |
253 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 251 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
254 | 252 | ||
255 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); | 253 | QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); |
256 | 254 | ||
257 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); | 255 | QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); |
258 | tl->addLayout(l1, 1); | 256 | tl->addLayout(l1, 1); |
259 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { | 257 | for(int i = 0 ; i < NUM_OF_ATI ; i++) { |
260 | 258 | ||
261 | label_text = ""; | 259 | label_text = ""; |
262 | if ( i == 0) | 260 | if ( i == 0) |
263 | label_text.sprintf("ATI :"); | 261 | label_text.sprintf("ATI :"); |
264 | else | 262 | else |
265 | label_text.sprintf("ATI %d:", i ); | 263 | label_text.sprintf("ATI %d:", i ); |
266 | 264 | ||
267 | ati_label[i] = new QLabel(label_text, this); | 265 | ati_label[i] = new QLabel(label_text, this); |
268 | l1->addWidget(ati_label[i], i, 0); | 266 | l1->addWidget(ati_label[i], i, 0); |
269 | 267 | ||
270 | ati_label_result[i] = new QLineEdit(this); | 268 | ati_label_result[i] = new QLineEdit(this); |
271 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); | 269 | ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); |
272 | l1->addWidget(ati_label_result[i], i, 1); | 270 | l1->addWidget(ati_label_result[i], i, 1); |
273 | } | 271 | } |
274 | //tl->addSpacing(1); | 272 | //tl->addSpacing(1); |
275 | 273 | ||
276 | QHBoxLayout *l2 = new QHBoxLayout; | 274 | QHBoxLayout *l2 = new QHBoxLayout; |
277 | QPushButton *ok = new QPushButton(i18n("Close"), this); | 275 | QPushButton *ok = new QPushButton(QObject::tr("Close"), this); |
278 | ok->setDefault(TRUE); | 276 | ok->setDefault(TRUE); |
279 | ok->setFocus(); | 277 | ok->setFocus(); |
280 | 278 | ||
281 | tl->addLayout(l2); | 279 | tl->addLayout(l2); |
282 | l2->addStretch(1); | 280 | l2->addStretch(1); |
283 | 281 | ||
284 | connect(ok, SIGNAL(clicked()), SLOT(accept())); | 282 | connect(ok, SIGNAL(clicked()), SLOT(accept())); |
285 | l2->addWidget(ok); | 283 | l2->addWidget(ok); |
286 | 284 | ||
287 | setMinimumSize(sizeHint()); | 285 | setMinimumSize(sizeHint()); |
288 | } | 286 | } |
289 | 287 | ||
290 | 288 | ||
291 | void ModemInfo::setAtiString(int i, QString s) { | 289 | void ModemInfo::setAtiString(int i, QString s) { |
292 | if(i < NUM_OF_ATI) | 290 | if(i < NUM_OF_ATI) |
293 | ati_label_result[i]->setText(s); | 291 | ati_label_result[i]->setText(s); |
294 | } | 292 | } |
295 | 293 | ||
296 | //#include "modeminfo.moc" | 294 | //#include "modeminfo.moc" |
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index fc89f35..84acd0e 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro | |||
@@ -1,18 +1,17 @@ | |||
1 | #TEMPLATE = app | 1 | #TEMPLATE = app |
2 | # | 2 | # |
3 | TEMPLATE = lib | 3 | TEMPLATE = lib |
4 | #CONFIG += qt warn_on release | 4 | #CONFIG += qt warn_on release |
5 | CONFIG += qt warn_on debug | 5 | CONFIG += qt warn_on debug |
6 | DESTDIR = $(OPIEDIR)/plugins/networksettings | 6 | DESTDIR = $(OPIEDIR)/plugins/networksettings |
7 | HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h | 7 | HEADERS = pppmodule.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h chooserwidget.h devices.h |
8 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp | 8 | SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp chooserwidget.cpp devices.cpp |
9 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | 9 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ |
10 | DEPENDPATH+= $(OPIEDIR)/include | 10 | DEPENDPATH+= $(OPIEDIR)/include |
11 | LIBS += -lqpe -L../interfaces/ -linterfaces | 11 | LIBS += -lqpe -L../interfaces/ -linterfaces |
12 | INTERFACES= | ||
13 | TARGET = kppp | 12 | TARGET = kppp |
14 | VERSION = 1.0.0 | 13 | VERSION = 1.0.0 |
15 | 14 | ||
16 | 15 | ||
17 | 16 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp index 5fa7d3f..97baf31 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.cpp +++ b/noncore/settings/networksettings/ppp/pppconfig.cpp | |||
@@ -1,70 +1,75 @@ | |||
1 | 1 | ||
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | #include <qtabwidget.h> | 4 | #include <qtabwidget.h> |
5 | 5 | ||
6 | #include "accounts.h" | 6 | #include "accounts.h" |
7 | #include "devices.h" | ||
7 | #include "general.h" | 8 | #include "general.h" |
8 | #include "interfaceppp.h" | 9 | #include "interfaceppp.h" |
9 | #include "modem.h" | 10 | #include "modem.h" |
10 | #include "pppconfig.h" | 11 | #include "pppconfig.h" |
11 | #include "pppdata.h" | 12 | #include "pppdata.h" |
12 | #include "runtests.h" | 13 | #include "runtests.h" |
13 | 14 | ||
14 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, | 15 | PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, |
15 | const char *name, | 16 | const char *name, |
16 | bool modal, WFlags fl ) | 17 | bool modal, WFlags fl ) |
17 | : QDialog(parent, name, modal, fl) | 18 | : QDialog(parent, name, modal, fl) |
18 | { | 19 | { |
19 | setCaption(tr("Configure Modem")); | 20 | setCaption(tr("Configure Modem")); |
20 | int result = runTests(); | 21 | int result = runTests(); |
21 | if(result == TEST_CRITICAL){ | 22 | if(result == TEST_CRITICAL){ |
22 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); | 23 | QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); |
23 | return; | 24 | return; |
24 | } | 25 | } |
25 | 26 | ||
26 | interface = iface; | 27 | interface = iface; |
27 | qDebug("PPPConfigWidget::PPPConfigWidget"); | 28 | qDebug("PPPConfigWidget::PPPConfigWidget"); |
28 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 29 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
29 | 30 | ||
30 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 31 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
31 | qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID()); | 32 | |
32 | 33 | ||
33 | QVBoxLayout *layout = new QVBoxLayout( this ); | 34 | QVBoxLayout *layout = new QVBoxLayout( this ); |
34 | layout->setSpacing( 0 ); | 35 | layout->setSpacing( 0 ); |
35 | layout->setMargin( 1 ); | 36 | layout->setMargin( 1 ); |
36 | tabWindow = new QTabWidget( this, "tabWidget" ); | 37 | tabWindow = new QTabWidget( this, "tabWidget" ); |
37 | layout->addWidget( tabWindow ); | 38 | layout->addWidget( tabWindow ); |
38 | 39 | ||
39 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts" ); | 40 | accounts = new AccountWidget( interface->data(), tabWindow, "accounts", Qt::WStyle_ContextHelp ); |
40 | tabWindow->addTab( accounts, tr("&Accounts") ); | 41 | tabWindow->addTab( accounts, tr("&Accounts") ); |
41 | modem1 = new ModemWidget( interface, tabWindow, "modem1" ); | 42 | devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp ); |
42 | tabWindow->addTab( modem1, tr("&Device") ); | 43 | tabWindow->addTab( devices, tr("&Devices") ); |
43 | modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); | 44 | |
44 | tabWindow->addTab( modem2, tr("&Modem") ); | 45 | //OLD: |
46 | // modem1 = new ModemWidget( interface, tabWindow, "modem1" ); | ||
47 | // tabWindow->addTab( modem1, tr("&Device") ); | ||
48 | // modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); | ||
49 | // tabWindow->addTab( modem2, tr("&Modem") ); | ||
45 | 50 | ||
46 | } | 51 | } |
47 | 52 | ||
48 | 53 | ||
49 | PPPConfigWidget::~PPPConfigWidget() | 54 | PPPConfigWidget::~PPPConfigWidget() |
50 | { | 55 | { |
51 | 56 | ||
52 | } | 57 | } |
53 | 58 | ||
54 | void PPPConfigWidget::accept() | 59 | void PPPConfigWidget::accept() |
55 | { | 60 | { |
56 | qDebug("PPPConfigWidget::accept"); | 61 | qDebug("PPPConfigWidget::accept"); |
57 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); | 62 | qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1()); |
58 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); | 63 | qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); |
59 | interface->setInterfaceName( interface->data()->modemDevice() ); | 64 | interface->setInterfaceName( interface->data()->devname() ); |
60 | interface->setHardwareName( interface->data()->accname() ); | 65 | interface->setHardwareName( interface->data()->accname() ); |
61 | interface->save(); | 66 | interface->save(); |
62 | QDialog::accept(); | 67 | QDialog::accept(); |
63 | } | 68 | } |
64 | 69 | ||
65 | 70 | ||
66 | void PPPConfigWidget::reject() | 71 | void PPPConfigWidget::reject() |
67 | { | 72 | { |
68 | interface->data()->cancel(); | 73 | interface->data()->cancel(); |
69 | QDialog::reject(); | 74 | QDialog::reject(); |
70 | } | 75 | } |
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h index 9bab6fe..4d7912f 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.h +++ b/noncore/settings/networksettings/ppp/pppconfig.h | |||
@@ -1,37 +1,43 @@ | |||
1 | #ifndef _PPPCONFIG_H_ | 1 | #ifndef _PPPCONFIG_H_ |
2 | #define _PPPCONFIG_H_ | 2 | #define _PPPCONFIG_H_ |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | 5 | ||
6 | class QTabWidget; | 6 | class QTabWidget; |
7 | //class Interface; | 7 | //class Interface; |
8 | class InterfacePPP; | 8 | class InterfacePPP; |
9 | class AccountWidget; | 9 | class AccountWidget; |
10 | class GeneralWidget; | 10 | class GeneralWidget; |
11 | class DevicesWidget; | ||
12 | |||
13 | //OLD: | ||
11 | class ModemWidget; | 14 | class ModemWidget; |
12 | class ModemWidget2; | 15 | class ModemWidget2; |
13 | 16 | ||
14 | class PPPConfigWidget : public QDialog { | 17 | class PPPConfigWidget : public QDialog { |
15 | Q_OBJECT | 18 | Q_OBJECT |
16 | public: | 19 | public: |
17 | 20 | ||
18 | PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0, | 21 | PPPConfigWidget( InterfacePPP*, QWidget *parent=0, const char *name=0, |
19 | bool modal = false, WFlags fl = 0 ); | 22 | bool modal = false, WFlags fl = 0 ); |
20 | ~PPPConfigWidget(); | 23 | ~PPPConfigWidget(); |
21 | 24 | ||
22 | 25 | ||
23 | protected slots: | 26 | protected slots: |
24 | virtual void accept(); | 27 | virtual void accept(); |
25 | virtual void reject(); | 28 | virtual void reject(); |
26 | 29 | ||
27 | private: | 30 | private: |
28 | InterfacePPP *interface; | 31 | InterfacePPP *interface; |
29 | QTabWidget *tabWindow; | 32 | QTabWidget *tabWindow; |
30 | AccountWidget *accounts; | 33 | AccountWidget *accounts; |
31 | GeneralWidget *general; | 34 | GeneralWidget *general; |
35 | DevicesWidget* devices; | ||
36 | |||
37 | //OLD: | ||
32 | ModemWidget *modem1; | 38 | ModemWidget *modem1; |
33 | ModemWidget2 *modem2; | 39 | ModemWidget2 *modem2; |
34 | }; | 40 | }; |
35 | 41 | ||
36 | 42 | ||
37 | #endif | 43 | #endif |
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 8f45e54..f4727c1 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp | |||
@@ -1,213 +1,224 @@ | |||
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 "pppdata.h" | 27 | #include "pppdata.h" |
28 | #include "runtests.h" | 28 | #include "runtests.h" |
29 | #include "devices.h" | 29 | //#include "devices.h" |
30 | //#include <klocale.h> | 30 | //#include <klocale.h> |
31 | #define i18n QObject::tr | ||
32 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
33 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 33 | #include <qapplication.h> |
35 | // #include <klocale.h> | 34 | // #include <klocale.h> |
36 | // #include <kconfig.h> | 35 | // #include <kconfig.h> |
37 | // #include <kmessagebox.h> | 36 | // #include <kmessagebox.h> |
38 | // #include <kapplication.h> | 37 | // #include <kapplication.h> |
39 | #include <assert.h> | 38 | #include <assert.h> |
40 | 39 | ||
41 | #define SEPARATOR -sseepp- | 40 | #define SEPARATOR -sseepp- |
42 | #define SEP QString("%1SEPARATOR%1") | 41 | #define SEP QString("%1SEPARATOR%1") |
43 | 42 | ||
44 | PPPData::PPPData() | 43 | PPPData::PPPData() |
45 | : modemDeviceGroup(-1), | 44 | : passwd(""), |
46 | passwd(""), | 45 | _modemName(""), |
47 | highcount(-1), // start out with no entries | 46 | highcount(-1), // start out with no entries |
48 | caccount(-1), // set the current account index also | 47 | highcountdev(-1), // start out with no entries |
48 | // caccount(-1), // set the current account index also | ||
49 | suidprocessid(-1), // process ID of setuid child | 49 | suidprocessid(-1), // process ID of setuid child |
50 | pppdisrunning(false), | 50 | pppdisrunning(false), |
51 | pppderror(0) | 51 | pppderror(0) |
52 | { | 52 | { |
53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; | 53 | highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1; |
54 | highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; | ||
55 | Config cfg = config(); | ||
56 | cfg.setGroup(GENERAL_GRP); | ||
57 | accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); | ||
58 | deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); | ||
59 | qDebug("PPPData::PPPData has a accountList %s", accountList.join("---").latin1()); | ||
60 | qDebug("PPPData::PPPData has a deviceList %s", deviceList.join("---").latin1()); | ||
54 | 61 | ||
55 | if (highcount > MAX_ACCOUNTS) | 62 | // if (highcount > MAX_ACCOUNTS) |
56 | highcount = MAX_ACCOUNTS; | 63 | // highcount = MAX_ACCOUNTS; |
57 | 64 | ||
58 | if(highcount >= 0 && defaultAccount().isEmpty()) { | 65 | // if(highcount >= 0 && defaultAccount().isEmpty()) { |
59 | setAccountbyIndex(0); | 66 | // setAccountbyIndex(0); |
60 | setDefaultAccount(accname()); | 67 | // setDefaultAccount(accname()); |
61 | } else if(!setAccount(defaultAccount())) | 68 | // } else if(!setAccount(defaultAccount())) |
62 | setDefaultAccount(accname()); | 69 | setDefaultAccount(accname()); |
63 | 70 | ||
64 | // start out with internal debugging disabled | 71 | // start out with internal debugging disabled |
65 | // the user is still free to specify `debug' on his own | 72 | // the user is still free to specify `debug' on his own |
66 | setPPPDebug(false); | 73 | setPPPDebug(false); |
67 | 74 | ||
68 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); | 75 | ::pppdVersion(&pppdVer, &pppdMod, &pppdPatch); |
69 | 76 | ||
70 | } | 77 | } |
71 | 78 | ||
72 | Config PPPData::config() | 79 | Config PPPData::config() |
73 | { | 80 | { |
74 | return Config("NetworkSetupPPP"); | 81 | return Config("NetworkSetupPPP"); |
75 | } | 82 | } |
76 | 83 | ||
77 | // | 84 | // |
78 | // save configuration | 85 | // save configuration |
79 | // | 86 | // |
80 | void PPPData::save() | 87 | void PPPData::save() |
81 | { | 88 | { |
82 | qDebug("PPPData saving data"); | 89 | qDebug("PPPData saving data"); |
83 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); | 90 | writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); |
91 | writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); | ||
84 | QString key; | 92 | QString key; |
85 | QStringList keys; | 93 | QStringList keys; |
86 | Config cfg = config(); | 94 | Config cfg = config(); |
95 | cfg.setGroup(GENERAL_GRP); | ||
96 | cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); | ||
97 | cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); | ||
98 | |||
87 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | 99 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); |
88 | it != stringEntries.end(); ++it ){ | 100 | it != stringEntries.end(); ++it ){ |
89 | QString val = it.data(); | 101 | QString val = it.data(); |
90 | key = it.key(); | 102 | key = it.key(); |
91 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); | 103 | // qDebug("saving %s -> %s", key.latin1(), val.latin1() ); |
92 | keys = QStringList::split( "SEPARATOR", key ); | 104 | keys = QStringList::split( "SEPARATOR", key ); |
93 | qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | 105 | //qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); |
94 | cfg.setGroup(keys[0]); | 106 | cfg.setGroup(keys[0]); |
95 | cfg.writeEntry(keys[1], val); | 107 | cfg.writeEntry(keys[1], val); |
96 | } | 108 | } |
97 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | 109 | for( QMap<QString,int>::Iterator it = intEntries.begin(); |
98 | it != intEntries.end(); ++it ){ | 110 | it != intEntries.end(); ++it ){ |
99 | int val = it.data(); | 111 | int val = it.data(); |
100 | key = it.key(); | 112 | key = it.key(); |
101 | // qDebug("saving %s -> %i", key.latin1(), val ); | 113 | // qDebug("saving %s -> %i", key.latin1(), val ); |
102 | keys = QStringList::split( "SEPARATOR", key ); | 114 | keys = QStringList::split( "SEPARATOR", key ); |
103 | qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); | 115 | //qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val ); |
104 | cfg.setGroup(keys[0]); | 116 | cfg.setGroup(keys[0]); |
105 | cfg.writeEntry(keys[1], val); | 117 | cfg.writeEntry(keys[1], val); |
106 | } | 118 | } |
107 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | 119 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); |
108 | it != listEntries.end(); ++it ){ | 120 | it != listEntries.end(); ++it ){ |
109 | QStringList val = it.data(); | 121 | QStringList val = it.data(); |
110 | key = it.key(); | 122 | key = it.key(); |
111 | QChar sep = sepEntries[key]; | 123 | QChar sep = sepEntries[key]; |
112 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); | 124 | // qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() ); |
113 | keys = QStringList::split( "SEPARATOR", key ); | 125 | keys = QStringList::split( "SEPARATOR", key ); |
114 | qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() ); | ||
115 | cfg.setGroup(keys[0]); | 126 | cfg.setGroup(keys[0]); |
116 | cfg.writeEntry(keys[1], val, sep); | 127 | cfg.writeEntry(keys[1], val, sep); |
117 | } | 128 | } |
118 | } | 129 | } |
119 | 130 | ||
120 | 131 | ||
121 | // | 132 | // |
122 | // cancel changes | 133 | // cancel changes |
123 | // | 134 | // |
124 | void PPPData::cancel() { | 135 | void PPPData::cancel() { |
125 | stringEntries.clear(); | 136 | stringEntries.clear(); |
126 | intEntries.clear(); | 137 | intEntries.clear(); |
127 | listEntries.clear(); | 138 | listEntries.clear(); |
128 | } | 139 | } |
129 | 140 | ||
130 | // functions to read/write date to configuration file | 141 | // functions to read/write date to configuration file |
131 | QString PPPData::readConfig(const QString &group, const QString &key, | 142 | QString PPPData::readConfig(const QString &group, const QString &key, |
132 | const QString &defvalue = "") | 143 | const QString &defvalue = "") |
133 | { | 144 | { |
134 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); | 145 | // qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1()); |
135 | QString idx = SEP.arg(group).arg(key); | 146 | QString idx = SEP.arg(group).arg(key); |
136 | if (stringEntries.find(idx) != stringEntries.end()) | 147 | if (stringEntries.find(idx) != stringEntries.end()) |
137 | return stringEntries[idx]; | 148 | return stringEntries[idx]; |
138 | Config cfg = config(); | 149 | Config cfg = config(); |
139 | cfg.setGroup(group); | 150 | cfg.setGroup(group); |
140 | return cfg.readEntry(key, defvalue); | 151 | return cfg.readEntry(key, defvalue); |
141 | } | 152 | } |
142 | 153 | ||
143 | 154 | ||
144 | int PPPData::readNumConfig(const QString &group, const QString &key, | 155 | int PPPData::readNumConfig(const QString &group, const QString &key, |
145 | int defvalue) | 156 | int defvalue) |
146 | { | 157 | { |
147 | QString idx = SEP.arg(group).arg(key); | 158 | QString idx = SEP.arg(group).arg(key); |
148 | if (intEntries.find(idx) != intEntries.end()) | 159 | if (intEntries.find(idx) != intEntries.end()) |
149 | return intEntries[idx]; | 160 | return intEntries[idx]; |
150 | Config cfg = config(); | 161 | Config cfg = config(); |
151 | cfg.setGroup(group); | 162 | cfg.setGroup(group); |
152 | return cfg.readNumEntry(key, defvalue); | 163 | return cfg.readNumEntry(key, defvalue); |
153 | 164 | ||
154 | // if (config) { | 165 | // if (config) { |
155 | // config->setGroup(group); | 166 | // config->setGroup(group); |
156 | // return config->readNumEntry(key, defvalue); | 167 | // return config->readNumEntry(key, defvalue); |
157 | // } else | 168 | // } else |
158 | // return defvalue; | 169 | // return defvalue; |
159 | 170 | ||
160 | } | 171 | } |
161 | 172 | ||
162 | 173 | ||
163 | bool PPPData::readListConfig(const QString &group, const QString &key, | 174 | bool PPPData::readListConfig(const QString &group, const QString &key, |
164 | QStringList &list, char sep) { | 175 | QStringList &list, char sep) { |
165 | list.clear(); | 176 | list.clear(); |
166 | QString idx = SEP.arg(group).arg(key); | 177 | QString idx = SEP.arg(group).arg(key); |
167 | if (listEntries.find(idx) != listEntries.end()){ | 178 | if (listEntries.find(idx) != listEntries.end()){ |
168 | list = listEntries[idx]; | 179 | list = listEntries[idx]; |
169 | return true; | 180 | return true; |
170 | } | 181 | } |
171 | Config cfg = config(); | 182 | Config cfg = config(); |
172 | cfg.setGroup(group); | 183 | cfg.setGroup(group); |
173 | list = cfg.readListEntry(key, sep); | 184 | list = cfg.readListEntry(key, sep); |
174 | if (list.count() > 0) return true; | 185 | if (list.count() > 0) return true; |
175 | return false; | 186 | return false; |
176 | 187 | ||
177 | // if (config) { | 188 | // if (config) { |
178 | // config->setGroup(group); | 189 | // config->setGroup(group); |
179 | // list = config->readListEntry(key, sep); | 190 | // list = config->readListEntry(key, sep); |
180 | // return true; | 191 | // return true; |
181 | // } else | 192 | // } else |
182 | // return false; | 193 | // return false; |
183 | } | 194 | } |
184 | 195 | ||
185 | 196 | ||
186 | void PPPData::writeConfig(const QString &group, const QString &key, | 197 | void PPPData::writeConfig(const QString &group, const QString &key, |
187 | const QString &value) { | 198 | const QString &value) { |
188 | stringEntries.insert( SEP.arg(group).arg(key), value ); | 199 | stringEntries.insert( SEP.arg(group).arg(key), value ); |
189 | // if (config) { | 200 | // if (config) { |
190 | // config->setGroup(group); | 201 | // config->setGroup(group); |
191 | // config->writeEntry(key, value); | 202 | // config->writeEntry(key, value); |
192 | // } | 203 | // } |
193 | } | 204 | } |
194 | 205 | ||
195 | 206 | ||
196 | void PPPData::writeConfig(const QString &group, const QString &key, int value) | 207 | void PPPData::writeConfig(const QString &group, const QString &key, int value) |
197 | { | 208 | { |
198 | intEntries.insert( SEP.arg(group).arg(key), value ); | 209 | intEntries.insert( SEP.arg(group).arg(key), value ); |
199 | // if (config) { | 210 | // if (config) { |
200 | // config->setGroup(group); | 211 | // config->setGroup(group); |
201 | // config->writeEntry(key, value); | 212 | // config->writeEntry(key, value); |
202 | // } | 213 | // } |
203 | } | 214 | } |
204 | 215 | ||
205 | 216 | ||
206 | void PPPData::writeListConfig(const QString &group, const QString &key, | 217 | void PPPData::writeListConfig(const QString &group, const QString &key, |
207 | QStringList &list, char sep) | 218 | QStringList &list, char sep) |
208 | { | 219 | { |
209 | listEntries.insert( SEP.arg(group).arg(key), list ); | 220 | listEntries.insert( SEP.arg(group).arg(key), list ); |
210 | sepEntries.insert( SEP.arg(group).arg(key), sep ); | 221 | sepEntries.insert( SEP.arg(group).arg(key), sep ); |
211 | // if (config) { | 222 | // if (config) { |
212 | // config->setGroup(group); | 223 | // config->setGroup(group); |
213 | // config->writeEntry(key, list, sep); | 224 | // config->writeEntry(key, list, sep); |
@@ -251,207 +262,219 @@ void PPPData::set_show_clock_on_caption(bool set) { | |||
251 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); | 262 | writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) set); |
252 | } | 263 | } |
253 | 264 | ||
254 | 265 | ||
255 | bool PPPData::get_xserver_exit_disconnect() { | 266 | bool PPPData::get_xserver_exit_disconnect() { |
256 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); | 267 | return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true); |
257 | } | 268 | } |
258 | 269 | ||
259 | 270 | ||
260 | void PPPData::setPPPDebug(bool set) { | 271 | void PPPData::setPPPDebug(bool set) { |
261 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); | 272 | writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set); |
262 | } | 273 | } |
263 | 274 | ||
264 | 275 | ||
265 | bool PPPData::getPPPDebug() { | 276 | bool PPPData::getPPPDebug() { |
266 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); | 277 | return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false); |
267 | } | 278 | } |
268 | 279 | ||
269 | 280 | ||
270 | void PPPData::set_xserver_exit_disconnect(bool set) { | 281 | void PPPData::set_xserver_exit_disconnect(bool set) { |
271 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); | 282 | writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set); |
272 | } | 283 | } |
273 | 284 | ||
274 | 285 | ||
275 | bool PPPData::quit_on_disconnect() { | 286 | bool PPPData::quit_on_disconnect() { |
276 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); | 287 | return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false); |
277 | } | 288 | } |
278 | 289 | ||
279 | 290 | ||
280 | void PPPData::set_quit_on_disconnect(bool set) { | 291 | void PPPData::set_quit_on_disconnect(bool set) { |
281 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); | 292 | writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set); |
282 | } | 293 | } |
283 | 294 | ||
284 | 295 | ||
285 | bool PPPData::get_show_log_window() { | 296 | bool PPPData::get_show_log_window() { |
286 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); | 297 | return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false); |
287 | } | 298 | } |
288 | 299 | ||
289 | 300 | ||
290 | void PPPData::set_show_log_window(bool set) { | 301 | void PPPData::set_show_log_window(bool set) { |
291 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); | 302 | writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set); |
292 | } | 303 | } |
293 | 304 | ||
294 | 305 | ||
295 | bool PPPData::automatic_redial() { | 306 | bool PPPData::automatic_redial() { |
296 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); | 307 | return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE); |
297 | } | 308 | } |
298 | 309 | ||
299 | 310 | ||
300 | void PPPData::set_automatic_redial(bool set) { | 311 | void PPPData::set_automatic_redial(bool set) { |
301 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); | 312 | writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set); |
302 | } | 313 | } |
303 | 314 | ||
304 | 315 | ||
305 | // bool PPPData::get_iconify_on_connect() { | 316 | // bool PPPData::get_iconify_on_connect() { |
306 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); | 317 | // return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE); |
307 | // } | 318 | // } |
308 | 319 | ||
309 | 320 | ||
310 | // void PPPData::set_iconify_on_connect(bool set) { | 321 | // void PPPData::set_iconify_on_connect(bool set) { |
311 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); | 322 | // writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set); |
312 | // } | 323 | // } |
313 | 324 | ||
314 | 325 | ||
315 | // bool PPPData::get_dock_into_panel() { | 326 | // bool PPPData::get_dock_into_panel() { |
316 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); | 327 | // return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false); |
317 | // } | 328 | // } |
318 | 329 | ||
319 | 330 | ||
320 | // void PPPData::set_dock_into_panel(bool set) { | 331 | // void PPPData::set_dock_into_panel(bool set) { |
321 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); | 332 | // writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set); |
322 | // } | 333 | // } |
323 | 334 | ||
324 | 335 | ||
325 | QString PPPData::pppdVersion() { | 336 | QString PPPData::pppdVersion() { |
326 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); | 337 | return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch); |
327 | } | 338 | } |
328 | 339 | ||
329 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { | 340 | bool PPPData::pppdVersionMin(int ver, int mod, int patch) { |
330 | // check if pppd version fulfills minimum requirement | 341 | // check if pppd version fulfills minimum requirement |
331 | return (pppdVer > ver | 342 | return (pppdVer > ver |
332 | || (pppdVer == ver && pppdMod > mod) | 343 | || (pppdVer == ver && pppdMod > mod) |
333 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); | 344 | || (pppdVer == ver && pppdMod == mod && pppdPatch >= patch)); |
334 | } | 345 | } |
335 | 346 | ||
336 | int PPPData::pppdTimeout() { | 347 | int PPPData::pppdTimeout() { |
337 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); | 348 | return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT); |
338 | } | 349 | } |
339 | 350 | ||
340 | 351 | ||
341 | void PPPData::setpppdTimeout(int n) { | 352 | void PPPData::setpppdTimeout(int n) { |
342 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); | 353 | writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n); |
343 | } | 354 | } |
344 | 355 | ||
345 | 356 | ||
346 | const QString PPPData::modemDevice() { | 357 | const QString PPPData::modemDevice() { |
347 | return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]); | 358 | return readConfig (modemGroup(), MODEMDEV_KEY, "/dev/modem" ); |
348 | } | 359 | } |
349 | 360 | ||
350 | 361 | ||
362 | // const QString PPPData::modemName() | ||
363 | // { | ||
364 | // return readConfig(modemGroup(), MODEMNAME_KEY); | ||
365 | // } | ||
366 | |||
367 | // bool PPPData::setModemName(const QString &n) { | ||
368 | // qDebug("Setting modem name to >%s<", n.latin1()); | ||
369 | // _modemName = n; | ||
370 | // writeConfig(cgroup, MODEMNAME_KEY, n); | ||
371 | // return true; //FIXME | ||
372 | // } | ||
373 | |||
374 | // bool PPPData::changeModemName(const QString &n) { | ||
375 | // qDebug("Setting modem name to >%s<", n.latin1()); | ||
376 | // _modemName = n; | ||
377 | // writeConfig(modemGroup(), MODEMNAME_KEY, n); | ||
378 | // return true; //FIXME | ||
379 | // } | ||
380 | |||
351 | bool PPPData::setModemDevice(const QString &n) { | 381 | bool PPPData::setModemDevice(const QString &n) { |
352 | qDebug("Setting modem dev to >%s<", n.latin1()); | 382 | qDebug("Setting modem dev to >%s<", n.latin1()); |
353 | bool ret = false; | 383 | writeConfig(modemGroup(), MODEMDEV_KEY, n); |
354 | for (int i = 0; devices[i]; i++) | 384 | return true; //FIXME |
355 | if (devices[i] == n){ | ||
356 | modemDeviceGroup = i; | ||
357 | writeConfig(modemGroup(), MODEMDEV_KEY, n); | ||
358 | ret = true; | ||
359 | } | ||
360 | qDebug(ret?"SUCCESS":"FAILURE"); | ||
361 | return ret; | ||
362 | } | 385 | } |
363 | 386 | ||
364 | 387 | ||
365 | const QString PPPData::flowcontrol() { | 388 | const QString PPPData::flowcontrol() { |
366 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); | 389 | return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS"); |
367 | } | 390 | } |
368 | 391 | ||
369 | 392 | ||
370 | void PPPData::setFlowcontrol(const QString &n) { | 393 | void PPPData::setFlowcontrol(const QString &n) { |
371 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); | 394 | writeConfig(modemGroup(), FLOWCONTROL_KEY, n); |
372 | } | 395 | } |
373 | 396 | ||
374 | 397 | ||
375 | const QString PPPData::speed() { | 398 | const QString PPPData::speed() { |
376 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); | 399 | QString s = readConfig(modemGroup(), SPEED_KEY, "57600"); |
377 | // undo the damage of a bug in former versions. It left an empty Speed= | 400 | // undo the damage of a bug in former versions. It left an empty Speed= |
378 | // entry in kppprc. kppp did set the serial port to 57600 as default but | 401 | // entry in kppprc. kppp did set the serial port to 57600 as default but |
379 | // pppd wouldn't receive the speed via the command line. | 402 | // pppd wouldn't receive the speed via the command line. |
380 | if(s.toUInt() == 0) | 403 | if(s.toUInt() == 0) |
381 | s = "57600"; | 404 | s = "57600"; |
382 | return s; | 405 | return s; |
383 | } | 406 | } |
384 | 407 | ||
385 | 408 | ||
386 | void PPPData::setSpeed(const QString &n) { | 409 | void PPPData::setSpeed(const QString &n) { |
387 | writeConfig(modemGroup(), SPEED_KEY, n); | 410 | writeConfig(modemGroup(), SPEED_KEY, n); |
388 | } | 411 | } |
389 | 412 | ||
390 | 413 | ||
391 | #if 0 | 414 | #if 0 |
392 | void PPPData::setUseCDLine(const int n) { | 415 | void PPPData::setUseCDLine(const int n) { |
393 | writeConfig(modemGroup(),USECDLINE_KEY,n); | 416 | writeConfig(modemGroup(),USECDLINE_KEY,n); |
394 | } | 417 | } |
395 | 418 | ||
396 | 419 | ||
397 | int PPPData::UseCDLine() { | 420 | int PPPData::UseCDLine() { |
398 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); | 421 | return readNumConfig(modemGroup(),USECDLINE_KEY,0); |
399 | } | 422 | } |
400 | #endif | 423 | #endif |
401 | 424 | ||
402 | const QString PPPData::modemEscapeStr() { | 425 | const QString PPPData::modemEscapeStr() { |
403 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); | 426 | return readConfig(modemGroup(),ESCAPESTR_KEY,"+++"); |
404 | } | 427 | } |
405 | 428 | ||
406 | 429 | ||
407 | void PPPData::setModemEscapeStr(const QString &n) { | 430 | void PPPData::setModemEscapeStr(const QString &n) { |
408 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); | 431 | writeConfig(modemGroup(),ESCAPESTR_KEY,n); |
409 | } | 432 | } |
410 | 433 | ||
411 | 434 | ||
412 | const QString PPPData::modemEscapeResp() { | 435 | const QString PPPData::modemEscapeResp() { |
413 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); | 436 | return readConfig(modemGroup(),ESCAPERESP_KEY,"OK"); |
414 | } | 437 | } |
415 | 438 | ||
416 | 439 | ||
417 | void PPPData::setModemEscapeResp(const QString &n) { | 440 | void PPPData::setModemEscapeResp(const QString &n) { |
418 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); | 441 | writeConfig(modemGroup(),ESCAPERESP_KEY,n); |
419 | } | 442 | } |
420 | 443 | ||
421 | 444 | ||
422 | int PPPData::modemEscapeGuardTime() { | 445 | int PPPData::modemEscapeGuardTime() { |
423 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); | 446 | return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50); |
424 | } | 447 | } |
425 | 448 | ||
426 | 449 | ||
427 | void PPPData::setModemEscapeGuardTime(int n) { | 450 | void PPPData::setModemEscapeGuardTime(int n) { |
428 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); | 451 | writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n); |
429 | } | 452 | } |
430 | 453 | ||
431 | 454 | ||
432 | bool PPPData::modemLockFile() { | 455 | bool PPPData::modemLockFile() { |
433 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); | 456 | return readNumConfig(modemGroup(), LOCKFILE_KEY, 1); |
434 | } | 457 | } |
435 | 458 | ||
436 | 459 | ||
437 | void PPPData::setModemLockFile(bool set) { | 460 | void PPPData::setModemLockFile(bool set) { |
438 | writeConfig(modemGroup(), LOCKFILE_KEY, set); | 461 | writeConfig(modemGroup(), LOCKFILE_KEY, set); |
439 | } | 462 | } |
440 | 463 | ||
441 | 464 | ||
442 | int PPPData::modemTimeout() { | 465 | int PPPData::modemTimeout() { |
443 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); | 466 | return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT); |
444 | } | 467 | } |
445 | 468 | ||
446 | 469 | ||
447 | void PPPData::setModemTimeout(int n) { | 470 | void PPPData::setModemTimeout(int n) { |
448 | writeConfig(modemGroup(), TIMEOUT_KEY, n); | 471 | writeConfig(modemGroup(), TIMEOUT_KEY, n); |
449 | } | 472 | } |
450 | 473 | ||
451 | 474 | ||
452 | int PPPData::modemToneDuration() { | 475 | int PPPData::modemToneDuration() { |
453 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); | 476 | return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION); |
454 | } | 477 | } |
455 | 478 | ||
456 | 479 | ||
457 | void PPPData::setModemToneDuration(int n) { | 480 | void PPPData::setModemToneDuration(int n) { |
@@ -624,339 +647,364 @@ QString PPPData::volumeHigh() { | |||
624 | if(tmp == "M1L4") | 647 | if(tmp == "M1L4") |
625 | tmp = "M1L3"; | 648 | tmp = "M1L3"; |
626 | return tmp; | 649 | return tmp; |
627 | } | 650 | } |
628 | 651 | ||
629 | 652 | ||
630 | void PPPData::setVolumeHigh(const QString &s) { | 653 | void PPPData::setVolumeHigh(const QString &s) { |
631 | writeConfig(modemGroup(), VOLUME_HIGH, s); | 654 | writeConfig(modemGroup(), VOLUME_HIGH, s); |
632 | } | 655 | } |
633 | 656 | ||
634 | 657 | ||
635 | QString PPPData::volumeInitString() { | 658 | QString PPPData::volumeInitString() { |
636 | QString s; | 659 | QString s; |
637 | 660 | ||
638 | switch(volume()) { | 661 | switch(volume()) { |
639 | case 0: | 662 | case 0: |
640 | s = volumeOff(); | 663 | s = volumeOff(); |
641 | break; | 664 | break; |
642 | case 1: | 665 | case 1: |
643 | s = volumeMedium(); | 666 | s = volumeMedium(); |
644 | break; | 667 | break; |
645 | case 2: | 668 | case 2: |
646 | s = volumeHigh(); | 669 | s = volumeHigh(); |
647 | break; | 670 | break; |
648 | default: | 671 | default: |
649 | s = volumeMedium(); | 672 | s = volumeMedium(); |
650 | } | 673 | } |
651 | 674 | ||
652 | return s; | 675 | return s; |
653 | } | 676 | } |
654 | 677 | ||
655 | 678 | ||
656 | int PPPData::volume() { | 679 | int PPPData::volume() { |
657 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); | 680 | return readNumConfig(modemGroup(), VOLUME_KEY, 1); |
658 | } | 681 | } |
659 | 682 | ||
660 | 683 | ||
661 | void PPPData::setVolume(int i) { | 684 | void PPPData::setVolume(int i) { |
662 | writeConfig(modemGroup(), VOLUME_KEY, i); | 685 | writeConfig(modemGroup(), VOLUME_KEY, i); |
663 | } | 686 | } |
664 | 687 | ||
665 | int PPPData::waitForDialTone() { | 688 | int PPPData::waitForDialTone() { |
666 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); | 689 | return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); |
667 | } | 690 | } |
668 | 691 | ||
669 | void PPPData::setWaitForDialTone(int i) { | 692 | void PPPData::setWaitForDialTone(int i) { |
670 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); | 693 | writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); |
671 | } | 694 | } |
672 | 695 | ||
673 | void PPPData::setModemAnswerStr(const QString &n) { | 696 | void PPPData::setModemAnswerStr(const QString &n) { |
674 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); | 697 | writeConfig(modemGroup(), ANSWERSTR_KEY, n); |
675 | } | 698 | } |
676 | 699 | ||
677 | 700 | ||
678 | const QString PPPData::modemRingResp() { | 701 | const QString PPPData::modemRingResp() { |
679 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); | 702 | return readConfig(modemGroup(), RINGRESP_KEY, "RING"); |
680 | } | 703 | } |
681 | 704 | ||
682 | 705 | ||
683 | void PPPData::setModemRingResp(const QString &n) { | 706 | void PPPData::setModemRingResp(const QString &n) { |
684 | writeConfig(modemGroup(), RINGRESP_KEY, n); | 707 | writeConfig(modemGroup(), RINGRESP_KEY, n); |
685 | } | 708 | } |
686 | 709 | ||
687 | 710 | ||
688 | const QString PPPData::modemAnswerResp() { | 711 | const QString PPPData::modemAnswerResp() { |
689 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); | 712 | return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); |
690 | } | 713 | } |
691 | 714 | ||
692 | 715 | ||
693 | void PPPData::setModemAnswerResp(const QString &n) { | 716 | void PPPData::setModemAnswerResp(const QString &n) { |
694 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); | 717 | writeConfig(modemGroup(), ANSWERRESP_KEY, n); |
695 | } | 718 | } |
696 | 719 | ||
697 | 720 | ||
698 | const QString PPPData::enter() { | 721 | const QString PPPData::enter() { |
699 | return readConfig(modemGroup(), ENTER_KEY, "CR"); | 722 | return readConfig(modemGroup(), ENTER_KEY, "CR"); |
700 | } | 723 | } |
701 | 724 | ||
702 | 725 | ||
703 | void PPPData::setEnter(const QString &n) { | 726 | void PPPData::setEnter(const QString &n) { |
704 | writeConfig(modemGroup(), ENTER_KEY, n); | 727 | writeConfig(modemGroup(), ENTER_KEY, n); |
705 | } | 728 | } |
706 | 729 | ||
707 | 730 | ||
708 | // | 731 | // |
709 | // functions to set/return account information | 732 | // functions to set/return account information |
710 | // | 733 | // |
711 | 734 | ||
712 | //returns number of accounts | 735 | //returns number of accounts |
713 | int PPPData::count() const { | 736 | int PPPData::count() const { |
714 | return highcount + 1; | 737 | return highcount + 1; |
715 | } | 738 | } |
716 | 739 | ||
717 | 740 | ||
718 | bool PPPData::setAccount(const QString &aname) { | 741 | bool PPPData::setAccount(const QString &aname) { |
719 | qDebug("setting account to >%s<", aname.latin1()); | 742 | qDebug("setting account to >%s<", aname.latin1()); |
720 | for(int i = 0; i <= highcount; i++) { | 743 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
721 | setAccountbyIndex(i); | 744 | cgroup = *it; |
722 | if(accname() == aname) { | 745 | qDebug("PPPData::setAccount %s", cgroup.latin1()); |
723 | caccount = i; | 746 | qDebug( "iterator %s", (*it).latin1() ); |
724 | qDebug("SUCCESS"); | 747 | if(accname() == aname) { |
725 | return true; | 748 | qDebug("SUCCESS"); |
749 | return true; | ||
750 | } | ||
751 | |||
726 | } | 752 | } |
727 | } | 753 | qDebug("FAILURE"); |
728 | qDebug("FAILURE"); | 754 | return false; |
729 | return false; | ||
730 | } | 755 | } |
731 | 756 | ||
732 | 757 | /* | |
733 | bool PPPData::setAccountbyIndex(int i) { | 758 | bool PPPData::setAccountbyIndex(int i) { |
734 | if(i >= 0 && i <= highcount) { | 759 | if(i >= 0 && i <= highcount) { |
760 | QString tmp; | ||
761 | tmp.sprintf("%s%i", ACCOUNT_GRP, i); | ||
762 | if (_deleted.find(tmp)!=_deleted.end()) return false; | ||
735 | caccount = i; | 763 | caccount = i; |
736 | cgroup.sprintf("%s%i", ACCOUNT_GRP, i); | 764 | cgroup = tmp; |
737 | return true; | 765 | return true; |
738 | } | 766 | } |
739 | return false; | 767 | return false; |
740 | } | 768 | } |
741 | 769 | */ | |
742 | 770 | ||
743 | bool PPPData::isUniqueAccname(const QString &n) { | 771 | bool PPPData::isUniqueAccname(const QString &n) { |
744 | int current = caccount; | 772 | QString save_cgroup = cgroup; |
745 | for(int i=0; i <= highcount; i++) { | 773 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { |
746 | setAccountbyIndex(i); | 774 | cgroup = *it; |
747 | if(accname() == n && i != current) { | 775 | qDebug("PPPData::setAccount %s", cgroup.latin1()); |
748 | setAccountbyIndex(current); | 776 | qDebug( "%s \n", (*it).latin1() ); |
749 | return false; | 777 | if(accname() == n && cgroup != save_cgroup) { |
750 | } | 778 | cgroup = save_cgroup; |
779 | qDebug("SUCCESS"); | ||
780 | return false; | ||
781 | } | ||
782 | |||
751 | } | 783 | } |
752 | setAccountbyIndex(current); | 784 | cgroup = save_cgroup; |
753 | return true; | 785 | return true; |
754 | } | 786 | } |
755 | 787 | ||
756 | 788 | ||
757 | bool PPPData::deleteAccount() { | 789 | bool PPPData::isUniqueDevname(const QString &n) { |
758 | //FIXME: PPPData::deleteAccount | 790 | QString save_mName = _modemName; |
759 | // if(caccount < 0) | 791 | qDebug("PPPData::isUniqueDevname checking if %s is unique", n.latin1()); |
760 | return false; | 792 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { |
761 | 793 | _modemName = *it; | |
762 | // QMap <QString, QString> map; | 794 | qDebug("PPPData::isUniqueDevname %s == %s", n.latin1() , devname().latin1()); |
763 | // QMap <QString, QString>::Iterator it; | 795 | if(devname() == n && _modemName != save_mName) { |
764 | 796 | _modemName = save_mName; | |
765 | // // set all entries of the current account to "" | 797 | qDebug("NOT UNIQUE"); |
766 | // map = config->entryMap(cgroup); | 798 | return false; |
767 | // it = map.begin(); | 799 | } |
768 | // while (it != map.end()) { | ||
769 | // config->writeEntry(it.key(), ""); | ||
770 | // it++; | ||
771 | // } | ||
772 | 800 | ||
773 | // // shift the succeeding accounts | 801 | } |
774 | // for(int i = caccount+1; i <= highcount; i++) { | 802 | _modemName = save_mName; |
775 | // setAccountbyIndex(i); | 803 | return true; |
776 | // map = config->entryMap(cgroup); | 804 | } |
777 | // it = map.begin(); | ||
778 | // setAccountbyIndex(i-1); | ||
779 | // config->setGroup(cgroup); | ||
780 | // while (it != map.end()) { | ||
781 | // config->writeEntry(it.key(), *it); | ||
782 | // it++; | ||
783 | // } | ||
784 | // } | ||
785 | 805 | ||
786 | // // make sure the top account is cleared | ||
787 | // setAccountbyIndex(highcount); | ||
788 | // map = config->entryMap(cgroup); | ||
789 | // it = map.begin(); | ||
790 | // config->setGroup(cgroup); | ||
791 | // while (it.key() != QString::null) { | ||
792 | // config->writeEntry(it.key(), ""); | ||
793 | // it++; | ||
794 | // } | ||
795 | 806 | ||
796 | // highcount--; | 807 | bool PPPData::deleteAccount() { |
797 | // if(caccount > highcount) | 808 | // FIXME: check if this account exists in a config... |
798 | // caccount = highcount; | 809 | Config cfg = PPPData::config(); |
810 | cfg.setGroup(cgroup); | ||
811 | cfg.clearGroup(); | ||
812 | accountList.remove(cgroup); | ||
799 | 813 | ||
800 | // setAccountbyIndex(caccount); | 814 | QString key; |
815 | QStringList keys; | ||
816 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | ||
817 | it != stringEntries.end(); ++it ){ | ||
818 | QString val = it.data(); | ||
819 | key = it.key(); | ||
820 | keys = QStringList::split( "SEPARATOR", key ); | ||
821 | if(keys[0]==cgroup){ | ||
822 | stringEntries.remove( it ); | ||
823 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | ||
824 | } | ||
825 | } | ||
826 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | ||
827 | it != intEntries.end(); ++it ){ | ||
828 | int val = it.data(); | ||
829 | key = it.key(); | ||
830 | keys = QStringList::split( "SEPARATOR", key ); | ||
831 | if(keys[0]==cgroup){ | ||
832 | intEntries.remove( it ); | ||
833 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | ||
834 | } | ||
835 | } | ||
836 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | ||
837 | it != listEntries.end(); ++it ){ | ||
838 | QStringList val = it.data(); | ||
839 | key = it.key(); | ||
840 | if(keys[0]==cgroup){ | ||
841 | listEntries.remove( it ); | ||
842 | sepEntries.remove( key ); | ||
843 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | ||
844 | } | ||
845 | } | ||
801 | 846 | ||
802 | // return true; | 847 | return true; |
803 | } | 848 | } |
804 | 849 | ||
805 | 850 | ||
806 | bool PPPData::deleteAccount(const QString &aname) { | 851 | bool PPPData::deleteAccount(const QString &aname) { |
807 | if(!setAccount(aname)) | 852 | if(!setAccount(aname)) |
808 | return false; | 853 | return false; |
809 | 854 | ||
810 | deleteAccount(); | 855 | deleteAccount(); |
811 | 856 | ||
812 | return true; | 857 | return true; |
813 | } | 858 | } |
814 | 859 | ||
815 | 860 | ||
816 | int PPPData::newaccount() { | 861 | int PPPData::newaccount() { |
817 | 862 | ||
818 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); | 863 | qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); |
819 | // if(!config) open(); | 864 | // if(!config) open(); |
820 | if (highcount >= MAX_ACCOUNTS) return -1; | 865 | // if (highcount >= MAX_ACCOUNTS) return -1; |
821 | 866 | ||
822 | highcount++; | ||
823 | setAccountbyIndex(highcount); | ||
824 | 867 | ||
868 | QString tmp; | ||
869 | tmp.sprintf("%s%i", ACCOUNT_GRP, ++highcount); | ||
870 | cgroup = QString(tmp); | ||
871 | accountList << tmp; | ||
872 | qDebug("PPPData::newaccount() Group: >%s<",cgroup.latin1()); | ||
825 | setpppdArgumentDefaults(); | 873 | setpppdArgumentDefaults(); |
826 | qDebug("PPPData::newaccount -> %i",caccount); | 874 | return highcount; |
827 | return caccount; | ||
828 | } | 875 | } |
829 | 876 | ||
830 | int PPPData::copyaccount(int i) { | 877 | int PPPData::copyaccount(const QString&) { |
831 | // FIXME: PPPData::copyaccount | 878 | // FIXME: PPPData::copyaccount |
832 | // if(highcount >= MAX_ACCOUNTS) | 879 | // if(highcount >= MAX_ACCOUNTS) |
833 | return -1; | 880 | return -1; |
834 | 881 | ||
835 | // setAccountbyIndex(i); | 882 | // setAccountbyIndex(i); |
836 | 883 | ||
837 | // QMap <QString, QString> map = config->entryMap(cgroup); | 884 | // QMap <QString, QString> map = config->entryMap(cgroup); |
838 | // QMap <QString, QString>::ConstIterator it = map.begin(); | 885 | // QMap <QString, QString>::ConstIterator it = map.begin(); |
839 | 886 | ||
840 | // QString newname = i18n("%1_copy").arg(accname()); | 887 | // QString newname = QObject::tr("%1_copy").arg(accname()); |
841 | 888 | ||
842 | // newaccount(); | 889 | // newaccount(); |
843 | 890 | ||
844 | // while (it != map.end()) { | 891 | // while (it != map.end()) { |
845 | // config->writeEntry(it.key(), *it); | 892 | // config->writeEntry(it.key(), *it); |
846 | // it++; | 893 | // it++; |
847 | // } | 894 | // } |
848 | 895 | ||
849 | // setAccname(newname); | 896 | // setAccname(newname); |
850 | 897 | ||
851 | // return caccount; | 898 | // return caccount; |
852 | } | 899 | } |
853 | 900 | ||
854 | 901 | ||
855 | const QString PPPData::accname() { | 902 | const QString PPPData::accname() { |
856 | return readConfig(cgroup, NAME_KEY); | 903 | return readConfig(cgroup, NAME_KEY); |
857 | } | 904 | } |
858 | 905 | ||
859 | void PPPData::setAccname(const QString &n) { | 906 | void PPPData::setAccname(const QString &n) { |
860 | if(!cgroup.isNull()) { | 907 | if(!cgroup.isNull()) { |
861 | // are we manipulating the default account's name ? then change it, too. | 908 | // are we manipulating the default account's name ? then change it, too. |
862 | bool def = accname() == defaultAccount(); | 909 | bool def = accname() == defaultAccount(); |
863 | writeConfig(cgroup, NAME_KEY, n); | 910 | writeConfig(cgroup, NAME_KEY, n); |
864 | if (def) | 911 | if (def) |
865 | setDefaultAccount(n); | 912 | setDefaultAccount(n); |
866 | } | 913 | } |
914 | writeConfig(cgroup, NAME_KEY, n); | ||
867 | } | 915 | } |
868 | 916 | ||
869 | 917 | ||
870 | #define SEPARATOR_CHAR '&' | 918 | #define SEPARATOR_CHAR '&' |
871 | QStringList &PPPData::phonenumbers() { | 919 | QStringList &PPPData::phonenumbers() { |
872 | 920 | ||
873 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); | 921 | readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); |
874 | return phonelist; | 922 | return phonelist; |
875 | 923 | ||
876 | } | 924 | } |
877 | 925 | ||
878 | 926 | ||
879 | const QString PPPData::phonenumber() { | 927 | const QString PPPData::phonenumber() { |
880 | return readConfig(cgroup, PHONENUMBER_KEY); | 928 | return readConfig(cgroup, PHONENUMBER_KEY); |
881 | } | 929 | } |
882 | 930 | ||
883 | 931 | ||
884 | void PPPData::setPhonenumber(const QString &n) { | 932 | void PPPData::setPhonenumber(const QString &n) { |
885 | writeConfig(cgroup, PHONENUMBER_KEY, n); | 933 | writeConfig(cgroup, PHONENUMBER_KEY, n); |
886 | } | 934 | } |
887 | 935 | ||
888 | 936 | ||
889 | const QString PPPData::dialPrefix() { | 937 | const QString PPPData::dialPrefix() { |
890 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); | 938 | return readConfig(cgroup, DIAL_PREFIX_KEY, ""); |
891 | } | 939 | } |
892 | 940 | ||
893 | 941 | ||
894 | void PPPData::setDialPrefix(const QString &s) { | 942 | void PPPData::setDialPrefix(const QString &s) { |
895 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); | 943 | writeConfig(cgroup, DIAL_PREFIX_KEY, s); |
896 | } | 944 | } |
897 | 945 | ||
898 | 946 | ||
899 | int PPPData::authMethod() { | 947 | int PPPData::authMethod() { |
900 | return readNumConfig(cgroup, AUTH_KEY, 0); | 948 | return readNumConfig(cgroup, AUTH_KEY, 0); |
901 | } | 949 | } |
902 | 950 | ||
903 | 951 | ||
904 | void PPPData::setAuthMethod(int value) { | 952 | void PPPData::setAuthMethod(int value) { |
905 | writeConfig(cgroup, AUTH_KEY, value); | 953 | writeConfig(cgroup, AUTH_KEY, value); |
906 | } | 954 | } |
907 | 955 | ||
908 | 956 | ||
909 | const QString PPPData::storedUsername() { | 957 | const QString PPPData::storedUsername() { |
910 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); | 958 | return readConfig(cgroup, STORED_USERNAME_KEY, ""); |
911 | } | 959 | } |
912 | 960 | ||
913 | 961 | ||
914 | void PPPData::setStoredUsername(const QString &b) { | 962 | void PPPData::setStoredUsername(const QString &b) { |
915 | writeConfig(cgroup, STORED_USERNAME_KEY, b); | 963 | writeConfig(cgroup, STORED_USERNAME_KEY, b); |
916 | } | 964 | } |
917 | 965 | ||
918 | 966 | ||
919 | const QString PPPData::storedPassword() { | 967 | const QString PPPData::storedPassword() { |
920 | qDebug("getting stored pw"); | 968 | qDebug("getting stored pw"); |
921 | qDebug("g %s", cgroup.latin1() ); | 969 | qDebug("g %s", cgroup.latin1() ); |
922 | qDebug("k %s", STORED_PASSWORD_KEY); | 970 | qDebug("k %s", STORED_PASSWORD_KEY); |
923 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); | 971 | return readConfig(cgroup, STORED_PASSWORD_KEY, ""); |
924 | } | 972 | } |
925 | 973 | ||
926 | 974 | ||
927 | void PPPData::setStoredPassword(const QString &b) { | 975 | void PPPData::setStoredPassword(const QString &b) { |
928 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); | 976 | writeConfig(cgroup, STORED_PASSWORD_KEY, b); |
929 | } | 977 | } |
930 | 978 | ||
931 | 979 | ||
932 | bool PPPData::storePassword() { | 980 | bool PPPData::storePassword() { |
933 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); | 981 | return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); |
934 | } | 982 | } |
935 | 983 | ||
936 | 984 | ||
937 | const QString PPPData::command_before_connect() { | 985 | const QString PPPData::command_before_connect() { |
938 | return readConfig(cgroup, BEFORE_CONNECT_KEY); | 986 | return readConfig(cgroup, BEFORE_CONNECT_KEY); |
939 | } | 987 | } |
940 | 988 | ||
941 | 989 | ||
942 | void PPPData::setCommand_before_connect(const QString &n) { | 990 | void PPPData::setCommand_before_connect(const QString &n) { |
943 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); | 991 | writeConfig(cgroup, BEFORE_CONNECT_KEY, n); |
944 | } | 992 | } |
945 | 993 | ||
946 | 994 | ||
947 | void PPPData::setStorePassword(bool b) { | 995 | void PPPData::setStorePassword(bool b) { |
948 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); | 996 | writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); |
949 | } | 997 | } |
950 | 998 | ||
951 | 999 | ||
952 | const QString PPPData::command_on_connect() { | 1000 | const QString PPPData::command_on_connect() { |
953 | return readConfig(cgroup, COMMAND_KEY); | 1001 | return readConfig(cgroup, COMMAND_KEY); |
954 | } | 1002 | } |
955 | 1003 | ||
956 | 1004 | ||
957 | void PPPData::setCommand_on_connect(const QString &n) { | 1005 | void PPPData::setCommand_on_connect(const QString &n) { |
958 | writeConfig(cgroup, COMMAND_KEY, n); | 1006 | writeConfig(cgroup, COMMAND_KEY, n); |
959 | } | 1007 | } |
960 | 1008 | ||
961 | 1009 | ||
962 | const QString PPPData::command_on_disconnect() { | 1010 | const QString PPPData::command_on_disconnect() { |
@@ -1083,220 +1131,365 @@ QStringList &PPPData::dns() { | |||
1083 | 1131 | ||
1084 | 1132 | ||
1085 | void PPPData::setDns(QStringList &list) { | 1133 | void PPPData::setDns(QStringList &list) { |
1086 | writeListConfig(cgroup, DNS_KEY, list); | 1134 | writeListConfig(cgroup, DNS_KEY, list); |
1087 | } | 1135 | } |
1088 | 1136 | ||
1089 | 1137 | ||
1090 | const QString PPPData::domain() { | 1138 | const QString PPPData::domain() { |
1091 | return readConfig(cgroup, DOMAIN_KEY); | 1139 | return readConfig(cgroup, DOMAIN_KEY); |
1092 | } | 1140 | } |
1093 | 1141 | ||
1094 | 1142 | ||
1095 | void PPPData::setDomain(const QString &n ) { | 1143 | void PPPData::setDomain(const QString &n ) { |
1096 | writeConfig(cgroup, DOMAIN_KEY, n); | 1144 | writeConfig(cgroup, DOMAIN_KEY, n); |
1097 | } | 1145 | } |
1098 | 1146 | ||
1099 | 1147 | ||
1100 | QStringList &PPPData::scriptType() { | 1148 | QStringList &PPPData::scriptType() { |
1101 | static QStringList typelist; | 1149 | static QStringList typelist; |
1102 | 1150 | ||
1103 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); | 1151 | readListConfig(cgroup, SCRIPTCOM_KEY, typelist); |
1104 | while(typelist.count() > MAX_SCRIPT_ENTRIES) | 1152 | while(typelist.count() > MAX_SCRIPT_ENTRIES) |
1105 | typelist.remove(typelist.last()); | 1153 | typelist.remove(typelist.last()); |
1106 | 1154 | ||
1107 | return typelist; | 1155 | return typelist; |
1108 | } | 1156 | } |
1109 | 1157 | ||
1110 | 1158 | ||
1111 | void PPPData::setScriptType(QStringList &list) { | 1159 | void PPPData::setScriptType(QStringList &list) { |
1112 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); | 1160 | writeListConfig(cgroup, SCRIPTCOM_KEY, list); |
1113 | } | 1161 | } |
1114 | 1162 | ||
1115 | 1163 | ||
1116 | QStringList &PPPData::script() { | 1164 | QStringList &PPPData::script() { |
1117 | static QStringList scriptlist; | 1165 | static QStringList scriptlist; |
1118 | 1166 | ||
1119 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); | 1167 | readListConfig(cgroup, SCRIPTARG_KEY, scriptlist); |
1120 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) | 1168 | while(scriptlist.count() > MAX_SCRIPT_ENTRIES) |
1121 | scriptlist.remove(scriptlist.last()); | 1169 | scriptlist.remove(scriptlist.last()); |
1122 | 1170 | ||
1123 | return scriptlist; | 1171 | return scriptlist; |
1124 | } | 1172 | } |
1125 | 1173 | ||
1126 | 1174 | ||
1127 | void PPPData::setScript(QStringList &list) { | 1175 | void PPPData::setScript(QStringList &list) { |
1128 | writeListConfig(cgroup, SCRIPTARG_KEY, list); | 1176 | writeListConfig(cgroup, SCRIPTARG_KEY, list); |
1129 | } | 1177 | } |
1130 | 1178 | ||
1131 | 1179 | ||
1132 | // const QString PPPData::accountingFile() { | 1180 | // const QString PPPData::accountingFile() { |
1133 | // return readConfig(cgroup, ACCTFILE_KEY); | 1181 | // return readConfig(cgroup, ACCTFILE_KEY); |
1134 | // } | 1182 | // } |
1135 | 1183 | ||
1136 | 1184 | ||
1137 | // void PPPData::setAccountingFile(const QString &n) { | 1185 | // void PPPData::setAccountingFile(const QString &n) { |
1138 | // writeConfig(cgroup, ACCTFILE_KEY, n); | 1186 | // writeConfig(cgroup, ACCTFILE_KEY, n); |
1139 | // } | 1187 | // } |
1140 | 1188 | ||
1141 | 1189 | ||
1142 | // const QString PPPData::totalCosts() { | 1190 | // const QString PPPData::totalCosts() { |
1143 | // return readConfig(cgroup, TOTALCOSTS_KEY); | 1191 | // return readConfig(cgroup, TOTALCOSTS_KEY); |
1144 | // } | 1192 | // } |
1145 | 1193 | ||
1146 | 1194 | ||
1147 | // void PPPData::setTotalCosts(const QString &n) { | 1195 | // void PPPData::setTotalCosts(const QString &n) { |
1148 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); | 1196 | // writeConfig(cgroup, TOTALCOSTS_KEY, n); |
1149 | // } | 1197 | // } |
1150 | 1198 | ||
1151 | 1199 | ||
1152 | // int PPPData::totalBytes() { | 1200 | // int PPPData::totalBytes() { |
1153 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); | 1201 | // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); |
1154 | // } | 1202 | // } |
1155 | 1203 | ||
1156 | // void PPPData::setTotalBytes(int n) { | 1204 | // void PPPData::setTotalBytes(int n) { |
1157 | // writeConfig(cgroup, TOTALBYTES_KEY, n); | 1205 | // writeConfig(cgroup, TOTALBYTES_KEY, n); |
1158 | // } | 1206 | // } |
1159 | 1207 | ||
1160 | 1208 | ||
1161 | QStringList &PPPData::pppdArgument() { | 1209 | QStringList &PPPData::pppdArgument() { |
1162 | static QStringList arglist; | 1210 | static QStringList arglist; |
1163 | 1211 | ||
1164 | while(arglist.count() > MAX_PPPD_ARGUMENTS) | 1212 | while(arglist.count() > MAX_PPPD_ARGUMENTS) |
1165 | arglist.remove(arglist.last()); | 1213 | arglist.remove(arglist.last()); |
1166 | readListConfig(cgroup, PPPDARG_KEY, arglist); | 1214 | readListConfig(cgroup, PPPDARG_KEY, arglist); |
1167 | 1215 | ||
1168 | return arglist; | 1216 | return arglist; |
1169 | } | 1217 | } |
1170 | 1218 | ||
1171 | 1219 | ||
1172 | void PPPData::setpppdArgument(QStringList &args) { | 1220 | void PPPData::setpppdArgument(QStringList &args) { |
1173 | writeListConfig(cgroup, PPPDARG_KEY, args); | 1221 | writeListConfig(cgroup, PPPDARG_KEY, args); |
1174 | } | 1222 | } |
1175 | 1223 | ||
1176 | 1224 | ||
1177 | void PPPData::setpppdArgumentDefaults() { | 1225 | void PPPData::setpppdArgumentDefaults() { |
1178 | QStringList arg; | 1226 | QStringList arg; |
1227 | arg << "lcp-echo-failure 0"; | ||
1179 | setpppdArgument(arg); | 1228 | setpppdArgument(arg); |
1180 | } | 1229 | } |
1181 | 1230 | ||
1182 | 1231 | ||
1183 | // // graphing widget | 1232 | // // graphing widget |
1184 | // void PPPData::setGraphingOptions(bool enable, | 1233 | // void PPPData::setGraphingOptions(bool enable, |
1185 | // QColor bg, | 1234 | // QColor bg, |
1186 | // QColor text, | 1235 | // QColor text, |
1187 | // QColor in, | 1236 | // QColor in, |
1188 | // QColor out) | 1237 | // QColor out) |
1189 | // { | 1238 | // { |
1190 | // if(config) { | 1239 | // if(config) { |
1191 | // config->setGroup(GRAPH_GRP); | 1240 | // config->setGroup(GRAPH_GRP); |
1192 | // config->writeEntry(GENABLED, enable); | 1241 | // config->writeEntry(GENABLED, enable); |
1193 | // // config->writeEntry(GCOLOR_BG, bg); | 1242 | // // config->writeEntry(GCOLOR_BG, bg); |
1194 | // // config->writeEntry(GCOLOR_TEXT, text); | 1243 | // // config->writeEntry(GCOLOR_TEXT, text); |
1195 | // // config->writeEntry(GCOLOR_IN, in); | 1244 | // // config->writeEntry(GCOLOR_IN, in); |
1196 | // // config->writeEntry(GCOLOR_OUT, out); | 1245 | // // config->writeEntry(GCOLOR_OUT, out); |
1197 | // } | 1246 | // } |
1198 | // } | 1247 | // } |
1199 | 1248 | ||
1200 | // void PPPData::graphingOptions(bool &enable, | 1249 | // void PPPData::graphingOptions(bool &enable, |
1201 | // QColor &bg, | 1250 | // QColor &bg, |
1202 | // QColor &text, | 1251 | // QColor &text, |
1203 | // QColor &in, | 1252 | // QColor &in, |
1204 | // QColor &out) | 1253 | // QColor &out) |
1205 | // { | 1254 | // { |
1206 | // QColor c; | 1255 | // QColor c; |
1207 | 1256 | ||
1208 | // if(config) { | 1257 | // if(config) { |
1209 | // config->setGroup(GRAPH_GRP); | 1258 | // config->setGroup(GRAPH_GRP); |
1210 | // enable = config->readBoolEntry(GENABLED, true); | 1259 | // enable = config->readBoolEntry(GENABLED, true); |
1211 | // bg = Qt::white; | 1260 | // bg = Qt::white; |
1212 | // //bg = config->readColorEntry(GCOLOR_BG, &c); | 1261 | // //bg = config->readColorEntry(GCOLOR_BG, &c); |
1213 | // text = Qt::black; | 1262 | // text = Qt::black; |
1214 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); | 1263 | // //text = config->readColorEntry(GCOLOR_TEXT, &c); |
1215 | // in = Qt::blue; | 1264 | // in = Qt::blue; |
1216 | // //in = config->readColorEntry(GCOLOR_IN, &c); | 1265 | // //in = config->readColorEntry(GCOLOR_IN, &c); |
1217 | // out = Qt::red; | 1266 | // out = Qt::red; |
1218 | // //out = config->readColorEntry(GCOLOR_OUT, &c); | 1267 | // //out = config->readColorEntry(GCOLOR_OUT, &c); |
1219 | // } | 1268 | // } |
1220 | // } | 1269 | // } |
1221 | 1270 | ||
1222 | 1271 | ||
1223 | // bool PPPData::graphingEnabled() { | 1272 | // bool PPPData::graphingEnabled() { |
1224 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); | 1273 | // return (bool) readNumConfig(GRAPH_GRP, GENABLED, true); |
1225 | // } | 1274 | // } |
1226 | 1275 | ||
1227 | 1276 | ||
1228 | 1277 | ||
1229 | // | 1278 | // |
1230 | //functions to change/set the child pppd process info | 1279 | //functions to change/set the child pppd process info |
1231 | // | 1280 | // |
1232 | bool PPPData::pppdRunning() const { | 1281 | bool PPPData::pppdRunning() const { |
1233 | return pppdisrunning; | 1282 | return pppdisrunning; |
1234 | } | 1283 | } |
1235 | 1284 | ||
1236 | void PPPData::setpppdRunning(bool set) { | 1285 | void PPPData::setpppdRunning(bool set) { |
1237 | pppdisrunning = set; | 1286 | pppdisrunning = set; |
1238 | } | 1287 | } |
1239 | 1288 | ||
1240 | int PPPData::pppdError() const { | 1289 | int PPPData::pppdError() const { |
1241 | return pppderror; | 1290 | return pppderror; |
1242 | } | 1291 | } |
1243 | 1292 | ||
1244 | void PPPData::setpppdError(int err) { | 1293 | void PPPData::setpppdError(int err) { |
1245 | pppderror = err; | 1294 | pppderror = err; |
1246 | } | 1295 | } |
1247 | 1296 | ||
1248 | QString PPPData::modemGroup() | 1297 | QString PPPData::modemGroup() |
1249 | { | 1298 | { |
1250 | if (modemDeviceGroup<0){ | 1299 | if (_modemName.isEmpty()) |
1251 | qDebug("wrong modem %i\n using 0",modemDeviceGroup); | 1300 | _modemName = deviceList[0]; |
1252 | modemDeviceGroup = 0; //FIXME! | 1301 | return _modemName; |
1253 | } | ||
1254 | return QString("%1_%1").arg(MODEM_GRP).arg(modemDeviceGroup); | ||
1255 | } | 1302 | } |
1256 | 1303 | ||
1257 | 1304 | ||
1258 | QMap<QString,QString> PPPData::getConfiguredInterfaces() | 1305 | QMap<QString,QString> PPPData::getConfiguredInterfaces() |
1259 | { | 1306 | { |
1260 | QMap<QString,QString> ifaces; | 1307 | QMap<QString,QString> ifaces; |
1261 | Config config = PPPData::config(); | 1308 | Config config = PPPData::config(); |
1262 | config.setGroup(ACCLIST_GRP); | 1309 | config.setGroup(ACCLIST_GRP); |
1263 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); | 1310 | int count = config.readNumEntry( ACCOUNTS_COUNT, -1 ); |
1264 | QString accGrp, dev, acc; | 1311 | QString accGrp, dev, acc; |
1265 | for (int i = 0; i < count; i++){ | 1312 | for (int i = 0; i < count; i++){ |
1266 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); | 1313 | accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); |
1267 | config.setGroup(accGrp); | 1314 | config.setGroup(accGrp); |
1268 | dev = config.readEntry( ACOUNTS_DEV, "error" ); | 1315 | dev = config.readEntry( ACOUNTS_DEV, "error" ); |
1269 | acc = config.readEntry( ACOUNTS_ACC, "error" ); | 1316 | acc = config.readEntry( ACOUNTS_ACC, "error" ); |
1270 | ifaces.insert( dev, acc ); | 1317 | ifaces.insert( dev, acc ); |
1271 | } | 1318 | } |
1272 | 1319 | ||
1273 | return ifaces; | 1320 | return ifaces; |
1274 | } | 1321 | } |
1275 | 1322 | ||
1276 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) | 1323 | void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) |
1277 | { | 1324 | { |
1278 | QMap<QString,QString>::Iterator it; | 1325 | QMap<QString,QString>::Iterator it; |
1279 | int i = 0; | 1326 | int i = 0; |
1280 | Config cfg = config(); | 1327 | Config cfg = config(); |
1281 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 1328 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
1282 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); | 1329 | cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++)); |
1283 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); | 1330 | cfg.writeEntry( ACOUNTS_DEV, it.key() ); |
1284 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); | 1331 | cfg.writeEntry( ACOUNTS_ACC, it.data() ); |
1285 | qDebug("I %i",i); | 1332 | qDebug("I %i",i); |
1286 | } | 1333 | } |
1287 | cfg.setGroup( ACCLIST_GRP ); | 1334 | cfg.setGroup( ACCLIST_GRP ); |
1288 | qDebug("saved %i account settings", i); | 1335 | qDebug("saved %i account settings", i); |
1289 | cfg.writeEntry( ACCOUNTS_COUNT, i ); | 1336 | cfg.writeEntry( ACCOUNTS_COUNT, i ); |
1290 | 1337 | ||
1291 | } | 1338 | } |
1292 | 1339 | ||
1293 | /** | 1340 | /** |
1294 | * pppd's getword() function knows about escape characters. | 1341 | * pppd's getword() function knows about escape characters. |
1295 | * If we write the username and password to the secrets file | 1342 | * If we write the username and password to the secrets file |
1296 | * we'll therefore have to escape back slashes. | 1343 | * we'll therefore have to escape back slashes. |
1297 | */ | 1344 | */ |
1298 | QString PPPData::encodeWord(const QString &s) { | 1345 | QString PPPData::encodeWord(const QString &s) { |
1299 | QString r = s; | 1346 | QString r = s; |
1300 | r.replace(QRegExp("\\"), "\\\\"); | 1347 | r.replace(QRegExp("\\"), "\\\\"); |
1301 | return r; | 1348 | return r; |
1302 | } | 1349 | } |
1350 | |||
1351 | QStringList PPPData::getDevicesList() | ||
1352 | { | ||
1353 | Config cfg("NetworkSetupPPP"); | ||
1354 | cfg.setGroup("Devices_General"); | ||
1355 | return cfg.readListEntry(DEVICES_LIST,DEVICES_LIST_SEP); | ||
1356 | } | ||
1357 | |||
1358 | QStringList PPPData::getAccountList() | ||
1359 | { | ||
1360 | QStringList list; | ||
1361 | QString save_cgroup; | ||
1362 | save_cgroup = cgroup; | ||
1363 | for ( QStringList::Iterator it = accountList.begin(); it != accountList.end(); ++it ) { | ||
1364 | cgroup = *it; | ||
1365 | list << accname(); | ||
1366 | } | ||
1367 | cgroup = save_cgroup; | ||
1368 | return list; | ||
1369 | }; | ||
1370 | |||
1371 | |||
1372 | const QString PPPData::devname() | ||
1373 | { | ||
1374 | QString tmp = readConfig(modemGroup(), MODEMNAME_KEY ); | ||
1375 | qDebug("PPPData::devname() of %s is %s", modemGroup().latin1(), tmp.latin1()); | ||
1376 | return tmp; | ||
1377 | } | ||
1378 | |||
1379 | void PPPData::setDevname(const QString &n) { | ||
1380 | // if(!cgroup.isNull()) { | ||
1381 | // // are we manipulating the default account's name ? then change it, too. | ||
1382 | // bool def = accname() == defaultAccount(); | ||
1383 | // writeConfig(cgroup, NAME_KEY, n); | ||
1384 | // if (def) | ||
1385 | // setDefaultAccount(n); | ||
1386 | // } | ||
1387 | writeConfig(modemGroup(), MODEMNAME_KEY, n ); | ||
1388 | } | ||
1389 | |||
1390 | |||
1391 | bool PPPData::setDevice(const QString &dev ) | ||
1392 | { | ||
1393 | qDebug("setting device to >%s<", dev.latin1()); | ||
1394 | QString save_mName = _modemName; | ||
1395 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | ||
1396 | _modemName = *it; | ||
1397 | qDebug("PPPData::setDevice %s is named %s", _modemName.latin1(), devname().latin1() ); | ||
1398 | qDebug( "iterator %s", (*it).latin1() ); | ||
1399 | if(devname() == dev) { | ||
1400 | qDebug("SUCCESS"); | ||
1401 | return true; | ||
1402 | } | ||
1403 | |||
1404 | } | ||
1405 | _modemName = save_mName; | ||
1406 | qDebug("FAILURE"); | ||
1407 | return false; | ||
1408 | } | ||
1409 | |||
1410 | bool PPPData::deleteDevice() | ||
1411 | { | ||
1412 | // FIXME: check if this account exists in a config... | ||
1413 | Config cfg = PPPData::config(); | ||
1414 | cfg.setGroup(modemGroup()); | ||
1415 | cfg.clearGroup(); | ||
1416 | deviceList.remove(modemGroup()); | ||
1417 | |||
1418 | QString key; | ||
1419 | QStringList keys; | ||
1420 | for( QMap<QString,QString>::Iterator it = stringEntries.begin(); | ||
1421 | it != stringEntries.end(); ++it ){ | ||
1422 | QString val = it.data(); | ||
1423 | key = it.key(); | ||
1424 | keys = QStringList::split( "SEPARATOR", key ); | ||
1425 | if(keys[0]==modemGroup()){ | ||
1426 | stringEntries.remove( it ); | ||
1427 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() ); | ||
1428 | } | ||
1429 | } | ||
1430 | for( QMap<QString,int>::Iterator it = intEntries.begin(); | ||
1431 | it != intEntries.end(); ++it ){ | ||
1432 | int val = it.data(); | ||
1433 | key = it.key(); | ||
1434 | keys = QStringList::split( "SEPARATOR", key ); | ||
1435 | if(keys[0]==modemGroup()){ | ||
1436 | intEntries.remove( it ); | ||
1437 | qDebug("deleting >%s< key >%s< value >%i<", keys[0].latin1(), keys[1].latin1(), val ); | ||
1438 | } | ||
1439 | } | ||
1440 | for( QMap<QString,QStringList>::Iterator it = listEntries.begin(); | ||
1441 | it != listEntries.end(); ++it ){ | ||
1442 | QStringList val = it.data(); | ||
1443 | key = it.key(); | ||
1444 | if(keys[0]==modemGroup()){ | ||
1445 | listEntries.remove( it ); | ||
1446 | sepEntries.remove( key ); | ||
1447 | qDebug("deleting >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.join("").latin1() ); | ||
1448 | } | ||
1449 | } | ||
1450 | |||
1451 | return true; | ||
1452 | |||
1453 | } | ||
1454 | |||
1455 | bool PPPData::deleteDevice(const QString &dev) | ||
1456 | { | ||
1457 | if(!setDevice(dev)) | ||
1458 | return false; | ||
1459 | |||
1460 | return deleteDevice(); | ||
1461 | } | ||
1462 | |||
1463 | int PPPData::newdevice() | ||
1464 | { | ||
1465 | |||
1466 | qDebug("PPPData::newdevice highcount %i",highcountdev); | ||
1467 | |||
1468 | |||
1469 | QString tmp; | ||
1470 | tmp.sprintf("%s%i", MODEM_GRP, ++highcountdev); | ||
1471 | _modemName = QString(tmp); | ||
1472 | deviceList << tmp; | ||
1473 | qDebug("PPPData::newdevice() Group: >%s<",cgroup.latin1()); | ||
1474 | return highcountdev; | ||
1475 | } | ||
1476 | |||
1477 | int PPPData::copydevice(const QString&) | ||
1478 | { | ||
1479 | return false; | ||
1480 | } | ||
1481 | |||
1482 | |||
1483 | QStringList PPPData::getDevicesNamesList() | ||
1484 | { | ||
1485 | QStringList list; | ||
1486 | QString save_mName = _modemName; | ||
1487 | qDebug("PPPData::getDevicesNamesList has %s", deviceList.join("---").latin1()); | ||
1488 | for ( QStringList::Iterator it = deviceList.begin(); it != deviceList.end(); ++it ) { | ||
1489 | _modemName = *it; | ||
1490 | qDebug("PPPData::getDevicesNamesList adding %s as %s",_modemName.latin1(), devname().latin1()); | ||
1491 | list << devname(); | ||
1492 | } | ||
1493 | _modemName = save_mName; | ||
1494 | return list; | ||
1495 | }; | ||
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index 6e1379d..d1cbeb5 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h | |||
@@ -1,438 +1,467 @@ | |||
1 | /* -*- C++ -*- | 1 | /* -*- C++ -*- |
2 | * | 2 | * |
3 | * kPPP: A pppd front end for the KDE project | 3 | * kPPP: A pppd front end for the KDE project |
4 | * | 4 | * |
5 | * $Id$ | 5 | * $Id$ |
6 | * | 6 | * |
7 | * Copyright (C) 1997 Bernd Johannes Wuebben | 7 | * Copyright (C) 1997 Bernd Johannes Wuebben |
8 | * wuebben@math.cornell.edu | 8 | * wuebben@math.cornell.edu |
9 | * | 9 | * |
10 | * based on EzPPP: | 10 | * based on EzPPP: |
11 | * Copyright (C) 1997 Jay Painter | 11 | * Copyright (C) 1997 Jay Painter |
12 | * | 12 | * |
13 | * This program is free software; you can redistribute it and/or | 13 | * This program 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 program is distributed in the hope that it will be useful, | 18 | * This program 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 | #ifndef _PPPDATA_H_ | 28 | #ifndef _PPPDATA_H_ |
29 | #define _PPPDATA_H_ | 29 | #define _PPPDATA_H_ |
30 | 30 | ||
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | 33 | ||
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qmap.h> | 35 | #include <qmap.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
38 | 38 | ||
39 | #include "kpppconfig.h" | 39 | #include "kpppconfig.h" |
40 | 40 | ||
41 | class Config; | 41 | class Config; |
42 | 42 | ||
43 | // string lengths | 43 | // string lengths |
44 | 44 | ||
45 | #define PATH_SIZE 120 | 45 | #define PATH_SIZE 120 |
46 | #define MODEMSTR_SIZE 80 | 46 | #define MODEMSTR_SIZE 80 |
47 | #define ACCNAME_SIZE 50 | 47 | #define ACCNAME_SIZE 50 |
48 | #define PHONENUMBER_SIZE 60 | 48 | #define PHONENUMBER_SIZE 60 |
49 | #define COMMAND_SIZE 255 | 49 | #define COMMAND_SIZE 255 |
50 | #define IPADDR_SIZE 15 | 50 | #define IPADDR_SIZE 15 |
51 | #define DOMAIN_SIZE 50 | 51 | #define DOMAIN_SIZE 50 |
52 | #define TIMEOUT_SIZE 60 | 52 | #define TIMEOUT_SIZE 60 |
53 | 53 | ||
54 | // | 54 | // |
55 | // keys for config file | 55 | // keys for config file |
56 | // | 56 | // |
57 | 57 | ||
58 | // groups | 58 | // groups |
59 | #define GENERAL_GRP "PPP_General" | 59 | #define GENERAL_GRP "PPP_General" |
60 | #define MODEM_GRP "PPP_Modem" | 60 | #define MODEM_GRP "PPP_Modem" |
61 | #define ACCOUNT_GRP "PPP_Account" | 61 | #define ACCOUNT_GRP "PPP_Account" |
62 | #define ACCLIST_GRP "PPP_Accounts_List" | 62 | #define ACCLIST_GRP "PPP_Accounts_List" |
63 | //#define GRAPH_GRP "Graph" | 63 | //#define GRAPH_GRP "Graph" |
64 | //#define WINPOS_GRP "WindowPosition" | 64 | //#define WINPOS_GRP "WindowPosition" |
65 | 65 | ||
66 | // general | 66 | // general |
67 | #define ACCOUNT_LIST "AccountList" | ||
68 | #define DEVICE_LIST "DeviceList" | ||
67 | #define DEFAULTACCOUNT_KEY "DefaultAccount" | 69 | #define DEFAULTACCOUNT_KEY "DefaultAccount" |
68 | #define PPPDVERSION_KEY "pppdVersion" | 70 | #define PPPDVERSION_KEY "pppdVersion" |
69 | #define PPPDTIMEOUT_KEY "pppdTimeout" | 71 | #define PPPDTIMEOUT_KEY "pppdTimeout" |
70 | #define SHOWCLOCK_KEY "ShowClock" | 72 | #define SHOWCLOCK_KEY "ShowClock" |
71 | #define SHOWLOGWIN_KEY "ShowLogWindow" | 73 | #define SHOWLOGWIN_KEY "ShowLogWindow" |
72 | #define AUTOREDIAL_KEY "AutomaticRedial" | 74 | #define AUTOREDIAL_KEY "AutomaticRedial" |
73 | #define DISCONNECT_KEY "DisconnectOnXServerExit" | 75 | #define DISCONNECT_KEY "DisconnectOnXServerExit" |
74 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" | 76 | #define QUITONDISCONNECT_KEY "QuitOnDisconnect" |
75 | #define NUMACCOUNTS_KEY "NumberOfAccounts" | 77 | #define NUMACCOUNTS_KEY "HighcountAccounts" |
78 | #define NUMDEVICES_KEY "HighcountDevices" | ||
76 | #define ID_KEY "ID" | 79 | #define ID_KEY "ID" |
77 | 80 | ||
78 | // modem | 81 | // modem |
82 | #define MODEMNAME_KEY "Modem_Name" | ||
79 | #define MODEMDEV_KEY "Device" | 83 | #define MODEMDEV_KEY "Device" |
80 | #define LOCKFILE_KEY "UseLockFile" | 84 | #define LOCKFILE_KEY "UseLockFile" |
81 | #define FLOWCONTROL_KEY "FlowControl" | 85 | #define FLOWCONTROL_KEY "FlowControl" |
82 | #define SPEED_KEY "Speed" | 86 | #define SPEED_KEY "Speed" |
83 | #define TIMEOUT_KEY "Timeout" | 87 | #define TIMEOUT_KEY "Timeout" |
84 | #define TONEDURATION_KEY "ToneDuration" | 88 | #define TONEDURATION_KEY "ToneDuration" |
85 | #define BUSYWAIT_KEY "BusyWait" | 89 | #define BUSYWAIT_KEY "BusyWait" |
86 | #define INITSTR_KEY "InitString" | 90 | #define INITSTR_KEY "InitString" |
87 | #define INITRESP_KEY "InitResponse" | 91 | #define INITRESP_KEY "InitResponse" |
88 | #define PREINITDELAY_KEY "PreInitDelay" | 92 | #define PREINITDELAY_KEY "PreInitDelay" |
89 | #define INITDELAY_KEY "InitDelay" | 93 | #define INITDELAY_KEY "InitDelay" |
90 | #define NODTDETECT_KEY "NoDialToneDetection" | 94 | #define NODTDETECT_KEY "NoDialToneDetection" |
91 | #define DIALTONEWAIT_KEY "WaitForDialTone" | 95 | #define DIALTONEWAIT_KEY "WaitForDialTone" |
92 | #define DIALSTR_KEY "DialString" | 96 | #define DIALSTR_KEY "DialString" |
93 | #define CONNECTRESP_KEY "ConnectResponse" | 97 | #define CONNECTRESP_KEY "ConnectResponse" |
94 | #define BUSYRESP_KEY "BusyResponse" | 98 | #define BUSYRESP_KEY "BusyResponse" |
95 | #define NOCARRIERRESP_KEY "NoCarrierResponse" | 99 | #define NOCARRIERRESP_KEY "NoCarrierResponse" |
96 | #define NODIALTONERESP_KEY "NoDialToneResp" | 100 | #define NODIALTONERESP_KEY "NoDialToneResp" |
97 | #define HANGUPSTR_KEY "HangupString" | 101 | #define HANGUPSTR_KEY "HangupString" |
98 | #define HANGUPRESP_KEY "HangUpResponse" | 102 | #define HANGUPRESP_KEY "HangUpResponse" |
99 | #define ANSWERSTR_KEY "AnswerString" | 103 | #define ANSWERSTR_KEY "AnswerString" |
100 | #define RINGRESP_KEY "RingResponse" | 104 | #define RINGRESP_KEY "RingResponse" |
101 | #define ANSWERRESP_KEY "AnswerResponse" | 105 | #define ANSWERRESP_KEY "AnswerResponse" |
102 | #define ENTER_KEY "Enter" | 106 | #define ENTER_KEY "Enter" |
103 | #define ESCAPESTR_KEY "EscapeString" | 107 | #define ESCAPESTR_KEY "EscapeString" |
104 | #define ESCAPERESP_KEY "EscapeResponse" | 108 | #define ESCAPERESP_KEY "EscapeResponse" |
105 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" | 109 | #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" |
106 | #define USECDLINE_KEY "UseCDLine" | 110 | #define USECDLINE_KEY "UseCDLine" |
107 | #define VOLUME_HIGH "VolumeHigh" | 111 | #define VOLUME_HIGH "VolumeHigh" |
108 | #define VOLUME_MEDIUM "VolumeMedium" | 112 | #define VOLUME_MEDIUM "VolumeMedium" |
109 | #define VOLUME_OFF "VolumeOff" | 113 | #define VOLUME_OFF "VolumeOff" |
110 | #define VOLUME_KEY "Volume" | 114 | #define VOLUME_KEY "Volume" |
111 | 115 | ||
112 | // account | 116 | // account |
113 | #define NAME_KEY "Name" | 117 | #define NAME_KEY "Name" |
114 | #define PHONENUMBER_KEY "Phonenumber" | 118 | #define PHONENUMBER_KEY "Phonenumber" |
115 | #define DIAL_PREFIX_KEY "DialPrefix" | 119 | #define DIAL_PREFIX_KEY "DialPrefix" |
116 | #define AUTH_KEY "Authentication" | 120 | #define AUTH_KEY "Authentication" |
117 | #define STORED_PASSWORD_KEY "Password" | 121 | #define STORED_PASSWORD_KEY "Password" |
118 | #define STORED_USERNAME_KEY "Username" | 122 | #define STORED_USERNAME_KEY "Username" |
119 | #define STORE_PASSWORD_KEY "StorePassword" | 123 | #define STORE_PASSWORD_KEY "StorePassword" |
120 | #define BEFORE_CONNECT_KEY "BeforeConnect" | 124 | #define BEFORE_CONNECT_KEY "BeforeConnect" |
121 | #define COMMAND_KEY "Command" | 125 | #define COMMAND_KEY "Command" |
122 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" | 126 | #define DISCONNECT_COMMAND_KEY "DisconnectCommand" |
123 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" | 127 | #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" |
124 | #define IPADDR_KEY "IPAddr" | 128 | #define IPADDR_KEY "IPAddr" |
125 | #define SUBNETMASK_KEY "SubnetMask" | 129 | #define SUBNETMASK_KEY "SubnetMask" |
126 | #define ACCTENABLED_KEY "AccountingEnabled" | 130 | #define ACCTENABLED_KEY "AccountingEnabled" |
127 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" | 131 | #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" |
128 | #define ACCTFILE_KEY "AccountingFile" | 132 | #define ACCTFILE_KEY "AccountingFile" |
129 | #define AUTONAME_KEY "AutoName" | 133 | #define AUTONAME_KEY "AutoName" |
130 | #define GATEWAY_KEY "Gateway" | 134 | #define GATEWAY_KEY "Gateway" |
131 | #define DEFAULTROUTE_KEY "DefaultRoute" | 135 | #define DEFAULTROUTE_KEY "DefaultRoute" |
132 | #define DOMAIN_KEY "Domain" | 136 | #define DOMAIN_KEY "Domain" |
133 | #define DNS_KEY "DNS" | 137 | #define DNS_KEY "DNS" |
134 | #define AUTODNS_KEY "AutoDNS" | 138 | #define AUTODNS_KEY "AutoDNS" |
135 | #define EXDNSDISABLED_KEY "ExDNSDisabled" | 139 | #define EXDNSDISABLED_KEY "ExDNSDisabled" |
136 | #define SCRIPTCOM_KEY "ScriptCommands" | 140 | #define SCRIPTCOM_KEY "ScriptCommands" |
137 | #define SCRIPTARG_KEY "ScriptArguments" | 141 | #define SCRIPTARG_KEY "ScriptArguments" |
138 | #define PPPDARG_KEY "pppdArguments" | 142 | #define PPPDARG_KEY "pppdArguments" |
139 | #define PPP_DEBUG_OPTION "PPPDebug" | 143 | #define PPP_DEBUG_OPTION "PPPDebug" |
140 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" | 144 | #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" |
141 | #define DOCKING_KEY "DockIntoPanel" | 145 | #define DOCKING_KEY "DockIntoPanel" |
142 | #define TOTALCOSTS_KEY "TotalCosts" | 146 | #define TOTALCOSTS_KEY "TotalCosts" |
143 | #define TOTALBYTES_KEY "TotalBytes" | 147 | #define TOTALBYTES_KEY "TotalBytes" |
144 | 148 | ||
145 | // pppd errors | 149 | // pppd errors |
146 | #define E_IF_TIMEOUT 1 | 150 | #define E_IF_TIMEOUT 1 |
147 | #define E_PPPD_DIED 2 | 151 | #define E_PPPD_DIED 2 |
148 | 152 | ||
149 | // account list | 153 | // account list |
150 | #define ACCOUNTS_COUNT "Accounts_Count" | 154 | #define ACCOUNTS_COUNT "Accounts_Count" |
151 | #define ACOUNTS_DEV "Accounts_Modem" | 155 | #define ACOUNTS_DEV "Accounts_Modem" |
152 | #define ACOUNTS_ACC "Accounts_Account" | 156 | #define ACOUNTS_ACC "Accounts_Account" |
153 | 157 | ||
158 | #define DEVICESNAMES_LIST "DevicesNames_List" | ||
159 | #define DEVICES_LIST "Devices_List" | ||
160 | #define DEVICES_LIST_SEP ',' | ||
161 | |||
154 | class PPPData { | 162 | class PPPData { |
155 | public: | 163 | public: |
156 | PPPData(); | 164 | PPPData(); |
157 | ~PPPData() {}; | 165 | ~PPPData() {}; |
158 | 166 | ||
159 | enum { NumInitStrings = 2 }; | 167 | enum { NumInitStrings = 2 }; |
160 | 168 | ||
161 | // general functions | 169 | // general functions |
162 | void save(); | 170 | void save(); |
163 | void cancel(); | 171 | void cancel(); |
164 | 172 | ||
173 | QStringList getAccountList(); | ||
174 | |||
165 | static QMap<QString,QString> getConfiguredInterfaces(); | 175 | static QMap<QString,QString> getConfiguredInterfaces(); |
166 | static void setConfiguredInterfaces( QMap<QString,QString> ); | 176 | static void setConfiguredInterfaces( QMap<QString,QString> ); |
167 | 177 | ||
168 | // function to read/write date to configuration file | 178 | // function to read/write date to configuration file |
169 | static Config config(); | 179 | static Config config(); |
170 | QString readConfig(const QString &, const QString &, const QString &); | 180 | QString readConfig(const QString &, const QString &, const QString &); |
171 | int readNumConfig(const QString &, const QString &, int); | 181 | int readNumConfig(const QString &, const QString &, int); |
172 | bool readListConfig(const QString &, const QString &, | 182 | bool readListConfig(const QString &, const QString &, |
173 | QStringList &, char sep = ','); | 183 | QStringList &, char sep = ','); |
174 | void writeConfig(const QString &, const QString &, const QString &); | 184 | void writeConfig(const QString &, const QString &, const QString &); |
175 | void writeConfig(const QString &, const QString &, int); | 185 | void writeConfig(const QString &, const QString &, int); |
176 | void writeListConfig(const QString &, const QString &, | 186 | void writeListConfig(const QString &, const QString &, |
177 | QStringList &, char sep = ','); | 187 | QStringList &, char sep = ','); |
178 | 188 | ||
179 | // return the current account group | 189 | // return the current account group |
180 | QString currentGroup() { return cgroup; } | 190 | QString currentGroup() { return cgroup; } |
181 | QString modemGroup(); | 191 | QString modemGroup(); |
182 | 192 | ||
183 | // functions to set/get general kppp info | 193 | // functions to set/get general kppp info |
184 | QString password(); | 194 | QString password(); |
185 | void setPassword(const QString &); | 195 | void setPassword(const QString &); |
186 | 196 | ||
187 | int currentAccountID() { return caccount; }; | 197 | // int currentAccountID() { return caccount; }; |
188 | const QString defaultAccount(); | 198 | const QString defaultAccount(); |
189 | void setDefaultAccount(const QString &); | 199 | void setDefaultAccount(const QString &); |
190 | 200 | ||
191 | void set_xserver_exit_disconnect(bool set); | 201 | void set_xserver_exit_disconnect(bool set); |
192 | bool get_xserver_exit_disconnect(); | 202 | bool get_xserver_exit_disconnect(); |
193 | 203 | ||
194 | void setPPPDebug(bool set); | 204 | void setPPPDebug(bool set); |
195 | bool getPPPDebug(); | 205 | bool getPPPDebug(); |
196 | 206 | ||
197 | void set_quit_on_disconnect(bool); | 207 | void set_quit_on_disconnect(bool); |
198 | bool quit_on_disconnect(); | 208 | bool quit_on_disconnect(); |
199 | 209 | ||
200 | void set_show_clock_on_caption(bool set); | 210 | void set_show_clock_on_caption(bool set); |
201 | bool get_show_clock_on_caption(); | 211 | bool get_show_clock_on_caption(); |
202 | 212 | ||
203 | void set_show_log_window(bool set); | 213 | void set_show_log_window(bool set); |
204 | bool get_show_log_window(); | 214 | bool get_show_log_window(); |
205 | 215 | ||
206 | void set_automatic_redial(bool set); | 216 | void set_automatic_redial(bool set); |
207 | bool automatic_redial(); | 217 | bool automatic_redial(); |
208 | 218 | ||
209 | // void set_iconify_on_connect(bool set); | 219 | // void set_iconify_on_connect(bool set); |
210 | // bool get_iconify_on_connect(); | 220 | // bool get_iconify_on_connect(); |
211 | 221 | ||
212 | // void set_dock_into_panel(bool set); | 222 | // void set_dock_into_panel(bool set); |
213 | // bool get_dock_into_panel(); | 223 | // bool get_dock_into_panel(); |
214 | 224 | ||
215 | const QString enter(); | 225 | const QString enter(); |
216 | void setEnter(const QString &); | 226 | void setEnter(const QString &); |
217 | 227 | ||
218 | QString pppdVersion(); | 228 | QString pppdVersion(); |
219 | bool pppdVersionMin(int ver, int mod, int patch); | 229 | bool pppdVersionMin(int ver, int mod, int patch); |
220 | 230 | ||
221 | int pppdTimeout(); | 231 | int pppdTimeout(); |
222 | void setpppdTimeout(int); | 232 | void setpppdTimeout(int); |
223 | 233 | ||
224 | int busyWait(); | 234 | int busyWait(); |
225 | void setbusyWait(int); | 235 | void setbusyWait(int); |
226 | 236 | ||
227 | bool modemLockFile(); | 237 | bool modemLockFile(); |
228 | void setModemLockFile(bool set); | 238 | void setModemLockFile(bool set); |
229 | 239 | ||
230 | int modemEscapeGuardTime(); | 240 | int modemEscapeGuardTime(); |
231 | void setModemEscapeGuardTime(int i); | 241 | void setModemEscapeGuardTime(int i); |
232 | 242 | ||
233 | void setModemEscapeStr(const QString &); | 243 | void setModemEscapeStr(const QString &); |
234 | const QString modemEscapeStr(); | 244 | const QString modemEscapeStr(); |
235 | 245 | ||
236 | void setModemEscapeResp(const QString &); | 246 | void setModemEscapeResp(const QString &); |
237 | const QString modemEscapeResp(); | 247 | const QString modemEscapeResp(); |
238 | 248 | ||
239 | const QString modemDevice(); | 249 | // const QString modemName(); |
240 | bool setModemDevice(const QString &); | 250 | // bool setModemName(const QString &); |
251 | // bool changeModemName(const QString &); | ||
252 | |||
253 | const QString modemDevice(); | ||
254 | bool setModemDevice(const QString &); | ||
241 | 255 | ||
242 | const QString flowcontrol(); | 256 | const QString flowcontrol(); |
243 | void setFlowcontrol(const QString &); | 257 | void setFlowcontrol(const QString &); |
244 | 258 | ||
245 | int modemTimeout(); | 259 | int modemTimeout(); |
246 | void setModemTimeout(int); | 260 | void setModemTimeout(int); |
247 | 261 | ||
248 | int modemToneDuration(); | 262 | int modemToneDuration(); |
249 | void setModemToneDuration(int); | 263 | void setModemToneDuration(int); |
250 | 264 | ||
251 | QString volumeInitString(); | 265 | QString volumeInitString(); |
252 | int volume(); | 266 | int volume(); |
253 | void setVolume(int); | 267 | void setVolume(int); |
254 | 268 | ||
255 | int waitForDialTone(); | 269 | int waitForDialTone(); |
256 | void setWaitForDialTone(int i); | 270 | void setWaitForDialTone(int i); |
257 | 271 | ||
258 | // modem command strings/responses | 272 | // modem command strings/responses |
259 | const QString modemInitStr(int i); | 273 | const QString modemInitStr(int i); |
260 | void setModemInitStr(int i, const QString &); | 274 | void setModemInitStr(int i, const QString &); |
261 | 275 | ||
262 | const QString modemInitResp(); | 276 | const QString modemInitResp(); |
263 | void setModemInitResp(const QString &); | 277 | void setModemInitResp(const QString &); |
264 | 278 | ||
265 | int modemPreInitDelay(); | 279 | int modemPreInitDelay(); |
266 | void setModemPreInitDelay(int); | 280 | void setModemPreInitDelay(int); |
267 | 281 | ||
268 | int modemInitDelay(); | 282 | int modemInitDelay(); |
269 | void setModemInitDelay(int); | 283 | void setModemInitDelay(int); |
270 | 284 | ||
271 | QString modemNoDialToneDetectionStr(); | 285 | QString modemNoDialToneDetectionStr(); |
272 | void setModemNoDialToneDetectionStr(const QString &); | 286 | void setModemNoDialToneDetectionStr(const QString &); |
273 | 287 | ||
274 | const QString modemDialStr(); | 288 | const QString modemDialStr(); |
275 | void setModemDialStr(const QString &); | 289 | void setModemDialStr(const QString &); |
276 | 290 | ||
277 | const QString modemConnectResp(); | 291 | const QString modemConnectResp(); |
278 | void setModemConnectResp(const QString &); | 292 | void setModemConnectResp(const QString &); |
279 | 293 | ||
280 | const QString modemBusyResp(); | 294 | const QString modemBusyResp(); |
281 | void setModemBusyResp(const QString &); | 295 | void setModemBusyResp(const QString &); |
282 | 296 | ||
283 | const QString modemNoCarrierResp(); | 297 | const QString modemNoCarrierResp(); |
284 | void setModemNoCarrierResp(const QString &); | 298 | void setModemNoCarrierResp(const QString &); |
285 | 299 | ||
286 | const QString modemNoDialtoneResp(); | 300 | const QString modemNoDialtoneResp(); |
287 | void setModemNoDialtoneResp(const QString &); | 301 | void setModemNoDialtoneResp(const QString &); |
288 | 302 | ||
289 | const QString modemHangupStr(); | 303 | const QString modemHangupStr(); |
290 | void setModemHangupStr(const QString &); | 304 | void setModemHangupStr(const QString &); |
291 | 305 | ||
292 | const QString modemHangupResp(); | 306 | const QString modemHangupResp(); |
293 | void setModemHangupResp(const QString &); | 307 | void setModemHangupResp(const QString &); |
294 | 308 | ||
295 | const QString modemAnswerStr(); | 309 | const QString modemAnswerStr(); |
296 | void setModemAnswerStr(const QString &); | 310 | void setModemAnswerStr(const QString &); |
297 | 311 | ||
298 | const QString modemRingResp(); | 312 | const QString modemRingResp(); |
299 | void setModemRingResp(const QString &); | 313 | void setModemRingResp(const QString &); |
300 | 314 | ||
301 | const QString modemAnswerResp(); | 315 | const QString modemAnswerResp(); |
302 | void setModemAnswerResp(const QString &); | 316 | void setModemAnswerResp(const QString &); |
303 | 317 | ||
304 | QString volumeOff(); | 318 | QString volumeOff(); |
305 | void setVolumeOff(const QString &); | 319 | void setVolumeOff(const QString &); |
306 | 320 | ||
307 | QString volumeMedium(); | 321 | QString volumeMedium(); |
308 | void setVolumeMedium(const QString &); | 322 | void setVolumeMedium(const QString &); |
309 | 323 | ||
310 | QString volumeHigh(); | 324 | QString volumeHigh(); |
311 | void setVolumeHigh(const QString &); | 325 | void setVolumeHigh(const QString &); |
312 | 326 | ||
313 | // functions to set/get account information | 327 | // functions to set/get account information |
314 | int count() const; | 328 | int count() const; |
315 | bool setAccount(const QString &); | 329 | bool setAccount(const QString &); |
316 | bool setAccountbyIndex(int); | 330 | // bool setAccountbyIndex(int); |
317 | 331 | ||
318 | bool isUniqueAccname(const QString &); | 332 | bool isUniqueAccname(const QString &); |
333 | bool isUniqueDevname(const QString &); | ||
319 | 334 | ||
320 | bool deleteAccount(); | 335 | bool deleteAccount(); |
321 | bool deleteAccount(const QString &); | 336 | bool deleteAccount(const QString &); |
322 | int newaccount(); | 337 | int newaccount(); |
323 | int copyaccount(int i); | 338 | int copyaccount(const QString&); |
324 | 339 | ||
325 | const QString accname(); | 340 | const QString accname(); |
326 | void setAccname(const QString &); | 341 | void setAccname(const QString &); |
327 | 342 | ||
328 | QStringList &phonenumbers(); | 343 | QStringList &phonenumbers(); |
329 | const QString phonenumber(); | 344 | const QString phonenumber(); |
330 | void setPhonenumber(const QString &); | 345 | void setPhonenumber(const QString &); |
331 | 346 | ||
332 | const QString dialPrefix(); | 347 | const QString dialPrefix(); |
333 | void setDialPrefix(const QString &); | 348 | void setDialPrefix(const QString &); |
334 | 349 | ||
335 | int authMethod(); | 350 | int authMethod(); |
336 | void setAuthMethod(int); | 351 | void setAuthMethod(int); |
337 | 352 | ||
338 | const QString storedUsername(); | 353 | const QString storedUsername(); |
339 | void setStoredUsername(const QString &); | 354 | void setStoredUsername(const QString &); |
340 | 355 | ||
341 | const QString storedPassword(); | 356 | const QString storedPassword(); |
342 | void setStoredPassword(const QString &); | 357 | void setStoredPassword(const QString &); |
343 | 358 | ||
344 | bool storePassword(); | 359 | bool storePassword(); |
345 | void setStorePassword(bool); | 360 | void setStorePassword(bool); |
346 | 361 | ||
347 | const QString speed(); | 362 | const QString speed(); |
348 | void setSpeed(const QString &); | 363 | void setSpeed(const QString &); |
349 | 364 | ||
350 | const QString command_before_connect(); | 365 | const QString command_before_connect(); |
351 | void setCommand_before_connect(const QString &); | 366 | void setCommand_before_connect(const QString &); |
352 | 367 | ||
353 | const QString command_on_connect(); | 368 | const QString command_on_connect(); |
354 | void setCommand_on_connect(const QString &); | 369 | void setCommand_on_connect(const QString &); |
355 | 370 | ||
356 | const QString command_on_disconnect(); | 371 | const QString command_on_disconnect(); |
357 | void setCommand_on_disconnect(const QString &); | 372 | void setCommand_on_disconnect(const QString &); |
358 | 373 | ||
359 | const QString command_before_disconnect(); | 374 | const QString command_before_disconnect(); |
360 | void setCommand_before_disconnect(const QString &); | 375 | void setCommand_before_disconnect(const QString &); |
361 | 376 | ||
362 | const QString ipaddr(); | 377 | const QString ipaddr(); |
363 | void setIpaddr(const QString &); | 378 | void setIpaddr(const QString &); |
364 | 379 | ||
365 | const QString subnetmask(); | 380 | const QString subnetmask(); |
366 | void setSubnetmask(const QString &); | 381 | void setSubnetmask(const QString &); |
367 | 382 | ||
368 | bool AcctEnabled(); | 383 | bool AcctEnabled(); |
369 | void setAcctEnabled(bool set); | 384 | void setAcctEnabled(bool set); |
370 | 385 | ||
371 | // int VolAcctEnabled(); | 386 | // int VolAcctEnabled(); |
372 | // void setVolAcctEnabled(int set); | 387 | // void setVolAcctEnabled(int set); |
373 | 388 | ||
374 | bool autoDNS(); | 389 | bool autoDNS(); |
375 | void setAutoDNS(bool set); | 390 | void setAutoDNS(bool set); |
376 | 391 | ||
377 | bool exDNSDisabled(); | 392 | bool exDNSDisabled(); |
378 | void setExDNSDisabled(bool set); | 393 | void setExDNSDisabled(bool set); |
379 | 394 | ||
380 | bool autoname(); | 395 | bool autoname(); |
381 | void setAutoname(bool set); | 396 | void setAutoname(bool set); |
382 | 397 | ||
383 | const QString gateway(); | 398 | const QString gateway(); |
384 | void setGateway(const QString &); | 399 | void setGateway(const QString &); |
385 | 400 | ||
386 | bool defaultroute(); | 401 | bool defaultroute(); |
387 | void setDefaultroute(bool set); | 402 | void setDefaultroute(bool set); |
388 | 403 | ||
389 | QStringList &dns(); | 404 | QStringList &dns(); |
390 | void setDns(QStringList &); | 405 | void setDns(QStringList &); |
391 | 406 | ||
392 | const QString domain(); | 407 | const QString domain(); |
393 | void setDomain(const QString &); | 408 | void setDomain(const QString &); |
394 | 409 | ||
395 | QStringList &scriptType(); | 410 | QStringList &scriptType(); |
396 | void setScriptType(QStringList &); | 411 | void setScriptType(QStringList &); |
397 | 412 | ||
398 | QStringList &script(); | 413 | QStringList &script(); |
399 | void setScript(QStringList &); | 414 | void setScript(QStringList &); |
400 | 415 | ||
401 | QStringList &pppdArgument(); | 416 | QStringList &pppdArgument(); |
402 | void setpppdArgumentDefaults(); | 417 | void setpppdArgumentDefaults(); |
403 | void setpppdArgument(QStringList &); | 418 | void setpppdArgument(QStringList &); |
404 | 419 | ||
405 | //functions to change/set the child pppd process info | 420 | //functions to change/set the child pppd process info |
406 | bool pppdRunning() const; | 421 | bool pppdRunning() const; |
407 | void setpppdRunning(bool set); | 422 | void setpppdRunning(bool set); |
408 | 423 | ||
409 | int pppdError() const; | 424 | int pppdError() const; |
410 | void setpppdError(int err); | 425 | void setpppdError(int err); |
411 | 426 | ||
427 | QStringList getDevicesList(); | ||
412 | 428 | ||
413 | static QString encodeWord(const QString &s); | 429 | static QString encodeWord(const QString &s); |
414 | 430 | ||
431 | const QString devname(); | ||
432 | void setDevname(const QString &); | ||
433 | bool setDevice(const QString& ); | ||
434 | bool deleteDevice(); | ||
435 | bool deleteDevice(const QString &); | ||
436 | int newdevice(); | ||
437 | int copydevice(const QString&); | ||
438 | QStringList getDevicesNamesList(); | ||
439 | |||
415 | private: | 440 | private: |
416 | 441 | ||
417 | //static PPPData *_data; | 442 | //static PPPData *_data; |
418 | int modemDeviceGroup; | 443 | // int modemDeviceGroup; |
419 | QString passwd; | 444 | QString passwd; |
420 | // static Config* config; // configuration object | 445 | QString _modemName; |
421 | int highcount; // index of highest account | 446 | int highcount; // index of highest account |
422 | int caccount; // index of the current account | 447 | int highcountdev; // index of highest device |
448 | // int caccount; // index of the current account | ||
423 | QString cgroup; // name of current config group | 449 | QString cgroup; // name of current config group |
424 | pid_t suidprocessid; // process ID of setuid child | 450 | pid_t suidprocessid; // process ID of setuid child |
425 | bool pppdisrunning; // pppd process | 451 | bool pppdisrunning; // pppd process |
426 | // daemon | 452 | // daemon |
427 | int pppderror; // error encounterd running pppd | 453 | int pppderror; // error encounterd running pppd |
428 | int pppdVer, pppdMod, pppdPatch; // pppd version | 454 | int pppdVer, pppdMod, pppdPatch; // pppd version |
429 | 455 | ||
456 | |||
430 | QStringList phonelist; | 457 | QStringList phonelist; |
458 | QStringList accountList; | ||
459 | QStringList deviceList; | ||
431 | QMap<QString,QString> stringEntries; | 460 | QMap<QString,QString> stringEntries; |
432 | QMap<QString,int> intEntries; | 461 | QMap<QString,int> intEntries; |
433 | QMap<QString,QStringList> listEntries; | 462 | QMap<QString,QStringList> listEntries; |
434 | QMap<QString,QChar> sepEntries; | 463 | QMap<QString,QChar> sepEntries; |
435 | 464 | ||
436 | }; | 465 | }; |
437 | 466 | ||
438 | #endif | 467 | #endif |
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index d4c137b..af05eb7 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,137 +1,250 @@ | |||
1 | #include <errno.h> | ||
2 | #include <signal.h> | ||
1 | 3 | ||
4 | |||
5 | #include <qpe/config.h> | ||
6 | |||
7 | #include "modem.h" | ||
2 | #include "pppconfig.h" | 8 | #include "pppconfig.h" |
3 | #include "pppmodule.h" | 9 | #include "pppmodule.h" |
4 | #include "pppdata.h" | 10 | #include "pppdata.h" |
5 | #include "interfaceinformationppp.h" | 11 | #include "interfaceinformationppp.h" |
6 | #include "interfaceppp.h" | 12 | #include "interfaceppp.h" |
7 | 13 | ||
14 | // don't polute global namespace | ||
15 | namespace { | ||
16 | /* | ||
17 | * If network settings is qutting and we've ppp | ||
18 | * devices open we need to save the pid_t the PPData | ||
19 | * and the interface number | ||
20 | */ | ||
21 | struct Connection { | ||
22 | pid_t pid; | ||
23 | QString device; | ||
24 | QString name; | ||
25 | }; | ||
26 | class InterfaceKeeper { | ||
27 | public: | ||
28 | InterfaceKeeper(); | ||
29 | ~InterfaceKeeper(); | ||
30 | |||
31 | void addInterface( pid_t, const QString& pppDev, const QString& name ); | ||
32 | QMap<QString, Connection> interfaces()const; // will check if still available | ||
33 | private: | ||
34 | bool isAvailable( pid_t )const; | ||
35 | QMap<QString, Connection> m_interfaces; | ||
36 | }; | ||
37 | } | ||
38 | |||
8 | 39 | ||
9 | /** | 40 | /** |
10 | * Constructor, find all of the possible interfaces | 41 | * Constructor, find all of the possible interfaces |
42 | * We also need to restore the state.. it could be that | ||
43 | * an interface was up while closing the application | ||
44 | * we need to be able to shut it down... | ||
11 | */ | 45 | */ |
12 | PPPModule::PPPModule() : Module() | 46 | PPPModule::PPPModule() : Module() |
13 | { | 47 | { |
48 | InterfaceKeeper inFace; | ||
49 | QMap<QString,Connection> running = inFace.interfaces(); | ||
50 | QStringList handledInterfaceNames; | ||
51 | |||
14 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); | 52 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
15 | QMap<QString,QString>::Iterator it; | 53 | QMap<QString,QString>::Iterator it; |
16 | InterfacePPP *iface; | 54 | InterfacePPP *iface; |
17 | qDebug("getting interfaces"); | 55 | qDebug("getting interfaces"); |
18 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 56 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ |
19 | qDebug("ifaces %s", it.key().latin1()); | 57 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); |
20 | iface = new InterfacePPP( 0, it.key() ); | 58 | iface = new InterfacePPP( 0, it.key() ); |
21 | iface->setHardwareName( it.data() ); | 59 | iface->setHardwareName( it.data() ); |
22 | list.append( (Interface*)iface ); | 60 | list.append( (Interface*)iface ); |
61 | |||
62 | // check if (*it) is one of the running ifaces | ||
63 | if ( running.contains( it.data() ) ) { | ||
64 | qDebug("iface is running %s", it.key().latin1() ); | ||
65 | handledInterfaceNames << running[it.data()].device; | ||
66 | iface->setStatus( true ); | ||
67 | iface->setPPPDpid( running[it.data()].pid ); | ||
68 | iface->modem()->setPPPDevice( running[it.data()].device ); | ||
69 | iface->refresh(); | ||
70 | } | ||
23 | } | 71 | } |
72 | |||
73 | setHandledInterfaceNames( handledInterfaceNames ); | ||
24 | } | 74 | } |
25 | 75 | ||
26 | /** | 76 | /** |
27 | * Delete any interfaces that we own. | 77 | * Delete any interfaces that we own. |
28 | */ | 78 | */ |
29 | PPPModule::~PPPModule(){ | 79 | PPPModule::~PPPModule(){ |
80 | qDebug("PPPModule::~PPPModule() " ); | ||
30 | QMap<QString,QString> ifaces; | 81 | QMap<QString,QString> ifaces; |
82 | InterfaceKeeper keeper; | ||
31 | Interface *i; | 83 | Interface *i; |
32 | for ( i=list.first(); i != 0; i=list.next() ){ | 84 | for ( i=list.first(); i != 0; i=list.next() ){ |
85 | /* if online save the state */ | ||
86 | if ( i->getStatus() ) { | ||
87 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); | ||
88 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); | ||
89 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); | ||
90 | } | ||
33 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 91 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
34 | delete i; | 92 | delete i; |
35 | } | 93 | } |
36 | PPPData::setConfiguredInterfaces( ifaces ); | 94 | PPPData::setConfiguredInterfaces( ifaces ); |
37 | } | 95 | } |
38 | 96 | ||
39 | /** | 97 | /** |
40 | * Change the current profile | 98 | * Change the current profile |
41 | */ | 99 | */ |
42 | void PPPModule::setProfile(const QString &newProfile){ | 100 | void PPPModule::setProfile(const QString &newProfile){ |
43 | profile = newProfile; | 101 | profile = newProfile; |
44 | } | 102 | } |
45 | 103 | ||
46 | /** | 104 | /** |
47 | * get the icon name for this device. | 105 | * get the icon name for this device. |
48 | * @param Interface* can be used in determining the icon. | 106 | * @param Interface* can be used in determining the icon. |
49 | * @return QString the icon name (minus .png, .gif etc) | 107 | * @return QString the icon name (minus .png, .gif etc) |
50 | */ | 108 | */ |
51 | QString PPPModule::getPixmapName(Interface* ){ | 109 | QString PPPModule::getPixmapName(Interface* ){ |
52 | return "ppp"; | 110 | return "ppp"; |
53 | } | 111 | } |
54 | 112 | ||
55 | /** | 113 | /** |
56 | * Check to see if the interface i is owned by this module. | 114 | * Check to see if the interface i is owned by this module. |
57 | * @param Interface* interface to check against | 115 | * @param Interface* interface to check against |
58 | * @return bool true if i is owned by this module, false otherwise. | 116 | * @return bool true if i is owned by this module, false otherwise. |
59 | */ | 117 | */ |
60 | bool PPPModule::isOwner(Interface *i){ | 118 | bool PPPModule::isOwner(Interface *i){ |
61 | return list.find( i ) != -1; | 119 | return list.find( i ) != -1; |
62 | } | 120 | } |
63 | 121 | ||
64 | /** | 122 | /** |
65 | * Create, and return the WLANConfigure Module | 123 | * Create, and return the WLANConfigure Module |
66 | * @return QWidget* pointer to this modules configure. | 124 | * @return QWidget* pointer to this modules configure. |
67 | */ | 125 | */ |
68 | QWidget *PPPModule::configure(Interface *i){ | 126 | QWidget *PPPModule::configure(Interface *i){ |
69 | qDebug("return ModemWidget"); | 127 | qDebug("return ModemWidget"); |
70 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, | 128 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
71 | 0, "PPPConfig", false, | 129 | 0, "PPPConfig", false, |
72 | Qt::WDestructiveClose ); | 130 | Qt::WDestructiveClose | Qt::WStyle_ContextHelp); |
73 | return pppconfig; | 131 | return pppconfig; |
74 | } | 132 | } |
75 | 133 | ||
76 | /** | 134 | /** |
77 | * Create, and return the Information Module | 135 | * Create, and return the Information Module |
78 | * @return QWidget* pointer to this modules info. | 136 | * @return QWidget* pointer to this modules info. |
79 | */ | 137 | */ |
80 | QWidget *PPPModule::information(Interface *i){ | 138 | QWidget *PPPModule::information(Interface *i){ |
81 | // We don't have any advanced pppd information widget yet :-D | 139 | // We don't have any advanced pppd information widget yet :-D |
82 | // TODO ^ | 140 | // TODO ^ |
83 | 141 | ||
84 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | 142 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); |
85 | } | 143 | } |
86 | 144 | ||
87 | /** | 145 | /** |
88 | * Get all active (up or down) interfaces | 146 | * Get all active (up or down) interfaces |
89 | * @return QList<Interface> A list of interfaces that exsist that havn't | 147 | * @return QList<Interface> A list of interfaces that exsist that havn't |
90 | * been called by isOwner() | 148 | * been called by isOwner() |
91 | */ | 149 | */ |
92 | QList<Interface> PPPModule::getInterfaces(){ | 150 | QList<Interface> PPPModule::getInterfaces(){ |
93 | // List all of the files in the peer directory | 151 | // List all of the files in the peer directory |
94 | qDebug("PPPModule::getInterfaces"); | 152 | qDebug("PPPModule::getInterfaces"); |
95 | return list; | 153 | return list; |
96 | } | 154 | } |
97 | 155 | ||
98 | /** | 156 | /** |
99 | * Attempt to add a new interface as defined by name | 157 | * Attempt to add a new interface as defined by name |
100 | * @param name the name of the type of interface that should be created given | 158 | * @param name the name of the type of interface that should be created given |
101 | * by possibleNewInterfaces(); | 159 | * by possibleNewInterfaces(); |
102 | * @return Interface* NULL if it was unable to be created. | 160 | * @return Interface* NULL if it was unable to be created. |
103 | */ | 161 | */ |
104 | Interface *PPPModule::addNewInterface(const QString &newInterface){ | 162 | Interface *PPPModule::addNewInterface(const QString &newInterface){ |
105 | 163 | ||
106 | InterfacePPP *ifaceppp; | 164 | InterfacePPP *ifaceppp; |
107 | Interface *iface; | 165 | Interface *iface; |
108 | ifaceppp = new InterfacePPP(); | 166 | ifaceppp = new InterfacePPP(); |
109 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); | 167 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
110 | imp.showMaximized(); | 168 | imp.showMaximized(); |
111 | if(imp.exec() == QDialog::Accepted ){ | 169 | if(imp.exec() == QDialog::Accepted ){ |
112 | iface = (InterfacePPP*) ifaceppp; | 170 | iface = (InterfacePPP*) ifaceppp; |
113 | iface->setModuleOwner( this ); | 171 | iface->setModuleOwner( this ); |
114 | list.append( iface ); | 172 | list.append( iface ); |
115 | return iface; | 173 | return iface; |
116 | }else { | 174 | }else { |
117 | delete ifaceppp; | 175 | delete ifaceppp; |
118 | iface = NULL; | 176 | iface = NULL; |
119 | } | 177 | } |
120 | return iface; | 178 | return iface; |
121 | } | 179 | } |
122 | 180 | ||
123 | /** | 181 | /** |
124 | * Attempts to remove the interface, doesn't delete i | 182 | * Attempts to remove the interface, doesn't delete i |
125 | * @return bool true if successfull, false otherwise. | 183 | * @return bool true if successfull, false otherwise. |
126 | */ | 184 | */ |
127 | bool PPPModule::remove(Interface *i){ | 185 | bool PPPModule::remove(Interface *i){ |
128 | return list.remove(i); | 186 | return list.remove(i); |
129 | } | 187 | } |
130 | 188 | ||
131 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | 189 | void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) |
132 | { | 190 | { |
133 | newIfaces.insert(QObject::tr("PPP") , | 191 | newIfaces.insert(QObject::tr("PPP") , |
134 | QObject::tr("generic ppp device")); | 192 | QObject::tr("generic ppp device")); |
135 | } | 193 | } |
136 | 194 | ||
137 | 195 | ||
196 | |||
197 | namespace { | ||
198 | InterfaceKeeper::InterfaceKeeper( ) { | ||
199 | } | ||
200 | InterfaceKeeper::~InterfaceKeeper() { | ||
201 | Config cfg("ppp_plugin_keeper"); | ||
202 | QStringList lst = cfg.groupList(); | ||
203 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
204 | Connection con; | ||
205 | cfg.setGroup( (*it) ); | ||
206 | cfg.clearGroup(); | ||
207 | } | ||
208 | |||
209 | for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) { | ||
210 | Connection con = it.data(); | ||
211 | cfg.setGroup( con.name ); | ||
212 | cfg.writeEntry( "pid", con.pid ); | ||
213 | cfg.writeEntry( "device", con.device ); | ||
214 | } | ||
215 | } | ||
216 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) { | ||
217 | Connection con; | ||
218 | con.pid = pid; | ||
219 | con.device = dev; | ||
220 | con.name = name; | ||
221 | m_interfaces.insert( name, con ); | ||
222 | } | ||
223 | QMap<QString, Connection> InterfaceKeeper::interfaces()const { | ||
224 | Config cfg("ppp_plugin_keeper"); | ||
225 | QMap<QString, Connection> ifaces; | ||
226 | QStringList lst = cfg.groupList(); | ||
227 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | ||
228 | Connection con; | ||
229 | cfg.setGroup( (*it) ); | ||
230 | con.name = (*it); | ||
231 | con.pid = cfg.readNumEntry("pid"); | ||
232 | con.device = cfg.readEntry("device"); | ||
233 | qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); | ||
234 | |||
235 | if ( con.pid != -1 && isAvailable( con.pid ) ) | ||
236 | ifaces.insert( con.name, con ); | ||
237 | } | ||
238 | return ifaces; | ||
239 | } | ||
240 | bool InterfaceKeeper::isAvailable( pid_t p)const { | ||
241 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) { | ||
242 | qDebug("isAvailable %d", p); | ||
243 | return true; | ||
244 | } | ||
245 | |||
246 | qDebug("notAvailable %d", p); | ||
247 | return false; | ||
248 | } | ||
249 | |||
250 | } | ||
diff --git a/noncore/settings/networksettings/ppp/runtests.cpp b/noncore/settings/networksettings/ppp/runtests.cpp index 83ef2ea..5548601 100644 --- a/noncore/settings/networksettings/ppp/runtests.cpp +++ b/noncore/settings/networksettings/ppp/runtests.cpp | |||
@@ -1,279 +1,277 @@ | |||
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 | * This file was contributed by Mario Weilguni <mweilguni@sime.com> | 9 | * This file was contributed by Mario Weilguni <mweilguni@sime.com> |
10 | * Thanks Mario ! | 10 | * Thanks Mario ! |
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 <qdir.h> | 27 | #include <qdir.h> |
28 | #include "runtests.h" | 28 | #include "runtests.h" |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | #include <pwd.h> | 35 | #include <pwd.h> |
36 | #include <netinet/in.h> | 36 | #include <netinet/in.h> |
37 | 37 | ||
38 | #ifdef HAVE_RESOLV_H | 38 | #ifdef HAVE_RESOLV_H |
39 | #include <arpa/nameser.h> | 39 | #include <arpa/nameser.h> |
40 | #include <resolv.h> | 40 | #include <resolv.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #ifndef _PATH_RESCONF | 43 | #ifndef _PATH_RESCONF |
44 | #define _PATH_RESCONF "/etc/resolv.conf" | 44 | #define _PATH_RESCONF "/etc/resolv.conf" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | //#include <klocale.h> | ||
48 | #define i18n QObject::tr | ||
49 | #include "pppdata.h" | 47 | #include "pppdata.h" |
50 | 48 | ||
51 | // initial effective uid (main.cpp) | 49 | // initial effective uid (main.cpp) |
52 | extern uid_t euid; | 50 | extern uid_t euid; |
53 | 51 | ||
54 | // secure pppd location (opener.cpp) | 52 | // secure pppd location (opener.cpp) |
55 | extern const char* pppdPath(); | 53 | extern const char* pppdPath(); |
56 | 54 | ||
57 | // shamelessly stolen from pppd-2.3.5 | 55 | // shamelessly stolen from pppd-2.3.5 |
58 | /******************************************************************** | 56 | /******************************************************************** |
59 | * | 57 | * |
60 | * Internal routine to decode the version.modification.patch level | 58 | * Internal routine to decode the version.modification.patch level |
61 | */ | 59 | */ |
62 | 60 | ||
63 | static void decode_version (const char *_buf, int *version, | 61 | static void decode_version (const char *_buf, int *version, |
64 | int *modification, int *patch) | 62 | int *modification, int *patch) |
65 | { | 63 | { |
66 | char *buffer = qstrdup(_buf); | 64 | char *buffer = qstrdup(_buf); |
67 | char *buf = buffer; | 65 | char *buf = buffer; |
68 | *version = (int) strtoul (buf, &buf, 10); | 66 | *version = (int) strtoul (buf, &buf, 10); |
69 | *modification = 0; | 67 | *modification = 0; |
70 | *patch = 0; | 68 | *patch = 0; |
71 | 69 | ||
72 | if (*buf == '.') | 70 | if (*buf == '.') |
73 | { | 71 | { |
74 | ++buf; | 72 | ++buf; |
75 | *modification = (int) strtoul (buf, &buf, 10); | 73 | *modification = (int) strtoul (buf, &buf, 10); |
76 | if (*buf == '.') | 74 | if (*buf == '.') |
77 | { | 75 | { |
78 | ++buf; | 76 | ++buf; |
79 | *patch = (int) strtoul (buf, &buf, 10); | 77 | *patch = (int) strtoul (buf, &buf, 10); |
80 | } | 78 | } |
81 | } | 79 | } |
82 | 80 | ||
83 | if (*buf != '\0') | 81 | if (*buf != '\0') |
84 | { | 82 | { |
85 | *version = | 83 | *version = |
86 | *modification = | 84 | *modification = |
87 | *patch = 0; | 85 | *patch = 0; |
88 | } | 86 | } |
89 | 87 | ||
90 | delete [] buffer; | 88 | delete [] buffer; |
91 | } | 89 | } |
92 | 90 | ||
93 | 91 | ||
94 | void pppdVersion(int *version, int *modification, int *patch) { | 92 | void pppdVersion(int *version, int *modification, int *patch) { |
95 | char buffer[30]; | 93 | char buffer[30]; |
96 | const char *pppd; | 94 | const char *pppd; |
97 | char *query; | 95 | char *query; |
98 | 96 | ||
99 | *version = *modification = *patch = 0; | 97 | *version = *modification = *patch = 0; |
100 | 98 | ||
101 | // locate pppd | 99 | // locate pppd |
102 | if(!(pppd = pppdPath())) | 100 | if(!(pppd = pppdPath())) |
103 | return; | 101 | return; |
104 | 102 | ||
105 | // call pppd with --version option | 103 | // call pppd with --version option |
106 | if(!(query = new char[strlen(pppd)+25])) | 104 | if(!(query = new char[strlen(pppd)+25])) |
107 | return; | 105 | return; |
108 | strcpy(query, pppd); | 106 | strcpy(query, pppd); |
109 | // had to add a dummy device to prevent a "no device specified | 107 | // had to add a dummy device to prevent a "no device specified |
110 | // and stdin is not a tty" error from newer pppd versions. | 108 | // and stdin is not a tty" error from newer pppd versions. |
111 | strcat(query, " --version /dev/tty 2>&1"); | 109 | strcat(query, " --version /dev/tty 2>&1"); |
112 | fflush(0L); | 110 | fflush(0L); |
113 | FILE *output = popen(query, "r"); | 111 | FILE *output = popen(query, "r"); |
114 | delete [] query; | 112 | delete [] query; |
115 | if(!output) | 113 | if(!output) |
116 | return; | 114 | return; |
117 | 115 | ||
118 | // read output | 116 | // read output |
119 | int size = fread(buffer, sizeof(char), 29, output); | 117 | int size = fread(buffer, sizeof(char), 29, output); |
120 | 118 | ||
121 | if(ferror(output)) { | 119 | if(ferror(output)) { |
122 | pclose(output); | 120 | pclose(output); |
123 | return; | 121 | return; |
124 | } | 122 | } |
125 | pclose(output); | 123 | pclose(output); |
126 | buffer[size] = '\0'; | 124 | buffer[size] = '\0'; |
127 | 125 | ||
128 | // find position of version number x.y.z | 126 | // find position of version number x.y.z |
129 | char *p = buffer; | 127 | char *p = buffer; |
130 | while(*p && !isdigit(*p)) | 128 | while(*p && !isdigit(*p)) |
131 | p++; | 129 | p++; |
132 | if (*p == 0) | 130 | if (*p == 0) |
133 | return; | 131 | return; |
134 | char *p2 = p; | 132 | char *p2 = p; |
135 | while(*p2 == '.' || isdigit(*p2)) | 133 | while(*p2 == '.' || isdigit(*p2)) |
136 | p2++; | 134 | p2++; |
137 | *p2 = '\0'; | 135 | *p2 = '\0'; |
138 | 136 | ||
139 | decode_version(p, version, modification, patch); | 137 | decode_version(p, version, modification, patch); |
140 | } | 138 | } |
141 | 139 | ||
142 | 140 | ||
143 | int uidFromName(const char *uname) { | 141 | int uidFromName(const char *uname) { |
144 | struct passwd *pw; | 142 | struct passwd *pw; |
145 | 143 | ||
146 | setpwent(); | 144 | setpwent(); |
147 | while((pw = getpwent()) != NULL) { | 145 | while((pw = getpwent()) != NULL) { |
148 | if(strcmp(uname, pw->pw_name) == 0) { | 146 | if(strcmp(uname, pw->pw_name) == 0) { |
149 | int uid = pw->pw_uid; | 147 | int uid = pw->pw_uid; |
150 | endpwent(); | 148 | endpwent(); |
151 | return uid; | 149 | return uid; |
152 | } | 150 | } |
153 | } | 151 | } |
154 | 152 | ||
155 | endpwent(); | 153 | endpwent(); |
156 | return -1; | 154 | return -1; |
157 | } | 155 | } |
158 | 156 | ||
159 | 157 | ||
160 | const char *homedirFromUid(uid_t uid) { | 158 | const char *homedirFromUid(uid_t uid) { |
161 | struct passwd *pw; | 159 | struct passwd *pw; |
162 | char *d = 0; | 160 | char *d = 0; |
163 | 161 | ||
164 | setpwent(); | 162 | setpwent(); |
165 | while((pw = getpwent()) != NULL) { | 163 | while((pw = getpwent()) != NULL) { |
166 | if(pw->pw_uid == uid) { | 164 | if(pw->pw_uid == uid) { |
167 | d = strdup(pw->pw_dir); | 165 | d = strdup(pw->pw_dir); |
168 | endpwent(); | 166 | endpwent(); |
169 | return d; | 167 | return d; |
170 | } | 168 | } |
171 | } | 169 | } |
172 | 170 | ||
173 | endpwent(); | 171 | endpwent(); |
174 | return d; | 172 | return d; |
175 | } | 173 | } |
176 | 174 | ||
177 | 175 | ||
178 | const char* getHomeDir() { | 176 | const char* getHomeDir() { |
179 | static const char *hd = 0; | 177 | static const char *hd = 0; |
180 | static bool ranTest = false; | 178 | static bool ranTest = false; |
181 | if(!ranTest) { | 179 | if(!ranTest) { |
182 | hd = homedirFromUid(getuid()); | 180 | hd = homedirFromUid(getuid()); |
183 | ranTest = true; | 181 | ranTest = true; |
184 | } | 182 | } |
185 | 183 | ||
186 | return hd; | 184 | return hd; |
187 | } | 185 | } |
188 | 186 | ||
189 | 187 | ||
190 | int runTests() { | 188 | int runTests() { |
191 | int warning = 0; | 189 | int warning = 0; |
192 | 190 | ||
193 | // Test pre-1: check if the user is allowed to dial-out | 191 | // Test pre-1: check if the user is allowed to dial-out |
194 | if(access("/etc/kppp.allow", R_OK) == 0 && getuid() != 0) { | 192 | if(access("/etc/kppp.allow", R_OK) == 0 && getuid() != 0) { |
195 | bool access = FALSE; | 193 | bool access = FALSE; |
196 | FILE *f; | 194 | FILE *f; |
197 | if((f = fopen("/etc/kppp.allow", "r")) != NULL) { | 195 | if((f = fopen("/etc/kppp.allow", "r")) != NULL) { |
198 | char buf[2048]; // safe | 196 | char buf[2048]; // safe |
199 | while(f != NULL && !feof(f)) { | 197 | while(f != NULL && !feof(f)) { |
200 | if(fgets(buf, sizeof(buf), f) != NULL) { | 198 | if(fgets(buf, sizeof(buf), f) != NULL) { |
201 | QString s(buf); | 199 | QString s(buf); |
202 | 200 | ||
203 | s = s.stripWhiteSpace(); | 201 | s = s.stripWhiteSpace(); |
204 | if(s[0] == '#' || s.length() == 0) | 202 | if(s[0] == '#' || s.length() == 0) |
205 | continue; | 203 | continue; |
206 | 204 | ||
207 | if((uid_t)uidFromName(QFile::encodeName(s)) == getuid()) { | 205 | if((uid_t)uidFromName(QFile::encodeName(s)) == getuid()) { |
208 | access = TRUE; | 206 | access = TRUE; |
209 | fclose(f); | 207 | fclose(f); |
210 | f = NULL; | 208 | f = NULL; |
211 | } | 209 | } |
212 | } | 210 | } |
213 | } | 211 | } |
214 | if(f) | 212 | if(f) |
215 | fclose(f); | 213 | fclose(f); |
216 | } | 214 | } |
217 | 215 | ||
218 | if(!access) { | 216 | if(!access) { |
219 | QMessageBox::warning(0,"error", | 217 | QMessageBox::warning(0,"error", |
220 | i18n("You're not allowed to dial out with " | 218 | QObject::tr("You're not allowed to dial out with " |
221 | "kppp.\nContact your system administrator.")); | 219 | "kppp.\nContact your system administrator.")); |
222 | return TEST_CRITICAL; | 220 | return TEST_CRITICAL; |
223 | } | 221 | } |
224 | } | 222 | } |
225 | 223 | ||
226 | // Test 1: search the pppd binary | 224 | // Test 1: search the pppd binary |
227 | const char *f = pppdPath(); | 225 | const char *f = pppdPath(); |
228 | 226 | ||
229 | if(!f) { | 227 | if(!f) { |
230 | QMessageBox::warning(0,"error", | 228 | QMessageBox::warning(0,"error", |
231 | i18n("Cannot find the PPP daemon!\n" | 229 | QObject::tr("Cannot find the PPP daemon!\n" |
232 | "Make sure that pppd is installed.")); | 230 | "Make sure that pppd is installed.")); |
233 | warning++; | 231 | warning++; |
234 | } | 232 | } |
235 | 233 | ||
236 | // Test 2: check access to the pppd binary | 234 | // Test 2: check access to the pppd binary |
237 | if(f) { | 235 | if(f) { |
238 | #if 0 | 236 | #if 0 |
239 | if(access(f, X_OK) != 0 /* && geteuid() != 0 */) { | 237 | if(access(f, X_OK) != 0 /* && geteuid() != 0 */) { |
240 | KMessageBox::warning(0, | 238 | KMessageBox::warning(0, |
241 | i18n("You do not have the permission " | 239 | QObject::tr("You do not have the permission " |
242 | "to start pppd!\n" | 240 | "to start pppd!\n" |
243 | "Contact your system administrator " | 241 | "Contact your system administrator " |
244 | "and ask to get access to pppd.")); | 242 | "and ask to get access to pppd.")); |
245 | return TEST_CRITICAL; | 243 | return TEST_CRITICAL; |
246 | } | 244 | } |
247 | #endif | 245 | #endif |
248 | 246 | ||
249 | if(geteuid() != 0) { | 247 | if(geteuid() != 0) { |
250 | struct stat st; | 248 | struct stat st; |
251 | stat(f, &st); | 249 | stat(f, &st); |
252 | if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) { | 250 | if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) { |
253 | QMessageBox::warning(0,"error", | 251 | QMessageBox::warning(0,"error", |
254 | i18n("You don't have sufficient permission to run\n" | 252 | QObject::tr("You don't have sufficient permission to run\n" |
255 | "%1\n" | 253 | "%1\n" |
256 | "Please make sure that kppp is owned by root " | 254 | "Please make sure that kppp is owned by root " |
257 | "and has the SUID bit set.").arg(f)); | 255 | "and has the SUID bit set.").arg(f)); |
258 | warning++; | 256 | warning++; |
259 | } | 257 | } |
260 | } | 258 | } |
261 | } | 259 | } |
262 | 260 | ||
263 | // Test 5: check for existence of /etc/resolv.conf | 261 | // Test 5: check for existence of /etc/resolv.conf |
264 | if (access(_PATH_RESCONF, R_OK) != 0) { | 262 | if (access(_PATH_RESCONF, R_OK) != 0) { |
265 | QString file = _PATH_RESCONF" "; | 263 | QString file = _PATH_RESCONF" "; |
266 | QString msgstr = i18n("%1 is missing or can't be read!\n" | 264 | QString msgstr = QObject::tr("%1 is missing or can't be read!\n" |
267 | "Ask your system administrator to create " | 265 | "Ask your system administrator to create " |
268 | "this file (can be empty) with appropriate " | 266 | "this file (can be empty) with appropriate " |
269 | "read and write permissions.").arg(file); | 267 | "read and write permissions.").arg(file); |
270 | QMessageBox::warning(0, "errror", msgstr); | 268 | QMessageBox::warning(0, "errror", msgstr); |
271 | warning ++; | 269 | warning ++; |
272 | } | 270 | } |
273 | 271 | ||
274 | if(warning == 0) | 272 | if(warning == 0) |
275 | return TEST_OK; | 273 | return TEST_OK; |
276 | else | 274 | else |
277 | return TEST_WARNING; | 275 | return TEST_WARNING; |
278 | } | 276 | } |
279 | 277 | ||
diff --git a/noncore/settings/networksettings/wlan/keyedit.cpp b/noncore/settings/networksettings/wlan/keyedit.cpp index ad9ecae..13a1c3b 100644 --- a/noncore/settings/networksettings/wlan/keyedit.cpp +++ b/noncore/settings/networksettings/wlan/keyedit.cpp | |||
@@ -1,21 +1,22 @@ | |||
1 | #include "keyedit.h" | 1 | #include "keyedit.h" |
2 | #include <qlineedit.h> | 2 | #include <qlineedit.h> |
3 | 3 | ||
4 | KeyEdit::KeyEdit(QWidget* parent, const char* name) : | 4 | KeyEdit::KeyEdit(QWidget* parent, const char* name) : |
5 | QLineEdit(parent, name) | 5 | QLineEdit(parent, name) |
6 | { | 6 | { |
7 | setEchoMode(Password); | ||
7 | } | 8 | } |
8 | 9 | ||
9 | KeyEdit::~KeyEdit() | 10 | KeyEdit::~KeyEdit() |
10 | { | 11 | { |
11 | } | 12 | } |
12 | 13 | ||
13 | void KeyEdit::focusInEvent(QFocusEvent *event) | 14 | void KeyEdit::focusInEvent(QFocusEvent *event) |
14 | { | 15 | { |
15 | setEchoMode(Normal); | 16 | setEchoMode(Normal); |
16 | } | 17 | } |
17 | 18 | ||
18 | void KeyEdit::focusOutEvent(QFocusEvent *event) | 19 | void KeyEdit::focusOutEvent(QFocusEvent *event) |
19 | { | 20 | { |
20 | setEchoMode(Password); | 21 | setEchoMode(Password); |
21 | } | 22 | } |
diff --git a/noncore/settings/networksettings/wlan/wlan.ui b/noncore/settings/networksettings/wlan/wlan.ui index 7932445..7e39e23 100644 --- a/noncore/settings/networksettings/wlan/wlan.ui +++ b/noncore/settings/networksettings/wlan/wlan.ui | |||
@@ -1,110 +1,110 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>WLAN</class> | 2 | <class>WLAN</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QDialog</class> | 4 | <class>QDialog</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>WLAN</cstring> | 7 | <cstring>WLAN</cstring> |
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>251</width> | 14 | <width>247</width> |
15 | <height>299</height> | 15 | <height>299</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Wireless Configuration</string> | 20 | <string>Wireless Configuration</string> |
21 | </property> | 21 | </property> |
22 | <property stdset="1"> | 22 | <property stdset="1"> |
23 | <name>sizeGripEnabled</name> | 23 | <name>sizeGripEnabled</name> |
24 | <bool>true</bool> | 24 | <bool>true</bool> |
25 | </property> | 25 | </property> |
26 | <property> | 26 | <property> |
27 | <name>layoutMargin</name> | 27 | <name>layoutMargin</name> |
28 | </property> | 28 | </property> |
29 | <vbox> | 29 | <vbox> |
30 | <property stdset="1"> | 30 | <property stdset="1"> |
31 | <name>margin</name> | 31 | <name>margin</name> |
32 | <number>0</number> | 32 | <number>0</number> |
33 | </property> | 33 | </property> |
34 | <property stdset="1"> | 34 | <property stdset="1"> |
35 | <name>spacing</name> | 35 | <name>spacing</name> |
36 | <number>6</number> | 36 | <number>6</number> |
37 | </property> | 37 | </property> |
38 | <widget> | 38 | <widget> |
39 | <class>QTabWidget</class> | 39 | <class>QTabWidget</class> |
40 | <property stdset="1"> | 40 | <property stdset="1"> |
41 | <name>name</name> | 41 | <name>name</name> |
42 | <cstring>tabWidget</cstring> | 42 | <cstring>tabWidget</cstring> |
43 | </property> | 43 | </property> |
44 | <property stdset="1"> | 44 | <property stdset="1"> |
45 | <name>enabled</name> | 45 | <name>enabled</name> |
46 | <bool>true</bool> | 46 | <bool>true</bool> |
47 | </property> | 47 | </property> |
48 | <widget> | 48 | <widget> |
49 | <class>QWidget</class> | 49 | <class>QWidget</class> |
50 | <property stdset="1"> | 50 | <property stdset="1"> |
51 | <name>name</name> | 51 | <name>name</name> |
52 | <cstring>ConfigPage</cstring> | 52 | <cstring>ConfigPage</cstring> |
53 | </property> | 53 | </property> |
54 | <attribute> | 54 | <attribute> |
55 | <name>title</name> | 55 | <name>title</name> |
56 | <string>General</string> | 56 | <string>General</string> |
57 | </attribute> | 57 | </attribute> |
58 | <spacer> | 58 | <spacer> |
59 | <property> | 59 | <property> |
60 | <name>name</name> | 60 | <name>name</name> |
61 | <cstring>Spacer31</cstring> | 61 | <cstring>Spacer31</cstring> |
62 | </property> | 62 | </property> |
63 | <property stdset="1"> | 63 | <property stdset="1"> |
64 | <name>orientation</name> | 64 | <name>orientation</name> |
65 | <enum>Vertical</enum> | 65 | <enum>Vertical</enum> |
66 | </property> | 66 | </property> |
67 | <property stdset="1"> | 67 | <property stdset="1"> |
68 | <name>sizeType</name> | 68 | <name>sizeType</name> |
69 | <enum>Expanding</enum> | 69 | <enum>Expanding</enum> |
70 | </property> | 70 | </property> |
71 | <property> | 71 | <property> |
72 | <name>sizeHint</name> | 72 | <name>sizeHint</name> |
73 | <size> | 73 | <size> |
74 | <width>20</width> | 74 | <width>20</width> |
75 | <height>20</height> | 75 | <height>20</height> |
76 | </size> | 76 | </size> |
77 | </property> | 77 | </property> |
78 | </spacer> | 78 | </spacer> |
79 | <widget> | 79 | <widget> |
80 | <class>QLabel</class> | 80 | <class>QLabel</class> |
81 | <property stdset="1"> | 81 | <property stdset="1"> |
82 | <name>name</name> | 82 | <name>name</name> |
83 | <cstring>modeLabel</cstring> | 83 | <cstring>modeLabel</cstring> |
84 | </property> | 84 | </property> |
85 | <property stdset="1"> | 85 | <property stdset="1"> |
86 | <name>enabled</name> | 86 | <name>enabled</name> |
87 | <bool>true</bool> | 87 | <bool>true</bool> |
88 | </property> | 88 | </property> |
89 | <property stdset="1"> | 89 | <property stdset="1"> |
90 | <name>geometry</name> | 90 | <name>geometry</name> |
91 | <rect> | 91 | <rect> |
92 | <x>11</x> | 92 | <x>11</x> |
93 | <y>11</y> | 93 | <y>11</y> |
94 | <width>84</width> | 94 | <width>84</width> |
95 | <height>29</height> | 95 | <height>29</height> |
96 | </rect> | 96 | </rect> |
97 | </property> | 97 | </property> |
98 | <property stdset="1"> | 98 | <property stdset="1"> |
99 | <name>sizePolicy</name> | 99 | <name>sizePolicy</name> |
100 | <sizepolicy> | 100 | <sizepolicy> |
101 | <hsizetype>1</hsizetype> | 101 | <hsizetype>1</hsizetype> |
102 | <vsizetype>1</vsizetype> | 102 | <vsizetype>1</vsizetype> |
103 | </sizepolicy> | 103 | </sizepolicy> |
104 | </property> | 104 | </property> |
105 | <property stdset="1"> | 105 | <property stdset="1"> |
106 | <name>text</name> | 106 | <name>text</name> |
107 | <string>Mode</string> | 107 | <string>Mode</string> |
108 | </property> | 108 | </property> |
109 | </widget> | 109 | </widget> |
110 | <widget> | 110 | <widget> |
@@ -194,280 +194,286 @@ | |||
194 | <sizepolicy> | 194 | <sizepolicy> |
195 | <hsizetype>5</hsizetype> | 195 | <hsizetype>5</hsizetype> |
196 | <vsizetype>1</vsizetype> | 196 | <vsizetype>1</vsizetype> |
197 | </sizepolicy> | 197 | </sizepolicy> |
198 | </property> | 198 | </property> |
199 | </widget> | 199 | </widget> |
200 | <widget> | 200 | <widget> |
201 | <class>QLabel</class> | 201 | <class>QLabel</class> |
202 | <property stdset="1"> | 202 | <property stdset="1"> |
203 | <name>name</name> | 203 | <name>name</name> |
204 | <cstring>macLabel</cstring> | 204 | <cstring>macLabel</cstring> |
205 | </property> | 205 | </property> |
206 | <property stdset="1"> | 206 | <property stdset="1"> |
207 | <name>enabled</name> | 207 | <name>enabled</name> |
208 | <bool>false</bool> | 208 | <bool>false</bool> |
209 | </property> | 209 | </property> |
210 | <property stdset="1"> | 210 | <property stdset="1"> |
211 | <name>geometry</name> | 211 | <name>geometry</name> |
212 | <rect> | 212 | <rect> |
213 | <x>11</x> | 213 | <x>11</x> |
214 | <y>108</y> | 214 | <y>108</y> |
215 | <width>39</width> | 215 | <width>39</width> |
216 | <height>25</height> | 216 | <height>25</height> |
217 | </rect> | 217 | </rect> |
218 | </property> | 218 | </property> |
219 | <property stdset="1"> | 219 | <property stdset="1"> |
220 | <name>text</name> | 220 | <name>text</name> |
221 | <string>MAC</string> | 221 | <string>MAC</string> |
222 | </property> | 222 | </property> |
223 | </widget> | 223 | </widget> |
224 | <widget> | 224 | <widget> |
225 | <class>QCheckBox</class> | 225 | <class>QCheckBox</class> |
226 | <property stdset="1"> | 226 | <property stdset="1"> |
227 | <name>name</name> | 227 | <name>name</name> |
228 | <cstring>specifyAp</cstring> | 228 | <cstring>specifyAp</cstring> |
229 | </property> | 229 | </property> |
230 | <property stdset="1"> | 230 | <property stdset="1"> |
231 | <name>geometry</name> | 231 | <name>geometry</name> |
232 | <rect> | 232 | <rect> |
233 | <x>11</x> | 233 | <x>11</x> |
234 | <y>81</y> | 234 | <y>81</y> |
235 | <width>227</width> | 235 | <width>227</width> |
236 | <height>21</height> | 236 | <height>21</height> |
237 | </rect> | 237 | </rect> |
238 | </property> | 238 | </property> |
239 | <property stdset="1"> | 239 | <property stdset="1"> |
240 | <name>text</name> | 240 | <name>text</name> |
241 | <string>Specify &Access Point</string> | 241 | <string>Specify &Access Point</string> |
242 | </property> | 242 | </property> |
243 | </widget> | 243 | </widget> |
244 | <widget> | 244 | <widget> |
245 | <class>QCheckBox</class> | 245 | <class>QCheckBox</class> |
246 | <property stdset="1"> | 246 | <property stdset="1"> |
247 | <name>name</name> | 247 | <name>name</name> |
248 | <cstring>specifyChan</cstring> | 248 | <cstring>specifyChan</cstring> |
249 | </property> | 249 | </property> |
250 | <property stdset="1"> | 250 | <property stdset="1"> |
251 | <name>geometry</name> | 251 | <name>geometry</name> |
252 | <rect> | 252 | <rect> |
253 | <x>11</x> | 253 | <x>11</x> |
254 | <y>141</y> | 254 | <y>141</y> |
255 | <width>129</width> | 255 | <width>129</width> |
256 | <height>21</height> | 256 | <height>21</height> |
257 | </rect> | 257 | </rect> |
258 | </property> | 258 | </property> |
259 | <property stdset="1"> | 259 | <property stdset="1"> |
260 | <name>text</name> | 260 | <name>text</name> |
261 | <string>Specify &Channel</string> | 261 | <string>Specify &Channel</string> |
262 | </property> | 262 | </property> |
263 | </widget> | 263 | </widget> |
264 | <spacer> | 264 | <spacer> |
265 | <property> | 265 | <property> |
266 | <name>name</name> | 266 | <name>name</name> |
267 | <cstring>Spacer10</cstring> | 267 | <cstring>Spacer10</cstring> |
268 | </property> | 268 | </property> |
269 | <property stdset="1"> | 269 | <property stdset="1"> |
270 | <name>orientation</name> | 270 | <name>orientation</name> |
271 | <enum>Horizontal</enum> | 271 | <enum>Horizontal</enum> |
272 | </property> | 272 | </property> |
273 | <property stdset="1"> | 273 | <property stdset="1"> |
274 | <name>sizeType</name> | 274 | <name>sizeType</name> |
275 | <enum>Expanding</enum> | 275 | <enum>Expanding</enum> |
276 | </property> | 276 | </property> |
277 | <property> | 277 | <property> |
278 | <name>sizeHint</name> | 278 | <name>sizeHint</name> |
279 | <size> | 279 | <size> |
280 | <width>20</width> | 280 | <width>20</width> |
281 | <height>20</height> | 281 | <height>20</height> |
282 | </size> | 282 | </size> |
283 | </property> | 283 | </property> |
284 | </spacer> | 284 | </spacer> |
285 | <widget> | 285 | <widget> |
286 | <class>QComboBox</class> | 286 | <class>QComboBox</class> |
287 | <item> | 287 | <item> |
288 | <property> | 288 | <property> |
289 | <name>text</name> | 289 | <name>text</name> |
290 | <string>Auto</string> | 290 | <string>any</string> |
291 | </property> | ||
292 | </item> | ||
293 | <item> | ||
294 | <property> | ||
295 | <name>text</name> | ||
296 | <string>Managed</string> | ||
297 | </property> | ||
298 | </item> | ||
299 | <item> | ||
300 | <property> | ||
301 | <name>text</name> | ||
302 | <string>Ad-Hoc</string> | ||
303 | </property> | 291 | </property> |
304 | </item> | 292 | </item> |
305 | <property stdset="1"> | 293 | <property stdset="1"> |
306 | <name>name</name> | 294 | <name>name</name> |
307 | <cstring>mode</cstring> | 295 | <cstring>essid</cstring> |
308 | </property> | ||
309 | <property stdset="1"> | ||
310 | <name>enabled</name> | ||
311 | <bool>true</bool> | ||
312 | </property> | 296 | </property> |
313 | <property stdset="1"> | 297 | <property stdset="1"> |
314 | <name>geometry</name> | 298 | <name>geometry</name> |
315 | <rect> | 299 | <rect> |
316 | <x>101</x> | 300 | <x>101</x> |
317 | <y>11</y> | 301 | <y>46</y> |
318 | <width>103</width> | 302 | <width>103</width> |
319 | <height>29</height> | 303 | <height>29</height> |
320 | </rect> | 304 | </rect> |
321 | </property> | 305 | </property> |
322 | <property stdset="1"> | 306 | <property stdset="1"> |
323 | <name>sizePolicy</name> | 307 | <name>sizePolicy</name> |
324 | <sizepolicy> | 308 | <sizepolicy> |
325 | <hsizetype>1</hsizetype> | 309 | <hsizetype>7</hsizetype> |
326 | <vsizetype>0</vsizetype> | 310 | <vsizetype>0</vsizetype> |
327 | </sizepolicy> | 311 | </sizepolicy> |
328 | </property> | 312 | </property> |
313 | <property stdset="1"> | ||
314 | <name>editable</name> | ||
315 | <bool>true</bool> | ||
316 | </property> | ||
317 | <property stdset="1"> | ||
318 | <name>currentItem</name> | ||
319 | <number>0</number> | ||
320 | </property> | ||
321 | <property stdset="1"> | ||
322 | <name>sizeLimit</name> | ||
323 | <number>5</number> | ||
324 | </property> | ||
325 | <property stdset="1"> | ||
326 | <name>autoCompletion</name> | ||
327 | <bool>true</bool> | ||
328 | </property> | ||
329 | <property stdset="1"> | ||
330 | <name>duplicatesEnabled</name> | ||
331 | <bool>false</bool> | ||
332 | </property> | ||
329 | </widget> | 333 | </widget> |
330 | <widget> | 334 | <widget> |
331 | <class>QComboBox</class> | 335 | <class>QComboBox</class> |
332 | <item> | 336 | <item> |
333 | <property> | 337 | <property> |
334 | <name>text</name> | 338 | <name>text</name> |
335 | <string>any</string> | 339 | <string>Infrastructure</string> |
340 | </property> | ||
341 | </item> | ||
342 | <item> | ||
343 | <property> | ||
344 | <name>text</name> | ||
345 | <string>Auto</string> | ||
346 | </property> | ||
347 | </item> | ||
348 | <item> | ||
349 | <property> | ||
350 | <name>text</name> | ||
351 | <string>Managed</string> | ||
352 | </property> | ||
353 | </item> | ||
354 | <item> | ||
355 | <property> | ||
356 | <name>text</name> | ||
357 | <string>Ad-Hoc</string> | ||
336 | </property> | 358 | </property> |
337 | </item> | 359 | </item> |
338 | <property stdset="1"> | 360 | <property stdset="1"> |
339 | <name>name</name> | 361 | <name>name</name> |
340 | <cstring>essid</cstring> | 362 | <cstring>mode</cstring> |
363 | </property> | ||
364 | <property stdset="1"> | ||
365 | <name>enabled</name> | ||
366 | <bool>true</bool> | ||
341 | </property> | 367 | </property> |
342 | <property stdset="1"> | 368 | <property stdset="1"> |
343 | <name>geometry</name> | 369 | <name>geometry</name> |
344 | <rect> | 370 | <rect> |
345 | <x>101</x> | 371 | <x>101</x> |
346 | <y>46</y> | 372 | <y>11</y> |
347 | <width>103</width> | 373 | <width>103</width> |
348 | <height>29</height> | 374 | <height>29</height> |
349 | </rect> | 375 | </rect> |
350 | </property> | 376 | </property> |
351 | <property stdset="1"> | 377 | <property stdset="1"> |
352 | <name>sizePolicy</name> | 378 | <name>sizePolicy</name> |
353 | <sizepolicy> | 379 | <sizepolicy> |
354 | <hsizetype>7</hsizetype> | 380 | <hsizetype>1</hsizetype> |
355 | <vsizetype>0</vsizetype> | 381 | <vsizetype>0</vsizetype> |
356 | </sizepolicy> | 382 | </sizepolicy> |
357 | </property> | 383 | </property> |
358 | <property stdset="1"> | ||
359 | <name>editable</name> | ||
360 | <bool>true</bool> | ||
361 | </property> | ||
362 | <property stdset="1"> | ||
363 | <name>currentItem</name> | ||
364 | <number>0</number> | ||
365 | </property> | ||
366 | <property stdset="1"> | ||
367 | <name>sizeLimit</name> | ||
368 | <number>5</number> | ||
369 | </property> | ||
370 | <property stdset="1"> | ||
371 | <name>autoCompletion</name> | ||
372 | <bool>true</bool> | ||
373 | </property> | ||
374 | <property stdset="1"> | ||
375 | <name>duplicatesEnabled</name> | ||
376 | <bool>false</bool> | ||
377 | </property> | ||
378 | </widget> | 384 | </widget> |
379 | </widget> | 385 | </widget> |
380 | <widget> | 386 | <widget> |
381 | <class>QWidget</class> | 387 | <class>QWidget</class> |
382 | <property stdset="1"> | 388 | <property stdset="1"> |
383 | <name>name</name> | 389 | <name>name</name> |
384 | <cstring>WepPage</cstring> | 390 | <cstring>WepPage</cstring> |
385 | </property> | 391 | </property> |
386 | <attribute> | 392 | <attribute> |
387 | <name>title</name> | 393 | <name>title</name> |
388 | <string>Encryption</string> | 394 | <string>Encryption</string> |
389 | </attribute> | 395 | </attribute> |
390 | <grid> | 396 | <grid> |
391 | <property stdset="1"> | 397 | <property stdset="1"> |
392 | <name>margin</name> | 398 | <name>margin</name> |
393 | <number>11</number> | 399 | <number>11</number> |
394 | </property> | 400 | </property> |
395 | <property stdset="1"> | 401 | <property stdset="1"> |
396 | <name>spacing</name> | 402 | <name>spacing</name> |
397 | <number>6</number> | 403 | <number>6</number> |
398 | </property> | 404 | </property> |
399 | <widget row="0" column="0" > | 405 | <widget row="0" column="0" > |
400 | <class>QCheckBox</class> | 406 | <class>QCheckBox</class> |
401 | <property stdset="1"> | 407 | <property stdset="1"> |
402 | <name>name</name> | 408 | <name>name</name> |
403 | <cstring>wepEnabled</cstring> | 409 | <cstring>wepEnabled</cstring> |
404 | </property> | 410 | </property> |
405 | <property stdset="1"> | 411 | <property stdset="1"> |
406 | <name>text</name> | 412 | <name>text</name> |
407 | <string>&Enable Encryption</string> | 413 | <string>&Enable Encryption</string> |
408 | </property> | 414 | </property> |
409 | </widget> | 415 | </widget> |
410 | <widget row="1" column="0" > | 416 | <widget row="1" column="0" > |
411 | <class>QButtonGroup</class> | 417 | <class>QButtonGroup</class> |
412 | <property stdset="1"> | 418 | <property stdset="1"> |
413 | <name>name</name> | 419 | <name>name</name> |
414 | <cstring>KeyButtonGroup</cstring> | 420 | <cstring>KeyButtonGroup</cstring> |
415 | </property> | 421 | </property> |
416 | <property stdset="1"> | 422 | <property stdset="1"> |
417 | <name>enabled</name> | 423 | <name>enabled</name> |
418 | <bool>false</bool> | 424 | <bool>false</bool> |
419 | </property> | 425 | </property> |
420 | <property stdset="1"> | 426 | <property stdset="1"> |
421 | <name>title</name> | 427 | <name>title</name> |
422 | <string>&Key Setting</string> | 428 | <string>&Key Setting</string> |
423 | </property> | 429 | </property> |
424 | <grid> | 430 | <grid> |
425 | <property stdset="1"> | 431 | <property stdset="1"> |
426 | <name>margin</name> | 432 | <name>margin</name> |
427 | <number>11</number> | 433 | <number>11</number> |
428 | </property> | 434 | </property> |
429 | <property stdset="1"> | 435 | <property stdset="1"> |
430 | <name>spacing</name> | 436 | <name>spacing</name> |
431 | <number>6</number> | 437 | <number>6</number> |
432 | </property> | 438 | </property> |
433 | <widget row="0" column="0" > | 439 | <widget row="0" column="0" > |
434 | <class>QRadioButton</class> | 440 | <class>QRadioButton</class> |
435 | <property stdset="1"> | 441 | <property stdset="1"> |
436 | <name>name</name> | 442 | <name>name</name> |
437 | <cstring>keyRadio0</cstring> | 443 | <cstring>keyRadio0</cstring> |
438 | </property> | 444 | </property> |
439 | <property stdset="1"> | 445 | <property stdset="1"> |
440 | <name>text</name> | 446 | <name>text</name> |
441 | <string>Key &1</string> | 447 | <string>Key &1</string> |
442 | </property> | 448 | </property> |
443 | <property stdset="1"> | 449 | <property stdset="1"> |
444 | <name>checked</name> | 450 | <name>checked</name> |
445 | <bool>true</bool> | 451 | <bool>true</bool> |
446 | </property> | 452 | </property> |
447 | </widget> | 453 | </widget> |
448 | <widget row="1" column="0" > | 454 | <widget row="1" column="0" > |
449 | <class>QRadioButton</class> | 455 | <class>QRadioButton</class> |
450 | <property stdset="1"> | 456 | <property stdset="1"> |
451 | <name>name</name> | 457 | <name>name</name> |
452 | <cstring>keyRadio1</cstring> | 458 | <cstring>keyRadio1</cstring> |
453 | </property> | 459 | </property> |
454 | <property stdset="1"> | 460 | <property stdset="1"> |
455 | <name>text</name> | 461 | <name>text</name> |
456 | <string>Key &2</string> | 462 | <string>Key &2</string> |
457 | </property> | 463 | </property> |
458 | </widget> | 464 | </widget> |
459 | <widget row="2" column="0" > | 465 | <widget row="2" column="0" > |
460 | <class>QRadioButton</class> | 466 | <class>QRadioButton</class> |
461 | <property stdset="1"> | 467 | <property stdset="1"> |
462 | <name>name</name> | 468 | <name>name</name> |
463 | <cstring>keyRadio2</cstring> | 469 | <cstring>keyRadio2</cstring> |
464 | </property> | 470 | </property> |
465 | <property stdset="1"> | 471 | <property stdset="1"> |
466 | <name>text</name> | 472 | <name>text</name> |
467 | <string>Key &3</string> | 473 | <string>Key &3</string> |
468 | </property> | 474 | </property> |
469 | </widget> | 475 | </widget> |
470 | <widget row="3" column="0" > | 476 | <widget row="3" column="0" > |
471 | <class>QRadioButton</class> | 477 | <class>QRadioButton</class> |
472 | <property stdset="1"> | 478 | <property stdset="1"> |
473 | <name>name</name> | 479 | <name>name</name> |
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index cdafb4d..26e3aa9 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -1,269 +1,276 @@ | |||
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 <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qtextstream.h> | 7 | #include <qtextstream.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qspinbox.h> | 11 | #include <qspinbox.h> |
12 | #include <qradiobutton.h> | 12 | #include <qradiobutton.h> |
13 | #include <qcheckbox.h> | 13 | #include <qcheckbox.h> |
14 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
15 | #include <qcombobox.h> | 15 | #include <qcombobox.h> |
16 | 16 | ||
17 | #ifdef QWS | 17 | #ifdef QWS |
18 | #include <opie/oprocess.h> | 18 | #include <opie/oprocess.h> |
19 | #else | 19 | #else |
20 | #define OProcess KProcess | 20 | #define OProcess KProcess |
21 | #include <kprocess.h> | 21 | #include <kprocess.h> |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 24 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
25 | #define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools" | 25 | #define PREUP "/etc/netwrok/if-pre-up.d/wireless-tools" |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Constructor, read in the wireless.opts file for parsing later. | 28 | * Constructor, read in the wireless.opts file for parsing later. |
29 | */ | 29 | */ |
30 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), currentProfile("*"), interface(i) { | 30 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { |
31 | interfaces = new Interfaces(); | 31 | interfaces = new Interfaces(); |
32 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 32 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
33 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 33 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
34 | 34 | ||
35 | // Check sanity - the existance of the wireless-tools if-pre-up script | 35 | // Check sanity - the existance of the wireless-tools if-pre-up script |
36 | QFile file(QString(PREUP)); | 36 | QFile file(QString(PREUP)); |
37 | if (file.exists()) { | 37 | if (file.exists()) { |
38 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); | 38 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | WLANImp::~WLANImp() { | 42 | WLANImp::~WLANImp() { |
43 | //FIXME: delete interfaces; | 43 | //FIXME: delete interfaces; |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Change the profile for both wireless settings and network settings. | 47 | * Change the profile for both wireless settings and network settings. |
48 | */ | 48 | */ |
49 | void WLANImp::setProfile(const QString &profile){ | 49 | void WLANImp::setProfile(const QString &profile){ |
50 | interfaceSetup->setProfile(profile); | 50 | interfaceSetup->setProfile(profile); |
51 | parseOpts(); | 51 | parseOpts(); |
52 | } | 52 | } |
53 | 53 | ||
54 | void WLANImp::parseOpts() { | 54 | void WLANImp::parseOpts() { |
55 | bool error; | 55 | bool error; |
56 | QString opt; | 56 | QString opt; |
57 | 57 | ||
58 | if (! interfaces->isInterfaceSet()) | 58 | if (! interfaces->isInterfaceSet()) |
59 | return; | 59 | return; |
60 | 60 | ||
61 | 61 | ||
62 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 62 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
63 | if(opt == "any" || opt == "off" || opt.isNull()){ | 63 | if(opt == "any" || opt == "off" || opt.isNull()){ |
64 | essid->setEditText("any"); | 64 | essid->setEditText("any"); |
65 | } else { | 65 | } else { |
66 | essid->setEditText(opt); | 66 | essid->setEditText(opt); |
67 | } | 67 | } |
68 | 68 | ||
69 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); | 69 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); |
70 | if (opt == "Auto") { | 70 | |
71 | mode->setCurrentItem(0); | 71 | for ( int i = 0; i < mode->count(); i++) |
72 | } else if (opt == "Ad-Hoc") { | 72 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); |
73 | mode->setCurrentItem(2); | ||
74 | } else { | ||
75 | // Managed/Infrastructure mode | ||
76 | mode->setCurrentItem(1); | ||
77 | } | ||
78 | 73 | ||
79 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); | 74 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); |
80 | if (! opt.isNull()) { | 75 | if (! opt.isNull()) { |
81 | specifyAp->setChecked(true); | 76 | specifyAp->setChecked(true); |
82 | macEdit->setText(opt); | 77 | macEdit->setText(opt); |
83 | } | 78 | } |
84 | 79 | ||
85 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 80 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
86 | if (! opt.isNull()) { | 81 | if (! opt.isNull()) { |
87 | specifyChan->setChecked(true); | 82 | specifyChan->setChecked(true); |
88 | networkChannel->setValue(opt.toInt()); | 83 | networkChannel->setValue(opt.toInt()); |
89 | } | 84 | } |
90 | 85 | ||
91 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 86 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); |
92 | if (opt.isNull()) | 87 | if (opt.isNull()) |
93 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 88 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
94 | parseKeyStr(opt); | 89 | parseKeyStr(opt); |
95 | } | 90 | } |
96 | 91 | ||
97 | void WLANImp::parseKeyStr(QString keystr) { | 92 | void WLANImp::parseKeyStr(QString keystr) { |
98 | int loc = 0; | 93 | int loc = 0; |
99 | int index = 1; | 94 | int index = 1; |
100 | QString key; | 95 | QString key; |
101 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 96 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
102 | int enc = -1; // encryption state | 97 | int enc = -1; // encryption state |
103 | 98 | ||
104 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { | 99 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { |
105 | if ((*it).left(3) == "off") { | 100 | if ((*it).left(3) == "off") { |
106 | // encryption disabled | 101 | // encryption disabled |
107 | enc = 0; | 102 | enc = 0; |
108 | } else if ((*it).left(2) == "on") { | 103 | } else if ((*it).left(2) == "on") { |
109 | // encryption enabled | 104 | // encryption enabled |
110 | enc = 1; | 105 | enc = 1; |
111 | } else if ((*it).left(4) == "open") { | 106 | } else if ((*it).left(4) == "open") { |
112 | // open mode, accept non encrypted packets | 107 | // open mode, accept non encrypted packets |
113 | acceptNonEnc->setChecked(true); | 108 | acceptNonEnc->setChecked(true); |
114 | } else if ((*it).left(10) == "restricted") { | 109 | } else if ((*it).left(10) == "restricted") { |
115 | // restricted mode, only accept encrypted packets | 110 | // restricted mode, only accept encrypted packets |
116 | rejectNonEnc->setChecked(true); | 111 | rejectNonEnc->setChecked(true); |
117 | } else if ((*it).left(3) == "key") { | 112 | } else if ((*it).left(3) == "key") { |
118 | // new set of options | 113 | // new set of options |
119 | } else if ((*it).left(1) == "[") { | 114 | } else if ((*it).left(1) == "[") { |
120 | index = (*it).mid(1, 1).toInt(); | 115 | index = (*it).mid(1, 1).toInt(); |
121 | // switch current key to index | 116 | // switch current key to index |
122 | switch (index) { | 117 | switch (index) { |
123 | case 1: | 118 | case 1: |
124 | keyRadio0->setChecked(true); | 119 | keyRadio0->setChecked(true); |
125 | break; | 120 | break; |
126 | case 2: | 121 | case 2: |
127 | keyRadio1->setChecked(true); | 122 | keyRadio1->setChecked(true); |
128 | break; | 123 | break; |
129 | case 3: | 124 | case 3: |
130 | keyRadio2->setChecked(true); | 125 | keyRadio2->setChecked(true); |
131 | break; | 126 | break; |
132 | case 4: | 127 | case 4: |
133 | keyRadio3->setChecked(true); | 128 | keyRadio3->setChecked(true); |
134 | break; | 129 | break; |
135 | } | 130 | } |
136 | } else { | 131 | } else { |
137 | // key | 132 | // key |
138 | key = (*it); | 133 | key = (*it); |
139 | } | 134 | } |
140 | if (! key.isNull()) { | 135 | if (! key.isNull()) { |
141 | if (enc == -1) | 136 | if (enc == -1) |
142 | enc = 1; | 137 | enc = 1; |
143 | QStringList::Iterator next = ++it; | 138 | QStringList::Iterator next = ++it; |
144 | if (it == keys.end()) { | 139 | if (it == keys.end()) { |
145 | break; | 140 | break; |
146 | } | 141 | } |
147 | if ((*(next)).left(1) == "[") { | 142 | if ((*(next)).left(1) == "[") { |
148 | // set key at index | 143 | // set key at index |
149 | index = (*(next)).mid(1, 1).toInt(); | 144 | index = (*(next)).mid(1, 1).toInt(); |
150 | } else { | 145 | } else { |
151 | index = 1; | 146 | index = 1; |
152 | } | 147 | } |
153 | switch (index) { | 148 | switch (index) { |
154 | case 1: | 149 | case 1: |
155 | keyLineEdit0->setText(key); | 150 | keyLineEdit0->setText(key); |
156 | break; | 151 | break; |
157 | case 2: | 152 | case 2: |
158 | keyLineEdit1->setText(key); | 153 | keyLineEdit1->setText(key); |
159 | break; | 154 | break; |
160 | case 3: | 155 | case 3: |
161 | keyLineEdit2->setText(key); | 156 | keyLineEdit2->setText(key); |
162 | break; | 157 | break; |
163 | case 4: | 158 | case 4: |
164 | keyLineEdit3->setText(key); | 159 | keyLineEdit3->setText(key); |
165 | break; | 160 | break; |
166 | } | 161 | } |
167 | key = QString::null; | 162 | key = QString::null; |
168 | } | 163 | } |
169 | } | 164 | } |
170 | if (enc == 1) { | 165 | if (enc == 1) { |
171 | wepEnabled->setChecked(true); | 166 | wepEnabled->setChecked(true); |
172 | } else { | 167 | } else { |
173 | wepEnabled->setChecked(false); | 168 | wepEnabled->setChecked(false); |
174 | } | 169 | } |
175 | } | 170 | } |
176 | 171 | ||
177 | /** | 172 | /** |
178 | * Check to see if the current config is valid | 173 | * Check to see if the current config is valid |
179 | * Save interfaces | 174 | * Save interfaces |
180 | */ | 175 | */ |
181 | void WLANImp::accept() { | 176 | void WLANImp::accept() { |
182 | if (wepEnabled->isChecked()) { | 177 | if (wepEnabled->isChecked()) { |
183 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || | 178 | if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) || |
184 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || | 179 | (keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) || |
185 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || | 180 | (keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) || |
186 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { | 181 | (keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) { |
187 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); | 182 | QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok); |
188 | return; | 183 | return; |
189 | } | 184 | } |
190 | } | 185 | } |
191 | 186 | ||
192 | if (essid->currentText().isEmpty()) { | 187 | if (essid->currentText().isEmpty()) { |
193 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); | 188 | QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok); |
194 | return; | 189 | return; |
195 | } | 190 | } |
196 | 191 | ||
197 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { | 192 | if (specifyAp->isChecked() && macEdit->text().isEmpty()) { |
198 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); | 193 | QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok); |
199 | return; | 194 | return; |
200 | } | 195 | } |
201 | 196 | ||
202 | // Try to save the interfaces settings. | 197 | // Try to save the interfaces settings. |
203 | writeOpts(); | 198 | writeOpts(); |
204 | 199 | ||
205 | // Close out the dialog | 200 | // Close out the dialog |
206 | QDialog::accept(); | 201 | // FIXME: QDialog::accept(); |
207 | } | 202 | } |
208 | 203 | ||
209 | void WLANImp::writeOpts() { | 204 | void WLANImp::writeOpts() { |
210 | bool error = false; | 205 | // eh can't really do anything about it other then return. :-D |
206 | if(!interfaces->isInterfaceSet()){ | ||
207 | QMessageBox::warning(0,"Inface not set","should not happen!!!"); | ||
208 | return; | ||
209 | } | ||
210 | bool error = false; | ||
211 | |||
212 | qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() ); | ||
213 | |||
214 | if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!"); | ||
211 | 215 | ||
212 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); | 216 | interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText()); |
213 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); | 217 | interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText()); |
214 | 218 | ||
215 | if (specifyAp->isChecked()) { | 219 | if (specifyAp->isChecked()) { |
216 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); | 220 | interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text()); |
217 | } else { | 221 | } else { |
218 | interfaces->removeInterfaceOption(QString("wireless_ap")); | 222 | interfaces->removeInterfaceOption(QString("wireless_ap")); |
219 | } | 223 | } |
220 | 224 | ||
221 | if (specifyChan->isChecked()) { | 225 | if (specifyChan->isChecked()) { |
222 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); | 226 | interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text()); |
223 | } else { | 227 | } else { |
224 | interfaces->removeInterfaceOption(QString("wireless_channel")); | 228 | interfaces->removeInterfaceOption(QString("wireless_channel")); |
225 | } | 229 | } |
226 | 230 | ||
227 | if (wepEnabled->isChecked()) { | 231 | if (wepEnabled->isChecked()) { |
228 | QStringList keyList; | 232 | QStringList keyList; |
229 | 233 | ||
230 | if (! keyLineEdit0->text().isNull()) { | 234 | if (! keyLineEdit0->text().isNull()) { |
231 | keyList += keyLineEdit0->text(); | 235 | keyList += keyLineEdit0->text(); |
232 | keyList += "[1]"; | 236 | keyList += "[1]"; |
233 | } else if (! keyLineEdit1->text().isNull()) { | 237 | } //else |
238 | if (! keyLineEdit1->text().isNull()) { | ||
234 | keyList += keyLineEdit1->text(); | 239 | keyList += keyLineEdit1->text(); |
235 | keyList += "[2]"; | 240 | keyList += "[2]"; |
236 | } else if (! keyLineEdit2->text().isNull()) { | 241 | } //else |
242 | if (! keyLineEdit2->text().isNull()) { | ||
237 | keyList += keyLineEdit2->text(); | 243 | keyList += keyLineEdit2->text(); |
238 | keyList += "[3]"; | 244 | keyList += "[3]"; |
239 | } else if (! keyLineEdit3->text().isNull()) { | 245 | } //else |
246 | if (! keyLineEdit3->text().isNull()) { | ||
240 | keyList += keyLineEdit3->text(); | 247 | keyList += keyLineEdit3->text(); |
241 | keyList += "[4]"; | 248 | keyList += "[4]"; |
242 | } | 249 | } |
243 | if (acceptNonEnc->isChecked()) { | 250 | if (acceptNonEnc->isChecked()) { |
244 | keyList += "open"; | 251 | keyList += "open"; |
245 | } else { | 252 | } else { |
246 | keyList += "restricted"; | 253 | keyList += "restricted"; |
247 | } | 254 | } |
248 | 255 | ||
249 | keyList += "key"; | 256 | keyList += "key"; |
250 | if (keyRadio0->isChecked()) { | 257 | if (keyRadio0->isChecked()) { |
251 | keyList += "[1]"; | 258 | keyList += "[1]"; |
252 | } else if (keyRadio1->isChecked()) { | 259 | } else if (keyRadio1->isChecked()) { |
253 | keyList += "[2]"; | 260 | keyList += "[2]"; |
254 | } else if (keyRadio2->isChecked()) { | 261 | } else if (keyRadio2->isChecked()) { |
255 | keyList += "[3]"; | 262 | keyList += "[3]"; |
256 | } else if (keyRadio3->isChecked()) { | 263 | } else if (keyRadio3->isChecked()) { |
257 | keyList += "[4]"; | 264 | keyList += "[4]"; |
258 | } | 265 | } |
259 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); | 266 | interfaces->setInterfaceOption(QString("wireless_key"), keyList.join(QString(" "))); |
260 | } else { | 267 | } else { |
261 | interfaces->removeInterfaceOption(QString("wireless_key")); | 268 | interfaces->removeInterfaceOption(QString("wireless_key")); |
262 | } | 269 | } |
263 | interfaces->removeInterfaceOption(QString("wireless_enc")); | 270 | interfaces->removeInterfaceOption(QString("wireless_enc")); |
264 | 271 | ||
265 | if(!interfaceSetup->saveChanges()) | 272 | if(!interfaceSetup->saveChanges()) |
266 | return; | 273 | return; |
267 | 274 | ||
268 | QDialog::accept(); | 275 | QDialog::accept(); |
269 | } | 276 | } |
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index a4488f9..b4c3509 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -1,98 +1,98 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp.h" | 2 | #include "wlanimp2.h" |
3 | #include "infoimp.h" | 3 | #include "infoimp.h" |
4 | #include "wextensions.h" | 4 | #include "wextensions.h" |
5 | #include "interfaceinformationimp.h" | 5 | #include "interfaceinformationimp.h" |
6 | 6 | ||
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qlabel.h> | 9 | #include <qlabel.h> |
10 | #include <qlineedit.h> | 10 | #include <qlineedit.h> |
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qspinbox.h> | 12 | #include <qspinbox.h> |
13 | #include <qtabwidget.h> | 13 | #include <qtabwidget.h> |
14 | 14 | ||
15 | 15 | ||
16 | 16 | ||
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Constructor, find all of the possible interfaces | 19 | * Constructor, find all of the possible interfaces |
20 | */ | 20 | */ |
21 | WLANModule::WLANModule() | 21 | WLANModule::WLANModule() |
22 | : Module(), | 22 | : Module(), |
23 | wlanconfigWiget(0) | 23 | wlanconfigWiget(0) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Delete any interfaces that we own. | 28 | * Delete any interfaces that we own. |
29 | */ | 29 | */ |
30 | WLANModule::~WLANModule(){ | 30 | WLANModule::~WLANModule(){ |
31 | Interface *i; | 31 | Interface *i; |
32 | for ( i=list.first(); i != 0; i=list.next() ) | 32 | for ( i=list.first(); i != 0; i=list.next() ) |
33 | delete i; | 33 | delete i; |
34 | 34 | ||
35 | } | 35 | } |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Change the current profile | 38 | * Change the current profile |
39 | */ | 39 | */ |
40 | void WLANModule::setProfile(const QString &newProfile){ | 40 | void WLANModule::setProfile(const QString &newProfile){ |
41 | profile = newProfile; | 41 | profile = newProfile; |
42 | } | 42 | } |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * get the icon name for this device. | 45 | * get the icon name for this device. |
46 | * @param Interface* can be used in determining the icon. | 46 | * @param Interface* can be used in determining the icon. |
47 | * @return QString the icon name (minus .png, .gif etc) | 47 | * @return QString the icon name (minus .png, .gif etc) |
48 | */ | 48 | */ |
49 | QString WLANModule::getPixmapName(Interface* ){ | 49 | QString WLANModule::getPixmapName(Interface* ){ |
50 | return "wlan"; | 50 | return "wlan"; |
51 | } | 51 | } |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Check to see if the interface i is owned by this module. | 54 | * Check to see if the interface i is owned by this module. |
55 | * @param Interface* interface to check against | 55 | * @param Interface* interface to check against |
56 | * @return bool true if i is owned by this module, false otherwise. | 56 | * @return bool true if i is owned by this module, false otherwise. |
57 | */ | 57 | */ |
58 | bool WLANModule::isOwner(Interface *i){ | 58 | bool WLANModule::isOwner(Interface *i){ |
59 | WExtensions we(i->getInterfaceName()); | 59 | WExtensions we(i->getInterfaceName()); |
60 | if(!we.doesHaveWirelessExtensions()) | 60 | if(!we.doesHaveWirelessExtensions()) |
61 | return false; | 61 | return false; |
62 | 62 | ||
63 | i->setHardwareName("802.11b"); | 63 | i->setHardwareName("802.11b"); |
64 | list.append(i); | 64 | list.append(i); |
65 | return true; | 65 | return true; |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Create, and return the WLANConfigure Module | 69 | * Create, and return the WLANConfigure Module |
70 | * @return QWidget* pointer to this modules configure. | 70 | * @return QWidget* pointer to this modules configure. |
71 | */ | 71 | */ |
72 | QWidget *WLANModule::configure(Interface *i){ | 72 | QWidget *WLANModule::configure(Interface *i){ |
73 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); | 73 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); |
74 | wlanconfig->setProfile(profile); | 74 | wlanconfig->setProfile(profile); |
75 | return wlanconfig; | 75 | return wlanconfig; |
76 | } | 76 | } |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Create, and return the Information Module | 79 | * Create, and return the Information Module |
80 | * @return QWidget* pointer to this modules info. | 80 | * @return QWidget* pointer to this modules info. |
81 | */ | 81 | */ |
82 | QWidget *WLANModule::information(Interface *i){ | 82 | QWidget *WLANModule::information(Interface *i){ |
83 | WExtensions we(i->getInterfaceName()); | 83 | WExtensions we(i->getInterfaceName()); |
84 | if(!we.doesHaveWirelessExtensions()) | 84 | if(!we.doesHaveWirelessExtensions()) |
85 | return NULL; | 85 | return NULL; |
86 | 86 | ||
87 | return getInfo( i ); | 87 | return getInfo( i ); |
88 | } | 88 | } |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Get all active (up or down) interfaces | 91 | * Get all active (up or down) interfaces |
92 | * @return QList<Interface> A list of interfaces that exsist that havn't | 92 | * @return QList<Interface> A list of interfaces that exsist that havn't |
93 | * been called by isOwner() | 93 | * been called by isOwner() |
94 | */ | 94 | */ |
95 | QList<Interface> WLANModule::getInterfaces(){ | 95 | QList<Interface> WLANModule::getInterfaces(){ |
96 | return list; | 96 | return list; |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index c06f639..19b0e84 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -332,110 +332,110 @@ bool UserDialog::editUser(const char *username) { | |||
332 | } | 332 | } |
333 | } | 333 | } |
334 | if(invalid_group) { | 334 | if(invalid_group) { |
335 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); | 335 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); |
336 | edituserDialog->groupComboBox->setCurrentItem(0); | 336 | edituserDialog->groupComboBox->setCurrentItem(0); |
337 | } | 337 | } |
338 | 338 | ||
339 | // Select the groups in the listview, to which the user belongs. | 339 | // Select the groups in the listview, to which the user belongs. |
340 | QCheckListItem *temp; | 340 | QCheckListItem *temp; |
341 | // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. | 341 | // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. |
342 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. | 342 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. |
343 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 343 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
344 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 344 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
345 | qWarning(*it); | 345 | qWarning(*it); |
346 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 346 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
347 | for ( ; lvit.current(); ++lvit ) { | 347 | for ( ; lvit.current(); ++lvit ) { |
348 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 348 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
349 | temp=(QCheckListItem*)lvit.current(); | 349 | temp=(QCheckListItem*)lvit.current(); |
350 | temp->setOn(true);// If we find a line with that groupname, select it.; | 350 | temp->setOn(true);// If we find a line with that groupname, select it.; |
351 | } | 351 | } |
352 | } | 352 | } |
353 | } | 353 | } |
354 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) | 354 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) |
355 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 355 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
356 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 356 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
357 | qWarning(*it); | 357 | qWarning(*it); |
358 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 358 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
359 | for ( ; lvit.current(); ++lvit ) { | 359 | for ( ; lvit.current(); ++lvit ) { |
360 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 360 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
361 | temp=(QCheckListItem*)lvit.current(); | 361 | temp=(QCheckListItem*)lvit.current(); |
362 | temp->setOn(true);// If we find a line with that groupname, select it.; | 362 | temp->setOn(true);// If we find a line with that groupname, select it.; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! | 367 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! |
368 | 368 | ||
369 | accounts->findUser(username);// Fill user variables in 'acccounts' object. | 369 | accounts->findUser(username);// Fill user variables in 'acccounts' object. |
370 | accounts->pw_name=edituserDialog->loginLineEdit->text(); | 370 | accounts->pw_name=edituserDialog->loginLineEdit->text(); |
371 | // Has the password been changed ? Make a new "crypt":ed password. | 371 | // Has the password been changed ? Make a new "crypt":ed password. |
372 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); | 372 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); |
373 | 373 | ||
374 | // Set all variables in accounts object, that will be used when calling 'updateUser()' | 374 | // Set all variables in accounts object, that will be used when calling 'updateUser()' |
375 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); | 375 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); |
376 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. | 376 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. |
377 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. | 377 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. |
378 | } | 378 | } |
379 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); | 379 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); |
380 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); | 380 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); |
381 | // Update userinfo, using the information stored in the user variables stored in the accounts object. | 381 | // Update userinfo, using the information stored in the user variables stored in the accounts object. |
382 | accounts->updateUser(username); | 382 | accounts->updateUser(username); |
383 | 383 | ||
384 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) | 384 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) |
385 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { | 385 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { |
386 | accounts->delGroupMember((*it).left((*it).find(":")),username); | 386 | accounts->delGroupMember((*it).left((*it).find(":")),username); |
387 | } | 387 | } |
388 | 388 | ||
389 | // Add User to additional groups that he/she is a member of. | 389 | // Add User to additional groups that he/she is a member of. |
390 | QListViewItemIterator it( edituserDialog->groupsListView ); | 390 | QListViewItemIterator it( edituserDialog->groupsListView ); |
391 | for ( ; it.current(); ++it ) { | 391 | for ( ; it.current(); ++it ) { |
392 | temp=(QCheckListItem*)it.current(); | 392 | temp=(QCheckListItem*)it.current(); |
393 | if ( temp->isOn() ) | 393 | if ( temp->isOn() ) |
394 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); | 394 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); |
395 | } | 395 | } |
396 | 396 | ||
397 | // Copy image to pics/users/ | 397 | // Copy image to pics/users/ |
398 | if(!(edituserDialog->userImage.isNull())) { | 398 | if(!(edituserDialog->userImage.isNull())) { |
399 | QDir d; | 399 | QDir d; |
400 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 400 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
401 | d.mkdir("/opt/QtPalmtop/pics/users"); | 401 | d.mkdir("/opt/QtPalmtop/pics/users"); |
402 | } | 402 | } |
403 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 403 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
404 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); | 404 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); |
405 | edituserDialog->userImage.save(filename,"PNG"); | 405 | edituserDialog->userImage.save(filename,"PNG"); |
406 | } | 406 | } |
407 | return true; | 407 | return true; |
408 | } | 408 | } |
409 | 409 | ||
410 | /** | 410 | /** |
411 | * "OK" has been clicked. Verify some information before closing the dialog. | 411 | * "OK" has been clicked. Verify some information before closing the dialog. |
412 | * | 412 | * |
413 | */ | 413 | */ |
414 | void UserDialog::accept() { | 414 | void UserDialog::accept() { |
415 | // Add checking... valid username? username taken? | 415 | // Add checking... valid username? username taken? |
416 | if(loginLineEdit->text().isEmpty()) { | 416 | if(loginLineEdit->text().isEmpty()) { |
417 | QMessageBox::information(0,"Empty Login","Please enter a login."); | 417 | QMessageBox::information(0,"Empty Login","Please enter a login."); |
418 | return; | 418 | return; |
419 | } | 419 | } |
420 | QDialog::accept(); | 420 | QDialog::accept(); |
421 | } | 421 | } |
422 | 422 | ||
423 | /** | 423 | /** |
424 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. | 424 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. |
425 | * | 425 | * |
426 | */ | 426 | */ |
427 | void UserDialog::clickedPicture() { | 427 | void UserDialog::clickedPicture() { |
428 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics"); | 428 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); |
429 | if(!(filename.isEmpty())) { | 429 | if(!(filename.isEmpty())) { |
430 | userImage.reset(); | 430 | userImage.reset(); |
431 | if(!(userImage.load(filename))) { | 431 | if(!(userImage.load(filename))) { |
432 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); | 432 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); |
433 | } else { | 433 | } else { |
434 | // userImage=userImage.smoothScale(48,48); | 434 | // userImage=userImage.smoothScale(48,48); |
435 | QPixmap *picture; | 435 | QPixmap *picture; |
436 | picture=(QPixmap *)picturePushButton->pixmap(); | 436 | picture=(QPixmap *)picturePushButton->pixmap(); |
437 | picture->convertFromImage(userImage,0); | 437 | picture->convertFromImage(userImage,0); |
438 | picturePushButton->update(); | 438 | picturePushButton->update(); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | } | 441 | } |
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h index b7b925d..3272afc 100644 --- a/noncore/settings/usermanager/userdialog.h +++ b/noncore/settings/usermanager/userdialog.h | |||
@@ -1,66 +1,67 @@ | |||
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 | #ifndef USERDIALOG_H | 9 | #ifndef USERDIALOG_H |
10 | #define USERDIALOG_H | 10 | #define USERDIALOG_H |
11 | 11 | ||
12 | #include <qdialog.h> | 12 | #include <qdialog.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qcombobox.h> | 14 | #include <qcombobox.h> |
15 | #include <qlistview.h> | 15 | #include <qlistview.h> |
16 | #include <qtabwidget.h> | 16 | #include <qtabwidget.h> |
17 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
18 | #include <qcheckbox.h> | 18 | #include <qcheckbox.h> |
19 | #include <qlabel.h> | ||
19 | 20 | ||
20 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
21 | 22 | ||
22 | #include <opie/ofiledialog.h> | 23 | #include <opie/ofiledialog.h> |
23 | 24 | ||
24 | class UserDialog : public QDialog | 25 | class UserDialog : public QDialog |
25 | { | 26 | { |
26 | Q_OBJECT | 27 | Q_OBJECT |
27 | private: | 28 | private: |
28 | QTabWidget *myTabWidget; | 29 | QTabWidget *myTabWidget; |
29 | QPushButton *picturePushButton; | 30 | QPushButton *picturePushButton; |
30 | QLineEdit *loginLineEdit; | 31 | QLineEdit *loginLineEdit; |
31 | QLineEdit *uidLineEdit; | 32 | QLineEdit *uidLineEdit; |
32 | QLineEdit *gecosLineEdit; | 33 | QLineEdit *gecosLineEdit; |
33 | QLineEdit *passwordLineEdit; | 34 | QLineEdit *passwordLineEdit; |
34 | QComboBox *shellComboBox; | 35 | QComboBox *shellComboBox; |
35 | QComboBox *groupComboBox; | 36 | QComboBox *groupComboBox; |
36 | QLabel *skelLabel; | 37 | QLabel *skelLabel; |
37 | QCheckBox *skelCheckBox; | 38 | QCheckBox *skelCheckBox; |
38 | QListView *groupsListView; | 39 | QListView *groupsListView; |
39 | 40 | ||
40 | QStringList groupMembers; | 41 | QStringList groupMembers; |
41 | QString pictureLocation; | 42 | QString pictureLocation; |
42 | QImage userImage; | 43 | QImage userImage; |
43 | int groupID; | 44 | int groupID; |
44 | int userID; | 45 | int userID; |
45 | int vm; | 46 | int vm; |
46 | enum VIEWMODE { | 47 | enum VIEWMODE { |
47 | VIEWMODE_NEW, | 48 | VIEWMODE_NEW, |
48 | VIEWMODE_EDIT | 49 | VIEWMODE_EDIT |
49 | }; | 50 | }; |
50 | 51 | ||
51 | void setupTab1(void); | 52 | void setupTab1(void); |
52 | void setupTab2(void); | 53 | void setupTab2(void); |
53 | void accept(void); | 54 | void accept(void); |
54 | 55 | ||
55 | private slots: | 56 | private slots: |
56 | void clickedPicture(void); | 57 | void clickedPicture(void); |
57 | 58 | ||
58 | public: | 59 | public: |
59 | UserDialog( int viewmode=VIEWMODE_NEW, QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 ); | 60 | UserDialog( int viewmode=VIEWMODE_NEW, QWidget* parent = 0, const char* name = 0, bool modal=true, WFlags fl = 0 ); |
60 | ~UserDialog(); | 61 | ~UserDialog(); |
61 | static bool addUser(int uid, int gid); | 62 | static bool addUser(int uid, int gid); |
62 | static bool editUser(const char *username); | 63 | static bool editUser(const char *username); |
63 | static bool delUser(const char *username); | 64 | static bool delUser(const char *username); |
64 | }; | 65 | }; |
65 | 66 | ||
66 | #endif | 67 | #endif |
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index 1946013..65bbd8b 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -1,126 +1,126 @@ | |||
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 | #include <stdio.h> | 13 | #include <stdio.h> |
14 | 14 | ||
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | 18 | ||
19 | #include <qregexp.h> | 19 | #include <qregexp.h> |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * The mainwindow constructor. | 22 | * The mainwindow constructor. |
23 | * | 23 | * |
24 | * @param QWidget *parent | 24 | * @param QWidget *parent |
25 | * @param const char *name | 25 | * @param const char *name |
26 | * @ param WFlags fl | 26 | * @ param WFlags fl |
27 | * | 27 | * |
28 | */ | 28 | */ |
29 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { | 29 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { |
30 | setCaption(tr("OPIE User Manager")); | 30 | setCaption(tr("Opie User Manager")); |
31 | 31 | ||
32 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. | 32 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. |
33 | accounts=new Passwd(); | 33 | accounts=new Passwd(); |
34 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. | 34 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. |
35 | 35 | ||
36 | // Create the toolbar. | 36 | // Create the toolbar. |
37 | QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar"); | 37 | QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar"); |
38 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? | 38 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? |
39 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); | 39 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); |
40 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); | 40 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); |
41 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); | 41 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); |
42 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); | 42 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); |
43 | userstext->setUsesTextLabel(true); | 43 | userstext->setUsesTextLabel(true); |
44 | toolbar->addSeparator(); | 44 | toolbar->addSeparator(); |
45 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); | 45 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); |
46 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); | 46 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); |
47 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); | 47 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); |
48 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); | 48 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); |
49 | groupstext->setUsesTextLabel(true); | 49 | groupstext->setUsesTextLabel(true); |
50 | addToolBar(toolbar,"myToolBar"); | 50 | addToolBar(toolbar,"myToolBar"); |
51 | 51 | ||
52 | // Add a tabwidget and all the tabs. | 52 | // Add a tabwidget and all the tabs. |
53 | myTabWidget = new QTabWidget(this,"My Tab Widget"); | 53 | myTabWidget = new QTabWidget(this,"My Tab Widget"); |
54 | setupTabAccounts(); | 54 | setupTabAccounts(); |
55 | setupTabAllUsers(); | 55 | setupTabAllUsers(); |
56 | setupTabAllGroups(); | 56 | setupTabAllGroups(); |
57 | userPopupMenu.insertItem("Copy",0); | 57 | userPopupMenu.insertItem("Copy",0); |
58 | 58 | ||
59 | getUsers(); // Fill out the iconview & listview with all users. | 59 | getUsers(); // Fill out the iconview & listview with all users. |
60 | getGroups(); // Fill out the group listview with all groups. | 60 | getGroups(); // Fill out the group listview with all groups. |
61 | 61 | ||
62 | setCentralWidget(myTabWidget); | 62 | setCentralWidget(myTabWidget); |
63 | } | 63 | } |
64 | 64 | ||
65 | UserConfig::~UserConfig() { | 65 | UserConfig::~UserConfig() { |
66 | accounts->close(); | 66 | accounts->close(); |
67 | delete accounts; | 67 | delete accounts; |
68 | } | 68 | } |
69 | 69 | ||
70 | void UserConfig::setupTabAccounts() { | 70 | void UserConfig::setupTabAccounts() { |
71 | QWidget *tabpage = new QWidget(this); | 71 | QWidget *tabpage = new QWidget(this); |
72 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 72 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
73 | layout->setMargin(5); | 73 | layout->setMargin(5); |
74 | 74 | ||
75 | usersIconView=new QListView(tabpage,"users"); | 75 | usersIconView=new QListView(tabpage,"users"); |
76 | usersIconView->addColumn("Icon"); | 76 | usersIconView->addColumn("Icon"); |
77 | usersIconView->addColumn("Username"); | 77 | usersIconView->addColumn("Username"); |
78 | usersIconView->setAllColumnsShowFocus(true); | 78 | usersIconView->setAllColumnsShowFocus(true); |
79 | layout->addWidget(usersIconView); | 79 | layout->addWidget(usersIconView); |
80 | 80 | ||
81 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); | 81 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); |
82 | 82 | ||
83 | myTabWidget->addTab(tabpage,"Users"); | 83 | myTabWidget->addTab(tabpage,"Users"); |
84 | } | 84 | } |
85 | 85 | ||
86 | void UserConfig::setupTabAllUsers() { | 86 | void UserConfig::setupTabAllUsers() { |
87 | QWidget *tabpage = new QWidget(this); | 87 | QWidget *tabpage = new QWidget(this); |
88 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 88 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
89 | layout->setMargin(5); | 89 | layout->setMargin(5); |
90 | 90 | ||
91 | usersListView=new QListView(tabpage,"allusers"); | 91 | usersListView=new QListView(tabpage,"allusers"); |
92 | usersListView->addColumn("UID"); | 92 | usersListView->addColumn("UID"); |
93 | usersListView->addColumn("Login"); | 93 | usersListView->addColumn("Login"); |
94 | usersListView->addColumn("Username"); | 94 | usersListView->addColumn("Username"); |
95 | layout->addWidget(usersListView); | 95 | layout->addWidget(usersListView); |
96 | usersListView->setSorting(1,1); | 96 | usersListView->setSorting(1,1); |
97 | usersListView->setAllColumnsShowFocus(true); | 97 | usersListView->setAllColumnsShowFocus(true); |
98 | 98 | ||
99 | myTabWidget->addTab(tabpage,"All Users"); | 99 | myTabWidget->addTab(tabpage,"All Users"); |
100 | } | 100 | } |
101 | 101 | ||
102 | void UserConfig::setupTabAllGroups() { | 102 | void UserConfig::setupTabAllGroups() { |
103 | QWidget *tabpage = new QWidget(this); | 103 | QWidget *tabpage = new QWidget(this); |
104 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 104 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
105 | layout->setMargin(5); | 105 | layout->setMargin(5); |
106 | 106 | ||
107 | groupsListView=new QListView(tabpage,"groups"); | 107 | groupsListView=new QListView(tabpage,"groups"); |
108 | groupsListView->addColumn("GID"); | 108 | groupsListView->addColumn("GID"); |
109 | groupsListView->addColumn("Groupname"); | 109 | groupsListView->addColumn("Groupname"); |
110 | layout->addWidget(groupsListView); | 110 | layout->addWidget(groupsListView); |
111 | groupsListView->setSorting(1,1); | 111 | groupsListView->setSorting(1,1); |
112 | groupsListView->setAllColumnsShowFocus(true); | 112 | groupsListView->setAllColumnsShowFocus(true); |
113 | 113 | ||
114 | myTabWidget->addTab(tabpage,"All Groups"); | 114 | myTabWidget->addTab(tabpage,"All Groups"); |
115 | } | 115 | } |
116 | void UserConfig::getUsers() { | 116 | void UserConfig::getUsers() { |
117 | QString mytext; | 117 | QString mytext; |
118 | QPixmap mypixmap; | 118 | QPixmap mypixmap; |
119 | QListViewItem *listviewitem; | 119 | QListViewItem *listviewitem; |
120 | 120 | ||
121 | // Empty the iconview & the listview. | 121 | // Empty the iconview & the listview. |
122 | usersIconView->clear(); | 122 | usersIconView->clear(); |
123 | usersListView->clear(); | 123 | usersListView->clear(); |
124 | 124 | ||
125 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. | 125 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. |
126 | availableUID=500; | 126 | availableUID=500; |
diff --git a/noncore/settings/usermanager/usermanager.pro b/noncore/settings/usermanager/usermanager.pro index 576a233..1baccb6 100644 --- a/noncore/settings/usermanager/usermanager.pro +++ b/noncore/settings/usermanager/usermanager.pro | |||
@@ -1,34 +1,34 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | #CONFIG = qt warn_on debug | 2 | #CONFIG = qt warn_on debug |
3 | CONFIG = qt warn_on release | 3 | CONFIG = qt warn_on release |
4 | HEADERS = usermanager.h userdialog.h groupdialog.h passwd.h | 4 | HEADERS = usermanager.h userdialog.h groupdialog.h passwd.h |
5 | SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.cpp main.cpp | 5 | SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.h main.cpp |
6 | INCLUDEPATH+= $(OPIEDIR)/include | 6 | INCLUDEPATH+= $(OPIEDIR)/include |
7 | DEPENDPATH+= $(OPIEDIR)/include | 7 | DEPENDPATH+= $(OPIEDIR)/include |
8 | LIBS += -lqpe -lopie -lcrypt | 8 | LIBS += -lqpe -lopie -lcrypt |
9 | TARGET = usermanager | 9 | TARGET = usermanager |
10 | DESTDIR = $(OPIEDIR)/bin | 10 | DESTDIR = $(OPIEDIR)/bin |
11 | 11 | ||
12 | TRANSLATIONS = ../../../i18n/de/usermanager.ts \ | 12 | TRANSLATIONS = ../../../i18n/de/usermanager.ts \ |
13 | ../../../i18n/nl/usermanager.ts \ | 13 | ../../../i18n/nl/usermanager.ts \ |
14 | ../../../i18n/xx/usermanager.ts \ | 14 | ../../../i18n/xx/usermanager.ts \ |
15 | ../../../i18n/en/usermanager.ts \ | 15 | ../../../i18n/en/usermanager.ts \ |
16 | ../../../i18n/es/usermanager.ts \ | 16 | ../../../i18n/es/usermanager.ts \ |
17 | ../../../i18n/fr/usermanager.ts \ | 17 | ../../../i18n/fr/usermanager.ts \ |
18 | ../../../i18n/hu/usermanager.ts \ | 18 | ../../../i18n/hu/usermanager.ts \ |
19 | ../../../i18n/ja/usermanager.ts \ | 19 | ../../../i18n/ja/usermanager.ts \ |
20 | ../../../i18n/ko/usermanager.ts \ | 20 | ../../../i18n/ko/usermanager.ts \ |
21 | ../../../i18n/no/usermanager.ts \ | 21 | ../../../i18n/no/usermanager.ts \ |
22 | ../../../i18n/pl/usermanager.ts \ | 22 | ../../../i18n/pl/usermanager.ts \ |
23 | ../../../i18n/pt/usermanager.ts \ | 23 | ../../../i18n/pt/usermanager.ts \ |
24 | ../../../i18n/pt_BR/usermanager.ts \ | 24 | ../../../i18n/pt_BR/usermanager.ts \ |
25 | ../../../i18n/sl/usermanager.ts \ | 25 | ../../../i18n/sl/usermanager.ts \ |
26 | ../../../i18n/zh_CN/usermanager.ts \ | 26 | ../../../i18n/zh_CN/usermanager.ts \ |
27 | ../../../i18n/zh_TW/usermanager.ts \ | 27 | ../../../i18n/zh_TW/usermanager.ts \ |
28 | ../../../i18n/it/usermanager.ts \ | 28 | ../../../i18n/it/usermanager.ts \ |
29 | ../../../i18n/da/usermanager.ts | 29 | ../../../i18n/da/usermanager.ts |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | include ( $(OPIEDIR)/include.pro ) | 34 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/styles/flat/flat.cpp b/noncore/styles/flat/flat.cpp index b6635c5..24366f6 100644 --- a/noncore/styles/flat/flat.cpp +++ b/noncore/styles/flat/flat.cpp | |||
@@ -1,381 +1,443 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "flat.h" | 21 | #include <qtopia/qpeapplication.h> |
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qpushbutton.h> | 22 | #include <qpushbutton.h> |
24 | #include <qtoolbutton.h> | 23 | #include <qtoolbutton.h> |
25 | #include <qpainter.h> | 24 | #include <qpainter.h> |
26 | #include <qfontmetrics.h> | 25 | #include <qfontmetrics.h> |
27 | #include <qpalette.h> | 26 | #include <qpalette.h> |
28 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
29 | #include <qscrollbar.h> | 28 | #include <qscrollbar.h> |
30 | #include <qbutton.h> | 29 | #include <qbutton.h> |
31 | #include <qframe.h> | 30 | #include <qframe.h> |
32 | #include <qtabbar.h> | 31 | #include <qtabbar.h> |
33 | #include <qspinbox.h> | 32 | #include <qspinbox.h> |
34 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qmap.h> | ||
35 | 35 | ||
36 | #define INCLUDE_MENUITEM_DEF | 36 | #define INCLUDE_MENUITEM_DEF |
37 | #include <qmenudata.h> | 37 | #include <qmenudata.h> |
38 | #include <qpopupmenu.h> | ||
39 | |||
40 | #include "flat.h" | ||
38 | 41 | ||
39 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) | 42 | #define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2) |
40 | 43 | ||
41 | class SpinBoxHack : public QSpinBox | 44 | class SpinBoxHack : public QSpinBox |
42 | { | 45 | { |
43 | public: | 46 | public: |
44 | void setFlatButtons( bool f ) { | 47 | void setFlatButtons( bool f ) { |
45 | upButton()->setFlat( f ); | 48 | upButton()->setFlat( f ); |
46 | downButton()->setFlat( f ); | 49 | downButton()->setFlat( f ); |
47 | } | 50 | } |
48 | }; | 51 | }; |
49 | 52 | ||
50 | class FlatStylePrivate : public QObject | 53 | class FlatStylePrivate : public QObject |
51 | { | 54 | { |
52 | Q_OBJECT | 55 | Q_OBJECT |
53 | public: | 56 | public: |
54 | FlatStylePrivate() : QObject() {} | 57 | FlatStylePrivate() : QObject() {} |
55 | 58 | ||
56 | bool eventFilter( QObject *o, QEvent *e ) { | 59 | bool eventFilter( QObject *o, QEvent *e ) { |
57 | if ( e->type() == QEvent::ParentPaletteChange && o->inherits( "QMenuBar" ) ) { | 60 | if ( e->type() == QEvent::ParentPaletteChange ) { |
58 | QWidget *w = (QWidget *)o; | 61 | if ( o->inherits( "QMenuBar" ) ) { |
59 | if ( w->parentWidget() ) { | 62 | QWidget *w = (QWidget *)o; |
60 | QPalette p = w->parentWidget()->palette(); | 63 | if ( w->parentWidget() ) { |
61 | QColorGroup a = p.active(); | 64 | QPalette p = w->parentWidget()->palette(); |
62 | a.setColor( QColorGroup::Light, a.foreground() ); | 65 | QColorGroup a = p.active(); |
63 | a.setColor( QColorGroup::Dark, a.foreground() ); | 66 | a.setColor( QColorGroup::Light, a.foreground() ); |
64 | p.setActive( a ); | 67 | a.setColor( QColorGroup::Dark, a.foreground() ); |
65 | p.setInactive( a ); | 68 | p.setActive( a ); |
66 | w->setPalette( p ); | 69 | p.setInactive( a ); |
70 | w->setPalette( p ); | ||
71 | } | ||
72 | } else if ( o->inherits( "QHeader" ) ) { | ||
73 | QWidget *w = (QWidget *)o; | ||
74 | if ( w->parentWidget() ) { | ||
75 | QPalette p = w->parentWidget()->palette(); | ||
76 | QColorGroup a = p.active(); | ||
77 | a.setColor( QColorGroup::Light, a.button() ); | ||
78 | p.setActive( a ); | ||
79 | p.setInactive( a ); | ||
80 | w->setPalette( p ); | ||
81 | } | ||
67 | } | 82 | } |
68 | } | 83 | } |
69 | return FALSE; | 84 | return FALSE; |
70 | } | 85 | } |
86 | |||
87 | QMap<QFrame *,int> frameStyles; | ||
71 | }; | 88 | }; |
72 | 89 | ||
73 | FlatStyle::FlatStyle() : revItem(FALSE) | 90 | FlatStyle::FlatStyle() : revItem(FALSE), fillBtnBorder(FALSE) |
74 | { | 91 | { |
75 | setButtonMargin(3); | 92 | setButtonMargin(3); |
76 | setScrollBarExtent(13,13); | 93 | setScrollBarExtent(13,13); |
77 | setButtonDefaultIndicatorWidth(0); | 94 | setButtonDefaultIndicatorWidth(0); |
78 | d = new FlatStylePrivate; | 95 | d = new FlatStylePrivate; |
79 | } | 96 | } |
80 | 97 | ||
81 | FlatStyle::~FlatStyle() | 98 | FlatStyle::~FlatStyle() |
82 | { | 99 | { |
83 | delete d; | 100 | delete d; |
84 | } | 101 | } |
85 | 102 | ||
86 | int FlatStyle::buttonMargin() const | 103 | int FlatStyle::buttonMargin() const |
87 | { | 104 | { |
88 | return 3; | 105 | return 3; |
89 | } | 106 | } |
90 | 107 | ||
91 | QSize FlatStyle::scrollBarExtent() const | 108 | QSize FlatStyle::scrollBarExtent() const |
92 | { | 109 | { |
93 | return QSize(13,13); | 110 | return QSize(13,13); |
94 | } | 111 | } |
95 | 112 | ||
96 | void FlatStyle::polish ( QPalette & ) | 113 | void FlatStyle::polish ( QPalette & ) |
97 | { | 114 | { |
98 | } | 115 | } |
99 | 116 | ||
100 | void FlatStyle::polish( QWidget *w ) | 117 | void FlatStyle::polish( QWidget *w ) |
101 | { | 118 | { |
102 | if ( w->inherits( "QFrame" ) ) { | 119 | if ( w->inherits( "QFrame" ) ) { |
103 | QFrame *f = (QFrame *)w; | 120 | QFrame *f = (QFrame *)w; |
104 | if ( f->frameShape() != QFrame::NoFrame ) | 121 | if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) |
122 | f->setFrameShadow( QFrame::Plain ); | ||
123 | else if ( f->frameShape() != QFrame::NoFrame ) | ||
105 | f->setFrameShape( QFrame::StyledPanel ); | 124 | f->setFrameShape( QFrame::StyledPanel ); |
106 | f->setLineWidth( 1 ); | 125 | f->setLineWidth( 1 ); |
107 | } | 126 | } |
108 | if ( w->inherits( "QSpinBox" ) ) | 127 | if ( w->inherits( "QSpinBox" ) ) |
109 | ((SpinBoxHack*)w)->setFlatButtons( TRUE ); | 128 | ((SpinBoxHack*)w)->setFlatButtons( TRUE ); |
110 | if ( w->inherits( "QMenuBar" ) ) { | 129 | if ( w->inherits( "QMenuBar" ) ) { |
111 | // make selected item look flat | 130 | // make selected item look flat |
112 | QPalette p = w->palette(); | 131 | QPalette p = w->palette(); |
113 | QColorGroup a = p.active(); | 132 | QColorGroup a = p.active(); |
114 | a.setColor( QColorGroup::Light, a.foreground() ); | 133 | a.setColor( QColorGroup::Light, a.foreground() ); |
115 | a.setColor( QColorGroup::Dark, a.foreground() ); | 134 | a.setColor( QColorGroup::Dark, a.foreground() ); |
116 | p.setActive( a ); | 135 | p.setActive( a ); |
117 | p.setInactive( a ); | 136 | p.setInactive( a ); |
118 | w->setPalette( p ); | 137 | w->setPalette( p ); |
119 | w->installEventFilter( d ); | 138 | w->installEventFilter( d ); |
139 | } else if ( w->inherits( "QHeader" ) ) { | ||
140 | // make headers look flat | ||
141 | QPalette p = w->palette(); | ||
142 | QColorGroup a = p.active(); | ||
143 | a.setColor( QColorGroup::Light, a.button() ); | ||
144 | p.setActive( a ); | ||
145 | p.setInactive( a ); | ||
146 | w->setPalette( p ); | ||
147 | w->installEventFilter( d ); | ||
120 | } | 148 | } |
121 | } | 149 | } |
122 | 150 | ||
123 | void FlatStyle::unPolish( QWidget *w ) | 151 | void FlatStyle::unPolish( QWidget *w ) |
124 | { | 152 | { |
125 | if ( w->inherits( "QFrame" ) ) { | 153 | if ( w->inherits("QFrame") ) { |
126 | QFrame *f = (QFrame *)w; | 154 | QFrame *f = (QFrame *)w; |
127 | if ( f->frameShape() != QFrame::NoFrame ) | 155 | if ( f->frameShape() == QFrame::HLine || f->frameShape() == QFrame::VLine ) { |
156 | f->setFrameShadow( QFrame::Sunken ); | ||
157 | } else if ( f->frameShape() != QFrame::NoFrame ) { | ||
128 | f->setFrameShape( QFrame::StyledPanel ); | 158 | f->setFrameShape( QFrame::StyledPanel ); |
129 | f->setLineWidth( 2 ); | 159 | f->setLineWidth( 2 ); |
160 | } | ||
130 | } | 161 | } |
131 | if ( w->inherits( "QSpinBox" ) ) | 162 | if ( w->inherits("QSpinBox") ) |
132 | ((SpinBoxHack*)w)->setFlatButtons( FALSE ); | 163 | ((SpinBoxHack*)w)->setFlatButtons( FALSE ); |
133 | if ( w->inherits( "QMenuBar" ) ) { | 164 | if ( w->inherits("QMenuBar") || w->inherits("QHeader") ) { |
134 | w->unsetPalette(); | 165 | w->unsetPalette(); |
135 | w->removeEventFilter( d ); | 166 | w->removeEventFilter( d ); |
136 | } | 167 | } |
137 | } | 168 | } |
138 | 169 | ||
139 | int FlatStyle::defaultFrameWidth() const | 170 | int FlatStyle::defaultFrameWidth() const |
140 | { | 171 | { |
141 | return 1; | 172 | return 2; |
142 | } | 173 | } |
143 | 174 | ||
144 | void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h, | 175 | void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h, |
145 | int flags, const QColorGroup &g, bool enabled, | 176 | int flags, const QColorGroup &g, bool enabled, |
146 | const QPixmap *pixmap, const QString& text, int len, | 177 | const QPixmap *pixmap, const QString& text, int len, |
147 | const QColor* penColor ) | 178 | const QColor* penColor ) |
148 | { | 179 | { |
149 | QColor pc( penColor ? *penColor : g.foreground() ); | 180 | QColor pc( penColor ? *penColor : g.foreground() ); |
150 | QColorGroup cg( g ); | 181 | QColorGroup cg( g ); |
151 | if ( !enabled ) | 182 | if ( !enabled ) |
152 | cg.setColor( QColorGroup::Light, cg.background() ); | 183 | cg.setColor( QColorGroup::Light, cg.background() ); |
153 | if ( revItem ) { | 184 | if ( revItem ) { |
154 | pc = cg.button(); | 185 | pc = cg.button(); |
155 | revItem = FALSE; | 186 | revItem = FALSE; |
156 | } | 187 | } |
157 | QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc ); | 188 | QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc ); |
158 | } | 189 | } |
159 | 190 | ||
160 | void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, | 191 | void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h, |
161 | const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill ) | 192 | const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill ) |
162 | { | 193 | { |
163 | if ( fill ) | 194 | if ( fill ) |
164 | p->setBrush( *fill ); | 195 | p->setBrush( *fill ); |
165 | p->setPen( QPen(g.foreground(), lineWidth) ); | 196 | p->setPen( QPen(g.foreground(), lineWidth) ); |
166 | p->drawRect( x, y, w, h ); | 197 | p->drawRect( x, y, w, h ); |
167 | } | 198 | } |
168 | 199 | ||
169 | void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, | 200 | void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h, |
170 | const QColorGroup &cg, bool /*sunken*/, const QBrush* fill ) | 201 | const QColorGroup &cg, bool /*sunken*/, const QBrush* fill ) |
171 | { | 202 | { |
172 | QPen oldPen = p->pen(); | 203 | QPen oldPen = p->pen(); |
173 | 204 | ||
205 | int x2 = x+w-1; | ||
206 | int y2 = y+h-1; | ||
207 | |||
208 | if ( fillBtnBorder && btnBg != cg.color(QColorGroup::Button) ) { | ||
209 | p->setPen( btnBg ); | ||
210 | p->drawLine( x, y, x2, y ); | ||
211 | p->drawLine( x, y2, x2, y2 ); | ||
212 | p->drawLine( x, y+1, x, y2-1 ); | ||
213 | p->drawLine( x2, y+1, x2, y2-1 ); | ||
214 | p->fillRect( x+1, y+1, 3, 3, btnBg ); | ||
215 | p->fillRect( x+1, y2-3, 3, 3, btnBg ); | ||
216 | p->fillRect( x2-3, y2-3, 3, 3, btnBg ); | ||
217 | p->fillRect( x2-3, y+1, 3, 3, btnBg ); | ||
218 | p->fillRect( x+2, y+2, w-4, h-4, fill?(*fill):cg.brush(QColorGroup::Button) ); | ||
219 | } else { | ||
220 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) ); | ||
221 | } | ||
222 | |||
174 | if ( h >= 10 ) { | 223 | if ( h >= 10 ) { |
175 | x++; y++; | 224 | x++; y++; |
225 | x2--; y2--; | ||
176 | w -= 2; h -= 2; | 226 | w -= 2; h -= 2; |
177 | } | 227 | } |
178 | 228 | ||
179 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) ); | ||
180 | |||
181 | int x2 = x+w-1; | ||
182 | int y2 = y+h-1; | ||
183 | |||
184 | p->setPen( cg.foreground() ); | 229 | p->setPen( cg.foreground() ); |
185 | 230 | ||
186 | if ( h < 10 ) { | 231 | if ( h < 10 ) { |
187 | p->setBrush( NoBrush ); | 232 | p->setBrush( NoBrush ); |
188 | p->drawRect( x, y, w, h ); | 233 | p->drawRect( x, y, w, h ); |
189 | } else { | 234 | } else { |
190 | p->drawLine( x+3, y, x2-3, y ); | 235 | p->drawLine( x+3, y, x2-3, y ); |
191 | p->drawLine( x+3, y2, x2-3, y2 ); | 236 | p->drawLine( x+3, y2, x2-3, y2 ); |
192 | p->drawLine( x, y+3, x, y2-3 ); | 237 | p->drawLine( x, y+3, x, y2-3 ); |
193 | p->drawLine( x2, y+3, x2, y2-3 ); | 238 | p->drawLine( x2, y+3, x2, y2-3 ); |
194 | 239 | ||
195 | p->drawLine( x+1, y+1, x+2, y+1 ); | 240 | p->drawLine( x+1, y+1, x+2, y+1 ); |
196 | p->drawPoint( x+1, y+2 ); | 241 | p->drawPoint( x+1, y+2 ); |
197 | p->drawLine( x2-2, y+1, x2-1, y+1 ); | 242 | p->drawLine( x2-2, y+1, x2-1, y+1 ); |
198 | p->drawPoint( x2-1, y+2 ); | 243 | p->drawPoint( x2-1, y+2 ); |
199 | 244 | ||
200 | p->drawLine( x+1, y2-1, x+2, y2-1 ); | 245 | p->drawLine( x+1, y2-1, x+2, y2-1 ); |
201 | p->drawPoint( x+1, y2-2 ); | 246 | p->drawPoint( x+1, y2-2 ); |
202 | p->drawLine( x2-2, y2-1, x2-1, y2-1 ); | 247 | p->drawLine( x2-2, y2-1, x2-1, y2-1 ); |
203 | p->drawPoint( x2-1, y2-2 ); | 248 | p->drawPoint( x2-1, y2-2 ); |
204 | } | 249 | } |
205 | 250 | ||
206 | p->setPen( oldPen ); | 251 | p->setPen( oldPen ); |
207 | } | 252 | } |
208 | 253 | ||
209 | void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) | 254 | void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h ) |
210 | { | 255 | { |
211 | x++; y++; | 256 | x++; y++; |
212 | x-=2; y-=2; | 257 | x-=2; y-=2; |
213 | p->fillRect( x, y, w, h, color1 ); | 258 | p->fillRect( x, y, w, h, color1 ); |
214 | } | 259 | } |
215 | 260 | ||
216 | void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, | 261 | void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h, |
217 | const QColorGroup &g, bool /*sunken*/, const QBrush* fill ) | 262 | const QColorGroup &g, bool /*sunken*/, const QBrush* fill ) |
218 | { | 263 | { |
219 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); | 264 | p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) ); |
220 | p->setPen( g.foreground() ); | 265 | p->setPen( g.foreground() ); |
221 | p->setBrush( NoBrush ); | 266 | p->setBrush( NoBrush ); |
222 | p->drawRect( x, y, w, h ); | 267 | p->drawRect( x, y, w, h ); |
223 | } | 268 | } |
224 | 269 | ||
225 | void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, | 270 | void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h, |
226 | const QColorGroup &g, bool sunken, const QBrush* fill ) | 271 | const QColorGroup &g, bool sunken, const QBrush* fill ) |
227 | { | 272 | { |
273 | if ( p->device()->devType() == QInternal::Widget ) { | ||
274 | QWidget *w = (QWidget *)p->device(); | ||
275 | if ( w->isA("QToolButton") ) { | ||
276 | QToolButton *btn = (QToolButton *)w; | ||
277 | if ( btn->parentWidget() ) { | ||
278 | btnBg = btn->parentWidget()->backgroundColor(); | ||
279 | fillBtnBorder = TRUE; | ||
280 | } | ||
281 | } | ||
282 | } | ||
228 | QBrush fb( fill ? *fill : g.button() ); | 283 | QBrush fb( fill ? *fill : g.button() ); |
229 | if ( sunken && fb == g.brush( QColorGroup::Button ) ) { | 284 | if ( sunken && fb == g.brush( QColorGroup::Button ) ) { |
230 | fb = g.buttonText(); | 285 | fb = g.buttonText(); |
231 | revItem = TRUE;// ugh | 286 | revItem = TRUE;// ugh |
232 | } | 287 | } |
233 | drawButton( p, x, y, w, h, g, sunken, &fb ); | 288 | drawButton( p, x, y, w, h, g, sunken, &fb ); |
289 | fillBtnBorder = FALSE; | ||
234 | } | 290 | } |
235 | 291 | ||
236 | void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) | 292 | void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p ) |
237 | { | 293 | { |
238 | QColorGroup g = btn->colorGroup(); | 294 | QColorGroup g = btn->colorGroup(); |
239 | int x1, y1, x2, y2; | 295 | int x1, y1, x2, y2; |
240 | 296 | ||
241 | btn->rect().coords( &x1, &y1, &x2, &y2 );// get coordinates | 297 | btn->rect().coords( &x1, &y1, &x2, &y2 );// get coordinates |
242 | 298 | ||
243 | p->setPen( g.foreground() ); | 299 | p->setPen( g.foreground() ); |
244 | p->setBrush( QBrush(g.button(),NoBrush) ); | 300 | p->setBrush( QBrush(g.button(),NoBrush) ); |
245 | 301 | ||
246 | // int diw = buttonDefaultIndicatorWidth(); | 302 | // int diw = buttonDefaultIndicatorWidth(); |
247 | /* | 303 | /* |
248 | if ( btn->isDefault() || btn->autoDefault() ) { | 304 | if ( btn->isDefault() || btn->autoDefault() ) { |
249 | if ( btn->isDefault() ) { | 305 | if ( btn->isDefault() ) { |
250 | p->setPen( g.shadow() ); | 306 | p->setPen( g.shadow() ); |
251 | p->drawRect( x1, y1, x2-x1+1, y2-y1+1 ); | 307 | p->drawRect( x1, y1, x2-x1+1, y2-y1+1 ); |
252 | } | 308 | } |
253 | x1 += diw; | 309 | x1 += diw; |
254 | y1 += diw; | 310 | y1 += diw; |
255 | x2 -= diw; | 311 | x2 -= diw; |
256 | y2 -= diw; | 312 | y2 -= diw; |
257 | } | 313 | } |
258 | */ | 314 | */ |
259 | 315 | ||
316 | if ( btn->parentWidget() ) { | ||
317 | btnBg = btn->parentWidget()->backgroundColor(); | ||
318 | fillBtnBorder = TRUE; | ||
319 | } | ||
320 | |||
260 | bool clearButton = TRUE; | 321 | bool clearButton = TRUE; |
261 | if ( btn->isDown() ) { | 322 | if ( btn->isDown() ) { |
262 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, | 323 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, |
263 | &g.brush( QColorGroup::Text ) ); | 324 | &g.brush( QColorGroup::Text ) ); |
264 | } else { | 325 | } else { |
265 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) { | 326 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) { |
266 | QBrush fill(g.light(), Dense4Pattern ); | 327 | QBrush fill(g.light(), Dense4Pattern ); |
267 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill ); | 328 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill ); |
268 | clearButton = FALSE; | 329 | clearButton = FALSE; |
269 | } else { | 330 | } else { |
270 | if ( !btn->isFlat() ) | 331 | if ( !btn->isFlat() ) |
271 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(), | 332 | drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(), |
272 | &g.brush( QColorGroup::Button ) ); | 333 | &g.brush( QColorGroup::Button ) ); |
273 | } | 334 | } |
274 | } | 335 | } |
275 | /* | 336 | /* |
276 | if ( clearButton ) { | 337 | if ( clearButton ) { |
277 | if (btn->isDown()) | 338 | if (btn->isDown()) |
278 | p->setBrushOrigin(p->brushOrigin() + QPoint(1,1)); | 339 | p->setBrushOrigin(p->brushOrigin() + QPoint(1,1)); |
279 | p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3, | 340 | p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3, |
280 | g.brush( QColorGroup::Button ) ); | 341 | g.brush( QColorGroup::Button ) ); |
281 | if (btn->isDown()) | 342 | if (btn->isDown()) |
282 | p->setBrushOrigin(p->brushOrigin() - QPoint(1,1)); | 343 | p->setBrushOrigin(p->brushOrigin() - QPoint(1,1)); |
283 | } | 344 | } |
284 | */ | 345 | */ |
285 | 346 | ||
347 | fillBtnBorder = FALSE; | ||
286 | if ( p->brush().style() != NoBrush ) | 348 | if ( p->brush().style() != NoBrush ) |
287 | p->setBrush( NoBrush ); | 349 | p->setBrush( NoBrush ); |
288 | } | 350 | } |
289 | 351 | ||
290 | void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) | 352 | void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p ) |
291 | { | 353 | { |
292 | QRect r = pushButtonContentsRect( btn ); | 354 | QRect r = pushButtonContentsRect( btn ); |
293 | int x, y, w, h; | 355 | int x, y, w, h; |
294 | r.rect( &x, &y, &w, &h ); | 356 | r.rect( &x, &y, &w, &h ); |
295 | QColorGroup cg = btn->colorGroup(); | 357 | QColorGroup cg = btn->colorGroup(); |
296 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() ) | 358 | if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() ) |
297 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() ); | 359 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() ); |
298 | else if ( btn->isDown() || btn->isOn() ) | 360 | else if ( btn->isDown() || btn->isOn() ) |
299 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() ); | 361 | cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() ); |
300 | if ( btn->isMenuButton() ) { | 362 | if ( btn->isMenuButton() ) { |
301 | int dx = menuButtonIndicatorWidth( btn->height() ); | 363 | int dx = menuButtonIndicatorWidth( btn->height() ); |
302 | drawArrow( p, DownArrow, FALSE, | 364 | drawArrow( p, DownArrow, FALSE, |
303 | x+w-dx, y+2, dx-4, h-4, | 365 | x+w-dx, y+2, dx-4, h-4, |
304 | cg, | 366 | cg, |
305 | btn->isEnabled() ); | 367 | btn->isEnabled() ); |
306 | w -= dx; | 368 | w -= dx; |
307 | } | 369 | } |
308 | 370 | ||
309 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) { | 371 | if ( btn->iconSet() && !btn->iconSet()->isNull() ) { |
310 | QIconSet::Mode mode = btn->isEnabled() | 372 | QIconSet::Mode mode = btn->isEnabled() |
311 | ? QIconSet::Normal : QIconSet::Disabled; | 373 | ? QIconSet::Normal : QIconSet::Disabled; |
312 | if ( mode == QIconSet::Normal && btn->hasFocus() ) | 374 | if ( mode == QIconSet::Normal && btn->hasFocus() ) |
313 | mode = QIconSet::Active; | 375 | mode = QIconSet::Active; |
314 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); | 376 | QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode ); |
315 | int pixw = pixmap.width(); | 377 | int pixw = pixmap.width(); |
316 | int pixh = pixmap.height(); | 378 | int pixh = pixmap.height(); |
317 | p->drawPixmap( x+2, y+h/2-pixh/2, pixmap ); | 379 | p->drawPixmap( x+2, y+h/2-pixh/2, pixmap ); |
318 | x += pixw + 4; | 380 | x += pixw + 4; |
319 | w -= pixw + 4; | 381 | w -= pixw + 4; |
320 | } | 382 | } |
321 | drawItem( p, x, y, w, h, | 383 | drawItem( p, x, y, w, h, |
322 | AlignCenter | ShowPrefix, | 384 | AlignCenter | ShowPrefix, |
323 | cg, btn->isEnabled(), | 385 | cg, btn->isEnabled(), |
324 | btn->pixmap(), btn->text(), -1, &cg.buttonText() ); | 386 | btn->pixmap(), btn->text(), -1, &cg.buttonText() ); |
325 | 387 | ||
326 | } | 388 | } |
327 | 389 | ||
328 | QRect FlatStyle::comboButtonRect( int x, int y, int w, int h) | 390 | QRect FlatStyle::comboButtonRect( int x, int y, int w, int h) |
329 | { | 391 | { |
330 | return QRect(x+2, y+2, w-4-13, h-4); | 392 | return QRect(x+2, y+2, w-4-13, h-4); |
331 | } | 393 | } |
332 | 394 | ||
333 | 395 | ||
334 | QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h) | 396 | QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h) |
335 | { | 397 | { |
336 | return QRect(x+2, y+2, w-4-14, h-4); | 398 | return QRect(x+2, y+2, w-4-14, h-4); |
337 | } | 399 | } |
338 | 400 | ||
339 | void FlatStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, | 401 | void FlatStyle::drawComboButton( QPainter *p, int x, int y, int w, int h, |
340 | const QColorGroup &g, bool sunken, | 402 | const QColorGroup &g, bool sunken, |
341 | bool /*editable*/, | 403 | bool /*editable*/, |
342 | bool enabled, | 404 | bool enabled, |
343 | const QBrush * /*fill*/ ) | 405 | const QBrush * /*fill*/ ) |
344 | { | 406 | { |
345 | x++; y++; | 407 | x++; y++; |
346 | w-=2; h-=2; | 408 | w-=2; h-=2; |
347 | p->setPen( g.foreground() ); | 409 | p->setPen( g.foreground() ); |
348 | p->setBrush( QBrush(NoBrush) ); | 410 | p->setBrush( QBrush(NoBrush) ); |
349 | p->drawRect( x, y, w, h ); | 411 | p->drawRect( x, y, w, h ); |
350 | p->setPen( g.background() ); | 412 | p->setPen( g.background() ); |
351 | p->drawRect( x+1, y+1, w-14, h-2 ); | 413 | p->drawRect( x+1, y+1, w-14, h-2 ); |
352 | p->fillRect( x+2, y+2, w-16, h-4, g.brush( QColorGroup::Base ) ); | 414 | p->fillRect( x+2, y+2, w-16, h-4, g.brush( QColorGroup::Base ) ); |
353 | QColorGroup cg( g ); | 415 | QColorGroup cg( g ); |
354 | if ( sunken ) { | 416 | if ( sunken ) { |
355 | cg.setColor( QColorGroup::ButtonText, g.button() ); | 417 | cg.setColor( QColorGroup::ButtonText, g.button() ); |
356 | cg.setColor( QColorGroup::Button, g.buttonText() ); | 418 | cg.setColor( QColorGroup::Button, g.buttonText() ); |
357 | } | 419 | } |
358 | drawArrow( p, QStyle::DownArrow, FALSE, | 420 | drawArrow( p, QStyle::DownArrow, FALSE, |
359 | x+w-13, y+1, 12, h-2, cg, enabled, | 421 | x+w-13, y+1, 12, h-2, cg, enabled, |
360 | &cg.brush( QColorGroup::Button ) ); | 422 | &cg.brush( QColorGroup::Button ) ); |
361 | 423 | ||
362 | } | 424 | } |
363 | 425 | ||
364 | 426 | ||
365 | void FlatStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, | 427 | void FlatStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w, |
366 | int h, const QColorGroup &cg, bool on, bool down, bool enabled ) | 428 | int h, const QColorGroup &cg, bool on, bool down, bool enabled ) |
367 | { | 429 | { |
368 | static const QCOORD pts1[] = { // dark lines | 430 | static const QCOORD pts1[] = { // dark lines |
369 | 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; | 431 | 1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 }; |
370 | static const QCOORD pts4[] = { // white lines | 432 | static const QCOORD pts4[] = { // white lines |
371 | 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, | 433 | 2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7, |
372 | 11,4, 10,3, 10,2 }; | 434 | 11,4, 10,3, 10,2 }; |
373 | static const QCOORD pts5[] = { // inner fill | 435 | static const QCOORD pts5[] = { // inner fill |
374 | 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; | 436 | 4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 }; |
375 | 437 | ||
376 | p->eraseRect( x, y, w, h ); | 438 | p->eraseRect( x, y, w, h ); |
377 | QPointArray a( QCOORDARRLEN(pts1), pts4 ); | 439 | QPointArray a( QCOORDARRLEN(pts1), pts4 ); |
378 | a.translate( x, y ); | 440 | a.translate( x, y ); |
379 | p->setPen( cg.foreground() ); | 441 | p->setPen( cg.foreground() ); |
380 | p->drawPolyline( a ); | 442 | p->drawPolyline( a ); |
381 | a.setPoints( QCOORDARRLEN(pts4), pts1 ); | 443 | a.setPoints( QCOORDARRLEN(pts4), pts1 ); |
@@ -496,193 +558,194 @@ QStyle::ScrollControl FlatStyle::scrollBarPointOver( const QScrollBar* sb, int s | |||
496 | } | 558 | } |
497 | 559 | ||
498 | /*! \reimp */ | 560 | /*! \reimp */ |
499 | 561 | ||
500 | void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ) | 562 | void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl ) |
501 | { | 563 | { |
502 | #define ADD_LINE_ACTIVE ( activeControl == AddLine ) | 564 | #define ADD_LINE_ACTIVE ( activeControl == AddLine ) |
503 | #define SUB_LINE_ACTIVE ( activeControl == SubLine ) | 565 | #define SUB_LINE_ACTIVE ( activeControl == SubLine ) |
504 | QColorGroup g = sb->colorGroup(); | 566 | QColorGroup g = sb->colorGroup(); |
505 | 567 | ||
506 | int sliderMin, sliderMax, sliderLength, buttonDim; | 568 | int sliderMin, sliderMax, sliderLength, buttonDim; |
507 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); | 569 | scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim ); |
508 | 570 | ||
509 | if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) { | 571 | if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) { |
510 | p->setPen( g.foreground() ); | 572 | p->setPen( g.foreground() ); |
511 | p->setBrush( g.brush( QColorGroup::Mid ) ); | 573 | p->setBrush( g.brush( QColorGroup::Mid ) ); |
512 | p->drawRect( 0, 0, sb->width(), sb->height() ); | 574 | p->drawRect( 0, 0, sb->width(), sb->height() ); |
513 | } | 575 | } |
514 | 576 | ||
515 | if (sliderStart > sliderMax) { // sanity check | 577 | if (sliderStart > sliderMax) { // sanity check |
516 | sliderStart = sliderMax; | 578 | sliderStart = sliderMax; |
517 | } | 579 | } |
518 | 580 | ||
519 | int dimB = buttonDim; | 581 | int dimB = buttonDim; |
520 | QRect addB; | 582 | QRect addB; |
521 | QRect subB; | 583 | QRect subB; |
522 | QRect addPageR; | 584 | QRect addPageR; |
523 | QRect subPageR; | 585 | QRect subPageR; |
524 | QRect sliderR; | 586 | QRect sliderR; |
525 | int addX, addY, subX, subY; | 587 | int addX, addY, subX, subY; |
526 | int length = HORIZONTAL ? sb->width() : sb->height(); | 588 | int length = HORIZONTAL ? sb->width() : sb->height(); |
527 | int extent = HORIZONTAL ? sb->height() : sb->width(); | 589 | int extent = HORIZONTAL ? sb->height() : sb->width(); |
528 | 590 | ||
529 | if ( HORIZONTAL ) { | 591 | if ( HORIZONTAL ) { |
530 | subY = addY = ( extent - dimB ) / 2; | 592 | subY = addY = ( extent - dimB ) / 2; |
531 | subX = length - dimB - dimB + 1; | 593 | subX = length - dimB - dimB + 1; |
532 | addX = length - dimB; | 594 | addX = length - dimB; |
533 | } else { | 595 | } else { |
534 | subX = addX = ( extent - dimB ) / 2; | 596 | subX = addX = ( extent - dimB ) / 2; |
535 | subY = length - dimB - dimB + 1; | 597 | subY = length - dimB - dimB + 1; |
536 | addY = length - dimB; | 598 | addY = length - dimB; |
537 | } | 599 | } |
538 | 600 | ||
539 | int sliderEnd = sliderStart + sliderLength; | 601 | int sliderEnd = sliderStart + sliderLength; |
540 | int sliderW = extent; | 602 | int sliderW = extent; |
541 | if ( HORIZONTAL ) { | 603 | if ( HORIZONTAL ) { |
542 | subB.setRect( subX,subY,dimB,dimB ); | 604 | subB.setRect( subX,subY,dimB,dimB ); |
543 | addB.setRect( addX,addY,dimB,dimB ); | 605 | addB.setRect( addX,addY,dimB,dimB ); |
544 | subPageR.setRect( 0, 0, sliderStart+1, sliderW ); | 606 | subPageR.setRect( 0, 0, sliderStart+1, sliderW ); |
545 | addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+2, sliderW ); | 607 | addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+2, sliderW ); |
546 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); | 608 | sliderR .setRect( sliderStart, 0, sliderLength, sliderW ); |
547 | 609 | ||
548 | } else { | 610 | } else { |
549 | subB.setRect( subX,subY,dimB,dimB ); | 611 | subB.setRect( subX,subY,dimB,dimB ); |
550 | addB.setRect( addX,addY,dimB,dimB ); | 612 | addB.setRect( addX,addY,dimB,dimB ); |
551 | subPageR.setRect( 0, 0, sliderW, sliderStart+1 ); | 613 | subPageR.setRect( 0, 0, sliderW, sliderStart+1 ); |
552 | addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+2 ); | 614 | addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+2 ); |
553 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); | 615 | sliderR .setRect( 0, sliderStart, sliderW, sliderLength ); |
554 | } | 616 | } |
555 | 617 | ||
556 | bool maxedOut = (sb->maxValue() == sb->minValue()); | 618 | bool maxedOut = (sb->maxValue() == sb->minValue()); |
557 | p->setPen( g.foreground() ); | 619 | p->setPen( g.foreground() ); |
558 | if ( controls & AddLine ) { | 620 | if ( controls & AddLine ) { |
559 | p->setBrush( ADD_LINE_ACTIVE ? g.foreground() : g.button() ); | 621 | p->setBrush( ADD_LINE_ACTIVE ? g.foreground() : g.button() ); |
560 | p->drawRect( addB.x(), addB.y(), addB.width(), addB.height() ); | 622 | p->drawRect( addB.x(), addB.y(), addB.width(), addB.height() ); |
561 | p->setPen( ADD_LINE_ACTIVE ? g.button() : g.foreground() ); | 623 | p->setPen( ADD_LINE_ACTIVE ? g.button() : g.foreground() ); |
562 | QColorGroup cg( g ); | 624 | QColorGroup cg( g ); |
563 | if ( maxedOut ) | 625 | if ( maxedOut ) |
564 | cg.setColor( QColorGroup::ButtonText, g.mid() ); | 626 | cg.setColor( QColorGroup::ButtonText, g.mid() ); |
565 | else if ( ADD_LINE_ACTIVE ) | 627 | else if ( ADD_LINE_ACTIVE ) |
566 | cg.setColor( QColorGroup::ButtonText, g.button() ); | 628 | cg.setColor( QColorGroup::ButtonText, g.button() ); |
567 | int xo = VERTICAL ? 1 : 0; | 629 | int xo = VERTICAL ? 1 : 0; |
568 | drawArrow( p, VERTICAL ? DownArrow : RightArrow, FALSE, | 630 | drawArrow( p, VERTICAL ? DownArrow : RightArrow, FALSE, |
569 | addB.x()+2+xo, addB.y()+2, addB.width()-4-xo, addB.height()-4, | 631 | addB.x()+2+xo, addB.y()+2, addB.width()-4-xo, addB.height()-4, |
570 | cg, TRUE, &p->brush() ); | 632 | cg, TRUE, &p->brush() ); |
571 | } | 633 | } |
572 | if ( controls & SubLine ) { | 634 | if ( controls & SubLine ) { |
573 | p->setBrush( SUB_LINE_ACTIVE ? g.foreground() : g.button() ); | 635 | p->setBrush( SUB_LINE_ACTIVE ? g.foreground() : g.button() ); |
574 | p->drawRect( subB.x(), subB.y(), subB.width(), subB.height() ); | 636 | p->drawRect( subB.x(), subB.y(), subB.width(), subB.height() ); |
575 | p->setPen( SUB_LINE_ACTIVE ? g.button() : g.foreground() ); | 637 | p->setPen( SUB_LINE_ACTIVE ? g.button() : g.foreground() ); |
576 | QColorGroup cg( g ); | 638 | QColorGroup cg( g ); |
577 | if ( maxedOut ) | 639 | if ( maxedOut ) |
578 | cg.setColor( QColorGroup::ButtonText, g.mid() ); | 640 | cg.setColor( QColorGroup::ButtonText, g.mid() ); |
579 | else if ( SUB_LINE_ACTIVE ) | 641 | else if ( SUB_LINE_ACTIVE ) |
580 | cg.setColor( QColorGroup::ButtonText, g.button() ); | 642 | cg.setColor( QColorGroup::ButtonText, g.button() ); |
581 | int xo = VERTICAL ? 1 : 0; | 643 | int xo = VERTICAL ? 1 : 0; |
582 | drawArrow( p, VERTICAL ? UpArrow : LeftArrow, FALSE, | 644 | drawArrow( p, VERTICAL ? UpArrow : LeftArrow, FALSE, |
583 | subB.x()+2+xo, subB.y()+2, subB.width()-4-xo, subB.height()-4, | 645 | subB.x()+2+xo, subB.y()+2, subB.width()-4-xo, subB.height()-4, |
584 | cg, TRUE, &p->brush() ); | 646 | cg, TRUE, &p->brush() ); |
585 | } | 647 | } |
586 | 648 | ||
587 | 649 | ||
588 | p->setPen( g.foreground() ); | 650 | p->setPen( g.foreground() ); |
589 | p->setBrush( g.brush( QColorGroup::Mid ) ); | 651 | p->setBrush( g.brush( QColorGroup::Mid ) ); |
590 | if ( controls & SubPage ) | 652 | if ( controls & SubPage ) |
591 | p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() ); | 653 | p->drawRect( subPageR.x(), subPageR.y(), subPageR.width(), subPageR.height() ); |
592 | if ( controls & AddPage && addPageR.y() < addPageR.bottom() ) | 654 | if ( controls & AddPage && addPageR.y() < addPageR.bottom() && |
655 | addPageR.x() < addPageR.right() ) | ||
593 | p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() ); | 656 | p->drawRect( addPageR.x(), addPageR.y(), addPageR.width(), addPageR.height() ); |
594 | if ( controls & Slider ) { | 657 | if ( controls & Slider ) { |
595 | QPoint bo = p->brushOrigin(); | 658 | QPoint bo = p->brushOrigin(); |
596 | p->setBrushOrigin(sliderR.topLeft()); | 659 | p->setBrushOrigin(sliderR.topLeft()); |
597 | p->setPen( g.foreground() ); | 660 | p->setPen( g.foreground() ); |
598 | p->setBrush( g.button() ); | 661 | p->setBrush( g.button() ); |
599 | p->drawRect( sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height() ); | 662 | p->drawRect( sliderR.x(), sliderR.y(), sliderR.width(), sliderR.height() ); |
600 | p->setBrushOrigin(bo); | 663 | p->setBrushOrigin(bo); |
601 | QColorGroup cg( g ); | 664 | QColorGroup cg( g ); |
602 | if ( maxedOut ) | 665 | if ( maxedOut ) |
603 | cg.setColor( QColorGroup::ButtonText, g.mid() ); | 666 | cg.setColor( QColorGroup::ButtonText, g.mid() ); |
604 | drawRiffles( p, sliderR.x(), sliderR.y(), | 667 | drawRiffles( p, sliderR.x(), sliderR.y(), |
605 | sliderR.width(), sliderR.height(), cg, HORIZONTAL ); | 668 | sliderR.width(), sliderR.height(), cg, HORIZONTAL ); |
606 | } | 669 | } |
607 | 670 | ||
608 | // ### perhaps this should not be able to accept focus if maxedOut? | 671 | // ### perhaps this should not be able to accept focus if maxedOut? |
609 | if ( sb->hasFocus() && (controls & Slider) ) | 672 | if ( sb->hasFocus() && (controls & Slider) ) |
610 | p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2, | 673 | p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2, |
611 | sliderR.width()-5, sliderR.height()-5, | 674 | sliderR.width()-5, sliderR.height()-5, |
612 | sb->backgroundColor() ); | 675 | sb->backgroundColor() ); |
613 | 676 | ||
614 | } | 677 | } |
615 | 678 | ||
616 | void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h, | 679 | void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h, |
617 | const QColorGroup &g, bool horizontal ) | 680 | const QColorGroup &g, bool horizontal ) |
618 | { | 681 | { |
619 | if (!horizontal) { | 682 | if (!horizontal) { |
620 | if (h > 20) { | 683 | if (h > 20) { |
621 | y += (h-20)/2 ; | 684 | y += (h-20)/2 ; |
622 | h = 20; | 685 | h = 20; |
623 | } | 686 | } |
624 | if (h > 12) { | 687 | if (h > 12) { |
625 | int n = 3; | 688 | int n = 3; |
626 | int my = y+h/2-2; | 689 | int my = y+h/2-2; |
627 | int i ; | 690 | int i ; |
628 | p->setPen(g.buttonText()); | 691 | p->setPen(g.buttonText()); |
629 | for (i=0; i<n; i++) { | 692 | for (i=0; i<n; i++) { |
630 | p->drawLine(x+4, my+3*i, x+w-5, my+3*i); | 693 | p->drawLine(x+4, my+3*i, x+w-5, my+3*i); |
631 | } | 694 | } |
632 | } | 695 | } |
633 | } else { | 696 | } else { |
634 | if (w > 20) { | 697 | if (w > 20) { |
635 | x += (w-20)/2 ; | 698 | x += (w-20)/2 ; |
636 | w = 20; | 699 | w = 20; |
637 | } | 700 | } |
638 | if (w > 12) { | 701 | if (w > 12) { |
639 | int n = 3; | 702 | int n = 3; |
640 | int mx = x+w/2-4; | 703 | int mx = x+w/2-4; |
641 | int i ; | 704 | int i ; |
642 | p->setPen(g.buttonText()); | 705 | p->setPen(g.buttonText()); |
643 | for (i=0; i<n; i++) { | 706 | for (i=0; i<n; i++) { |
644 | p->drawLine(mx+3*i, y+4, mx + 3*i, y+h-5); | 707 | p->drawLine(mx+3*i, y+4, mx + 3*i, y+h-5); |
645 | } | 708 | } |
646 | } | 709 | } |
647 | } | 710 | } |
648 | } | 711 | } |
649 | 712 | ||
650 | int FlatStyle::sliderLength() const | 713 | int FlatStyle::sliderLength() const |
651 | { | 714 | { |
652 | return 12; | 715 | return 12; |
653 | } | 716 | } |
654 | 717 | ||
655 | void FlatStyle::drawSlider( QPainter *p, int x, int y, int w, int h, | 718 | void FlatStyle::drawSlider( QPainter *p, int x, int y, int w, int h, |
656 | const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow ) | 719 | const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow ) |
657 | { | 720 | { |
658 | int a = tickAbove ? 3 : 0; | 721 | int a = tickAbove ? 3 : 0; |
659 | int b = tickBelow ? 3 : 0; | 722 | int b = tickBelow ? 3 : 0; |
660 | 723 | ||
661 | p->setPen( g.foreground() ); | 724 | p->setPen( g.foreground() ); |
662 | p->setBrush( g.button() ); | 725 | p->setBrush( g.button() ); |
663 | if ( o == Horizontal ) { | 726 | if ( o == Horizontal ) { |
664 | p->drawRect( x, y+a, w, h-a-b ); | 727 | p->drawRect( x, y+a, w, h-a-b ); |
665 | int xp = x + w/2; | 728 | int xp = x + w/2; |
666 | p->drawLine( xp-1, y+a+3, xp-1, y+h-b-4 ); | 729 | p->drawLine( xp-1, y+a+3, xp-1, y+h-b-4 ); |
667 | p->drawLine( xp, y+a+3, xp, y+h-b-4 ); | 730 | p->drawLine( xp, y+a+3, xp, y+h-b-4 ); |
668 | } else { | 731 | } else { |
669 | p->drawRect( x+a, y, w-a-b, h ); | 732 | p->drawRect( x+a, y, w-a-b, h ); |
670 | int yp = y + h/2; | 733 | int yp = y + h/2; |
671 | p->drawLine( x+a+3, yp-1, x+w-b-4, yp-1 ); | 734 | p->drawLine( x+a+3, yp-1, x+w-b-4, yp-1 ); |
672 | p->drawLine( x+a+3, yp, x+w-b-4, yp ); | 735 | p->drawLine( x+a+3, yp, x+w-b-4, yp ); |
673 | } | 736 | } |
674 | } | 737 | } |
675 | 738 | ||
676 | void FlatStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, | 739 | void FlatStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h, |
677 | Orientation o, bool tickAbove, bool tickBelow ) | 740 | Orientation o, bool tickAbove, bool tickBelow ) |
678 | { | 741 | { |
679 | int a = tickAbove ? 3 : 0; | 742 | int a = tickAbove ? 3 : 0; |
680 | int b = tickBelow ? 3 : 0; | 743 | int b = tickBelow ? 3 : 0; |
681 | if ( o == Horizontal ) | 744 | if ( o == Horizontal ) |
682 | p->fillRect( x, y+a, w, h-a-b, color1 ); | 745 | p->fillRect( x, y+a, w, h-a-b, color1 ); |
683 | else | 746 | else |
684 | p->fillRect( x+a, y, w-a-b, h, color1 ); | 747 | p->fillRect( x+a, y, w-a-b, h, color1 ); |
685 | } | 748 | } |
686 | 749 | ||
687 | /*!\reimp | 750 | /*!\reimp |
688 | */ | 751 | */ |
@@ -691,192 +754,198 @@ void FlatStyle::drawSliderGrooveMask( QPainter *p, | |||
691 | const QColorGroup& , QCOORD c, | 754 | const QColorGroup& , QCOORD c, |
692 | Orientation orient ) | 755 | Orientation orient ) |
693 | { | 756 | { |
694 | if ( orient == Horizontal ) | 757 | if ( orient == Horizontal ) |
695 | p->fillRect( x, y + c - 2, w, 4, color1 ); | 758 | p->fillRect( x, y + c - 2, w, 4, color1 ); |
696 | else | 759 | else |
697 | p->fillRect( x + c - 2, y, 4, h, color1 ); | 760 | p->fillRect( x + c - 2, y, 4, h, color1 ); |
698 | } | 761 | } |
699 | 762 | ||
700 | void FlatStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, QCOORD c, Orientation orient ) | 763 | void FlatStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, QCOORD c, Orientation orient ) |
701 | { | 764 | { |
702 | if ( orient == Horizontal ) | 765 | if ( orient == Horizontal ) |
703 | p->fillRect( x, y + c - 2, w, 4, g.foreground() ); | 766 | p->fillRect( x, y + c - 2, w, 4, g.foreground() ); |
704 | else | 767 | else |
705 | p->fillRect( x + c - 2, y, 4, h, g.foreground() ); | 768 | p->fillRect( x + c - 2, y, 4, h, g.foreground() ); |
706 | } | 769 | } |
707 | 770 | ||
708 | void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) | 771 | void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected ) |
709 | { | 772 | { |
710 | QRect r( t->rect() ); | 773 | QRect r( t->rect() ); |
711 | if ( tb->shape() == QTabBar::RoundedAbove ) { | 774 | if ( tb->shape() == QTabBar::RoundedAbove ) { |
712 | p->setPen( tb->colorGroup().foreground() ); | 775 | p->setPen( tb->colorGroup().foreground() ); |
713 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); | 776 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); |
714 | if ( r.left() == 0 ) | 777 | if ( r.left() == 0 ) |
715 | p->drawPoint( tb->rect().bottomLeft() ); | 778 | p->drawPoint( tb->rect().bottomLeft() ); |
716 | else | 779 | else |
717 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); | 780 | p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); |
718 | 781 | ||
719 | if ( selected ) { | 782 | if ( selected ) { |
720 | p->setPen( tb->colorGroup().background() ); | 783 | p->setPen( tb->colorGroup().background() ); |
721 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); | 784 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); |
722 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), | 785 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-2), |
723 | tb->colorGroup().brush( QColorGroup::Background )); | 786 | tb->colorGroup().brush( QColorGroup::Background )); |
724 | } else { | 787 | } else { |
725 | r.setRect( r.left() + 2, r.top() + 2, | 788 | r.setRect( r.left() + 2, r.top() + 2, |
726 | r.width() - 4, r.height() - 2 ); | 789 | r.width() - 4, r.height() - 2 ); |
727 | p->setPen( tb->colorGroup().button() ); | 790 | p->setPen( tb->colorGroup().button() ); |
728 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); | 791 | p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 ); |
729 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), | 792 | p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3), |
730 | tb->colorGroup().brush( QColorGroup::Button )); | 793 | tb->colorGroup().brush( QColorGroup::Button )); |
731 | } | 794 | } |
732 | 795 | ||
733 | p->setPen( tb->colorGroup().foreground() ); | 796 | p->setPen( tb->colorGroup().foreground() ); |
734 | p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); | 797 | p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 ); |
735 | p->drawPoint( r.left()+1, r.top() + 1 ); | 798 | p->drawPoint( r.left()+1, r.top() + 1 ); |
736 | p->drawLine( r.left()+2, r.top(), | 799 | p->drawLine( r.left()+2, r.top(), |
737 | r.right() - 2, r.top() ); | 800 | r.right() - 2, r.top() ); |
738 | 801 | ||
739 | p->drawPoint( r.right() - 1, r.top() + 1 ); | 802 | p->drawPoint( r.right() - 1, r.top() + 1 ); |
740 | p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); | 803 | p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1); |
741 | } else if ( tb->shape() == QTabBar::RoundedBelow ) { | 804 | } else if ( tb->shape() == QTabBar::RoundedBelow ) { |
742 | if ( selected ) { | 805 | if ( selected ) { |
743 | p->setPen( tb->colorGroup().background() ); | 806 | p->setPen( tb->colorGroup().background() ); |
744 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); | 807 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); |
745 | p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), | 808 | p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2), |
746 | tb->palette().normal().brush( QColorGroup::Background )); | 809 | tb->palette().normal().brush( QColorGroup::Background )); |
747 | } else { | 810 | } else { |
748 | p->setPen( tb->colorGroup().foreground() ); | 811 | p->setPen( tb->colorGroup().foreground() ); |
749 | p->drawLine( r.left(), r.top(), | 812 | p->drawLine( r.left(), r.top(), |
750 | r.right(), r.top() ); | 813 | r.right(), r.top() ); |
751 | r.setRect( r.left() + 2, r.top(), | 814 | r.setRect( r.left() + 2, r.top(), |
752 | r.width() - 4, r.height() - 2 ); | 815 | r.width() - 4, r.height() - 2 ); |
753 | p->setPen( tb->colorGroup().button() ); | 816 | p->setPen( tb->colorGroup().button() ); |
754 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); | 817 | p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); |
755 | p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), | 818 | p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3), |
756 | tb->palette().normal().brush( QColorGroup::Button )); | 819 | tb->palette().normal().brush( QColorGroup::Button )); |
757 | } | 820 | } |
758 | 821 | ||
759 | p->setPen( tb->colorGroup().foreground() ); | 822 | p->setPen( tb->colorGroup().foreground() ); |
760 | p->drawLine( r.right(), r.top(), | 823 | p->drawLine( r.right(), r.top(), |
761 | r.right(), r.bottom() - 2 ); | 824 | r.right(), r.bottom() - 2 ); |
762 | p->drawPoint( r.right() - 1, r.bottom() - 1 ); | 825 | p->drawPoint( r.right() - 1, r.bottom() - 1 ); |
763 | p->drawLine( r.right() - 2, r.bottom(), | 826 | p->drawLine( r.right() - 2, r.bottom(), |
764 | r.left() + 2, r.bottom() ); | 827 | r.left() + 2, r.bottom() ); |
765 | 828 | ||
766 | p->drawLine( r.left(), r.top()+1, | 829 | p->drawLine( r.left(), r.top()+1, |
767 | r.left(), r.bottom() - 2 ); | 830 | r.left(), r.bottom() - 2 ); |
768 | p->drawPoint( r.left() + 1, r.bottom() - 1 ); | 831 | p->drawPoint( r.left() + 1, r.bottom() - 1 ); |
769 | if ( r.left() == 0 ) | 832 | if ( r.left() == 0 ) |
770 | p->drawPoint( tb->rect().topLeft() ); | 833 | p->drawPoint( tb->rect().topLeft() ); |
771 | 834 | ||
772 | } else { | 835 | } else { |
773 | QCommonStyle::drawTab( p, tb, t, selected ); | 836 | QCommonStyle::drawTab( p, tb, t, selected ); |
774 | } | 837 | } |
775 | } | 838 | } |
776 | 839 | ||
777 | static const int motifItemFrame = 0;// menu item frame width | 840 | static const int motifItemFrame = 0;// menu item frame width |
778 | static const int motifSepHeight = 2;// separator item height | 841 | static const int motifSepHeight = 2;// separator item height |
779 | static const int motifItemHMargin = 1;// menu item hor text margin | 842 | static const int motifItemHMargin = 1;// menu item hor text margin |
780 | static const int motifItemVMargin = 2;// menu item ver text margin | 843 | static const int motifItemVMargin = 2;// menu item ver text margin |
781 | static const int motifArrowHMargin = 0;// arrow horizontal margin | 844 | static const int motifArrowHMargin = 0;// arrow horizontal margin |
782 | static const int motifTabSpacing = 12;// space between text and tab | 845 | static const int motifTabSpacing = 12;// space between text and tab |
783 | static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark | 846 | static const int motifCheckMarkHMargin = 1;// horiz. margins of check mark |
784 | static const int windowsRightBorder= 8; // right border on windows | 847 | static const int windowsRightBorder= 8; // right border on windows |
785 | static const int windowsCheckMarkWidth = 2; // checkmarks width on windows | 848 | static const int windowsCheckMarkWidth = 2; // checkmarks width on windows |
786 | 849 | ||
850 | void FlatStyle::polishPopupMenu ( QPopupMenu *m ) | ||
851 | { | ||
852 | QWindowsStyle::polishPopupMenu( m ); | ||
853 | m->setLineWidth( 1 ); | ||
854 | } | ||
855 | |||
787 | /*! \reimp | 856 | /*! \reimp |
788 | */ | 857 | */ |
789 | int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) | 858 | int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ ) |
790 | { | 859 | { |
791 | #ifndef QT_NO_MENUDATA | 860 | #ifndef QT_NO_MENUDATA |
792 | int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm | 861 | int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm |
793 | 862 | ||
794 | if ( mi->isSeparator() ) | 863 | if ( mi->isSeparator() ) |
795 | return 10; // arbitrary | 864 | return 10; // arbitrary |
796 | else if ( mi->pixmap() ) | 865 | else if ( mi->pixmap() ) |
797 | w += mi->pixmap()->width();// pixmap only | 866 | w += mi->pixmap()->width();// pixmap only |
798 | 867 | ||
799 | if ( !mi->text().isNull() ) { | 868 | if ( !mi->text().isNull() ) { |
800 | if ( mi->text().find('\t') >= 0 )// string contains tab | 869 | if ( mi->text().find('\t') >= 0 )// string contains tab |
801 | w += motifTabSpacing; | 870 | w += motifTabSpacing; |
802 | } | 871 | } |
803 | 872 | ||
804 | if ( maxpmw ) { // we have iconsets | 873 | if ( maxpmw ) { // we have iconsets |
805 | w += maxpmw; | 874 | w += maxpmw; |
806 | w += 6; // add a little extra border around the iconset | 875 | w += 6; // add a little extra border around the iconset |
807 | } | 876 | } |
808 | 877 | ||
809 | if ( checkable && maxpmw < windowsCheckMarkWidth ) { | 878 | if ( checkable && maxpmw < windowsCheckMarkWidth ) { |
810 | w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks | 879 | w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks |
811 | } | 880 | } |
812 | 881 | ||
813 | if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) | 882 | if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks) |
814 | w += motifCheckMarkHMargin; // add space to separate the columns | 883 | w += motifCheckMarkHMargin; // add space to separate the columns |
815 | 884 | ||
816 | w += windowsRightBorder; // windows has a strange wide border on the right side | 885 | w += windowsRightBorder; // windows has a strange wide border on the right side |
817 | 886 | ||
818 | return w; | 887 | return w; |
819 | #endif | 888 | #endif |
820 | } | 889 | } |
821 | 890 | ||
822 | /*! \reimp | 891 | /*! \reimp |
823 | */ | 892 | */ |
824 | int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) | 893 | int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm ) |
825 | { | 894 | { |
826 | #ifndef QT_NO_MENUDATA | 895 | #ifndef QT_NO_MENUDATA |
827 | int h = 0; | 896 | int h = 0; |
828 | if ( mi->isSeparator() ) // separator height | 897 | if ( mi->isSeparator() ) // separator height |
829 | h = motifSepHeight; | 898 | h = motifSepHeight; |
830 | else if ( mi->pixmap() ) // pixmap height | 899 | else if ( mi->pixmap() ) // pixmap height |
831 | h = mi->pixmap()->height() + 2*motifItemFrame; | 900 | h = mi->pixmap()->height() + 2*motifItemFrame; |
832 | else // text height | 901 | else // text height |
833 | h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; | 902 | h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1; |
834 | 903 | ||
835 | if ( !mi->isSeparator() && mi->iconSet() != 0 ) { | 904 | if ( !mi->isSeparator() && mi->iconSet() != 0 ) { |
836 | h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); | 905 | h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame ); |
837 | } | 906 | } |
838 | if ( mi->custom() ) | 907 | if ( mi->custom() ) |
839 | h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; | 908 | h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1; |
840 | return h; | 909 | return h; |
841 | #endif | 910 | #endif |
842 | } | 911 | } |
843 | 912 | ||
844 | void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, | 913 | void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, |
845 | const QPalette& pal, | 914 | const QPalette& pal, |
846 | bool act, bool enabled, int x, int y, int w, int h) | 915 | bool act, bool enabled, int x, int y, int w, int h) |
847 | { | 916 | { |
848 | #ifndef QT_NO_MENUDATA | 917 | #ifndef QT_NO_MENUDATA |
849 | const QColorGroup & g = pal.active(); | 918 | const QColorGroup & g = pal.active(); |
850 | bool dis = !enabled; | 919 | bool dis = !enabled; |
851 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); | 920 | QColorGroup itemg = dis ? pal.disabled() : pal.active(); |
852 | 921 | ||
853 | if ( checkable ) | 922 | if ( checkable ) |
854 | maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks | 923 | maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks |
855 | 924 | ||
856 | int checkcol = maxpmw; | 925 | int checkcol = maxpmw; |
857 | 926 | ||
858 | if ( mi && mi->isSeparator() ) { // draw separator | 927 | if ( mi && mi->isSeparator() ) { // draw separator |
859 | p->setPen( g.dark() ); | 928 | p->setPen( g.dark() ); |
860 | p->drawLine( x, y, x+w, y ); | 929 | p->drawLine( x, y, x+w, y ); |
861 | return; | 930 | return; |
862 | } | 931 | } |
863 | 932 | ||
864 | QBrush fill = act? g.brush( QColorGroup::Highlight ) : | 933 | QBrush fill = act? g.brush( QColorGroup::Highlight ) : |
865 | g.brush( QColorGroup::Button ); | 934 | g.brush( QColorGroup::Button ); |
866 | p->fillRect( x, y, w, h, fill); | 935 | p->fillRect( x, y, w, h, fill); |
867 | 936 | ||
868 | if ( !mi ) | 937 | if ( !mi ) |
869 | return; | 938 | return; |
870 | 939 | ||
871 | if ( mi->isChecked() ) { | 940 | if ( mi->isChecked() ) { |
872 | if ( act && !dis ) { | 941 | if ( act && !dis ) { |
873 | qDrawShadePanel( p, x, y, checkcol, h, | 942 | qDrawShadePanel( p, x, y, checkcol, h, |
874 | g, TRUE, 1, &g.brush( QColorGroup::Button ) ); | 943 | g, TRUE, 1, &g.brush( QColorGroup::Button ) ); |
875 | } else { | 944 | } else { |
876 | qDrawShadePanel( p, x, y, checkcol, h, | 945 | qDrawShadePanel( p, x, y, checkcol, h, |
877 | g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); | 946 | g, TRUE, 1, &g.brush( QColorGroup::Midlight ) ); |
878 | } | 947 | } |
879 | } else if ( !act ) { | 948 | } else if ( !act ) { |
880 | p->fillRect(x, y, checkcol , h, | 949 | p->fillRect(x, y, checkcol , h, |
881 | g.brush( QColorGroup::Button )); | 950 | g.brush( QColorGroup::Button )); |
882 | } | 951 | } |
@@ -915,118 +984,119 @@ void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int | |||
915 | QColor discol; | 984 | QColor discol; |
916 | if ( dis ) { | 985 | if ( dis ) { |
917 | discol = itemg.text(); | 986 | discol = itemg.text(); |
918 | p->setPen( discol ); | 987 | p->setPen( discol ); |
919 | } | 988 | } |
920 | 989 | ||
921 | int xm = motifItemFrame + checkcol + motifItemHMargin; | 990 | int xm = motifItemFrame + checkcol + motifItemHMargin; |
922 | 991 | ||
923 | if ( mi->custom() ) { | 992 | if ( mi->custom() ) { |
924 | int m = motifItemVMargin; | 993 | int m = motifItemVMargin; |
925 | p->save(); | 994 | p->save(); |
926 | if ( dis && !act ) { | 995 | if ( dis && !act ) { |
927 | p->setPen( g.light() ); | 996 | p->setPen( g.light() ); |
928 | mi->custom()->paint( p, itemg, act, enabled, | 997 | mi->custom()->paint( p, itemg, act, enabled, |
929 | x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); | 998 | x+xm+1, y+m+1, w-xm-tab+1, h-2*m ); |
930 | p->setPen( discol ); | 999 | p->setPen( discol ); |
931 | } | 1000 | } |
932 | mi->custom()->paint( p, itemg, act, enabled, | 1001 | mi->custom()->paint( p, itemg, act, enabled, |
933 | x+xm, y+m, w-xm-tab+1, h-2*m ); | 1002 | x+xm, y+m, w-xm-tab+1, h-2*m ); |
934 | p->restore(); | 1003 | p->restore(); |
935 | } | 1004 | } |
936 | QString s = mi->text(); | 1005 | QString s = mi->text(); |
937 | if ( !s.isNull() ) { // draw text | 1006 | if ( !s.isNull() ) { // draw text |
938 | int t = s.find( '\t' ); | 1007 | int t = s.find( '\t' ); |
939 | int m = motifItemVMargin; | 1008 | int m = motifItemVMargin; |
940 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; | 1009 | const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; |
941 | if ( t >= 0 ) { // draw tab text | 1010 | if ( t >= 0 ) { // draw tab text |
942 | if ( dis && !act ) { | 1011 | if ( dis && !act ) { |
943 | p->setPen( g.light() ); | 1012 | p->setPen( g.light() ); |
944 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, | 1013 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1, |
945 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); | 1014 | y+m+1, tab, h-2*m, text_flags, s.mid( t+1 )); |
946 | p->setPen( discol ); | 1015 | p->setPen( discol ); |
947 | } | 1016 | } |
948 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, | 1017 | p->drawText( x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame, |
949 | y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); | 1018 | y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); |
950 | } | 1019 | } |
951 | if ( dis && !act ) | 1020 | if ( dis && !act ) |
952 | p->setPen( discol ); | 1021 | p->setPen( discol ); |
953 | p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); | 1022 | p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t ); |
954 | } else if ( mi->pixmap() ) { // draw pixmap | 1023 | } else if ( mi->pixmap() ) { // draw pixmap |
955 | QPixmap *pixmap = mi->pixmap(); | 1024 | QPixmap *pixmap = mi->pixmap(); |
956 | if ( pixmap->depth() == 1 ) | 1025 | if ( pixmap->depth() == 1 ) |
957 | p->setBackgroundMode( OpaqueMode ); | 1026 | p->setBackgroundMode( OpaqueMode ); |
958 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); | 1027 | p->drawPixmap( x+xm, y+motifItemFrame, *pixmap ); |
959 | if ( pixmap->depth() == 1 ) | 1028 | if ( pixmap->depth() == 1 ) |
960 | p->setBackgroundMode( TransparentMode ); | 1029 | p->setBackgroundMode( TransparentMode ); |
961 | } | 1030 | } |
962 | if ( mi->popup() ) { // draw sub menu arrow | 1031 | if ( mi->popup() ) { // draw sub menu arrow |
963 | int dim = (h-2*motifItemFrame) / 2; | 1032 | int dim = (h-2*motifItemFrame) / 2; |
964 | if ( act ) { | 1033 | if ( act ) { |
965 | if ( !dis ) | 1034 | if ( !dis ) |
966 | discol = white; | 1035 | discol = white; |
967 | QColorGroup g2( discol, g.highlight(), | 1036 | QColorGroup g2( discol, g.highlight(), |
968 | white, white, | 1037 | white, white, |
969 | dis ? discol : white, | 1038 | dis ? discol : white, |
970 | discol, white ); | 1039 | discol, white ); |
971 | drawArrow( p, RightArrow, FALSE, | 1040 | drawArrow( p, RightArrow, FALSE, |
972 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, | 1041 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, |
973 | dim, dim, g2, TRUE ); | 1042 | dim, dim, g2, TRUE ); |
974 | } else { | 1043 | } else { |
975 | drawArrow( p, RightArrow, | 1044 | drawArrow( p, RightArrow, |
976 | FALSE, | 1045 | FALSE, |
977 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, | 1046 | x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2, |
978 | dim, dim, g, mi->isEnabled() ); | 1047 | dim, dim, g, mi->isEnabled() ); |
979 | } | 1048 | } |
980 | } | 1049 | } |
981 | #endif | 1050 | #endif |
982 | } | 1051 | } |
983 | 1052 | ||
984 | void FlatStyle::getButtonShift( int &x, int &y ) | 1053 | void FlatStyle::getButtonShift( int &x, int &y ) |
985 | { | 1054 | { |
986 | x = 0; y = 0; | 1055 | x = 0; y = 0; |
987 | } | 1056 | } |
988 | 1057 | ||
989 | //=========================================================================== | 1058 | //=========================================================================== |
990 | 1059 | ||
991 | FlatStyleImpl::FlatStyleImpl() | 1060 | FlatStyleImpl::FlatStyleImpl() |
992 | : flat(0), ref(0) | 1061 | : flat(0), ref(0) |
993 | { | 1062 | { |
994 | } | 1063 | } |
995 | 1064 | ||
996 | FlatStyleImpl::~FlatStyleImpl() | 1065 | FlatStyleImpl::~FlatStyleImpl() |
997 | { | 1066 | { |
998 | // We do not delete the style because Qt does that when a new style | 1067 | // We do not delete the style because Qt does that when a new style |
999 | // is set. | 1068 | // is set. |
1000 | } | 1069 | } |
1001 | 1070 | ||
1002 | QStyle *FlatStyleImpl::style() | 1071 | QStyle *FlatStyleImpl::style() |
1003 | { | 1072 | { |
1004 | if ( !flat ) | 1073 | if ( !flat ) |
1005 | flat = new FlatStyle(); | 1074 | flat = new FlatStyle(); |
1006 | return flat; | 1075 | return flat; |
1007 | } | 1076 | } |
1008 | 1077 | ||
1009 | QString FlatStyleImpl::name() const | 1078 | QString FlatStyleImpl::name() const |
1010 | { | 1079 | { |
1011 | return QString("Flat"); | 1080 | return qApp->translate("FlatStyle", "Flat", "Name of the style Flat"); |
1012 | } | 1081 | } |
1013 | 1082 | ||
1014 | QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 1083 | QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
1015 | { | 1084 | { |
1016 | *iface = 0; | 1085 | *iface = 0; |
1017 | if ( uuid == IID_QUnknown ) | 1086 | if ( uuid == IID_QUnknown ) |
1018 | *iface = this; | 1087 | *iface = this; |
1019 | else if ( uuid == IID_Style ) | 1088 | else if ( uuid == IID_Style ) |
1020 | *iface = this; | 1089 | *iface = this; |
1090 | else | ||
1091 | return QS_FALSE; | ||
1021 | 1092 | ||
1022 | if ( *iface ) | 1093 | (*iface)->addRef(); |
1023 | (*iface)->addRef(); | ||
1024 | return QS_OK; | 1094 | return QS_OK; |
1025 | } | 1095 | } |
1026 | 1096 | ||
1027 | Q_EXPORT_INTERFACE() | 1097 | Q_EXPORT_INTERFACE() |
1028 | { | 1098 | { |
1029 | Q_CREATE_INSTANCE( FlatStyleImpl ) | 1099 | Q_CREATE_INSTANCE( FlatStyleImpl ) |
1030 | } | 1100 | } |
1031 | 1101 | ||
1032 | #include "flat.moc" | 1102 | #include "flat.moc" |
diff --git a/noncore/styles/flat/flat.h b/noncore/styles/flat/flat.h index e446800..ebea95b 100644 --- a/noncore/styles/flat/flat.h +++ b/noncore/styles/flat/flat.h | |||
@@ -1,114 +1,118 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef FLATSTYLE_H | 21 | #ifndef FLATSTYLE_H |
22 | #define FLATSTYLE_H | 22 | #define FLATSTYLE_H |
23 | 23 | ||
24 | #include <qcolor.h> | ||
24 | #include <qwindowsstyle.h> | 25 | #include <qwindowsstyle.h> |
25 | #include <qpe/styleinterface.h> | 26 | #include <qpe/styleinterface.h> |
26 | 27 | ||
27 | class FlatStylePrivate; | 28 | class FlatStylePrivate; |
28 | 29 | ||
29 | class Q_EXPORT FlatStyle : public QWindowsStyle | 30 | class FlatStyle : public QWindowsStyle |
30 | { | 31 | { |
31 | public: | 32 | public: |
32 | FlatStyle(); | 33 | FlatStyle(); |
33 | virtual ~FlatStyle(); | 34 | virtual ~FlatStyle(); |
34 | virtual void polish( QPalette &p ); | 35 | virtual void polish( QPalette &p ); |
35 | virtual void polish( QWidget *w ); | 36 | virtual void polish( QWidget *w ); |
36 | virtual void unPolish( QWidget *w ); | 37 | virtual void unPolish( QWidget *w ); |
37 | 38 | ||
38 | int defaultFrameWidth () const; | 39 | int defaultFrameWidth () const; |
39 | void drawItem( QPainter *p, int x, int y, int w, int h, | 40 | void drawItem( QPainter *p, int x, int y, int w, int h, |
40 | int flags, const QColorGroup &g, bool enabled, | 41 | int flags, const QColorGroup &g, bool enabled, |
41 | const QPixmap *pixmap, const QString& text, int len, const QColor* penColor ); | 42 | const QPixmap *pixmap, const QString& text, int len, const QColor* penColor ); |
42 | void drawPanel ( QPainter * p, int x, int y, int w, int h, | 43 | void drawPanel ( QPainter * p, int x, int y, int w, int h, |
43 | const QColorGroup &, bool sunken=FALSE, int lineWidth = 1, const QBrush * fill = 0 ); | 44 | const QColorGroup &, bool sunken=FALSE, int lineWidth = 1, const QBrush * fill = 0 ); |
44 | void drawButton( QPainter *p, int x, int y, int w, int h, | 45 | void drawButton( QPainter *p, int x, int y, int w, int h, |
45 | const QColorGroup &g, bool sunken, const QBrush* fill ); | 46 | const QColorGroup &g, bool sunken, const QBrush* fill ); |
46 | void drawButtonMask ( QPainter * p, int x, int y, int w, int h ); | 47 | void drawButtonMask ( QPainter * p, int x, int y, int w, int h ); |
47 | void drawBevelButton( QPainter *p, int x, int y, int w, int h, | 48 | void drawBevelButton( QPainter *p, int x, int y, int w, int h, |
48 | const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 ); | 49 | const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 ); |
49 | void drawToolButton( QPainter *p, int x, int y, int w, int h, | 50 | void drawToolButton( QPainter *p, int x, int y, int w, int h, |
50 | const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 ); | 51 | const QColorGroup &g, bool sunken=FALSE, const QBrush* fill=0 ); |
51 | void drawPushButton( QPushButton *btn, QPainter *p ); | 52 | void drawPushButton( QPushButton *btn, QPainter *p ); |
52 | void drawPushButtonLabel( QPushButton *btn, QPainter *p ); | 53 | void drawPushButtonLabel( QPushButton *btn, QPainter *p ); |
53 | QRect comboButtonRect( int x, int y, int w, int h); | 54 | QRect comboButtonRect( int x, int y, int w, int h); |
54 | QRect comboButtonFocusRect( int x, int y, int w, int h); | 55 | QRect comboButtonFocusRect( int x, int y, int w, int h); |
55 | void drawComboButton( QPainter *p, int x, int y, int w, int h, | 56 | void drawComboButton( QPainter *p, int x, int y, int w, int h, |
56 | const QColorGroup &g, bool sunken, bool, bool enabled, | 57 | const QColorGroup &g, bool sunken, bool, bool enabled, |
57 | const QBrush *fill ); | 58 | const QBrush *fill ); |
58 | void drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h, | 59 | void drawExclusiveIndicator ( QPainter * p, int x, int y, int w, int h, |
59 | const QColorGroup & g, bool on, bool down = FALSE, bool enabled = TRUE ); | 60 | const QColorGroup & g, bool on, bool down = FALSE, bool enabled = TRUE ); |
60 | void drawIndicator ( QPainter * p, int x, int y, int w, int h, | 61 | void drawIndicator ( QPainter * p, int x, int y, int w, int h, |
61 | const QColorGroup & g, int state, bool down = FALSE, bool enabled = TRUE ); | 62 | const QColorGroup & g, int state, bool down = FALSE, bool enabled = TRUE ); |
62 | void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int&); | 63 | void scrollBarMetrics( const QScrollBar*, int&, int&, int&, int&); |
63 | void drawScrollBarControls( QPainter*, const QScrollBar*, int sliderStart, uint controls, uint activeControl ); | 64 | void drawScrollBarControls( QPainter*, const QScrollBar*, int sliderStart, uint controls, uint activeControl ); |
64 | ScrollControl scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ); | 65 | ScrollControl scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p ); |
65 | void drawRiffles( QPainter* p, int x, int y, int w, int h, | 66 | void drawRiffles( QPainter* p, int x, int y, int w, int h, |
66 | const QColorGroup &g, bool horizontal ); | 67 | const QColorGroup &g, bool horizontal ); |
67 | int sliderLength() const; | 68 | int sliderLength() const; |
68 | void drawSlider( QPainter *p, int x, int y, int w, int h, | 69 | void drawSlider( QPainter *p, int x, int y, int w, int h, |
69 | const QColorGroup &g, Orientation, bool tickAbove, bool tickBelow ); | 70 | const QColorGroup &g, Orientation, bool tickAbove, bool tickBelow ); |
70 | void drawSliderMask( QPainter *p, int x, int y, int w, int h, | 71 | void drawSliderMask( QPainter *p, int x, int y, int w, int h, |
71 | Orientation, bool tickAbove, bool tickBelow ); | 72 | Orientation, bool tickAbove, bool tickBelow ); |
72 | void drawSliderGrooveMask( QPainter *p, int x, int y, int w, int h, | 73 | void drawSliderGrooveMask( QPainter *p, int x, int y, int w, int h, |
73 | const QColorGroup& , QCOORD c, Orientation orient ); | 74 | const QColorGroup& , QCOORD c, Orientation orient ); |
74 | void drawSliderGroove ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, QCOORD c, Orientation ); | 75 | void drawSliderGroove ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, QCOORD c, Orientation ); |
75 | void drawTab( QPainter *, const QTabBar *, QTab *, bool selected ); | 76 | void drawTab( QPainter *, const QTabBar *, QTab *, bool selected ); |
77 | void polishPopupMenu ( QPopupMenu * ); | ||
76 | int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); | 78 | int extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*, const QFontMetrics& ); |
77 | int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& ); | 79 | int popupMenuItemHeight( bool checkable, QMenuItem*, const QFontMetrics& ); |
78 | void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, | 80 | void drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi, |
79 | const QPalette& pal, | 81 | const QPalette& pal, |
80 | bool act, bool enabled, int x, int y, int w, int h); | 82 | bool act, bool enabled, int x, int y, int w, int h); |
81 | 83 | ||
82 | int buttonMargin() const; | 84 | int buttonMargin() const; |
83 | QSize scrollBarExtent() const; | 85 | QSize scrollBarExtent() const; |
84 | void getButtonShift( int &x, int &y ); | 86 | void getButtonShift( int &x, int &y ); |
85 | 87 | ||
86 | private: | 88 | private: |
87 | FlatStylePrivate *d; | 89 | FlatStylePrivate *d; |
88 | bool revItem; | 90 | bool revItem; |
91 | bool fillBtnBorder; | ||
92 | QColor btnBg; | ||
89 | // Disabled copy constructor and operator= | 93 | // Disabled copy constructor and operator= |
90 | #if defined(Q_DISABLE_COPY) | 94 | #if defined(Q_DISABLE_COPY) |
91 | FlatStyle( const FlatStyle & ); | 95 | FlatStyle( const FlatStyle & ); |
92 | FlatStyle& operator=( const FlatStyle & ); | 96 | FlatStyle& operator=( const FlatStyle & ); |
93 | #endif | 97 | #endif |
94 | }; | 98 | }; |
95 | 99 | ||
96 | 100 | ||
97 | class FlatStyleImpl : public StyleInterface | 101 | class FlatStyleImpl : public StyleInterface |
98 | { | 102 | { |
99 | public: | 103 | public: |
100 | FlatStyleImpl(); | 104 | FlatStyleImpl(); |
101 | virtual ~FlatStyleImpl(); | 105 | virtual ~FlatStyleImpl(); |
102 | 106 | ||
103 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 107 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
104 | Q_REFCOUNT | 108 | Q_REFCOUNT |
105 | 109 | ||
106 | virtual QStyle *style(); | 110 | virtual QStyle *style(); |
107 | virtual QString name() const; | 111 | virtual QString name() const; |
108 | 112 | ||
109 | private: | 113 | private: |
110 | FlatStyle *flat; | 114 | FlatStyle *flat; |
111 | ulong ref; | 115 | ulong ref; |
112 | }; | 116 | }; |
113 | 117 | ||
114 | #endif // FLATSTYLE_H | 118 | #endif // FLATSTYLE_H |
diff --git a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp index 71dd7eb..73f8bb3 100644 --- a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp +++ b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp | |||
@@ -1,88 +1,89 @@ | |||
1 | #include "inputDialog.h" | 1 | #include "inputDialog.h" |
2 | 2 | ||
3 | #include <qapplication.h> | 3 | #include <qapplication.h> |
4 | 4 | ||
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | #include <qcheckbox.h> | 6 | #include <qcheckbox.h> |
7 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
8 | #include <qvariant.h> | 8 | #include <qvariant.h> |
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qwhatsthis.h> | 10 | #include <qwhatsthis.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | #include <qlayout.h> | ||
12 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
13 | #include <qstringlist.h> | 14 | #include <qstringlist.h> |
14 | #include <qmainwindow.h> | 15 | #include <qmainwindow.h> |
15 | #include "helpwindow.h" | 16 | #include "helpwindow.h" |
16 | 17 | ||
17 | #include <opie/oprocess.h> | 18 | #include <opie/oprocess.h> |
18 | 19 | ||
19 | #include <stdlib.h> | 20 | #include <stdlib.h> |
20 | // #include <sys/stat.h> | 21 | // #include <sys/stat.h> |
21 | // #include <unistd.h> | 22 | // #include <unistd.h> |
22 | 23 | ||
23 | InputDialog::InputDialog( ) | 24 | InputDialog::InputDialog( ) |
24 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { | 25 | : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { |
25 | setCaption( tr("Symbol Lookup")); | 26 | setCaption( tr("Symbol Lookup")); |
26 | 27 | ||
27 | QGridLayout *layout = new QGridLayout( this ); | 28 | QGridLayout *layout = new QGridLayout( this ); |
28 | layout->setSpacing(6); | 29 | layout->setSpacing(6); |
29 | layout->setMargin( 2); | 30 | layout->setMargin( 2); |
30 | 31 | ||
31 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 32 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
32 | LineEdit1->setFocus(); | 33 | LineEdit1->setFocus(); |
33 | 34 | ||
34 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); | 35 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); |
35 | 36 | ||
36 | QLabel *label; | 37 | QLabel *label; |
37 | label = new QLabel(this); | 38 | label = new QLabel(this); |
38 | label->setText( tr("Enter something to lookup / search.")); | 39 | label->setText( tr("Enter something to lookup / search.")); |
39 | label->setMaximumHeight(60); | 40 | label->setMaximumHeight(60); |
40 | layout->addMultiCellWidget( label, 1, 1, 0, 3); | 41 | layout->addMultiCellWidget( label, 1, 1, 0, 3); |
41 | 42 | ||
42 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup())); | 43 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup())); |
43 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); | 44 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); |
44 | layout->addItem( spacer, 8, 0 ); | 45 | layout->addItem( spacer, 8, 0 ); |
45 | 46 | ||
46 | } | 47 | } |
47 | 48 | ||
48 | InputDialog::~InputDialog() { | 49 | InputDialog::~InputDialog() { |
49 | } | 50 | } |
50 | 51 | ||
51 | void InputDialog::doLookup() { | 52 | void InputDialog::doLookup() { |
52 | // http://finance.yahoo.com/l?m=&s=siemens&t= | 53 | // http://finance.yahoo.com/l?m=&s=siemens&t= |
53 | 54 | ||
54 | QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\""; | 55 | QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\""; |
55 | QString tempHtml = "/tmp/stockticker.html"; | 56 | QString tempHtml = "/tmp/stockticker.html"; |
56 | QString cmd = "wget -O "+tempHtml+" "+url; | 57 | QString cmd = "wget -O "+tempHtml+" "+url; |
57 | qDebug(cmd); | 58 | qDebug(cmd); |
58 | 59 | ||
59 | 60 | ||
60 | /* | 61 | /* |
61 | OProcess proc; | 62 | OProcess proc; |
62 | proc << "/usr/bin/wget"; | 63 | proc << "/usr/bin/wget"; |
63 | proc<<"-O"<< tempHtml<< url; | 64 | proc<<"-O"<< tempHtml<< url; |
64 | 65 | ||
65 | connect( &proc, SIGNAL( processExited( OProcess *)),this, SLOT( showBrowser(OProcess *))); | 66 | connect( &proc, SIGNAL( processExited( OProcess *)),this, SLOT( showBrowser(OProcess *))); |
66 | proc.start( OProcess::NotifyOnExit); | 67 | proc.start( OProcess::NotifyOnExit); |
67 | */ | 68 | */ |
68 | system(cmd.latin1()); | 69 | system(cmd.latin1()); |
69 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); | 70 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); |
70 | StockLookup->setCaption("Symbol"); | 71 | StockLookup->setCaption("Symbol"); |
71 | StockLookup->showMaximized(); | 72 | StockLookup->showMaximized(); |
72 | StockLookup->show(); | 73 | StockLookup->show(); |
73 | LineEdit1->text(); | 74 | LineEdit1->text(); |
74 | 75 | ||
75 | 76 | ||
76 | } | 77 | } |
77 | 78 | ||
78 | void InputDialog::showBrowser(OProcess*) { | 79 | void InputDialog::showBrowser(OProcess*) { |
79 | qDebug("BLAH"); | 80 | qDebug("BLAH"); |
80 | QString tempHtml = "/tmp/stockticker.html"; | 81 | QString tempHtml = "/tmp/stockticker.html"; |
81 | 82 | ||
82 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); | 83 | HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); |
83 | StockLookup->setCaption("Symbol"); | 84 | StockLookup->setCaption("Symbol"); |
84 | StockLookup->showMaximized(); | 85 | StockLookup->showMaximized(); |
85 | StockLookup->show(); | 86 | StockLookup->show(); |
86 | LineEdit1->text(); | 87 | LineEdit1->text(); |
87 | 88 | ||
88 | } | 89 | } |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp index d740b6f..915233a 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp | |||
@@ -28,182 +28,182 @@ | |||
28 | #include <qvariant.h> | 28 | #include <qvariant.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qstringlist.h> | 32 | #include <qstringlist.h> |
33 | #include <qmainwindow.h> | 33 | #include <qmainwindow.h> |
34 | 34 | ||
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | 36 | ||
37 | StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char* name) | 37 | StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char* name) |
38 | : TodayConfigWidget(parent, name ) { | 38 | : TodayConfigWidget(parent, name ) { |
39 | 39 | ||
40 | QGridLayout *layout = new QGridLayout( this ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
41 | layout->setSpacing(2); | 41 | layout->setSpacing(2); |
42 | layout->setMargin( 2); | 42 | layout->setMargin( 2); |
43 | 43 | ||
44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
45 | LineEdit1->setFocus(); | 45 | LineEdit1->setFocus(); |
46 | // QWhatsThis::add( LineEdit1, tr("Enter the stock symbols you want to be shown here.")); | 46 | // QWhatsThis::add( LineEdit1, tr("Enter the stock symbols you want to be shown here.")); |
47 | 47 | ||
48 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 4); | 48 | layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 4); |
49 | 49 | ||
50 | Config cfg( "stockticker"); | 50 | Config cfg( "stockticker"); |
51 | cfg.setGroup( "Symbols" ); | 51 | cfg.setGroup( "Symbols" ); |
52 | QString symbollist; | 52 | QString symbollist; |
53 | symbollist = cfg.readEntry("Symbols", ""); | 53 | symbollist = cfg.readEntry("Symbols", ""); |
54 | LineEdit1->setText(symbollist); | 54 | LineEdit1->setText(symbollist); |
55 | 55 | ||
56 | QLabel *label; | 56 | QLabel *label; |
57 | label = new QLabel(this); | 57 | label = new QLabel(this); |
58 | label->setText( tr("Enter stock symbols seperated\nby a space.")); | 58 | label->setText( tr("Enter stock symbols seperated\nby a space.")); |
59 | label->setMaximumHeight(60); | 59 | label->setMaximumHeight(60); |
60 | layout->addMultiCellWidget( label, 1, 1, 0, 4); | 60 | layout->addMultiCellWidget( label, 1, 1, 0, 4); |
61 | 61 | ||
62 | cfg.setGroup( "Fields" ); | 62 | cfg.setGroup( "Fields" ); |
63 | 63 | ||
64 | timeCheck= new QCheckBox ( "Time",this ); | 64 | timeCheck= new QCheckBox ( "Time",this ); |
65 | timeCheck->setChecked( cfg.readBoolEntry("timeCheck",1)); | 65 | timeCheck->setChecked( cfg.readBoolEntry("timeCheck",1)); |
66 | layout->addMultiCellWidget(timeCheck, 2, 2, 0, 0 ); | 66 | layout->addMultiCellWidget(timeCheck, 2, 2, 0, 0 ); |
67 | QWhatsThis::add( timeCheck, tr("Toggles Time of current price field")); | 67 | QWhatsThis::add( timeCheck, tr("Toggles Time of current price field")); |
68 | 68 | ||
69 | dateCheck= new QCheckBox ( "Date", this ); | 69 | dateCheck= new QCheckBox ( "Date", this ); |
70 | dateCheck->setChecked( cfg.readBoolEntry("dateCheck",1)); | 70 | dateCheck->setChecked( cfg.readBoolEntry("dateCheck",1)); |
71 | layout->addMultiCellWidget( dateCheck, 2, 2, 1, 1 ); | 71 | layout->addMultiCellWidget( dateCheck, 2, 2, 1, 1 ); |
72 | QWhatsThis::add(dateCheck, tr("Toggles date field")); | 72 | QWhatsThis::add(dateCheck, tr("Toggles date field")); |
73 | 73 | ||
74 | symbolCheck= new QCheckBox ( "Symbol", this ); | 74 | symbolCheck= new QCheckBox ( "Symbol", this ); |
75 | symbolCheck->setChecked( cfg.readBoolEntry("symbolCheck",1)); | 75 | symbolCheck->setChecked( cfg.readBoolEntry("symbolCheck",1)); |
76 | layout->addMultiCellWidget( symbolCheck, 2, 2, 2, 2 ); | 76 | layout->addMultiCellWidget( symbolCheck, 2, 2, 2, 2 ); |
77 | QWhatsThis::add(symbolCheck, tr("Toggles Symbol field")); | 77 | QWhatsThis::add(symbolCheck, tr("Toggles Symbol field")); |
78 | 78 | ||
79 | nameCheck= new QCheckBox ( "Name", this ); | 79 | nameCheck= new QCheckBox ( "Name", this ); |
80 | nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1)); | 80 | nameCheck->setChecked( cfg.readBoolEntry("nameCheck",1)); |
81 | layout->addMultiCellWidget( nameCheck, 3, 3, 0, 0 ); | 81 | layout->addMultiCellWidget( nameCheck, 3, 3, 0, 0 ); |
82 | QWhatsThis::add(nameCheck, tr("Toggles Name of symbols owner field")); | 82 | QWhatsThis::add(nameCheck, tr("Toggles Name of symbols owner field")); |
83 | 83 | ||
84 | currentPriceCheck= new QCheckBox ( "Price", this ); | 84 | currentPriceCheck= new QCheckBox ( "Price", this ); |
85 | currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1)); | 85 | currentPriceCheck->setChecked( cfg.readBoolEntry("currentPriceCheck",1)); |
86 | layout->addMultiCellWidget( currentPriceCheck, 3, 3, 1, 1 ); | 86 | layout->addMultiCellWidget( currentPriceCheck, 3, 3, 1, 1 ); |
87 | QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field")); | 87 | QWhatsThis::add(currentPriceCheck, tr("Toggles current Price field")); |
88 | 88 | ||
89 | lastPriceCheck= new QCheckBox ( "Last Price", this ); | 89 | lastPriceCheck= new QCheckBox ( "Last Price", this ); |
90 | lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1)); | 90 | lastPriceCheck->setChecked( cfg.readBoolEntry("lastPriceCheck",1)); |
91 | layout->addMultiCellWidget(lastPriceCheck, 3, 3, 2, 2); | 91 | layout->addMultiCellWidget(lastPriceCheck, 3, 3, 2, 2); |
92 | QWhatsThis::add(lastPriceCheck, tr("Toggles last price field")); | 92 | QWhatsThis::add(lastPriceCheck, tr("Toggles last price field")); |
93 | 93 | ||
94 | openPriceCheck= new QCheckBox ( "Open Price", this); | 94 | openPriceCheck= new QCheckBox ( "Open Price", this); |
95 | openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1)); | 95 | openPriceCheck->setChecked( cfg.readBoolEntry("openPriceCheck",1)); |
96 | layout->addMultiCellWidget( openPriceCheck, 4, 4, 0, 0 ); | 96 | layout->addMultiCellWidget( openPriceCheck, 4, 4, 0, 0 ); |
97 | QWhatsThis::add(openPriceCheck, tr("Toggles opening price field")); | 97 | QWhatsThis::add(openPriceCheck, tr("Toggles opening price field")); |
98 | 98 | ||
99 | minPriceCheck= new QCheckBox ( "Min Price", this ); | 99 | minPriceCheck= new QCheckBox ( "Min Price", this ); |
100 | minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1)); | 100 | minPriceCheck->setChecked( cfg.readBoolEntry("minPriceCheck",1)); |
101 | layout->addMultiCellWidget( minPriceCheck, 4, 4, 1, 1); | 101 | layout->addMultiCellWidget( minPriceCheck, 4, 4, 1, 1); |
102 | QWhatsThis::add(minPriceCheck, tr("Toggles minimum daily price field")); | 102 | QWhatsThis::add(minPriceCheck, tr("Toggles minimum daily price field")); |
103 | 103 | ||
104 | maxPriceCheck= new QCheckBox ( "Max Price", this); | 104 | maxPriceCheck= new QCheckBox ( "Max Price", this); |
105 | maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1)); | 105 | maxPriceCheck->setChecked( cfg.readBoolEntry("maxPriceCheck",1)); |
106 | layout->addMultiCellWidget( maxPriceCheck, 4, 4, 2, 2 ); | 106 | layout->addMultiCellWidget( maxPriceCheck, 4, 4, 2, 2 ); |
107 | QWhatsThis::add(maxPriceCheck, tr("Toggles maximum daily price field")); | 107 | QWhatsThis::add(maxPriceCheck, tr("Toggles maximum daily price field")); |
108 | 108 | ||
109 | variationCheck= new QCheckBox ( "Variation", this ); | 109 | variationCheck= new QCheckBox ( "Variation", this ); |
110 | variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1)); | 110 | variationCheck->setChecked( cfg.readBoolEntry("variationCheck",1)); |
111 | layout->addMultiCellWidget( variationCheck, 5, 5, 0, 0 ); | 111 | layout->addMultiCellWidget( variationCheck, 5, 5, 0, 0 ); |
112 | QWhatsThis::add(variationCheck, tr("Toggles daily variation of price field")); | 112 | QWhatsThis::add(variationCheck, tr("Toggles daily variation of price field")); |
113 | 113 | ||
114 | volumeCheck= new QCheckBox ( "Volume", this ); | 114 | volumeCheck= new QCheckBox ( "Volume", this ); |
115 | volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1)); | 115 | volumeCheck->setChecked( cfg.readBoolEntry("volumeCheck",1)); |
116 | layout->addMultiCellWidget( volumeCheck , 5, 5, 1, 1); | 116 | layout->addMultiCellWidget( volumeCheck , 5, 5, 1, 1); |
117 | QWhatsThis::add(volumeCheck, tr("Toggles volume of trading field")); | 117 | QWhatsThis::add(volumeCheck, tr("Toggles volume of trading field")); |
118 | 118 | ||
119 | timerDelaySpin = new QSpinBox( this, "timer spin" ); | 119 | timerDelaySpin = new QSpinBox( this, "timer spin" ); |
120 | QWhatsThis::add( timerDelaySpin , tr( "How often stocks prices should be looked up. In minutes" ) ); | 120 | QWhatsThis::add( timerDelaySpin , tr( "How often stocks prices should be looked up. In minutes" ) ); |
121 | timerDelaySpin->setMaxValue( 60); | 121 | timerDelaySpin->setMaxValue( 60); |
122 | 122 | ||
123 | cfg.setGroup("Timer"); | 123 | cfg.setGroup("Timer"); |
124 | timerDelaySpin->setValue( cfg.readNumEntry("Delay",0)); | 124 | timerDelaySpin->setValue( cfg.readNumEntry("Delay",15)); |
125 | layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0); | 125 | layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0); |
126 | 126 | ||
127 | QLabel *label2; | 127 | QLabel *label2; |
128 | label2 = new QLabel(this); | 128 | label2 = new QLabel(this); |
129 | label2->setText( tr("Minutes between lookups.")); | 129 | label2->setText( tr("Minutes between lookups.")); |
130 | label2->setMaximumHeight(60); | 130 | label2->setMaximumHeight(60); |
131 | layout->addMultiCellWidget( label2, 6, 6, 1, 2); | 131 | layout->addMultiCellWidget( label2, 6, 6, 1, 2); |
132 | 132 | ||
133 | scrollSpeed = new QSpinBox( this, "Scrollspin" ); | 133 | scrollSpeed = new QSpinBox( this, "Scrollspin" ); |
134 | QWhatsThis::add( timerDelaySpin , tr( "Speed of scrolling action, in milliseconds" ) ); | 134 | QWhatsThis::add( timerDelaySpin , tr( "Speed of scrolling action, in milliseconds" ) ); |
135 | scrollSpeed->setMaxValue( 1000); | 135 | scrollSpeed->setMaxValue( 1000); |
136 | scrollSpeed->setSteps(50,50); | 136 | scrollSpeed->setSteps(50,50); |
137 | cfg.setGroup("Timer"); | 137 | cfg.setGroup("Timer"); |
138 | scrollSpeed->setValue( cfg.readNumEntry("ScrollSpeed",50)); | 138 | scrollSpeed->setValue( cfg.readNumEntry("ScrollSpeed",50)); |
139 | layout->addMultiCellWidget( scrollSpeed , 7, 7, 0, 0); | 139 | layout->addMultiCellWidget( scrollSpeed , 7, 7, 0, 0); |
140 | 140 | ||
141 | QLabel *label3; | 141 | QLabel *label3; |
142 | label3 = new QLabel(this); | 142 | label3 = new QLabel(this); |
143 | label3->setText( tr("Scroll Speed, in milliseconds")); | 143 | label3->setText( tr("Scroll Speed, in milliseconds")); |
144 | label3->setMaximumHeight(60); | 144 | label3->setMaximumHeight(60); |
145 | layout->addMultiCellWidget( label3, 7, 7, 1, 2); | 145 | layout->addMultiCellWidget( label3, 7, 7, 1, 2); |
146 | 146 | ||
147 | scrollLength = new QSpinBox( this, "ScrollLength" ); | 147 | scrollLength = new QSpinBox( this, "ScrollLength" ); |
148 | QWhatsThis::add( timerDelaySpin , tr( "Length of scrolling" ) ); | 148 | QWhatsThis::add( timerDelaySpin , tr( "Length of scrolling" ) ); |
149 | scrollLength->setMaxValue( 10); | 149 | scrollLength->setMaxValue( 10); |
150 | // scrollLength->setSteps(5,5); | 150 | // scrollLength->setSteps(5,5); |
151 | cfg.setGroup("Timer"); | 151 | cfg.setGroup("Timer"); |
152 | scrollLength->setValue( cfg.readNumEntry("ScrollLength",1)); | 152 | scrollLength->setValue( cfg.readNumEntry("ScrollLength",1)); |
153 | layout->addMultiCellWidget( scrollLength , 8, 8, 0, 0); | 153 | layout->addMultiCellWidget( scrollLength , 8, 8, 0, 0); |
154 | 154 | ||
155 | QLabel *label4; | 155 | QLabel *label4; |
156 | label4 = new QLabel(this); | 156 | label4 = new QLabel(this); |
157 | label4->setText( tr("Scroll Length")); | 157 | label4->setText( tr("Scroll Length")); |
158 | label4->setMaximumHeight(60); | 158 | label4->setMaximumHeight(60); |
159 | layout->addMultiCellWidget( label4, 8, 8, 1, 2); | 159 | layout->addMultiCellWidget( label4, 8, 8, 1, 2); |
160 | 160 | ||
161 | // lookupButton = new QPushButton(this, "LookupButton"); | 161 | // lookupButton = new QPushButton(this, "LookupButton"); |
162 | // lookupButton->setText(tr("Symbol Lookup")); | 162 | // lookupButton->setText(tr("Symbol Lookup")); |
163 | // connect(lookupButton,SIGNAL(clicked()),SLOT( doLookup())); | 163 | // connect(lookupButton,SIGNAL(clicked()),SLOT( doLookup())); |
164 | // layout->addMultiCellWidget( lookupButton , 9, 9, 0, 0); | 164 | // layout->addMultiCellWidget( lookupButton , 9, 9, 0, 0); |
165 | 165 | ||
166 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); | 166 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); |
167 | layout->addItem( spacer, 9, 0 ); | 167 | layout->addItem( spacer, 9, 0 ); |
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void StocktickerPluginConfig::writeConfig() { | 172 | void StocktickerPluginConfig::writeConfig() { |
173 | Config cfg( "stockticker"); | 173 | Config cfg( "stockticker"); |
174 | cfg.setGroup( "Symbols" ); | 174 | cfg.setGroup( "Symbols" ); |
175 | QString outText = text().upper(); | 175 | QString outText = text().upper(); |
176 | outText.stripWhiteSpace(); | 176 | outText.stripWhiteSpace(); |
177 | cfg.writeEntry("Symbols", outText ); | 177 | cfg.writeEntry("Symbols", outText ); |
178 | cfg.setGroup( "Fields" ); | 178 | cfg.setGroup( "Fields" ); |
179 | cfg.writeEntry("timeCheck",timeCheck->isChecked()); | 179 | cfg.writeEntry("timeCheck",timeCheck->isChecked()); |
180 | cfg.writeEntry("dateCheck",dateCheck->isChecked()); | 180 | cfg.writeEntry("dateCheck",dateCheck->isChecked()); |
181 | cfg.writeEntry("symbolCheck",symbolCheck->isChecked()); | 181 | cfg.writeEntry("symbolCheck",symbolCheck->isChecked()); |
182 | cfg.writeEntry("nameCheck",nameCheck->isChecked()); | 182 | cfg.writeEntry("nameCheck",nameCheck->isChecked()); |
183 | cfg.writeEntry("currentPriceCheck",currentPriceCheck->isChecked()); | 183 | cfg.writeEntry("currentPriceCheck",currentPriceCheck->isChecked()); |
184 | cfg.writeEntry("lastPriceCheck",lastPriceCheck->isChecked()); | 184 | cfg.writeEntry("lastPriceCheck",lastPriceCheck->isChecked()); |
185 | cfg.writeEntry("openPriceCheck",openPriceCheck->isChecked()); | 185 | cfg.writeEntry("openPriceCheck",openPriceCheck->isChecked()); |
186 | cfg.writeEntry("minPriceCheck",minPriceCheck->isChecked()); | 186 | cfg.writeEntry("minPriceCheck",minPriceCheck->isChecked()); |
187 | cfg.writeEntry("maxPriceCheck",maxPriceCheck->isChecked()); | 187 | cfg.writeEntry("maxPriceCheck",maxPriceCheck->isChecked()); |
188 | cfg.writeEntry("variationCheck",variationCheck->isChecked()); | 188 | cfg.writeEntry("variationCheck",variationCheck->isChecked()); |
189 | cfg.writeEntry("volumeCheck",volumeCheck->isChecked()); | 189 | cfg.writeEntry("volumeCheck",volumeCheck->isChecked()); |
190 | 190 | ||
191 | cfg.setGroup("Timer"); | 191 | cfg.setGroup("Timer"); |
192 | cfg.writeEntry("Delay",timerDelaySpin->value()); | 192 | cfg.writeEntry("Delay",timerDelaySpin->value()); |
193 | cfg.writeEntry("ScrollLength",scrollLength->value()); | 193 | cfg.writeEntry("ScrollLength",scrollLength->value()); |
194 | cfg.writeEntry("ScrollSpeed",scrollSpeed->value()); | 194 | cfg.writeEntry("ScrollSpeed",scrollSpeed->value()); |
195 | 195 | ||
196 | cfg.write(); | 196 | cfg.write(); |
197 | } | 197 | } |
198 | 198 | ||
199 | StocktickerPluginConfig::~StocktickerPluginConfig() { | 199 | StocktickerPluginConfig::~StocktickerPluginConfig() { |
200 | } | 200 | } |
201 | 201 | ||
202 | QString StocktickerPluginConfig::text() const { | 202 | QString StocktickerPluginConfig::text() const { |
203 | return LineEdit1->text(); | 203 | return LineEdit1->text(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void StocktickerPluginConfig::doLookup() { | 206 | void StocktickerPluginConfig::doLookup() { |
207 | 207 | ||
208 | system("stockticker"); | 208 | system("stockticker"); |
209 | } | 209 | } |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h index 2b67a8b..10f9678 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h | |||
@@ -1,46 +1,46 @@ | |||
1 | /* | 1 | /* |
2 | * stocktickerconfig.h | 2 | * stocktickerconfig.h |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by LJP | 4 | * copyright : (c) 2002 by LJP |
5 | * email : llornkcor@handhelds.org | 5 | * email : llornkcor@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #ifndef STOCKTICKER_PLUGIN_CONFIG_H | 17 | #ifndef STOCKTICKER_PLUGIN_CONFIG_H |
18 | #define STOCKTICKER_PLUGIN_CONFIG_H | 18 | #define STOCKTICKER_PLUGIN_CONFIG_H |
19 | 19 | ||
20 | #include <qwidget.h> | 20 | #include <qwidget.h> |
21 | #include <opie/todayconfigwidget.h> | 21 | #include <opie/todayconfigwidget.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | 23 | ||
24 | class QLineEdit; | 24 | class QLineEdit; |
25 | class QCheckBox; | 25 | class QCheckBox; |
26 | class QPushButton; | 26 | class QPushButton; |
27 | class QCheckBox; | 27 | class QCheckBox; |
28 | class QSpinBox; | 28 | class QSpinBox; |
29 | 29 | ||
30 | class StocktickerPluginConfig : public TodayConfigWidget { | 30 | class StocktickerPluginConfig : public TodayConfigWidget { |
31 | //Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | StocktickerPluginConfig( QWidget *parent, const char *name ); | 33 | StocktickerPluginConfig( QWidget *parent, const char *name ); |
34 | ~StocktickerPluginConfig(); | 34 | ~StocktickerPluginConfig(); |
35 | QString text() const; | 35 | QString text() const; |
36 | void writeConfig(); | 36 | void writeConfig(); |
37 | private: | 37 | private: |
38 | QLineEdit* LineEdit1; | 38 | QLineEdit* LineEdit1; |
39 | QCheckBox *timeCheck, *dateCheck, *symbolCheck, *nameCheck, *currentPriceCheck, *lastPriceCheck, *openPriceCheck, *minPriceCheck, *maxPriceCheck, *variationCheck, *volumeCheck; | 39 | QCheckBox *timeCheck, *dateCheck, *symbolCheck, *nameCheck, *currentPriceCheck, *lastPriceCheck, *openPriceCheck, *minPriceCheck, *maxPriceCheck, *variationCheck, *volumeCheck; |
40 | QPushButton *lookupButton; | 40 | QPushButton *lookupButton; |
41 | QSpinBox *timerDelaySpin, *scrollSpeed, *scrollLength; | 41 | QSpinBox *timerDelaySpin, *scrollSpeed, *scrollLength; |
42 | private slots: | 42 | private slots: |
43 | void doLookup(); | 43 | void doLookup(); |
44 | 44 | ||
45 | }; | 45 | }; |
46 | #endif | 46 | #endif |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp index c3ca52d..fedc79c 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | |||
@@ -1,301 +1,327 @@ | |||
1 | /* | 1 | /* |
2 | * stocktickerpluginwidget.cpp | 2 | * stocktickerpluginwidget.cpp |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by L.J. Potter | 4 | * copyright : (c) 2002 by L.J. Potter |
5 | * email : llornkcor@handhelds.org | 5 | * email : llornkcor@handhelds.org |
6 | * | 6 | * |
7 | */ | 7 | */ |
8 | /*************************************************************************** | 8 | /*************************************************************************** |
9 | * * | 9 | * * |
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * |
11 | * it under the terms of the GNU General Public License as published by * | 11 | * it under the terms of the GNU General Public License as published by * |
12 | * the Free Software Foundation; either version 2 of the License, or * | 12 | * the Free Software Foundation; either version 2 of the License, or * |
13 | * (at your option) any later version. * | 13 | * (at your option) any later version. * |
14 | * * | 14 | * * |
15 | ***************************************************************************/ | 15 | ***************************************************************************/ |
16 | 16 | ||
17 | #include <qlayout.h> | 17 | #include <qlayout.h> |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | 20 | ||
21 | #include <opie/oticker.h> | 21 | #include <opie/oticker.h> |
22 | 22 | ||
23 | extern "C" { | 23 | extern "C" { |
24 | #include "libstocks/stocks.h" | 24 | #include "libstocks/stocks.h" |
25 | } | 25 | } |
26 | 26 | ||
27 | #include <pthread.h> | 27 | #include <pthread.h> |
28 | 28 | ||
29 | #include "stocktickerpluginwidget.h" | 29 | #include "stocktickerpluginwidget.h" |
30 | 30 | ||
31 | QString output; | 31 | QString output; |
32 | OTicker *stocktickerTicker; | 32 | OTicker *stocktickerTicker; |
33 | QCString stock_liste; | ||
34 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | ||
35 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | ||
36 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | ||
33 | 37 | ||
34 | void getStocks(char *blah) { | 38 | void getStocks(char *blah) { |
35 | 39 | ||
36 | // stocktickerTicker->setText( "Downloading stock data."); | 40 | // stocktickerTicker->setText( "Downloading stock data."); |
37 | stock *stocks_quotes=NULL; | 41 | stock *stocks_quotes=NULL; |
38 | stock *stocks_tmp; | 42 | stock *stocks_tmp; |
39 | QCString stock_liste = blah; | 43 | stock_liste = blah; |
40 | ::free ( blah ); | 44 | ::free ( blah ); |
41 | // char *stock_liste = (char *)blah->latin1(); | 45 | // char *stock_liste = (char *)blah->latin1(); |
42 | qDebug("%s", stock_liste.data() ); | 46 | // qDebug("%s", stock_liste.data() ); |
43 | QString tempString; | 47 | output = ""; |
44 | output = ""; | 48 | QString tempString; |
45 | 49 | libstocks_return_code error; | |
46 | libstocks_return_code error; | 50 | |
47 | 51 | // Config cfg( "stockticker"); | |
48 | Config cfg( "stockticker"); | 52 | // cfg.setGroup( "Fields" ); |
49 | cfg.setGroup( "Fields" ); | 53 | // bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; |
50 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | 54 | // bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; |
51 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | 55 | // bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; |
52 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | 56 | |
53 | 57 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; | |
54 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; | 58 | |
55 | 59 | dotimeCheck=1; | |
56 | dotimeCheck=cfg.readBoolEntry("timeCheck",1); | 60 | dodateCheck=1; |
57 | dodateCheck=cfg.readBoolEntry("dateCheck",1); | 61 | dosymbolCheck=1; |
58 | dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); | 62 | donameCheck=1; |
59 | donameCheck=cfg.readBoolEntry("nameCheck",1); | 63 | docurrentPriceCheck=1; |
60 | docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); | 64 | dolastPriceCheck=1; |
61 | dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); | 65 | doopenPriceCheck=1; |
62 | doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); | 66 | dominPriceCheck=1; |
63 | dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); | 67 | domaxPriceCheck=1; |
64 | domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); | 68 | dovariationCheck=1; |
65 | dovariationCheck=cfg.readBoolEntry("variationCheck",1); | 69 | dovolumeCheck=1; |
66 | dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); | 70 | |
67 | 71 | // dotimeCheck=cfg.readBoolEntry("timeCheck",1); | |
68 | // DefProxy(); | 72 | // dodateCheck=cfg.readBoolEntry("dateCheck",1); |
69 | { | 73 | // dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); |
70 | char *proxy; | 74 | // donameCheck=cfg.readBoolEntry("nameCheck",1); |
71 | libstocks_return_code error; | 75 | // docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); |
72 | 76 | // dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); | |
73 | /* Proxy support */ | 77 | // doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); |
74 | /* Checks for "http_proxy" environment variable */ | 78 | // dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); |
75 | proxy = getenv("http_proxy"); | 79 | // domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); |
76 | if(proxy) { | 80 | // dovariationCheck=cfg.readBoolEntry("variationCheck",1); |
77 | /* printf("proxy set\n"); */ | 81 | // dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); |
78 | error = set_proxy(proxy); | 82 | |
79 | if (error) { | 83 | // DefProxy(); |
80 | printf("Proxy error (%d)\n", error); | 84 | // { |
81 | QString tempString; | 85 | char *proxy; |
82 | tempString.sprintf("Proxy error (%d)\n", error); | 86 | // libstocks_return_code error; |
83 | output = tempString; | 87 | |
84 | return; | 88 | /* Proxy support */ |
85 | // exit(1); | 89 | /* Checks for "http_proxy" environment variable */ |
86 | } | 90 | proxy = getenv("http_proxy"); |
87 | } | 91 | if(proxy) { |
88 | } | 92 | /* printf("proxy set\n"); */ |
89 | // char *stock_liste = (char *)blah; | 93 | error = set_proxy(proxy); |
90 | /* Get the stocks and process errors */ | 94 | if (error) { |
91 | error = get_stocks( stock_liste.data(), &stocks_quotes); | 95 | // printf("Proxy error (%d)\n", error); |
92 | 96 | // QString tempString2; | |
93 | if (error) { | 97 | // tempString2.sprintf("Proxy error (%d)\n", error); |
94 | printf("Error in getting stocks (%d)\n", error); | 98 | // output = tempString2; |
95 | tempString.sprintf("Error in getting stocks (%d)\n", error); | 99 | // delete tempString2; |
96 | output =tempString; | 100 | return; |
97 | return; | 101 | // exit(1); |
98 | // exit(1); | 102 | } |
99 | } | 103 | } |
100 | 104 | ::free(proxy); | |
101 | stocks_tmp = stocks_quotes; | 105 | // } |
102 | 106 | /* Get the stocks and process errors */ | |
103 | /* Displays the stocks */ | 107 | error = get_stocks( stock_liste.data(), &stocks_quotes); |
104 | while(stocks_tmp!=0){ | 108 | |
105 | 109 | if (error) { | |
106 | if (stocks_tmp->Time) { | 110 | printf("Error in getting stocks (%d)\n", error); |
107 | // printf("%s ", stocks_tmp->Time); | 111 | tempString.sprintf("Error in getting stocks (%d)\n", error); |
108 | tempString.sprintf("| %s ", stocks_tmp->Time); | 112 | output =tempString; |
109 | tempString.replace(QRegExp("\""),""); | 113 | return; |
110 | if( dotimeCheck) | 114 | } |
111 | output +=tempString; | 115 | |
112 | } | 116 | stocks_tmp = stocks_quotes; |
113 | if (stocks_tmp->Date) { | 117 | |
114 | // printf("%s ", stocks_tmp->Date); | 118 | /* Displays the stocks */ |
115 | tempString.sprintf("| %s ", stocks_tmp->Date); | 119 | while(stocks_tmp!=0){ |
116 | tempString.replace(QRegExp("\""),""); | 120 | |
117 | if(dodateCheck) | 121 | if (stocks_tmp->Time) { |
118 | output +=tempString; | 122 | // printf("%s ", stocks_tmp->Time); |
119 | } | 123 | tempString.sprintf("| %s ", stocks_tmp->Time); |
120 | // printf("\n"); | 124 | tempString.replace(QRegExp("\""),""); |
121 | 125 | if( dotimeCheck) | |
122 | // printf("----------------------------------------\n"); | 126 | output +=tempString; |
123 | 127 | } | |
124 | if ( strlen(stocks_tmp->Symbol) > 20 ) { | 128 | if (stocks_tmp->Date) { |
125 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); | 129 | // printf("%s ", stocks_tmp->Date); |
126 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 130 | tempString.sprintf("| %s ", stocks_tmp->Date); |
127 | if(dosymbolCheck) | 131 | tempString.replace(QRegExp("\""),""); |
128 | output +=tempString; | 132 | if(dodateCheck) |
129 | } | 133 | output +=tempString; |
130 | else { | 134 | } |
131 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); | 135 | // printf("\n"); |
132 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 136 | |
133 | if(dosymbolCheck) | 137 | // printf("----------------------------------------\n"); |
134 | output +=tempString; | 138 | |
135 | } | 139 | if ( strlen(stocks_tmp->Symbol) > 20 ) { |
136 | 140 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); | |
137 | if (stocks_tmp->Name) { | 141 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
138 | if ( strlen(stocks_tmp->Name) > 20 ) { | 142 | if(dosymbolCheck) |
139 | // printf("| Name %.20s |\n",stocks_tmp->Name); | 143 | output +=tempString; |
140 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 144 | } |
141 | tempString.stripWhiteSpace(); | 145 | else { |
142 | if(donameCheck) | 146 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); |
143 | output +=tempString; | 147 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
144 | } else { | 148 | if(dosymbolCheck) |
145 | // printf("| Name | %-20s |\n",stocks_tmp->Name); | 149 | output +=tempString; |
146 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 150 | } |
147 | tempString.stripWhiteSpace(); | 151 | |
148 | if(donameCheck) | 152 | if (stocks_tmp->Name) { |
149 | output +=tempString; | 153 | if ( strlen(stocks_tmp->Name) > 20 ) { |
150 | } | 154 | // printf("| Name %.20s |\n",stocks_tmp->Name); |
151 | } | 155 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
152 | else { | 156 | tempString.stripWhiteSpace(); |
153 | // printf("| Name | |\n"); | 157 | if(donameCheck) |
154 | tempString.sprintf("| Name | |"); | 158 | output +=tempString; |
155 | if(donameCheck) | 159 | } else { |
156 | output +=tempString; | 160 | // printf("| Name | %-20s |\n",stocks_tmp->Name); |
157 | } | 161 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
158 | 162 | tempString.stripWhiteSpace(); | |
159 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); | 163 | if(donameCheck) |
160 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); | 164 | output +=tempString; |
161 | if(docurrentPriceCheck) | 165 | } |
162 | output +=tempString; | 166 | } |
163 | 167 | else { | |
164 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); | 168 | // printf("| Name | |\n"); |
165 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); | 169 | tempString.sprintf("| Name | |"); |
166 | if(dolastPriceCheck) | 170 | if(donameCheck) |
167 | output +=tempString; | 171 | output +=tempString; |
168 | 172 | } | |
169 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); | 173 | |
170 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); | 174 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); |
171 | if(doopenPriceCheck) | 175 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); |
172 | output +=tempString; | 176 | if(docurrentPriceCheck) |
173 | 177 | output +=tempString; | |
174 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); | 178 | |
175 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); | 179 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); |
176 | if(dominPriceCheck) | 180 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); |
177 | output +=tempString; | 181 | if(dolastPriceCheck) |
178 | 182 | output +=tempString; | |
179 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); | 183 | |
180 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); | 184 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); |
181 | if(domaxPriceCheck) | 185 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); |
182 | output +=tempString; | 186 | if(doopenPriceCheck) |
183 | 187 | output +=tempString; | |
184 | // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); | 188 | |
185 | tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); | 189 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); |
186 | if(dovariationCheck) | 190 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); |
187 | output +=tempString; | 191 | if(dominPriceCheck) |
188 | 192 | output +=tempString; | |
189 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); | 193 | |
190 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); | 194 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); |
191 | if(dovolumeCheck) | 195 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); |
192 | output +=tempString; | 196 | if(domaxPriceCheck) |
193 | 197 | output +=tempString; | |
194 | // printf("----------------------------------------\n\n"); | 198 | |
195 | tempString.sprintf("||==++==|"); | 199 | // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); |
196 | output +=tempString; | 200 | tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); |
197 | 201 | if(dovariationCheck) | |
198 | /* Simple function which help to browse in the stocks list */ | 202 | output +=tempString; |
199 | stocks_tmp = next_stock(stocks_tmp); | 203 | |
200 | } | 204 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); |
201 | 205 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); | |
202 | /* frees stocks */ | 206 | if(dovolumeCheck) |
203 | free_stocks(stocks_quotes); | 207 | output +=tempString; |
204 | stocktickerTicker->setText( output.latin1() ); | 208 | |
205 | 209 | // printf("----------------------------------------\n\n"); | |
206 | } | 210 | tempString.sprintf("||==++==|"); |
207 | 211 | output +=tempString; | |
208 | StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) | 212 | |
209 | : QWidget(parent, name ) { | 213 | /* Simple function which help to browse in the stocks list */ |
210 | init(); | 214 | stocks_tmp = next_stock(stocks_tmp); |
211 | startTimer(1000); | 215 | } |
212 | 216 | ||
213 | stocktickerTicker->setTextFormat(Qt::RichText); | 217 | stocktickerTicker->setText( output.latin1() ); |
214 | // checkConnection(); | 218 | |
215 | } | 219 | /* frees stocks */ |
216 | 220 | free_stocks(stocks_quotes); | |
217 | StockTickerPluginWidget::~StockTickerPluginWidget() { | 221 | free_stocks(stocks_tmp); |
218 | } | 222 | |
219 | 223 | stock_liste=""; | |
220 | void StockTickerPluginWidget::init() { | 224 | //delete stock_liste; |
221 | 225 | tempString=""; | |
222 | QHBoxLayout* layout = new QHBoxLayout( this ); | 226 | output=""; |
223 | stocktickerTicker = new OTicker(this); | 227 | } |
224 | // stocktickerTicker->setMinimumHeight(15); | 228 | |
225 | connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); | 229 | StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) |
226 | layout->addWidget( stocktickerTicker); | 230 | : QWidget(parent, name ) { |
227 | wasError = true; | 231 | init(); |
228 | } | 232 | startTimer(1000); |
229 | 233 | ||
230 | void StockTickerPluginWidget::doStocks() { | 234 | stocktickerTicker->setTextFormat(Qt::RichText); |
231 | Config cfg( "stockticker"); | 235 | // checkConnection(); |
232 | cfg.setGroup( "Symbols" ); | 236 | } |
233 | symbollist=""; | 237 | |
234 | symbollist = cfg.readEntry("Symbols", ""); | 238 | StockTickerPluginWidget::~StockTickerPluginWidget() { |
235 | symbollist.replace(QRegExp(" "),"+");//seperated by + | 239 | } |
236 | 240 | ||
237 | cfg.setGroup("Timer"); | 241 | void StockTickerPluginWidget::init() { |
238 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); | 242 | |
239 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); | 243 | QHBoxLayout* layout = new QHBoxLayout( this ); |
240 | 244 | stocktickerTicker = new OTicker(this); | |
241 | if (!symbollist.isEmpty()) { | 245 | // stocktickerTicker->setMinimumHeight(15); |
242 | pthread_t thread1; | 246 | connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); |
243 | char *blah = ::strdup(symbollist.latin1()); | 247 | layout->addWidget( stocktickerTicker); |
244 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, (void *) blah); | 248 | wasError = true; |
245 | } | 249 | } |
246 | } | 250 | |
247 | 251 | void StockTickerPluginWidget::doStocks() { | |
248 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | 252 | Config cfg( "stockticker"); |
249 | killTimer(e->timerId()); | 253 | cfg.setGroup( "Symbols" ); |
250 | checkConnection(); | 254 | symbollist=""; |
251 | } | 255 | symbollist = cfg.readEntry("Symbols", ""); |
252 | 256 | symbollist.replace(QRegExp(" "),"+");//seperated by + | |
253 | void StockTickerPluginWidget::checkConnection() { | 257 | |
254 | // qDebug("checking connection"); | 258 | cfg.setGroup("Timer"); |
255 | // Sock = new QSocket( this ); | 259 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); |
256 | 260 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); | |
257 | // if( wasError) | 261 | |
258 | // stocktickerTicker->setText("Checking connection"); | 262 | if (!symbollist.isEmpty()) { |
259 | 263 | pthread_t thread1; | |
260 | // if(Sock->state() == QSocket::Idle) { | 264 | char *blah = ::strdup(symbollist.latin1()); |
261 | // Sock->connectToHost("finance.yahoo.com", 80); | 265 | pthread_create( &thread1, NULL, (void * (*)(void *))getStocks, (void *) blah); |
262 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); | 266 | pthread_detach( thread1); |
263 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | 267 | |
264 | // } else { | 268 | //::free((void*)thread1); |
265 | // qDebug("State is not Idle"); | 269 | //getStocks(blah); |
266 | isConnected(); | 270 | } |
267 | // } | 271 | } |
268 | } | 272 | |
269 | 273 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | |
270 | void StockTickerPluginWidget::isConnected() { | 274 | killTimer(e->timerId()); |
271 | // qDebug("We connect, so ok to grab stocks"); | 275 | checkConnection(); |
272 | doStocks(); | 276 | } |
273 | 277 | ||
274 | Config cfg( "stockticker"); | 278 | void StockTickerPluginWidget::checkConnection() { |
275 | cfg.setGroup("Timer"); | 279 | // qDebug("checking connection"); |
276 | timerDelay= cfg.readNumEntry("Delay",0); | 280 | // Sock = new QSocket( this ); |
277 | if(timerDelay > 0) | 281 | |
278 | startTimer(timerDelay*60000); | 282 | // if( wasError) |
279 | qDebug("timer set for %d",(timerDelay*60000)/60000); | 283 | // stocktickerTicker->setText("Checking connection"); |
280 | wasError = false; | 284 | |
281 | 285 | // if(Sock->state() == QSocket::Idle) { | |
282 | // Sock->close(); | 286 | // Sock->connectToHost("finance.yahoo.com", 80); |
283 | } | 287 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); |
284 | 288 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | |
285 | void StockTickerPluginWidget::socketError(int errcode) { | 289 | // } else { |
286 | switch(errcode) { | 290 | // qDebug("State is not Idle"); |
287 | case QSocket::ErrConnectionRefused: | 291 | isConnected(); |
288 | output = tr("Connection refused."); | 292 | // } |
289 | break; | 293 | } |
290 | case QSocket::ErrHostNotFound: | 294 | |
291 | output = tr("Could not find server."); | 295 | void StockTickerPluginWidget::isConnected() { |
292 | break; | 296 | // qDebug("We connect, so ok to grab stocks"); |
293 | case QSocket::ErrSocketRead : | 297 | if(this->isVisible()) |
294 | output = tr("Socket read error."); | 298 | doStocks(); |
295 | break; | 299 | |
296 | }; | 300 | Config cfg( "stockticker"); |
297 | stocktickerTicker->setText( output ); | 301 | cfg.setGroup("Timer"); |
298 | wasError = true; | 302 | timerDelay= cfg.readNumEntry("Delay",0); |
299 | // Sock->close(); | 303 | if(timerDelay > 0) |
300 | 304 | startTimer(timerDelay*60000); | |
301 | } | 305 | // qDebug("timer set for %d",(timerDelay*60000)/60000); |
306 | wasError = false; | ||
307 | |||
308 | // Sock->close(); | ||
309 | } | ||
310 | |||
311 | void StockTickerPluginWidget::socketError(int errcode) { | ||
312 | switch(errcode) { | ||
313 | case QSocket::ErrConnectionRefused: | ||
314 | output = tr("Connection refused."); | ||
315 | break; | ||
316 | case QSocket::ErrHostNotFound: | ||
317 | output = tr("Could not find server."); | ||
318 | break; | ||
319 | case QSocket::ErrSocketRead : | ||
320 | output = tr("Socket read error."); | ||
321 | break; | ||
322 | }; | ||
323 | stocktickerTicker->setText( output ); | ||
324 | wasError = true; | ||
325 | // Sock->close(); | ||
326 | |||
327 | } | ||
diff --git a/noncore/todayplugins/weather/weatherconfig.h b/noncore/todayplugins/weather/weatherconfig.h index 3877818..d9ffec2 100644 --- a/noncore/todayplugins/weather/weatherconfig.h +++ b/noncore/todayplugins/weather/weatherconfig.h | |||
@@ -1,59 +1,60 @@ | |||
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 Dan Williams <williamsdr@acm.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef WEATHER_PLUGIN_CONFIG_H | 29 | #ifndef WEATHER_PLUGIN_CONFIG_H |
30 | #define WEATHER_PLUGIN_CONFIG_H | 30 | #define WEATHER_PLUGIN_CONFIG_H |
31 | 31 | ||
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | 34 | ||
35 | #include <opie/todayconfigwidget.h> | 35 | #include <opie/todayconfigwidget.h> |
36 | 36 | ||
37 | class QCheckBox; | 37 | class QCheckBox; |
38 | class QLineEdit; | 38 | class QLineEdit; |
39 | class QPushButton; | 39 | class QPushButton; |
40 | class QSpinBox; | 40 | class QSpinBox; |
41 | 41 | ||
42 | class WeatherPluginConfig : public TodayConfigWidget | 42 | class WeatherPluginConfig : public TodayConfigWidget |
43 | { | 43 | { |
44 | Q_OBJECT | ||
44 | public: | 45 | public: |
45 | WeatherPluginConfig( QWidget *parent, const char *name ); | 46 | WeatherPluginConfig( QWidget *parent, const char *name ); |
46 | ~WeatherPluginConfig(); | 47 | ~WeatherPluginConfig(); |
47 | void writeConfig(); | 48 | void writeConfig(); |
48 | 49 | ||
49 | private: | 50 | private: |
50 | QLineEdit *locationEdit; | 51 | QLineEdit *locationEdit; |
51 | QCheckBox *metricCB; | 52 | QCheckBox *metricCB; |
52 | QSpinBox *timerDelaySB; | 53 | QSpinBox *timerDelaySB; |
53 | 54 | ||
54 | private slots: | 55 | private slots: |
55 | void doLookup(); | 56 | void doLookup(); |
56 | //void slotCopyLink(); | 57 | //void slotCopyLink(); |
57 | }; | 58 | }; |
58 | 59 | ||
59 | #endif | 60 | #endif |
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index 41c99a8..ecbf12f 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -340,212 +340,213 @@ void Clock::modeSelect( int m ) | |||
340 | } | 340 | } |
341 | else //clock mode | 341 | else //clock mode |
342 | { | 342 | { |
343 | lcd->setNumDigits( 5 ); | 343 | lcd->setNumDigits( 5 ); |
344 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 344 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
345 | set->setEnabled( FALSE ); | 345 | set->setEnabled( FALSE ); |
346 | reset->setEnabled( FALSE ); | 346 | reset->setEnabled( FALSE ); |
347 | t->start( 1000 ); | 347 | t->start( 1000 ); |
348 | } | 348 | } |
349 | 349 | ||
350 | Config config( "Clock" ); | 350 | Config config( "Clock" ); |
351 | config.setGroup( "Mode" ); | 351 | config.setGroup( "Mode" ); |
352 | config.writeEntry( "clockMode", m ); | 352 | config.writeEntry( "clockMode", m ); |
353 | updateClock(); | 353 | updateClock(); |
354 | } | 354 | } |
355 | 355 | ||
356 | //this sets the alarm time | 356 | //this sets the alarm time |
357 | void Clock::slotSetAlarm() | 357 | void Clock::slotSetAlarm() |
358 | { | 358 | { |
359 | if ( !snoozeBtn->isHidden() ) | 359 | if ( !snoozeBtn->isHidden() ) |
360 | slotToggleAlarm(); | 360 | slotToggleAlarm(); |
361 | Set_Alarm *setAlarmDlg; | 361 | Set_Alarm *setAlarmDlg; |
362 | setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); | 362 | setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); |
363 | int result = setAlarmDlg->exec(); | 363 | int result = setAlarmDlg->exec(); |
364 | if ( result == 1 ) { | 364 | if ( result == 1 ) { |
365 | Config config( "qpe" ); | 365 | Config config( "qpe" ); |
366 | config.setGroup( "Time" ); | 366 | config.setGroup( "Time" ); |
367 | QString tmp; | 367 | QString tmp; |
368 | hour = setAlarmDlg->Hour_Slider->value(); | 368 | hour = setAlarmDlg->Hour_Slider->value(); |
369 | minute = setAlarmDlg->Minute_Slider->value(); | 369 | minute = setAlarmDlg->Minute_Slider->value(); |
370 | snoozeTime = setAlarmDlg->SnoozeSlider->value(); | 370 | snoozeTime = setAlarmDlg->SnoozeSlider->value(); |
371 | if ( ampm ) { | 371 | if ( ampm ) { |
372 | if ( hour == 12 ) | 372 | if ( hour == 12 ) |
373 | hour = 0; | 373 | hour = 0; |
374 | 374 | ||
375 | if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) | 375 | if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) |
376 | hour += 12; | 376 | hour += 12; |
377 | } | 377 | } |
378 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); | 378 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); |
379 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); | 379 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); |
380 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); | 380 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); |
381 | config.write(); | 381 | config.write(); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | void Clock::slotSnooze() | 385 | void Clock::slotSnooze() |
386 | { | 386 | { |
387 | bSound = FALSE; | 387 | bSound = FALSE; |
388 | int warn = 0; | 388 | int warn = 0; |
389 | QTime t = QTime::currentTime(); | 389 | QTime t = QTime::currentTime(); |
390 | QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); | 390 | QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); |
391 | when = whenl; | 391 | when = whenl; |
392 | AlarmServer::addAlarm( when, | 392 | AlarmServer::addAlarm( when, |
393 | "QPE/Application/clock", | 393 | "QPE/Application/clock", |
394 | "alarm(QDateTime,int)", warn ); | 394 | "alarm(QDateTime,int)", warn ); |
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | //toggles alarm on/off | 398 | //toggles alarm on/off |
399 | void Clock::slotToggleAlarm() | 399 | void Clock::slotToggleAlarm() |
400 | { | 400 | { |
401 | Config config( "qpe" ); | 401 | Config config( "qpe" ); |
402 | config.setGroup( "Time" ); | 402 | config.setGroup( "Time" ); |
403 | if ( alarmBool ) | 403 | if ( alarmBool ) |
404 | { | 404 | { |
405 | config.writeEntry( "clockAlarmSet", "FALSE" ); | 405 | config.writeEntry( "clockAlarmSet", "FALSE" ); |
406 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 406 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
407 | snoozeBtn->hide(); | 407 | snoozeBtn->hide(); |
408 | alarmBool = FALSE; | 408 | alarmBool = FALSE; |
409 | alarmOff(); | 409 | alarmOff(); |
410 | } | 410 | } |
411 | else | 411 | else |
412 | { | 412 | { |
413 | config.writeEntry( "clockAlarmSet", "TRUE" ); | 413 | config.writeEntry( "clockAlarmSet", "TRUE" ); |
414 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 414 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); |
415 | snoozeBtn->show(); | 415 | snoozeBtn->show(); |
416 | alarmBool = TRUE; | 416 | alarmBool = TRUE; |
417 | alarmOn(); | 417 | alarmOn(); |
418 | } | 418 | } |
419 | config.write(); | 419 | config.write(); |
420 | } | 420 | } |
421 | 421 | ||
422 | void Clock::alarmOn() | 422 | void Clock::alarmOn() |
423 | { | 423 | { |
424 | QDate d = QDate::currentDate(); | 424 | QDate d = QDate::currentDate(); |
425 | QTime tm( ( int ) hour, ( int ) minute, 0 ); | 425 | QTime tm( ( int ) hour, ( int ) minute, 0 ); |
426 | qDebug( "Time set " + tm.toString() ); | 426 | qDebug( "Time set " + tm.toString() ); |
427 | QTime t = QTime::currentTime(); | 427 | QTime t = QTime::currentTime(); |
428 | if ( t > tm ) | 428 | if ( t > tm ) |
429 | d = d.addDays( 1 ); | 429 | d = d.addDays( 1 ); |
430 | int warn = 0; | 430 | int warn = 0; |
431 | QDateTime whenl( d, tm ); | 431 | QDateTime whenl( d, tm ); |
432 | when = whenl; | 432 | when = whenl; |
433 | AlarmServer::addAlarm( when, | 433 | AlarmServer::addAlarm( when, |
434 | "QPE/Application/clock", | 434 | "QPE/Application/clock", |
435 | "alarm(QDateTime,int)", warn ); | 435 | "alarm(QDateTime,int)", warn ); |
436 | setCaption( "Alarm set: " + whenl.toString() ); | 436 | // setCaption( "Alarm set: " + whenl.toString() ); |
437 | setCaption( tr("Alarm set: %1" ).arg(whenl.toString()) ); | ||
437 | } | 438 | } |
438 | 439 | ||
439 | void Clock::alarmOff() | 440 | void Clock::alarmOff() |
440 | { | 441 | { |
441 | int warn = 0; | 442 | int warn = 0; |
442 | bSound = FALSE; | 443 | bSound = FALSE; |
443 | AlarmServer::deleteAlarm( when, | 444 | AlarmServer::deleteAlarm( when, |
444 | "QPE/Application/clock", | 445 | "QPE/Application/clock", |
445 | "alarm(QDateTime,int)", warn ); | 446 | "alarm(QDateTime,int)", warn ); |
446 | qDebug( "Alarm Off " + when.toString() ); | 447 | qDebug( "Alarm Off " + when.toString() ); |
447 | setCaption( "Clock" ); | 448 | setCaption( tr("Clock") ); |
448 | } | 449 | } |
449 | 450 | ||
450 | void Clock::clearTimer() | 451 | void Clock::clearTimer() |
451 | { | 452 | { |
452 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 453 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
453 | alarmBool = FALSE; | 454 | alarmBool = FALSE; |
454 | snoozeBtn->hide(); | 455 | snoozeBtn->hide(); |
455 | setCaption( "Clock" ); | 456 | setCaption( tr("Clock") ); |
456 | } | 457 | } |
457 | 458 | ||
458 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | 459 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) |
459 | { | 460 | { |
460 | int stopTimer = 0; | 461 | int stopTimer = 0; |
461 | int timerStay = 5000; | 462 | int timerStay = 5000; |
462 | bSound = TRUE; | 463 | bSound = TRUE; |
463 | qDebug( "Message received in clock" ); | 464 | qDebug( "Message received in clock" ); |
464 | if ( msg == "alarm(QDateTime,int)" ) | 465 | if ( msg == "alarm(QDateTime,int)" ) |
465 | { | 466 | { |
466 | Config config( "qpe" ); | 467 | Config config( "qpe" ); |
467 | config.setGroup( "Time" ); | 468 | config.setGroup( "Time" ); |
468 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) | 469 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) |
469 | { | 470 | { |
470 | clearTimer(); | 471 | clearTimer(); |
471 | pthread_t thread; | 472 | pthread_t thread; |
472 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); | 473 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); |
473 | 474 | ||
474 | } | 475 | } |
475 | else | 476 | else |
476 | { | 477 | { |
477 | 478 | ||
478 | Sound::soundAlarm(); | 479 | Sound::soundAlarm(); |
479 | stopTimer = startTimer( timerStay ); | 480 | stopTimer = startTimer( timerStay ); |
480 | } | 481 | } |
481 | } | 482 | } |
482 | 483 | ||
483 | if ( msg == "timerStart()" ) | 484 | if ( msg == "timerStart()" ) |
484 | { | 485 | { |
485 | slotStartTimer(); | 486 | slotStartTimer(); |
486 | } | 487 | } |
487 | if ( msg == "timerStop()" ) | 488 | if ( msg == "timerStop()" ) |
488 | { | 489 | { |
489 | slotStopTimer(); | 490 | slotStopTimer(); |
490 | } | 491 | } |
491 | if ( msg == "timerReset()" ) | 492 | if ( msg == "timerReset()" ) |
492 | { | 493 | { |
493 | slotResetTimer(); | 494 | slotResetTimer(); |
494 | } | 495 | } |
495 | 496 | ||
496 | show(); | 497 | show(); |
497 | raise(); | 498 | raise(); |
498 | QPEApplication::setKeepRunning(); | 499 | QPEApplication::setKeepRunning(); |
499 | setActiveWindow(); | 500 | setActiveWindow(); |
500 | } | 501 | } |
501 | 502 | ||
502 | void Clock::timerEvent( QTimerEvent *e ) | 503 | void Clock::timerEvent( QTimerEvent *e ) |
503 | { | 504 | { |
504 | static int stop = 0; | 505 | static int stop = 0; |
505 | if ( stop < 120 && bSound ) | 506 | if ( stop < 120 && bSound ) |
506 | { | 507 | { |
507 | Sound::soundAlarm(); | 508 | Sound::soundAlarm(); |
508 | stop++; | 509 | stop++; |
509 | } | 510 | } |
510 | else | 511 | else |
511 | { | 512 | { |
512 | stop = 0; | 513 | stop = 0; |
513 | killTimer( e->timerId() ); | 514 | killTimer( e->timerId() ); |
514 | clearTimer(); | 515 | clearTimer(); |
515 | setCaption( tr( "Clock: Alarm was missed." ) ); | 516 | setCaption( tr( "Clock: Alarm was missed." ) ); |
516 | } | 517 | } |
517 | } | 518 | } |
518 | 519 | ||
519 | AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true) | 520 | AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true) |
520 | { | 521 | { |
521 | bg = Resource::loadPixmap("clock/bg"); | 522 | bg = Resource::loadPixmap("clock/bg"); |
522 | } | 523 | } |
523 | 524 | ||
524 | QSizePolicy AnalogClock::sizePolicy() const | 525 | QSizePolicy AnalogClock::sizePolicy() const |
525 | { | 526 | { |
526 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | 527 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
527 | } | 528 | } |
528 | 529 | ||
529 | void AnalogClock::drawContents( QPainter *p ) | 530 | void AnalogClock::drawContents( QPainter *p ) |
530 | { | 531 | { |
531 | QRect r = contentsRect(); | 532 | QRect r = contentsRect(); |
532 | QRect fr; | 533 | QRect fr; |
533 | 534 | ||
534 | p->drawPixmap(QPoint(0, 0), bg, r); | 535 | p->drawPixmap(QPoint(0, 0), bg, r); |
535 | 536 | ||
536 | if ( r. width ( ) > r. height ( )) | 537 | if ( r. width ( ) > r. height ( )) |
537 | fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); | 538 | fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); |
538 | else | 539 | else |
539 | fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); | 540 | fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); |
540 | 541 | ||
541 | QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); | 542 | QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); |
542 | QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); | 543 | QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); |
543 | QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); | 544 | QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); |
544 | 545 | ||
545 | 546 | ||
546 | 547 | ||
547 | if ( clear ) | 548 | if ( clear ) |
548 | { | 549 | { |
549 | erase ( r ); | 550 | erase ( r ); |
550 | p-> setPen ( NoPen ); | 551 | p-> setPen ( NoPen ); |
551 | p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); | 552 | p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); |
diff --git a/noncore/tools/euroconv/main.cpp b/noncore/tools/euroconv/main.cpp index 2d97f4e..7d69535 100644 --- a/noncore/tools/euroconv/main.cpp +++ b/noncore/tools/euroconv/main.cpp | |||
@@ -1,39 +1,39 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | * | 2 | * |
3 | * File: main.cpp | 3 | * File: main.cpp |
4 | * | 4 | * |
5 | * Description: main file for OPIE Euroconv aapp | 5 | * Description: main file for OPIE Euroconv aapp |
6 | * | 6 | * |
7 | * | 7 | * |
8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> | 8 | * Authors: Eric Santonacci <Eric.Santonacci@talc.fr> |
9 | * | 9 | * |
10 | * Requirements: Qt | 10 | * Requirements: Qt |
11 | * | 11 | * |
12 | * $Id$ | 12 | * $Id$ |
13 | * | 13 | * |
14 | ***************************************************************************/ | 14 | ***************************************************************************/ |
15 | 15 | ||
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <qvbox.h> | 17 | #include <qvbox.h> |
18 | //#include <qapplication.h> | 18 | //#include <qapplication.h> |
19 | 19 | ||
20 | #include "calcdisplay.h" | 20 | #include "calcdisplay.h" |
21 | #include "calckeypad.h" | 21 | #include "calckeypad.h" |
22 | 22 | ||
23 | 23 | ||
24 | 24 | ||
25 | int main( int argc, char **argv ) { | 25 | int main( int argc, char **argv ) { |
26 | 26 | ||
27 | QPEApplication app( argc, argv ); | 27 | QPEApplication app( argc, argv ); |
28 | 28 | ||
29 | QVBox *layout = new QVBox(0, "fond"); | 29 | QVBox *layout = new QVBox(0, "fond"); |
30 | 30 | ||
31 | LCDDisplay lcd (layout, "lcd"); | 31 | LCDDisplay lcd (layout, "lcd"); |
32 | KeyPad num(&lcd, layout, "keypad"); | 32 | KeyPad num(&lcd, layout, "keypad"); |
33 | app.setMainWidget(layout); | 33 | app.setMainWidget(layout); |
34 | layout->setCaption("Euroconv"); | 34 | layout->setCaption( QObject::tr("Euroconv") ); |
35 | layout->showMaximized (); | 35 | layout->showMaximized (); |
36 | layout->show(); | 36 | layout->show(); |
37 | return app.exec(); | 37 | return app.exec(); |
38 | } | 38 | } |
39 | 39 | ||
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp index 21de4d2..49f6355 100644 --- a/noncore/tools/formatter/formatter.cpp +++ b/noncore/tools/formatter/formatter.cpp | |||
@@ -307,193 +307,194 @@ void FormatterApp::doFormat() { | |||
307 | outDlg->OutputEdit->append(tr("You can now close the output window.")); | 307 | outDlg->OutputEdit->append(tr("You can now close the output window.")); |
308 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 308 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
309 | // outDlg->close(); | 309 | // outDlg->close(); |
310 | // if(outDlg) | 310 | // if(outDlg) |
311 | // delete outDlg; | 311 | // delete outDlg; |
312 | } | 312 | } |
313 | break; | 313 | break; |
314 | }; | 314 | }; |
315 | } | 315 | } |
316 | 316 | ||
317 | bool FormatterApp::doFdisk() { | 317 | bool FormatterApp::doFdisk() { |
318 | return FALSE; | 318 | return FALSE; |
319 | 319 | ||
320 | } | 320 | } |
321 | 321 | ||
322 | void FormatterApp::fillCombos() { | 322 | void FormatterApp::fillCombos() { |
323 | 323 | ||
324 | StorageInfo storageInfo; | 324 | StorageInfo storageInfo; |
325 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 325 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
326 | QListIterator<FileSystem> it ( fs ); | 326 | QListIterator<FileSystem> it ( fs ); |
327 | QString storage; | 327 | QString storage; |
328 | for( ; it.current(); ++it ){ | 328 | for( ; it.current(); ++it ){ |
329 | const QString name = (*it)->name(); | 329 | const QString name = (*it)->name(); |
330 | const QString path = (*it)->path(); | 330 | const QString path = (*it)->path(); |
331 | const QString disk = (*it)->disk(); | 331 | const QString disk = (*it)->disk(); |
332 | const QString options = (*it)->options(); | 332 | const QString options = (*it)->options(); |
333 | if( name.find( tr("Internal"),0,TRUE) == -1) { | 333 | if( name.find( tr("Internal"),0,TRUE) == -1) { |
334 | storageComboBox->insertItem(name +" -> "+disk); | 334 | storageComboBox->insertItem(name +" -> "+disk); |
335 | } | 335 | } |
336 | // deviceComboBox->insertItem(disk); | 336 | // deviceComboBox->insertItem(disk); |
337 | } | 337 | } |
338 | parsetab("/etc/mtab"); | 338 | parsetab("/etc/mtab"); |
339 | // parsetab("/etc/fstab"); | 339 | // parsetab("/etc/fstab"); |
340 | fileSystemsCombo->insertStringList( fsList,-1); | 340 | fileSystemsCombo->insertStringList( fsList,-1); |
341 | deviceComboBox->insertStringList( deviceList,-1); | 341 | deviceComboBox->insertStringList( deviceList,-1); |
342 | storageComboSelected(0); | 342 | storageComboSelected(0); |
343 | deviceComboSelected(0); | 343 | deviceComboSelected(0); |
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | void FormatterApp::fsComboSelected(int ) { | 347 | void FormatterApp::fsComboSelected(int ) { |
348 | 348 | ||
349 | } | 349 | } |
350 | 350 | ||
351 | void FormatterApp::storageComboSelected(int index ) { | 351 | void FormatterApp::storageComboSelected(int index ) { |
352 | 352 | ||
353 | QString currentText = storageComboBox->text(index); | 353 | QString currentText = storageComboBox->text(index); |
354 | QString nameS = currentText.left( currentText.find("->",0,TRUE)); | 354 | QString nameS = currentText.left( currentText.find("->",0,TRUE)); |
355 | 355 | ||
356 | TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) ); | 356 | TextLabel4->setText( tr( "Storage Type: %1").arg( nameS) ); |
357 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); | 357 | currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); |
358 | 358 | ||
359 | QString fsType = getFileSystemType((const QString &) currentText); | 359 | QString fsType = getFileSystemType((const QString &) currentText); |
360 | // qDebug(fsType); | 360 | // qDebug(fsType); |
361 | for(int i = 0; i < fileSystemsCombo->count(); i++) { | 361 | for(int i = 0; i < fileSystemsCombo->count(); i++) { |
362 | if( fsType == fileSystemsCombo->text(i)) | 362 | if( fsType == fileSystemsCombo->text(i)) |
363 | fileSystemsCombo->setCurrentItem(i); | 363 | fileSystemsCombo->setCurrentItem(i); |
364 | } | 364 | } |
365 | // deviceComboSelected(index); | 365 | // deviceComboSelected(index); |
366 | } | 366 | } |
367 | 367 | ||
368 | void FormatterApp::deviceComboSelected(int index) { | 368 | void FormatterApp::deviceComboSelected(int index) { |
369 | 369 | ||
370 | StorageInfo storageInfo; | 370 | StorageInfo storageInfo; |
371 | QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; | 371 | QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; |
372 | 372 | ||
373 | selectedText = deviceComboBox->text(index); | 373 | selectedText = deviceComboBox->text(index); |
374 | 374 | ||
375 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 375 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
376 | QListIterator<FileSystem> it ( fs ); | 376 | QListIterator<FileSystem> it ( fs ); |
377 | QString storage; | 377 | QString storage; |
378 | for( ; it.current(); ++it ){ | 378 | for( ; it.current(); ++it ){ |
379 | const QString name = (*it)->name(); | 379 | const QString name = (*it)->name(); |
380 | const QString path = (*it)->path(); | 380 | const QString path = (*it)->path(); |
381 | const QString disk = (*it)->disk(); | 381 | const QString disk = (*it)->disk(); |
382 | // const QString options = (*it)->options(); | 382 | // const QString options = (*it)->options(); |
383 | if( selectedText == disk) { | 383 | if( selectedText == disk) { |
384 | diskS = disk; nameS= name; | 384 | diskS = disk; nameS= name; |
385 | mountPointLineEdit->setText(path); | 385 | mountPointLineEdit->setText(path); |
386 | long mult = (*it)->blockSize() / 1024; | 386 | long mult = (*it)->blockSize() / 1024; |
387 | long div = 1024 / (*it)->blockSize(); | 387 | long div = 1024 / (*it)->blockSize(); |
388 | if ( !mult ) mult = 1; | 388 | if ( !mult ) mult = 1; |
389 | if ( !div ) div = 1; | 389 | if ( !div ) div = 1; |
390 | long total = (*it)->totalBlocks() * mult / div; | 390 | long total = (*it)->totalBlocks() * mult / div; |
391 | long totalMb = total/1024; | 391 | long totalMb = total/1024; |
392 | long avail = (*it)->availBlocks() * mult / div; | 392 | long avail = (*it)->availBlocks() * mult / div; |
393 | long availMb = avail/1024; | 393 | long availMb = avail/1024; |
394 | long used = total - avail; | 394 | long used = total - avail; |
395 | long usedMb = used/1024; | 395 | long usedMb = used/1024; |
396 | totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); | 396 | totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); |
397 | usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); | 397 | usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); |
398 | avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); | 398 | avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | fsType = getFileSystemType((const QString &)selectedText); | 401 | fsType = getFileSystemType((const QString &)selectedText); |
402 | 402 | ||
403 | TextLabel5->setText(tr("Type: %1\nFormatted with %1\n%1, %1, %1").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS )); | 403 | TextLabel5->setText(tr("Type: %1\nFormatted with %2\n%3, %4, %5").arg( nameS).arg( fsType).arg(totalS).arg( usedS).arg( avS )); |
404 | TextLabel5->setTextFormat( Qt::RichText ); | ||
404 | // storageComboSelected(0); | 405 | // storageComboSelected(0); |
405 | } | 406 | } |
406 | 407 | ||
407 | void FormatterApp::cleanUp() { | 408 | void FormatterApp::cleanUp() { |
408 | 409 | ||
409 | } | 410 | } |
410 | 411 | ||
411 | 412 | ||
412 | void FormatterApp::editFstab() { | 413 | void FormatterApp::editFstab() { |
413 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); | 414 | QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); |
414 | e << (const QString &)"/etc/fstab"; | 415 | e << (const QString &)"/etc/fstab"; |
415 | } | 416 | } |
416 | 417 | ||
417 | void FormatterApp::parsetab(const QString &fileName) { | 418 | void FormatterApp::parsetab(const QString &fileName) { |
418 | 419 | ||
419 | fileSystemTypeList.clear(); | 420 | fileSystemTypeList.clear(); |
420 | fsList.clear(); | 421 | fsList.clear(); |
421 | struct mntent *me; | 422 | struct mntent *me; |
422 | // if(fileName == "/etc/mtab") { | 423 | // if(fileName == "/etc/mtab") { |
423 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 424 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
424 | if ( mntfp ) { | 425 | if ( mntfp ) { |
425 | while ( (me = getmntent( mntfp )) != 0 ) { | 426 | while ( (me = getmntent( mntfp )) != 0 ) { |
426 | QString deviceName = me->mnt_fsname; | 427 | QString deviceName = me->mnt_fsname; |
427 | QString filesystemType = me->mnt_type; | 428 | QString filesystemType = me->mnt_type; |
428 | if(deviceName != "none") { | 429 | if(deviceName != "none") { |
429 | if( fsList.contains(filesystemType) == 0 | 430 | if( fsList.contains(filesystemType) == 0 |
430 | & filesystemType.find("proc",0,TRUE) == -1 | 431 | & filesystemType.find("proc",0,TRUE) == -1 |
431 | & filesystemType.find("cramfs",0,TRUE) == -1 | 432 | & filesystemType.find("cramfs",0,TRUE) == -1 |
432 | & filesystemType.find("auto",0,TRUE) == -1) | 433 | & filesystemType.find("auto",0,TRUE) == -1) |
433 | fsList << filesystemType; | 434 | fsList << filesystemType; |
434 | deviceList << deviceName; | 435 | deviceList << deviceName; |
435 | qDebug(deviceName+"::"+filesystemType); | 436 | qDebug(deviceName+"::"+filesystemType); |
436 | fileSystemTypeList << deviceName+"::"+filesystemType; | 437 | fileSystemTypeList << deviceName+"::"+filesystemType; |
437 | } | 438 | } |
438 | } | 439 | } |
439 | } | 440 | } |
440 | endmntent( mntfp ); | 441 | endmntent( mntfp ); |
441 | // } else if(fileName == "/etc/fstab") { | 442 | // } else if(fileName == "/etc/fstab") { |
442 | // QFile f("/etc/fstab"); | 443 | // QFile f("/etc/fstab"); |
443 | // if ( f.open(IO_ReadOnly) ) { | 444 | // if ( f.open(IO_ReadOnly) ) { |
444 | // QTextStream t (&f); | 445 | // QTextStream t (&f); |
445 | // QString s; | 446 | // QString s; |
446 | // while (! t.eof()) { | 447 | // while (! t.eof()) { |
447 | // s=t.readLine(); | 448 | // s=t.readLine(); |
448 | // s=s.simplifyWhiteSpace(); | 449 | // s=s.simplifyWhiteSpace(); |
449 | // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { | 450 | // if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { |
450 | // // = me->mnt_fsname; | 451 | // // = me->mnt_fsname; |
451 | // QString filesystemType = me->mnt_type; | 452 | // QString filesystemType = me->mnt_type; |
452 | // QString deviceName = s.left(0,s.find(BLANK) ); | 453 | // QString deviceName = s.left(0,s.find(BLANK) ); |
453 | // s=s.remove(0,s.find(BLANK)+1 ); // devicename | 454 | // s=s.remove(0,s.find(BLANK)+1 ); // devicename |
454 | 455 | ||
455 | // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint | 456 | // s=s.remove(0,s.find(BLANK)+1 ); // mountpoint |
456 | // QStringt mountPoint= s.left(0,s.find(BLANK) ); | 457 | // QStringt mountPoint= s.left(0,s.find(BLANK) ); |
457 | // s=s.remove(0,s.find(BLANK)+1 ); // fs | 458 | // s=s.remove(0,s.find(BLANK)+1 ); // fs |
458 | // QString filesystemType= s.left(0,s.find(BLANK) ); | 459 | // QString filesystemType= s.left(0,s.find(BLANK) ); |
459 | // } | 460 | // } |
460 | // } | 461 | // } |
461 | // } | 462 | // } |
462 | // f.close(); | 463 | // f.close(); |
463 | // } | 464 | // } |
464 | } | 465 | } |
465 | 466 | ||
466 | QString FormatterApp::getFileSystemType(const QString ¤tText) { | 467 | QString FormatterApp::getFileSystemType(const QString ¤tText) { |
467 | 468 | ||
468 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 469 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
469 | 470 | ||
470 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 471 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
471 | QString temp = (*it); | 472 | QString temp = (*it); |
472 | if( temp.find( currentText,0,TRUE) != -1) { | 473 | if( temp.find( currentText,0,TRUE) != -1) { |
473 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 474 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
474 | // qDebug(fsType); | 475 | // qDebug(fsType); |
475 | } | 476 | } |
476 | } | 477 | } |
477 | return ""; | 478 | return ""; |
478 | } | 479 | } |
479 | 480 | ||
480 | bool FormatterApp::doFsck() { | 481 | bool FormatterApp::doFsck() { |
481 | 482 | ||
482 | Output *outDlg; | 483 | Output *outDlg; |
483 | QString selectedDevice; | 484 | QString selectedDevice; |
484 | // #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) | 485 | // #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) |
485 | selectedDevice = deviceComboBox->currentText(); | 486 | selectedDevice = deviceComboBox->currentText(); |
486 | QString mountPoint = mountPointLineEdit->text(); | 487 | QString mountPoint = mountPointLineEdit->text(); |
487 | QString umountS = "umount -v "+mountPoint+" 2>&1"; | 488 | QString umountS = "umount -v "+mountPoint+" 2>&1"; |
488 | QString remountS = "mount -v "+mountPoint+" 2>&1"; | 489 | QString remountS = "mount -v "+mountPoint+" 2>&1"; |
489 | // #else | 490 | // #else |
490 | // // for testing | 491 | // // for testing |
491 | // // currentText = diskDevice = "/dev/fd0"; | 492 | // // currentText = diskDevice = "/dev/fd0"; |
492 | // QString umountS = "umount -v /floppy 2>&1"; | 493 | // QString umountS = "umount -v /floppy 2>&1"; |
493 | // QString remountS = "mount -v /floppy 2>&1"; | 494 | // QString remountS = "mount -v /floppy 2>&1"; |
494 | // selectedDevice ="/dev/fd0"; | 495 | // selectedDevice ="/dev/fd0"; |
495 | 496 | ||
496 | // #endif | 497 | // #endif |
497 | 498 | ||
498 | QString fsType = getFileSystemType((const QString &)selectedDevice); | 499 | QString fsType = getFileSystemType((const QString &)selectedDevice); |
499 | QString cmd; | 500 | QString cmd; |