10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Model for managing SIP profiles. |
14 * Description: Model for managing SIP profiles. |
15 * Version : %version: 19 % << Don't touch! Updated by Synergy at check-out. |
|
16 * |
15 * |
17 */ |
16 */ |
18 |
17 |
19 |
18 |
20 #include <sipmanagedprofileregistry.h> |
|
21 #include <sipmanagedprofile.h> |
|
22 |
19 |
23 #include "mussipprofilemodel.h" |
20 #include "mussipprofilemodel.h" |
24 #include "muslogger.h" |
21 #include "muslogger.h" |
25 #include "mussettings.inl" |
22 #include <aknnotewrappers.h> |
26 #include "mussettingsmodel.h" |
23 #include <StringLoader.h> |
27 |
24 #include <aknview.h> |
28 |
25 #include <sipmanagedprofileregistry.h> |
|
26 |
|
27 |
|
28 const TInt KSIPGranularity = 5; |
29 const TInt KUnknownProfileId = 0; |
29 const TInt KUnknownProfileId = 0; |
30 |
30 |
31 |
31 |
32 // ======== MEMBER FUNCTIONS ======== |
32 // ======== MEMBER FUNCTIONS ======== |
33 |
33 |
34 |
34 |
35 // ---------------------------------------------------------------------------- |
|
36 // |
|
37 // ---------------------------------------------------------------------------- |
|
38 // |
|
39 CMusSIPProfileModel::CMusSIPProfileModel() |
35 CMusSIPProfileModel::CMusSIPProfileModel() |
40 { |
36 { |
41 } |
37 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::CMusSIPProfileModel()" ) |
42 |
38 } |
43 // ---------------------------------------------------------------------------- |
39 |
44 // |
40 |
45 // ---------------------------------------------------------------------------- |
|
46 // |
|
47 void CMusSIPProfileModel::ConstructL() |
41 void CMusSIPProfileModel::ConstructL() |
48 { |
42 { |
49 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ConstructL()" ) |
43 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ConstructL()" ) |
50 |
|
51 MUS_LOG( "[MUSSET] Creating CSIPManagedProfileRegistry " ) |
|
52 iEngine = CSIPManagedProfileRegistry::NewL( *this ); |
44 iEngine = CSIPManagedProfileRegistry::NewL( *this ); |
53 MUS_LOG( "[MUSSET] Done " ) |
45 ReadArrayFromEngineL(); |
54 MUS_LOG( "[MUSSET] Getting profiles " ) |
46 } |
55 iEngine->ProfilesL( iProfiles ); |
47 |
56 MUS_LOG( "[MUSSET] Done " ) |
48 |
57 SortProfilesL(); |
|
58 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ConstructL()" ) |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 CMusSIPProfileModel* CMusSIPProfileModel::NewL() |
49 CMusSIPProfileModel* CMusSIPProfileModel::NewL() |
66 { |
50 { |
67 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::NewL()" ) |
51 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::NewL()" ) |
68 CMusSIPProfileModel* self = new( ELeave ) CMusSIPProfileModel(); |
52 CMusSIPProfileModel* self = new( ELeave ) CMusSIPProfileModel(); |
69 |
53 |
73 |
57 |
74 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::NewL()" ) |
58 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::NewL()" ) |
75 return self; |
59 return self; |
76 } |
60 } |
77 |
61 |
78 // ---------------------------------------------------------------------------- |
62 |
79 // |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 CMusSIPProfileModel::~CMusSIPProfileModel() |
63 CMusSIPProfileModel::~CMusSIPProfileModel() |
83 { |
64 { |
84 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::~CMusSIPProfileModel()" ) |
65 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::~CMusSIPProfileModel()" ) |
85 iProfiles.ResetAndDestroy(); |
66 DeleteProfiles(); |
86 delete iEngine; |
67 delete iEngine; |
|
68 iEngine = NULL; |
87 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::~CMusSIPProfileModel()" ) |
69 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::~CMusSIPProfileModel()" ) |
88 } |
70 } |
89 |
71 |
90 // ---------------------------------------------------------------------------- |
72 |
91 // Returns reference to the locally cached SIP profile array. |
73 // ---------------------------------------------------------------------------- |
92 // ---------------------------------------------------------------------------- |
74 // Returns pointer to the locally cached SIP profile array. |
93 // |
75 // ---------------------------------------------------------------------------- |
94 RPointerArray<CSIPProfile>& CMusSIPProfileModel::ProfileArrayL() |
76 // |
95 { |
77 CArrayPtr<CSIPManagedProfile>* CMusSIPProfileModel::ProfileArrayL() |
96 MUS_LOG( "[MUSSET] <-> CMusSIPProfileModel::ProfileArrayL()" ) |
78 { |
|
79 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ProfileArrayL()" ) |
|
80 ReadProfileListFromEngineSafeL(); |
|
81 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileArrayL()" ) |
97 return iProfiles; |
82 return iProfiles; |
98 } |
83 } |
|
84 |
99 |
85 |
100 // ---------------------------------------------------------------------------- |
86 // ---------------------------------------------------------------------------- |
101 // Returns index to the default SIP profile in locally cached array. |
87 // Returns index to the default SIP profile in locally cached array. |
102 // ---------------------------------------------------------------------------- |
88 // ---------------------------------------------------------------------------- |
103 // |
89 // |
104 TInt CMusSIPProfileModel::DefaultProfileIndex() |
90 TInt CMusSIPProfileModel::DefaultProfileIndex() |
105 { |
91 { |
106 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileIndex()" ) |
92 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileIndex()" ) |
107 TInt index( KErrNotFound ); |
93 TInt index( KErrNotFound ); |
108 |
94 |
109 for ( TInt i = 0; i < iProfiles.Count(); i++ ) |
95 for ( TInt i = 0; i < iProfiles->Count(); i++ ) |
110 { |
96 { |
111 TBool defProfile( EFalse ); |
97 TBool defProfile( EFalse ); |
112 if ( |
98 if ( |
113 KErrNone == |
99 KErrNone == |
114 iProfiles[i]->GetParameter( KSIPDefaultProfile, defProfile ) |
100 iProfiles->At( i )->GetParameter( KSIPDefaultProfile, defProfile ) |
115 && defProfile ) |
101 && defProfile ) |
116 { |
102 { |
117 index = i; |
103 index = i; |
118 break; |
104 break; |
119 } |
105 } |
122 MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileIndex()( %d )", |
108 MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileIndex()( %d )", |
123 index ) |
109 index ) |
124 return index; |
110 return index; |
125 } |
111 } |
126 |
112 |
|
113 |
127 // ---------------------------------------------------------------------------- |
114 // ---------------------------------------------------------------------------- |
128 // Returns id of the default SIP profile. If default SIP profile is not found |
115 // Returns id of the default SIP profile. If default SIP profile is not found |
129 // KUnknownProfileId is returned. |
116 // KUnknownProfileId is returned. |
130 // ---------------------------------------------------------------------------- |
117 // ---------------------------------------------------------------------------- |
131 // |
118 // |
132 TUint32 CMusSIPProfileModel::DefaultProfileId() |
119 TUint32 CMusSIPProfileModel::DefaultProfileId() |
133 { |
120 { |
134 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileId()" ) |
121 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileId()" ) |
135 TUint32 id( KUnknownProfileId ); |
122 TUint32 id( KUnknownProfileId ); |
136 |
123 |
137 for ( TInt i = 0; i < iProfiles.Count(); i++ ) |
124 for ( TInt i = 0; i < iProfiles->Count(); i++ ) |
138 { |
125 { |
139 TBool defProfile( EFalse ); |
126 TBool defProfile( EFalse ); |
140 TInt error = iProfiles[i]->GetParameter( KSIPDefaultProfile, defProfile ); |
127 if ( |
141 if ( error == KErrNone && defProfile ) |
128 KErrNone == |
142 { |
129 iProfiles->At( i )->GetParameter( KSIPDefaultProfile, defProfile ) |
143 iProfiles[i]->GetParameter( KSIPProfileId, id ); |
130 && defProfile ) |
144 break; |
131 { |
|
132 iProfiles->At( i )->GetParameter( KSIPProfileId, id ); |
|
133 break; |
145 } |
134 } |
146 } |
135 } |
147 |
136 |
148 MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileId()( %d )", |
137 MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileId()( %d )", |
149 id ) |
138 id ) |
150 return id; |
139 return id; |
151 } |
140 } |
152 |
141 |
153 // ----------------------------------------------------------------------------- |
|
154 // Disable SIP Registration. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CMusSIPProfileModel::DisableProfileL() |
|
158 { |
|
159 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DisableProfileL " ) |
|
160 CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>( |
|
161 iEngine->ProfileL( DefaultProfileId()) ); |
|
162 CleanupStack::PushL( managedProfile ); |
|
163 MUS_LOG( "[MUSSET] Add registration parameter to profile.dat file " ) |
|
164 //set autoregistration off (i.e. when needed) => disable profile |
|
165 User::LeaveIfError( managedProfile->SetParameter( KSIPAutoRegistration, EFalse ) ); |
|
166 MUS_LOG( "[MUSSET] Saving profile " ) |
|
167 iEngine->SaveL( *managedProfile ); |
|
168 MUS_LOG( "[MUSSET] Saved" ) |
|
169 CleanupStack::PopAndDestroy( managedProfile ); |
|
170 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::DisableProfileL " ) |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // Enable SIP Registration. |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CMusSIPProfileModel::EnableProfileL() |
|
178 { |
|
179 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::EnableProfileL " ) |
|
180 CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>( |
|
181 iEngine->ProfileL( DefaultProfileId() ) ); |
|
182 CleanupStack::PushL( managedProfile ); |
|
183 MUS_LOG( "[MUSSET] Add registration parameters to profile.dat file " ) |
|
184 //set autoregistration on (i.e. always on) => enable profile |
|
185 User::LeaveIfError( managedProfile->SetParameter( KSIPAutoRegistration, ETrue ) ); |
|
186 MUS_LOG( "[MUSSET] Saving profile " ) |
|
187 iEngine->SaveL( *managedProfile ); |
|
188 MUS_LOG( "[MUSSET] Saved" ) |
|
189 CleanupStack::PopAndDestroy( managedProfile ); |
|
190 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::EnableRegisterL " ) |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // if SIP Registration enabled. |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 TBool CMusSIPProfileModel::ProfileEnabledL() |
|
198 { |
|
199 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ProfileEnabledL " ) |
|
200 CSIPManagedProfile* managedProfile = static_cast<CSIPManagedProfile*>( |
|
201 iEngine->ProfileL( DefaultProfileId() ) ); |
|
202 CleanupStack::PushL( managedProfile ); |
|
203 TBool enabled; |
|
204 MUS_LOG( "[MUSSET] Getting KSIPAutoRegistration" ) |
|
205 User::LeaveIfError( |
|
206 managedProfile->GetParameter( KSIPAutoRegistration, enabled ) ); |
|
207 MUS_LOG( "[MUSSET] Done" ) |
|
208 MUS_LOG1( "[MUSSET] KSIPAutoRegistration=%d", enabled ) |
|
209 CleanupStack::PopAndDestroy( managedProfile ); |
|
210 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileEnabledL " ) |
|
211 return enabled; |
|
212 } |
|
213 |
142 |
214 // ---------------------------------------------------------------------------- |
143 // ---------------------------------------------------------------------------- |
215 // Returns index of the default SIP profile on locally cached array. If default |
144 // Returns index of the default SIP profile on locally cached array. If default |
216 // SIP profile is not found, KErrNotFound is returned. |
145 // SIP profile is not found, KErrNotFound is returned. |
217 // ---------------------------------------------------------------------------- |
146 // ---------------------------------------------------------------------------- |
218 // |
147 // |
219 TInt CMusSIPProfileModel::ProfileIndexByIdL( TUint32 aId ) |
148 TInt CMusSIPProfileModel::ProfileIndexByIdL( TUint32 aId ) |
220 { |
149 { |
221 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ProfileIndexByIdL()" ) |
150 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ProfileIndexByIdL()" ) |
222 TInt index( KErrNotFound ); |
151 TInt index( KErrNotFound ); |
223 |
152 |
224 for ( TInt i = 0; i < iProfiles.Count(); i++ ) |
153 ReadProfileListFromEngineSafeL(); |
|
154 for ( TInt i = 0; i < iProfiles->Count(); i++ ) |
225 { |
155 { |
226 TUint32 id( KUnknownProfileId ); |
156 TUint32 id( KUnknownProfileId ); |
227 TInt error = iProfiles[i]->GetParameter( KSIPProfileId, id ); |
157 |
228 if ( error == KErrNone && id == aId ) |
158 if ( KErrNone == iProfiles->At( i )->GetParameter( KSIPProfileId, id ) |
|
159 && id == aId ) |
229 { |
160 { |
230 index = i; |
161 index = i; |
231 break; |
162 break; |
232 } |
163 } |
233 } |
164 } |
245 TUint32 CMusSIPProfileModel::ProfileIdByIndex( TUint aIndex ) |
176 TUint32 CMusSIPProfileModel::ProfileIdByIndex( TUint aIndex ) |
246 { |
177 { |
247 MUS_LOG1( "[MUSSET] -> CMusSIPProfileModel::ProfileIdByIndex()( %d )", |
178 MUS_LOG1( "[MUSSET] -> CMusSIPProfileModel::ProfileIdByIndex()( %d )", |
248 aIndex ) |
179 aIndex ) |
249 TUint32 profileId( KUnknownProfileId ); |
180 TUint32 profileId( KUnknownProfileId ); |
250 if ( aIndex < iProfiles.Count() ) |
181 if ( iProfiles->Count() > aIndex ) |
251 { |
182 { |
252 if ( iProfiles[aIndex]->GetParameter( KSIPProfileId, profileId ) ) |
183 if ( iProfiles->At( aIndex )->GetParameter( |
|
184 KSIPProfileId, profileId ) ) |
253 { |
185 { |
254 profileId = KUnknownProfileId; |
186 profileId = KUnknownProfileId; |
255 } |
187 } |
256 } |
188 } |
257 |
189 |
258 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileIdByIndex()" ) |
190 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileIdByIndex()" ) |
259 return profileId; |
191 return profileId; |
260 } |
192 } |
|
193 |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // Reads SIP profiles from SIP Profile Client array to locally cached array. |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 void CMusSIPProfileModel::ReadArrayFromEngineL() |
|
200 { |
|
201 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ReadArrayFromEngineL()" ) |
|
202 |
|
203 DeleteProfiles(); |
|
204 |
|
205 // Create the profile pointer array |
|
206 iProfiles = |
|
207 new ( ELeave ) CArrayPtrFlat<CSIPManagedProfile>( KSIPGranularity ); |
|
208 |
|
209 RPointerArray<CSIPProfile> profilePointerArray; |
|
210 TCleanupItem clItem( ResetAndDestroy, &profilePointerArray ); |
|
211 CleanupStack::PushL( clItem ); |
|
212 |
|
213 iEngine->ProfilesL( profilePointerArray ); |
|
214 for ( TInt i = 0; i < profilePointerArray.Count(); i++ ) |
|
215 { |
|
216 iProfiles->AppendL( |
|
217 static_cast<CSIPManagedProfile*>( profilePointerArray[i] ) ); |
|
218 } |
|
219 |
|
220 profilePointerArray.Reset(); |
|
221 CleanupStack::PopAndDestroy(); // clItem (profilePointerArray) |
|
222 |
|
223 SortProfilesL(); |
|
224 |
|
225 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ReadArrayFromEngineL()" ) |
|
226 } |
|
227 |
261 |
228 |
262 // ---------------------------------------------------------------------------- |
229 // ---------------------------------------------------------------------------- |
263 // Sorts internal array of SIP profiles by id. Used algorithm is generally |
230 // Sorts internal array of SIP profiles by id. Used algorithm is generally |
264 // slower than quicksort and selectionsort but very feasible for expected |
231 // slower than quicksort and selectionsort but very feasible for expected |
265 // amount of items to be sorted and complexity vise. |
232 // amount of items to be sorted and complexity vise. |
267 // |
234 // |
268 void CMusSIPProfileModel::SortProfilesL() |
235 void CMusSIPProfileModel::SortProfilesL() |
269 { |
236 { |
270 TUint32 profileIdFirst( 0 ); |
237 TUint32 profileIdFirst( 0 ); |
271 TUint32 profileIdSecond( 0 ); |
238 TUint32 profileIdSecond( 0 ); |
272 for ( TInt a = 0; a < iProfiles.Count() - 1; a++ ) |
239 for ( TInt a = 0; a < iProfiles->Count() - 1; a++ ) |
273 { |
240 { |
274 for ( TInt b = a + 1; b < iProfiles.Count(); b++ ) |
241 for ( TInt b = a + 1; b < iProfiles->Count(); b++ ) |
275 { |
242 { |
276 User::LeaveIfError( iProfiles[a]->GetParameter( |
243 User::LeaveIfError( iProfiles->At( a )->GetParameter( |
277 KSIPProfileId, profileIdFirst ) ); |
244 KSIPProfileId, profileIdFirst ) ); |
278 User::LeaveIfError( iProfiles[b]->GetParameter( |
245 User::LeaveIfError( iProfiles->At( b )->GetParameter( |
279 KSIPProfileId, profileIdSecond ) ); |
246 KSIPProfileId, profileIdSecond ) ); |
280 if ( profileIdFirst > profileIdSecond ) |
247 if ( profileIdFirst > profileIdSecond ) |
281 { |
248 { |
282 CSIPProfile* tmp = iProfiles[b]; |
249 CSIPManagedProfile* tmp = iProfiles->At( b ); |
283 iProfiles[b] = iProfiles[a]; |
250 iProfiles->At( b ) = iProfiles->At( a ); |
284 iProfiles[a] = tmp; |
251 iProfiles->At( a ) = tmp; |
285 } |
252 } |
286 } |
253 } |
287 } |
254 } |
288 } |
255 } |
|
256 |
|
257 |
|
258 // ---------------------------------------------------------------------------- |
|
259 // Deletes internally cached SIP profiles. |
|
260 // ---------------------------------------------------------------------------- |
|
261 // |
|
262 void CMusSIPProfileModel::DeleteProfiles() |
|
263 { |
|
264 if ( iProfiles ) |
|
265 { |
|
266 iProfiles->ResetAndDestroy(); |
|
267 delete iProfiles; |
|
268 iProfiles = NULL; |
|
269 } |
|
270 } |
|
271 |
289 |
272 |
290 // ---------------------------------------------------------------------------- |
273 // ---------------------------------------------------------------------------- |
291 // From class MSIPProfileRegistryObserver. |
274 // From class MSIPProfileRegistryObserver. |
292 // Notifies of an event in SIP profile registry. |
275 // Notifies of an event in SIP profile registry. |
293 // ---------------------------------------------------------------------------- |
276 // ---------------------------------------------------------------------------- |
294 // |
277 // |
295 void CMusSIPProfileModel::ProfileRegistryEventOccurred( |
278 void CMusSIPProfileModel::ProfileRegistryEventOccurred( |
296 TUint32 aSIPProfileId, TEvent aEvent ) |
279 TUint32 /*aSIPProfileId*/, TEvent /*aEvent*/ ) |
297 { |
280 { |
298 MUS_LOG("[MUSSET] -> CMusSIPProfileModel::ProfileRegistryEventOccurred()" ) |
|
299 MUS_LOG2(" SIPProfileId is %d,Event is %d",aSIPProfileId,aEvent) |
|
300 |
|
301 // We revert back to default settings if the profile used by MuS is deleted |
|
302 if ( aEvent == EProfileDestroyed ) |
|
303 { |
|
304 TRAP_IGNORE( |
|
305 //if the profile is the profile used by mush |
|
306 if ( MultimediaSharingSettings::SipProfileSettingL() == |
|
307 aSIPProfileId ) |
|
308 { |
|
309 //set the profile to default |
|
310 MultimediaSharingSettings::SetSipProfileSettingL( |
|
311 CMusSettingsModel::KVsSipProfileDefault ); |
|
312 //set mush off |
|
313 MultimediaSharingSettings::SetActivationSettingL( |
|
314 MusSettingsKeys::EActiveInHomeNetworks ); |
|
315 } |
|
316 ); |
|
317 } |
|
318 |
|
319 if ( aEvent == EProfileCreated || |
|
320 aEvent == EProfileUpdated || |
|
321 aEvent == EProfileDestroyed ) |
|
322 { |
|
323 // Profiles have been manipulated in SIP side, we must delete client |
|
324 // side profile objects and retrieve them again. If fetching fails, |
|
325 // we have empty array which is better than showing wrong values to |
|
326 // user. |
|
327 iProfiles.ResetAndDestroy(); |
|
328 TRAP_IGNORE( iEngine->ProfilesL( iProfiles ) ); |
|
329 TRAP_IGNORE( SortProfilesL() ); |
|
330 } |
|
331 |
|
332 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryEventOccurred()" ) |
281 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryEventOccurred()" ) |
333 } |
282 } |
|
283 |
334 |
284 |
335 // ---------------------------------------------------------------------------- |
285 // ---------------------------------------------------------------------------- |
336 // From class MSIPProfileRegistryObserver. |
286 // From class MSIPProfileRegistryObserver. |
337 // An asynchronous error has occurred related to SIP profile |
287 // An asynchronous error has occurred related to SIP profile |
338 // ---------------------------------------------------------------------------- |
288 // ---------------------------------------------------------------------------- |
342 TInt /*aError*/ ) |
292 TInt /*aError*/ ) |
343 { |
293 { |
344 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryErrorOccurred()" ) |
294 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryErrorOccurred()" ) |
345 } |
295 } |
346 |
296 |
347 // ---------------------------------------------------------------------------- |
297 |
348 //Set CMusSettingsModel to handle ProfileRegistry Event. |
298 // ---------------------------------------------------------------------------- |
349 // ---------------------------------------------------------------------------- |
299 // Reads SIP profile list from engine; if reading fails, old cached list is |
350 // |
300 // kept and returned. |
351 void CMusSIPProfileModel::SetCMusSettingsModel(CMusSettingsModel* aCMusSettingsModel) |
301 // ---------------------------------------------------------------------------- |
352 { |
302 // |
353 iCMusSettingsModel = aCMusSettingsModel; |
303 void CMusSIPProfileModel::ReadProfileListFromEngineSafeL() |
354 } |
304 { |
|
305 MUS_LOG( |
|
306 "[MUSSET] -> CMusSIPProfileModel::ReadProfileListFromEngineSafeL()" ) |
|
307 // To prevent complete disaster it we'll save the pointer of the old array |
|
308 CArrayPtrFlat<CSIPManagedProfile>* profiles = iProfiles; |
|
309 iProfiles = 0; |
|
310 TRAPD( error, ReadArrayFromEngineL() ); |
|
311 |
|
312 if ( error ) |
|
313 { |
|
314 // Problems with re-reading profiles; use existing array |
|
315 DeleteProfiles(); |
|
316 iProfiles = profiles; |
|
317 User::Leave( error ); |
|
318 } |
|
319 else |
|
320 { |
|
321 // No problems; delete backup array |
|
322 profiles->ResetAndDestroy(); |
|
323 delete profiles; |
|
324 } |
|
325 MUS_LOG( |
|
326 "[MUSSET] <- CMusSIPProfileModel::ReadProfileListFromEngineSafeL()" ) |
|
327 } |
|
328 |
|
329 |
|
330 // ---------------------------------------------------------------------------- |
|
331 // For deleting RPointerArray in case of leave (used in association with |
|
332 // TCleanupItem). |
|
333 // ---------------------------------------------------------------------------- |
|
334 // |
|
335 void CMusSIPProfileModel::ResetAndDestroy( TAny* aPointerArray ) |
|
336 { |
|
337 MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ResetAndDestroy()" ) |
|
338 RPointerArray<CSIPProfile>* array = |
|
339 static_cast<RPointerArray<CSIPProfile>*>( aPointerArray ); |
|
340 array->ResetAndDestroy(); |
|
341 array->Close(); |
|
342 MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ResetAndDestroy()" ) |
|
343 } |