summaryrefslogtreecommitdiffstats
path: root/src/src/knetstats.h
blob: e5042daf134c20772395a901e82a6f69e4413e96 (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
/***************************************************************************
 *   Copyright (C) 2004 by Hugo Parente Lima                               *
 *   hugo_pl@users.sourceforge.net                                         *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/

#ifndef KNETSTATS_H
#define KNETSTATS_H

#include <tqwidget.h>
#include <set>
#include <tqstring.h>
#include "configure.h"

class KNetStatsView;
class TDEConfig;
class TDEPopupMenu;
class TDEActionCollection;

class Interface;


class KNetStats : public TQWidget
{
	Q_OBJECT
  

	enum {
		IF_DETECTION_INTERVAL = 5000
	};

public:
	/// Constructor
	KNetStats();
	~KNetStats();

	TDEPopupMenu* const contextMenu() const { return mContextMenu; }
	/**
	*	\brief Search for network interfaces parsing /proc/net/dev
	*	\return A StringList with the network interface names
	*/
	static TQStringList scanInterfaces();
	int numInterfaces() const { return mInterfaces.size(); }


public slots:
	/// Display configure the dialog box
	bool configure();
	/// Configure dialog OK button
	void configOk();
	/// Configure dialog Apply button
	void configApply();
	/// Configure dialog Cancel button
	void configCancel();

	/// Diaplay the about box
	void about();
	/**
	*	Search for new interfaces
	*	\param count_ptr	Interface count, store the number of new <strong>visible</strong> interfaces found.
	*/
	void detectNewInterfaces(int* count_ptr = 0);
private:
	TDEPopupMenu* mContextMenu; // help menu usado por todos os tray icons
	Configure* mConfigure;
	TDEActionCollection* mActionCollection;
	bool mBoot;
	InterfaceMap mInterfaces;


	void readOptions();
	void saveConfig(const OptionsMap& options);
	void clearOptions(OptionsMap* options);
	void setupUi();
	// Creates a new interface, returns true or false if the new interface is visible or not.
	bool createInterface(const TQString& interface);

};

#endif