Revision: 201017 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 11 May 2010 16:35:18 +0300
branchRCL_3
changeset 18 52d91a16fec3
parent 14 de84881f4ac3
child 19 10246e066a50
Revision: 201017 Kit: 201019
XDMEngine/XdmProvisioning/src/xdmprovadapter.cpp
XDMSettingsUI/data/XDMPluginRsc.rss
XDMSettingsUI/inc/XDMPluginSLContainer.h
XDMSettingsUI/inc/XDMPluginSettinglist.h
XDMSettingsUI/src/XDMPlugin.cpp
XDMSettingsUI/src/XDMPluginSLContainer.cpp
XDMSettingsUI/src/XDMPluginSettinglist.cpp
presencefwsimpleadpt/src/simpleplugindata.cpp
presencesettingsui/data/psuigspluginrsc.rss
presencesettingsui/group/psuigsplugin.mmp
presencesettingsui/inc/psuigspluginmodel.h
presencesettingsui/src/psuigsplugin.cpp
presencesettingsui/src/psuigspluginmodel.cpp
simpledatamodeladapter/src/presencepluginconnection.cpp
simpledatamodeladapter/src/presenceplugindata.cpp
simpledatamodeladapter/src/presencepluginpublisher.cpp
simpleengine/xdmrlspres/src/prescondvalidity.cpp
simpleengine/xmlutils/src/simpledocument.cpp
simpleengine/xmlutils/src/simpleelement.cpp
--- a/XDMEngine/XdmProvisioning/src/xdmprovadapter.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/XDMEngine/XdmProvisioning/src/xdmprovadapter.cpp	Tue May 11 16:35:18 2010 +0300
@@ -28,6 +28,8 @@
 #include "xdmprovitem.h"
 #include "xdmprovadapter.h"
 
+// for CleanupResetAndDestroyPushL
+#include <mmf/common/mmfcontrollerpluginresolver.h>
 
 #ifdef _DEBUG
     #include <flogger.h>
@@ -305,6 +307,9 @@
 #ifdef _DEBUG 
     WriteToLog( _L8( "CXdmProvAdapter::GetSavingInfoL" ) );
 #endif    
+
+    CleanupResetAndDestroyPushL( aSavingInfo ); 
+ 
     if ( aIndex < iProvItems.Count() - 1 )
         {
 #ifdef _DEBUG 
@@ -339,7 +344,9 @@
         CleanupStack::Pop( idBuf );                     // >> idBuf
         idBuf = NULL;
         }
-        
+    
+    CleanupStack::Pop( &aSavingInfo ); 
+    
 #ifdef _DEBUG 
     WriteToLog( _L8( "CXdmProvAdapter::GetSavingInfoL done" ) );
 #endif
--- a/XDMSettingsUI/data/XDMPluginRsc.rss	Tue Apr 27 17:03:39 2010 +0300
+++ b/XDMSettingsUI/data/XDMPluginRsc.rss	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -96,7 +96,6 @@
             { 
             command = EGSXDMPluginCmdDelete;
             txt = qtn_xdm_options_delete;
-            flags = EEikMenuItemSpecific;
             },
         MENU_ITEM 
             { 
--- a/XDMSettingsUI/inc/XDMPluginSLContainer.h	Tue Apr 27 17:03:39 2010 +0300
+++ b/XDMSettingsUI/inc/XDMPluginSLContainer.h	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -163,6 +163,12 @@
         * @return TDes reference to current set
         */
         TDes& GetCurrentSetName();
+               
+        /**
+        * Returns ETrue is AP used by XDM settings is in use
+        * @return ETrue if ap in use
+        */
+        TBool SettingsApInUseL(TDesC& aXDMSetName);
         
         
     private: // Most of these methods perform operations using iData
--- a/XDMSettingsUI/inc/XDMPluginSettinglist.h	Tue Apr 27 17:03:39 2010 +0300
+++ b/XDMSettingsUI/inc/XDMPluginSettinglist.h	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -78,6 +78,13 @@
         * otherwise access point name returns here
         */
         void GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint);
