summaryrefslogtreecommitdiffstats
path: root/knetworkconf/knetworkconf/knetworkconf.h
blob: af034b4cbbfbccf187d317adfddea641c28862ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/***************************************************************************
                          knetworkconf.h  -  description
                             -------------------
    begin                : Sun Jan 12 00:54:19 UTC 2003
    copyright            : (C) 2003 by Juan Luis Baptiste
    email                : jbaptiste@merlinux.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KNETWORKCONF_H
#define KNETWORKCONF_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define DEVICE_UP 0
#define DEVICE_DOWN 1

#include <unistd.h>
#include <sys/types.h>

#include <kapp.h>
#include <tqwidget.h>
#include <tqpixmap.h>
#include <tqprocess.h>
#include <tqptrlist.h>
#include <tqstringlist.h>
#include <tqstring.h>
#include <tqcheckbox.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqradiobutton.h>
#include <tqlayout.h>
#include <kdialog.h>
#include <kinputdialog.h>
#include <kpopupmenu.h>
#include <kpushbutton.h>
#include <klistview.h>
#include <klineedit.h>
#include <klistbox.h>
#include <kcombobox.h>
#include <kmessagebox.h>
#include <kaboutapplication.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kapplication.h>

#include <dcopclient.h>

#include "knetworkconfdlg.h"
#include "kadddnsserverdlg.h"
#include "kadddevicecontainer.h"
#include "kadddevicedlg.h"
#include "kadddevicewifiext.h"
#include "knetworkinfo.h"
#include "kroutinginfo.h"
#include "knetworkconfigparser.h"
#include "kdnsinfo.h"
#include "kaddknownhostdlg.h"
#include "kknownhostinfo.h"
#include "knetworkinterface.h"
#include "kadddevicedlgextension.h"
#include "knetworkconfiface.h"
#include "kprofileslistviewtooltip.h"

/** KNetworkConf is the base class of the project */
class KNetworkConf : public KNetworkConfDlg, virtual public KNetworkConfIface
{
  Q_OBJECT
  TQ_OBJECT
  public:
    /** construtor */
    KNetworkConf(TQWidget* tqparent=0, const char *name=0);
    /** destructor */
    ~KNetworkConf();
    /** Puts the application in read-only mode. This happens when the user runing the application isn't root. */
    void setReadOnly(bool state);    
    void setVersion(TQString ver);
    TQString getVersion();   
    /** Disables all buttons a line edit widgets when the user has read only access. */
    void disableAll();

    /**
      Fill the Listview with the info of the network interfaces.
    */
    void loadNetworkDevicesInfo();
    void loadRoutingInfo();
    void loadDNSInfo();
    void loadNetworkProfiles();

  private: // Private attributes
    /**  */
    KNetworkConfigParser *config;
    KNetworkInterface * getDeviceInfo(TQString device);
    TQString getDeviceName(TQString ipAddr);
  /** Creates a TQStringList with the IP addresses contained in the TQListBox of name servers. */
    TQStringList getNamserversList(KListBox * serverList);
/** Creates a TQPtrList<KKownHostInfo> with the info contained in the KListView of name servers. */    
    TQPtrList<KKnownHostInfo> getKnownHostsList(KListView * hostsList);    
    TQString currentDevice;
    KRoutingInfo *routingInfo;
    KDNSInfo *dnsInfo;
    bool reloaded;    
    TQString commandOutput;
    TQProcess *procUpdateDevice;
    TQProcess *procDeviceState;    
    TQStringList deviceNamesList;
    bool devicesModified;    
    bool readOnly;
    TQPtrList<KKnownHostInfo> knownHostsList;
    TQPtrList<KNetworkInfo> profilesList;
    bool nameServersModified;
    /** The program's version. */
    TQString version;
    bool modified;
    bool devStateChanged;
    /**  */
    KNetworkInfo * netInfo;
    /** Has the errors throwed by GST when executed. */
    TQString commandErrOutput;
    /** Changes the state of device 'dev' to DEVICE_UP or DEVICE_DOWN.
    Return true on success, false on failure.  */
    void changeDeviceState(const TQString &dev, int state);
    KNetworkInfo *getProfile(TQPtrList<KNetworkInfo> profilesList, TQString selectedProfile);
    void showSelectedProfile(TQString profile);
    KProfilesListViewToolTip *tooltip;
    
  public slots:
      virtual void saveInfoSlot();
/** Puts the application in read-only mode. This happens when the user runing the application isn't root. */
    void setReadOnlySlot(bool state);    
    
  private slots:
    /** Enables the configure and remove buttons. */
    virtual void enableButtonsSlot();
    /** opens the add server dialog. */
    virtual void addServerSlot();
    /** opens the edit server dialog. */
    virtual void editServerSlot();    
    /** Terminates the application*/
    virtual void quitSlot();
    virtual void readFromStdout();
    virtual void readFromStdoutUpDown();
    virtual void enableInterfaceSlot();
    virtual void disableInterfaceSlot();
   /** Pops up the window for adding a new interface. */
    virtual void configureDeviceSlot();    
    void enableApplyButtonSlot();  
    /** Shows the help browser. Hopefully some day it will be one :-). */
    virtual void helpSlot();
    virtual void enableApplyButtonSlot(bool);
    virtual void enableApplyButtonSlot(const TQString &text);
    /** Saves all the modified info of devices, routes,etc. */
    virtual void moveDownServerSlot();
    virtual void moveUpServerSlot();
    virtual void removeServerSlot();
    bool valuesChanged(KNetworkInterface *dev,
                        TQString bootProto,
                        TQString nettqmask,
                        TQString ipAddr,
                        TQString gateway,
                        bool onBoot,
                        TQString desc,
			TQString broadcast);
    /** Returns a list of strings of all the configured devices. */
    TQStringList getDeviceList();
    /** Sets the TQPushButton::autoResize() in true for all buttons. */
    void makeButtonsResizeable();

    /** Adds a new host to the KListView that has the known hosts. */
    void addKnownHostSlot();
    void aboutSlot();
    /** Edits the info about a known host. */
    void editKnownHostSlot();
    /** Removes a known host from the list view */
    void removeKnownHostSlot();
    /** No descriptions */
    void readFromStdErrUpDown();
    void getNetworkInfoSlot();
    /** Shows the main window after the network info has been loaded. */
    void showMainWindow();
    void verifyDeviceStateChanged();
    /** Sees if a device is active or not in the ifconfig output. Not very nice, but it works. Inthe future, this has to be managed by gst. */
    bool isDeviceActive(const TQString &device, const TQString &ifconfigOutput);
  
    /*Shows a context menu when right-clicking in the interface list*/
    void showInterfaceContextMenuSlot(KListView*, TQListViewItem*, const TQPoint&);
    
    /** Enable some signals in the GUI that need to be enabled *after* the loading of the network info is done.*/
    void enableSignals ();
    virtual void enableProfileSlot();    
    virtual void createProfileSlot();
    //virtual void updateProfileNameSlot(TQListViewItem *item);
    virtual void removeProfileSlot();
    virtual void updateProfileSlot();
    
  signals:
    //Signal used to tell kcontrol that the network configuration has been changed.
    void networkStateChanged(bool);

};

#endif