webservices/wsoviplugin/inc/wsoviplugin.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2008 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: Header declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 #ifndef WSOvi_PLUGIN_H
       
    27 #define WSOvi_PLUGIN_H
       
    28 
       
    29 // INCLUDES
       
    30 #include <e32std.h>
       
    31 #include <flogger.h>
       
    32 
       
    33 #include "senserviceinvocationframework.h" // internal Framework\inc
       
    34 
       
    35 #include "wsovicons.h"
       
    36 #include "sensessionhandler.h"
       
    37 #include "senmessagehandler.h"
       
    38 #include "wsovihandlercontext.h"
       
    39 #include "wsovisessioncontext.h"
       
    40 #include "wsovimessagecontext.h"
       
    41 #include "SenSoapMessage.h"
       
    42 #include "SenXmlConstants.h"    
       
    43 
       
    44 // DATA TYPES
       
    45 typedef RSenPointerMap<TDesC8, TDesC8> RMapHandlers;
       
    46 /**
       
    47  * WSOvi Plugin framework.
       
    48  * An implementation of the CSIF definition. This is concrete
       
    49  * class, instance of which ECOM framework gives to ECOM clients.
       
    50  */
       
    51 class CWSOviPlugin : public CSIF
       
    52     {
       
    53     public:
       
    54         /**
       
    55          * Function:    NewL
       
    56          *
       
    57          * Description: Create instance of concrete implementation. Note that ECOM
       
    58          *              interface implementations can only have two signatures for
       
    59          *              NewL:
       
    60          *               - NewL without parameters (used here)
       
    61          *               - NewL with TAny* pointer, which may provide some client
       
    62          *                 data
       
    63          *
       
    64          * @return    Instance of this class.
       
    65          *
       
    66          * Note:       The interface, which is abstract base class of this
       
    67          *             implementation, also provides NewL method. Normally abstract
       
    68          *             classes do not provide NewL, because they cannot create
       
    69          *             instances of themselves.
       
    70          * @since S60 5.0
       
    71          */
       
    72         static CWSOviPlugin* NewL(TAny* aManager);
       
    73 
       
    74 
       
    75     public: 
       
    76 
       
    77         /**
       
    78          * Return a system wide unique string to identify this framework
       
    79          *
       
    80          * @return TDesC8 that uniquely identifies this framework.
       
    81          * @since S60 5.0
       
    82          */
       
    83         virtual const TDesC8& Id();
       
    84 
       
    85         /**
       
    86          * Try to find one or more session services that match the given
       
    87          * ServiceDescription.If not finded new session is created and added into
       
    88          * coreManager
       
    89          * Return the number of ServiceDescriptions that were added.
       
    90          *
       
    91          * @param   aPattern - A ServiceDescriptin that should be treated as a
       
    92          *          pattern
       
    93          * @param    aRemoteConsumer - the consumer sending the request
       
    94          * @param    aErrorMsg - in case that return value is negative, this may contain
       
    95          *           error as descriptor (SOAP Fault etc)
       
    96          * @return (TInt) count of matching ServiceDescriptions that were added or error
       
    97          * @since S60 5.0
       
    98          */
       
    99         virtual TInt AddServiceDescriptionL( MSenServiceDescription& aPattern, 
       
   100                                              MSenRemoteServiceConsumer& aRemoteConsumer,
       
   101                                              HBufC8*& aErrorMsg ); 
       
   102 
       
   103         /**
       
   104          * Attempt to register the ServiceDescription. 
       
   105          *   In fact session is created but not vaidated and added into CoreManager.
       
   106          *   So registering different to adding that it doesnt validate, just register.
       
   107          *   Common issue is increase core database by one session (validated or not)
       
   108          * @param aServiceDescription A ServiceDescription
       
   109          *
       
   110          * @return TInt aError - indicates the error or KErrNone if successful
       
   111          * @since S60 5.0
       
   112          */
       
   113         virtual TInt RegisterServiceDescriptionL(MSenServiceDescription& aServiceDescription);
       
   114 
       
   115 
       
   116         /**
       
   117          * Attempt to unregister the ServiceDescription from the ServiceManager
       
   118          * that owns the framework.
       
   119          * This is a callback used by the ServiceManager.
       
   120          *
       
   121          * @param aServiceDescription A ServiceDescription
       
   122          *
       
   123          * @return TInt aError - indicates the error or KErrNone if successful
       
   124          * @since S60 5.0
       
   125          */
       
   126         virtual TInt UnregisterServiceDescriptionL(
       
   127                                     MSenServiceDescription& aServiceDescription);
       
   128 
       
   129         /**
       
   130          * Create a ServiceSession based upon the given ServiceDescription.
       
   131          * The ServiceSession is expected to be "valid", i.e. ready for use
       
   132          * by a client.
       
   133          *
       
   134          * @param aServiceDescription A ServiceDescription
       
   135          *
       
   136          * @param aNewSession (CSenServiceSession)
       
   137          *
       
   138          * @return TInt error or KErrNone if successful
       
   139          * @since S60 5.0
       
   140          */
       
   141         virtual TInt CreateServiceSessionL( MSenServiceDescription& aServiceDescription,
       
   142                                             MSenServiceDescription& aPattern,
       
   143                                             CSenServiceSession*& aNewSession,
       
   144                                             MSenRemoteServiceConsumer& aRemoteConsumer,
       
   145                                             HBufC8*& /* aErrorMsg */ );
       
   146 
       
   147         /**
       
   148          * Return a new instance of a framework specific class that
       
   149          * implements the ServiceDesccription interface.
       
   150          *
       
   151          * @param new service description 
       
   152          *        (which typically derives from CSenServiceSession)
       
   153          *
       
   154          * @return TInt error or KErrNone if successful
       
   155          * @since S60 5.0
       
   156          */
       
   157         virtual CSenWSDescription* NewServiceDescriptionL();
       
   158 
       
   159         /**
       
   160          * Return the ServiceManager for which this instance is working.
       
   161          * This is used by the ServiceSession instances created by this framework.
       
   162          *
       
   163          * Note, in Sen, MSenCoreServiceManager IS SINGLETON(!), so all Frameworks
       
   164          * return their "owner" - that is - the only service manager in
       
   165          * Sen Framework
       
   166          *
       
   167          * @return (MSenCoreServiceManager)
       
   168          * @since S60 5.0
       
   169          */
       
   170         virtual MSenCoreServiceManager& Manager();
       
   171 
       
   172 
       
   173         /**
       
   174          * Set the ServiceManager to which this instance reports.
       
   175          * The (singleton) ServiceManager calls this method when
       
   176          * it instantiates a framework.
       
   177          *
       
   178          * @param aServiceManager The singleton ServiceManager in the system.
       
   179          * @since S60 5.0
       
   180          */
       
   181         virtual void SetManager(MSenCoreServiceManager& aServiceManager);
       
   182 
       
   183 
       
   184         /**
       
   185          * Return an object that can do SAX based parsing of a XML fragment
       
   186          * that contains framework specific configuration information.
       
   187          * The ServiceManager asks for this BaseFragment upon startup
       
   188          * in order to give this framework a chance to read its configuration
       
   189          * information from the central ServiceManager configuration document.
       
   190          *
       
   191          * @return (CSenBaseFragment)
       
   192          * @since S60 5.0
       
   193          */
       
   194         virtual CSenBaseFragment& ConfigParser();
       
   195 
       
   196         /**
       
   197          * Read the ServiceInvocationFramework configuration.
       
   198          * This method is invoked by the ServiceManager when it read config.
       
   199          * @since S60 5.0
       
   200          */
       
   201         virtual void StartElementL(const TDesC8& aNsUri,
       
   202                               const TDesC8& aLocalName,
       
   203                               const TDesC8& aQName,
       
   204                               const RAttributeArray& aAttrs);
       
   205 
       
   206         /**
       
   207          * Read the ServiceInvocationFramework configuration.
       
   208          * This method is invoked by the ServiceManager when it read config.
       
   209          * @since S60 5.0
       
   210          */
       
   211         virtual void EndElementL(const TDesC8& aNsUri,
       
   212                               const TDesC8& aLocalName,
       
   213                               const TDesC8& aQName);
       
   214 
       
   215     //derived from SenBaseFragment
       
   216         virtual HBufC8* AsXmlL();
       
   217         virtual HBufC* AsXmlUnicodeL();
       
   218 
       
   219     //derived from SIF
       
   220         virtual TInt OnEvent(const TInt aEvent,
       
   221                             TAny* /* aArgument */);
       
   222         virtual TAny* ExtendedInterface();
       
   223 
       
   224         virtual TInt SetTransportPropertiesL(MSenTransport& /* aTransport */);
       
   225 
       
   226 
       
   227     //----------------------Outbound direction
       
   228         /**
       
   229         * Function:   temporary. Call in proper order session handlers during validation phase
       
   230         * @return number of added descriptions into coreManager or error
       
   231         * @since S60 5.0
       
   232         */
       
   233         TInt ProcessOutboundValidationL( MSenServiceDescription& aPattern, 
       
   234                                          MSenRemoteServiceSession* aRemoteServiceSession,
       
   235                                          HBufC8*& aErrorMessage );
       
   236         /**
       
   237         * Function:   temporary. Call in proper order message handlers during outbound message phase
       
   238         * @return symbian error
       
   239         * @since S60 5.0
       
   240         */
       
   241         TInt ProcessOutboundMessageL( CWSOviMessageContext*& aMsgCtx);
       
   242 
       
   243     //----------------------Inbound direction    
       
   244         /**
       
   245         * Function:   temporary. Call in proper order message handlers during inbound message phase
       
   246         * @return symbian error
       
   247         * @since S60 5.0
       
   248         */
       
   249         TInt ProcessInboundMessageL( );
       
   250 
       
   251         /**
       
   252         * Function:   temporary. Call in proper order session handlers during inbound dispatch phase
       
   253         * @return symbian error
       
   254         * @since S60 5.0
       
   255         */
       
   256         TInt ProcessInboundDispatchL( MSenRemoteServiceSession* aRemoteServiceSession,
       
   257                                       const TInt aErrorCode,
       
   258                                       HBufC8* aMessage,
       
   259                                       MSenProperties* aResponseTransportProperties);
       
   260 
       
   261         //----------------------temporary methods 
       
   262         //  (till moment when engine with handlers will be available)
       
   263         
       
   264         MSenHandler* Handler(const TDesC8& aCue);
       
   265         TBool IsTrustedClient(MSenRemoteServiceConsumer& aRemoteConsumer);
       
   266         
       
   267     public: // destructor
       
   268         virtual ~CWSOviPlugin();
       
   269 
       
   270     protected:
       
   271         /**
       
   272          * Function:   CSenWsiPlugin
       
   273          *
       
   274          * Discussion: Perform the first phase of two phase construction
       
   275          */
       
   276         CWSOviPlugin(MSenCoreServiceManager& aManager);
       
   277 
       
   278         /**
       
   279          * Function:   ConstructL
       
   280          *
       
   281          * Discussion: Perform the second phase construction of a
       
   282          *             CImplementationClassPlus object.
       
   283          */
       
   284         void ConstructL();
       
   285         
       
   286     private:
       
   287         void AddHandlerTag(TPtr8& aXml, const TDesC8& aHandlerClassName);
       
   288         void AddHandlerL(const TDesC8& aHandlerClassName, const TDesC8& aVersion, SenHandler::THandlerType aType);
       
   289         void RemoveHandler(const TDesC8& aCue);
       
   290         void VerifyPermissionOnEachSessionL();
       
   291                 
       
   292     private: // data
       
   293         MSenCoreServiceManager& iManager;
       
   294         //mesg handlers has to be separate to session handlers (separate table) becouse common handlerBase 
       
   295         //  doesnt have name method
       
   296         RPointerArray<CSenMessageHandler> iMsgHandlers;
       
   297         RPointerArray<CSenSessionHandler> iSessionHandlers;
       
   298         RSenPointerMap<TDesC8, TDesC8> iVersions;
       
   299         RPointerArray<CWSOviHandlerContext> iHandlerContexts;
       
   300         RBuf8 iIMSI;
       
   301     };
       
   302 
       
   303 
       
   304 #endif // WSOvi_PLUGIN_H
       
   305