+        
+        /**
+        * For checking if access point is in use
+        * @param aAP Access point number as integer
+        * return ETrue if access point is in use
+        */
+        TBool IsAccessPointInUseL(TInt32 aAP);
       
         /**
         * Sets the focus to the first item of the settings list
--- a/XDMSettingsUI/src/XDMPlugin.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/XDMSettingsUI/src/XDMPlugin.cpp	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -42,6 +42,9 @@
 
 
 // Constants
+
+const TInt KMaxNameLength = 255;
+
 _LIT( KGSXDMPluginResourceFileName, "z:\\resource\\XDMPluginRsc.rsc" );
 
 #ifdef __SCALABLE_ICONS
@@ -404,6 +407,35 @@
             aMenuPane->SetItemDimmed(EGSXDMPluginCmdNewExisting, ETrue);
             }
         }
+    
+    if ( iSettingListContainer )
+        {
+        TBool inUse( EFalse );
+        HBufC* currentSetName = iMainListContainer->GetCurrentSetNameLC();
+        TBuf<KMaxNameLength> setName;
+        setName.Copy( currentSetName->Des() );
+        TRAP_IGNORE( inUse = iSettingListContainer->SettingsApInUseL( setName ) );
+        CleanupStack::PopAndDestroy( currentSetName );
+    
+        if ( inUse )
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EGSXDMPluginCmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EGSXDMPluginCmdDelete, EFalse );
+                aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, ETrue);
+                }
+            }
+        else
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EGSXDMPluginCmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EGSXDMPluginCmdDelete, ETrue );
+                aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, EFalse);
+                }
+            }
+        }
     }
 
 // ---------------------------------------------------------
--- a/XDMSettingsUI/src/XDMPluginSLContainer.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/XDMSettingsUI/src/XDMPluginSLContainer.cpp	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -450,6 +450,36 @@
     }
     
 // ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::IsAccessPointInUseL(TDesC& aXDMSetName)
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::SettingsApInUseL(TDesC& aXDMSetName)
+    {
+    TBool inUse( EFalse );   
+    TLex16 myLex;
+    iData->Reset();
+     
+    iData->iSettingName = aXDMSetName;
+    AknTextUtils::ConvertDigitsTo(iData->iSettingName, EDigitTypeWestern );    
+    iData->iSettingId = GetSettingIdL(iData->iSettingName);
+       
+    CXdmSettingsCollection* xDMSet = NULL;
+       
+    // read the source setting
+    xDMSet = TXdmSettingsApi::SettingsCollectionL(iData->iSettingId);
+    CleanupStack::PushL(xDMSet);
+    iData->iAccessPointDes = xDMSet->Property(EXdmPropToNapId);
+    myLex.Assign(iData->iAccessPointDes);
+    myLex.Val(iData->iAccessPoint);
+    CleanupStack::PopAndDestroy(xDMSet);
+    
+    inUse = iSettingList->IsAccessPointInUseL( iData->iAccessPoint );
+    iData->Reset();
+	
+    return inUse;
+    }
+
+// ---------------------------------------------------------------------------
 // CXDMPluginSLContainer::SetTitlePaneTextL( const TDesC& aTitleText ) const
 // ---------------------------------------------------------------------------
 //
@@ -476,6 +506,7 @@
         {
         return ETrue;
         }
+    
     return EFalse;   
     }
     
--- a/XDMSettingsUI/src/XDMPluginSettinglist.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/XDMSettingsUI/src/XDMPluginSettinglist.cpp	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -289,6 +289,27 @@
     }
 
 // -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::IsAccessPointInUseL(TInt32 aAP)
+// -----------------------------------------------------------------------------
+// 
+TBool CXDMPluginSettinglist::IsAccessPointInUseL(TInt32 aAP)
+    {
+    TBool inUse( EFalse );
+    
+    CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
+    CleanupStack::PushL(commsDb);
+    CApUtils* aPUtils = CApUtils::NewLC( *commsDb );
+    TInt err(KErrNone);
+    // to remove id bug
+    TRAP(err, aAP = aPUtils->WapIdFromIapIdL(aAP)); 
+    inUse = aPUtils->IsAPInUseL( aAP );   
+    // dont do anything if name not found or if some error occur
+    CleanupStack::PopAndDestroy(2); // commsDb, aPUtils
+    
+    return inUse;
+    }
+
+// -----------------------------------------------------------------------------
 // CXDMPluginSettinglist::SetTitlePaneTextL( const TDesC& aTitleText ) const
 // -----------------------------------------------------------------------------
 // 
--- a/presencefwsimpleadpt/src/simpleplugindata.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/presencefwsimpleadpt/src/simpleplugindata.cpp	Tue May 11 16:35:18 2010 +0300
@@ -531,7 +531,7 @@
     for ( TInt i = 0; i < count; i++ )
         {
         MPresenceInfo* info = aPresenceFactory.NewPresenceInfoLC();   // << info
-        aEntities.Append( info );
+        aEntities.AppendL( info );
         // aEntities may contain entries even this method leaves
         CleanupStack::Pop();                                      // >> info
 
@@ -539,7 +539,7 @@
 
         // Add SIP identity to active users list
         MXIMPIdentity* active = aFactory.NewIdentityLC();  // << active
-        aActives.Append( active );
+        aActives.AppendL( active );
         CleanupStack::Pop();                            // >> active
 
         // Convert SIP entity URI from UTF to Unicode.
@@ -731,7 +731,7 @@
             {
             // Add presentity into terminated list
             MXIMPIdentity* terminated = aFactory.NewIdentityLC();  // +terminated
-            aTerminated.Append( terminated );
+            aTerminated.AppendL( terminated );
             CleanupStack::Pop();                   // -terminated
 
             // Convert SIP entity URI from UTF to Unicode.
--- a/presencesettingsui/data/psuigspluginrsc.rss	Tue Apr 27 17:03:39 2010 +0300
+++ b/presencesettingsui/data/psuigspluginrsc.rss	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -91,7 +91,6 @@
             {
             command = EPSUICmdDelete;
             txt = qtn_presence_settings_delete;
-            flags = EEikMenuItemSpecific;
             },
         MENU_ITEM 
             { 
--- a/presencesettingsui/group/psuigsplugin.mmp	Tue Apr 27 17:03:39 2010 +0300
+++ b/presencesettingsui/group/psuigsplugin.mmp	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -74,5 +74,6 @@
 LIBRARY             inetprotutil.lib
 LIBRARY             xdmsettingsapi.lib
 LIBRARY             presencesettingsapi.lib
+LIBRARY             serviceprovidersettings.lib
 
 // End of File
--- a/presencesettingsui/inc/psuigspluginmodel.h	Tue Apr 27 17:03:39 2010 +0300
+++ b/presencesettingsui/inc/psuigspluginmodel.h	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -217,6 +217,14 @@
         */        
         HBufC* SipProfileNameL( TInt aId );
         
