sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32base.h>
|
sl@0
|
20 |
#include <ct.h>
|
sl@0
|
21 |
#include "ct/logger.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
// As it's easier for the implementer to initialise the ref
|
sl@0
|
24 |
// count to 0 than 1, reference count values are 1 less than you
|
sl@0
|
25 |
// might expect. The object should be deleted when the count reaches -1
|
sl@0
|
26 |
EXPORT_C void MCTToken::Release()
|
sl@0
|
27 |
{
|
sl@0
|
28 |
--ReferenceCount();
|
sl@0
|
29 |
|
sl@0
|
30 |
LOG2(_L("MCTToken::Release: token released, ref count == %d: %-32S"), ReferenceCount(), &Label());
|
sl@0
|
31 |
LOG_INC_INDENT();
|
sl@0
|
32 |
|
sl@0
|
33 |
if (ReferenceCount() < 0)
|
sl@0
|
34 |
{
|
sl@0
|
35 |
MCTTokenType& tokenType = TokenType();
|
sl@0
|
36 |
DoRelease();
|
sl@0
|
37 |
// FROM THIS POINT ON, THE OBJECT MAY BE DELETED
|
sl@0
|
38 |
tokenType.Release();
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
LOG_DEC_INDENT();
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
EXPORT_C void MCTToken::DoRelease()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
LOG1(_L("MCTToken::DoRelease: destroying token: %-32S"), &Label());
|
sl@0
|
47 |
LOG_INC_INDENT();
|
sl@0
|
48 |
|
sl@0
|
49 |
delete this;
|
sl@0
|
50 |
|
sl@0
|
51 |
LOG_DEC_INDENT();
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
// Dummy removal notification for use on non-removable tokens
|
sl@0
|
55 |
EXPORT_C void MCTToken::NotifyOnRemoval(TRequestStatus& /*aStatus*/)
|
sl@0
|
56 |
{
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
EXPORT_C void MCTToken::CancelNotify()
|
sl@0
|
60 |
{
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
// Base implementation of GetInterface. This just does the reference counting
|
sl@0
|
64 |
EXPORT_C void MCTToken::GetInterface(TUid aRequiredInterface,
|
sl@0
|
65 |
MCTTokenInterface*& aReturnedInterface,
|
sl@0
|
66 |
TRequestStatus& aStatus)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
++ReferenceCount();
|
sl@0
|
69 |
LOG2(_L("MCTToken::GetInterface: getting interface, ref count == %d: %-32S"), ReferenceCount(), &Label());
|
sl@0
|
70 |
LOG_INC_INDENT();
|
sl@0
|
71 |
|
sl@0
|
72 |
DoGetInterface(aRequiredInterface, aReturnedInterface, aStatus);
|
sl@0
|
73 |
|
sl@0
|
74 |
LOG_DEC_INDENT();
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
/** Cancel a GetInterface operation */
|
sl@0
|
78 |
EXPORT_C void MCTToken::CancelGetInterface()
|
sl@0
|
79 |
{
|
sl@0
|
80 |
if (DoCancelGetInterface())
|
sl@0
|
81 |
{
|
sl@0
|
82 |
Release();
|
sl@0
|
83 |
}
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
void MCTToken::ObjectCreated()
|
sl@0
|
87 |
{
|
sl@0
|
88 |
++ReferenceCount();
|
sl@0
|
89 |
LOG2(_L("MCTToken::ObjectCreated: token object created, ref count == %d: %-32S"), ReferenceCount(), &Label());
|
sl@0
|
90 |
}
|