websrv_pub/web_service_description_api/inc/MSenServiceDescription.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:        Interface (abstract) class for subclasses implementing the 
       
    15 *                most common value objects used in WSF, which are used to
       
    16 *                describe some invocable service. 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 #ifndef M_SEN_SERVICE_DESCRIPTION_H
       
    28 #define M_SEN_SERVICE_DESCRIPTION_H
       
    29 
       
    30 //  INCLUDES
       
    31 #include <e32base.h>
       
    32 #include <e32des8.h>    
       
    33 #include <s32strm.h>
       
    34 
       
    35 // CONSTANTS
       
    36 _LIT8(KSenFacetValFalse,                "false");
       
    37 _LIT8(KSenFacetValTrue,                 "true");
       
    38 
       
    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");
       
    49 
       
    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");
       
    55 
       
    56 // Transport schemes
       
    57 _LIT8(KSenTransportSchemeHTTP,              "http");
       
    58 _LIT8(KSenTransportSchemeTCP,               "tcp");
       
    59 _LIT8(KSenTransportSchemeLocal,             "local");
       
    60 _LIT8(KSenTransportSchemeHostlet,           "hostlet");
       
    61 //_LIT8(KSenTransportSchemeVirtualTCP,        "vtcp"); 
       
    62 
       
    63 const TInt KSenServiceDescriptionBaseScore = 100;
       
    64 
       
    65 // FORWARD DECLARATIONS
       
    66 class CSenFacet;
       
    67 
       
    68 // DATA TYPES
       
    69 typedef RPointerArray<CSenFacet> RFacetArray;
       
    70 
       
    71 // CLASS DECLARATION
       
    72 
       
    73 /**
       
    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
       
    78 * @since Series60 3.0
       
    79 */
       
    80 class MSenServiceDescription
       
    81     {
       
    82     public: 
       
    83         
       
    84         /**
       
    85         * DescriptionClassType enumeration.
       
    86         */
       
    87         IMPORT_C enum TDescriptionClassType
       
    88             {
       
    89             ERoot                               = 0, // not in use
       
    90             EBaseServiceDescription             = 1, // not in use
       
    91             EXmlServiceDescription              = 2,
       
    92             EIdentityProvider                   = 3, 
       
    93             EServicePattern                     = 4, 
       
    94             EServiceSession                     = 5,
       
    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,
       
   107             EWSDescription                      = 18,
       
   108             EWSPattern                          = 19,
       
   109             EAtomPubServiceSession              = 20,
       
   110             EAtomPubAuthClient                  = 21,
       
   111             EAccount                            = 22,
       
   112             EOviServiceSession                  = 23,
       
   113             EOviOAuthClient                     = 24
       
   114             };
       
   115 
       
   116         // New functions
       
   117     
       
   118         /**
       
   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.
       
   124         */
       
   125         virtual TDescriptionClassType DescriptionClassType() = 0;
       
   126 
       
   127         /**
       
   128         * Method returns ETrue if this service description matches the given 
       
   129         * pattern.
       
   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
       
   138         * for other aspects.
       
   139         * @since Series60 3.0
       
   140         * @param    aPattern is a Service Description, typically with partial
       
   141         *           information.
       
   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).
       
   145         */
       
   146         virtual TBool Matches(MSenServiceDescription& aPattern) = 0;
       
   147 
       
   148         /**
       
   149         * Getter for contract, which is typically some URI.
       
   150         * @since Series60 3.0
       
   151         * @return the Contract
       
   152         */
       
   153         virtual TPtrC8 Contract() = 0;
       
   154 
       
   155         /**
       
   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.
       
   161         */
       
   162         virtual TInt HasFacetL(const TDesC8& aURI, TBool& aHasFacet) = 0;
       
   163 
       
   164         /*
       
   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
       
   170         *                       to the caller.
       
   171         * @return       KErrNone 
       
   172         *               KErrNoMemory value couldn't be allocated due to lack 
       
   173         *               of memory
       
   174         *               KErrNotFound if the wanted facet was not found.
       
   175         *               Other system-wide Symbian error codes.
       
   176         */
       
   177         virtual TInt FacetValue(TDesC8& aURI, HBufC8*& aValueTo) = 0;
       
   178 
       
   179         /**
       
   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
       
   187         */
       
   188         virtual TInt AddFacetL(const CSenFacet& aFacet) = 0;
       
   189 
       
   190         /**
       
   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
       
   195         *               created.
       
   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.
       
   200         */
       
   201         virtual TInt SetFacetL(const CSenFacet& aFacet) = 0;
       
   202 
       
   203         /**
       
   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.
       
   210         */
       
   211         virtual TInt RemoveFacet(const TDesC8& aURI) = 0;
       
   212 
       
   213         /**
       
   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.
       
   222         */
       
   223         virtual TInt FacetsL(RFacetArray& aFacetArray) = 0;
       
   224 
       
   225         /**
       
   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.
       
   229         *
       
   230         * In case of system error, method leaves.
       
   231         *
       
   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
       
   241         *           information.
       
   242         * @return the score. If nothing matches, returns 0
       
   243         */
       
   244         virtual TInt ScoreMatchL(MSenServiceDescription& aPattern) = 0;
       
   245 
       
   246         /**
       
   247         * Getter for endpoint.
       
   248         * @since Series60 3.0
       
   249         * @return The endpoint.
       
   250         */
       
   251         virtual TPtrC8 Endpoint() = 0;
       
   252 
       
   253         /**
       
   254         * Getter for the framework ID.
       
   255         * @since Series60 3.0
       
   256         * @return The framework ID or KNullDesC8 if no framework is set
       
   257         */
       
   258         virtual TPtrC8 FrameworkId() = 0;
       
   259 
       
   260         /**
       
   261         * Getter for the framework version.
       
   262         * @since Series60 3.0
       
   263         * @return The framework version or KNullDesC8 if not set.
       
   264         */
       
   265         virtual TPtrC8 FrameworkVersion() = 0;
       
   266 
       
   267         /**
       
   268         * Setter for contract.
       
   269         * @since Series60 3.0
       
   270         * @param aContract  the contract to be set.
       
   271         */
       
   272         virtual void SetContractL(const TDesC8& aContract) = 0;
       
   273 
       
   274         /**
       
   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 &amp;).
       
   281         *        EncodeHttpCharactersLC() method from XmlUtils can be used
       
   282         *        for encoding of basic XML entities.
       
   283         */
       
   284         virtual void SetEndPointL(const TDesC8& aEndPoint) = 0;
       
   285 
       
   286         /**
       
   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.
       
   291         */
       
   292         virtual HBufC8* AsXmlL() = 0;
       
   293 
       
   294         /**
       
   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)
       
   298         *         encoding form.
       
   299         */
       
   300         virtual HBufC* AsXmlUnicodeL() = 0;
       
   301 
       
   302         /**
       
   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.
       
   306         */
       
   307         virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0;
       
   308     };
       
   309 
       
   310 #endif // M_SEN_SERVICE_DESCRIPTION_H
       
   311 
       
   312 // End of File