+	    /**
+        * Checks if SIP profile used by presence settings is in use
+        *
+        * @param aIndex is the index in the array
+        * @return ETrue if profile is registered
+        */    
+        TBool IsSipProfileRegisteredL( TInt aIndex );
+        
         //
         //
         // XDM related
@@ -280,8 +288,16 @@
         * Re-arranges presence settings (name and id arrays) 
         * to alphabetical order.
         */
-        void ReArrangePresenceSettingsL();            
-
+        void ReArrangePresenceSettingsL();   
+        
+        /** 
+        * Cleans links to specific presence settings for 
+        * service provider settings.
+        * 
+        * @param aPresenceId presence settings id.
+        */
+        void CleanServiceProviderSettingsDataL( TInt aPresenceId );
+             
     private: // Functions from base classes
 
         /** 
--- a/presencesettingsui/src/psuigsplugin.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/presencesettingsui/src/psuigsplugin.cpp	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -398,6 +398,33 @@
         {
         aMenuPane->DeleteMenuItem( EAknCmdHelp );
         }
+    
+    TInt index( KErrNotFound );
+    SettingCountAndIndex( index );
+    
+    if ( KErrNotFound < index )
+        {
+        // Hide delete option if sip profile used with presence settings
+        // is registered.
+        if ( iPSModel->IsSipProfileRegisteredL( index ) )
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EPSUICmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EPSUICmdDelete, EFalse );
+                aMenuPane->SetItemDimmed( EPSUICmdDelete, ETrue );
+                }
+            }
+        else
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EPSUICmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EPSUICmdDelete, ETrue );
+                aMenuPane->SetItemDimmed( EPSUICmdDelete, EFalse );
+                }
+            }
+        }
     }
 
 // ---------------------------------------------------------------------------
--- a/presencesettingsui/src/psuigspluginmodel.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/presencesettingsui/src/psuigspluginmodel.cpp	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -27,6 +27,10 @@
 #include <StringLoader.h>
 #include <psuigspluginrsc.rsg>
 #include <XdmSettingsApi.h>
+#include <spentry.h>
+#include <spproperty.h>
+#include <spsettings.h>
+
 #include "psuigspluginmodel.h"
 
 // ========================= MEMBER FUNCTIONS ================================
@@ -71,6 +75,7 @@
 void CPSUIGSPluginModel::ConstructL()
     {
     RetrieveSettingsL();
+    ReadSipArrayFromEngineL();
     iVisibleSettingName = HBufC::NewL( 
         KPresSetNameMaxLength + 2 );// max chars + KColumnListSeparator
     }
@@ -244,10 +249,12 @@
         __ASSERT_DEBUG( aToBeDeleted < iPSIdArray.Count() ,
             User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
         PresSettingsApi::RemoveSetL( iPSIdArray[ aToBeDeleted ]);
+        CleanServiceProviderSettingsDataL( iPSIdArray[ aToBeDeleted ] );
         }
     else
         {// is id
         PresSettingsApi::RemoveSetL( aToBeDeleted );
+        CleanServiceProviderSettingsDataL( aToBeDeleted );
         }
     RefreshPSArraysL();
     }
@@ -318,6 +325,94 @@
     }
 
 // ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::CleanServiceProviderSettingsDataL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPluginModel::CleanServiceProviderSettingsDataL( TInt aPresenceId )
+    {
+    CSPSettings* spSettings = CSPSettings::NewLC();
+    
+    RArray<TUint> serviceIds; 
+    CleanupClosePushL( serviceIds );
+    spSettings->FindServiceIdsL( serviceIds );
+	
+    for ( TInt i( 0 ) ; i < serviceIds.Count() ; i++ )
+        {
+        CSPEntry* spEntry = CSPEntry::NewLC(); 
+        CSPProperty* property1 = CSPProperty::NewLC();
+
+        TInt err = spSettings->FindPropertyL( 
+            serviceIds[ i ],
+            ESubPropertyPresenceSettingsId,
+            *property1 );
+
+        if ( KErrNone == err )
+            {           
+            User::LeaveIfError(
+                spSettings->FindEntryL( serviceIds[ i ], *spEntry ) );
+				
+            TInt presenceId( 0 );
+            User::LeaveIfError( property1->GetValue( presenceId ) );
+			
+            if ( presenceId == aPresenceId )
+                {
+                // Delete all presence related properties from services which
+                // has this presence id (ESubPropertyPresenceSettingsId).                  
+                RPropertyNameArray propertyNameArray;
+                CleanupClosePushL( propertyNameArray );
+                RPropertyNameArray propertyNameArrayToBeDeleted;
+                CleanupClosePushL( propertyNameArrayToBeDeleted );
+                
+                // presence properties to be removed if found
+                propertyNameArray.Append( EPropertyPCSPluginId );
+                propertyNameArray.Append( EPropertyPresenceSubServicePluginId );
+                propertyNameArray.Append( ESubPropertyPresenceSettingsId );
+                propertyNameArray.Append( ESubPropertyPresencePreferredSNAPId );
+                propertyNameArray.Append( ESubPropertyPresencePreferredIAPId );
+                propertyNameArray.Append( ESubPropertyPresencePresentityIDFieldType );
+                propertyNameArray.Append( ESubPropertyPresenceLaunchMethod );
+                propertyNameArray.Append( ESubPropertyPresenceLaunchUid );
+                propertyNameArray.Append( ESubPropertyPresenceAddrScheme );
+                propertyNameArray.Append( ESubPropertyPresenceEnabled );
+                propertyNameArray.Append( ESubPropertyPresenceRequestPreference );
+
+                for ( TInt j( 0 ) ; j < propertyNameArray.Count() ; j++ )
+                    {
+                    CSPProperty* property2 = CSPProperty::NewLC();
+                
+                    TInt err = spSettings->FindPropertyL( 
+                        serviceIds[ i ],
+                        propertyNameArray[ j ],
+                        *property2 );
+						
+                    // if property found add to be deleted array
+                    if ( !err )
+                        {
+                        propertyNameArrayToBeDeleted.Append( 
+                            propertyNameArray[ j ] );
+                        }
+                        
+                    CleanupStack::PopAndDestroy( property2 ); 
+                    }
+                
+                spSettings->DeleteServicePropertiesL( 
+                    serviceIds[ i ], propertyNameArrayToBeDeleted );
+
+                CleanupStack::PopAndDestroy( &propertyNameArrayToBeDeleted );
+                CleanupStack::PopAndDestroy( &propertyNameArray );
+                }
+            }
+        
+        CleanupStack::PopAndDestroy( property1 );
+        CleanupStack::PopAndDestroy( spEntry );
+        }
+    
+    CleanupStack::PopAndDestroy( &serviceIds );
+    CleanupStack::PopAndDestroy( spSettings );
+    }
+
+// ---------------------------------------------------------------------------
 // CPSUIGSPluginModel::MdcaCount()
 // See header for details.
 // ---------------------------------------------------------------------------
@@ -591,6 +686,32 @@
         }
     return HBufC::NewL( 0 );// name not found
     }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::IsSipProfileRegisteredL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TBool CPSUIGSPluginModel::IsSipProfileRegisteredL( TInt aIndex )
+    {
+    TBool registered( EFalse );  
+    TInt sipProfileId = SipProfileId( aIndex );
+    const TInt arrayCount = iSIPProfiles->Count();
+	
+    for ( TInt i = 0; i < arrayCount; i++ )
+        {
+        TUint32 tempValue;
+        iSIPProfiles->At( i )->GetParameter( KSIPProfileId, tempValue );
+		
+        if ( tempValue == sipProfileId )
+            {
+            iSIPProfiles->At( i )->GetParameter( 
+                KSIPProfileRegistered, registered );
+            }
+        }
+		
+    return registered;
+    }
  
 // ---------------------------------------------------------------------------
 // CPSUIGSPluginModel::ReadSipArrayFromEngineL()
--- a/simpledatamodeladapter/src/presencepluginconnection.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/simpledatamodeladapter/src/presencepluginconnection.cpp	Tue May 11 16:35:18 2010 +0300
@@ -108,7 +108,7 @@
     const TDesC8& aETag )
     {
     DP_SDA("CPresencePluginConnection::ConstructL loaded");
-     
+    
     iETag = aETag.AllocL();                  
     
     iSession = CPresencePluginSession::NewL( aServiceInfo, *this );
@@ -196,6 +196,8 @@
     {
     DP_SDA("CPresencePluginConnection::~CPresencePluginConnection");
     
+    Cancel();
+    
     delete iSipPresentity;
     iSipPresentity = NULL;
     
@@ -876,16 +878,17 @@
     }
 
 // ---------------------------------------------------------------------------
-// CPresencePluginPublisher::DoCancel()
+// CPresencePluginConnection::DoCancel()
 // ---------------------------------------------------------------------------
 //
 void CPresencePluginConnection::DoCancel(  )
     {
     DP_SDA("CPresencePluginConnection::DoCancel CANCEL");
+    iPublisher->Cancel();
     }
 
 // ---------------------------------------------------------------------------
-// CPresencePluginSession::RunL()
+// CPresencePluginConnection::RunL()
 // ---------------------------------------------------------------------------
 //
 void CPresencePluginConnection::RunL(  )
@@ -910,7 +913,7 @@
     }
 
 // ---------------------------------------------------------------------------
-// CPresencePluginSession::RunError
+// CPresencePluginConnection::RunError
 // ---------------------------------------------------------------------------
 //
 TInt CPresencePluginConnection::RunError( TInt /*aError*/ )
