|
1 /* |
|
2 * Copyright (c) 2004 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: Implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include "CMCETestUIEngineProfileContainer.h" |
|
24 #include "MCETestUIEngineDefaultValues.h" |
|
25 #include "CMCETestUIEngineProfile.h" |
|
26 #include "sipprofile.h" |
|
27 #include "MCETestUIEngineConstants.h" |
|
28 #include "MCETestUIDebug.h" |
|
29 |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CMCETestUIEngineProfileContainer::NewL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CMCETestUIEngineProfileContainer* CMCETestUIEngineProfileContainer::NewL( |
|
36 CMCETestUIEngine& aEngine, CSIP& aSip ) |
|
37 { |
|
38 CMCETestUIEngineProfileContainer* self = |
|
39 new( ELeave ) CMCETestUIEngineProfileContainer( aEngine, aSip ); |
|
40 |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CMCETestUIEngineProfileContainer::~CMCETestUIEngineProfileContainer |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CMCETestUIEngineProfileContainer::~CMCETestUIEngineProfileContainer() |
|
53 { |
|
54 iProfiles.ResetAndDestroy(); |
|
55 iUsedProfiles.ResetAndDestroy(); |
|
56 |
|
57 delete iProfileRegistry; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CMCETestUIEngineProfileContainer::CMCETestUIEngineProfileContainer |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CMCETestUIEngineProfileContainer::CMCETestUIEngineProfileContainer( |
|
65 CMCETestUIEngine& aEngine, CSIP& aSip ) |
|
66 : iEngine( aEngine ), |
|
67 iProfiles( 2 ), |
|
68 iSip( aSip ) |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CMCETestUIEngineProfileContainer::ConstructL |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CMCETestUIEngineProfileContainer::ConstructL() |
|
77 { |
|
78 iProfileRegistry = CSIPProfileRegistry::NewL( iSip, *this ); |
|
79 |
|
80 // Instantiate and store all profiles |
|
81 RPointerArray<CSIPProfile> profiles; |
|
82 iProfileRegistry->ProfilesL( profiles ); |
|
83 |
|
84 for ( TInt i = 0; i < profiles.Count(); ++i ) |
|
85 { |
|
86 CMCETestUIEngineProfile* item = |
|
87 CMCETestUIEngineProfile::NewL( profiles[i], iEngine ); |
|
88 CleanupStack::PushL( item ); |
|
89 User::LeaveIfError( iProfiles.Append( item ) ); |
|
90 CleanupStack::Pop( item ); |
|
91 } |
|
92 |
|
93 profiles.Reset(); |
|
94 |
|
95 if ( MCETestUIEngineDefaultValues::TakeDefaultProfileIntoUse() ) |
|
96 { |
|
97 TakeProfileIntoUseL( GetDefaultProfileL() ); |
|
98 } |
|
99 |
|
100 } |
|
101 |
|
102 |
|
103 // |
|
104 // -- MSIPProfileRegistryObserver functions ----------------------------------- |
|
105 // |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CMCETestUIEngineProfileContainer::ProfileRegistryEventOccurred |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CMCETestUIEngineProfileContainer::ProfileRegistryEventOccurred( |
|
112 TUint32 /*aProfileId*/, TEvent aEvent) |
|
113 { |
|
114 |
|
115 TPtrC aMessage; |
|
116 MCE_TESTUI_DEBUG3( "CMCETestUIEngineProfileContainer::ProfileRegistryEventOccurred", aEvent ); |
|
117 switch (aEvent) |
|
118 { |
|
119 case MSIPProfileRegistryObserver::EProfileUpdated: |
|
120 { |
|
121 aMessage.Set( KUserNotificationProfileUpdated ); |
|
122 break; |
|
123 } |
|
124 case MSIPProfileRegistryObserver::EProfileRegistered: |
|
125 { |
|
126 aMessage.Set( KUserNotificationProfileRegistered ); |
|
127 break; |
|
128 } |
|
129 case MSIPProfileRegistryObserver::EProfileDeregistered: |
|
130 { |
|
131 aMessage.Set( KUserNotificationProfileDeregistered ); |
|
132 break; |
|
133 } |
|
134 /* |
|
135 case MSIPProfileRegistryObserver::EProfileCreated: |
|
136 { |
|
137 break; |
|
138 } |
|
139 case MSIPProfileRegistryObserver::EProfileDestroyed: |
|
140 { |
|
141 break; |
|
142 } |
|
143 */ |
|
144 default: |
|
145 { |
|
146 aMessage.Set( KUserNotificationProfileUnknownEvent ); |
|
147 break; |
|
148 } |
|
149 } |
|
150 |
|
151 iEngine.NotifyUser( aMessage ); |
|
152 iEngine.EngineStateChangedL(); |
|
153 |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CMCETestUIEngineProfileContainer::ProfileRegistryErrorOccurred |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CMCETestUIEngineProfileContainer::ProfileRegistryErrorOccurred( |
|
161 TUint32 /*aProfileId*/, TInt /*aError*/ ) |
|
162 { |
|
163 // Not implemented yet |
|
164 } |
|
165 |
|
166 // |
|
167 // -- MSIPConnectionObserver dummy functions |
|
168 // |
|
169 |
|
170 void CMCETestUIEngineProfileContainer::IncomingRequest (CSIPServerTransaction* /*aTransaction*/) |
|
171 { |
|
172 // NOP |
|
173 } |
|
174 void CMCETestUIEngineProfileContainer::IncomingRequest (CSIPServerTransaction* /*aTransaction*/, |
|
175 CSIPDialog& /*aDialog*/) |
|
176 { |
|
177 // NOP |
|
178 } |
|
179 void CMCETestUIEngineProfileContainer::IncomingResponse (CSIPClientTransaction& /*aTransaction*/) |
|
180 { |
|
181 // NOP |
|
182 } |
|
183 void CMCETestUIEngineProfileContainer::IncomingResponse (CSIPClientTransaction& /*aTransaction*/, |
|
184 CSIPDialogAssocBase& /*aDialogAssoc*/) |
|
185 { |
|
186 // NOP |
|
187 } |
|
188 void CMCETestUIEngineProfileContainer::IncomingResponse (CSIPClientTransaction& /*aTransaction*/, |
|
189 CSIPInviteDialogAssoc* /*aDialogAssoc*/) |
|
190 { |
|
191 // NOP |
|
192 } |
|
193 void CMCETestUIEngineProfileContainer::IncomingResponse (CSIPClientTransaction& /*aTransaction*/, |
|
194 CSIPRegistrationBinding& /*aRegistration*/) |
|
195 { |
|
196 // NOP |
|
197 } |
|
198 void CMCETestUIEngineProfileContainer::ErrorOccured (TInt /*aError*/, |
|
199 CSIPTransactionBase& /*aTransaction*/) |
|
200 { |
|
201 // NOP |
|
202 } |
|
203 void CMCETestUIEngineProfileContainer::ErrorOccured (TInt /*aError*/, |
|
204 CSIPClientTransaction& /*aTransaction*/, |
|
205 CSIPRegistrationBinding& /*aRegistration*/) |
|
206 { |
|
207 // NOP |
|
208 } |
|
209 void CMCETestUIEngineProfileContainer::ErrorOccured (TInt /*aError*/, |
|
210 CSIPTransactionBase& /*aTransaction*/, |
|
211 CSIPDialogAssocBase& /*aDialogAssoc*/) |
|
212 { |
|
213 // NOP |
|
214 } |
|
215 void CMCETestUIEngineProfileContainer::ErrorOccured (TInt /*aError*/, CSIPRefresh& /*aSIPRefresh*/) |
|
216 { |
|
217 // NOP |
|
218 } |
|
219 void CMCETestUIEngineProfileContainer::ErrorOccured (TInt /*aError*/, |
|
220 CSIPRegistrationBinding& /*aRegistration*/) |
|
221 { |
|
222 // NOP |
|
223 } |
|
224 void CMCETestUIEngineProfileContainer::ErrorOccured (TInt /*aError*/, |
|
225 CSIPDialogAssocBase& /*aDialogAssoc*/) |
|
226 { |
|
227 // NOP |
|
228 } |
|
229 void CMCETestUIEngineProfileContainer::InviteCompleted (CSIPClientTransaction& /*aTransaction*/) |
|
230 { |
|
231 // NOP |
|
232 } |
|
233 void CMCETestUIEngineProfileContainer::InviteCanceled (CSIPServerTransaction& /*aTransaction*/) |
|
234 { |
|
235 // NOP |
|
236 } |
|
237 void CMCETestUIEngineProfileContainer::ConnectionStateChanged (CSIPConnection::TState /*aState*/) |
|
238 { |
|
239 // NOP |
|
240 } |
|
241 |
|
242 // |
|
243 // -- Public functions -------------------------------------------------------- |
|
244 // |
|
245 |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CMCETestUIEngineProfileContainer::AvailableProfiles |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 const RPointerArray<CMCETestUIEngineProfile>& |
|
252 CMCETestUIEngineProfileContainer::AvailableProfiles() |
|
253 { |
|
254 return iProfiles; |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CMCETestUIEngineProfileContainer::UsedProfiles |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 const RPointerArray<CMCETestUIEngineProfile>& |
|
262 CMCETestUIEngineProfileContainer::UsedProfiles() |
|
263 { |
|
264 return iUsedProfiles; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CMCETestUIEngineProfileContainer::IsProfileInUse |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 TBool CMCETestUIEngineProfileContainer::IsProfileInUse( |
|
272 CMCETestUIEngineProfile& aProfile ) |
|
273 { |
|
274 for ( TInt i = 0; i < iUsedProfiles.Count(); ++i ) |
|
275 { |
|
276 if ( iUsedProfiles[i] == &aProfile ) |
|
277 { |
|
278 return ETrue; |
|
279 } |
|
280 } |
|
281 return EFalse; |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CMCETestUIEngineProfileContainer::TakeProfileIntoUseL |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 void CMCETestUIEngineProfileContainer::TakeProfileIntoUseL( |
|
289 CMCETestUIEngineProfile& aProfile ) |
|
290 { |
|
291 // for every available profile |
|
292 for ( TInt i = 0; i < iProfiles.Count(); ++i ) |
|
293 { |
|
294 // check if it is the one to be taken into use |
|
295 if ( iProfiles[i] == &aProfile ) |
|
296 { |
|
297 // check that this is not allready in use |
|
298 if ( !IsProfileInUse( aProfile ) ) |
|
299 { |
|
300 iUsedProfiles.AppendL( iProfiles[i] ); |
|
301 iProfiles.Remove( i ); |
|
302 iProfiles.Compress(); |
|
303 |
|
304 if ( MCETestUIEngineDefaultValues::RegisterUsedProfiles() ) |
|
305 { |
|
306 iProfileRegistry->EnableL( aProfile.Profile(), *this ); |
|
307 } |
|
308 iEngine.EngineStateChangedL(); |
|
309 } |
|
310 } |
|
311 } |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CMCETestUIEngineProfileContainer::GetDefaultProfileL |
|
316 // ----------------------------------------------------------------------------- |
|
317 // |
|
318 CMCETestUIEngineProfile& CMCETestUIEngineProfileContainer::GetDefaultProfileL() |
|
319 { |
|
320 for ( TInt i = 0; i < iProfiles.Count(); ++i ) |
|
321 { |
|
322 if ( iProfiles[i]->IsDefault() ) |
|
323 { |
|
324 return *(iProfiles[i]); |
|
325 } |
|
326 } |
|
327 |
|
328 for ( TInt i = 0; i < iUsedProfiles.Count(); ++i ) |
|
329 { |
|
330 if ( iUsedProfiles[i]->IsDefault() ) |
|
331 { |
|
332 return *(iUsedProfiles[i]); |
|
333 } |
|
334 } |
|
335 |
|
336 User::Leave( KErrNotFound ); |
|
337 return *(CMCETestUIEngineProfile::NewL( NULL, iEngine )); // To keep compiler happy; |
|
338 } |
|
339 |
|
340 |
|
341 // End of file |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |