|
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 utils apis for fetching the attachments from other |
|
15 * : apps |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef CALENATTACHMENTUTILS_H |
|
20 #define CALENATTACHMENTUTILS_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <apparc.h> |
|
25 #include <badesca.h> |
|
26 #include <AknServerApp.h> |
|
27 #include <MediaFileTypes.hrh> |
|
28 #include <MMGFetchVerifier.h> |
|
29 #include <MAknFileFilter.h> |
|
30 #include <MAknFileSelectionObserver.h> |
|
31 #include <AknWaitNoteWrapper.h> |
|
32 #include <ConeResLoader.h> |
|
33 #include "calenattachmentmodel.h" |
|
34 |
|
35 class CAiwGenericParamList; |
|
36 class CCoeEnv; |
|
37 |
|
38 /** |
|
39 * Attachment utils used for attachment support |
|
40 */ |
|
41 class CCalenAttachmentUtils : public CBase |
|
42 { |
|
43 public: |
|
44 enum TCalenAttachmentFileType |
|
45 { |
|
46 EUnknown = 0, |
|
47 EImage, |
|
48 ENote, |
|
49 EAudio, |
|
50 EVideo |
|
51 }; |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Fetches an attachment of given type from external application. |
|
56 * |
|
57 * @param aType Fetch type. |
|
58 * @param aSelectedFiles OUT: array of selected files. |
|
59 * @param aParams Generic AIW parameters |
|
60 * @param aCheckDiskSpace |
|
61 * @param aMultiSelect if ETrue Media Gallery allows multiselect in file list. |
|
62 * @param aVerifier To verify selection. |
|
63 * @return EFalse if fetch canceled. |
|
64 */ |
|
65 IMPORT_C static TBool FetchFileL( TCalenAttachmentFileType aType, |
|
66 CDesCArray& aSelectedFiles, |
|
67 CAiwGenericParamList* aParams, |
|
68 TBool aCheckDiskSpace = EFalse, |
|
69 TBool aMultiSelect = EFalse, |
|
70 MMGFetchVerifier* aVerifier = NULL ); |
|
71 |
|
72 /** |
|
73 * Fetches an any attachment file from external application. |
|
74 * |
|
75 * @param aFileName OUT: filename of the fetched file. |
|
76 * @param aFilter To filter shown files. |
|
77 * @param aVerifier To verify selection. |
|
78 * @return EFalse if fetch canceled. |
|
79 */ |
|
80 IMPORT_C static TBool FetchAnyFileL( TFileName& aFileName, |
|
81 MAknFileSelectionObserver* aVerifier = NULL, |
|
82 MAknFileFilter* aFilter = NULL ); |
|
83 |
|
84 /** |
|
85 * Returns temp path used by calendar unified editor and optionally |
|
86 * appends file name to it. |
|
87 * |
|
88 * @param aTempPath generated temp path and filename. |
|
89 * @param aFileName optionally appended file name. |
|
90 */ |
|
91 IMPORT_C static void GetCalenEditorTempPath( TFileName& aTempPath, |
|
92 const TDesC* aFileName = NULL ); |
|
93 |
|
94 /** |
|
95 * Gets mime type of the given file handle |
|
96 * |
|
97 * @param RFile File handle |
|
98 * @return TDataType returns file's mime type |
|
99 */ |
|
100 IMPORT_C static TDataType GetMimeType(RFile aFile); |
|
101 |
|
102 /** |
|
103 * Gets mime type of the given file name |
|
104 * |
|
105 * @param aFileName name of the file |
|
106 * @return TDataType returns file's mime type |
|
107 */ |
|
108 IMPORT_C static TDataType GetMimeTypeL(const TDesC& aFileName); |
|
109 |
|
110 /** |
|
111 * Gets file size in bytes based on the file name |
|
112 * |
|
113 * @param aFileName name of the file of which size is required |
|
114 * @return TInt returns file size in bytes |
|
115 */ |
|
116 IMPORT_C static TInt GetFileSizeL(const TDesC& aFileName); |
|
117 |
|
118 /** |
|
119 * Opens the attachment |
|
120 * |
|
121 * @param RFile File handler to be opened |
|
122 * @param aExitObserver Exit observer that listens for exiting from the attahcment viewer |
|
123 * @return None |
|
124 */ |
|
125 IMPORT_C static void OpenAttachmentL(RFile& file, MAknServerAppExitObserver& aExitObserver); |
|
126 |
|
127 /** |
|
128 * Saves attachment either to the phone memory or memory card as chosen by the user |
|
129 * |
|
130 * @param RFile File handler to be saved |
|
131 * @param aExitObserver Exit observer that listens for exiting from the save UI dialogs |
|
132 * @return TInt returns Error code if any |
|
133 */ |
|
134 IMPORT_C static TInt SaveAttachmentL(RFile& aFile, MAknServerAppExitObserver& aExitObserver); |
|
135 |
|
136 private: |
|
137 |
|
138 /** |
|
139 * Fetches notes from notepad app |
|
140 * |
|
141 * @aParam aSelectedFiles has selected files |
|
142 */ |
|
143 static TBool FetchNoteL(CDesCArray& aSelectedFiles); |
|
144 |
|
145 /** |
|
146 * Fetch the file which is already existing |
|
147 * |
|
148 * @param aFileType Type of the file to be fetched |
|
149 * @param aSelectedFiles selecetd files after fetching |
|
150 * @param aMultiSelect for selecting multile files/or single file |
|
151 * @param aVerifier verifier for call back if file is selected |
|
152 */ |
|
153 static TBool FetchExistingL( TMediaFileType aFileType, |
|
154 CDesCArray& aSelectedFiles, |
|
155 TBool aMultiSelect, |
|
156 MMGFetchVerifier* aVerifier ); |
|
157 |
|
158 /** |
|
159 * Generates a legal filename from given text buffer. |
|
160 * |
|
161 * @param aFileName OUT: generated filename. |
|
162 * @param aBuffer text buffer. |
|
163 * @param aMaxLength maximum length for filename. |
|
164 * @param aExt optional file extension. |
|
165 */ |
|
166 static void GetFileNameFromBuffer( TFileName& aFileName, |
|
167 const TDesC& aBuffer, |
|
168 TInt aMaxLength, |
|
169 const TDesC* aExt = NULL ); |
|
170 }; |
|
171 |
|
172 #endif |