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

driverbase.cpp

Go to the documentation of this file.
00001 /*
00002  * driverbase.cpp,v 1.5 2003/11/25 19:29:56 mattid Exp
00003  *
00004  * COBAIN - Communications API for EPOC Environments
00005  * Copyright (C) 2002 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 #include "driverbase.h"
00026 #include "clientsession.h"
00027 
00028 CDriverBase::CDriverBase(RCobainClientSession &aClientSession,
00029                          TProtocol aProtocol)
00030     : iClientSession(aClientSession),
00031       iProtocol(aProtocol),
00032       iPeerListPump(aProtocol, aClientSession)
00033 {
00034 }
00035 
00036 CDriverBase::~CDriverBase()
00037 {
00038     CCobainLayer::Log(_L("~CDriverBase()"));
00039 
00040     // cancel possibly pending peer list retrieval
00041     iPeerListPump.Cancel();
00042 
00043     if( iConnectionListener != NULL ) {
00044         StopListeningL();
00045     }
00046 }
00047 
00048 void CDriverBase::ListenL(TUint aPort, MConnectionListener *aListener)
00049 {
00050     // check there is no pending listen
00051     __ASSERT_ALWAYS(iConnectionListener == NULL, User::Leave(KErrDriverAlreadyListening));
00052 
00053     // create connection listener
00054     iConnectionListener = new (ELeave) CConnectionListener(iClientSession, this);
00055 
00056     // synchronous call to start listening
00057     iClientSession.StartListening(iProtocol, aPort);
00058         
00059     // launch connection listening active object
00060     iConnectionListener->Listen(aListener);
00061 }
00062 
00063 void CDriverBase::StopListeningL()
00064 {
00065     // check there is a pending listen
00066     __ASSERT_ALWAYS(iConnectionListener != NULL, User::Leave(KErrDriverNotListening));
00067 
00068     CCobainLayer::Log(_L("CDriverBase::StopListening()"));
00069 
00070     // cancel pending listen operation (will call server to cancel serverside)
00071     iConnectionListener->Cancel();
00072 
00073     CCobainLayer::Log(_L("deleting iConnectionListener"));
00074     delete iConnectionListener;
00075     iConnectionListener;
00076 
00077     // no more connections will be received
00078     iListener = NULL;
00079 }
00080 
00081 void CDriverBase::DiscoverPeersL(TUint aServiceClassID, MNetworkDriverListener *aListener)
00082 {
00083     iPeerListPump.DiscoverPeers(aServiceClassID, aListener);
00084 }
00085 
00086 void CDriverBase::CancelPeerDiscovery()
00087 {
00088     iPeerListPump.Cancel();
00089 }

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