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