--- a/simpledatamodeladapter/src/presenceplugindata.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/simpledatamodeladapter/src/presenceplugindata.cpp	Tue May 11 16:35:18 2010 +0300
@@ -800,14 +800,14 @@
         {
         MPresenceInfo* info =
             aPresenceFactory.NewPresenceInfoLC();//<< info
-        aEntities.Append( info );
+        aEntities.AppendL( info );
         // aEntities may contain entries even this method leaves
         CleanupStack::Pop();// >> info
 
         NotifyToPrInfoL( aFactory, aPresenceFactory, *docs[i], *info );
         // Add SIp identity to active users list
         MXIMPIdentity* active = aFactory.NewIdentityLC();// << active
-        aActives.Append( active );
+        aActives.AppendL( active );
         CleanupStack::Pop();// >> active
 
         // Convert SIP entity URI from UTF to Unicode.
@@ -863,7 +863,7 @@
                         const TDesC8* uri8 = elem2->AttrValue( KPresenceUri8 );
                         MXIMPIdentity* terminated =
                             aFactory.NewIdentityLC();// << terminated
-                        aTerminated.Append( terminated );
+                        aTerminated.AppendL( terminated );
                         CleanupStack::Pop();                   // >> terminated
 
                         // Convert SIP entity URI from UTF to Unicode.
--- a/simpledatamodeladapter/src/presencepluginpublisher.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/simpledatamodeladapter/src/presencepluginpublisher.cpp	Tue May 11 16:35:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -123,6 +123,7 @@
         }
          
     DeleteWatchers();
