realtimenetprots/sipfw/ProfileAgent/Server/Inc/SipProfileCSServer.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003-2009 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:
       
    15 * Name        : SipProfileCSServer.h
       
    16 * Part of     : SIP Profile Server
       
    17 * Interface   : private
       
    18 * The class for ITC server
       
    19 * Version     : 1.0
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 /**
       
    27  @internalComponent
       
    28 */
       
    29 
       
    30 #ifndef SIPPROFILECSSERVER_H
       
    31 #define SIPPROFILECSSERVER_H
       
    32 
       
    33 //  INCLUDES
       
    34 
       
    35 #include <e32base.h>
       
    36 #include "SipProfileCSServer.pan"
       
    37 #include "SipProfileServerCore.h"
       
    38 
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 class CSipProfileCSServerCloseTimer;
       
    42 class CSIPProfileServerCore;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 /**
       
    46  * The class providing ITC server functionality.
       
    47  */
       
    48 class CSIPProfileCSServer: public CPolicyServer
       
    49 	{
       
    50 	public : 
       
    51     
       
    52 	    /**
       
    53         * Two-phased constructor.
       
    54 		* @return new instance
       
    55         */
       
    56 		static CSIPProfileCSServer* NewL(CSIPProfileServerCore& aServerCore);
       
    57 
       
    58 	    /**
       
    59         * Two-phased constructor.
       
    60 		* @return new instance
       
    61         */
       
    62 		static CSIPProfileCSServer* NewLC(CSIPProfileServerCore& aServerCore);
       
    63 
       
    64 	    /**
       
    65         * Destructor
       
    66         */
       
    67 		~CSIPProfileCSServer();
       
    68 
       
    69 	    /**
       
    70         * Initialize server
       
    71 		* @return KErrNone if successfull
       
    72         */
       
    73 		static TInt ThreadFunction(TAny* aNone);
       
    74 
       
    75 	    /**
       
    76         * Increment session counter
       
    77         */
       
    78 		void IncrementSessions();
       
    79 
       
    80 	    /**
       
    81         * Decrement session counter
       
    82         */
       
    83 		void DecrementSessions();
       
    84 
       
    85 	    /**
       
    86         * Stops server if execution no longer needed
       
    87         */
       
    88 		void ServerCanStop();
       
    89 
       
    90 	    /**
       
    91         * Stops server abnormally
       
    92         */
       
    93 		void ShutdownL();
       
    94 
       
    95 	    /**
       
    96         * Stops server abnormally, deletes profiles.dat
       
    97         */
       
    98 		void CleanShutdownL();
       
    99 
       
   100 	protected: // From CActive
       
   101 		
       
   102 	    /**
       
   103         * Called if server fails
       
   104 		* @param aError error code
       
   105 		* @return KErrNone, errors are ignored
       
   106         */
       
   107 		TInt RunError(TInt aError);
       
   108 
       
   109 	private:
       
   110 
       
   111 	    /**
       
   112         * Constructor
       
   113 		* @param aPriority priority of server
       
   114         */
       
   115 		CSIPProfileCSServer(CSIPProfileServerCore& aServerCore,
       
   116 		                    TInt aPriority);
       
   117 
       
   118 	    /**
       
   119         * Symbian 2nd phase constructor
       
   120         */
       
   121 		void ConstructL();
       
   122 
       
   123 	    /**
       
   124         * Send panic to client
       
   125 		* @param aMessage identifies client
       
   126 		* @param aReason panic reason code
       
   127         */
       
   128 		static void PanicClient(const RMessage2& aMessage, 
       
   129                              TSIPProfileCSPanic aReason);
       
   130 
       
   131 	    /**
       
   132         * Panic server
       
   133 		* @param aReason panic reason code
       
   134         */
       
   135 		static void PanicServer(TSIPProfileCSPanic aReason);
       
   136 
       
   137 	    /**
       
   138         * Initialize server
       
   139         */
       
   140 		static void ThreadFunctionL(RMutex& aMutex);
       
   141 		
       
   142 		/**
       
   143 		* Signals a client's semaphore,
       
   144 		* that is waiting for the server to be started.
       
   145 		* @return KErrNone if semaphore was found and signalled
       
   146 		*/ 
       
   147 		static TInt SignalClientSemaphore();
       
   148 
       
   149 	private: // From CServer
       
   150 		
       
   151 	    /**
       
   152         * Create new ITC session
       
   153 		* @param aVersion version of client
       
   154 		* @param aMessage identifies client
       
   155 		* @return new session instance
       
   156         */
       
   157 		CSession2* NewSessionL (const TVersion &aVersion, 
       
   158                                 const RMessage2& aMessage) const;
       
   159 
       
   160 	private:
       
   161 
       
   162 		TUint                          iSessionCount;
       
   163 		CSIPProfileServerCore&         iServerCore;
       
   164 		CSipProfileCSServerCloseTimer* iCloseTimer;
       
   165 
       
   166 
       
   167 	private: // For testing purposes
       
   168 #ifdef CPPUNIT_TEST
       
   169 		friend class CSIPProfileCSServerTest;
       
   170 		friend class CSIPProfileAlrTest;
       
   171 		friend class CSIPProfileStateTest;
       
   172 		friend class CSIPProfileServerCoreTest;
       
   173 		friend class CSIPProfileCSSessionTest;
       
   174 #endif
       
   175 	};
       
   176 
       
   177 #endif // SIPPROFILECSSERVER_H