64
|
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: Attachment fetch utility class for event viewers and editors
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cmrattachmentui.h"
|
|
19 |
#include "cmrattachmentprogressinfo.h"
|
|
20 |
#include "mesmrcalentry.h"
|
|
21 |
#include "cmrfilemanager.h"
|
|
22 |
#include "cmrgrid.h"
|
|
23 |
#include "cesmrglobalnote.h"
|
|
24 |
#include "esmrhelper.h"
|
|
25 |
|
|
26 |
#include <MGFetch.h>
|
|
27 |
#include <aknlistquerydialog.h>
|
|
28 |
#include <sysutil.h>
|
|
29 |
#include <calattachment.h>
|
|
30 |
#include <NpdApi.h>
|
|
31 |
#include <AknCommonDialogsDynMem.h>
|
|
32 |
#include <apparc.h>
|
|
33 |
#include <esmrgui.rsg>
|
|
34 |
#include <apgcli.h>
|
|
35 |
#include <apmrec.h>
|
|
36 |
#include <CommonContentPolicy.h>
|
|
37 |
#include <ct/rcpointerarray.h>
|
|
38 |
#include <aknnotewrappers.h>
|
|
39 |
#include <StringLoader.h>
|
|
40 |
|
|
41 |
#include "emailtrace.h"
|
|
42 |
|
|
43 |
namespace // codescanner::namespace
|
|
44 |
{
|
|
45 |
_LIT8( KUnknownDatatype, "unknown");
|
|
46 |
|
|
47 |
const TInt KTempTextFileNameLength( 20 );
|
|
48 |
_LIT( KTextFilenameExtension, ".txt" );
|
|
49 |
|
|
50 |
/**
|
|
51 |
* Check if the character is illegal for the filename
|
|
52 |
*/
|
|
53 |
TBool IsIllegalChar(const TUint aChar)
|
|
54 |
{
|
|
55 |
return (
|
|
56 |
aChar == '*' ||
|
|
57 |
aChar == '\\' ||
|
|
58 |
aChar == '<' ||
|
|
59 |
aChar == '>' ||
|
|
60 |
aChar == ':' ||
|
|
61 |
aChar == '.' ||
|
|
62 |
aChar == '"' ||
|
|
63 |
aChar == '/' ||
|
|
64 |
aChar == '|' ||
|
|
65 |
aChar == '?' ||
|
|
66 |
aChar == CEditableText::EParagraphDelimiter ||
|
|
67 |
aChar == CEditableText::ELineBreak ||
|
|
68 |
aChar < ' ' );
|
|
69 |
}
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Get the file name by making use of the content
|
|
73 |
*/
|
|
74 |
void GetFileNameFromBuffer( TFileName& aFileName,
|
|
75 |
const TDesC& aBuffer, TInt aMaxLength, const TDesC* aExt /*= NULL*/ )
|
|
76 |
{
|
|
77 |
if(aExt!=NULL)
|
|
78 |
{
|
|
79 |
aMaxLength -= aExt->Length();
|
|
80 |
}
|
|
81 |
|
|
82 |
TInt len = aBuffer.Length();
|
|
83 |
TInt max = Min( len, aMaxLength );
|
|
84 |
aFileName.Zero();
|
|
85 |
|
|
86 |
TInt cc = 0;
|
|
87 |
TUint ch;
|
|
88 |
TUint ch1 = 0;
|
|
89 |
TBool spaces = EFalse;
|
|
90 |
for( TInt i = 0; i < len && cc < max; i++ )
|
|
91 |
{
|
|
92 |
ch = aBuffer[i];
|
|
93 |
|
|
94 |
// ignore spaces from beginning of the buffer until first
|
|
95 |
// non-space is encountered.
|
|
96 |
if( !spaces && ch != ' ' )
|
|
97 |
{
|
|
98 |
spaces = ETrue;
|
|
99 |
}
|
|
100 |
|
|
101 |
if(i>0)
|
|
102 |
{
|
|
103 |
ch1 = aBuffer[i-1];
|
|
104 |
}
|
|
105 |
|
|
106 |
// strip illegal chars away.
|
|
107 |
// checks also if previous and current chars are '.'
|
|
108 |
if( spaces && !IsIllegalChar(ch) )
|
|
109 |
{
|
|
110 |
if( !( i > 0 && ch == '.' && ch1 == '.' ) )
|
|
111 |
{
|
|
112 |
aFileName.Append( ch );
|
|
113 |
cc++;
|
|
114 |
}
|
|
115 |
}
|
|
116 |
}
|
|
117 |
|
|
118 |
aFileName.Trim();
|
|
119 |
|
|
120 |
// If filename is empty at this point, do not append extension either.
|
|
121 |
// Instead, empty filename is returned so that caller can use whatever
|
|
122 |
// default name
|
|
123 |
if( aFileName.Length() > 0 && aExt != NULL )
|
|
124 |
{
|
|
125 |
aFileName.Append(*aExt);
|
|
126 |
}
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
EXPORT_C CMRAttachmentUi* CMRAttachmentUi::NewL()
|
|
135 |
{
|
|
136 |
FUNC_LOG;
|
|
137 |
|
|
138 |
CMRAttachmentUi* self = new ( ELeave ) CMRAttachmentUi();
|
|
139 |
CleanupStack::PushL( self );
|
|
140 |
self->ConstructL();
|
|
141 |
CleanupStack::Pop( self );
|
|
142 |
return self;
|
|
143 |
}
|
|
144 |
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
EXPORT_C TInt CMRAttachmentUi::LaunchFetchUi( MESMRCalEntry& aEntry )
|
|
150 |
{
|
|
151 |
FUNC_LOG;
|
|
152 |
|
|
153 |
iEntry = &aEntry;
|
|
154 |
|
|
155 |
TInt error( KErrNone );
|
|
156 |
TRAP( error, DoLaunchFetchUiL() );
|
|
157 |
return error;
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
EXPORT_C TInt CMRAttachmentUi::LaunchViewerUi( MESMRCalEntry& aEntry )
|
|
165 |
{
|
|
166 |
FUNC_LOG;
|
|
167 |
|
|
168 |
iEntry = &aEntry;
|
|
169 |
TInt error( KErrNone );
|
|
170 |
TRAP( error, DoLaunchViewerUiL() );
|
|
171 |
return error;
|
|
172 |
}
|
|
173 |
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
EXPORT_C CMRAttachmentUi::~CMRAttachmentUi()
|
|
179 |
{
|
|
180 |
FUNC_LOG;
|
|
181 |
|
|
182 |
delete iFilesToCopy;
|
|
183 |
delete iFilesToAdd;
|
|
184 |
delete iManager;
|
|
185 |
delete iProgress;
|
|
186 |
iFsSession.Close();
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
EXPORT_C void CMRAttachmentUi::SetObserver( MMRAttachmentUiObserver& aObserver )
|
|
194 |
{
|
|
195 |
FUNC_LOG;
|
|
196 |
|
|
197 |
iObserver = &aObserver;
|
|
198 |
}
|
|
199 |
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
EXPORT_C TAttachmentOpResult CMRAttachmentUi::LatestOperationResult()
|
|
205 |
{
|
|
206 |
FUNC_LOG;
|
|
207 |
|
|
208 |
TAttachmentOpResult result;
|
|
209 |
result.iFiles = &(iManager->CopiedFiles());
|
|
210 |
return result;
|
|
211 |
}
|
|
212 |
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
CMRAttachmentUi::CMRAttachmentUi()
|
|
218 |
{
|
|
219 |
FUNC_LOG;
|
|
220 |
|
|
221 |
}
|
|
222 |
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
void CMRAttachmentUi::ConstructL()
|
|
228 |
{
|
|
229 |
FUNC_LOG;
|
|
230 |
|
|
231 |
}
|
|
232 |
|
|
233 |
// ---------------------------------------------------------------------------
|
|
234 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
235 |
// ---------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CMRAttachmentUi::DoLaunchFetchUiL()
|
|
238 |
{
|
|
239 |
FUNC_LOG;
|
|
240 |
|
|
241 |
TMediaFileType type = ResolveAttachmentTypeL();
|
|
242 |
|
|
243 |
if ( ENoMediaFile != type )
|
|
244 |
{
|
|
245 |
// Create array of descriptors for the selected files
|
|
246 |
iFilesToCopy = new ( ELeave ) CDesCArrayFlat( 5 );
|
|
247 |
iFilesToAdd = new ( ELeave ) CDesCArrayFlat( 1 );
|
|
248 |
TBool retval( EFalse );
|
|
249 |
HBufC* buf = NULL;
|
|
250 |
// Connect session
|
|
251 |
User::LeaveIfError( iFsSession.Connect() );
|
|
252 |
User::LeaveIfError( iFsSession.ShareProtected() );
|
|
253 |
|
|
254 |
if( type == EPresentationsFile )
|
|
255 |
{
|
|
256 |
buf = CNotepadApi::FetchMemoL();
|
|
257 |
if( buf )
|
|
258 |
{
|
|
259 |
CleanupStack::PushL(buf);
|
|
260 |
|
|
261 |
TFileName filename;
|
|
262 |
TInt max = KTempTextFileNameLength;
|
|
263 |
|
|
264 |
// first try to create filename from memo text.
|
|
265 |
GetFileNameFromBuffer( filename, *buf, max, &KTextFilenameExtension );
|
|
266 |
|
|
267 |
TFileName tempPath;
|
|
268 |
User::LeaveIfError( ESMRHelper::CreateAndAppendPrivateDirToFileName( tempPath ) );
|
|
269 |
tempPath.Append( filename );
|
|
270 |
|
|
271 |
// check the file name for validity and possible name duplicates.
|
|
272 |
TInt err = CApaApplication::GenerateFileName( iFsSession, tempPath );
|
|
273 |
|
|
274 |
if( err == KErrNone )
|
|
275 |
{
|
|
276 |
// write buffer to text file
|
|
277 |
CPlainText* text = CPlainText::NewL();
|
|
278 |
CleanupStack::PushL( text );
|
|
279 |
text->InsertL( 0, *buf );
|
|
280 |
text->ExportAsTextL( tempPath, CPlainText::EOrganiseByParagraph, 0 );
|
|
281 |
CleanupStack::PopAndDestroy( text );
|
|
282 |
iFilesToAdd->AppendL( tempPath );
|
|
283 |
}
|
|
284 |
|
|
285 |
CleanupStack::PopAndDestroy( buf );
|
|
286 |
}
|
|
287 |
}
|
|
288 |
else if( type == EAnyMediaFile )
|
|
289 |
{
|
|
290 |
TInt supportedTypes = AknCommonDialogsDynMem::EMemoryTypePhone |
|
|
291 |
AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage |
|
|
292 |
AknCommonDialogsDynMem::EMemoryTypeMMCExternal;
|
|
293 |
|
|
294 |
TFileName filename;
|
|
295 |
retval = AknCommonDialogsDynMem::RunSelectDlgLD( supportedTypes,
|
|
296 |
filename,
|
|
297 |
R_MR_ATTACHMENT_MEMORY_SELECTION_DIALOG,
|
|
298 |
/*aFilter*/NULL,
|
|
299 |
/*aVerifier*/this );
|
|
300 |
if( retval )
|
|
301 |
{
|
|
302 |
iFilesToCopy->AppendL( filename );
|
|
303 |
}
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
// Open the dialog.
|
|
308 |
retval = MGFetch::RunL(
|
|
309 |
*iFilesToCopy, // When dialog is closed, fileArray contains selected files
|
|
310 |
type, // Displays only media files of type aMediaType
|
|
311 |
ETrue, // single or multiple file selection
|
|
312 |
this // Pointer to class implementing MMGFetchVerifier;
|
|
313 |
// when user has selected file(s),
|
|
314 |
// MMGFetchVerifier::VerifySelectionL is called.
|
|
315 |
);
|
|
316 |
}
|
|
317 |
|
|
318 |
TInt index(0);
|
|
319 |
while ( index < iFilesToCopy->MdcaCount() )
|
|
320 |
{
|
|
321 |
TPtrC filename( iFilesToCopy->MdcaPoint(index) );
|
|
322 |
if ( IsDuplicateNameL( filename ) )
|
|
323 |
{
|
|
324 |
iFilesToCopy->Delete( index );
|
|
325 |
|
|
326 |
//though attachment is aleady attached to this entry, show the info note for this info.
|
|
327 |
CAknInformationNote* note = new ( ELeave ) CAknInformationNote(ETrue);
|
|
328 |
HBufC* cannotAttach = StringLoader::LoadLC(
|
|
329 |
R_QTN_MEET_REQ_INFO_ALREADY_ATTACHED );
|
|
330 |
note->ExecuteLD( *cannotAttach );
|
|
331 |
CleanupStack::PopAndDestroy( cannotAttach );
|
|
332 |
}
|
|
333 |
else
|
|
334 |
{
|
|
335 |
++index;
|
|
336 |
}
|
|
337 |
}
|
|
338 |
|
|
339 |
// Start copy
|
|
340 |
if( iFilesToCopy->MdcaCount() > 0 )
|
|
341 |
{
|
|
342 |
// Count files to be copied
|
|
343 |
iFileCount = iFilesToCopy->Count();
|
|
344 |
if( iFileCount > 0 )
|
|
345 |
{
|
|
346 |
StartCopyOpL();
|
|
347 |
}
|
|
348 |
}
|
|
349 |
// Add directly to CCalAttachment, no copy needed
|
|
350 |
else if( iFilesToAdd->MdcaCount() > 0 )
|
|
351 |
{
|
|
352 |
UpdateEntryL();
|
|
353 |
}
|
|
354 |
}
|
|
355 |
}
|
|
356 |
|
|
357 |
// ---------------------------------------------------------------------------
|
|
358 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
//
|
|
361 |
void CMRAttachmentUi::StartCopyOpL()
|
|
362 |
{
|
|
363 |
FUNC_LOG;
|
|
364 |
|
|
365 |
// Fetch the first filename from the array
|
|
366 |
TInt size( 0 );
|
|
367 |
for( TInt i = 0; i < iFileCount; ++i )
|
|
368 |
{
|
|
369 |
const TDesC& originalPath = (*iFilesToCopy)[i];
|
|
370 |
TEntry entry;
|
|
371 |
User::LeaveIfError( iFsSession.Entry( originalPath,entry ) );
|
|
372 |
// Count total size for the progressbar
|
|
373 |
size += entry.iSize;
|
|
374 |
}
|
|
375 |
|
|
376 |
if( !iManager )
|
|
377 |
{
|
|
378 |
iManager = CMRFileManager::NewL(iFsSession);
|
|
379 |
}
|
|
380 |
if( !iProgress )
|
|
381 |
{
|
|
382 |
iProgress = CMRAttachmentProgressInfo::NewL( *iManager, *this );
|
|
383 |
}
|
|
384 |
// Give total size to progress bar
|
|
385 |
// Set progressbar as a observer to copy operation
|
|
386 |
iProgress->StartProgressNoteL( size );
|
|
387 |
|
|
388 |
// Check if there is space available
|
|
389 |
if( !SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, size ) )
|
|
390 |
{
|
|
391 |
iManager->SetObserver( *iProgress );
|
|
392 |
iManager->CopyFilesL( *iFilesToCopy );
|
|
393 |
}
|
|
394 |
}
|
|
395 |
|
|
396 |
// ---------------------------------------------------------------------------
|
|
397 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
398 |
// ---------------------------------------------------------------------------
|
|
399 |
//
|
|
400 |
void CMRAttachmentUi::UpdateEntryL()
|
|
401 |
{
|
|
402 |
FUNC_LOG;
|
|
403 |
|
|
404 |
MDesC16Array* fileArray = NULL;
|
|
405 |
if( iFilesToAdd->MdcaCount() > 0 )
|
|
406 |
{
|
|
407 |
fileArray = iFilesToAdd;
|
|
408 |
}
|
|
409 |
else
|
|
410 |
{
|
|
411 |
fileArray = &iManager->CopiedFiles();
|
|
412 |
}
|
|
413 |
|
|
414 |
TInt fileCount( fileArray->MdcaCount() );
|
|
415 |
|
|
416 |
for( TInt i = 0; i < fileCount; ++i )
|
|
417 |
{
|
|
418 |
const TDesC& fileName( fileArray->MdcaPoint(i) );
|
|
419 |
// When copy done add attachment File handles to calentry
|
|
420 |
RFile fileHandle;
|
|
421 |
User::LeaveIfError( fileHandle.Open(
|
|
422 |
iFsSession, fileName, EFileWrite ) );
|
|
423 |
CleanupClosePushL( fileHandle );
|
|
424 |
// create attachment and add to calendar entry
|
|
425 |
CCalAttachment* attachment = CCalAttachment::NewFileL( fileHandle );
|
|
426 |
|
|
427 |
RApaLsSession apaSession;
|
|
428 |
TDataRecognitionResult dataType;
|
|
429 |
User::LeaveIfError(apaSession.Connect());
|
|
430 |
apaSession.RecognizeData(fileHandle, dataType);
|
|
431 |
apaSession.Close();
|
|
432 |
|
|
433 |
TPtrC8 contentType( dataType.iDataType.Des8() );
|
|
434 |
|
|
435 |
if ( contentType.Length() )
|
|
436 |
{
|
|
437 |
attachment->SetMimeTypeL( contentType );
|
|
438 |
}
|
|
439 |
else
|
|
440 |
{
|
|
441 |
attachment->SetMimeTypeL( KUnknownDatatype );
|
|
442 |
}
|
|
443 |
|
|
444 |
CleanupStack::PopAndDestroy( &fileHandle );
|
|
445 |
CleanupStack::PushL( attachment );
|
|
446 |
// set attachment properties
|
|
447 |
const TDesC& filenameOriginal = iFilesToCopy->MdcaPoint( i );
|
|
448 |
TFileName label;
|
|
449 |
TParse parser;
|
|
450 |
parser.Set( filenameOriginal , NULL, NULL );
|
|
451 |
label.Append( parser.NameAndExt() );
|
|
452 |
attachment->SetLabelL( label );
|
|
453 |
|
|
454 |
|
|
455 |
|
|
456 |
iEntry->Entry().AddAttachmentL( *attachment ); // calEntry takes ownership
|
|
457 |
CleanupStack::Pop( attachment );
|
|
458 |
}
|
|
459 |
|
|
460 |
if( iObserver )
|
|
461 |
{
|
|
462 |
iObserver->AttachmentOperationCompleted( *iFilesToCopy );
|
|
463 |
}
|
|
464 |
}
|
|
465 |
|
|
466 |
// ---------------------------------------------------------------------------
|
|
467 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
468 |
// ---------------------------------------------------------------------------
|
|
469 |
//
|
|
470 |
void CMRAttachmentUi::DoLaunchViewerUiL()
|
|
471 |
{
|
|
472 |
FUNC_LOG;
|
|
473 |
|
|
474 |
}
|
|
475 |
|
|
476 |
// ---------------------------------------------------------------------------
|
|
477 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
478 |
// ---------------------------------------------------------------------------
|
|
479 |
//
|
|
480 |
TMediaFileType CMRAttachmentUi::ResolveAttachmentTypeL()
|
|
481 |
{
|
|
482 |
FUNC_LOG;
|
|
483 |
|
|
484 |
TMediaFileType type = ENoMediaFile;
|
|
485 |
TInt selectedOption( 0 );
|
|
486 |
|
|
487 |
if ( CMRGrid::ExecuteL( selectedOption ) )
|
|
488 |
{
|
|
489 |
switch( selectedOption )
|
|
490 |
{
|
|
491 |
case 0:
|
|
492 |
type = EImageFile;
|
|
493 |
break;
|
|
494 |
case 1:
|
|
495 |
type = EVideoFile;
|
|
496 |
break;
|
|
497 |
case 2:
|
|
498 |
type = EMusicFile;
|
|
499 |
break;
|
|
500 |
case 3:
|
|
501 |
type = EPresentationsFile;
|
|
502 |
break;
|
|
503 |
case 4:
|
|
504 |
type = EAnyMediaFile;
|
|
505 |
break;
|
|
506 |
|
|
507 |
default:
|
|
508 |
break;
|
|
509 |
}
|
|
510 |
}
|
|
511 |
|
|
512 |
return type;
|
|
513 |
}
|
|
514 |
|
|
515 |
// ---------------------------------------------------------------------------
|
|
516 |
// CMRAttachmentUi::AttachmentOperationCompleted
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
//
|
|
519 |
void CMRAttachmentUi::DialogDismissedL( TInt /*aButtonId*/ )
|
|
520 |
{
|
|
521 |
FUNC_LOG;
|
|
522 |
|
|
523 |
// Called whent the copy process has ended
|
|
524 |
UpdateEntryL();
|
|
525 |
}
|
|
526 |
|
|
527 |
// ---------------------------------------------------------------------------
|
|
528 |
// CMRAttachmentUi::VerifySelectionL
|
|
529 |
// ---------------------------------------------------------------------------
|
|
530 |
//
|
|
531 |
TBool CMRAttachmentUi::VerifySelectionL( const MDesCArray* aSelectedFiles )
|
|
532 |
{
|
|
533 |
FUNC_LOG;
|
|
534 |
|
|
535 |
TInt fileCount = aSelectedFiles->MdcaCount();
|
|
536 |
TBool isProtected = EFalse;
|
|
537 |
for( TInt i = 0; i < fileCount; ++i )
|
|
538 |
{
|
|
539 |
const TDesC& originalPath = aSelectedFiles->MdcaPoint( i );
|
|
540 |
RFile selected;
|
|
541 |
User::LeaveIfError( selected.Open(
|
|
542 |
iFsSession, originalPath, EFileRead ) );
|
|
543 |
CleanupClosePushL( selected );
|
|
544 |
isProtected = FileDrmProtectedL( selected );
|
|
545 |
CleanupStack::PopAndDestroy();
|
|
546 |
if ( isProtected )
|
|
547 |
{
|
|
548 |
break;
|
|
549 |
}
|
|
550 |
}
|
|
551 |
// Protected file returns verification fail and
|
|
552 |
// unprotected file returns verification ok
|
|
553 |
return !isProtected;
|
|
554 |
}
|
|
555 |
|
|
556 |
// ---------------------------------------------------------------------------
|
|
557 |
// CMRAttachmentUi::OkToExitL
|
|
558 |
// ---------------------------------------------------------------------------
|
|
559 |
//
|
|
560 |
TBool CMRAttachmentUi::OkToExitL(
|
|
561 |
const TDesC& aDriveAndPath,
|
|
562 |
const TEntry& aEntry )
|
|
563 |
{
|
|
564 |
FUNC_LOG;
|
|
565 |
|
|
566 |
TFileName path;
|
|
567 |
path = aDriveAndPath;
|
|
568 |
path.Append( aEntry.iName );
|
|
569 |
|
|
570 |
RFile selected;
|
|
571 |
User::LeaveIfError( selected.Open( iFsSession, path, EFileRead ) );
|
|
572 |
CleanupClosePushL( selected );
|
|
573 |
TBool isProtected = FileDrmProtectedL( selected );
|
|
574 |
CleanupStack::PopAndDestroy();
|
|
575 |
|
|
576 |
// Protected file returns not ok to exit and
|
|
577 |
// unprotected file returns ok to exit
|
|
578 |
return !isProtected;
|
|
579 |
}
|
|
580 |
|
|
581 |
// ---------------------------------------------------------------------------
|
|
582 |
// CMRAttachmentUi::FileDrmProtectedL
|
|
583 |
// ---------------------------------------------------------------------------
|
|
584 |
//
|
|
585 |
TBool CMRAttachmentUi::FileDrmProtectedL( RFile& aFile )
|
|
586 |
{
|
|
587 |
FUNC_LOG;
|
|
588 |
|
|
589 |
TBool isProtected( EFalse );
|
|
590 |
CCommonContentPolicy* ccp = CCommonContentPolicy::NewLC();
|
|
591 |
isProtected = ccp->IsClosedFileL( aFile );
|
|
592 |
if ( isProtected )
|
|
593 |
{
|
|
594 |
CESMRGlobalNote::ExecuteL
|
|
595 |
( CESMRGlobalNote::EESMRAlarmAlreadyPassed );
|
|
596 |
}
|
|
597 |
CleanupStack::PopAndDestroy( ccp );
|
|
598 |
return isProtected;
|
|
599 |
}
|
|
600 |
|
|
601 |
// ---------------------------------------------------------------------------
|
|
602 |
// CMRAttachmentUi::IsDuplicateNameL
|
|
603 |
// ---------------------------------------------------------------------------
|
|
604 |
//
|
|
605 |
TBool CMRAttachmentUi::IsDuplicateNameL(
|
|
606 |
const TDesC& aSelectedFile )
|
|
607 |
{
|
|
608 |
FUNC_LOG;
|
|
609 |
|
|
610 |
CCalEntry& entry( iEntry->Entry() );
|
|
611 |
|
|
612 |
TInt attachmentCount = entry.AttachmentCountL();
|
|
613 |
|
|
614 |
TBool matchNotFound( ETrue );
|
|
615 |
if( attachmentCount )
|
|
616 |
{
|
|
617 |
TParsePtrC fileNameParser(aSelectedFile);
|
|
618 |
TPtrC parsedFileName = fileNameParser.NameAndExt();
|
|
619 |
|
|
620 |
for(TInt index = 0; index < attachmentCount && matchNotFound; ++index)
|
|
621 |
{
|
|
622 |
CCalAttachment* attachment = entry.AttachmentL(index);
|
|
623 |
matchNotFound = parsedFileName.Compare( attachment->Label() );
|
|
624 |
}
|
|
625 |
}
|
|
626 |
|
|
627 |
return !matchNotFound;
|
|
628 |
}
|
|
629 |
|
|
630 |
// End of file
|
|
631 |
|