calendarui/server/CalenSvr/src/CalenServer.cpp
branchRCL_3
changeset 21 9711e452b5e9
parent 19 1984aceb8774
child 30 d68a4b5d5885
equal deleted inserted replaced
20:21239b3bcd78 21:9711e452b5e9
    49 const TInt KBufferSizeIncrement( 64 );
    49 const TInt KBufferSizeIncrement( 64 );
    50 const TInt KBuffLength = 128;
    50 const TInt KBuffLength = 128;
    51 
    51 
    52 
    52 
    53 const TInt KComma( ',' );
    53 const TInt KComma( ',' );
    54 _LIT(KPhoneCalendarName,"PhoneCalendar");
    54 
       
    55 _LIT(KPersonal,"Personal");
       
    56 _LIT(KFamily,"Family");
       
    57 _LIT(KFriends,"Friends");
    55 
    58 
    56 // ================= MEMBER FUNCTIONS =======================
    59 // ================= MEMBER FUNCTIONS =======================
    57 //
    60 //
    58 // Construction and destruction 
    61 // Construction and destruction 
    59 //
    62 //
   336 
   339 
   337         if(!index)
   340         if(!index)
   338             {
   341             {
   339             TBuf<KMaxFileName> calendarFileName;
   342             TBuf<KMaxFileName> calendarFileName;
   340             calendarFileName.Append(KCalendarDatabaseFilePath);
   343             calendarFileName.Append(KCalendarDatabaseFilePath);
   341             calendarInfo->SetEnabled(EFalse);
       
   342             TRAPD(error,session->CreateCalFileL(calendarFileName,*calendarInfo));
   344             TRAPD(error,session->CreateCalFileL(calendarFileName,*calendarInfo));
   343 			User::LeaveIfError(error);
   345 			User::LeaveIfError(error);
   344             }
   346             }
   345         else
   347         else
   346             {
   348             {
   368 //
   370 //
   369 void CCalenServer::ReadCalendarNamesFromResourceL(CDesC16ArrayFlat& aCalendarNames)
   371 void CCalenServer::ReadCalendarNamesFromResourceL(CDesC16ArrayFlat& aCalendarNames)
   370     {
   372     {
   371     TRACE_ENTRY_POINT;
   373     TRACE_ENTRY_POINT;
   372     
   374     
   373     RFs fsSession;
   375     
   374     CleanupClosePushL( fsSession );
   376     
   375     RResourceFile resourceFile;
   377     
   376     CleanupClosePushL( resourceFile );
   378     
   377     User::LeaveIfError( fsSession.Connect() );
       
   378     TFileName resourceFileName( KMissedAlarmResourceFile );
       
   379     
       
   380     BaflUtils::NearestLanguageFile( fsSession, resourceFileName );
       
   381     
       
   382     resourceFile.OpenL(fsSession, resourceFileName );
       
   383     resourceFile.ConfirmSignatureL( 0 );
       
   384     
       
   385     //Phone calendar 
       
   386        HBufC* phoneCalendarBuffer = KPhoneCalendarName().AllocLC();
       
   387        aCalendarNames.AppendL(phoneCalendarBuffer->Des());
       
   388        CleanupStack::PopAndDestroy( phoneCalendarBuffer );
       
   389         
   379         
   390     // personal
   380     // personal
   391         HBufC8* personalBuffer = resourceFile.AllocReadLC( R_CALE_DB_PERSONAL );    
   381          HBufC* personalBuffer = KPersonal().AllocLC();    
   392        const TPtrC16 ptrPBuffer(( TText16*) personalBuffer->Ptr(),
   382         aCalendarNames.AppendL( personalBuffer->Des() );    
   393                                          ( personalBuffer->Length()+1 )>>1 );    
       
   394        HBufC *personalCalendar = ptrPBuffer.AllocL();    
       
   395        aCalendarNames.AppendL( personalCalendar->Des() );    
       
   396        CleanupStack::PopAndDestroy( personalBuffer );
   383        CleanupStack::PopAndDestroy( personalBuffer );
   397        
   384        
   398     // famliy
   385     // famliy
   399        HBufC8* familyBuffer=resourceFile.AllocReadLC( R_CALE_DB_FAMILY );
   386         HBufC* familyBuffer = KFamily().AllocLC();    
   400        const TPtrC16 ptrFBuffer(( TText16*) familyBuffer->Ptr(),
   387        aCalendarNames.AppendL( familyBuffer->Des() );    
   401                ( familyBuffer->Length()+1 )>>1 );
       
   402        HBufC *familyCalendar = ptrFBuffer.AllocL();
       
   403        aCalendarNames.AppendL( familyCalendar->Des() );
       
   404        CleanupStack::PopAndDestroy( familyBuffer );
   388        CleanupStack::PopAndDestroy( familyBuffer );
   405        
   389        
   406     //friends
   390     //friends
   407        HBufC8* friendsBuffer = resourceFile.AllocReadLC( R_CALE_DB_FRIENDS );
   391        HBufC* friendBuffer = KFriends().AllocLC();    
   408        const TPtrC16 ptrFrBuffer(( TText16*) friendsBuffer->Ptr(),
   392       aCalendarNames.AppendL( friendBuffer->Des() );    
   409                ( friendsBuffer->Length()+1 )>>1 );
   393       CleanupStack::PopAndDestroy( friendBuffer );
   410        HBufC *friendsCalendar = ptrFrBuffer.AllocL();
       
   411        aCalendarNames.AppendL( friendsCalendar->Des() );
       
   412        CleanupStack::PopAndDestroy( friendsBuffer );
       
   413    
   394    
   414     CleanupStack::PopAndDestroy(&resourceFile);
       
   415     CleanupStack::PopAndDestroy(&fsSession);
       
   416     
   395     
   417     TRACE_EXIT_POINT;
   396     TRACE_EXIT_POINT;
   418     }
   397     }
   419 
   398 
   420 // -----------------------------------------------------------------------------
   399 // -----------------------------------------------------------------------------
   470     TRACE_ENTRY_POINT;
   449     TRACE_ENTRY_POINT;
   471     
   450     
   472     TPtrC marker = aRepositoryBuffer;
   451     TPtrC marker = aRepositoryBuffer;
   473     TInt calendarColorOffset;
   452     TInt calendarColorOffset;
   474     
   453     
   475     //For phone calendar 
   454   
   476     aCalendarColors.Append(KRgbRed.Value());
       
   477     
   455     
   478     while ((calendarColorOffset = marker.Locate(TChar(KComma)))
   456     while ((calendarColorOffset = marker.Locate(TChar(KComma)))
   479             != KErrNotFound)
   457             != KErrNotFound)
   480         {
   458         {
   481         TLex lex(marker.Left(calendarColorOffset));
   459         TLex lex(marker.Left(calendarColorOffset));