void CleanupArray(TAny* aArray) { CArrayPtrFlat<MEikSrvNotifierBase2>* subjects = static_cast<CArrayPtrFlat<MEikSrvNotifierBase2>*>(aArray); subjects->ResetAndDestroy(); delete subjects; }
// ----------------------------------------------------------------------------- // CSIPSettListSIPProfSetTypeListItem::ResetAndDestroy // For deleting array in case of leave // ----------------------------------------------------------------------------- // void CSIPSettListSIPProfSetTypeListItem::ResetAndDestroy( TAny* aPointerArray ) { __GSLOGSTRING("CSIPSettListSIPProfSetTypeListItem::ResetAndDestroy" ) CArrayPtrFlat<CAknEnumeratedText>* array = static_cast<CArrayPtrFlat<CAknEnumeratedText>*>( aPointerArray ); array->ResetAndDestroy(); delete array; }
//=============================================== // CNSmlDSSettings::CreateXMLProfiles() // // //=============================================== void CNSmlDSSettings::CreateXMLProfilesL(TBool aRestore) { TBool status = TRUE; TInt error = KErrNone; //file server RFs wSession; error = wSession.Connect(); if (error != KErrNone) { return; } RXMLReader DSProfileParser; DSProfileParser.CreateL(); CArrayPtrFlat<CNSmlDSProfile>* customProfileArray = new (ELeave) CArrayPtrFlat<CNSmlDSProfile> (5); CleanupStack::PushL(customProfileArray); CNSmlProfileContentHandler* cb = CNSmlProfileContentHandler::NewL(this ,customProfileArray); CleanupStack::PushL(cb); DSProfileParser.SetContentHandler(cb); DSProfileParser.SetFeature(EXMLValidation, ETrue); DSProfileParser.SetFeature(EXMLValidation, EFalse); DSProfileParser.GetFeature(EXMLBinary, status); DSProfileParser.GetFeature(EXMLValidation, status); status = TRUE; RFile wFile; TInt err =wFile.Open(wSession, Kinfile, EFileRead | EFileShareReadersOnly); if (err != KErrNone) { CleanupStack::PopAndDestroy(2); return; } CleanupClosePushL(wFile); //parse file TRAP(error, DSProfileParser.ParseL(wFile)); if (error != KErrNone) { CleanupStack::PopAndDestroy(3); return; } TInt index; TBuf<150> buf; if(aRestore) { //handling back up-restore for custom profiles CNSmlDSProfileList* profList = new (ELeave) CArrayPtrFlat<CNSmlDSProfileListItem>(1); CleanupStack::PushL(profList); GetAllProfileListL( profList ); for( TInt i = 0 ; i < profList->Count() ; i++ ) { TInt id = profList->At(i)->IntValue( EDSProfileId ); CNSmlDSProfile* prof = ProfileL(id); CleanupStack::PushL( prof ); buf = prof->StrValue(EDSProfileServerId); if (buf.Compare(KEmpty) != 0) { for (index = 0; index < customProfileArray->Count(); index++ ) { if (buf.Compare(customProfileArray->At(index)->StrValue(EDSProfileServerId)) == 0) { DeleteProfileL(id); } } } else { buf = prof->StrValue(EDSProfileServerURL); for (index = 0; index < customProfileArray->Count(); index++ ) { if (buf.Compare(customProfileArray->At(index)->StrValue(EDSProfileServerURL)) == 0) { DeleteProfileL(id); } } } CleanupStack::PopAndDestroy(); // prof } profList->ResetAndDestroy(); CleanupStack::PopAndDestroy(); } //save profiles TBool defaultprofilefound = EFalse; //Set the ProfileID to default WriteRepositoryL( KCRUidDSDefaultProfileInternalKeys, KNsmlDsDefaultProfile, -1 ); for ( index = 0; index < customProfileArray->Count(); index++ ) { if (CheckXMLProfileSettings(customProfileArray ,index)) { customProfileArray->At(index)->SaveL(); if(!defaultprofilefound && customProfileArray->At(index)->IntValue(EDSProfileDefaultProfile)) { //Set the ProfileID to be used as a Default Profile WriteRepositoryL( KCRUidDSDefaultProfileInternalKeys, KNsmlDsDefaultProfile, customProfileArray->At(index)->IntValue(EDSProfileId) ); defaultprofilefound = ETrue; } } } CleanupStack::PopAndDestroy(); // wFile CleanupStack::PopAndDestroy(); // cb customProfileArray->ResetAndDestroy(); CleanupStack::PopAndDestroy(); //customProfileArray }