00001 //-*-c++-*- 00002 /*************************************************************************** 00003 * Copyright (C) 2003 by Fred Schaettgen * 00004 * kdebluetooth@schaettgen.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 OTINQUIRY_H 00013 #define OTINQUIRY_H 00014 00015 #include <qstring.h> 00016 #include <qobject.h> 00017 00018 #include <qguardedptr.h> 00019 #include <qtimer.h> 00020 00021 #include <OTPeer.h> 00022 00023 // #include <set> 00024 // #include <deque> 00025 00026 namespace Opietooth2 { 00027 00028 class QSocket; 00029 class QDateTime; 00030 00031 class OTDriver; 00032 class OTHCISocket; 00033 00045 class OTInquiry : public QObject { 00046 00047 Q_OBJECT 00048 00049 public: 00050 00054 OTInquiry( OTDriver* Drv ); 00055 00057 virtual ~OTInquiry(); 00058 00059 // General/Unlimited Inquiry Access Code 00060 static const int GIAC = 0x9E8B33; 00061 00062 // Limited Dedicated Inquiry Access Code 00063 static const int LIAC = 0x9E8B00; 00064 00073 bool inquire( double timeout = 8.0, 00074 int numResponses = 0, 00075 int lap = GIAC); 00076 00077 void stopInquiring( ); 00078 00093 /* 00094 void inquirePeriodically( double minduration, 00095 double maxduration, 00096 double timeout = 8.0, 00097 int numResponses = 0, 00098 int lap = LIAC 00099 ); 00100 */ 00107 bool isInquiring(); 00108 00114 bool isFinished(); 00115 00119 void reset(); 00120 00121 inline OTDriver * driver() const 00122 { return Driver; } 00123 00124 protected: 00125 00130 virtual void onPeerFound( OTPeer * Peer, bool ); 00131 00132 enum ErrorCode { 00133 InquiryFinishedTimeout = 0x0100 00134 }; 00135 00136 signals : 00137 00138 void peerFound( OTPeer *, bool ); 00139 00145 void finished(); 00146 00152 void error( QString message ); 00153 00154 private: 00155 00156 // std::set<DeviceAddress> addrCache; 00157 // double currentTimeout; 00158 // QByteArray* buf; 00159 // QSocket* hciSocket; 00160 QGuardedPtr<OTHCISocket> Socket; 00161 OTDriver * Driver; 00162 00163 //QDateTime *startTime; 00164 QTimer *InquiryTimeoutTimer; 00165 00166 // std::deque<InquiryInfo> infoQueue; 00167 bool SuccessfullyStarted; 00168 bool SuccessfullyEnded; 00169 00170 private slots: 00171 00172 void slotInquiryTimeout(); 00173 void slotHCIEvent(unsigned char eventCode, QByteArray buf); 00174 00175 }; 00176 00177 } 00178 #endif
1.4.2