webservices/wsrestplugin/inc/senrestplugin.h
changeset 0 62f9d29f7211
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2004 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 #ifndef SEN_REST_PLUGIN_H
       
    26 #define SEN_REST_PLUGIN_H
       
    27 
       
    28 #include <e32std.h>
       
    29 #include <flogger.h>
       
    30 #include "SenXmlUtils.h"
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class MSenCoreServiceManager;
       
    34 class CSenBaseFragment;
       
    35 class MSenTransport;
       
    36 class CSenRestServiceSession;
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 _LIT8(KRestFrameworkVersion,     "1.0");
       
    41 _LIT8(KRestFrameworkXMLNS,       "urn:com.nokia.Sen.rest.config.1.0");
       
    42 _LIT8(KRestFrameworkCue,         "com.nokia.Sen.rest.RestServiceFramework");
       
    43                                  
       
    44 // INCLUDES
       
    45 #include "senserviceinvocationframework.h" // internal Framework\inc
       
    46 
       
    47 /**
       
    48  * Class:       CSenIdWsfPlugin
       
    49  *
       
    50  * Description: An implementation of the CSIF definition. This is concrete
       
    51  * class, instance of which ECOM framework gives to ECOM clients.
       
    52  */
       
    53 class CSenRestPlugin : public CSIF
       
    54     {
       
    55 public:
       
    56     /**
       
    57      * Function:    NewL
       
    58      *
       
    59      * Description: Create instance of concrete implementation. Note that ECOM
       
    60      *              interface implementations can only have two signatures for
       
    61      *              NewL:
       
    62      *               - NewL without parameters (used here)
       
    63      *               - NewL with TAny* pointer, which may provide some client
       
    64      *                 data
       
    65      *
       
    66      * Returns:    Instance of this class.
       
    67      *
       
    68      * Note:       The interface, which is abstract base class of this
       
    69      *             implementation, also provides NewL method. Normally abstract
       
    70      *             classes do not provide NewL, because they cannot create
       
    71      *             instances of themselves.
       
    72      */
       
    73     static CSenRestPlugin* NewL(TAny* aManager);
       
    74 
       
    75 
       
    76 public: // Methods implementing CSIF ECOM interface
       
    77     // For convenience of components classes
       
    78     //RFileLogger* Log() const;
       
    79 
       
    80     /**
       
    81      * Return a system wide unique string to identify this framework
       
    82      *
       
    83      * @return TDesC8 that uniquely identifies this framework.
       
    84      */
       
    85     virtual const TDesC8& Id();
       
    86 
       
    87     /**
       
    88      * Try to find one or more services that match the given
       
    89      * ServiceDescription.
       
    90      * Register ServiceDescriptions for these to the owner of the framework,
       
    91      * i.e. to the ServiceManager. Return the number of ServiceDescriptions
       
    92      * that were added.
       
    93      *
       
    94      * @param   aPattern - A ServiceDescriptin that should be treated as a
       
    95      *          pattern
       
    96      *
       
    97      * @param
       
    98      *  return (TInt) count of matching ServiceDescriptions that were added
       
    99      */
       
   100     virtual TInt AddServiceDescriptionL( MSenServiceDescription& aPattern, 
       
   101                                          MSenRemoteServiceConsumer& aRemoteConsumer,
       
   102                                          HBufC8*& aErrorMsg ); 
       
   103 
       
   104     /**
       
   105      * Attempt to register the ServiceDescription to the ServiceManager that
       
   106      * owns the framework.
       
   107      * This is a callback used by the ServiceManager to give frameworks a
       
   108      * chance to replace a generic ServiceDescription into something that is
       
   109      * more specific, and more useful, to the ServiceInvocationFramework.
       
   110      *
       
   111      * @param aServiceDescription A ServiceDescription
       
   112      *
       
   113      *  return TInt aError - indicates the error or KErrNone if successful
       
   114      */
       
   115     virtual TInt RegisterServiceDescriptionL(MSenServiceDescription& aServiceDescription);
       
   116 
       
   117 
       
   118     /**
       
   119      * Attempt to unregister the ServiceDescription from the ServiceManager
       
   120      * that owns the framework.
       
   121      * This is a callback used by the ServiceManager.
       
   122      *
       
   123      * @param aServiceDescription A ServiceDescription
       
   124      *
       
   125      *  return TInt aError - indicates the error or KErrNone if successful
       
   126      */
       
   127     virtual TInt UnregisterServiceDescriptionL(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      */
       
   140     virtual TInt CreateServiceSessionL(MSenServiceDescription& aServiceDescription,
       
   141                                        MSenServiceDescription& aPattern,
       
   142                                        CSenServiceSession*& aNewSession,
       
   143                                        MSenRemoteServiceConsumer& aRemoteConsumer,
       
   144                                        HBufC8*& aErrMsg);
       
   145 
       
   146     /**
       
   147      * Return a new instance of a framework specific class that
       
   148      * implements the ServiceDesccription interface.
       
   149      *
       
   150      * @param new service description 
       
   151      *        (which typically derives from CSenServiceSession)
       
   152      *
       
   153      * return TInt error or KErrNone if successful
       
   154      */
       
   155     virtual CSenWSDescription* NewServiceDescriptionL();
       
   156 
       
   157     /**
       
   158      * Return the ServiceManager for which this instance is working.
       
   159      * This is used by the ServiceSession instances created by this framework.
       
   160      *
       
   161      * Note, in Sen, MSenCoreServiceManager IS SINGLETON(!), so all Frameworks
       
   162      * return their "owner" - that is - the only service manager in
       
   163      * Sen Framework
       
   164      *
       
   165      * @return (MSenCoreServiceManager)
       
   166      */
       
   167     virtual MSenCoreServiceManager& Manager();
       
   168 
       
   169 
       
   170     /**
       
   171      * Set the ServiceManager to which this instance reports.
       
   172      * The (singleton) ServiceManager calls this method when
       
   173      * it instantiates a framework.
       
   174      *
       
   175      * @param aServiceManager The singleton ServiceManager in the system.
       
   176      */
       
   177     virtual void SetManager(MSenCoreServiceManager& aServiceManager);
       
   178 
       
   179 
       
   180     /**
       
   181      * Return an object that can do SAX based parsing of a XML fragment
       
   182      * that contains framework specific configuration information.
       
   183      * The ServiceManager asks for this BaseFragment upon startup
       
   184      * in order to give this framework a chance to read its configuration
       
   185      * information from the central ServiceManager configuration document.
       
   186      *
       
   187      * @return (CSenBaseFragment)
       
   188      */
       
   189     virtual CSenBaseFragment& ConfigParser();
       
   190 
       
   191     /**
       
   192      * Write the ServiceInvocationFramework configuration as XML to a HBufC8.
       
   193      *
       
   194      * This method is invoked by the ServiceManager when it saves
       
   195      * its state and/or configuration.
       
   196      *
       
   197      * Upon startup the chunk of XML that is written will be passed back to
       
   198      * the configuation parser of the framework.
       
   199      *
       
   200      * The "schema" that shall be adhered to is:
       
   201      * <pre>
       
   202      * &lt;element name="Framework"&gt;
       
   203      *      &lt;any/&gt;&lt;!-- this is where implementations write additional
       
   204      *      information --&gt;
       
   205      *      &lt;attribute name="class" type="String"&gt;
       
   206      *    &lt;!-- In Syimbian the class attribute is used as cue for the
       
   207      *      ECOM Resolver --&gt;
       
   208      * &lt;/element&gt;
       
   209      * </pre>
       
   210      *
       
   211      * @param aTo - a HBufC8 to which the framework should write its
       
   212      *              configuration
       
   213      */
       
   214 
       
   215     virtual HBufC8* AsXmlL();
       
   216     virtual HBufC* AsXmlUnicodeL();
       
   217     virtual void EndElementL(const TDesC8& aNsUri, const TDesC8& aLocalName, const TDesC8& aQName);
       
   218 
       
   219     TInt OnEvent(const TInt aEvent, TAny* aArgument);
       
   220 
       
   221     virtual TAny* ExtendedInterface();
       
   222 
       
   223     // New methods
       
   224 
       
   225     /**
       
   226     * REST framework specifies at least following text/xml content type:
       
   227     * KTextWwwFormContentType ==  "application/x-www-form-urlencoded; charset=UTF-8"
       
   228     * @return KErrNone on success, system-wide error code otherwise
       
   229     */    
       
   230     virtual TInt SetTransportPropertiesL(MSenTransport& aTransport);
       
   231 
       
   232 public: // destructor
       
   233     virtual ~CSenRestPlugin();
       
   234 
       
   235 
       
   236 protected:
       
   237     /**
       
   238      * Function:   CSenRestPlugin
       
   239      *
       
   240      * Discussion: Perform the first phase of two phase construction
       
   241      */
       
   242     CSenRestPlugin(MSenCoreServiceManager& aManager);
       
   243 
       
   244     /**
       
   245      * Function:   ConstructL
       
   246      *
       
   247      * Discussion: Perform the second phase construction of a
       
   248      *             CImplementationClassPlus object.
       
   249      */
       
   250     void ConstructL();
       
   251 
       
   252 private: // data
       
   253     MSenCoreServiceManager& iManager;
       
   254     };
       
   255 
       
   256 
       
   257 #endif // SEN_REST_PLUGIN_H
       
   258