summaryrefslogtreecommitdiffstats
path: root/src/knemod/knemodaemon.h
blob: e0ac3d90463fcd21b320ce3633ed810136dda403 (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
/* This file is part of KNemo
   Copyright (C) 2004, 2006 Percy Leonhardt <[email protected]>

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

   KNemo 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 Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef KNEMODAEMON_H
#define KNEMODAEMON_H

#include <tqdict.h>
#include <tqcolor.h>
#include <tqcstring.h>
#include <tqdatetime.h>

#include <kdedmodule.h>
#include <knotifyclient.h>

#include "data.h"
#include "global.h"

class TQTimer;
class KInstance;
class Interface;
class BackendBase;
class KNotifyClient::Instance;

/**
 * This class is the main entry point of KNemo. It reads the configuration,
 * creates the logical interfaces and starts an interface updater. It also
 * takes care of configuration changes by the user.
 *
 * @short KNemos main entry point
 * @author Percy Leonhardt <[email protected]>
 */
class KNemoDaemon : public KDEDModule
{
    K_DCOP
    Q_OBJECT
//    TQ_OBJECT
public:
    /**
     * Default Constructor
     */
    KNemoDaemon( const TQCString& name );

    /**
     * Default Destructor
     */
    virtual ~KNemoDaemon();

    // tell the control center module which interface the user selected
    static TQString sSelectedInterface;

k_dcop:
    /*
     * Called from the control center module when the user changed
     * the settings. It updates the internal list of interfaces
     * that should be monitored.
     */
    virtual void reparseConfiguration();

    /* When the user selects 'Configure KNemo...' from the context
     * menus this functions gets called from the control center
     * module. This way the module knows for which interface the
     * user opened the dialog and can preselect the appropriate
     * interface in the list.
     */
    virtual TQString getSelectedInterface();

private:
    /*
     * Read the configuration on startup
     */
    void readConfig();

private slots:
    /**
     * trigger the backend to update the interface informations
     */
    void updateInterfaces();

private:
    TQColor mColorVLines;
    TQColor mColorHLines;
    TQColor mColorIncoming;
    TQColor mColorOutgoing;
    TQColor mColorBackground;

    // every time this timer expires we will
    // gather new informations from the backend
    TQTimer* mPollTimer;
    // our own instance
    KInstance* mInstance;
    // needed so that KNotifyClient::event will work
    KNotifyClient::Instance* mNotifyInstance;
    // application wide settings are stored here
    GeneralData mGeneralData;
    // settings for the traffic plotter are stored here
    PlotterSettings mPlotterSettings;
    // the name of backend we currently use
    TQString mBackendName;
    // the backend used to update the interface informations
    BackendBase* mBackend;
    // a list of all interfaces the user wants to monitor
    TQDict<Interface> mInterfaceDict;
};

#endif // KNEMODAEMON_H