|
1 /* |
|
2 * Copyright (c) 2007 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: CCCHPlugin implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cchlogger.h" |
|
21 #include "cchplugin.h" |
|
22 #include "cchservice.h" |
|
23 #include "cchservicenotifier.h" |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 // None |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 // None |
|
30 |
|
31 // CONSTANTS |
|
32 // None |
|
33 |
|
34 // MACROS |
|
35 // None |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 // None |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 // None |
|
42 |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 // None |
|
45 |
|
46 // FORWARD DECLARATIONS |
|
47 // None |
|
48 |
|
49 // ============================= LOCAL FUNCTIONS ============================= |
|
50 |
|
51 // ============================ MEMBER FUNCTIONS ============================= |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CCCHPlugin::CCCHPlugin |
|
55 // C++ default constructor can NOT contain any code, that might leave. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CCCHPlugin::CCCHPlugin( TUid aUid ) : |
|
59 iUid( aUid ) |
|
60 { |
|
61 // No implementation required |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CCCHPlugin::ConstructL |
|
66 // Symbian 2nd phase constructor can leave. |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CCCHPlugin::ConstructL( TUid aUid ) |
|
70 { |
|
71 CCHLOGSTRING( "CCCHPlugin::ConstructL" ); |
|
72 CCHLOGSTRING2( " Uid: 0x%X", aUid ); |
|
73 |
|
74 iPlugin = CCchService::NewL( aUid, *this ); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CCCHPlugin::NewL |
|
79 // Two-phased constructor. |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CCCHPlugin* CCCHPlugin::NewL( TUid aUid ) |
|
83 { |
|
84 CCCHPlugin* self = new (ELeave) CCCHPlugin( aUid ); |
|
85 CleanupStack::PushL( self ); |
|
86 self->ConstructL( aUid ); |
|
87 CleanupStack::Pop( self ); |
|
88 return self; |
|
89 } |
|
90 |
|
91 // Destructor |
|
92 CCCHPlugin::~CCCHPlugin() |
|
93 { |
|
94 iObservers.Reset(); |
|
95 |
|
96 delete iPlugin; |
|
97 iPlugin = NULL; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CCCHPlugin::CheckUid |
|
102 // |
|
103 // (other items were commented in a header). |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 TBool CCCHPlugin::CheckUid( const TUid aUid ) const |
|
107 { |
|
108 return iUid == aUid; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CCCHPlugin::Plugin |
|
113 // |
|
114 // (other items were commented in a header). |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 CCchService* CCCHPlugin::Plugin() const |
|
118 { |
|
119 return iPlugin; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CCCHPlugin::SetServiceNotifier |
|
124 // |
|
125 // (other items were commented in a header). |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CCCHPlugin::SetServiceNotifier( MCCHServiceNotifier* aObserver ) |
|
129 { |
|
130 CCHLOGSTRING( "CCCHPlugin::SetServiceNotifier" ); |
|
131 |
|
132 TInt index( iObservers.Find( aObserver ) ); |
|
133 |
|
134 if ( KErrNotFound == index ) |
|
135 { |
|
136 iObservers.Append( aObserver ); |
|
137 } |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CCCHPlugin::RemoveServiceNotifier |
|
142 // |
|
143 // (other items were commented in a header). |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CCCHPlugin::RemoveServiceNotifier( MCCHServiceNotifier* aObserver ) |
|
147 { |
|
148 CCHLOGSTRING( "CCCHPlugin::RemoveServiceNotifier" ); |
|
149 |
|
150 TInt index( iObservers.Find( aObserver ) ); |
|
151 |
|
152 if ( KErrNotFound != index ) |
|
153 { |
|
154 iObservers.Remove( index ); |
|
155 iObservers.Compress(); |
|
156 } |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CCCHPlugin::ServiceStateChanged |
|
161 // |
|
162 // (other items were commented in a header). |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 void CCCHPlugin::ServiceStateChanged( |
|
166 const TServiceSelection aServiceSelection, |
|
167 TCCHSubserviceState aState, TInt aError ) |
|
168 { |
|
169 CCHLOGSTRING( "CCCHPlugin::ServiceStateChanged" ); |
|
170 CCHLOGSTRING2( " Service Id: %d", aServiceSelection.iServiceId ); |
|
171 CCHLOGSTRING2( " SubService's Type: %d", aServiceSelection.iType ); |
|
172 CCHLOGSTRING2( " State: %d", aState ); |
|
173 CCHLOGSTRING2( " Error: %d", aError ); |
|
174 |
|
175 for ( TInt i( 0 ); i < iObservers.Count(); i++ ) |
|
176 { |
|
177 if ( iObservers[ i ] ) |
|
178 { |
|
179 TRAP_IGNORE( |
|
180 iObservers[ i ]->StateChangedL( |
|
181 aServiceSelection.iServiceId, |
|
182 aServiceSelection.iType, |
|
183 aState, |
|
184 aError ) ); |
|
185 } |
|
186 } |
|
187 } |
|
188 |
|
189 // ========================== OTHER EXPORTED FUNCTIONS ======================= |
|
190 |
|
191 // End of File |