49
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 - 2004 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: Performs a set of util methods related to objects.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef OBJECTUTILS_H
|
|
19 |
#define OBJECTUTILS_H
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <e32def.h>
|
|
23 |
#include <badesca.h>
|
|
24 |
|
|
25 |
#include "nwx_defs.h"
|
|
26 |
#include <nw_dom_element.h>
|
|
27 |
|
|
28 |
// CONSTANTS
|
|
29 |
|
|
30 |
// MACROS
|
|
31 |
|
|
32 |
// DATA TYPES
|
|
33 |
|
|
34 |
// FUNCTION PROTOTYPES
|
|
35 |
|
|
36 |
// FORWARD DECLARATIONS
|
|
37 |
#ifdef __cplusplus
|
|
38 |
extern "C" {
|
|
39 |
#endif /* __cplusplus */
|
|
40 |
|
|
41 |
typedef struct NW_LMgr_Box_s NW_LMgr_Box_t;
|
|
42 |
typedef struct NW_HED_DomHelper_s NW_HED_DomHelper_t;
|
|
43 |
|
|
44 |
#ifdef __cplusplus
|
|
45 |
}
|
|
46 |
#endif /* __cplusplus */
|
|
47 |
|
|
48 |
class CBrCtlObjectInfo;
|
|
49 |
|
|
50 |
// CLASS DECLARATION
|
|
51 |
|
|
52 |
class ObjectUtils
|
|
53 |
{
|
|
54 |
public: // Datatypes
|
|
55 |
typedef enum
|
|
56 |
{
|
|
57 |
EHandlerImage,
|
|
58 |
EHandlerPlugin,
|
|
59 |
EHandlerExternalApp,
|
|
60 |
EHandlerAny
|
|
61 |
} THandlerType;
|
|
62 |
|
|
63 |
|
|
64 |
public: // Constructors and destructor
|
|
65 |
/**
|
|
66 |
* Destructor.
|
|
67 |
*/
|
|
68 |
~ObjectUtils();
|
|
69 |
|
|
70 |
|
|
71 |
public: // New Methods
|
|
72 |
/**
|
|
73 |
* Returns ETrue if aBox is an object box.
|
|
74 |
*
|
|
75 |
* @param aBox a box.
|
|
76 |
* @param aOnlyIfPlaceHolder if true this method will only return true
|
|
77 |
* if the box is showing its place-holder (not an active plugin).
|
|
78 |
* Otherwise it was true true if it an object-box.
|
|
79 |
*
|
|
80 |
* @return ETrue or EFalse.
|
|
81 |
*/
|
|
82 |
static TBool IsObjectBox(const NW_LMgr_Box_t& aBox, TBool aOnlyIfPlaceHolder);
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Returns ETrue if aBox is an object box in the pre-active state.
|
|
86 |
*
|
|
87 |
* @param aBox a box.
|
|
88 |
*
|
|
89 |
* @return ETrue or EFalse.
|
|
90 |
*/
|
|
91 |
static TBool IsDownloadedObjectBox(const NW_LMgr_Box_t& aBox);
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Gets the following information about the object's resource: whether a third party
|
|
95 |
* plugin or external application can open the resource, the size of the resource,
|
|
96 |
* the mime-type of the resource, and the name of the plugin or application to
|
|
97 |
* be used to open the resource.
|
|
98 |
*
|
|
99 |
* @param aBox the object's associated box.
|
|
100 |
* @param aBrCtlObjectInfo, upon completion it holds the info about the object.
|
|
101 |
*
|
|
102 |
* @return void.
|
|
103 |
*/
|
|
104 |
static void GetBrCtlObjectInfoL(const NW_LMgr_Box_t& aBox, CBrCtlObjectInfo& aBrCtlObjectInfo);
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Determines whether a given content-type of dot-extension has a cooresponding
|
|
108 |
* plugin or external application. aContentType and aUrl can be NULL, but at least
|
|
109 |
* one must be non-NULL (otherwise it will always return EFalse). If aHandlerType
|
|
110 |
* is EPlugin then it returns ETrue only if their is a supported plugin. If aHandlerType
|
|
111 |
* is EExternalApp then it returns ETrue only if their is a supported external
|
|
112 |
* application. If aHandlerType is EBoth then it returns ETrue only if their is a
|
|
113 |
* supported plugin or external application.
|
|
114 |
*
|
|
115 |
* @param aContentType the content type to compare against, may be NULL.
|
|
116 |
* @param aUrl the url to extract the dot-extension and to compare against, may be NULL.
|
|
117 |
* @param aHandlerType the type of handler to consider.
|
|
118 |
*
|
|
119 |
* @return ETrue or EFalse.
|
|
120 |
*/
|
|
121 |
static TBool IsSupported(const TDesC* aContentType, const TDesC* aUrl,
|
|
122 |
THandlerType aHandlerType);
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Returns ETrue if plugin support is enabled.
|
|
126 |
*
|
|
127 |
* @return ETrue or EFalse.
|
|
128 |
*/
|
|
129 |
static TBool Enabled();
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Extracts the attribute's names and values from the given aElementNode.
|
|
133 |
*
|
|
134 |
* @param aDomHelper the caller's DomHelper, used to interact with its
|
|
135 |
* dom-tree.
|
|
136 |
* @param aElementNode the element to extract attributes from.
|
|
137 |
* @param aNameArray the attribute names.
|
|
138 |
* @param aValueArray the attribute values.
|
|
139 |
*
|
|
140 |
* @return void
|
|
141 |
*/
|
|
142 |
static void GetAttributesL(const NW_HED_DomHelper_t& aDomHelper,
|
|
143 |
const NW_DOM_ElementNode_t& aElementNode, CDesCArray** aNameArray,
|
|
144 |
CDesCArray** aValueArray);
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Extracts the <param> tag attribute's name and value from the given aElementNode.
|
|
148 |
*
|
|
149 |
* @param aDomHelper the caller's DomHelper, used to interact with its
|
|
150 |
* dom-tree.
|
|
151 |
* @param aElementNode the element to extract attributes from.
|
|
152 |
* @param aNameArray the attribute names.
|
|
153 |
* @param aValueArray the attribute values.
|
|
154 |
*
|
|
155 |
* @return void
|
|
156 |
*/
|
|
157 |
static void GetParamAttributesL(const NW_HED_DomHelper_t& aDomHelper,
|
|
158 |
const NW_DOM_ElementNode_t& aElementNode, CDesCArray** aNameArray,
|
|
159 |
CDesCArray** aValueArray);
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Given a name and value array attained from GetAttributesL it returns
|
|
163 |
* a copy of the attribute value associated with the given name. Upon
|
|
164 |
* success the caller adopts aValue. aValue is set to NULL if no
|
|
165 |
* attribute with the given name is present.
|
|
166 |
*
|
|
167 |
* @param aNameArray the attribute names.
|
|
168 |
* @param aValueArray the attribute values.
|
|
169 |
* @param aName the name of the attribute to be extracted.
|
|
170 |
* @param aValue upon success it contains a copy of the attribute value or
|
|
171 |
* NULL if the attribute wasn't present.
|
|
172 |
*
|
|
173 |
* @return void
|
|
174 |
*/
|
|
175 |
static void GetAttributeValueL(const CDesCArray& aNameArray,
|
|
176 |
const CDesCArray& aValueArray, const TDesC& aName, TDesC** aValue);
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Given a name and value array this method inserts name/value pair to array.
|
|
180 |
* If the name already is in the array, replace value
|
|
181 |
* by deleting old pair and adding new pair
|
|
182 |
*
|
|
183 |
* @param aNameArray the attribute names.
|
|
184 |
* @param aValueArray the attribute values.
|
|
185 |
* @param aName the name of the attribute to be replaced.
|
|
186 |
* @param aValue the value of the attribute to be replaced.
|
|
187 |
*
|
|
188 |
* @return void
|
|
189 |
*/
|
|
190 |
static void SetAttributeValueL( CDesCArray& aNameArray,
|
|
191 |
CDesCArray& aValueArray, const TDesC& aName, const TDesC& aValue);
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Given a name and value array this method remove name/value pair from array.
|
|
195 |
* If the name is not found in the array, do nothing
|
|
196 |
*
|
|
197 |
* @param aNameArray the attribute names.
|
|
198 |
* @param aValueArray the attribute values.
|
|
199 |
* @param aName the name of the attribute to be removed.
|
|
200 |
*
|
|
201 |
* @return void
|
|
202 |
*/
|
|
203 |
static void ObjectUtils::RemoveAttributeL( CDesCArray& aNameArray,
|
|
204 |
CDesCArray& aValueArray, const TDesC& aName );
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Returns the content type associated with the given class-id.
|
|
208 |
*
|
|
209 |
* @param aClassId the classid to lookup.
|
|
210 |
*
|
|
211 |
* @return the associated content type of NULL if no association exists.
|
|
212 |
*/
|
|
213 |
static TDesC* ObjectUtils::GetAssociatedContentType(const TDesC& aClassId);
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Returns the source param name associated with the given class-id.
|
|
217 |
*
|
|
218 |
* @param aClassId the classid to lookup.
|
|
219 |
*
|
|
220 |
* @return the associated source param name of NULL if no association exists.
|
|
221 |
*/
|
|
222 |
static TDesC* ObjectUtils::GetAssociatedSourceParamName(const TDesC& aClassId);
|
|
223 |
|
|
224 |
/**
|
|
225 |
* General purpose panic function for Object related errors.
|
|
226 |
*
|
|
227 |
* @since 2.6
|
|
228 |
* @param aError The reason for panic. Could be left out.
|
|
229 |
* @return void
|
|
230 |
*/
|
|
231 |
static void Panic(TInt aError = KErrNone);
|
|
232 |
|
|
233 |
/**
|
|
234 |
* General purpose panic function for Object related errors.
|
|
235 |
*
|
|
236 |
* @since 2.8
|
|
237 |
* @param aUrl The uri with file name and extension.
|
|
238 |
* @return the content type of the uri
|
|
239 |
*/
|
|
240 |
static HBufC* ObjectUtils::GetContentTypeByUrl(const TDesC* aUri);
|
|
241 |
|
|
242 |
private: // Private Methods
|
|
243 |
/**
|
|
244 |
* C++ default constructor.
|
|
245 |
*/
|
|
246 |
ObjectUtils();
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Returns the name of the plugin that supports the given content-type or
|
|
250 |
* dot-extension otherwise NULL if no plugin support this type. aContentType
|
|
251 |
* and aUrl can be NULL, but at least one must be non-NULL (otherwise it will
|
|
252 |
* always return EFalse). The caller adopts the result.
|
|
253 |
*
|
|
254 |
* @param aContentType the content type to compare against, may be NULL.
|
|
255 |
* @param aUrl the url to compare against, may be NULL.
|
|
256 |
*
|
|
257 |
* @return The name of the plugin or NULL
|
|
258 |
*/
|
|
259 |
static TDesC* GetPluginNameL(const TDesC* aContentType,
|
|
260 |
const TDesC* aUrl);
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Returns the name of the external application that supports the given
|
|
264 |
* content-type or NULL if no application support this type.
|
|
265 |
* The caller adopts the result.
|
|
266 |
*
|
|
267 |
* @return The name of the application or NULL
|
|
268 |
*/
|
|
269 |
static TDesC* GetExternalAppNameL(const TDesC* aContentType);
|
|
270 |
|
|
271 |
/**
|
|
272 |
* Returns ETrue if the content-type or dot-extension is a supported image type.
|
|
273 |
* aContentType and aUrl can be NULL, but at least one must be non-NULL (otherwise
|
|
274 |
* it will always return EFalse).
|
|
275 |
*
|
|
276 |
* @param aContentType the content type to compare against, may be NULL.
|
|
277 |
* @param aUrl the url to compare against, may be NULL.
|
|
278 |
*
|
|
279 |
* @return ETrue if its a supported image type.
|
|
280 |
*/
|
|
281 |
static TBool IsImageSupported(const TDesC* aContentType, const TDesC* aUrl);
|
|
282 |
|
|
283 |
/**
|
|
284 |
* Returns the cooresponding value (either source-param-name or content-type)
|
|
285 |
* given the class-id.
|
|
286 |
*
|
|
287 |
* @param aClassId the class-id used to map to the requested value.
|
|
288 |
* @param aValueSelector used to select the cooresponding value
|
|
289 |
* (either KParamName or KContentType)
|
|
290 |
* @return the value or NULL on out of memory.
|
|
291 |
*/
|
|
292 |
static TDesC* ObjectUtils::GetClassidAssociation(const TDesC& aClassId,
|
|
293 |
TInt aValueSelector);
|
|
294 |
};
|
|
295 |
|
|
296 |
#endif // OBJECTUTILS_H
|