Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

btdiscoverer.h

Go to the documentation of this file.
00001 /*
00002  * btdiscoverer.h,v 1.6 2003/11/09 13:38:21 mattid Exp
00003  *
00004  * COBAIN - Communications API for EPOC Environments
00005  * Copyright (C) 2002-2003 Matti Dahlbom, Matti Kokkola
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * Contact: Matti Dahlbom <matti@777-team.org>
00022  *          Matti Kokkola <matti.kokkola@iki.fi>
00023  */
00024 
00025 #ifndef __BTDISCOVERER_H
00026 #define __BTDISCOVERER_H
00027 
00028 #include "clientservercommon.h"
00029 
00030 class CServerSession;
00031 
00032 // panic category and errors
00033 _LIT(KBTDiscovererPanic, "CBTDiscoverer");
00034 
00035 const TInt KErrBtdiscovererBase = -10500;
00036 const TInt KErrBtdiscovererAllocFailed = KErrBtdiscovererBase - 1;
00037 
00038 // bluetooth device address list type for device discovery
00039 typedef RPointerArray<TNameRecord> RDeviceAddressList;
00040 
00041 // for discovering blueooth devices and services
00042 class CBTDiscoverer : public CActive, 
00043                       public MSdpAgentNotifier,
00044                       public MSdpAttributeValueVisitor
00045 {
00046     public:
00047         static CBTDiscoverer * NewL(RMessage &aMessage, CServerSession &aSession);
00048         ~CBTDiscoverer();
00049 
00050         void StartL(RSocketServ &aSocketServ);
00051 
00052         // from CActive
00053         void RunL();
00054         TInt RunError(TInt aError); 
00055         void DoCancel();
00056 
00057         // from MSdpNotifier
00058         void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
00059         void AttributeRequestResult(TSdpServRecordHandle aHandle, 
00060                                     TSdpAttributeID aAttrID, 
00061                                     CSdpAttrValue* aAttrValue);
00062         void NextRecordRequestComplete(TInt aError, 
00063                                        TSdpServRecordHandle aHandle, 
00064                                        TInt aTotalRecordsCount);
00065 
00066         // from MSdpAttributeValueVisitor
00067         void VisitAttributeValueL(CSdpAttrValue &aValue, TSdpElementType aType);
00068         void StartListL(CSdpAttrValueList &aList);
00069         void EndListL();
00070     private:
00071         enum TDiscoveryState {
00072             ENone = 1, 
00073             EDiscoveringDevice,
00074             EDiscoveringService
00075         };
00076 
00077         CBTDiscoverer(RMessage &aMessage, CServerSession &aSession);
00078         void ConstructL();
00079         void DeviceDiscovered();
00080         void DiscoverServices(TNameRecord &aNameRecord);
00081         void FinishDiscovery();
00082 
00083         RMessage &iMessage;
00084         CServerSession &iSession;
00085 
00086         // device discovery resources
00087         RHostResolver iHr;
00088         TNameEntry iNameEntry;
00089 
00090         // service discovery resources
00091         CSdpSearchPattern *iSdpPattern;
00092         CSdpAgent *iAgent;
00093 
00094         // attribute parsing state variables
00095         TInt iAttrNum;
00096         TBool iPeerOk;
00097 
00098         // addresses of discovered devices 
00099         RDeviceAddressList iDeviceAddresses;
00100 
00101         // ordinal (index in iDeviceAddresses) of the device whose are being discovered
00102         TInt iCurrentDeviceIndex;
00103 
00104         // discovered peers
00105         TInt iNumPeers;
00106         //##TODO## maybe use RPointerArray instead?
00107         TPeerDataList *iPeerList;
00108 };
00109 
00110 #endif

Generated on Mon Dec 8 10:26:06 2003 for CobainAPIImplementation by doxygen 1.3.5