~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

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 the GNU General Public
 
8
    License version 2 or at your option version 3 as published by
 
9
    the Free Software Foundation.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 
 
20
*/
 
21
 
 
22
#ifndef KSG_SENSORSOCKETAGENT_H
 
23
#define KSG_SENSORSOCKETAGENT_H
 
24
 
 
25
#include <QtNetwork/QTcpSocket>
 
26
 
 
27
#include "SensorAgent.h"
 
28
 
 
29
class QString;
 
30
 
 
31
namespace KSGRD {
 
32
 
 
33
 
 
34
/**
 
35
  The SensorSocketAgent connects to a ksysguardd via a TCP
 
36
  connection. It keeps a list of pending requests that have not been
 
37
  answered yet by ksysguard. The current implementation only allowes
 
38
  one pending requests. Incoming requests are queued in an input
 
39
  FIFO.
 
40
 */
 
41
class SensorSocketAgent : public SensorAgent
 
42
{
 
43
  Q_OBJECT
 
44
 
 
45
  public:
 
46
    explicit SensorSocketAgent( SensorManager *sm );
 
47
    ~SensorSocketAgent();
 
48
 
 
49
    bool start( const QString &host, const QString &shell,
 
50
                const QString &command = "", int port = -1 );
 
51
 
 
52
    void hostInfo( QString &shell, QString &command, int &port ) const;
 
53
 
 
54
  private Q_SLOTS:
 
55
    void connectionClosed();
 
56
    void msgSent();
 
57
    void msgRcvd();
 
58
    void error( QAbstractSocket::SocketError );
 
59
 
 
60
  private:
 
61
    bool writeMsg( const char *msg, int len );
 
62
 
 
63
    QTcpSocket mSocket;
 
64
    int mPort;
 
65
};
 
66
 
 
67
}
 
68
        
 
69
#endif