pressrv_plat/xdm_protocol_plugin_api/inc/XdmProtocol.h
changeset 0 c8caa15ef882
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 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:   XDM Protocol
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __XDMPROTOCOL__
       
    22 #define __XDMPROTOCOL__
       
    23 
       
    24 #include <ecom.h>
       
    25 #include <e32base.h>
       
    26 #include "XdmEngine.h"
       
    27 #include "XdmDocument.h"
       
    28 #include "XdmProtocolInfo.h"
       
    29     
       
    30 //Idle timeout value for the protocol implementation in seconds
       
    31 const TInt KDefaultIdleTimeout          = 10;
       
    32 
       
    33 /**
       
    34 * A helper class for  parameter passing from
       
    35 * the XDM engine to the protocol implementation
       
    36 */
       
    37 NONSHARABLE_CLASS( TXdmProtocolParams )
       
    38     {
       
    39     public:
       
    40         
       
    41         /**
       
    42         * C++ constructor
       
    43         *
       
    44         * @param CXdmEngine& Engine handle
       
    45         * @param CXdmProtocolInfo Protocol info handle
       
    46         * @return TXdmProtocolParams
       
    47         */
       
    48         TXdmProtocolParams( const CXdmEngine& aXdmEngine,
       
    49                             const CXdmProtocolInfo& aProtocolInfo ) :
       
    50                             iXdmEngine( aXdmEngine ),
       
    51                             iProtocolInfo( aProtocolInfo ){}
       
    52             
       
    53                             
       
    54     public:  //Data
       
    55     
       
    56         const CXdmEngine&               iXdmEngine;
       
    57         const CXdmProtocolInfo&         iProtocolInfo;             
       
    58     };
       
    59     
       
    60 //FORWARD DECLARATION
       
    61 class CXdmDocument;
       
    62 class CXdmDirectory;
       
    63 class CXdmDocumentNode;
       
    64 
       
    65 //CLASS DECLARATION
       
    66 NONSHARABLE_CLASS( CXdmProtocol ) : public CBase
       
    67     {
       
    68     public:
       
    69         
       
    70         /**
       
    71         * Symbian OS constructor.
       
    72         *
       
    73         * @param CXdmEngine& Reference to the engine
       
    74         * @param CXdmProtocolInfo& Protocol information
       
    75         * @return CXdmProtocol*
       
    76         */
       
    77         static CXdmProtocol* NewL( const CXdmEngine& aXdmEngine,
       
    78                                    const CXdmProtocolInfo& aProtocolInfo );
       
    79         
       
    80         /**
       
    81         * C++ destructor.
       
    82         *
       
    83         */
       
    84 	    virtual ~CXdmProtocol();
       
    85 	
       
    86 	public:
       
    87         
       
    88         /**
       
    89         * Initialise the media used to transfer XDM data
       
    90         *
       
    91         * @param TInt Idle timeout
       
    92         * @param TRequestStatus& Request status of the caller
       
    93         * @return void
       
    94         */
       
    95         virtual void InitTransferMedium( TInt aIdleTimeout, TRequestStatus& aStatus ) = 0;
       
    96         
       
    97         /**
       
    98         * Is the transfer medium ready
       
    99         *
       
   100         * @return TBool Is the medium ready
       
   101         */
       
   102         virtual TBool IsTransferAvailable() const = 0;
       
   103                                                                        
       
   104         /**
       
   105         * Cancel initialisation of the transfer media.
       
   106         *
       
   107         * @return void
       
   108         */
       
   109         virtual void CancelTransferMediumInit() = 0;
       
   110         
       
   111         /**
       
   112         * Create a new document node.
       
   113         *
       
   114         * @return CXdmDocumentNode* 
       
   115         */
       
   116         virtual CXdmDocumentNode* CreateDocumentNodeL() = 0;
       
   117         
       
   118         /**
       
   119         * Create a new document model
       
   120         *
       
   121         * @param TDesC& Name of the new document model
       
   122         * @param TXdmDocType Type of the new document
       
   123         * @return CXdmDocument*
       
   124         */
       
   125         virtual CXdmDocument* CreateDocumentL( const TDesC& aDocumentName,
       
   126                                                const TXdmDocType aDocumentType ) = 0;
       
   127         
       
   128         /**
       
   129         * Create a new directory model
       
   130         *
       
   131         * @param TDesC& Directory path
       
   132         * @return CXdmDirectory*
       
   133         */
       
   134         virtual CXdmDirectory* CreateDirectoryL( const TDesC& aDirectoryPath ) = 0;
       
   135     
       
   136     protected:
       
   137 
       
   138         /**
       
   139         * C++ constructor for derived classes.
       
   140         *
       
   141         * @return CXdmProtocol
       
   142         */      
       
   143         CXdmProtocol();
       
   144 
       
   145     private:  //Data
       
   146 
       
   147         TUid                        iDestructorKey;
       
   148     };
       
   149 
       
   150 // ----------------------------------------------------
       
   151 // CXdmProtocol::CXdmProtocol
       
   152 // 
       
   153 // ----------------------------------------------------
       
   154 //
       
   155 inline CXdmProtocol::CXdmProtocol()
       
   156 	{
       
   157 	}
       
   158 
       
   159 // ----------------------------------------------------
       
   160 // CXdmProtocol::~CXdmProtocol
       
   161 // 
       
   162 // ----------------------------------------------------
       
   163 //
       
   164 inline CXdmProtocol::~CXdmProtocol()
       
   165 	{
       
   166 	REComSession::DestroyedImplementation( iDestructorKey );
       
   167     }
       
   168 
       
   169 // ----------------------------------------------------
       
   170 // CXdmProtocol::NewL
       
   171 // Create a new protocol implementation
       
   172 // ----------------------------------------------------
       
   173 //
       
   174 inline CXdmProtocol* CXdmProtocol::NewL( const CXdmEngine& aXdmEngine,
       
   175                                          const CXdmProtocolInfo& aProtocolInfo )
       
   176     {
       
   177     TAny* ptr = NULL;
       
   178     TXdmProtocolParams params( aXdmEngine, aProtocolInfo );
       
   179     ptr = REComSession::CreateImplementationL( 
       
   180           aProtocolInfo.ProtocolUid(), _FOFF( CXdmProtocol,
       
   181           iDestructorKey ), ( TAny* )&params );
       
   182     return ptr != NULL ? reinterpret_cast<CXdmProtocol*>( ptr ) : NULL;
       
   183     }
       
   184     
       
   185 #endif      //__XDMPROTOCOL__
       
   186             
       
   187 // End of File