presencesettingsui/src/psuigspluginmodel.cpp
branchRCL_3
changeset 18 52d91a16fec3
parent 0 c8caa15ef882
equal deleted inserted replaced
14:de84881f4ac3 18:52d91a16fec3
     1 /*
     1 /*
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    25 #include <sipmanagedprofile.h>
    25 #include <sipmanagedprofile.h>
    26 #include <sipprofile.h>
    26 #include <sipprofile.h>
    27 #include <StringLoader.h>
    27 #include <StringLoader.h>
    28 #include <psuigspluginrsc.rsg>
    28 #include <psuigspluginrsc.rsg>
    29 #include <XdmSettingsApi.h>
    29 #include <XdmSettingsApi.h>
       
    30 #include <spentry.h>
       
    31 #include <spproperty.h>
       
    32 #include <spsettings.h>
       
    33 
    30 #include "psuigspluginmodel.h"
    34 #include "psuigspluginmodel.h"
    31 
    35 
    32 // ========================= MEMBER FUNCTIONS ================================
    36 // ========================= MEMBER FUNCTIONS ================================
    33 
    37 
    34 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    69 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    70 //
    74 //
    71 void CPSUIGSPluginModel::ConstructL()
    75 void CPSUIGSPluginModel::ConstructL()
    72     {
    76     {
    73     RetrieveSettingsL();
    77     RetrieveSettingsL();
       
    78     ReadSipArrayFromEngineL();
    74     iVisibleSettingName = HBufC::NewL( 
    79     iVisibleSettingName = HBufC::NewL( 
    75         KPresSetNameMaxLength + 2 );// max chars + KColumnListSeparator
    80         KPresSetNameMaxLength + 2 );// max chars + KColumnListSeparator
    76     }
    81     }
    77 
    82 
    78 // ---------------------------------------------------------------------------
    83 // ---------------------------------------------------------------------------
   242     if ( aIsIndex )
   247     if ( aIsIndex )
   243         {// is index
   248         {// is index
   244         __ASSERT_DEBUG( aToBeDeleted < iPSIdArray.Count() ,
   249         __ASSERT_DEBUG( aToBeDeleted < iPSIdArray.Count() ,
   245             User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
   250             User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
   246         PresSettingsApi::RemoveSetL( iPSIdArray[ aToBeDeleted ]);
   251         PresSettingsApi::RemoveSetL( iPSIdArray[ aToBeDeleted ]);
       
   252         CleanServiceProviderSettingsDataL( iPSIdArray[ aToBeDeleted ] );
   247         }
   253         }
   248     else
   254     else
   249         {// is id
   255         {// is id
   250         PresSettingsApi::RemoveSetL( aToBeDeleted );
   256         PresSettingsApi::RemoveSetL( aToBeDeleted );
       
   257         CleanServiceProviderSettingsDataL( aToBeDeleted );
   251         }
   258         }
   252     RefreshPSArraysL();
   259     RefreshPSArraysL();
   253     }
   260     }
   254 
   261 
   255 // ---------------------------------------------------------------------------
   262 // ---------------------------------------------------------------------------
   313                 break;// no need to go through if already found
   320                 break;// no need to go through if already found
   314                 }
   321                 }
   315             }
   322             }
   316         }
   323         }
   317     CleanupStack::PopAndDestroy( &pairArray );
   324     CleanupStack::PopAndDestroy( &pairArray );
       
   325     }
       
   326 
       
   327 // ---------------------------------------------------------------------------
       
   328 // CPSUIGSPluginModel::CleanServiceProviderSettingsDataL()
       
   329 // See header for details.
       
   330 // ---------------------------------------------------------------------------
       
   331 // 
       
   332 void CPSUIGSPluginModel::CleanServiceProviderSettingsDataL( TInt aPresenceId )
       
   333     {
       
   334     CSPSettings* spSettings = CSPSettings::NewLC();
       
   335     
       
   336     RArray<TUint> serviceIds; 
       
   337     CleanupClosePushL( serviceIds );
       
   338     spSettings->FindServiceIdsL( serviceIds );
       
   339 	
       
   340     for ( TInt i( 0 ) ; i < serviceIds.Count() ; i++ )
       
   341         {
       
   342         CSPEntry* spEntry = CSPEntry::NewLC(); 
       
   343         CSPProperty* property1 = CSPProperty::NewLC();
       
   344 
       
   345         TInt err = spSettings->FindPropertyL( 
       
   346             serviceIds[ i ],
       
   347             ESubPropertyPresenceSettingsId,
       
   348             *property1 );
       
   349 
       
   350         if ( KErrNone == err )
       
   351             {           
       
   352             User::LeaveIfError(
       
   353                 spSettings->FindEntryL( serviceIds[ i ], *spEntry ) );
       
   354 				
       
   355             TInt presenceId( 0 );
       
   356             User::LeaveIfError( property1->GetValue( presenceId ) );
       
   357 			
       
   358             if ( presenceId == aPresenceId )
       
   359                 {
       
   360                 // Delete all presence related properties from services which
       
   361                 // has this presence id (ESubPropertyPresenceSettingsId).                  
       
   362                 RPropertyNameArray propertyNameArray;
       
   363                 CleanupClosePushL( propertyNameArray );
       
   364                 RPropertyNameArray propertyNameArrayToBeDeleted;
       
   365                 CleanupClosePushL( propertyNameArrayToBeDeleted );
       
   366                 
       
   367                 // presence properties to be removed if found
       
   368                 propertyNameArray.Append( EPropertyPCSPluginId );
       
   369                 propertyNameArray.Append( EPropertyPresenceSubServicePluginId );
       
   370                 propertyNameArray.Append( ESubPropertyPresenceSettingsId );
       
   371                 propertyNameArray.Append( ESubPropertyPresencePreferredSNAPId );
       
   372                 propertyNameArray.Append( ESubPropertyPresencePreferredIAPId );
       
   373                 propertyNameArray.Append( ESubPropertyPresencePresentityIDFieldType );
       
   374                 propertyNameArray.Append( ESubPropertyPresenceLaunchMethod );
       
   375                 propertyNameArray.Append( ESubPropertyPresenceLaunchUid );
       
   376                 propertyNameArray.Append( ESubPropertyPresenceAddrScheme );
       
   377                 propertyNameArray.Append( ESubPropertyPresenceEnabled );
       
   378                 propertyNameArray.Append( ESubPropertyPresenceRequestPreference );
       
   379 
       
   380                 for ( TInt j( 0 ) ; j < propertyNameArray.Count() ; j++ )
       
   381                     {
       
   382                     CSPProperty* property2 = CSPProperty::NewLC();
       
   383                 
       
   384                     TInt err = spSettings->FindPropertyL( 
       
   385                         serviceIds[ i ],
       
   386                         propertyNameArray[ j ],
       
   387                         *property2 );
       
   388 						
       
   389                     // if property found add to be deleted array
       
   390                     if ( !err )
       
   391                         {
       
   392                         propertyNameArrayToBeDeleted.Append( 
       
   393                             propertyNameArray[ j ] );
       
   394                         }
       
   395                         
       
   396                     CleanupStack::PopAndDestroy( property2 ); 
       
   397                     }
       
   398                 
       
   399                 spSettings->DeleteServicePropertiesL( 
       
   400                     serviceIds[ i ], propertyNameArrayToBeDeleted );
       
   401 
       
   402                 CleanupStack::PopAndDestroy( &propertyNameArrayToBeDeleted );
       
   403                 CleanupStack::PopAndDestroy( &propertyNameArray );
       
   404                 }
       
   405             }
       
   406         
       
   407         CleanupStack::PopAndDestroy( property1 );
       
   408         CleanupStack::PopAndDestroy( spEntry );
       
   409         }
       
   410     
       
   411     CleanupStack::PopAndDestroy( &serviceIds );
       
   412     CleanupStack::PopAndDestroy( spSettings );
   318     }
   413     }
   319 
   414 
   320 // ---------------------------------------------------------------------------
   415 // ---------------------------------------------------------------------------
   321 // CPSUIGSPluginModel::MdcaCount()
   416 // CPSUIGSPluginModel::MdcaCount()
   322 // See header for details.
   417 // See header for details.
   589             return EscapeUtils::ConvertToUnicodeFromUtf8L( *profileName );// name found
   684             return EscapeUtils::ConvertToUnicodeFromUtf8L( *profileName );// name found
   590             }
   685             }
   591         }
   686         }
   592     return HBufC::NewL( 0 );// name not found
   687     return HBufC::NewL( 0 );// name not found
   593     }
   688     }
       
   689 
       
   690 // ---------------------------------------------------------------------------
       
   691 // CPSUIGSPluginModel::IsSipProfileRegisteredL()
       
   692 // See header for details.
       
   693 // ---------------------------------------------------------------------------
       
   694 // 
       
   695 TBool CPSUIGSPluginModel::IsSipProfileRegisteredL( TInt aIndex )
       
   696     {
       
   697     TBool registered( EFalse );  
       
   698     TInt sipProfileId = SipProfileId( aIndex );
       
   699     const TInt arrayCount = iSIPProfiles->Count();
       
   700 	
       
   701     for ( TInt i = 0; i < arrayCount; i++ )
       
   702         {
       
   703         TUint32 tempValue;
       
   704         iSIPProfiles->At( i )->GetParameter( KSIPProfileId, tempValue );
       
   705 		
       
   706         if ( tempValue == sipProfileId )
       
   707             {
       
   708             iSIPProfiles->At( i )->GetParameter( 
       
   709                 KSIPProfileRegistered, registered );
       
   710             }
       
   711         }
       
   712 		
       
   713     return registered;
       
   714     }
   594  
   715  
   595 // ---------------------------------------------------------------------------
   716 // ---------------------------------------------------------------------------
   596 // CPSUIGSPluginModel::ReadSipArrayFromEngineL()
   717 // CPSUIGSPluginModel::ReadSipArrayFromEngineL()
   597 // See header for details.
   718 // See header for details.
   598 // ---------------------------------------------------------------------------
   719 // ---------------------------------------------------------------------------