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