websrv_pub/web_service_description_api/inc/SenServicePattern.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-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:        Class derives the XML service description and further extends
       
    15 *                it by adding consumer policy interface implementation.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 #ifndef SEN_SERVICE_PATTERN_H
       
    27 #define SEN_SERVICE_PATTERN_H
       
    28 
       
    29 //  INCLUDES
       
    30 #include <e32base.h>
       
    31 #include <s32strm.h>
       
    32 #include <SenXmlServiceDescription.h>
       
    33 #include <MSenConsumerPolicy.h>
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CSenConsumerPolicy;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41 * Class derives the XML service description and further extends
       
    42 * it by implementing consumer policy interface.
       
    43 *
       
    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). 
       
    47 *
       
    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.
       
    52 *
       
    53 * The main purpose of this class is to simplify the initialization
       
    54 * of service connections for Basic Web Services.
       
    55 *
       
    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!).
       
    61 *
       
    62 * This is due the nature of Service Pattern: it acts as a consumer
       
    63 * originated filter, after which a service will be resolved.
       
    64 *
       
    65 * Any service which "meets" the Service Pattern "constraints", is
       
    66 * considered as a "match", because such service accepts this
       
    67 * (search) pattern.
       
    68 *
       
    69 *  @lib SenServDesc.lib
       
    70 *  @since Series60 3.0
       
    71 */
       
    72 class CSenServicePattern : public CSenXmlServiceDescription, public MSenConsumerPolicy
       
    73 
       
    74     {
       
    75     public:  // Constructors and destructor
       
    76         
       
    77         /**
       
    78          *  Standard 2 phase constructors
       
    79          */
       
    80         IMPORT_C static CSenServicePattern* NewL();
       
    81 
       
    82         /**
       
    83          *  Standard 2 phase constructors
       
    84          */
       
    85         IMPORT_C static CSenServicePattern* NewLC();
       
    86 
       
    87         /**
       
    88          *  Standard 2 phase constructor
       
    89          *  @param aNamespaceURI    namespace URI for the service pattern.
       
    90          */
       
    91         IMPORT_C static CSenServicePattern* NewL(const TDesC8& aNamespaceURI);
       
    92 
       
    93         /**
       
    94          *  Standard 2 phase constructor
       
    95          *  @param aNamespaceURI    namespace URI for the service pattern.
       
    96          */
       
    97         IMPORT_C static CSenServicePattern* NewLC(const TDesC8& aNamespaceURI);
       
    98 
       
    99         /**
       
   100          *  Standard 2 phase constructor.
       
   101          *  @param aEndPoint    service pattern endpoint.
       
   102          *  @param aContract    service pattern contract.
       
   103          */
       
   104         IMPORT_C static CSenServicePattern* NewL(   const TDesC8& aEndPoint,
       
   105                                                     const TDesC8& aContract );
       
   106 
       
   107         /**
       
   108          *  Standard 2 phase constructor.
       
   109          *  @param aEndPoint    service pattern endpoint.
       
   110          *  @param aContract    service pattern contract.
       
   111          */
       
   112         IMPORT_C static CSenServicePattern* NewLC(  const TDesC8& aEndPoint,
       
   113                                                     const TDesC8& aContract );
       
   114         
       
   115         /**
       
   116         * Destructor.
       
   117         */
       
   118         IMPORT_C virtual ~CSenServicePattern();
       
   119 
       
   120         // New functions
       
   121         
       
   122         /**
       
   123         * Convenience method for writing out the consumer policy as XML
       
   124         * in UTF-8 form.
       
   125         * @since Series60 3.0
       
   126         * @return consumer policy as UTF-8 form XML.
       
   127         */ 
       
   128         IMPORT_C HBufC8* ConsumerPolicyAsXmlL();
       
   129         
       
   130         // Functions from base classes
       
   131         
       
   132         // From CSenXmlServiceDescription 
       
   133         
       
   134         /**
       
   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.
       
   142         */
       
   143         IMPORT_C TBool Matches(MSenServiceDescription& aServicePattern);
       
   144         
       
   145         /**
       
   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
       
   153         */
       
   154         IMPORT_C void StartElementL(const TDesC8& aNsUri,
       
   155                                     const TDesC8& aLocalName,
       
   156                                     const TDesC8& aQName,
       
   157                                     const RAttributeArray& aAttributes);
       
   158                                 
       
   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);
       
   164     
       
   165         IMPORT_C virtual TInt AddConsumerIdentityProviderIdL(
       
   166                                                         const TDesC8& aProviderId);
       
   167 
       
   168         IMPORT_C virtual const CSenIdentityProviderIdArray8&
       
   169                                                 ConsumerIdentityProviderIds8L();
       
   170 
       
   171         IMPORT_C virtual TBool AcceptsConsumerPolicy(
       
   172                                             MSenConsumerPolicy& aPolicyPattern);
       
   173 
       
   174         IMPORT_C virtual TInt RebuildFromConsumerPolicy(
       
   175                                                     MSenConsumerPolicy& aTemplate);
       
   176         
       
   177     protected:  // New functions
       
   178         
       
   179         /**
       
   180         * C++ constructor.
       
   181         * @since Series60 3.0
       
   182         * @param aType enumeration defininng the type of this class.
       
   183         */
       
   184         IMPORT_C CSenServicePattern(
       
   185                             MSenServiceDescription::TDescriptionClassType aType);
       
   186         
       
   187         /**
       
   188         * Base constructor offered to sub class implementations.
       
   189         * @since Series60 3.0
       
   190         */
       
   191         IMPORT_C void BaseConstructL();
       
   192 
       
   193         /**
       
   194         * Base constructor offered to sub class implementations.
       
   195         * @since Series60 3.0
       
   196         * @param aNamespaceURI the localname for XML element representation
       
   197         *        of this class.
       
   198         */
       
   199         IMPORT_C void BaseConstructL(const TDesC8& aNamespaceURI);
       
   200 
       
   201         /**
       
   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
       
   206         */
       
   207         IMPORT_C void BaseConstructL(const TDesC8& aEndPoint, const TDesC8& aContract);
       
   208         
       
   209 	public:
       
   210 		/**
       
   211         * Sets the Consumer SNAP ID.
       
   212         * @param aSnapId  A TUint32 Snap ID
       
   213         */
       
   214         IMPORT_C void SetConsumerSnapIdL(TUint32 aSnapId);
       
   215 		/**
       
   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
       
   220         *                       wide error codes.
       
   221         */
       
   222         IMPORT_C TInt ConsumerSnapId(TUint32& aCurrentSnapId);
       
   223 		
       
   224     protected:  // Data
       
   225     
       
   226         // Consumer policy class instance, used as a delegate in parsing
       
   227         CSenConsumerPolicy* iConsumerPolicy;
       
   228     };
       
   229 
       
   230 #endif SEN_SERVICE_PATTERN_H
       
   231 
       
   232 // End of File