mmshplugins/mmshsettingsuiplugin/src/mussipprofilemodel.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
    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.
    15 *
    16 *
    16 */
    17 */
    17 
    18 
    18 
    19 
       
    20 #include <sipmanagedprofileregistry.h>
       
    21 #include <sipmanagedprofile.h>
    19 
    22 
    20 #include "mussipprofilemodel.h"
    23 #include "mussipprofilemodel.h"
    21 #include "muslogger.h"
    24 #include "muslogger.h"
    22 #include <aknnotewrappers.h>
    25 #include "mussettings.inl"
    23 #include <StringLoader.h>
    26 #include "mussettingsmodel.h"
    24 #include <aknview.h>
    27 
    25 #include <sipmanagedprofileregistry.h>
    28 
    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 //
    35 CMusSIPProfileModel::CMusSIPProfileModel()
    39 CMusSIPProfileModel::CMusSIPProfileModel()
    36     {
    40     {
    37     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::CMusSIPProfileModel()" )
    41     }
    38     }
    42 
    39 
    43 // ----------------------------------------------------------------------------
    40 
    44 // 
       
    45 // ----------------------------------------------------------------------------
       
    46 //
    41 void CMusSIPProfileModel::ConstructL()
    47 void CMusSIPProfileModel::ConstructL()
    42     {
    48     {
    43     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ConstructL()" )
    49     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ConstructL()" )
       
    50             
       
    51     MUS_LOG( "[MUSSET]  Creating CSIPManagedProfileRegistry " )
    44     iEngine = CSIPManagedProfileRegistry::NewL( *this );
    52     iEngine = CSIPManagedProfileRegistry::NewL( *this );
    45     ReadArrayFromEngineL();
    53     MUS_LOG( "[MUSSET]  Done " )
    46     }
    54     MUS_LOG( "[MUSSET]  Getting profiles " )
    47 
    55     iEngine->ProfilesL( iProfiles );
    48 
    56     MUS_LOG( "[MUSSET]  Done " )
       
    57     SortProfilesL();
       
    58     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ConstructL()" )
       
    59     }
       
    60 
       
    61 // ----------------------------------------------------------------------------
       
    62 // 
       
    63 // ----------------------------------------------------------------------------
       
    64 //
    49 CMusSIPProfileModel* CMusSIPProfileModel::NewL()
    65 CMusSIPProfileModel* CMusSIPProfileModel::NewL()
    50     {
    66     {
    51     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::NewL()" )
    67     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::NewL()" )
    52     CMusSIPProfileModel* self = new( ELeave ) CMusSIPProfileModel();
    68     CMusSIPProfileModel* self = new( ELeave ) CMusSIPProfileModel();
    53 
    69 
    57 
    73 
    58     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::NewL()" )
    74     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::NewL()" )
    59     return self;
    75     return self;
    60     }
    76     }
    61 
    77 
    62 
    78 // ----------------------------------------------------------------------------
       
    79 // 
       
    80 // ----------------------------------------------------------------------------
       
    81 //
    63 CMusSIPProfileModel::~CMusSIPProfileModel()
    82 CMusSIPProfileModel::~CMusSIPProfileModel()
    64     {
    83     {
    65     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::~CMusSIPProfileModel()" )
    84     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::~CMusSIPProfileModel()" )
    66     DeleteProfiles();
    85     iProfiles.ResetAndDestroy();
    67     delete iEngine;
    86     delete iEngine;
    68     iEngine = NULL;
       
    69     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::~CMusSIPProfileModel()" )
    87     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::~CMusSIPProfileModel()" )
    70     }
    88     }
    71 
    89 
    72 
    90 // ----------------------------------------------------------------------------
    73 // ----------------------------------------------------------------------------
    91 // Returns reference to the locally cached SIP profile array.
    74 // Returns pointer to the locally cached SIP profile array.
    92 // ----------------------------------------------------------------------------
    75 // ----------------------------------------------------------------------------
    93 //
    76 //
    94 RPointerArray<CSIPProfile>& CMusSIPProfileModel::ProfileArrayL()
    77 CArrayPtr<CSIPManagedProfile>* CMusSIPProfileModel::ProfileArrayL()
    95     {
    78     {
    96     MUS_LOG( "[MUSSET] <-> CMusSIPProfileModel::ProfileArrayL()" )
    79     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ProfileArrayL()" )
       
    80     ReadProfileListFromEngineSafeL();
       
    81     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileArrayL()" )
       
    82     return iProfiles;
    97     return iProfiles;
    83     }
    98     }
    84 
       
    85 
    99 
    86 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
    87 // Returns index to the default SIP profile in locally cached array.
   101 // Returns index to the default SIP profile in locally cached array.
    88 // ----------------------------------------------------------------------------
   102 // ----------------------------------------------------------------------------
    89 //
   103 //
    90 TInt CMusSIPProfileModel::DefaultProfileIndex()
   104 TInt CMusSIPProfileModel::DefaultProfileIndex()
    91     {
   105     {
    92     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileIndex()" )
   106     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileIndex()" )
    93     TInt index( KErrNotFound );
   107     TInt index( KErrNotFound );
    94 
   108 
    95     for ( TInt i = 0; i < iProfiles->Count(); i++ )
   109     for ( TInt i = 0; i < iProfiles.Count(); i++ )
    96         {
   110         {
    97         TBool defProfile( EFalse );
   111         TBool defProfile( EFalse );
    98         if (
   112         if (
    99     	    KErrNone ==
   113     	    KErrNone ==
   100     	    iProfiles->At( i )->GetParameter( KSIPDefaultProfile, defProfile )
   114     	    iProfiles[i]->GetParameter( KSIPDefaultProfile, defProfile )
   101     	    && defProfile )
   115     	    && defProfile )
   102             {
   116             {
   103             index = i;
   117             index = i;
   104             break;
   118             break;
   105             }
   119             }
   108     MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileIndex()( %d )",
   122     MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileIndex()( %d )",
   109               index )
   123               index )
   110     return index;
   124     return index;
   111     }
   125     }
   112 
   126 
   113 
       
   114 // ----------------------------------------------------------------------------
   127 // ----------------------------------------------------------------------------
   115 // Returns id of the default SIP profile. If default SIP profile is not found
   128 // Returns id of the default SIP profile. If default SIP profile is not found
   116 // KUnknownProfileId is returned.
   129 // KUnknownProfileId is returned.
   117 // ----------------------------------------------------------------------------
   130 // ----------------------------------------------------------------------------
   118 //
   131 //
   119 TUint32 CMusSIPProfileModel::DefaultProfileId()
   132 TUint32 CMusSIPProfileModel::DefaultProfileId()
   120     {
   133     {
   121     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileId()" )
   134     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::DefaultProfileId()" )
   122     TUint32 id( KUnknownProfileId );
   135     TUint32 id( KUnknownProfileId );
   123 
   136 
   124     for ( TInt i = 0; i < iProfiles->Count(); i++ )
   137     for ( TInt i = 0; i < iProfiles.Count(); i++ )
   125         {
   138         {
   126         TBool defProfile( EFalse );
   139         TBool defProfile( EFalse );
   127         if (
   140         TInt error = iProfiles[i]->GetParameter( KSIPDefaultProfile, defProfile );
   128     	    KErrNone ==
   141         if ( error == KErrNone && defProfile )
   129     	    iProfiles->At( i )->GetParameter( KSIPDefaultProfile, defProfile )
   142             {
   130     	    && defProfile )
   143             iProfiles[i]->GetParameter( KSIPProfileId, id );
   131             {
   144             break;
   132         	iProfiles->At( i )->GetParameter( KSIPProfileId, id );
       
   133         	break;
       
   134             }
   145             }
   135         }
   146         }
   136 
   147 
   137     MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileId()( %d )",
   148     MUS_LOG1( "[MUSSET] <- CMusSIPProfileModel::DefaultProfileId()( %d )",
   138               id )
   149               id )
   139     return id;
   150     return id;
   140     }
   151     }
   141 
   152 
       
   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     }
   142 
   213 
   143 // ----------------------------------------------------------------------------
   214 // ----------------------------------------------------------------------------
   144 // Returns index of the default SIP profile on locally cached array. If default
   215 // Returns index of the default SIP profile on locally cached array. If default
   145 // SIP profile is not found, KErrNotFound is returned.
   216 // SIP profile is not found, KErrNotFound is returned.
   146 // ----------------------------------------------------------------------------
   217 // ----------------------------------------------------------------------------
   147 //
   218 //
   148 TInt CMusSIPProfileModel::ProfileIndexByIdL( TUint32 aId )
   219 TInt CMusSIPProfileModel::ProfileIndexByIdL( TUint32 aId )
   149     {
   220     {
   150     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ProfileIndexByIdL()" )
   221     MUS_LOG( "[MUSSET] -> CMusSIPProfileModel::ProfileIndexByIdL()" )
   151     TInt index( KErrNotFound );
   222     TInt index( KErrNotFound );
   152 
   223     
   153 	ReadProfileListFromEngineSafeL();
   224     for ( TInt i = 0; i < iProfiles.Count(); i++ )
   154     for ( TInt i = 0; i < iProfiles->Count(); i++ )
       
   155         {
   225         {
   156         TUint32 id( KUnknownProfileId );
   226         TUint32 id( KUnknownProfileId );
   157 
   227         TInt error = iProfiles[i]->GetParameter( KSIPProfileId, id );
   158         if ( KErrNone == iProfiles->At( i )->GetParameter( KSIPProfileId, id )
   228         if ( error == KErrNone && id == aId )
   159             && id == aId )
       
   160             {
   229             {
   161             index = i;
   230             index = i;
   162             break;
   231             break;
   163             }
   232             }
   164         }
   233         }
   176 TUint32 CMusSIPProfileModel::ProfileIdByIndex( TUint aIndex )
   245 TUint32 CMusSIPProfileModel::ProfileIdByIndex( TUint aIndex )
   177     {
   246     {
   178     MUS_LOG1( "[MUSSET] -> CMusSIPProfileModel::ProfileIdByIndex()( %d )",
   247     MUS_LOG1( "[MUSSET] -> CMusSIPProfileModel::ProfileIdByIndex()( %d )",
   179               aIndex )
   248               aIndex )
   180 	TUint32 profileId( KUnknownProfileId );
   249 	TUint32 profileId( KUnknownProfileId );
   181     if ( iProfiles->Count() > aIndex )
   250     if ( aIndex < iProfiles.Count() )
   182         {
   251         {
   183         if ( iProfiles->At( aIndex )->GetParameter(
   252         if ( iProfiles[aIndex]->GetParameter( KSIPProfileId, profileId ) )
   184             KSIPProfileId, profileId ) )
       
   185             {
   253             {
   186             profileId = KUnknownProfileId;
   254             profileId = KUnknownProfileId;
   187             }
   255             }
   188         }
   256         }
   189 
   257 
   190     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileIdByIndex()" )
   258     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileIdByIndex()" )
   191     return profileId;
   259     return profileId;
   192     }
   260     }
   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 
       
   228 
   261 
   229 // ----------------------------------------------------------------------------
   262 // ----------------------------------------------------------------------------
   230 // Sorts internal array of SIP profiles by id. Used algorithm is generally
   263 // Sorts internal array of SIP profiles by id. Used algorithm is generally
   231 // slower than quicksort and selectionsort but very feasible for expected
   264 // slower than quicksort and selectionsort but very feasible for expected
   232 // amount of items to be sorted and complexity vise.
   265 // amount of items to be sorted and complexity vise.
   234 //
   267 //
   235 void CMusSIPProfileModel::SortProfilesL()
   268 void CMusSIPProfileModel::SortProfilesL()
   236     {
   269     {
   237 	TUint32 profileIdFirst( 0 );
   270 	TUint32 profileIdFirst( 0 );
   238 	TUint32 profileIdSecond( 0 );
   271 	TUint32 profileIdSecond( 0 );
   239     for ( TInt a = 0; a < iProfiles->Count() - 1; a++ )
   272     for ( TInt a = 0; a < iProfiles.Count() - 1; a++ )
   240         {
   273         {
   241         for ( TInt b = a + 1; b < iProfiles->Count(); b++ )
   274         for ( TInt b = a + 1; b < iProfiles.Count(); b++ )
   242             {
   275             {
   243             User::LeaveIfError( iProfiles->At( a )->GetParameter(
   276             User::LeaveIfError( iProfiles[a]->GetParameter(
   244             	KSIPProfileId, profileIdFirst ) );
   277             	KSIPProfileId, profileIdFirst ) );
   245     		User::LeaveIfError( iProfiles->At( b )->GetParameter(
   278     		User::LeaveIfError( iProfiles[b]->GetParameter(
   246     			KSIPProfileId, profileIdSecond ) );
   279     			KSIPProfileId, profileIdSecond ) );
   247             if ( profileIdFirst > profileIdSecond )
   280             if ( profileIdFirst > profileIdSecond )
   248                 {
   281                 {
   249                 CSIPManagedProfile* tmp = iProfiles->At( b );
   282                 CSIPProfile* tmp = iProfiles[b];
   250                 iProfiles->At( b ) = iProfiles->At( a );
   283                 iProfiles[b] = iProfiles[a];
   251                 iProfiles->At( a )  = tmp;
   284                 iProfiles[a]  = tmp;
   252                 }
   285                 }
   253             }
   286             }
   254         }
   287         }
   255     }
   288     }
   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 
       
   272 
   289 
   273 // ----------------------------------------------------------------------------
   290 // ----------------------------------------------------------------------------
   274 // From class MSIPProfileRegistryObserver.
   291 // From class MSIPProfileRegistryObserver.
   275 // Notifies of an event in SIP profile registry.
   292 // Notifies of an event in SIP profile registry.
   276 // ----------------------------------------------------------------------------
   293 // ----------------------------------------------------------------------------
   277 //
   294 //
   278 void CMusSIPProfileModel::ProfileRegistryEventOccurred(
   295 void CMusSIPProfileModel::ProfileRegistryEventOccurred(
   279     TUint32 /*aSIPProfileId*/, TEvent /*aEvent*/ )
   296     TUint32 aSIPProfileId, TEvent aEvent )
   280 	{
   297 	{  
       
   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     
   281     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryEventOccurred()" )
   332     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryEventOccurred()" )
   282 	}
   333 	}
   283 
       
   284 
   334 
   285 // ----------------------------------------------------------------------------
   335 // ----------------------------------------------------------------------------
   286 // From class MSIPProfileRegistryObserver.
   336 // From class MSIPProfileRegistryObserver.
   287 // An asynchronous error has occurred related to SIP profile
   337 // An asynchronous error has occurred related to SIP profile
   288 // ----------------------------------------------------------------------------
   338 // ----------------------------------------------------------------------------
   292 	TInt /*aError*/ )
   342 	TInt /*aError*/ )
   293     {
   343     {
   294     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryErrorOccurred()" )
   344     MUS_LOG( "[MUSSET] <- CMusSIPProfileModel::ProfileRegistryErrorOccurred()" )
   295     }
   345     }
   296 
   346 
   297 
   347 // ----------------------------------------------------------------------------
   298 // ----------------------------------------------------------------------------
   348 //Set CMusSettingsModel to handle ProfileRegistry Event.
   299 // Reads SIP profile list from engine; if reading fails, old cached list is
   349 // ----------------------------------------------------------------------------
   300 // kept and returned.
   350 //
   301 // ----------------------------------------------------------------------------
   351 void CMusSIPProfileModel::SetCMusSettingsModel(CMusSettingsModel* aCMusSettingsModel)
   302 //
   352 	{
   303 void CMusSIPProfileModel::ReadProfileListFromEngineSafeL()
   353 	iCMusSettingsModel = aCMusSettingsModel;
   304     {
   354 	}
   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     }