kinternet: replace Qt3-compatibility-classes with Qt4-classes
[opensuse:qinternet.git] / src / kinternet.h
1 // -*- c++ -*-
2 /***************************************************************************
3  *                                                                         *
4  *   Copyright: SuSE Linux AG, Nuernberg                                   *
5  *                                                                         *
6  *   Authors: Arvin Schnell <arvin@suse.de>                                *
7  *            Adrian Schroeter <adrian@suse.de>                            *
8  *            Thomas Strehl <tstrehl@suse.de>                              *
9  *            Stefan Rauch <srauch@suse.de>                                *
10  *                                                                         *
11  ***************************************************************************/
12
13 /***************************************************************************
14  *                                                                         *
15  *   This program is free software; you can redistribute it and/or modify  *
16  *   it under the terms of the GNU General Public License as published by  *
17  *   the Free Software Foundation; either version 2 of the License, or     *
18  *   (at your option) any later version.                                   *
19  *                                                                         *
20  ***************************************************************************/
21
22
23 #ifndef KINTERNET_H
24 #define KINTERNET_H
25
26
27 #include <qwidget.h>
28 #include <qtimer.h>
29 #include <QMenu>
30 //Added by qt3to4:
31 #include <QPaintEvent>
32 #include <QPixmap>
33 #include <QMouseEvent>
34 #include <QSystemTrayIcon>
35
36 #ifndef NOKDE
37 #include <kpopupmenu.h>
38 #include <kconfig.h>
39 #include <kprocess.h>
40 #else
41 class ProviderIface { };
42 #endif
43
44 #include "check.h"
45 #include "logview.h"
46 #include "datarateview.h"
47 #include "configview.h"
48 #include "settings.h"
49 #include "server.h"
50 #include "lists.h"
51 #include "password.h"
52 #include "dialprefix.h"
53 #include "wirelessdialog.h"
54
55 class KInternetIface;
56 class MyWallet;
57 #ifndef NOKDE
58 class NetworkStatusIface_stub;
59 #endif
60
61
62 class KInternet : public QWidget
63 {
64     Q_OBJECT
65
66 public:
67
68     enum disp_mode_t {
69         PLAIN,
70         KICKER,
71         SWALLOWED
72     };
73
74     /***** constructor and destructor *****/
75
76     KInternet (bool quiet, disp_mode_t disp_mode, QWidget* parent = 0,
77                const char* name = 0);
78     ~KInternet ();
79
80     /***** status informations of smpppd *****/
81
82     enum status_t { ERROR, DISCONNECTED, LURKING, CONNECTING, CONNECTED,
83                     DISCONNECTING, NOLINK };
84
85     status_t get_status () const { return m_status; }
86
87 #ifndef NOKDE
88     void setDesktopNetworkStatus();
89     void initNetworkStatus();
90 #endif
91
92 private:
93
94     bool quiet;
95     disp_mode_t disp_mode;
96
97     bool demand;
98     bool ask_password;
99     QString dial_prefix;
100     QString dial_prefix_regex;
101
102     status_t m_status;
103     int num_links;
104     int action_flags;
105     bool is_wireless;
106     
107     bool wirelessdlg_displayed;
108
109     /***** menu stuff *****/
110
111     void make_menu ();
112     void make_submenu_interfaces ();
113     void make_submenu_providers ();
114     void set_menu ();
115 #ifndef NOKDE
116     NetworkStatusIface_stub *myservice;
117 #endif
118
119 private slots:
120
121     void slot_start ();
122     void slot_start2 (bool);
123     void slot_dialin ();
124     void slot_hangup ();
125     void slot_stop ();
126
127     void slot_add ();
128     void slot_remove ();
129
130     void slot_interface (int);
131     void slot_provider (int);
132     void slot_prefix ();
133     void slot_prefix2 (bool);
134     void slot_reconnect ();
135     void slot_quit ();
136     void slot_abouttoquit ();
137     
138     void slot_observe_wdialog();
139
140 private:
141
142 #ifndef NOKDE
143     KPopupMenu* menu;
144 #else
145     QMenu* menu;
146 #endif
147
148     QMenu* menu_conf;
149     QMenu* menu_inter;
150     QMenu* menu_prov;
151
152     int id_check, id_log, id_datarate, id_config, id_reconnect;
153     int id_start, id_dialin, id_hangup, id_stop, id_add, id_remove;
154     int id_menu_prov, id_menu_inter, id_yast2, id_prefix;
155     int id_wireless;
156
157     /***** icons *****/
158
159     QPixmap* main_icon;
160 #ifndef NOKDE
161     QPixmap* mini_icon;
162 #endif
163     QPixmap* error_icon;
164     QPixmap* buildup_icon;
165     QPixmap* connected_icon;
166     QPixmap* connecting_icon;
167     QPixmap* lurking_icon;
168     QPixmap* nolink_icon;
169     QPixmap* disconnected_icon;
170     QPixmap* disconnecting_icon;
171     QPixmap* unknown_icon;
172     QPixmap* transfer_icon[5];
173     QPixmap* demand_icon;
174     QPixmap* multilink_icon;
175
176     /***** dialog stuff *****/
177
178     CheckDlg* checkdlg;
179     LogviewDlg* logviewdlg;
180     DatarateviewDlg* datarateviewdlg;
181     ConfigviewDlg* configviewdlg;
182     SettingsDlg* settingsdlg;
183
184     WirelessDialog* wdialog;
185
186     QSystemTrayIcon* trayicon;
187
188 private slots:
189
190     void show_check ();
191     void hide_check ();
192
193     void show_logview ();
194     void hide_logview ();
195
196     void show_datarateview ();
197     void hide_datarateview ();
198
199     void show_configview ();
200     void hide_configview ();
201
202     void show_settings ();
203     void hide_settings ();
204     void updated_settings ();
205     
206     void show_wireless_dialog();
207
208     void slot_servererror(QString);
209
210     /***** transfer stuff *****/
211
212 private:
213
214     bool transfer_on;
215     bool activeDefaultRoute;
216     Data::bytes_t rx_bytes, tx_bytes;
217     int transfer_icon_nr;
218     QTimer* transfer_timer;
219
220 private slots:
221
222     void transfer_draw_icon ();
223
224     /***** connection to server *****/
225
226 public:
227
228     const Server* get_server () const { return server; }
229
230 private:
231
232     AutoServer* autoserver;
233     Server* server;
234
235 private slots:
236
237     void new_autoserver_status (AutoServer::status_t);
238     void new_server_status (Server::status_t);
239
240     void new_data (Server::msg_t);
241     void new_data_new (Server::msg_t);
242     void new_data_old (Server::msg_t);
243
244     void tray_activated ( QSystemTrayIcon::ActivationReason );
245
246     /***** YaST2 stuff *****/
247
248 private slots:
249
250     void slot_start_yast2 ();
251
252     /***** scripts stuff *****/
253
254 private:
255
256     bool i_started_connection;
257     void start_script (bool);
258
259     /***** wallet *****/
260
261     MyWallet* mywallet;
262     PasswordWfl* passwordwfl;
263
264     /***** misc *****/
265
266     DialPrefixWfl* dialprefixwfl;
267
268     void handleClick(Qt::MouseButton button, const QPoint& pos);
269
270     void mousePressEvent (QMouseEvent*);        // overridden
271     void paintEvent (QPaintEvent*);             // overridden
272
273     QPixmap* current_icon;
274     QColor current_color;
275     bool show_addons;
276
277     void select_icon();
278     void update_icon();
279
280     bool set_interface;
281
282     KInternetIface* dcop_iface;
283
284     /* some long messages */
285     QString msg1;
286
287 };
288
289
290 #endif