epoc32/include/mw/msenhostlet.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). 
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: Hostlet call back interface
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
#ifndef M_SEN_HOSTLET_H
williamr@2
    20
#define M_SEN_HOSTLET_H
williamr@2
    21
williamr@2
    22
//  INCLUDES
williamr@2
    23
#include <e32base.h> // for CBase
williamr@2
    24
#include <badesca.h>
williamr@2
    25
williamr@2
    26
#include <MSenHostletRequest.h>
williamr@2
    27
#include <MSenHostletResponse.h>
williamr@2
    28
#include <SenXmlServiceDescription.h>
williamr@2
    29
#include <SenServiceConnection.h> 
williamr@2
    30
williamr@2
    31
// FORWARD DECLARE
williamr@2
    32
williamr@2
    33
// CLASS DECLARATION
williamr@2
    34
class MSenHostlet
williamr@2
    35
    {
williamr@2
    36
    public:
williamr@2
    37
        /**
williamr@2
    38
         * Main method for receiving incoming messages, which are typically SOAP / XML,
williamr@2
    39
         * and for providing service for these requests.
williamr@2
    40
         *  @param aRequestUtf8 the request that needs to be be processed by the
williamr@2
    41
         *   hostlet application (local service provider).
williamr@2
    42
         *  @param aResponse is where response data is to be set. 
williamr@2
    43
         *   CSenHostletConnection::ResponsdL should be called 
williamr@2
    44
         *   in order to send the response back to the requester
williamr@2
    45
         *   (service consumer).
williamr@2
    46
         */
williamr@2
    47
        virtual TInt ServiceL(MSenHostletRequest& aRequest, MSenHostletResponse& aResponse) = 0;
williamr@2
    48
williamr@2
    49
        /**
williamr@2
    50
        * Defines the service endpoint for this hostlet
williamr@2
    51
        * @return endpoint that this hostlet has specified. If hostlet
williamr@2
    52
        * implementation does not wish to define any endpoint, but to
williamr@2
    53
        * use contract only, it should return KNullDesC8 (zero-length descriptor).
williamr@2
    54
        * In such case, CSenHostletConnection constructor will attempt to resolve
williamr@2
    55
        * secure identifier (UID3) of the application, and use that to generate
williamr@2
    56
        * a locally unique endpoint. If the UID3 is not available, then the
williamr@2
    57
        * constructor of CSenHostletConnection will leave with the following
williamr@2
    58
        * error code: KErrSenNoContractNoEndPoint     
williamr@2
    59
        *
williamr@2
    60
        * Note: Hostlets, which don't provide endpoint and don't have UID3, cannot 
williamr@2
    61
        * create hostlet connection: instead, CSenHostletConnection constructor
williamr@2
    62
        * will leave with the following code: KErrSenNoContractNoEndPoint
williamr@2
    63
        *
williamr@2
    64
        * If endpoint is not specified, hostlet connection itself
williamr@2
    65
        * will generate an endpoint from applications secure ID (UID3) if such is available,
williamr@2
    66
        * and consumers can invoke the service via the provided contract ("service type" 
williamr@2
    67
        * identifier).
williamr@2
    68
        *
williamr@2
    69
        */
williamr@2
    70
        virtual TPtrC8 Endpoint() const = 0;
williamr@2
    71
williamr@2
    72
        /**
williamr@2
    73
        * Defines the service constract URI for this hostlet
williamr@2
    74
        * @return the URI identifier for the provided service, for example
williamr@2
    75
        * "urn:liberty:id-sis-pp:2003-08". Note that there might be multiple
williamr@2
    76
        * hostlets (local service providers) which all share common service
williamr@2
    77
        * type, that is, they all have same service contract URI.
williamr@2
    78
        *
williamr@2
    79
        * Note: Hostlets, which don't provide endpoint and don't have UID3, cannot 
williamr@2
    80
        * create hostlet connection: instead, CSenHostletConnection constructor
williamr@2
    81
        * will leave with the following error code: KErrSenNoContractNoEndPoint
williamr@2
    82
        */
williamr@2
    83
        virtual TPtrC8 Contract() const = 0;
williamr@2
    84
williamr@2
    85
        /**
williamr@2
    86
        * Defines the framework for this hostlet.
williamr@2
    87
        * @return the framework ID. Default inline implementation 
williamr@2
    88
        * returns RESTful service invocation framework ID, 
williamr@2
    89
        * KDefaultRestServicesFrameworkID, as defined in SenServiceConnection.h
williamr@2
    90
        */
williamr@2
    91
        inline virtual TPtrC8 FrameworkId() const { return KDefaultRestServicesFrameworkID(); }
williamr@2
    92
williamr@2
    93
        /**
williamr@2
    94
        * Each Hostlet implementation may further describes its service via this callback.
williamr@2
    95
        * @param aSD is the description, where service specific attributes can be defined.
williamr@2
    96
        * Default, inline implementation sets the endpoint, contract and framework ID
williamr@2
    97
        * by calling the other, more simple callbacks.
williamr@2
    98
        *
williamr@2
    99
        * It is mandatory for each hostlet to define either endpoint or contract.
williamr@2
   100
        * Otherwise, the constuctor of CSenHostletConnection will leave with the
williamr@2
   101
        * following error code:
williamr@2
   102
        *     KErrSenNoContractNoEndPoint - neither endpoint or contract was 
williamr@2
   103
        *     specified. This is illegal, since the service would lack an identifier. 
williamr@2
   104
        * 
williamr@2
   105
        * @param aSD is the service description into which this hostlet may further
williamr@2
   106
        * define other service specific information, like facets. Note that this 
williamr@2
   107
        * call back is "stronger" than Endpoint() and Contract(), and thus any
williamr@2
   108
        * value specified in this method will be in effect for the hostlet connection.
williamr@2
   109
        */
williamr@2
   110
        inline virtual void DescribeServiceL(CSenXmlServiceDescription& aSD) 
williamr@2
   111
            { 
williamr@2
   112
            aSD.SetEndPointL(Endpoint());
williamr@2
   113
            aSD.SetContractL(Contract()); 
williamr@2
   114
            aSD.SetFrameworkIdL(FrameworkId());
williamr@2
   115
            } 
williamr@2
   116
williamr@2
   117
        /**
williamr@2
   118
        * This callback function is invoked each time when any hostlet connection's
williamr@2
   119
        * asynchronous RespondL is completed. Method can be used to trigger the 
williamr@2
   120
        * release of some response releated system resources, as it is invoked 
williamr@2
   121
        * after the response has been delivered to the consumer (application
williamr@2
   122
        * may wish to close handles to reserved file or memory).
williamr@2
   123
        *
williamr@2
   124
        * @param aTxnId identifies what transaction (service message) was completed
williamr@2
   125
        * @param aCompletionCode indicates whether transaction completed ok (KErrNone)
williamr@2
   126
        * or not (error code).
williamr@2
   127
        * @param aDesc may provide additional information about completed transaction,
williamr@2
   128
        * typically this description is provided, if an error has occured.
williamr@2
   129
        * It is optional for hostlet implementation to implement this method. 
williamr@2
   130
        */
williamr@2
   131
        inline virtual void OnServiceCompleteL(TInt /* aTxnId */, 
williamr@2
   132
                                               TInt /* aCompletionCode */, 
williamr@2
   133
                                               const TDesC8& /* aDesc*/ ) { ; }
williamr@2
   134
                                             
williamr@2
   135
				/**
williamr@2
   136
        * Hostlet connection calls this method several times, passing a different
williamr@2
   137
        * UID per each call. If application wants to provide particular interface
williamr@2
   138
        * to hostlet connection (web services stack), it needs to return a pointer
williamr@2
   139
        * to such M-class as a return value of this method. For any interface, that
williamr@2
   140
        * application has not implemented, it is supposed to return NULL.
williamr@2
   141
        * @param aUID is the unique identifier of some interface
williamr@2
   142
        * @return value should be a valid (void) pointer to any interface implemented
williamr@2
   143
        * by the application. NULL signalizes that application does not provide interface
williamr@2
   144
        * for give UID. 
williamr@2
   145
        */    
williamr@2
   146
	    inline virtual TAny* GetInterfaceByUid( TUid /* aUID */ ) { return NULL; };                                             
williamr@2
   147
    };
williamr@2
   148
williamr@2
   149
williamr@2
   150
#endif // M_SEN_HOSTLET_H
williamr@2
   151
williamr@2
   152
// End of File