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.20 2003/11/20 07:52:20 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     
00059         ~CBTCommunicator();
00060 
00067         RSocket* ConnectL(TPeerData *aPeerData);
00068 
00077         void DiscoverPeersL(const RMessage &aMessage,
00078                             CServerSession &aSession);
00079 
00091         CConcreteConnection* StartListeningL(const TInt aServiceClassID,
00092                                              const TInt aApplicationID,
00093                                              const TDesC8 &aServiceName,
00094                                              const TDesC8 &aServiceDesc);
00098         void StopListeningL();
00099 
00100     private:
00101         CBTCommunicator(CServerSession *aSession);
00102         void ConstructL();
00103         void StartAdvertisingL(TInt aPort,
00104                                const TInt aServiceClassID,
00105                                const TInt aApplicationID,
00106                                const TDesC8 &aServiceName,
00107                                const TDesC8 &aServiceDesc);
00108         TInt OpenListeningSocketL();
00109         void SetChannelSecurityL(TInt aChannel);
00110         void SetAvailabilityL(TBool aIsAvailable);
00111 
00112         // server session
00113         CServerSession *iServerSession;
00114 
00115         CSdpAgent *iAgent;
00116 
00117         // remote device/service discoverer
00118         CBTDiscoverer *iDiscoverer;
00119 
00120         // Socket stuff for incoming connections
00121         RSocketServ iSocketServ;
00122         RSocket iListeningSocket;
00123         CConcreteConnection *iListeningConnection;    
00124 
00125         // SDP stuff
00126         RSdp iSdpSession;
00127         RSdpDatabase iSdpDB;
00128 
00129         // The service record of the advertised service
00130         TSdpServRecordHandle iRecord;
00131 
00132         // record version
00133         TInt iRecordVersion;
00134 
00135         // whether listening for connections
00136         TBool iIsListening;
00137 };
00138 
00139 #endif

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