|
1 /* |
|
2 * Copyright (c) 2005 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 "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: TLS data object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "AiwTlsData.h" |
|
23 |
|
24 // CONSTANTS |
|
25 |
|
26 const TInt KMenuLaunchObserversGranularity = 2; |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ========================================== |
|
29 |
|
30 CAiwTlsData::CAiwTlsData() : |
|
31 iMenuLaunchObservers( KMenuLaunchObserversGranularity ) |
|
32 { |
|
33 } |
|
34 |
|
35 CAiwTlsData::~CAiwTlsData() |
|
36 { |
|
37 iMenuLaunchObservers.Reset(); |
|
38 Dll::FreeTls(); |
|
39 } |
|
40 |
|
41 CAiwTlsData* CAiwTlsData::NewL() |
|
42 { |
|
43 CAiwTlsData* data = new( ELeave ) CAiwTlsData; |
|
44 CleanupStack::PushL( data ); |
|
45 data->ConstructL(); |
|
46 CleanupStack::Pop(); // data |
|
47 return data; |
|
48 } |
|
49 |
|
50 void CAiwTlsData::ConstructL() |
|
51 { |
|
52 User::LeaveIfError( Dll::SetTls( this ) ); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CAiwTlsData::OpenL |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CAiwTlsData* CAiwTlsData::OpenL() |
|
60 { |
|
61 CAiwTlsData* data = Instance(); |
|
62 if ( !data ) |
|
63 { |
|
64 data = NewL(); |
|
65 } |
|
66 |
|
67 data->iRefCount++; |
|
68 return data; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CAiwTlsData::Close |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CAiwTlsData::Close() |
|
76 { |
|
77 CAiwTlsData* data = Instance(); |
|
78 __ASSERT_DEBUG( data, User::Invariant() ); |
|
79 if ( data ) |
|
80 { |
|
81 if ( --data->iRefCount == 0 ) |
|
82 { |
|
83 delete data; // also frees TLS |
|
84 } |
|
85 } |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CAiwTlsData::AddMenuLaunchObserverL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CAiwTlsData::AddMenuLaunchObserverL( MAiwMenuLaunchObserver* aObserver ) |
|
93 { |
|
94 User::LeaveIfError( iMenuLaunchObservers.Append( aObserver ) ); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CAiwTlsData::RemoveMenuLaunchObserver |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CAiwTlsData::RemoveMenuLaunchObserver( MAiwMenuLaunchObserver* aObserver ) |
|
102 { |
|
103 TInt index = iMenuLaunchObservers.Find( aObserver ); |
|
104 if ( index >= 0 ) |
|
105 { |
|
106 iMenuLaunchObservers.Remove( index ); |
|
107 } |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CAiwTlsData::ReportMenuLaunch |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CAiwTlsData::ReportMenuLaunch() |
|
115 { |
|
116 TInt count = iMenuLaunchObservers.Count(); |
|
117 for ( TInt i = 0 ; i < count ; i++ ) |
|
118 { |
|
119 iMenuLaunchObservers[i]->MenuLaunched(); |
|
120 } |
|
121 } |
|
122 |
|
123 // End of file |