+    iClientStatus = NULL;
     }
 
 // ---------------------------------------------------------------------------
@@ -575,6 +576,7 @@
     DP_SDA("CPresencePluginPublisher::DoCancel CANCEL");
     iXdmUtils->Cancel();
     iPublisher->Close();
+    iPublisher = NULL;
     }
 
 // ---------------------------------------------------------------------------
--- a/simpleengine/xdmrlspres/src/prescondvalidity.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/simpleengine/xdmrlspres/src/prescondvalidity.cpp	Tue May 11 16:35:18 2010 +0300
@@ -61,6 +61,8 @@
     OPENG_DP(D_OPENG_LIT( "TPresCondValidity::GetValidity()" ) );
     OPENG_DP(D_OPENG_LIT( "     aRuleID = %S"),&aRuleID);
 
+    CleanupClosePushL (aValidTimes);
+    
 	CXdmDocumentNode* validityNode = GetValidityNodeL(aRuleID, EFalse);
 	if(validityNode==NULL)
 	    return KErrNotFound;
@@ -99,7 +101,7 @@
 
 	for(TInt i=0; i<nodeCount; i++)
 	    {
-        aValidTimes.Append(myTimePeriod);
+        aValidTimes.AppendL(myTimePeriod);
 
 	    // processing from
 	    (fromNodes[i])->SetLeafNode(ETrue);
@@ -134,6 +136,8 @@
 	    
     fromNodes.Close();
     untilNodes.Close();
+    
+    CleanupStack::Pop();
 	return KErrNone;
 	}
 
