upnpharvester/mdhserver/inc/server/mdhserver.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2007 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:      Metadata Harvester server executable header file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 #ifndef MDHSERVER_H
       
    25 #define MDHSERVER_H
       
    26 
       
    27 //  INCLUDES
       
    28 #include <e32base.h>
       
    29 #include <f32file.h>
       
    30 #include "mdhmediaservercontainer.h"
       
    31 
       
    32 // ---------------------------------------------------------------
       
    33 // Server's policy
       
    34 // ---------------------------------------------------------------
       
    35 
       
    36 //Total number of ranges
       
    37 const TUint KCmMdhServerRangeCount = 2;
       
    38 
       
    39 //Definition of the ranges of IPC numbers
       
    40 const TInt KCmMdhServerRanges[KCmMdhServerRangeCount] = 
       
    41         {
       
    42         0,
       
    43         3
       
    44         };
       
    45 
       
    46 //Policy to implement for each of the above ranges        
       
    47 const TUint8 KCmMdhServerElementsIndex[KCmMdhServerRangeCount] = 
       
    48         {
       
    49         1, //applies to 1st range
       
    50         CPolicyServer::ENotSupported
       
    51         };
       
    52 
       
    53 //Specific capability checks
       
    54 const CPolicyServer::TPolicyElement KCmMdhServerElements[] = 
       
    55         {
       
    56         {_INIT_SECURITY_POLICY_C3(ECapabilityNetworkServices,
       
    57             ECapabilityReadUserData, ECapabilityWriteUserData ),
       
    58             CPolicyServer::EFailClient },
       
    59         {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices),
       
    60             CPolicyServer::EFailClient}
       
    61         };
       
    62 
       
    63 //Package all the above together into a policy
       
    64 const CPolicyServer::TPolicy KCmMdhServerPolicy =
       
    65         {
       
    66         //specifies all connect attempts should pass
       
    67         CPolicyServer::EAlwaysPass, 
       
    68         KCmMdhServerRangeCount,
       
    69         KCmMdhServerRanges,
       
    70         KCmMdhServerElementsIndex,
       
    71         KCmMdhServerElements
       
    72         };
       
    73 
       
    74 
       
    75 // DATA TYPES
       
    76 
       
    77 enum TCmMdhServerState
       
    78         {
       
    79         ECmMdhServerStateIdle = 0,
       
    80         ECmMdhServerStateSearching,
       
    81         ECmMdhServerStateHarvesting
       
    82         };
       
    83 
       
    84 // FORWARD DECLARATIONS
       
    85 
       
    86 // FUNCTION PROTOTYPES
       
    87 
       
    88 // Method to panic server in case of serious error
       
    89 void PanicServer( TInt aPanic );
       
    90 // Method to panic client if e.g. message is malformed
       
    91 void PanicClient( const RMessage2& aMessage, TInt aPanic );
       
    92 
       
    93 
       
    94 // CLASS DECLARATION
       
    95 
       
    96 /**
       
    97 *  Dummy Server Core class
       
    98 *
       
    99 *  @lib CmMdhServer
       
   100 *  @since Series 60 3.1
       
   101 */
       
   102 class CCmMdhServer : public CPolicyServer
       
   103     {
       
   104 
       
   105     public:  // Constructors and destructor
       
   106         
       
   107         /**
       
   108         * Two-phased constructor.
       
   109         */
       
   110         static CCmMdhServer* NewLC();
       
   111         
       
   112         /**
       
   113         * Destructor.
       
   114         */
       
   115         virtual ~CCmMdhServer();
       
   116 
       
   117     public: // New functions
       
   118     
       
   119         /**
       
   120         * Sets server's state
       
   121         * @since S60 3.1 
       
   122         * @param aServerState, server state
       
   123         * @param aErrCode error code.
       
   124         */
       
   125         void SetServerStateL( TCmMdhServerState aServerState, 
       
   126                               TInt aErrCode = KErrNone );
       
   127 
       
   128         /**
       
   129         * Decrement server sessions
       
   130         * @since S60 3.1 
       
   131         */        
       
   132         void DecrementSessions();
       
   133 
       
   134         /**
       
   135         * Returns server's current state
       
   136         * @since S60 3.1
       
   137         * @return server state
       
   138         */         
       
   139         TCmMdhServerState ServerState();
       
   140  
       
   141          /**
       
   142         * Set current asyncronous message
       
   143         * @since S60 3.1
       
   144         * @param aMessage, message
       
   145         */        
       
   146         void SetCurrentAsyncMsg( const RMessage2& aMessage );
       
   147     
       
   148          /**
       
   149         * Creates media server container instance
       
   150         * @since S60 3.1
       
   151         */         
       
   152         void CreateMediaserverContainerL();
       
   153         
       
   154          /**
       
   155         * Destroys media server container instance
       
   156         * @since S60 3.1
       
   157         */        
       
   158         void DestroyMediaserverContainer();   
       
   159                 
       
   160          /**
       
   161         * Returns media server container reference
       
   162         * @since S60 3.1
       
   163         * @return media server container
       
   164         */        
       
   165         CCmMdhMediaserverContainer& MediaserverContainer();
       
   166     
       
   167         /**
       
   168         * Increments sessions
       
   169         * @since S60 3.1
       
   170         */ 
       
   171         void IncrementSessions();             
       
   172     
       
   173     private:
       
   174 
       
   175         /**
       
   176         * C++ default constructor.
       
   177         */
       
   178         CCmMdhServer();
       
   179 
       
   180         /**
       
   181         * By default Symbian 2nd phase constructor is private.
       
   182         */
       
   183         void ConstructL();
       
   184 
       
   185     private: // Functions from base classes
       
   186         
       
   187         CSession2* NewSessionL( const TVersion& aVersion,
       
   188                                 const RMessage2& aMessage ) const;
       
   189     
       
   190 
       
   191     private:    // Data
       
   192         
       
   193         /** Current asyncronous message */
       
   194         RMessage2                   iCurrentAsyncMsg;
       
   195         
       
   196         /** Media server container ( owned ) */
       
   197         CCmMdhMediaserverContainer* iMediaserverContainer; 
       
   198         
       
   199         /** Server state */
       
   200         TCmMdhServerState           iServerState;
       
   201         
       
   202         /** Count of sessions */
       
   203         TInt                       iSessionCount;
       
   204         
       
   205     };
       
   206 
       
   207 
       
   208 #endif // MDHSERVER_H
       
   209            
       
   210 // End of File