51
|
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 "receiver.h"
|
|
23 |
#include "receiveobserver.h"
|
|
24 |
#include <bluetooth/logger.h>
|
|
25 |
|
|
26 |
#ifdef __FLOG_ACTIVE
|
|
27 |
_LIT8(KLogComponent, LOG_COMPONENT_REMCON_REF_SER_BEARER);
|
|
28 |
#endif
|
|
29 |
|
|
30 |
CReceiver* CReceiver::NewL(RComm& aComm, MReceiveObserver& aObserver)
|
|
31 |
{
|
|
32 |
LOG_STATIC_FUNC
|
|
33 |
CReceiver* self = new(ELeave) CReceiver(aComm, aObserver);
|
|
34 |
return self;
|
|
35 |
}
|
|
36 |
|
|
37 |
CReceiver::~CReceiver()
|
|
38 |
{
|
|
39 |
LOG_FUNC
|
|
40 |
Cancel();
|
|
41 |
}
|
|
42 |
|
|
43 |
CReceiver::CReceiver(RComm& aComm, MReceiveObserver& aObserver)
|
|
44 |
: CActive(CActive::EPriorityStandard),
|
|
45 |
iComm(aComm),
|
|
46 |
iObserver(aObserver)
|
|
47 |
{
|
|
48 |
LOG_FUNC
|
|
49 |
CActiveScheduler::Add(this);
|
|
50 |
}
|
|
51 |
|
|
52 |
void CReceiver::Receive(TDes8& aBuf)
|
|
53 |
{
|
|
54 |
iComm.Read(iStatus, aBuf);
|
|
55 |
SetActive();
|
|
56 |
}
|
|
57 |
|
|
58 |
void CReceiver::RunL()
|
|
59 |
{
|
|
60 |
iObserver.MroReceiveComplete(iStatus.Int());
|
|
61 |
}
|
|
62 |
|
|
63 |
void CReceiver::DoCancel()
|
|
64 |
{
|
|
65 |
iComm.ReadCancel();
|
|
66 |
}
|