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

bluetoothcommunicator.h

Go to the documentation of this file.
00001 /*
00002  * bluetoothcommunicator.h,v 1.22 2004/01/06 17:05:40 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 __BLUETOOTHCOMMUNICATOR_H
00026 #define __BLUETOOTHCOMMUNICATOR_H
00027 
00028 #include <e32base.h>
00029 #include <e32svr.h>
00030 #include <btsdp.h>
00031 #include <es_sock.h>
00032 
00033 #include "clientservercommon.h"
00034 
00035 // panic category and error codes
00036 _LIT(KBTCommPanic, "CBTCommunicator");
00037 
00038 const TInt KErrBTCommAlreadyListening = -9990;
00039 const TInt KerrBTCommFailedToCreateListeningSocket = -9991;
00040 
00041 // size of the listen queue
00042 const TInt KListeningQueueSize = 8;
00043 
00044 class CServerSession;
00045 class CBTDiscoverer;
00046 class CConcreteConnection;
00047 
00054 class CBTCommunicator : public CBase
00055 {
00056     public:
00057         static CBTCommunicator * NewL(CServerSession *aSession);
00058         ~CBTCommunicator();
00059 
00066         RSocket* ConnectL(TPeerData *aPeerData);
00067 
00076         void DiscoverPeersL(const RMessage &aMessage,
00077                             CServerSession &aSession);
00078 
00092         CConcreteConnection* StartListeningL(const TInt aServiceClassID,
00093                                              const TInt aApplicationID,
00094                                              const TDesC8 &aServiceName,
00095                                              const TDesC8 &aServiceDesc,
00096                                              TInt aListeningSocketType);
00100         void StopListeningL();
00101 
00110         static TInt ResolveMTU(RSocket& socket);
00111 
00112     private:
00113         CBTCommunicator(CServerSession *aSession);
00114         void ConstructL();
00115         void StartAdvertisingL(TInt aPort,
00116                                const TInt aServiceClassID,
00117                                const TInt aApplicationID,
00118                                const TDesC8 &aServiceName,
00119                                const TDesC8 &aServiceDesc);
00120         TInt OpenListeningSocketL();
00121         void SetChannelSecurityL(TInt aChannel);
00122         void SetAvailabilityL(TBool aIsAvailable);
00123 
00124         // server session
00125         CServerSession *iServerSession;
00126 
00127         // remote device/service discoverer
00128         CBTDiscoverer *iDiscoverer;
00129 
00130         // whether listening for connections
00131         TBool iIsListening;
00132 
00133         // type of listening socket (either KRFCOMM or KL2CAP)
00134         TInt iListeningSocketType;
00135 
00136         // Socket stuff for incoming connections
00137         RSocketServ iSocketServ;
00138         RSocket iListeningSocket;
00139         CConcreteConnection *iListeningConnection;    
00140 
00141         // SDP stuff
00142         CSdpAgent *iAgent;
00143         RSdp iSdpSession;
00144         RSdpDatabase iSdpDB;
00145 
00146         // The service record of the advertised service
00147         TSdpServRecordHandle iRecord;
00148 
00149         // record version
00150         TInt iRecordVersion;
00151 };
00152 
00153 #endif

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