--- a/simpleengine/xmlutils/src/simpledocument.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/simpleengine/xmlutils/src/simpledocument.cpp	Tue May 11 16:35:18 2010 +0300
@@ -196,12 +196,14 @@
 void CSimpleDocument::GetDirectContentsL( 
     RPointerArray<MSimpleContent>& aContents )
     {
+    CleanupClosePushL( aContents ); 
     aContents.Reset();
     TInt myCount = iContents.Count();
     for ( TInt i = 0; i<myCount; i++ )
         {
-        User::LeaveIfError( aContents.Append( iContents[i] ));
-        }               
+        aContents.AppendL( iContents[i] );
+        }
+    CleanupStack::Pop( &aContents );
     }
     
 // ----------------------------------------------------------
@@ -653,7 +655,7 @@
     // Let's convert first ROOT element into CBodyPart
     CBodyPart* root = CBodyPart::NewL();
     // Add into cleanup array
-    aBodies.Append( root );     
+    aBodies.AppendL( root );     
     CSenElement* e = Root()->BaseElement();
     
     // externalize the document into stream
@@ -676,7 +678,7 @@
     // calculate the size of headers
     TInt headerSize = KContentTypeSize + KCIDSize;
     HBufC8* headers = HBufC8::NewL( headerSize );  
