calendarui/commonutils/src/calenattachmentmodel.cpp
changeset 0 f979ecb2b13e
child 10 38571fd2a704
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 *  Description : For handling the attachment data
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System includes
       
    20 #include <AknsUtils.h>
       
    21 #include <coeutils.h>
       
    22 #include <eikenv.h>
       
    23 #include <AknUtils.h>
       
    24 #include <AknsConstants.h>
       
    25 #include <aknlayout.cdl.h>
       
    26 #include <gulicon.h>
       
    27 #include <calattachment.h>
       
    28 #include <Calendar.rsg>
       
    29 #include <StringLoader.h>
       
    30 #include <AknQueryDialog.h>
       
    31 #include <aknnotewrappers.h>
       
    32 
       
    33 // User includes
       
    34 #include "calenattachmentmodel.h"
       
    35 #include "calendarui_debug.h"
       
    36 #include "calenattachmentutils.h"
       
    37 #include "calenattachmentinfo.h"
       
    38 #include "calencontext.h"
       
    39 
       
    40 // Literals
       
    41 _LIT8( KTextDataType, "text/plain" );
       
    42 
       
    43 // Constants
       
    44 const TInt KNotepadUID = 0x1000599d;
       
    45 const TInt KTotalAttachLimit( 1 );
       
    46 const TInt KBuffLength ( 4 );
       
    47 const TInt KTen( 10 );
       
    48 
       
    49 // Literals.
       
    50 
       
    51 _LIT( KFormatString, "%d" );
       
    52 _LIT( KFormatStringTwoDigit, "%02d" );
       
    53 _LIT( KFormatStringThreeDigit, "%03d" );
       
    54 // ----------------------------------------------------------------------------
       
    55 // CCalenAttachmentModel::NewL
       
    56 // First phase construction
       
    57 // ----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C CCalenAttachmentModel* CCalenAttachmentModel::NewL()
       
    60     {
       
    61     TRACE_ENTRY_POINT;
       
    62     
       
    63     CCalenAttachmentModel* self = new ( ELeave ) CCalenAttachmentModel();
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop();
       
    67     
       
    68     TRACE_EXIT_POINT;
       
    69     return self;
       
    70     }
       
    71 
       
    72 // ----------------------------------------------------------------------------
       
    73 // CCalenAttachmentModel::~CCalenAttachmentModel
       
    74 // Destructor
       
    75 // ----------------------------------------------------------------------------
       
    76 //
       
    77 CCalenAttachmentModel::~CCalenAttachmentModel()
       
    78     {
       
    79     TRACE_ENTRY_POINT;
       
    80     iAppList.Close();
       
    81     
       
    82     if(iAttachInfoArray.Count())
       
    83         {
       
    84         iAttachInfoArray.ResetAndDestroy();
       
    85         }
       
    86     TRACE_EXIT_POINT;
       
    87     }
       
    88 
       
    89 // ----------------------------------------------------------------------------
       
    90 // CCalenAttachmentModel::CCalenAttachmentModel
       
    91 // default constructor
       
    92 // ----------------------------------------------------------------------------
       
    93 //
       
    94 CCalenAttachmentModel::CCalenAttachmentModel()
       
    95     {
       
    96     TRACE_ENTRY_POINT;
       
    97     isAttachmentModelCleared = ETrue;
       
    98     TRACE_EXIT_POINT;
       
    99     }
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // CCalenAttachmentModel::ConstructL
       
   103 // Second phase construction
       
   104 // ----------------------------------------------------------------------------
       
   105 //
       
   106 void CCalenAttachmentModel::ConstructL()
       
   107     {
       
   108     TRACE_ENTRY_POINT;
       
   109     
       
   110     User::LeaveIfError( iAppList.Connect() );
       
   111     LoadResourcesL();
       
   112     
       
   113     TRACE_EXIT_POINT;
       
   114     }
       
   115 
       
   116 // ----------------------------------------------------------------------------
       
   117 // CCalenAttachmentModel::SetObserver
       
   118 // Sets attachment model observer.
       
   119 // ----------------------------------------------------------------------------
       
   120 //
       
   121 EXPORT_C void CCalenAttachmentModel::SetObserver( 
       
   122                                         MCalenAttachmentModelObserver* aObserver)
       
   123     {
       
   124     TRACE_ENTRY_POINT;
       
   125     
       
   126     iAttachmentModelObserver = aObserver;
       
   127     
       
   128     TRACE_EXIT_POINT;
       
   129     }
       
   130 
       
   131 // ----------------------------------------------------------------------------
       
   132 // CCalenAttachmentModel::NumberOfItems
       
   133 // Returns number of attachments.
       
   134 // ----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C TInt CCalenAttachmentModel::NumberOfItems() const
       
   137     {
       
   138     TRACE_ENTRY_POINT;
       
   139     TRACE_EXIT_POINT;
       
   140     return iAttachInfoArray.Count();
       
   141     }
       
   142 
       
   143 // ----------------------------------------------------------------------------
       
   144 // CCalenAttachmentModel::AttachmentInfoAt
       
   145 // Returns reference to attachment info at given index.
       
   146 // ----------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C CCalenAttachmentInfo& CCalenAttachmentModel::AttachmentInfoAt(
       
   149                                                         TInt aIndex ) const
       
   150     {
       
   151     TRACE_ENTRY_POINT;
       
   152     TRACE_EXIT_POINT;
       
   153     return *iAttachInfoArray[aIndex];
       
   154     }
       
   155 
       
   156 // ----------------------------------------------------------------------------
       
   157 // CCalenAttachmentModel::AddAttachmentL
       
   158 // Adds attachment to the internal array. Notifies attachment model
       
   159 // observer with ECalenAttachmentAdded parameter.
       
   160 // ----------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C void CCalenAttachmentModel::AddAttachmentL(const TDesC& aFullName, const TDesC& aSystemFileName)
       
   163     {
       
   164     TRACE_ENTRY_POINT;
       
   165     
       
   166     TInt attachmentSize;
       
   167     attachmentSize = CCalenAttachmentUtils::GetFileSizeL(aFullName);
       
   168     
       
   169         
       
   170     if( CheckFileSizeLimitL( attachmentSize ) )
       
   171         {
       
   172     
       
   173     TDataType dataType;
       
   174     dataType = CCalenAttachmentUtils::GetMimeTypeL(aFullName);
       
   175     
       
   176     CCalenAttachmentInfo* info = CreateNewInfoL( aFullName, aSystemFileName, attachmentSize, ETrue, 
       
   177                               dataType, CCalenAttachmentInfo::ECalenNewAttachment ); 
       
   178     CleanupStack::PushL(info);
       
   179     
       
   180     iAttachInfoArray.AppendL(info);
       
   181     isAttachmentModelCleared = EFalse;
       
   182     if((iAttachmentModelObserver!=NULL) && (NumberOfItems()>0))
       
   183         {
       
   184         iAttachmentModelObserver->NotifyChanges(
       
   185                 MCalenAttachmentModelObserver::ECalenAttachmentAdded, 0 );
       
   186         }
       
   187 
       
   188     CleanupStack::Pop(); // info
       
   189         }
       
   190     else
       
   191         {
       
   192         iAttachmentModelObserver->NotifyChanges(
       
   193                         MCalenAttachmentModelObserver::ECalenAttachmentAdded, 0 );
       
   194                 
       
   195         }
       
   196     TRACE_EXIT_POINT;
       
   197     }
       
   198 
       
   199 // ----------------------------------------------------------------------------
       
   200 // CCalenAttachmentModel::CheckFileSizeLimitL
       
   201 // checks if the total attachment size and the new file size exceeds  
       
   202 // attachments from the calentry
       
   203 // ----------------------------------------------------------------------------
       
   204 //
       
   205 TBool CCalenAttachmentModel::CheckFileSizeLimitL( TInt aNewFileSize )                                                     
       
   206     {
       
   207     TRACE_ENTRY_POINT;
       
   208     
       
   209     TInt currAttachmentSize( KErrNone );
       
   210     TBool fileSizeOk( EFalse );
       
   211     //Check if the attachement size plus the current attachment size equals 1MB
       
   212     for( int index = 0 ;index < iAttachInfoArray.Count();index++ )
       
   213         {
       
   214         currAttachmentSize += AttachmentInfoAt(index).Size();
       
   215         }
       
   216             
       
   217     if( ( currAttachmentSize + aNewFileSize )  <= 1024000 )
       
   218         {
       
   219         fileSizeOk = ETrue;
       
   220         }
       
   221     else
       
   222         {
       
   223         // attachment size is exceeded, show the info note for this info.
       
   224         CDesCArrayFlat* sizeArray = new(ELeave)CDesCArrayFlat(2);
       
   225         CleanupStack::PushL( sizeArray );
       
   226         
       
   227         TBuf<KBuffLength> totalLimitBuf;
       
   228         totalLimitBuf.Zero();
       
   229         totalLimitBuf.Format( KFormatString, KTotalAttachLimit );
       
   230         
       
   231         TBuf<KBuffLength> availableBuf;
       
   232         TInt avaiableSize( KErrNone );
       
   233         availableBuf.Zero();
       
   234         avaiableSize =  ( 1024000 - currAttachmentSize )/1000;
       
   235         
       
   236         if( avaiableSize < KTen  )
       
   237             {
       
   238             availableBuf.Format( KFormatString, avaiableSize );    
       
   239             }
       
   240        else if( ( avaiableSize/KTen )< KTen )
       
   241            {
       
   242            availableBuf.Format( KFormatStringTwoDigit, avaiableSize );
       
   243            }
       
   244        else
       
   245            {
       
   246            availableBuf.Format( KFormatStringThreeDigit, avaiableSize );
       
   247            }
       
   248         
       
   249         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( totalLimitBuf );
       
   250         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( availableBuf );
       
   251         
       
   252         sizeArray->AppendL( totalLimitBuf );
       
   253         sizeArray->AppendL( availableBuf );
       
   254         
       
   255         CAknInformationNote* note = new ( ELeave ) CAknInformationNote(ETrue);
       
   256         HBufC* attachSizeExceeded = StringLoader::LoadLC( 
       
   257                 R_QTN_CALEN_SIZE_EXCEEDED ,CEikonEnv::Static());
       
   258        
       
   259        TPtr ptr = attachSizeExceeded->Des();         	
       
   260        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr );          	
       
   261         
       
   262         note->ExecuteLD( *attachSizeExceeded );
       
   263         
       
   264         CleanupStack::PopAndDestroy( attachSizeExceeded );
       
   265         CleanupStack::PopAndDestroy( sizeArray );
       
   266         
       
   267         }
       
   268      
       
   269     return fileSizeOk;
       
   270     TRACE_EXIT_POINT;
       
   271     }
       
   272 
       
   273 // ----------------------------------------------------------------------------
       
   274 // CCalenAttachmentModel::AddAttachmentL
       
   275 // adds an attachment info in to model,used while fetching already saved 
       
   276 // attachments from the calentry
       
   277 // ----------------------------------------------------------------------------
       
   278 //
       
   279 EXPORT_C void CCalenAttachmentModel::AddAttachmentL( 
       
   280                                                     const TDesC& aFullName,
       
   281                                                     const TDesC& aSystemFileName,
       
   282                                                     TInt aSize,
       
   283                                                     TBool aFetched,
       
   284                                                     const TDataType& aDataType )
       
   285 	{
       
   286 	
       
   287 	TRACE_ENTRY_POINT;
       
   288 
       
   289 	CCalenAttachmentInfo* info = 
       
   290 	CreateNewInfoL( aFullName, 
       
   291 	                aSystemFileName, 
       
   292 	                aSize, 
       
   293 	                aFetched, 
       
   294 	                aDataType, 
       
   295 	                CCalenAttachmentInfo::ECalenAttachmentFetchedFromEntry );
       
   296 	CleanupStack::PushL(info);
       
   297 	iAttachInfoArray.AppendL(info);
       
   298 	CleanupStack::Pop();
       
   299 	isAttachmentModelCleared = EFalse;
       
   300 
       
   301 	TRACE_EXIT_POINT;
       
   302 	
       
   303 	}
       
   304 
       
   305 // ----------------------------------------------------------------------------
       
   306 // CCalenAttachmentModel::DeleteAttachment
       
   307 // Deletes attachment from internal array. Notifies attachment model
       
   308 // observer with ECalenAttachmentRemoved parameter.
       
   309 // ----------------------------------------------------------------------------
       
   310 //
       
   311 EXPORT_C TBool CCalenAttachmentModel::DeleteAttachment( TInt aIndex )
       
   312 	{
       
   313 	
       
   314 	TRACE_ENTRY_POINT;
       
   315 	
       
   316 	TInt attachmentDeleted(EFalse); 
       
   317 	TRAP_IGNORE( attachmentDeleted = DoDeleteAttachmentL( aIndex ) );
       
   318 
       
   319 	TRACE_EXIT_POINT;
       
   320 	return attachmentDeleted;
       
   321 	}
       
   322 
       
   323 // ----------------------------------------------------------------------------
       
   324 // CCalenAttachmentModel::DoDeleteAttachmentL
       
   325 // Deletes attachment from internal array. Notifies attachment model
       
   326 // observer with ECalenAttachmentRemoved parameter.
       
   327 // (rest of the details are commented in the header)
       
   328 // ----------------------------------------------------------------------------
       
   329 //
       
   330 TBool CCalenAttachmentModel::DoDeleteAttachmentL( TInt aIndex )
       
   331 	{
       
   332 
       
   333 	TRACE_EXIT_POINT;
       
   334 	
       
   335 	if( 0 <= aIndex && aIndex < iAttachInfoArray.Count() )
       
   336 		{
       
   337 		// Get the attachment information.
       
   338 		CCalenAttachmentInfo* attachmentInfo = NULL;
       
   339 		attachmentInfo = iAttachInfoArray[ aIndex ];
       
   340 		
       
   341 		// Get the attachment file name
       
   342 		TFileName fileName( attachmentInfo->FileName() );
       
   343 		
       
   344 		// Confirm if needs to be deleted.
       
   345 		CAknQueryDialog* confirmQuery = NULL;
       
   346 		confirmQuery = CAknQueryDialog::NewL();
       
   347 		HBufC* stringBuf = NULL;
       
   348 		stringBuf = StringLoader::LoadLC( 
       
   349 		                                  R_QTN_QUERY_COMMON_CONF_REMOVE, 
       
   350 		                                  fileName,
       
   351 		                                  CEikonEnv::Static() );
       
   352 		confirmQuery->SetPromptL( *stringBuf );
       
   353 		if( EAknSoftkeyYes != 
       
   354 		confirmQuery->ExecuteLD( R_CALEN_ATTACHMENT_DELETE_QUERY ) )
       
   355 			{
       
   356 			// Return without doing anything if `No' is pressed.
       
   357 			CleanupStack::PopAndDestroy( stringBuf );
       
   358 			TRACE_EXIT_POINT;
       
   359 			return EFalse;
       
   360 			}
       
   361 		
       
   362 		// Delete the attachment and notify the observers.
       
   363 		delete attachmentInfo;
       
   364 		iAttachInfoArray.Remove( aIndex );
       
   365 		
       
   366 		if( iAttachmentModelObserver )
       
   367 			{
       
   368 			iAttachmentModelObserver->NotifyChanges( 
       
   369 					 MCalenAttachmentModelObserver::ECalenAttachmentRemoved, 
       
   370 					 aIndex );
       
   371 			}
       
   372 		
       
   373 		// Delete the file from temporary directory.
       
   374 		CFileMan* fileMan = CFileMan::NewL( CEikonEnv::Static()->FsSession() );
       
   375 		CleanupStack::PushL( fileMan );
       
   376 		TFileName temporaryPath;
       
   377 		CCalenAttachmentUtils::GetCalenEditorTempPath( temporaryPath, &fileName );
       
   378 		fileMan->Delete( temporaryPath );
       
   379 		
       
   380 		// Cleanup.
       
   381 		CleanupStack::PopAndDestroy( fileMan );
       
   382 		CleanupStack::PopAndDestroy( stringBuf );
       
   383 		}
       
   384 
       
   385 	TRACE_EXIT_POINT;
       
   386 	return ETrue;
       
   387 	}
       
   388 
       
   389 // ----------------------------------------------------------------------------
       
   390 // CCalenAttachmentModel::Reset
       
   391 // Reset the attachment model (empties the internal array).
       
   392 // -----------------------------------------------------------------------------
       
   393 //
       
   394 EXPORT_C void CCalenAttachmentModel::Reset()
       
   395 	{
       
   396 	
       
   397 	TRACE_ENTRY_POINT;
       
   398 
       
   399 	if( iAttachInfoArray.Count() )
       
   400 		{
       
   401 		iAttachInfoArray.ResetAndDestroy();
       
   402 		}
       
   403 	isAttachmentModelCleared = ETrue;
       
   404 	
       
   405 	TRACE_EXIT_POINT;
       
   406 	
       
   407 	}
       
   408 
       
   409 // ----------------------------------------------------------------------------
       
   410 // CCalenAttachmentModel::BitmapForFileL
       
   411 // Returns pointer to bitmap of the application that handles given file.
       
   412 // ----------------------------------------------------------------------------
       
   413 //
       
   414 EXPORT_C CGulIcon* CCalenAttachmentModel::BitmapForFileL(
       
   415                                     CCalenAttachmentInfo& aAttaInfo )
       
   416     {
       
   417     TRACE_ENTRY_POINT;
       
   418     
       
   419     TUid appUid( KNullUid );
       
   420     // Get data appuid based on the datatype:
       
   421     TInt err = iAppList.AppForDataType( aAttaInfo.DataType(), appUid );
       
   422  
       
   423     if( aAttaInfo.DataType().Des8().Compare( KTextDataType ) == 0 )
       
   424         {
       
   425         appUid.iUid = KNotepadUID;
       
   426         err = KErrNone;
       
   427         }
       
   428     
       
   429     // get bitmap based on the appuid
       
   430     CGulIcon* icon = BitmapForAppL(appUid);
       
   431     CleanupStack::PushL(icon);    
       
   432     AknIconUtils::SetSize( icon->Bitmap(), iIconSize );
       
   433     CleanupStack::Pop(icon);
       
   434     
       
   435     TRACE_ENTRY_POINT;
       
   436     return icon;
       
   437     }
       
   438 
       
   439 // ----------------------------------------------------------------------------
       
   440 // CCalenAttachmentModel::LoadResourcesL
       
   441 // Loads resources
       
   442 // ----------------------------------------------------------------------------
       
   443 EXPORT_C void CCalenAttachmentModel::LoadResourcesL()
       
   444     {
       
   445     TRACE_ENTRY_POINT;
       
   446     
       
   447     // Resolve icon layout
       
   448     TRect mainPane;
       
   449     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane );
       
   450     TAknLayoutRect listPaneLayout;
       
   451     listPaneLayout.LayoutRect( mainPane, AknLayout::list_gen_pane( 0 ) );
       
   452     TAknLayoutRect doubleGraphicLayout;
       
   453     doubleGraphicLayout.LayoutRect( listPaneLayout.Rect(),
       
   454         AknLayout::list_double_large_graphic_pane_list_double2_large_graphic_pane_list_single_big_large_graphic_pane( 0 ) );
       
   455     TAknLayoutRect iconLayout;
       
   456     iconLayout.LayoutRect( doubleGraphicLayout.Rect(),
       
   457         AknLayout::List_pane_elements__double_large_graphic__Line_8() );
       
   458     TAknLayoutRect addIconLayout;
       
   459     addIconLayout.LayoutRect( doubleGraphicLayout.Rect(),
       
   460         AknLayout::List_pane_elements__double_large_graphic__Line_9( 0 ) );   
       
   461 
       
   462     iIconSize = iconLayout.Rect().Size();
       
   463 
       
   464     TInt count = iAttachInfoArray.Count();
       
   465     while(count--)
       
   466         {
       
   467         // Update already existing icons
       
   468         iAttachInfoArray[count]->DoUpdateIconL();
       
   469         }
       
   470     
       
   471     TRACE_EXIT_POINT;
       
   472     }
       
   473 
       
   474 // ----------------------------------------------------------------------------
       
   475 // CCalenAttachmentModel::GetAttachmentFileL
       
   476 // Get attachment file 
       
   477 // ----------------------------------------------------------------------------
       
   478 //
       
   479 EXPORT_C RFile CCalenAttachmentModel::GetAttachmentFileL(TInt aIndex)
       
   480     {
       
   481     TRACE_ENTRY_POINT;
       
   482     
       
   483     RFile file;
       
   484     CCalenAttachmentInfo* attachmentInfo = iAttachInfoArray[aIndex];
       
   485     TParsePtrC fileNameParser(attachmentInfo->SystemFileName());
       
   486     CEikonEnv* eikonEnv = CEikonEnv::Static();
       
   487     RFs& fs = eikonEnv->FsSession();
       
   488     User::LeaveIfError(fs.ShareProtected());
       
   489     TInt err = file.Open( fs, attachmentInfo->SystemFileName(), 
       
   490                           EFileRead|EFileShareReadersOnly);
       
   491     if(err == KErrInUse)
       
   492         {
       
   493         file.Close();
       
   494         User::LeaveIfError( file.Open( fs, attachmentInfo->SystemFileName(),
       
   495                             EFileRead|EFileShareReadersOnly) );
       
   496         }
       
   497     
       
   498     TRACE_EXIT_POINT;
       
   499     return file;
       
   500     }
       
   501 
       
   502 // ----------------------------------------------------------------------------
       
   503 // CCalenAttachmentModel::BitmapForAppL
       
   504 // Returns pointer to bitmap of given application.
       
   505 // ----------------------------------------------------------------------------
       
   506 //
       
   507 CGulIcon* CCalenAttachmentModel::BitmapForAppL( const TUid &aAppUid )
       
   508     {
       
   509     TRACE_ENTRY_POINT;
       
   510     
       
   511     CFbsBitmap* tempBitmap = NULL;
       
   512     CFbsBitmap* tempMask = NULL;
       
   513 
       
   514     AknsUtils::CreateAppIconLC( AknsUtils::SkinInstance(),
       
   515                                 aAppUid,
       
   516                                 EAknsAppIconTypeList,
       
   517                                 tempBitmap,
       
   518                                 tempMask );
       
   519 
       
   520     CGulIcon* bitmap = CGulIcon::NewL( tempBitmap, tempMask );
       
   521     CleanupStack::Pop(2); // tempBitmap, tempMask
       
   522 
       
   523     TRACE_EXIT_POINT;
       
   524     return bitmap;
       
   525     }
       
   526 
       
   527 // ----------------------------------------------------------------------------
       
   528 // CCalenAttachmentModel::CreateNewInfoL
       
   529 // Creates new attachment info object.
       
   530 // ----------------------------------------------------------------------------
       
   531 //
       
   532 CCalenAttachmentInfo* CCalenAttachmentModel::CreateNewInfoL( 
       
   533                                                     const TDesC& aFileName,
       
   534                                                     const TDesC& aSystemFileName,
       
   535                                                     TInt aSize, TBool aFetched,
       
   536                                                     const TDataType& aDataType,
       
   537                     CCalenAttachmentInfo::TCalenAttachmentStoreType aStoreType)
       
   538     {
       
   539     TRACE_ENTRY_POINT;
       
   540     TRACE_EXIT_POINT;
       
   541     
       
   542     return CCalenAttachmentInfo::NewL( *this, aFileName, aSystemFileName, aSize, 
       
   543                                         aFetched, aDataType, aStoreType);
       
   544     }
       
   545 
       
   546 // ----------------------------------------------------------------------------
       
   547 // CCalenAttachmentModel::GetAttachmentListL
       
   548 // Returns attachment list
       
   549 // ----------------------------------------------------------------------------
       
   550 //
       
   551 EXPORT_C void CCalenAttachmentModel::GetAttachmentListL(
       
   552                     RPointerArray<CCalenAttachmentInfo> &aAttachmentList)
       
   553     {
       
   554     TRACE_ENTRY_POINT;
       
   555     
       
   556     for(TInt index=0;index<iAttachInfoArray.Count();index++)
       
   557        {
       
   558        aAttachmentList.Append(iAttachInfoArray[index]); 
       
   559        }
       
   560     
       
   561     TRACE_EXIT_POINT;
       
   562     }
       
   563 
       
   564 // ----------------------------------------------------------------------------
       
   565 // CCalenAttachmentModel::CheckForExistingAttachmentsL
       
   566 // check for already existing attachments from the entry
       
   567 // ----------------------------------------------------------------------------
       
   568 //
       
   569 EXPORT_C void CCalenAttachmentModel::CheckForExistingAttachmentsL( CCalEntry* aEntry )
       
   570 	{
       
   571 	
       
   572 	TRACE_ENTRY_POINT;
       
   573 
       
   574 	if( isAttachmentModelCleared && aEntry )
       
   575 		{
       
   576 		TInt attachmentCount = aEntry->AttachmentCountL();
       
   577 		if( attachmentCount )
       
   578 			{
       
   579 			for(TInt index=0;index<attachmentCount;index++)
       
   580 				{
       
   581 				CCalAttachment* attachment = aEntry->AttachmentL(index);
       
   582 				if(attachment->FileAttachment())
       
   583 					{
       
   584 					RFile fileHandle;
       
   585 					CleanupClosePushL(fileHandle);
       
   586 					attachment->FileAttachment()->FetchFileHandleL(fileHandle);
       
   587 
       
   588 					TFileName fileName(attachment->Label());
       
   589 					TFileName systemFileName;
       
   590 					fileHandle.FullName(systemFileName);
       
   591 					TDataType fileMimeType(attachment->MimeType());
       
   592 					TInt fileSize(0);
       
   593 					fileHandle.Size(fileSize);
       
   594 
       
   595 					AddAttachmentL( fileName, systemFileName, fileSize,
       
   596 					                ETrue, fileMimeType );
       
   597 					CleanupStack::PopAndDestroy(&fileHandle);
       
   598 					}
       
   599 				}
       
   600 			}
       
   601 		}
       
   602 
       
   603 	TRACE_EXIT_POINT;
       
   604 	
       
   605 	}
       
   606 
       
   607 // End of file	--Don't remove this.