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 "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Class derives the XML service description and further extends
15 * it by adding consumer policy interface implementation.
26 #ifndef SEN_SERVICE_PATTERN_H
27 #define SEN_SERVICE_PATTERN_H
32 #include <SenXmlServiceDescription.h>
33 #include <MSenConsumerPolicy.h>
35 // FORWARD DECLARATIONS
36 class CSenConsumerPolicy;
41 * Class derives the XML service description and further extends
42 * it by implementing consumer policy interface.
44 * Service pattern is typically used by Basic Web Service consumers,
45 * which often know, which policy to use in the communication with
46 * certain Web Service Provider (WSP).
48 * For example, a Basic Web Service consumer application might want
49 * strictly define certain Internet Access Point (IAP) to be used when
50 * initializing new service connection. Such an application can simply
51 * instantiate new ServicePattern and set pre-known IAP ID into it.
53 * The main purpose of this class is to simplify the initialization
54 * of service connections for Basic Web Services.
56 * It is important to note, that all the consumer policy information entered
57 * via ServicePattern extending the MSenConsumerPolicy is treated
58 * in "policy-per-client" terms. In other words, any consumer
59 * policy information will not be stored for latter use of other
60 * applications (even they might happen to use same WSP and contract!).
62 * This is due the nature of Service Pattern: it acts as a consumer
63 * originated filter, after which a service will be resolved.
65 * Any service which "meets" the Service Pattern "constraints", is
66 * considered as a "match", because such service accepts this
69 * @lib SenServDesc.lib
72 class CSenServicePattern : public CSenXmlServiceDescription, public MSenConsumerPolicy
75 public: // Constructors and destructor
78 * Standard 2 phase constructors
80 IMPORT_C static CSenServicePattern* NewL();
83 * Standard 2 phase constructors
85 IMPORT_C static CSenServicePattern* NewLC();
88 * Standard 2 phase constructor
89 * @param aNamespaceURI namespace URI for the service pattern.
91 IMPORT_C static CSenServicePattern* NewL(const TDesC8& aNamespaceURI);
94 * Standard 2 phase constructor
95 * @param aNamespaceURI namespace URI for the service pattern.
97 IMPORT_C static CSenServicePattern* NewLC(const TDesC8& aNamespaceURI);
100 * Standard 2 phase constructor.
101 * @param aEndPoint service pattern endpoint.
102 * @param aContract service pattern contract.
104 IMPORT_C static CSenServicePattern* NewL( const TDesC8& aEndPoint,
105 const TDesC8& aContract );
108 * Standard 2 phase constructor.
109 * @param aEndPoint service pattern endpoint.
110 * @param aContract service pattern contract.
112 IMPORT_C static CSenServicePattern* NewLC( const TDesC8& aEndPoint,
113 const TDesC8& aContract );
118 IMPORT_C virtual ~CSenServicePattern();
123 * Convenience method for writing out the consumer policy as XML
125 * @since Series60 3.0
126 * @return consumer policy as UTF-8 form XML.
128 IMPORT_C HBufC8* ConsumerPolicyAsXmlL();
130 // Functions from base classes
132 // From CSenXmlServiceDescription
135 * Compares that both service description and possible
136 * policy inside of it matches with this instance.
137 * @since Series60 3.0
138 * @param aPattern the service description to compare to
139 * @return ETrue both service description and policy information
140 * matches, otherwise EFalse. If some value is not set
141 * in current instance, it is not compared.
143 IMPORT_C TBool Matches(MSenServiceDescription& aServicePattern);
146 * Callback function which implements the XML content handler interface.
147 * Parses the consumer policies independently.
148 * @since Series60 3.0
149 * @param aNsUri The namespace URI of the new element
150 * @param aLocalName The local name of the new element
151 * @param aQName The qualified name of the new element
152 * @param aAttributes The attributes of the new element
154 IMPORT_C void StartElementL(const TDesC8& aNsUri,
155 const TDesC8& aLocalName,
156 const TDesC8& aQName,
157 const RAttributeArray& aAttributes);
159 // From MSenConsumerPolicy
160 IMPORT_C virtual void SetConsumerIapIdL(TUint32 aIapId);
161 IMPORT_C virtual TInt ConsumerIapId(TUint32& aCurrentIapId);
162 IMPORT_C virtual void SetConsumerIdentityProviderIdsL(
163 CSenIdentityProviderIdArray8& aList);
165 IMPORT_C virtual TInt AddConsumerIdentityProviderIdL(
166 const TDesC8& aProviderId);
168 IMPORT_C virtual const CSenIdentityProviderIdArray8&
169 ConsumerIdentityProviderIds8L();
171 IMPORT_C virtual TBool AcceptsConsumerPolicy(
172 MSenConsumerPolicy& aPolicyPattern);
174 IMPORT_C virtual TInt RebuildFromConsumerPolicy(
175 MSenConsumerPolicy& aTemplate);
177 protected: // New functions
181 * @since Series60 3.0
182 * @param aType enumeration defininng the type of this class.
184 IMPORT_C CSenServicePattern(
185 MSenServiceDescription::TDescriptionClassType aType);
188 * Base constructor offered to sub class implementations.
189 * @since Series60 3.0
191 IMPORT_C void BaseConstructL();
194 * Base constructor offered to sub class implementations.
195 * @since Series60 3.0
196 * @param aNamespaceURI the localname for XML element representation
199 IMPORT_C void BaseConstructL(const TDesC8& aNamespaceURI);
202 * Base constructor offered to sub class implementations.
203 * @since Series60 3.0
204 * @param aEndPoint is the actual endpoint to the service
205 * @param aContract of the service, typically some URI
207 IMPORT_C void BaseConstructL(const TDesC8& aEndPoint, const TDesC8& aContract);
211 * Sets the Consumer SNAP ID.
212 * @param aSnapId A TUint32 Snap ID
214 IMPORT_C void SetConsumerSnapIdL(TUint32 aSnapId);
216 * Gets the Consumer SNAP ID.
217 * @param aCurrentSnapId A TUint32 reference to be filled in with the
218 * value of the SNAP ID.
219 * @return KErrNone if no error, or some of the system
222 IMPORT_C TInt ConsumerSnapId(TUint32& aCurrentSnapId);
226 // Consumer policy class instance, used as a delegate in parsing
227 CSenConsumerPolicy* iConsumerPolicy;
230 #endif SEN_SERVICE_PATTERN_H