pimappservices/calendar/tsrc/tcal_filechangenotification.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "caltestlib.h"
       
    17 #include <calentry.h>
       
    18 #include <calsession.h>
       
    19 #include <calentryview.h>
       
    20 #include <e32test.h>
       
    21 #include <calchangecallback.h>
       
    22 #include <calfilechangenotification.h>
       
    23 #include <calrrule.h>
       
    24 #include <calcalendarinfo.h>
       
    25 
       
    26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    27 #include <tzusernames.h>
       
    28 #include <tzuserdefineddata.h>
       
    29 #endif
       
    30 
       
    31 _LIT(KTestName,"tcal_filechangenotification");
       
    32 RTest test(KTestName);
       
    33 _LIT(KTestFileName,"c:tcal_filechangenotification");
       
    34 
       
    35 
       
    36 class CCalFileChangeNotificationTest : public CBase, MCalChangeCallBack2, MCalFileChangeObserver
       
    37     {
       
    38 public:
       
    39     static CCalFileChangeNotificationTest* NewLC();
       
    40     ~CCalFileChangeNotificationTest();
       
    41     
       
    42     // from MCalChangeCallBack2
       
    43     void CalendarInfoChangeNotificationL(RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries);
       
    44 
       
    45     // from MCalChangeCallBack2
       
    46     void CalChangeNotification(RArray<TCalChangeEntry>& aChangeItems);
       
    47     //Test tasks
       
    48     void TestFileCreatedL();
       
    49     void TestFileDeletedL();
       
    50     void TestFileChangeWithCalendarInfoL();
       
    51     void TestUpdateCalendarInfoL();
       
    52     void TestMixedNotificationL();
       
    53  
       
    54 private: 
       
    55     CCalFileChangeNotificationTest();
       
    56     void ConstructL();
       
    57     
       
    58     TCalLocalUid StoreEntryL();
       
    59     void RegisterEntryNotificationL();
       
    60     TBool CompareFileNotification(RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries);
       
    61     TBool CompareEntryNotification(RArray<TCalChangeEntry>& aChangeItems);
       
    62   
       
    63 private:
       
    64     TBool               iNotificationCallBackOccurred;
       
    65     TBool               iFileNotificationCallBackOccurred;
       
    66     CCalTestLibrary*    iTestLib;
       
    67     CCalSession*        iOtherSession;//It does the change such as create file, add calendar info...
       
    68     RArray<MCalFileChangeObserver::TChangeType> iExpectedCalendarInfoTypes;
       
    69     RArray<TCalChangeEntry> iExpectedEntryChange;
       
    70     };
       
    71 
       
    72 CCalFileChangeNotificationTest::CCalFileChangeNotificationTest()
       
    73     :iNotificationCallBackOccurred(EFalse), iFileNotificationCallBackOccurred(EFalse)
       
    74     {
       
    75     }
       
    76 
       
    77 void CCalFileChangeNotificationTest::CalendarInfoChangeNotificationL(RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries)
       
    78     {
       
    79     test.Printf(_L("MCalFileChangeObserver notification happened\n") );
       
    80     iFileNotificationCallBackOccurred = ETrue;
       
    81     
       
    82     test(CompareFileNotification(aCalendarInfoChangeEntries));
       
    83     if(iExpectedCalendarInfoTypes.Count() == 0 && iExpectedEntryChange.Count() == 0)
       
    84         {
       
    85         CActiveScheduler::Stop();
       
    86         }
       
    87     }
       
    88 
       
    89 TBool CCalFileChangeNotificationTest::CompareFileNotification(RPointerArray<CCalFileChangeInfo>& aCalendarInfoChangeEntries)
       
    90     {//return ETrue if all elements in aCalendarInfoChangeEntries are found in the iExpectedCalendarInfoTypes otherwise EFalse.
       
    91     TBool ret = EFalse;
       
    92     const TInt count = aCalendarInfoChangeEntries.Count();
       
    93     TInt jj = 0;
       
    94     do
       
    95         {
       
    96         CCalFileChangeInfo* calFileChangeInfo = aCalendarInfoChangeEntries[jj];
       
    97         ret = EFalse;
       
    98         TInt countExpected = iExpectedCalendarInfoTypes.Count();
       
    99         for(TInt ii = countExpected-1; ii >= 0; --ii)
       
   100             {
       
   101             if(calFileChangeInfo->FileNameL() == KTestFileName() && calFileChangeInfo->ChangeType() == iExpectedCalendarInfoTypes[ii])
       
   102                  {
       
   103                  iExpectedCalendarInfoTypes.Remove(ii);
       
   104                  ret = ETrue;
       
   105                  countExpected = iExpectedCalendarInfoTypes.Count();
       
   106                  break;
       
   107                  }
       
   108             }
       
   109         
       
   110         ++ jj;
       
   111         }while (ret && jj < count);
       
   112             
       
   113     return ret;
       
   114     }
       
   115 
       
   116 TBool CCalFileChangeNotificationTest::CompareEntryNotification(RArray<TCalChangeEntry>& aChangeItems)
       
   117     {//return ETrue if all elements in aChangeItems are found in the iExpectedEntryChange otherwise EFalse.
       
   118     TBool ret = EFalse;
       
   119     const TInt count = aChangeItems.Count();
       
   120     TInt jj = 0;
       
   121     do
       
   122         {
       
   123         TCalChangeEntry entryChange = aChangeItems[jj];
       
   124         TBool found = EFalse;
       
   125          TInt countExpected = iExpectedEntryChange.Count();
       
   126         for(TInt ii = countExpected-1; ii >= 0; --ii)
       
   127             {
       
   128             if(entryChange.iEntryId == iExpectedEntryChange[ii].iEntryId &&
       
   129                entryChange.iChangeType == iExpectedEntryChange[ii].iChangeType &&
       
   130                entryChange.iEntryType == iExpectedEntryChange[ii].iEntryType)
       
   131                  {
       
   132                  iExpectedEntryChange.Remove(ii);
       
   133                  ret = ETrue;
       
   134                  countExpected = iExpectedEntryChange.Count();
       
   135                  break;
       
   136                  }
       
   137             }
       
   138         
       
   139         ++ jj;
       
   140         }while (ret && jj < count);
       
   141             
       
   142     return ret;
       
   143     }
       
   144 
       
   145 void CCalFileChangeNotificationTest::CalChangeNotification(RArray<TCalChangeEntry>& aChangeItems)
       
   146     {
       
   147     test.Printf(_L("MCalChangeCallBack2 notification happened\n") );
       
   148     iNotificationCallBackOccurred = ETrue;
       
   149     test(CompareEntryNotification(aChangeItems));
       
   150     if(iExpectedCalendarInfoTypes.Count() == 0 && iExpectedEntryChange.Count() == 0)
       
   151         {
       
   152         CActiveScheduler::Stop();
       
   153         }
       
   154     }
       
   155 
       
   156 CCalFileChangeNotificationTest* CCalFileChangeNotificationTest::NewLC()
       
   157     {
       
   158     CCalFileChangeNotificationTest* self = new (ELeave) CCalFileChangeNotificationTest();
       
   159     CleanupStack::PushL(self);
       
   160     self->ConstructL();
       
   161     return (self);
       
   162     }
       
   163     
       
   164 CCalFileChangeNotificationTest::~CCalFileChangeNotificationTest()
       
   165     {
       
   166     delete iOtherSession;
       
   167     TRAP_IGNORE(iTestLib->DeleteFileL(KTestFileName));
       
   168     delete iTestLib;
       
   169     iExpectedCalendarInfoTypes.Close();
       
   170     iExpectedEntryChange.Close();
       
   171     }
       
   172 
       
   173 void CCalFileChangeNotificationTest::ConstructL()
       
   174     {
       
   175     iTestLib = CCalTestLibrary::NewL();
       
   176     TRAP_IGNORE(iTestLib->DeleteFileL(KTestFileName));
       
   177     iOtherSession = CCalSession::NewL();
       
   178     }
       
   179 
       
   180 TCalLocalUid CCalFileChangeNotificationTest::StoreEntryL()
       
   181     {
       
   182     test.Printf(_L("Add entry\n" ));
       
   183     RPointerArray<CCalEntry> entries;
       
   184     CleanupResetAndDestroyPushL(entries);
       
   185     _LIT8(KUid, "UID_TzDb");
       
   186     HBufC8* guid = KUid().AllocLC();
       
   187     CCalEntry* entry = CCalEntry::NewL(CCalEntry::EAppt, guid, CCalEntry::EMethodNone, 0);
       
   188     CleanupStack::Pop(guid);
       
   189     CleanupStack::PushL(entry);
       
   190     entries.AppendL(entry);
       
   191     CleanupStack::Pop(entry);
       
   192     
       
   193     //Set entry start and end time
       
   194     TTime startTime (TDateTime(2005, EJanuary, 7, 10, 0, 0, 0)); 
       
   195     TCalTime calStartTime;
       
   196     calStartTime.SetTimeLocalL(startTime);
       
   197     TTime endTime (TDateTime(2005, EJanuary, 7, 11, 0, 0, 0)); 
       
   198     TCalTime calEndTime;
       
   199     calEndTime.SetTimeLocalL(endTime);
       
   200     entry->SetStartAndEndTimeL(calStartTime, calEndTime);
       
   201     
       
   202     //Set repeating 
       
   203     TCalRRule repeat(TCalRRule::EDaily);
       
   204     repeat.SetDtStart(calStartTime);
       
   205     repeat.SetCount(3);
       
   206     entry->SetRRuleL(repeat);
       
   207 
       
   208     //Store the Entry
       
   209     TInt numStoredEntries;
       
   210     iOtherSession->OpenL(KTestFileName());
       
   211     CCalEntryView* otherView =CCalEntryView::NewL(*iOtherSession);
       
   212     CleanupStack::PushL(otherView);
       
   213     otherView->StoreL(entries, numStoredEntries);
       
   214     CleanupStack::PopAndDestroy(otherView);
       
   215     test (numStoredEntries == entries.Count());
       
   216     TCalLocalUid entryId = entries[0]->LocalUidL();
       
   217 
       
   218     CleanupStack::PopAndDestroy(&entries);
       
   219     return entryId; 
       
   220     }
       
   221 
       
   222 /** Test the file change notification is send and received when the other client has created a file.
       
   223 */
       
   224 void CCalFileChangeNotificationTest::TestFileCreatedL()
       
   225     {//maybe combine with delete
       
   226     //Register for Calendar entry change notification.
       
   227     test.Next(_L("Test notification when file is created"));
       
   228     iTestLib->GetSession().StartFileChangeNotificationL(*this);
       
   229     iOtherSession->CreateCalFileL(KTestFileName());
       
   230     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarFileCreated);
       
   231     
       
   232     CActiveScheduler::Start();
       
   233     //CActiveScheduler is stopped in Callback
       
   234         
       
   235     test(iFileNotificationCallBackOccurred);
       
   236     test(iExpectedCalendarInfoTypes.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   237  
       
   238     iFileNotificationCallBackOccurred = EFalse;
       
   239     iTestLib->GetSession().StopFileChangeNotification();
       
   240     }
       
   241 
       
   242 /** Test the file change notifications are send and received when the other client has created a file with a metadata.
       
   243 */  
       
   244 void CCalFileChangeNotificationTest::TestFileChangeWithCalendarInfoL()
       
   245     {
       
   246     //Register for Calendar entry change notification.
       
   247     test.Next(_L("Test notification when file is created"));
       
   248     iTestLib->GetSession().StartFileChangeNotificationL(*this);
       
   249     CCalCalendarInfo* calendarInfo = CCalCalendarInfo::NewL();
       
   250     CleanupStack::PushL(calendarInfo);  
       
   251     iOtherSession->CreateCalFileL(KTestFileName(), *calendarInfo);
       
   252     CleanupStack::PopAndDestroy(calendarInfo);
       
   253     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarFileCreated);
       
   254     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarInfoCreated);
       
   255     CActiveScheduler::Start();
       
   256     //CActiveScheduler is stopped in Callback       
       
   257     test(iFileNotificationCallBackOccurred);
       
   258     test(iExpectedCalendarInfoTypes.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   259     iFileNotificationCallBackOccurred = EFalse;
       
   260     
       
   261     iOtherSession->DeleteCalFileL(KTestFileName());
       
   262     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarFileDeleted);
       
   263     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarInfoDeleted);
       
   264     
       
   265     CActiveScheduler::Start();
       
   266     //CActiveScheduler is stopped in Callback       
       
   267     test(iFileNotificationCallBackOccurred);
       
   268     iFileNotificationCallBackOccurred = EFalse;
       
   269     test(iExpectedCalendarInfoTypes.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   270  
       
   271     iTestLib->GetSession().StopFileChangeNotification();
       
   272     }
       
   273 
       
   274 /** Test the file change notifications are send and received when the other client has updated the metadata.
       
   275 */
       
   276 void CCalFileChangeNotificationTest::TestUpdateCalendarInfoL()
       
   277     {
       
   278     test.Next(_L("Test notification when calendar info is updated"));
       
   279     CCalCalendarInfo* calendarInfo = CCalCalendarInfo::NewL();
       
   280     CleanupStack::PushL(calendarInfo);  
       
   281     iOtherSession->CreateCalFileL(KTestFileName(), *calendarInfo);
       
   282     CleanupStack::PopAndDestroy(calendarInfo);
       
   283     iOtherSession->OpenL(KTestFileName);
       
   284 
       
   285     iTestLib->GetSession().StartFileChangeNotificationL(*this);
       
   286     
       
   287     const TInt numUpdates = 10;
       
   288     for(TInt ii= 0; ii < numUpdates; ++ii)
       
   289         {
       
   290         calendarInfo = CCalCalendarInfo::NewL();
       
   291         CleanupStack::PushL(calendarInfo);  
       
   292         iOtherSession->SetCalendarInfoL(*calendarInfo);
       
   293         CleanupStack::PopAndDestroy(calendarInfo);
       
   294         iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarInfoUpdated);
       
   295         }
       
   296     CActiveScheduler::Start();
       
   297     //CActiveScheduler is stopped in Callback       
       
   298     test(iFileNotificationCallBackOccurred);
       
   299     test(iExpectedCalendarInfoTypes.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   300     iFileNotificationCallBackOccurred = EFalse;
       
   301 
       
   302     iTestLib->GetSession().StopFileChangeNotification();
       
   303     iOtherSession->DeleteCalFileL(KTestFileName());
       
   304     }
       
   305 
       
   306 /** Test the file change notification is send and received when the other client has deleted a file.
       
   307 */
       
   308 void CCalFileChangeNotificationTest::TestFileDeletedL()
       
   309     {
       
   310     test.Next(_L("TestFileDeletedL"));
       
   311 
       
   312     //Register for Calendar entry change notification.
       
   313     test.Next(_L("Test notification when file is deleted"));
       
   314     iTestLib->GetSession().StartFileChangeNotificationL(*this);
       
   315     iOtherSession->DeleteCalFileL(KTestFileName());
       
   316     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarFileDeleted);
       
   317      
       
   318     CActiveScheduler::Start();
       
   319     //CActiveScheduler is stopped in Callback
       
   320          
       
   321     test(iFileNotificationCallBackOccurred);
       
   322     test(iExpectedCalendarInfoTypes.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   323     iFileNotificationCallBackOccurred = EFalse;
       
   324      
       
   325     iTestLib->GetSession().StopFileChangeNotification();
       
   326     }
       
   327 
       
   328 void CCalFileChangeNotificationTest::RegisterEntryNotificationL()
       
   329     {//requeste for the change notification
       
   330     RDebug::Print(_L("Register Notication" ));
       
   331     iTestLib->ReplaceFileL(KTestFileName);
       
   332     iTestLib->GetSession().OpenL(KTestFileName);
       
   333 
       
   334     TCalTime minTime;
       
   335     minTime.SetTimeUtcL(TCalTime::MinTime());
       
   336     TCalTime maxTime;
       
   337     maxTime.SetTimeUtcL(TCalTime::MaxTime());
       
   338     CalCommon::TCalTimeRange timeRange(minTime, maxTime);
       
   339     CCalChangeNotificationFilter* filter = CCalChangeNotificationFilter::NewL(MCalChangeCallBack2::EChangeEntryAll, ETrue, timeRange);
       
   340     iTestLib->GetSession().StartChangeNotification(*this, *filter);
       
   341     delete filter;
       
   342     }
       
   343 
       
   344 /** Test the file change notifications and entry change notification are received when the other client change the file and\or calendar entries.
       
   345 */
       
   346 void CCalFileChangeNotificationTest::TestMixedNotificationL()
       
   347     {
       
   348 // (1) Session 1 request both file and entry notification
       
   349     //Session 1 Register for Calendar entry change notification.
       
   350     test.Next(_L("Test entry and file notification are mixed"));
       
   351     //Session 1 Register for Calendar file change notification.
       
   352     iTestLib->GetSession().StartFileChangeNotificationL(*this);
       
   353     RegisterEntryNotificationL();
       
   354    
       
   355     //Session 2 set and store the calendar info
       
   356     iOtherSession->OpenL(KTestFileName());
       
   357     CCalCalendarInfo* calendarInfo = CCalCalendarInfo::NewL();
       
   358     CleanupStack::PushL(calendarInfo);  
       
   359     iOtherSession->SetCalendarInfoL(*calendarInfo);
       
   360     CleanupStack::PopAndDestroy(calendarInfo);
       
   361 
       
   362     //one file change notification is expected
       
   363     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarInfoCreated);
       
   364     //Session 2 also add an entry
       
   365     TCalLocalUid entryId = StoreEntryL();//Add an entry by iOtherSession
       
   366     TCalChangeEntry change;
       
   367     change.iEntryId = entryId;
       
   368     change.iChangeType = MCalChangeCallBack2::EChangeAdd;
       
   369     change.iEntryType = MCalChangeCallBack2::EChangeEntryEvent;
       
   370     //one entry change notification is expected
       
   371     iExpectedEntryChange.AppendL(change);
       
   372 
       
   373     CActiveScheduler::Start();
       
   374     //CActiveScheduler is stopped in Callback       
       
   375     test(iFileNotificationCallBackOccurred);
       
   376     test(iExpectedCalendarInfoTypes.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   377     test(iNotificationCallBackOccurred);
       
   378     test(iExpectedEntryChange.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   379 
       
   380     iFileNotificationCallBackOccurred = EFalse;
       
   381     iNotificationCallBackOccurred = EFalse;
       
   382 
       
   383 // (2) Session 1 stoped file change notification only request for entry notification
       
   384     iTestLib->GetSession().StopFileChangeNotification();   
       
   385     calendarInfo = CCalCalendarInfo::NewL();
       
   386     CleanupStack::PushL(calendarInfo);  
       
   387     iOtherSession->SetCalendarInfoL(*calendarInfo);
       
   388     CleanupStack::PopAndDestroy(calendarInfo);
       
   389     StoreEntryL();
       
   390     change.iChangeType = MCalChangeCallBack2::EChangeModify;    
       
   391     iExpectedEntryChange.AppendL(change);
       
   392     CActiveScheduler::Start();
       
   393     test(!iFileNotificationCallBackOccurred);
       
   394     test(iNotificationCallBackOccurred);
       
   395     test(iExpectedEntryChange.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   396     iNotificationCallBackOccurred = EFalse;
       
   397     
       
   398 // (3) Session 1 start the entry change notification and stoped file change notification
       
   399     iTestLib->GetSession().StartFileChangeNotificationL(*this);
       
   400     iTestLib->GetSession().StopChangeNotification();
       
   401     StoreEntryL();
       
   402     calendarInfo = CCalCalendarInfo::NewL();
       
   403     CleanupStack::PushL(calendarInfo);  
       
   404     iOtherSession->SetCalendarInfoL(*calendarInfo);
       
   405     CleanupStack::PopAndDestroy(calendarInfo);
       
   406     iExpectedCalendarInfoTypes.AppendL(MCalFileChangeObserver::ECalendarInfoUpdated);
       
   407     CActiveScheduler::Start();
       
   408     test(iFileNotificationCallBackOccurred);
       
   409     test(!iNotificationCallBackOccurred);
       
   410     test(iExpectedCalendarInfoTypes.Count() == 0);//In callback function elements in iExpectedCalendarInfoTypes has been remove when it callback item is equel to the expoected.
       
   411 
       
   412     iTestLib->GetSession().StopFileChangeNotification(); 
       
   413     delete iOtherSession;
       
   414     iTestLib->DeleteFileL(KTestFileName());
       
   415     iOtherSession = CCalSession::NewL();
       
   416     }
       
   417   
       
   418 /**
       
   419 */
       
   420 void DoTestsL()
       
   421     {
       
   422     test.Title();
       
   423     test.Start(_L("@SYMTESTCaseID:PIM-TCAL-TZDBCHANGE-0001 Calendar TZ Rules Data Change Awareness Test Suite"));
       
   424     CCalFileChangeNotificationTest* testManager = CCalFileChangeNotificationTest::NewLC();
       
   425     
       
   426     // Run the test suite
       
   427     testManager->TestFileCreatedL();
       
   428     testManager->TestFileDeletedL();
       
   429     testManager->TestFileChangeWithCalendarInfoL();
       
   430     testManager->TestUpdateCalendarInfoL();
       
   431     testManager->TestMixedNotificationL();
       
   432     
       
   433     CleanupStack::PopAndDestroy(testManager);
       
   434     test.End();
       
   435     }
       
   436 
       
   437 TInt E32Main()
       
   438     {
       
   439     __UHEAP_MARK;
       
   440 
       
   441     CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
   442     if(!trapCleanup)
       
   443         {
       
   444         return KErrNoMemory;
       
   445         }
       
   446 
       
   447     CActiveScheduler* scheduler = new CActiveScheduler;
       
   448     if(!scheduler)
       
   449         {
       
   450         return KErrNoMemory;
       
   451         }
       
   452     CActiveScheduler::Install(scheduler);   
       
   453     
       
   454     TRAPD(ret, DoTestsL());
       
   455     test.Printf(_L("Trapped return value from DoTestsL(): %d\n"), ret);
       
   456     test(ret == KErrNone);
       
   457 
       
   458     test.Close();   
       
   459 
       
   460     delete scheduler;
       
   461     delete trapCleanup; 
       
   462 
       
   463     __UHEAP_MARKEND;
       
   464 
       
   465     return (KErrNone);
       
   466     }
       
   467 
       
   468