1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * Data utility class for UniEditor & MMS related editors and viewers |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __UNIDATAUTILS_H |
|
23 #define __UNIDATAUTILS_H |
|
24 |
|
25 // INCLUDES |
|
26 #include <apmstd.h> //TDataType |
|
27 #include <apgcli.h> //RApaLsSession |
|
28 #include <barsc.h> |
|
29 #include <UniModelConst.h> |
|
30 #include <cmsvattachment.h> // TMsvAttachmentId |
|
31 |
|
32 |
|
33 // CONSTANTS |
|
34 _LIT8( KUniEmptySlide, "application/X-MmsEmptySlide" ); |
|
35 |
|
36 // MACROS |
|
37 |
|
38 // DATA TYPES |
|
39 |
|
40 // FUNCTION PROTOTYPES |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 class CMsgTextUtils; |
|
44 class CBaseMtm; |
|
45 class MMsvAttachmentManager; |
|
46 |
|
47 // CLASS DECLARATION |
|
48 |
|
49 /** |
|
50 * CUniDataUtils - Miscellaneous UI indenependent utilities. |
|
51 * |
|
52 * @lib UniDataUtils.lib |
|
53 * @since 3.1 |
|
54 */ |
|
55 class CUniDataUtils : public CBase |
|
56 { |
|
57 public: // Constructors and destructor |
|
58 |
|
59 /** |
|
60 * Constructor. |
|
61 * |
|
62 * @since 3.1 |
|
63 * @param aFs IN Fileserver session. |
|
64 * @return Pointer to instance |
|
65 */ |
|
66 static CUniDataUtils* NewL( RFs& aFs ); |
|
67 |
|
68 /** |
|
69 * Destructor. |
|
70 * |
|
71 * @since 3.1 |
|
72 */ |
|
73 virtual ~CUniDataUtils(); |
|
74 |
|
75 /** |
|
76 * DefaultFileName |
|
77 * (e.g. "noname" - no prefix) |
|
78 * |
|
79 * @since 3.1 |
|
80 * @return Pointer to default file name buffer |
|
81 */ |
|
82 inline TPtrC DefaultFileName() const; |
|
83 |
|
84 /** |
|
85 * EmptyPageString |
|
86 * (e.g. "Empty page") |
|
87 * |
|
88 * @since 3.1 |
|
89 * @return Pointer to "empty page" buffer |
|
90 */ |
|
91 inline TPtrC EmptyPageString() const; |
|
92 |
|
93 /** |
|
94 * CharconvIdToMibIdL |
|
95 * Converts between id's. |
|
96 * |
|
97 * @since 3.1 |
|
98 * @param aCharconvCharsetId IN charconv id |
|
99 * @return MIB enumeration |
|
100 */ |
|
101 TUint CharconvIdToMibIdL( TUint aCharconvCharsetId ); |
|
102 |
|
103 /** |
|
104 * MibIdToCharconvIdL |
|
105 * Converts between id's. |
|
106 * |
|
107 * @since 3.1 |
|
108 * @param aMibId IN MIB enumeration |
|
109 * @return Charconv id |
|
110 */ |
|
111 TUint MibIdToCharconvIdL( TUint aMibId ); |
|
112 |
|
113 /** |
|
114 * Gets bytes size of UTF8 formatted text |
|
115 * |
|
116 * @since 3.1 |
|
117 * @param aText |
|
118 * @return Size of text in bytes |
|
119 */ |
|
120 static TInt UTF8Size( TPtrC aText ); |
|
121 |
|
122 /** |
|
123 * Gets bytes size of file. |
|
124 * |
|
125 * @since 3.1 |
|
126 * @param aFileName |
|
127 * @return Size of the file. |
|
128 */ |
|
129 TInt FileSizeL( const TFileName& aFileName ); |
|
130 |
|
131 /** |
|
132 * Get open file handle for an attachment |
|
133 * |
|
134 * @since 3.1 |
|
135 * @param aMtm Client MTM |
|
136 * @param aId Attachment ID |
|
137 * @return Open read-only file handle. |
|
138 * It is callers responsibilty to close the handle. |
|
139 */ |
|
140 static RFile GetAttachmentFileL( CBaseMtm& aMtm, TMsvAttachmentId aId ); |
|
141 |
|
142 /** |
|
143 * Get the "attachment manager index position" for an attachment. |
|
144 * |
|
145 * @since 3.1 |
|
146 * @return "attachment manager index position" |
|
147 * @leave KErrNotFound if attachment is not found from the store |
|
148 */ |
|
149 static TInt IndexPositionOfAttachmentL( |
|
150 MMsvAttachmentManager& aManager, |
|
151 TMsvAttachmentId aId ); |
|
152 |
|
153 protected: |
|
154 |
|
155 /** |
|
156 * C++ constructor |
|
157 * |
|
158 * @since 3.1 |
|
159 * @param aFs IN Fileserver session. |
|
160 */ |
|
161 CUniDataUtils( RFs& aFs ); |
|
162 |
|
163 /** |
|
164 * ConstructL |
|
165 * Symbian OS constructor |
|
166 * |
|
167 * @since 3.1 |
|
168 */ |
|
169 void ConstructL(); |
|
170 |
|
171 /** |
|
172 * RegisterDataL |
|
173 * Reads data from resources. |
|
174 * |
|
175 * @since 3.1 |
|
176 */ |
|
177 void RegisterDataL(); |
|
178 |
|
179 /** |
|
180 * ReadResStringsL |
|
181 * Reads strings from resources to internal mimetype arrays. |
|
182 * |
|
183 * @since 3.1 |
|
184 * @param aResourceFile IN opened resourcefile |
|
185 * @param aSrcResId IN resource id to read from |
|
186 * @return Pointer to read string |
|
187 **/ |
|
188 HBufC* ReadResStringL( const RResourceFile& aResourceFile, TInt aSrcResId ); |
|
189 |
|
190 protected: // data |
|
191 |
|
192 RFs& iFs; |
|
193 CMsgTextUtils* iTextUtils; |
|
194 HBufC* iDefaultFileName; |
|
195 HBufC* iEmptyPageString; |
|
196 |
|
197 }; |
|
198 |
|
199 #include <UniDataUtils.inl> |
|
200 |
|
201 #endif // __UNIDATAUTILS_H |
|
202 |
|
203 // End of file |
|