Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OTPeer.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 /***************************************************************************
00003  *   Copyright (C) 2003 by Fred Schaettgen                                 *
00004  *   kdebluetooth@0xF.de                                                   *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  ***************************************************************************/
00011 
00012 #ifndef OTPEER_H
00013 #define OTPEER_H
00014 
00015 #include <qstring.h>
00016 #include <qobject.h>
00017 #include <qvector.h>
00018 #include <bluezlib.h>
00019 #include <OTDeviceAddress.h>
00020 
00021 class QTextStream;
00022 class QTimerEvent;
00023 
00024 namespace Opietooth2 {
00025 
00026 class OTGateway;
00027 
00028 class OTDriver;
00029 class OTSDPService;
00030 class OTSDPAttribute;
00031 class OTUUID;
00032 typedef QVector<OTSDPService> ServiceVector;
00033 
00034 class OTPeer : public QObject {
00035 
00036       Q_OBJECT;
00037 
00038 public :
00039 
00040       typedef enum PeerState_E {
00041         Peer_Unknown = -1,
00042         Peer_Down = 0,
00043         Peer_Up = 1
00044       } PeerState_t;
00045 
00046       OTPeer( OTGateway * _OT );
00047       OTPeer( QTextStream & TS, OTGateway * _TS );
00048       ~OTPeer();
00049 
00050       inline OTGateway * gateway() const
00051         { return OT; }
00052 
00053       inline int deviceClass( void ) const 
00054         { return Class; }
00055       inline void setDeviceClass( int cls )
00056         { Class = cls; }
00057 
00058       void setAddress( const OTDeviceAddress & A ) 
00059         { Addr = A; }
00060 
00061       const OTDeviceAddress & address( void )
00062         { return Addr; }
00063 
00064       inline QString name( void ) const 
00065         { return Name; }
00066       inline void setName( const QString & n )
00067         { Name = n; }
00068 
00069       ServiceVector & services( bool Force = 0 )
00070         { if( Force || serviceList.count() == 0 ) {
00071             updateServices();
00072           }
00073           return serviceList;
00074         }
00075 
00076       /* Returns TRUE if the device has at least a service 
00077          with inside the required class Id.*/
00078       bool hasServiceClassID( const OTUUID & uuid);
00079 
00080       /* Get a vector of Rfcomm channels of the services 
00081          having "uuid" in the class ID List */
00082       QArray<int> rfcommList( const OTUUID & uuid );
00083 
00084       inline void setState( PeerState_t S) 
00085         { State = S; }
00086       inline PeerState_t state( void )
00087         { return State; }
00088 
00089       // go and find out state
00090       // will report back with signal
00091       void findOutState( int timeoutInSec = 1, bool Force = 0 );
00092       void stopFindingOutState( void );
00093 
00094       // return driver to which this peer is connected to
00095       // if it is connected
00096       inline OTDriver * connectedTo( void ) const
00097         { return ConnectedTo; }
00098       inline void setConnectedTo( OTDriver * D ) 
00099         { ConnectedTo = D; }
00100 
00101       void save( QTextStream& TS ); 
00102       void load( QTextStream& TS ); 
00103 
00104 signals :
00105 
00106       // report back state
00107       void peerStateReport( OTPeer *);
00108       void error( const QString & );
00109 
00110 protected :
00111 
00112       // while polling for result of ping
00113       void timerEvent( QTimerEvent * ev );
00114 
00115 private:
00116 
00117       void updateServices();
00118 
00119       OTGateway * OT;
00120       OTDeviceAddress Addr;
00121       QString Name;
00122       int Class;
00123       ServiceVector serviceList;
00124       // -1 : don't know, 0 no, 1 yes
00125       PeerState_t State;
00126       OTDriver * ConnectedTo;
00127 
00128       int ProbeFD;
00129       int ProbePhase; // see OTDriver
00130       long ProbeTimeout;
00131 };
00132 
00133 }
00134 
00135 #endif

Generated on Sat Nov 5 16:17:55 2005 for OPIE by  doxygen 1.4.2