pimappservices/calendar/tsrc/caltestlib.cpp
changeset 49 5de72ea7a065
parent 0 f979ecb2b13e
equal deleted inserted replaced
37:360d55486d7f 49:5de72ea7a065
    19 #include <calinstance.h>
    19 #include <calinstance.h>
    20 #include <calinstanceview.h>
    20 #include <calinstanceview.h>
    21 #include <caldataexchange.h>
    21 #include <caldataexchange.h>
    22 #include <caldataformat.h>
    22 #include <caldataformat.h>
    23 #include <calsession.h>
    23 #include <calsession.h>
       
    24 #include <calcalendarinfo.h>
    24 #include <calprogresscallback.h>
    25 #include <calprogresscallback.h>
    25 #include <e32test.h>
    26 #include <e32test.h>
    26 #include <consolealarmalertservermain.h>
    27 #include <consolealarmalertservermain.h>
    27 #include <e32math.h>
    28 #include <e32math.h>
    28 #include <caliterator.h>
    29 #include <caliterator.h>
   118 	}
   119 	}
   119 
   120 
   120 void CCalTestLibrary::CloseCalendarSession(TBool aWaitForAgendaToClose)
   121 void CCalTestLibrary::CloseCalendarSession(TBool aWaitForAgendaToClose)
   121 	{
   122 	{
   122 	iChunkMutex.Wait();
   123 	iChunkMutex.Wait();
       
   124 	iSubCalSessions.ResetAndDestroy();
   123 	delete iSession;
   125 	delete iSession;
   124 	iSession = NULL;	
   126 	iSession = NULL;	
   125 	if (iRefCount && (--*iRefCount <= 0) && aWaitForAgendaToClose)
   127 	if (iRefCount && (--*iRefCount <= 0) && aWaitForAgendaToClose)
   126 		{
   128 		{
   127 		WaitForAgendaServerClose();
   129 		WaitForAgendaServerClose();
   397 		OpenCalendarSessionL();	
   399 		OpenCalendarSessionL();	
   398 		}
   400 		}
   399 	
   401 	
   400 	if (aIsCalFile)
   402 	if (aIsCalFile)
   401 		{
   403 		{
       
   404 		
       
   405 		for(TInt i = 0; i < iSubCalSessions.Count();i++)
       
   406 		    {
       
   407 		    CCalCalendarInfo* info = iSubCalSessions[i]->CalendarInfoL();
       
   408 		    HBufC* fileName = info->FileNameL().AllocLC();
       
   409 		    delete info;
       
   410 		    iSubCalSessions[i]->DeleteCalFileL(*fileName);
       
   411 		    CleanupStack::PopAndDestroy(fileName);
       
   412 		    }
       
   413 		
   402 		iSession->DeleteCalFileL(aFileName);
   414 		iSession->DeleteCalFileL(aFileName);
   403 		TInt indx=-1;
   415 		TInt indx=-1;
   404 		if(iDelFileFlag)
   416 		if(iDelFileFlag)
   405 			{
   417 			{
   406 			if(iFilesToDel->Find(aFileName, indx)==0)
   418 			if(iFilesToDel->Find(aFileName, indx)==0)
   946 	HAL::Get(HAL::ENanoTickPeriod, tickPeriod);
   958 	HAL::Get(HAL::ENanoTickPeriod, tickPeriod);
   947 	TUint durationInTicks = iEndTickCount - iStartTickCount;
   959 	TUint durationInTicks = iEndTickCount - iStartTickCount;
   948 	return tickPeriod * durationInTicks;	
   960 	return tickPeriod * durationInTicks;	
   949 	}
   961 	}
   950 
   962 
   951 
   963 EXPORT_C RPointerArray<CCalSession>& CCalTestLibrary::CreateCalSubSessionL(const TDesC& aFileName)
       
   964     {
       
   965     CCalSession* session = CCalSession::NewL(*iSession);
       
   966     CCalCalendarInfo* calendarInfo = CCalCalendarInfo::NewL();
       
   967     calendarInfo->SetColor(KRgbRed);
       
   968     calendarInfo->SetNameL(_L("test"));
       
   969     calendarInfo->SetEnabled(ETrue);
       
   970     
       
   971     TRAPD(err,session->CreateCalFileL(aFileName,*calendarInfo));
       
   972     if(err == KErrAlreadyExists)
       
   973         {
       
   974         session->DeleteCalFileL(aFileName);
       
   975         session->CreateCalFileL(aFileName,*calendarInfo);
       
   976         }
       
   977     session->OpenL(aFileName);
       
   978     iSubCalSessions.Append(session);
       
   979     
       
   980     delete calendarInfo;
       
   981     return iSubCalSessions;
       
   982     }
       
   983