|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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 * Declaration of class CodUtil. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef COD_UTIL_H |
|
22 #define COD_UTIL_H |
|
23 |
|
24 // INCLUDE FILES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <AiwGenericParam.h> |
|
28 #include <AiwGenericParam.hrh> |
|
29 |
|
30 // FORWARD DECLARATION |
|
31 |
|
32 class RFs; |
|
33 class RFile; |
|
34 class CBodyPart; |
|
35 class CAiwGenericParamList; |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * Static utility functions. Wrapped in a struct to keep the global namespace |
|
41 * clean. |
|
42 */ |
|
43 NONSHARABLE_STRUCT( CodUtil ) |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Check if file can be opened (unprotected, or rights present). |
|
49 * @param aFname File name. Nonempty ASSERT-ed. |
|
50 * @return ETrue if file can be opened. |
|
51 */ |
|
52 IMPORT_C static TBool CanOpenL( const TDesC& aFname ); |
|
53 |
|
54 /** |
|
55 * Check if file can be opened (unprotected, or rights present). |
|
56 * @param aFile File. |
|
57 * @return ETrue if file can be opened. |
|
58 */ |
|
59 IMPORT_C static TBool CanOpenL( RFile& aFile ); |
|
60 |
|
61 /** |
|
62 * Get integer parameter (if exists). |
|
63 * @param aParam Parameter to set. Not modified if not set. |
|
64 * @param aSemanticId. Semantic id. |
|
65 * @param aParams Parameter list. |
|
66 */ |
|
67 IMPORT_C static void GetIntParam |
|
68 ( |
|
69 TInt& aParam, |
|
70 TGenericParamId aSemanticId, |
|
71 const CAiwGenericParamList& aParams |
|
72 ); |
|
73 |
|
74 /** |
|
75 * Get TUint32 parameter (if exists). |
|
76 * @param aParam Parameter to set. Not modified if not set. |
|
77 * @param aSemanticId. Semantic id. |
|
78 * @param aParams Parameter list. |
|
79 */ |
|
80 IMPORT_C static void GetUint32Param |
|
81 ( |
|
82 TUint32& aParam, |
|
83 TGenericParamId aSemanticId, |
|
84 const CAiwGenericParamList& aParams |
|
85 ); |
|
86 |
|
87 /** |
|
88 * Get bool parameter (if exists). |
|
89 * @param aParam Parameter to set. Not modified if not set. |
|
90 * @param aSemanticId. Semantic id. |
|
91 * @param aParams Parameter list. |
|
92 */ |
|
93 IMPORT_C static void GetBoolParam |
|
94 ( |
|
95 TBool& aParam, |
|
96 TGenericParamId aSemanticId, |
|
97 const CAiwGenericParamList& aParams |
|
98 ); |
|
99 |
|
100 /** |
|
101 * Get descriptor parameter (if exists). |
|
102 * Both 8 and 16-bit variants are checked. |
|
103 * Leaves a temp buffer (or NULL) on the cleanup stack. |
|
104 * @param aParam Parameter to set. After returning: |
|
105 * - Set to point into aParams (8-bit param), or |
|
106 * - Set to point into the pushed temp buffer (16-bit param), or |
|
107 * - Remains unchaged (no param). |
|
108 * @param aSemanticId. Semantic id. |
|
109 * @param aParams Parameter list. |
|
110 */ |
|
111 IMPORT_C static void GetDesParamLC |
|
112 ( |
|
113 TPtrC8& aParam, |
|
114 TGenericParamId aSemanticId, |
|
115 const CAiwGenericParamList& aParams |
|
116 ); |
|
117 |
|
118 /** |
|
119 * Get 16-bit descriptor parameter (if exists). |
|
120 * @param aParam Parameter to set. After returning: |
|
121 * - Set to point into aParams, or |
|
122 * - Remains unchaged (no param). |
|
123 * @param aSemanticId. Semantic id. |
|
124 * @param aParams Parameter list. |
|
125 */ |
|
126 IMPORT_C static void GetDesParam |
|
127 ( |
|
128 TPtrC& aParam, |
|
129 TGenericParamId aSemanticId, |
|
130 const CAiwGenericParamList& aParams |
|
131 ); |
|
132 |
|
133 /** |
|
134 * Check if URL has 'cid' scheme. |
|
135 * @param aUrl URL. |
|
136 * @return ETrue if URL has 'cid' scheme. |
|
137 */ |
|
138 static TBool IsCidSchemeL( const TDesC8& aUrl ); |
|
139 |
|
140 /** |
|
141 * Lookup body part by CID, or NULL if not found. CID scheme asserted! |
|
142 * @param aParts Body parts. |
|
143 * @param aUrl URL. |
|
144 * @return The body part or NULL. |
|
145 */ |
|
146 static CBodyPart* PartByCidL |
|
147 ( const RPointerArray<CBodyPart>& aParts, const TDesC8& aUrl ); |
|
148 |
|
149 /** |
|
150 * Extract file name part of an URL. |
|
151 * @param aUrl URL. |
|
152 * @return File name part. This may be zero length. |
|
153 */ |
|
154 static TPtrC8 FileNameFromUrl( const TDesC8& aUrl ); |
|
155 |
|
156 /** |
|
157 * Allocate and return an absolute URL: |
|
158 * - If aUrl is already absolute, it is returned and aBase is ignored. |
|
159 * - If aUrl is a relative URL, resolve it against aBase. In |
|
160 * this case, aBase need to be an absolute URL. |
|
161 * URL-s need to be valid URL-s or this function leaves. |
|
162 * @param aBase Base URL, used only if aUrl is a relative URL. |
|
163 * @param aUrl URL. |
|
164 * @return Absolute URL. Ownership passed to caller. |
|
165 */ |
|
166 IMPORT_C static HBufC8* AbsoluteUrlLC |
|
167 ( const TDesC8& aBase, const TDesC8& aUrl ); |
|
168 |
|
169 /** |
|
170 * Convert to UCS-2. |
|
171 * @param aSrc Source string. |
|
172 * @param aEncoding Encoding or empty string. |
|
173 * @param aFs File Server Session to be used. |
|
174 * @return Converted string. Owner is the caller. |
|
175 */ |
|
176 static HBufC16* ConvertToUcs2L |
|
177 ( const TDesC8& aSrc, const TDesC8& aEncoding, RFs& aFs ); |
|
178 |
|
179 /** |
|
180 * Convert UCS-2 to UTF-8. |
|
181 * @param aUcs2Src Source string. |
|
182 * @return Converted string. Owner is the caller. |
|
183 */ |
|
184 static HBufC8* ConvertUcs2ToUtf8L( const TDesC& aUcs2Src ); |
|
185 |
|
186 /** |
|
187 * Convert 16-bit descriptor to 8 bit. |
|
188 * @param aDes Descriptor to convert. |
|
189 * @return Converted descriptor. Owner is the caller. Pushed on stack. |
|
190 */ |
|
191 |
|
192 IMPORT_C static HBufC8* ConvertLC( const TDesC& aDes ); |
|
193 |
|
194 /** |
|
195 * Convert 8-bit descriptor to 16 bit. |
|
196 * @param aDes Descriptor to convert. |
|
197 * @return Converted descriptor. Owner is the caller. Pushed on stack. |
|
198 */ |
|
199 IMPORT_C static HBufC* ConvertLC( const TDesC8& aDes ); |
|
200 |
|
201 /** |
|
202 * Convert 16-bit descriptor to 8 bit. |
|
203 * @param aDes Descriptor to convert. |
|
204 * @return Converted descriptor. Owner is the caller. Pushed on stack. |
|
205 */ |
|
206 |
|
207 IMPORT_C static HBufC8* ConvertL( const TDesC& aDes ); |
|
208 |
|
209 /** |
|
210 * Convert 8-bit descriptor to 16 bit. |
|
211 * @param aDes Descriptor to convert. |
|
212 * @return Converted descriptor. Owner is the caller. Pushed on stack. |
|
213 */ |
|
214 IMPORT_C static HBufC* ConvertL( const TDesC8& aDes ); |
|
215 |
|
216 /** |
|
217 * Count Access Points. |
|
218 * @return Number of Access Points. |
|
219 */ |
|
220 static TUint32 ApCountL(); |
|
221 |
|
222 /** |
|
223 * Get WAP gateway address (or NULL) for an Access Point. |
|
224 * @param aIap Access Point id. |
|
225 * @return Gateway address for the Access Point, or NULL if not a |
|
226 * WAP AP. Owner is the caller. |
|
227 */ |
|
228 static HBufC8* WapGatewayL( TUint32 aIap ); |
|
229 |
|
230 }; |
|
231 |
|
232 #endif /* def COD_UTIL_H */ |