remotecontrol/remotecontrolfw/reference/serialbearer/src/sender.cpp
changeset 51 20ac952a623c
equal deleted inserted replaced
48:22de2e391156 51:20ac952a623c
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19 */
       
    20 
       
    21 #include <c32comm.h>
       
    22 #include "sender.h"
       
    23 #include "sendobserver.h"
       
    24 #include <bluetooth/logger.h>
       
    25  
       
    26 #ifdef __FLOG_ACTIVE
       
    27 _LIT8(KLogComponent, LOG_COMPONENT_REMCON_REF_SER_BEARER);
       
    28 #endif
       
    29  
       
    30 CSender* CSender::NewL(RComm& aComm, MSendObserver& aObserver)
       
    31 	{
       
    32 	LOG_STATIC_FUNC
       
    33 	CSender* self = new(ELeave) CSender(aComm, aObserver);
       
    34 	return self;
       
    35 	}
       
    36 
       
    37 CSender::~CSender()
       
    38 	{
       
    39 	LOG_FUNC
       
    40 	Cancel();
       
    41 	}
       
    42 
       
    43 CSender::CSender(RComm& aComm, MSendObserver& aObserver)
       
    44 :	CActive(CActive::EPriorityStandard),
       
    45 	iComm(aComm),
       
    46 	iObserver(aObserver)
       
    47 	{
       
    48 	LOG_FUNC
       
    49 	CActiveScheduler::Add(this);
       
    50 	}
       
    51 
       
    52 void CSender::Send(const TDesC8& aBuf)
       
    53 	{
       
    54 	iComm.Write(iStatus, aBuf);
       
    55 	SetActive();
       
    56 	}
       
    57 
       
    58 void CSender::RunL()
       
    59 	{
       
    60 	iObserver.MsoSendComplete(iStatus.Int());
       
    61 	}
       
    62 
       
    63 void CSender::DoCancel()
       
    64 	{
       
    65 	iComm.WriteCancel();
       
    66 	}