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.10 2004/01/08 13:20: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 
00047 class CBTDiscoverer : public CActive, 
00048                       public MSdpAgentNotifier,
00049                       public MSdpAttributeValueVisitor
00050 {
00051     public:
00052         static CBTDiscoverer * NewL(RMessage &aMessage, CServerSession &aSession);
00053         ~CBTDiscoverer();
00054 
00055         void StartL(RSocketServ &aSocketServ);
00056 
00057         // from CActive
00058         void RunL();
00059         TInt RunError(TInt aError); 
00060         void DoCancel();
00061 
00062         // from MSdpNotifier
00063         void AttributeRequestComplete(TSdpServRecordHandle aHandle, TInt aError);
00064         void AttributeRequestResult(TSdpServRecordHandle aHandle, 
00065                                     TSdpAttributeID aAttrID, 
00066                                     CSdpAttrValue* aAttrValue);
00067         void NextRecordRequestComplete(TInt aError, 
00068                                        TSdpServRecordHandle aHandle, 
00069                                        TInt aTotalRecordsCount);
00070 
00071         // from MSdpAttributeValueVisitor
00072         void VisitAttributeValueL(CSdpAttrValue &aValue, TSdpElementType aType);
00073         void StartListL(CSdpAttrValueList &aList);
00074         void EndListL();
00075 
00076     private:
00077         CBTDiscoverer(RMessage &aMessage, CServerSession &aSession);
00078         void ConstructL();
00079         void DeviceDiscovered();
00080         void DiscoverServices(TNameRecord &aNameRecord);
00081         void FinishDiscovery();
00082         void ParseUuid(TDes &aBuf, const TUUID &aUuid, TUint32 &aUuid32);
00083 
00084         // client-side call resources
00085         RMessage &iMessage;
00086         CServerSession &iSession;
00087 
00088         // device discovery resources
00089         RHostResolver iHr;
00090         TNameEntry iNameEntry;
00091 
00092         // service discovery resources
00093         CSdpSearchPattern *iSdpPattern;
00094         CSdpAgent *iAgent;
00095         CSdpAttrIdMatchList *iAttrMatchList;
00096 
00097         // last 32-bit UUID or 0 if the last attribute was not UUID
00098         TUint32 iLastUuid32;
00099 
00100         // RFCOMM port of the service currently being processed
00101         TInt iRfcommPort;
00102 
00103         // L2CAP port of the service currently being processed
00104         TInt iL2capPort;
00105 
00106         // service name of the service currently being processed
00107         TServiceName iServiceName;
00108 
00109         // addresses of discovered devices 
00110         RDeviceAddressList iDeviceAddresses;
00111 
00112         // ordinal (index in iDeviceAddresses) of the device whose are being discovered
00113         TInt iCurrentDeviceIndex;
00114 
00115         // number of discovered peers so far
00116         TInt iNumPeers;
00117 
00118         // list of peers discovered so far
00119         TPeerDataList *iPeerList;
00120 };
00121 
00122 #endif

Generated on Tue Jan 13 15:47:06 2004 for CobainAPIImplementation by doxygen 1.3.5