2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Interface (abstract) class for subclasses implementing the
15 * most common value objects used in WSF, which are used to
16 * describe some invocable service.
27 #ifndef M_SEN_SERVICE_DESCRIPTION_H
28 #define M_SEN_SERVICE_DESCRIPTION_H
36 _LIT8(KSenFacetValFalse, "false");
37 _LIT8(KSenFacetValTrue, "true");
39 // Facet identifier (URN) constants:
40 _LIT8(KCompleteMessagesFacet, "urn:nokia.com.serene:complete-messages");
41 _LIT8(KExposeLocalServiceFacet, "urn:nokia.com.serene:expose");
42 _LIT8(KProviderSharableFacet, "urn:nokia.com.serene.provider:sharable");
43 _LIT8(KProviderCompleteClientMsgsFacet, "urn:nokia.com.serene.provider:complete-client-messages") ;
44 _LIT8(KProviderLoadOnStartupFacet, "urn:nokia.com.serene.provider:load-on-startup") ;
45 _LIT8(KProviderThreadsafeFacet, "urn:nokia.com.serene.provider:threadsafe") ;
46 _LIT8(KProviderReinitializableFacet, "urn:nokia.com.serene.provider:re-initializable") ;
47 _LIT8(KProviderStayOnBackgroundFacet, "urn:nokia.com.serene.provider:stay-on-background") ;
48 _LIT8(KTransportClassFacet, "urn:nokia.com:serene:transport:class");
50 // Transport plug-in types (ECOM cues / class types):
51 _LIT8(KSenTransportCueHTTP, "com.nokia.wsf.transport.plugin.httpchannel");
52 _LIT8(KSenTransportCueVirtualTCP, "com.nokia.wsf.transport.plugin.virtualtcp");
53 _LIT8(KSenTransportCueLocalEcom, "com.nokia.wsf.transport.plugin.local");
54 _LIT8(KSenTransportCueHostletConnection, "com.nokia.wsf.transport.plugin.hostlet");
57 _LIT8(KSenTransportSchemeHTTP, "http");
58 _LIT8(KSenTransportSchemeTCP, "tcp");
59 _LIT8(KSenTransportSchemeLocal, "local");
60 _LIT8(KSenTransportSchemeHostlet, "hostlet");
61 //_LIT8(KSenTransportSchemeVirtualTCP, "vtcp");
63 const TInt KSenServiceDescriptionBaseScore = 100;
65 // FORWARD DECLARATIONS
69 typedef RPointerArray<CSenFacet> RFacetArray;
74 * Interface (abstract) class for subclasses implementing the most common value
75 * objects used in WSF, which are used to describe some invocable service.
76 * All of the subclasses are capable of representing themselves in XML.
77 * @lib SenServDesc.lib
80 class MSenServiceDescription
85 * DescriptionClassType enumeration.
87 IMPORT_C enum TDescriptionClassType
89 ERoot = 0, // not in use
90 EBaseServiceDescription = 1, // not in use
91 EXmlServiceDescription = 2,
92 EIdentityProvider = 3,
95 EWebServiceSession = 6,
96 EBasicWebServiceSession = 7,
97 EIdWSFServiceSession = 8,
98 EIdWsfServiceInstance = 9,
99 ECoreServiceConsumer = 10,
100 ESenInternalServiceConsumer = 11,
101 EIdWsfAuthenticationServiceClient = 12,
102 EIdWsfDiscoveryServiceClient = 13,
103 ERestServiceSession = 14,
104 EWSStarServiceSession = 15,
105 EWSStarSTSClient = 16,
106 EWSStarPolicyClient = 17,
109 EAtomPubServiceSession = 20,
110 EAtomPubAuthClient = 21,
112 EOviServiceSession = 23,
119 * The DescriptionClassType() method is used to resolve the real
120 * subclass type in cases where instance of that class is seen
121 * through one of its superclass interfaces.
122 * @since Series60 3.0
123 * @return TDescriptionClassType enumeration identifying the class.
125 virtual TDescriptionClassType DescriptionClassType() = 0;
128 * Method returns ETrue if this service description matches the given
130 * The bits of information that are in the pattern are read and compared
131 * to corresponding fields in this service description. Note that a pattern
132 * may have far fewer fields and that only the non-null and non-zero-length
133 * fields are compared.
134 * For example, assume that a pattern with only a contract was defined;
135 * with the contract set to "urn:example.com:service". Each
136 * service description with the same contract will match the pattern,
137 * even if such a service description has non-null/non-zero-length fields
139 * @since Series60 3.0
140 * @param aPattern is a Service Description, typically with partial
142 * @return TBool ETrue if match, EFalse otherwise. If the value is
143 * not found from current instance, it is not used in comparison
144 * (even if offered in the given pattern).
146 virtual TBool Matches(MSenServiceDescription& aPattern) = 0;
149 * Getter for contract, which is typically some URI.
150 * @since Series60 3.0
151 * @return the Contract
153 virtual TPtrC8 Contract() = 0;
156 * Method for checking if service description has a certain facet.
157 * @since Series60 3.0
158 * @param aURI the facet to check, typically some URI.
159 * @param aHasFacet is ETrue if facet is found and EFalse, if not.
160 * @return KErrNone or other system-wide Symbian error codes.
162 virtual TInt HasFacetL(const TDesC8& aURI, TBool& aHasFacet) = 0;
165 * Method for getting a facet value from the service description
166 * @since Series60 3.0
167 * @param aURI the facet to get
168 * @param aValueTo a ref-to-pointer into which the value will
169 * be allocated, which ownership is transferred
172 * KErrNoMemory value couldn't be allocated due to lack
174 * KErrNotFound if the wanted facet was not found.
175 * Other system-wide Symbian error codes.
177 virtual TInt FacetValue(TDesC8& aURI, HBufC8*& aValueTo) = 0;
180 * Method for adding a facet. Will NOT override an already
181 * existing facet with a same name.
182 * @since Series60 3.0
183 * @param aFacet is the one to be added. A copy of the
184 * the original facet instance will be added.
185 * @return KErrNone or other system-wide Symbian error codes.
186 * KErrAlreadyExists if a facet with same name exists
188 virtual TInt AddFacetL(const CSenFacet& aFacet) = 0;
191 * Method for setting a facet.Adds a new facet, if non-existent.
192 * But, if a facet with same name exists, it will be overridden.
193 * @since Series60 3.0
194 * @param aFacet to be set. A copy of the original will be
196 * @return KErrNotFound if facet can not be found
197 * KErrNone if facet was found
198 * KErrNoMemory if no memory could be allocated for the value
199 * Other system-wide Symbian error codes.
201 virtual TInt SetFacetL(const CSenFacet& aFacet) = 0;
204 * Removes a characteristic (Facet) from the description
205 * @since Series60 3.0
206 * @param aURI of the facet to be removed.
207 * @return KErrNone if a Facet was successfully removed
208 * KErrNotFound if a Facet could not be found
209 * Other system-wide Symbian error codes.
211 virtual TInt RemoveFacet(const TDesC8& aURI) = 0;
214 * Method for getting all facets. Copies characteristics (Facets)
215 * from the description into array. For each characteristic (Facet)
216 * found in array the HasFacetL() method should return "ETrue".
217 * @since Series60 3.0
218 * @param aFacetArray is typically an empty array, into where
219 * copies of facets will be added. Ownership of the
220 * items in this array is transferred to the caller.
221 * @return KErrNone or other system-wide Symbian error codes.
223 virtual TInt FacetsL(RFacetArray& aFacetArray) = 0;
226 * This leaving variant of ScoreMatch() always returns a positive integer
227 * if this service description matches with the given pattern in at
228 * least one aspect. Higher numbers mean closer match.
230 * In case of system error, method leaves.
232 * The bits of information that are in the pattern are read and compared
233 * to corresponding fields in this ServiceDescription. Note that a pattern
234 * may have far fewer fields and that only the non-null fields are compared.
235 * For example, assume that a pattern with only a contract was defined;
236 * with the contract set to "urn:example.com:service".
237 * Each ServiceDescription with the same contract will match the pattern,
238 * even if such a ServiceDescription has non-null fields for other aspects.
239 * @since Series60 3.0
240 * @param aPattern a ServiceDescription, typically with partial
242 * @return the score. If nothing matches, returns 0
244 virtual TInt ScoreMatchL(MSenServiceDescription& aPattern) = 0;
247 * Getter for endpoint.
248 * @since Series60 3.0
249 * @return The endpoint.
251 virtual TPtrC8 Endpoint() = 0;
254 * Getter for the framework ID.
255 * @since Series60 3.0
256 * @return The framework ID or KNullDesC8 if no framework is set
258 virtual TPtrC8 FrameworkId() = 0;
261 * Getter for the framework version.
262 * @since Series60 3.0
263 * @return The framework version or KNullDesC8 if not set.
265 virtual TPtrC8 FrameworkVersion() = 0;
268 * Setter for contract.
269 * @since Series60 3.0
270 * @param aContract the contract to be set.
272 virtual void SetContractL(const TDesC8& aContract) = 0;
275 * Setter for endpoint.
276 * @since Series60 3.0
277 * @param aEndpoint to the service. Note that endpoint cannot
278 * include characters which are illegal in XML. If endpoint
279 * is an URL which contains illegal characters (like '&'-char),
280 * those need to be encoded into XML entity form (like &).
281 * EncodeHttpCharactersLC() method from XmlUtils can be used
282 * for encoding of basic XML entities.
284 virtual void SetEndPointL(const TDesC8& aEndPoint) = 0;
287 * Gets the service description as XML fragment in UTF-8 format.
288 * @since Series60 3.0
289 * @return the service description as XML, which ownership is
290 * transferred to the caller.
292 virtual HBufC8* AsXmlL() = 0;
295 * Gets the service description as XML, in Unicode (UCS-2)
296 * @since Series60 3.0
297 * @return the service description as XML, in Unicode (UCS-2)
300 virtual HBufC* AsXmlUnicodeL() = 0;
303 * Writes this service description as XML, in UTF-8 form to a stream
304 * @since Series60 3.0
305 * @param aWriteStream to write into.
307 virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0;
310 #endif // M_SEN_SERVICE_DESCRIPTION_H