|
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 else |
|
87 { |
|
88 iAttachInfoArray.Close(); |
|
89 } |
|
90 TRACE_EXIT_POINT; |
|
91 } |
|
92 |
|
93 // ---------------------------------------------------------------------------- |
|
94 // CCalenAttachmentModel::CCalenAttachmentModel |
|
95 // default constructor |
|
96 // ---------------------------------------------------------------------------- |
|
97 // |
|
98 CCalenAttachmentModel::CCalenAttachmentModel() |
|
99 { |
|
100 TRACE_ENTRY_POINT; |
|
101 isAttachmentModelCleared = ETrue; |
|
102 iEmbeddedFileOpened = EFalse; |
|
103 TRACE_EXIT_POINT; |
|
104 } |
|
105 |
|
106 // ---------------------------------------------------------------------------- |
|
107 // CCalenAttachmentModel::ConstructL |
|
108 // Second phase construction |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CCalenAttachmentModel::ConstructL() |
|
112 { |
|
113 TRACE_ENTRY_POINT; |
|
114 |
|
115 User::LeaveIfError( iAppList.Connect() ); |
|
116 LoadResourcesL(); |
|
117 |
|
118 TRACE_EXIT_POINT; |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CCalenAttachmentModel::SetObserver |
|
123 // Sets attachment model observer. |
|
124 // ---------------------------------------------------------------------------- |
|
125 // |
|
126 EXPORT_C void CCalenAttachmentModel::SetObserver( |
|
127 MCalenAttachmentModelObserver* aObserver) |
|
128 { |
|
129 TRACE_ENTRY_POINT; |
|
130 |
|
131 iAttachmentModelObserver = aObserver; |
|
132 |
|
133 TRACE_EXIT_POINT; |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CCalenAttachmentModel::NumberOfItems |
|
138 // Returns number of attachments. |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C TInt CCalenAttachmentModel::NumberOfItems() const |
|
142 { |
|
143 TRACE_ENTRY_POINT; |
|
144 TRACE_EXIT_POINT; |
|
145 return iAttachInfoArray.Count(); |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CCalenAttachmentModel::AttachmentInfoAt |
|
150 // Returns reference to attachment info at given index. |
|
151 // ---------------------------------------------------------------------------- |
|
152 // |
|
153 EXPORT_C CCalenAttachmentInfo& CCalenAttachmentModel::AttachmentInfoAt( |
|
154 TInt aIndex ) const |
|
155 { |
|
156 TRACE_ENTRY_POINT; |
|
157 TRACE_EXIT_POINT; |
|
158 return *iAttachInfoArray[aIndex]; |
|
159 } |
|
160 |
|
161 // ---------------------------------------------------------------------------- |
|
162 // CCalenAttachmentModel::AddAttachmentL |
|
163 // Adds attachment to the internal array. Notifies attachment model |
|
164 // observer with ECalenAttachmentAdded parameter. |
|
165 // ---------------------------------------------------------------------------- |
|
166 // |
|
167 EXPORT_C void CCalenAttachmentModel::AddAttachmentL(const TDesC& aFullName, const TDesC& aSystemFileName) |
|
168 { |
|
169 TRACE_ENTRY_POINT; |
|
170 |
|
171 TInt attachmentSize; |
|
172 attachmentSize = CCalenAttachmentUtils::GetFileSizeL(aFullName); |
|
173 |
|
174 |
|
175 if( CheckFileSizeLimitL( attachmentSize ) ) |
|
176 { |
|
177 |
|
178 TDataType dataType; |
|
179 dataType = CCalenAttachmentUtils::GetMimeTypeL(aFullName); |
|
180 |
|
181 CCalenAttachmentInfo* info = CreateNewInfoL( aFullName, aSystemFileName, attachmentSize, ETrue, |
|
182 dataType, CCalenAttachmentInfo::ECalenNewAttachment ); |
|
183 CleanupStack::PushL(info); |
|
184 |
|
185 iAttachInfoArray.AppendL(info); |
|
186 isAttachmentModelCleared = EFalse; |
|
187 if((iAttachmentModelObserver!=NULL) && (NumberOfItems()>0)) |
|
188 { |
|
189 iAttachmentModelObserver->NotifyChanges( |
|
190 MCalenAttachmentModelObserver::ECalenAttachmentAdded, 0 ); |
|
191 } |
|
192 |
|
193 CleanupStack::Pop(); // info |
|
194 } |
|
195 else |
|
196 { |
|
197 iAttachmentModelObserver->NotifyChanges( |
|
198 MCalenAttachmentModelObserver::ECalenAttachmentAdded, 0 ); |
|
199 |
|
200 } |
|
201 TRACE_EXIT_POINT; |
|
202 } |
|
203 |
|
204 // ---------------------------------------------------------------------------- |
|
205 // CCalenAttachmentModel::CheckFileSizeLimitL |
|
206 // checks if the total attachment size and the new file size exceeds |
|
207 // attachments from the calentry |
|
208 // ---------------------------------------------------------------------------- |
|
209 // |
|
210 TBool CCalenAttachmentModel::CheckFileSizeLimitL( TInt aNewFileSize ) |
|
211 { |
|
212 TRACE_ENTRY_POINT; |
|
213 |
|
214 TInt currAttachmentSize( KErrNone ); |
|
215 TBool fileSizeOk( EFalse ); |
|
216 //Check if the attachement size plus the current attachment size equals 1MB |
|
217 for( int index = 0 ;index < iAttachInfoArray.Count();index++ ) |
|
218 { |
|
219 currAttachmentSize += AttachmentInfoAt(index).Size(); |
|
220 } |
|
221 |
|
222 if( ( currAttachmentSize + aNewFileSize ) <= 1024000 ) |
|
223 { |
|
224 fileSizeOk = ETrue; |
|
225 } |
|
226 else |
|
227 { |
|
228 // attachment size is exceeded, show the info note for this info. |
|
229 CDesCArrayFlat* sizeArray = new(ELeave)CDesCArrayFlat(2); |
|
230 CleanupStack::PushL( sizeArray ); |
|
231 |
|
232 TBuf<KBuffLength> totalLimitBuf; |
|
233 totalLimitBuf.Zero(); |
|
234 totalLimitBuf.Format( KFormatString, KTotalAttachLimit ); |
|
235 |
|
236 TBuf<KBuffLength> availableBuf; |
|
237 TInt avaiableSize( KErrNone ); |
|
238 availableBuf.Zero(); |
|
239 avaiableSize = ( 1024000 - currAttachmentSize )/1000; |
|
240 |
|
241 if( avaiableSize < KTen ) |
|
242 { |
|
243 availableBuf.Format( KFormatString, avaiableSize ); |
|
244 } |
|
245 else if( ( avaiableSize/KTen )< KTen ) |
|
246 { |
|
247 availableBuf.Format( KFormatStringTwoDigit, avaiableSize ); |
|
248 } |
|
249 else |
|
250 { |
|
251 availableBuf.Format( KFormatStringThreeDigit, avaiableSize ); |
|
252 } |
|
253 |
|
254 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( totalLimitBuf ); |
|
255 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( availableBuf ); |
|
256 |
|
257 sizeArray->AppendL( totalLimitBuf ); |
|
258 sizeArray->AppendL( availableBuf ); |
|
259 |
|
260 CAknInformationNote* note = new ( ELeave ) CAknInformationNote(ETrue); |
|
261 HBufC* attachSizeExceeded = StringLoader::LoadLC( |
|
262 R_QTN_CALEN_SIZE_EXCEEDED ,CEikonEnv::Static()); |
|
263 |
|
264 TPtr ptr = attachSizeExceeded->Des(); |
|
265 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
|
266 |
|
267 note->ExecuteLD( *attachSizeExceeded ); |
|
268 |
|
269 CleanupStack::PopAndDestroy( attachSizeExceeded ); |
|
270 CleanupStack::PopAndDestroy( sizeArray ); |
|
271 |
|
272 } |
|
273 |
|
274 return fileSizeOk; |
|
275 TRACE_EXIT_POINT; |
|
276 } |
|
277 |
|
278 // ---------------------------------------------------------------------------- |
|
279 // CCalenAttachmentModel::AddAttachmentL |
|
280 // adds an attachment info in to model,used while fetching already saved |
|
281 // attachments from the calentry |
|
282 // ---------------------------------------------------------------------------- |
|
283 // |
|
284 EXPORT_C void CCalenAttachmentModel::AddAttachmentL( |
|
285 const TDesC& aFullName, |
|
286 const TDesC& aSystemFileName, |
|
287 TInt aSize, |
|
288 TBool aFetched, |
|
289 const TDataType& aDataType, |
|
290 RFile& aFile) |
|
291 { |
|
292 |
|
293 TRACE_ENTRY_POINT; |
|
294 |
|
295 CCalenAttachmentInfo* info = |
|
296 CreateNewInfoL( aFullName, |
|
297 aSystemFileName, |
|
298 aSize, |
|
299 aFetched, |
|
300 aDataType, |
|
301 CCalenAttachmentInfo::ECalenAttachmentFetchedFromEntry ); |
|
302 CleanupStack::PushL(info); |
|
303 info->SetFileHandle( aFile ); |
|
304 iAttachInfoArray.AppendL(info); |
|
305 CleanupStack::Pop(); |
|
306 isAttachmentModelCleared = EFalse; |
|
307 |
|
308 TRACE_EXIT_POINT; |
|
309 |
|
310 } |
|
311 |
|
312 // ---------------------------------------------------------------------------- |
|
313 // CCalenAttachmentModel::DeleteAttachment |
|
314 // Deletes attachment from internal array. Notifies attachment model |
|
315 // observer with ECalenAttachmentRemoved parameter. |
|
316 // ---------------------------------------------------------------------------- |
|
317 // |
|
318 EXPORT_C TBool CCalenAttachmentModel::DeleteAttachment( TInt aIndex ) |
|
319 { |
|
320 |
|
321 TRACE_ENTRY_POINT; |
|
322 |
|
323 TInt attachmentDeleted(EFalse); |
|
324 TRAP_IGNORE( attachmentDeleted = DoDeleteAttachmentL( aIndex ) ); |
|
325 |
|
326 TRACE_EXIT_POINT; |
|
327 return attachmentDeleted; |
|
328 } |
|
329 |
|
330 // ---------------------------------------------------------------------------- |
|
331 // CCalenAttachmentModel::DoDeleteAttachmentL |
|
332 // Deletes attachment from internal array. Notifies attachment model |
|
333 // observer with ECalenAttachmentRemoved parameter. |
|
334 // (rest of the details are commented in the header) |
|
335 // ---------------------------------------------------------------------------- |
|
336 // |
|
337 TBool CCalenAttachmentModel::DoDeleteAttachmentL( TInt aIndex ) |
|
338 { |
|
339 |
|
340 TRACE_EXIT_POINT; |
|
341 |
|
342 if( 0 <= aIndex && aIndex < iAttachInfoArray.Count() ) |
|
343 { |
|
344 // Get the attachment information. |
|
345 CCalenAttachmentInfo* attachmentInfo = NULL; |
|
346 attachmentInfo = iAttachInfoArray[ aIndex ]; |
|
347 |
|
348 // Get the attachment file name |
|
349 TFileName fileName( attachmentInfo->FileName() ); |
|
350 |
|
351 TParsePtrC fileNameParser(fileName); |
|
352 TPtrC parsedFileName = fileNameParser.NameAndExt(); |
|
353 |
|
354 // Confirm if needs to be deleted. |
|
355 CAknQueryDialog* confirmQuery = NULL; |
|
356 confirmQuery = CAknQueryDialog::NewL(); |
|
357 HBufC* stringBuf = NULL; |
|
358 stringBuf = StringLoader::LoadLC( |
|
359 R_QTN_QUERY_COMMON_CONF_REMOVE, |
|
360 parsedFileName, |
|
361 CEikonEnv::Static() ); |
|
362 confirmQuery->SetPromptL( *stringBuf ); |
|
363 if( EAknSoftkeyYes != |
|
364 confirmQuery->ExecuteLD( R_CALEN_ATTACHMENT_DELETE_QUERY ) ) |
|
365 { |
|
366 // Return without doing anything if `No' is pressed. |
|
367 CleanupStack::PopAndDestroy( stringBuf ); |
|
368 TRACE_EXIT_POINT; |
|
369 return EFalse; |
|
370 } |
|
371 |
|
372 // Delete the attachment and notify the observers. |
|
373 delete attachmentInfo; |
|
374 iAttachInfoArray.Remove( aIndex ); |
|
375 |
|
376 if( iAttachmentModelObserver ) |
|
377 { |
|
378 iAttachmentModelObserver->NotifyChanges( |
|
379 MCalenAttachmentModelObserver::ECalenAttachmentRemoved, |
|
380 aIndex ); |
|
381 } |
|
382 |
|
383 // Delete the file from temporary directory. |
|
384 CFileMan* fileMan = CFileMan::NewL( CEikonEnv::Static()->FsSession() ); |
|
385 CleanupStack::PushL( fileMan ); |
|
386 TFileName temporaryPath; |
|
387 CCalenAttachmentUtils::GetCalenEditorTempPath( temporaryPath, &fileName ); |
|
388 fileMan->Delete( temporaryPath ); |
|
389 |
|
390 // Cleanup. |
|
391 CleanupStack::PopAndDestroy( fileMan ); |
|
392 CleanupStack::PopAndDestroy( stringBuf ); |
|
393 } |
|
394 |
|
395 TRACE_EXIT_POINT; |
|
396 return ETrue; |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // CCalenAttachmentModel::Reset |
|
401 // Reset the attachment model (empties the internal array). |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 EXPORT_C void CCalenAttachmentModel::Reset() |
|
405 { |
|
406 |
|
407 TRACE_ENTRY_POINT; |
|
408 |
|
409 if( iAttachInfoArray.Count() ) |
|
410 { |
|
411 iAttachInfoArray.ResetAndDestroy(); |
|
412 } |
|
413 else |
|
414 { |
|
415 iAttachInfoArray.Reset(); |
|
416 } |
|
417 |
|
418 isAttachmentModelCleared = ETrue; |
|
419 |
|
420 TRACE_EXIT_POINT; |
|
421 |
|
422 } |
|
423 |
|
424 // ---------------------------------------------------------------------------- |
|
425 // CCalenAttachmentModel::BitmapForFileL |
|
426 // Returns pointer to bitmap of the application that handles given file. |
|
427 // ---------------------------------------------------------------------------- |
|
428 // |
|
429 EXPORT_C CGulIcon* CCalenAttachmentModel::BitmapForFileL( |
|
430 CCalenAttachmentInfo& aAttaInfo ) |
|
431 { |
|
432 TRACE_ENTRY_POINT; |
|
433 |
|
434 TUid appUid( KNullUid ); |
|
435 // Get data appuid based on the datatype: |
|
436 TInt err = iAppList.AppForDataType( aAttaInfo.DataType(), appUid ); |
|
437 |
|
438 if( aAttaInfo.DataType().Des8().Compare( KTextDataType ) == 0 ) |
|
439 { |
|
440 appUid.iUid = KNotepadUID; |
|
441 err = KErrNone; |
|
442 } |
|
443 |
|
444 // get bitmap based on the appuid |
|
445 CGulIcon* icon = BitmapForAppL(appUid); |
|
446 CleanupStack::PushL(icon); |
|
447 AknIconUtils::SetSize( icon->Bitmap(), iIconSize ); |
|
448 CleanupStack::Pop(icon); |
|
449 |
|
450 TRACE_ENTRY_POINT; |
|
451 return icon; |
|
452 } |
|
453 |
|
454 // ---------------------------------------------------------------------------- |
|
455 // CCalenAttachmentModel::LoadResourcesL |
|
456 // Loads resources |
|
457 // ---------------------------------------------------------------------------- |
|
458 EXPORT_C void CCalenAttachmentModel::LoadResourcesL() |
|
459 { |
|
460 TRACE_ENTRY_POINT; |
|
461 |
|
462 // Resolve icon layout |
|
463 TRect mainPane; |
|
464 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
465 TAknLayoutRect listPaneLayout; |
|
466 listPaneLayout.LayoutRect( mainPane, AknLayout::list_gen_pane( 0 ) ); |
|
467 TAknLayoutRect doubleGraphicLayout; |
|
468 doubleGraphicLayout.LayoutRect( listPaneLayout.Rect(), |
|
469 AknLayout::list_double_large_graphic_pane_list_double2_large_graphic_pane_list_single_big_large_graphic_pane( 0 ) ); |
|
470 TAknLayoutRect iconLayout; |
|
471 iconLayout.LayoutRect( doubleGraphicLayout.Rect(), |
|
472 AknLayout::List_pane_elements__double_large_graphic__Line_8() ); |
|
473 TAknLayoutRect addIconLayout; |
|
474 addIconLayout.LayoutRect( doubleGraphicLayout.Rect(), |
|
475 AknLayout::List_pane_elements__double_large_graphic__Line_9( 0 ) ); |
|
476 |
|
477 iIconSize = iconLayout.Rect().Size(); |
|
478 |
|
479 TInt count = iAttachInfoArray.Count(); |
|
480 while(count--) |
|
481 { |
|
482 // Update already existing icons |
|
483 iAttachInfoArray[count]->DoUpdateIconL(); |
|
484 } |
|
485 |
|
486 TRACE_EXIT_POINT; |
|
487 } |
|
488 |
|
489 // ---------------------------------------------------------------------------- |
|
490 // CCalenAttachmentModel::GetAttachmentFileL |
|
491 // Get attachment file |
|
492 // ---------------------------------------------------------------------------- |
|
493 // |
|
494 EXPORT_C RFile CCalenAttachmentModel::GetAttachmentFileL(TInt aIndex) |
|
495 { |
|
496 TRACE_ENTRY_POINT; |
|
497 |
|
498 RFile file; |
|
499 CCalenAttachmentInfo* attachmentInfo = iAttachInfoArray[aIndex]; |
|
500 if( attachmentInfo->IsFileHandleSet() ) |
|
501 { |
|
502 attachmentInfo->FileHandle(file); |
|
503 } |
|
504 else |
|
505 { |
|
506 TParsePtrC fileNameParser(attachmentInfo->SystemFileName()); |
|
507 CEikonEnv* eikonEnv = CEikonEnv::Static(); |
|
508 RFs& fs = eikonEnv->FsSession(); |
|
509 User::LeaveIfError(fs.ShareProtected()); |
|
510 TInt err = file.Open( fs, attachmentInfo->SystemFileName(), |
|
511 EFileRead|EFileShareReadersOnly); |
|
512 if(err == KErrInUse) |
|
513 { |
|
514 file.Close(); |
|
515 User::LeaveIfError( file.Open( fs, attachmentInfo->SystemFileName(), |
|
516 EFileRead|EFileShareReadersOnly) ); |
|
517 } |
|
518 } |
|
519 |
|
520 TRACE_EXIT_POINT; |
|
521 return file; |
|
522 } |
|
523 |
|
524 // ---------------------------------------------------------------------------- |
|
525 // CCalenAttachmentModel::BitmapForAppL |
|
526 // Returns pointer to bitmap of given application. |
|
527 // ---------------------------------------------------------------------------- |
|
528 // |
|
529 CGulIcon* CCalenAttachmentModel::BitmapForAppL( const TUid &aAppUid ) |
|
530 { |
|
531 TRACE_ENTRY_POINT; |
|
532 |
|
533 CFbsBitmap* tempBitmap = NULL; |
|
534 CFbsBitmap* tempMask = NULL; |
|
535 |
|
536 AknsUtils::CreateAppIconLC( AknsUtils::SkinInstance(), |
|
537 aAppUid, |
|
538 EAknsAppIconTypeList, |
|
539 tempBitmap, |
|
540 tempMask ); |
|
541 |
|
542 CGulIcon* bitmap = CGulIcon::NewL( tempBitmap, tempMask ); |
|
543 CleanupStack::Pop(2); // tempBitmap, tempMask |
|
544 |
|
545 TRACE_EXIT_POINT; |
|
546 return bitmap; |
|
547 } |
|
548 |
|
549 // ---------------------------------------------------------------------------- |
|
550 // CCalenAttachmentModel::CreateNewInfoL |
|
551 // Creates new attachment info object. |
|
552 // ---------------------------------------------------------------------------- |
|
553 // |
|
554 CCalenAttachmentInfo* CCalenAttachmentModel::CreateNewInfoL( |
|
555 const TDesC& aFileName, |
|
556 const TDesC& aSystemFileName, |
|
557 TInt aSize, TBool aFetched, |
|
558 const TDataType& aDataType, |
|
559 CCalenAttachmentInfo::TCalenAttachmentStoreType aStoreType) |
|
560 { |
|
561 TRACE_ENTRY_POINT; |
|
562 TRACE_EXIT_POINT; |
|
563 |
|
564 return CCalenAttachmentInfo::NewL( *this, aFileName, aSystemFileName, aSize, |
|
565 aFetched, aDataType, aStoreType); |
|
566 } |
|
567 |
|
568 // ---------------------------------------------------------------------------- |
|
569 // CCalenAttachmentModel::GetAttachmentListL |
|
570 // Returns attachment list |
|
571 // ---------------------------------------------------------------------------- |
|
572 // |
|
573 EXPORT_C void CCalenAttachmentModel::GetAttachmentListL( |
|
574 RPointerArray<CCalenAttachmentInfo> &aAttachmentList) |
|
575 { |
|
576 TRACE_ENTRY_POINT; |
|
577 |
|
578 for(TInt index=0;index<iAttachInfoArray.Count();index++) |
|
579 { |
|
580 aAttachmentList.Append(iAttachInfoArray[index]); |
|
581 } |
|
582 |
|
583 TRACE_EXIT_POINT; |
|
584 } |
|
585 |
|
586 // ---------------------------------------------------------------------------- |
|
587 // CCalenAttachmentModel::CheckForExistingAttachmentsL |
|
588 // check for already existing attachments from the entry |
|
589 // ---------------------------------------------------------------------------- |
|
590 // |
|
591 EXPORT_C void CCalenAttachmentModel::CheckForExistingAttachmentsL( CCalEntry* aEntry ) |
|
592 { |
|
593 |
|
594 TRACE_ENTRY_POINT; |
|
595 |
|
596 if( isAttachmentModelCleared && aEntry ) |
|
597 { |
|
598 TInt attachmentCount = aEntry->AttachmentCountL(); |
|
599 if( attachmentCount ) |
|
600 { |
|
601 for(TInt index=0;index<attachmentCount;index++) |
|
602 { |
|
603 CCalAttachment* attachment = aEntry->AttachmentL(index); |
|
604 if(attachment->FileAttachment()) |
|
605 { |
|
606 RFile fileHandle; |
|
607 CleanupClosePushL(fileHandle); |
|
608 attachment->FileAttachment()->FetchFileHandleL(fileHandle); |
|
609 |
|
610 TFileName fileName(attachment->Label()); |
|
611 TFileName systemFileName; |
|
612 fileHandle.FullName(systemFileName); |
|
613 TDataType fileMimeType(attachment->MimeType()); |
|
614 TInt fileSize(0); |
|
615 fileHandle.Size(fileSize); |
|
616 |
|
617 AddAttachmentL( fileName, systemFileName, fileSize, |
|
618 ETrue, fileMimeType, fileHandle); |
|
619 CleanupStack::PopAndDestroy(&fileHandle); |
|
620 } |
|
621 } |
|
622 } |
|
623 } |
|
624 |
|
625 TRACE_EXIT_POINT; |
|
626 } |
|
627 |
|
628 // ---------------------------------------------------------------------------- |
|
629 // CCalenAttachmentModel::AttachmentOpen |
|
630 // Set the flag if the attachment(Photo, audio and vedio files) is open. |
|
631 // ---------------------------------------------------------------------------- |
|
632 // |
|
633 EXPORT_C void CCalenAttachmentModel::AttachmentOpen(TBool& aEmbeddedFileOpened) |
|
634 { |
|
635 TRACE_ENTRY_POINT |
|
636 iEmbeddedFileOpened = aEmbeddedFileOpened; |
|
637 TRACE_EXIT_POINT |
|
638 } |
|
639 // ---------------------------------------------------------------------------- |
|
640 // CCalenAttachmentModel::IsAttachmentOpen |
|
641 // return True if the atacchment is opened. |
|
642 // ---------------------------------------------------------------------------- |
|
643 // |
|
644 EXPORT_C TBool CCalenAttachmentModel::IsAttachmentOpen() |
|
645 { |
|
646 TRACE_ENTRY_POINT |
|
647 TRACE_EXIT_POINT |
|
648 return iEmbeddedFileOpened; |
|
649 } |
|
650 // End of file --Don't remove this. |