-    aBuffers.Append( headers );
+    aBuffers.AppendL( headers );
     TPtr8 pH(headers->Des());
     // append to MIME headers for the root part   
     pH.Append( NSimpleDocument::NSimpleRoot::KContentType );
@@ -689,7 +691,7 @@
         { 
         // Let's convert next element into CBodyPart
         CBodyPart* cp = CBodyPart::NewL();
-        aBodies.Append( cp );                
+        aBodies.AppendL( cp );                
          
         // Set Headers
         headerSize = NSimpleDocument::NSimpleContent::KContentTypeSize + 
@@ -700,7 +702,7 @@
         
         headers = HBufC8::NewL( headerSize );
         // Append to cleanup array  
-        aBuffers.Append( headers );
+        aBuffers.AppendL( headers );
         pH.Set( headers->Des() );
 
         // _LIT8( KMyContentType, "Content-Type: %S\r\n"); 
@@ -716,7 +718,7 @@
                     
         // BASE64 encode
         HBufC8* body64 = HBufC8::NewL( (iContents[i])->Body().Length() * KB64Expand );  
-        aBuffers.Append( body64 );        
+        aBuffers.AppendL( body64 );        
         TImCodecB64 codec64;
         codec64.Initialise();        
         TPtr8 desti8 = body64->Des();  
--- a/simpleengine/xmlutils/src/simpleelement.cpp	Tue Apr 27 17:03:39 2010 +0300
+++ b/simpleengine/xmlutils/src/simpleelement.cpp	Tue May 11 16:35:18 2010 +0300
@@ -221,6 +221,7 @@
 TInt CSimpleElement::SimpleElementsL( 
     RPointerArray<MSimpleElement>& aElementArray )
     {
+    CleanupClosePushL( aElementArray );
     // Reset the output array first.
     aElementArray.Reset();
     iElements.ResetAndDestroy();
@@ -234,10 +235,12 @@
         CSenElement* pElement = elems[i];
         CSimpleElement* simple = CSimpleElement::NewL( pElement, EFalse );
         CleanupStack::PushL( simple );
-        User::LeaveIfError( aElementArray.Append( simple ));
+        iElements.AppendL( simple );
         CleanupStack::Pop( simple );
-        User::LeaveIfError( iElements.Append( simple ) );
+        aElementArray.AppendL( simple );
         }
+    CleanupStack::Pop( &aElementArray ); 
+    
     return elemCount ? KErrNone : KErrNotFound;
     }
 
@@ -292,6 +295,8 @@
 //
 TInt CSimpleElement::SimpleAttributesL( RPointerArray<MSimpleAttribute>& aArray )
     {  
+    CleanupClosePushL( aArray );
+    
     // Reset the output array first.
     aArray.Reset();
     iAttributes.ResetAndDestroy();
@@ -304,10 +309,12 @@
         CSenBaseAttribute* pAttr = elems[i];
         CSimpleAttribute* attr = CSimpleAttribute::NewL( pAttr );
         CleanupStack::PushL( attr );
-        User::LeaveIfError(iAttributes.Append( attr ));
+        iAttributes.AppendL( attr );
         CleanupStack::Pop( attr );        
-        User::LeaveIfError(aArray.Append( attr ));
+        aArray.AppendL( attr );
         }
+    CleanupStack::Pop( &aArray );
+    
     return elemCount ? KErrNone : KErrNotFound;
     }