S60 5th Edition SDK
Example Applications Guide

timeserver.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : timeserver.h
00004 *  Part of     : CSSync
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 
00017 #ifndef __TIMESERVER_H__
00018 #define __TIMESERVER_H__
00019 
00020 // INCLUDE FILES
00021 #include <e32base.h>
00022 #include "SyncServer.pan"
00023 
00024 // CLASS DECLARATION
00025 /**
00026 * CTimeServer.
00027 *  An instance of class CTimeServer is the main server class
00028 *  for the ClientServerSync example application
00029 */
00030 class CTimeServer : public CServer2
00031     {
00032     public : // Constructors and destructors
00033 
00034         /**
00035         * NewL.
00036         * Two-phased constructor.
00037         * @return Pointer to created CTimeServer object.
00038         */
00039         static CTimeServer* NewL();
00040 
00041         /**
00042         * NewLC.
00043         * Two-phased constructor.
00044         * @return Pointer to created CTimeServer object.
00045         */
00046         static CTimeServer* NewLC();
00047 
00048     public: // New functions
00049 
00050         /**
00051         * ThreadFunction.
00052         * Main function for the server thread.
00053         * @param aNone Not used.
00054         * @return Error code.
00055         */
00056         static TInt ThreadFunction( TAny* aNone );
00057 
00058         /**
00059         * IncrementSessions.
00060         * Increments the count of the active sessions for this server.
00061         */
00062         void IncrementSessions();
00063 
00064         /**
00065         * DecrementSessions.
00066         * Decrements the count of the active sessions for this server.
00067         * If no more sessions are in use the server terminates.
00068         */
00069         void DecrementSessions();
00070 
00071     protected: // Functions from base classes
00072 
00073         /**
00074         * From CActive, RunError.
00075         * Processes any errors.
00076         * @param aError The leave code reported.
00077         * @result return KErrNone if leave is handled.
00078         */
00079         TInt RunError( TInt aError );
00080 
00081     private: // Constructors and destructors
00082 
00083         /**
00084         * CTimeServer.
00085         * C++ default constructor.
00086         * @param aPriority priority for this thread.
00087         */
00088         CTimeServer( TInt aPriority );
00089 
00090         /**
00091         * ConstructL.
00092         * 2nd phase constructor.
00093         */
00094         void ConstructL();
00095 
00096     private: // New methods
00097 
00098         /**
00099         * PanicClient.
00100         * Panics the client.
00101         * @param aMessage The message channel to the client.
00102         * @param aReason The reason code for the panic.
00103         */
00104         static void PanicClient( const RMessage2& aMessage,
00105                                  TTimeServPanic aReason );
00106 
00107         /**
00108         * PanicServer.
00109         * Panics the server.
00110         * @param aReason the reason code for the panic.
00111         */
00112         static void PanicServer( TTimeServPanic aReason );
00113 
00114         /**
00115         * ThreadFunctionL.
00116         * Second stage startup for the server thread.
00117         */
00118         static void ThreadFunctionL();
00119 
00120     private: // Functions from base classes
00121 
00122         /**
00123         * From CServer, NewSessionL.
00124         * Create a time server session.
00125         * @param aVersion The client version.
00126         * @param aMessage Message from client.
00127         * @return Pointer to new session.
00128         */
00129         CSession2* NewSessionL( const TVersion& aVersion, 
00130                                 const RMessage2& aMessage ) const;
00131 
00132     private: // Data
00133 
00134         /**
00135         * iSessionCount, the number of open sessions.
00136         */
00137         TInt iSessionCount;
00138     };
00139 
00140 
00141 #endif // __TIMESERVER_H__
00142 
00143 
00144 // End of File

© Nokia 2009

Back to top