~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to ksysguard/gui/ksgrd/SensorManager.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-27 12:09:48 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20080527120948-dottsyd5rcwhzd36
Tags: 4:4.0.80-1ubuntu1
* Merge with Debian
 - remove 97_fix_target_link_libraries.diff
 - Add replaces/conflicts on -kde4 packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    KSysGuard, the KDE System Guard
3
 
   
4
 
    Copyright (c) 1999, 2000 Chris Schlaeger <cs@kde.org>
5
 
    
6
 
    This program is free software; you can redistribute it and/or
7
 
    modify it under the terms of version 2 of the GNU General Public
8
 
    License as published by the Free Software Foundation.
9
 
 
10
 
    This program is distributed in the hope that it will be useful,
11
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
    GNU General Public License for more details.
14
 
 
15
 
    You should have received a copy of the GNU General Public License
16
 
    along with this program; if not, write to the Free Software
17
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18
 
 
19
 
*/
20
 
 
21
 
#ifndef KSG_SENSORMANAGER_H
22
 
#define KSG_SENSORMANAGER_H
23
 
 
24
 
#include <kconfig.h>
25
 
 
26
 
#include <qdict.h>
27
 
#include <qobject.h>
28
 
 
29
 
#include <SensorAgent.h>
30
 
 
31
 
class HostConnector;
32
 
 
33
 
namespace KSGRD {
34
 
 
35
 
class SensorManagerIterator;
36
 
 
37
 
/**
38
 
  The SensorManager handles all interaction with the connected
39
 
  hosts. Connections to a specific hosts are handled by
40
 
  SensorAgents. Use engage() to establish a connection and
41
 
  disengage() to terminate the connection. If you don't know if a
42
 
  certain host is already connected use engageHost(). If there is no
43
 
  connection yet or the hostname is empty, a dialog will be shown to
44
 
  enter the connections details.
45
 
 */
46
 
class KDE_EXPORT SensorManager : public QObject
47
 
{
48
 
  Q_OBJECT
49
 
 
50
 
  friend class SensorManagerIterator;
51
 
 
52
 
  public:
53
 
    SensorManager();
54
 
    ~SensorManager();
55
 
 
56
 
    bool engageHost( const QString &hostName );
57
 
    bool engage( const QString &hostName, const QString &shell = "ssh",
58
 
                 const QString &command = "", int port = -1 );
59
 
 
60
 
    void requestDisengage( const SensorAgent *agent );
61
 
    bool disengage( const SensorAgent *agent );
62
 
    bool disengage( const QString &hostName );
63
 
    bool resynchronize( const QString &hostName );
64
 
    void hostLost( const SensorAgent *agent );
65
 
    void notify( const QString &msg ) const;
66
 
 
67
 
    void setBroadcaster( QWidget *wdg );
68
 
 
69
 
    virtual bool event( QEvent *event );
70
 
 
71
 
    bool sendRequest( const QString &hostName, const QString &request,
72
 
                      SensorClient *client, int id = 0 );
73
 
 
74
 
    const QString hostName( const SensorAgent *sensor ) const;
75
 
    bool hostInfo( const QString &host, QString &shell,
76
 
                   QString &command, int &port );
77
 
 
78
 
    const QString& translateUnit( const QString &unit ) const;
79
 
    const QString& translateSensorPath( const QString &path ) const;
80
 
    const QString& translateSensorType( const QString &type ) const;
81
 
    QString translateSensor(const QString& u) const;
82
 
 
83
 
    void readProperties( KConfig *cfg );
84
 
    void saveProperties( KConfig *cfg );
85
 
 
86
 
    void disconnectClient( SensorClient *client );
87
 
        
88
 
  public slots:
89
 
    void reconfigure( const SensorAgent *agent );
90
 
 
91
 
  signals:
92
 
    void update();
93
 
    void hostConnectionLost( const QString &hostName );
94
 
 
95
 
  protected:
96
 
    QDict<SensorAgent> mAgents;
97
 
 
98
 
  private:
99
 
    /**
100
 
      These dictionary stores the localized versions of the sensor
101
 
      descriptions and units.
102
 
     */
103
 
    QDict<QString> mDescriptions;
104
 
    QDict<QString> mUnits;
105
 
    QDict<QString> mDict;
106
 
    QDict<QString> mTypes;
107
 
 
108
 
    QWidget* mBroadcaster;
109
 
 
110
 
    HostConnector* mHostConnector;
111
 
};
112
 
 
113
 
KDE_EXPORT extern SensorManager* SensorMgr;
114
 
 
115
 
class KDE_EXPORT SensorManagerIterator : public QDictIterator<SensorAgent>
116
 
{
117
 
  public:
118
 
    SensorManagerIterator( const SensorManager *sm )
119
 
      : QDictIterator<SensorAgent>( sm->mAgents ) { }
120
 
 
121
 
    ~SensorManagerIterator() { }
122
 
};
123
 
 
124
 
}
125
 
 
126
 
#endif