contentpublishingsrv/contentpublishingserver/cpserver/inc/cpserver.h
branchRCL_3
changeset 114 a5a39a295112
equal deleted inserted replaced
113:0efa10d348c0 114:a5a39a295112
       
     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:  Content Publisher Server - Main class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CCPSERVER_H
       
    20 #define C_CCPSERVER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "cpserverdef.h"
       
    25 #include "cpserverburlistener.h"
       
    26 
       
    27 #ifdef CONTENT_PUBLISHER_DEBUG
       
    28 class CCPDebug;
       
    29 #endif
       
    30 
       
    31 class CCPDataManager;
       
    32 class CCPActionHandlerThread;
       
    33 class CCPServer;
       
    34 
       
    35 struct TPointersForSession
       
    36     {
       
    37     CCPServer* iServer;
       
    38     CCPDataManager* iDataManager;
       
    39     CCPActionHandlerThread* iActionHandlerThread;
       
    40     };
       
    41 
       
    42 // CLASS DECLARATION
       
    43 /**
       
    44  *  Content Publisher Server implementation
       
    45  *
       
    46  *  @since Series 60 5.0
       
    47  */
       
    48 class CCPServer : public CPolicyServer, public MBURListenerCallback
       
    49     {
       
    50 public:
       
    51     // Constructors and destructor
       
    52 
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      */
       
    56     static CCPServer* NewLC();
       
    57 
       
    58     /**
       
    59      * Destructor.
       
    60      */
       
    61     virtual ~CCPServer();
       
    62 
       
    63 public:
       
    64     // New functions        
       
    65 
       
    66     /**
       
    67      * Stops server.
       
    68      */
       
    69     void Stop();
       
    70 
       
    71     /**
       
    72      * Panic client. 
       
    73      * @param aMessage RMessage2
       
    74      * @param aPanic panic code
       
    75      */
       
    76     static void PanicClient( const RMessage2& aMessage, 
       
    77         TCPServerPanic aPanic );
       
    78 
       
    79     /**
       
    80      * start server
       
    81      * @return aErr Error code.
       
    82      */
       
    83     static TInt ThreadStart();
       
    84 
       
    85     /**
       
    86      * Decrements session counter
       
    87      */
       
    88     void RemoveSession();
       
    89 
       
    90     /**
       
    91      * Increments session counter
       
    92      */
       
    93     void AddSession();
       
    94 
       
    95     /**
       
    96      * HandleBUREventL is called when Backup and Restore state has been changed.
       
    97      *
       
    98      * @since S60 v3.1
       
    99      * @param aStatus Current Backup and Restore status.
       
   100      */
       
   101     void HandleBUREventL( TBURStatus aStatus );
       
   102 
       
   103     /**
       
   104      * Get Lock
       
   105      *
       
   106      * @return ETrue if Backup or Restore are running 
       
   107      */
       
   108     TBool GetLock();
       
   109 
       
   110     /**
       
   111      * Returns notifications array
       
   112      */
       
   113     RPointerArray<CLiwDefaultList>& GetNotifications( ); 
       
   114 
       
   115     /**
       
   116      * Get DataMap Cache
       
   117      *
       
   118      * @return DataMap cache reference
       
   119      */
       
   120     TLiwVariant& GetDataMapCache();
       
   121     
       
   122 private:
       
   123     // From CActive
       
   124 
       
   125     /**
       
   126      * Process any errors.
       
   127      * @param aError the leave code reported
       
   128      * @return KErrNone if leave is handled
       
   129      */
       
   130     TInt RunError( TInt aError );
       
   131 
       
   132 private:
       
   133     // New methods
       
   134 
       
   135     /**
       
   136      * Constructs the server. 
       
   137      * @param aPriority CServer2 input parameter
       
   138      */
       
   139     CCPServer( TInt aPriority );
       
   140 
       
   141     /**
       
   142      * Perform the second phase construction of a CCPServer object.
       
   143      */
       
   144     void ConstructL();
       
   145 
       
   146     /**
       
   147      * Panic the server. 
       
   148      * @param param aPanic the panic code
       
   149      * @return a updateId of container
       
   150      */
       
   151     static void PanicServer( TCPServerPanic aPanic );
       
   152     
       
   153     /**
       
   154      * Send notification
       
   155      * @param Map containing ids of item
       
   156      */
       
   157     void AppendNotificationL( CCPLiwMap* aMap ); 
       
   158 
       
   159     
       
   160 private:
       
   161     // From CServer2
       
   162 
       
   163     /**
       
   164      * Create a time server session, and return a pointer to the created object.
       
   165      * @param aVersion the client version 
       
   166      * @param aMessage RMessage2 
       
   167      * @return pointer to new session
       
   168      */
       
   169     CSession2* NewSessionL( const TVersion& /*aVersion*/,
       
   170         const RMessage2& /*aMessage*/) const;
       
   171 
       
   172     /**
       
   173      * create and run server
       
   174      */
       
   175     static void CreateAndRunServerL();
       
   176 
       
   177 
       
   178     /**
       
   179      * Publishers deactivation
       
   180      */
       
   181     void DeactivatePublishersL();
       
   182 
       
   183 
       
   184     /**
       
   185      * Resets Activate flag and update item in the DB
       
   186      */
       
   187     void ResetAndUpdateFlagL( CCPLiwMap* aMap );
       
   188         
       
   189 private:
       
   190     //data
       
   191 
       
   192     /*
       
   193      * Manager to send and receive data beetween server and storage 
       
   194      * Own.
       
   195      */
       
   196     CCPDataManager* iDataManager;
       
   197 
       
   198     /*
       
   199      * Manager to prepare and execute action
       
   200      * Own. 
       
   201      */
       
   202     CCPActionHandlerThread* iActionHandlerThread;
       
   203 
       
   204     /*
       
   205      * Count of sessions
       
   206      * Own.
       
   207      */
       
   208     TInt iCountSession;
       
   209 
       
   210     /**
       
   211      * Notifier for Backup and Restore changes.
       
   212      * Own.
       
   213      */
       
   214     CCPServerBURListener* iBURListener;
       
   215 
       
   216 #ifdef CONTENT_PUBLISHER_DEBUG
       
   217     CCPDebug* iDebug;
       
   218 #endif
       
   219 
       
   220     /*
       
   221      * Own.
       
   222      * True if database is lock
       
   223      */
       
   224     TBool iBURLock;
       
   225     
       
   226     /*
       
   227      * Own.
       
   228      * List of waiting notifications about publisher 
       
   229      * activation during startup 
       
   230      */
       
   231     RPointerArray<CLiwDefaultList> iNotifications;
       
   232     
       
   233     /*
       
   234      * Own.
       
   235      */
       
   236     TLiwVariant iDataMapCache;
       
   237     
       
   238     };
       
   239 
       
   240 #endif // C_CCPSERVER_H