contentpublishingsrv/contentpublishingserver/cpserver/inc/cpserver.h
changeset 0 79c6a41cd166
child 14 15e4dd19031c
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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>& CCPServer::GetNotifications( ); 
       
   114 
       
   115 private:
       
   116     // From CActive
       
   117 
       
   118     /**
       
   119      * Process any errors.
       
   120      * @param aError the leave code reported
       
   121      * @return KErrNone if leave is handled
       
   122      */
       
   123     TInt RunError( TInt aError );
       
   124 
       
   125 private:
       
   126     // New methods
       
   127 
       
   128     /**
       
   129      * Constructs the server. 
       
   130      * @param aPriority CServer2 input parameter
       
   131      */
       
   132     CCPServer( TInt aPriority );
       
   133 
       
   134     /**
       
   135      * Perform the second phase construction of a CCPServer object.
       
   136      */
       
   137     void ConstructL();
       
   138 
       
   139     /**
       
   140      * Panic the server. 
       
   141      * @param param aPanic the panic code
       
   142      * @return a updateId of container
       
   143      */
       
   144     static void PanicServer( TCPServerPanic aPanic );
       
   145     
       
   146     /**
       
   147      * Send notification
       
   148      * @param Map containing ids of item
       
   149      */
       
   150     void AppendNotificationL( CCPLiwMap* aMap ); 
       
   151 
       
   152     
       
   153 private:
       
   154     // From CServer2
       
   155 
       
   156     /**
       
   157      * Create a time server session, and return a pointer to the created object.
       
   158      * @param aVersion the client version 
       
   159      * @param aMessage RMessage2 
       
   160      * @return pointer to new session
       
   161      */
       
   162     CSession2* NewSessionL( const TVersion& /*aVersion*/,
       
   163         const RMessage2& /*aMessage*/) const;
       
   164 
       
   165     /**
       
   166      * create and run server
       
   167      */
       
   168     static void CreateAndRunServerL();
       
   169 
       
   170 
       
   171     /**
       
   172      * Publishers deactivation
       
   173      */
       
   174     void DeactivatePublishersL();
       
   175 
       
   176 
       
   177     /**
       
   178      * Resets Activate flag and update item in the DB
       
   179      */
       
   180     void ResetAndUpdateFlagL( CCPLiwMap* aMap );
       
   181         
       
   182 private:
       
   183     //data
       
   184 
       
   185     /*
       
   186      * Manager to send and receive data beetween server and storage 
       
   187      * Own.
       
   188      */
       
   189     CCPDataManager* iDataManager;
       
   190 
       
   191     /*
       
   192      * Manager to prepare and execute action
       
   193      * Own. 
       
   194      */
       
   195     CCPActionHandlerThread* iActionHandlerThread;
       
   196 
       
   197     /*
       
   198      * Count of sessions
       
   199      * Own.
       
   200      */
       
   201     TInt iCountSession;
       
   202 
       
   203     /**
       
   204      * Notifier for Backup and Restore changes.
       
   205      * Own.
       
   206      */
       
   207     CCPServerBURListener* iBURListener;
       
   208 
       
   209 #ifdef CONTENT_PUBLISHER_DEBUG
       
   210     CCPDebug* iDebug;
       
   211 #endif
       
   212 
       
   213     /*
       
   214      * Own.
       
   215      * True if database is lock
       
   216      */
       
   217     TBool iBURLock;
       
   218     
       
   219     /*
       
   220      * Own.
       
   221      * List of waiting notifications about publisher 
       
   222      * activation during startup 
       
   223      */
       
   224     RPointerArray<CLiwDefaultList> iNotifications;
       
   225     };
       
   226 
       
   227 #endif // C_CCPSERVER_H