messagingfw/alwaysonline/inc/AlwaysOnlineManagerServer.h
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 /*
       
     2 * Copyright (c) 2002 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 *     AlwaysOnline server. Governs always online plugins.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __ALWAYSONLINEMANAGERSERVER_H__
       
    20 #define __ALWAYSONLINEMANAGERSERVER_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <msvapi.h>
       
    24 #include "AlwaysOnlineManagerCommon.h"
       
    25 #include "AlwaysOnlineManager.h"
       
    26 
       
    27 //constants
       
    28 const TInt KAlwaysOnlineMajorVersionNumber = 1;
       
    29 const TInt KAlwaysOnlineMinorVersionNumber = 0;
       
    30 const TInt KAlwaysOnlineVersionNumber = 0;
       
    31 
       
    32 class TOAManagerStartupSignaller;
       
    33 
       
    34 // Server's policy defitions
       
    35 const TUint KAOMServerRangeCount = 6;
       
    36 
       
    37 /* 
       
    38 Available commands from alwaysonlinemanagerclient.h header file.
       
    39 
       
    40 EServerAPIBaseCommand = 0,                  //common command IDs 0 - 999
       
    41 EServerAPIBaseCommandStart,
       
    42 EServerAPIBaseCommandStop,
       
    43 EServerAPIEmailBaseCommand = 1000,          //email specific commands 1000 - 1999
       
    44 EServerAPIEmailTurnOff,                     // 1001 switch off specified mailbox
       
    45 EServerAPIEmailTurnOn,                      // 1002 switch on specified mailbox
       
    46 EServerAPIEmailAgentRemove,                 // 1003 remove specified mailbox
       
    47 EServerAPIEmailEMNReceived,                 // 1004 EMN received for specified mailbox
       
    48 EServerAPIEmailUpdateMailWhileConnected,    // 1005 acts like imap connection except does not reconnect if connection dropped
       
    49 
       
    50 EServerAPIPecBaseCommand = 2000,            //Pec specific commands 2000 - 2999
       
    51 
       
    52 EServerAPIImBaseCommand = 3000              // IM specific commands 3000 - 3999
       
    53 */
       
    54 
       
    55 const TInt KAOMServerRanges[KAOMServerRangeCount] = 
       
    56     {
       
    57     0, //range is 0-2 inclusive (EServerAPIBaseCommand, EServerAPIBaseCommandStart, EServerAPIBaseCommandStop)
       
    58     3, //range is 3-999 inclusive (Common commands not yet defined --> Unsupported)
       
    59     1000, //range is 1000-1005 inclusive (Email plugin commands)
       
    60     2000, //range is 2000-2999 inclusive (Pec plugin commands)
       
    61     3000, //range is 3000-3999 inclusive (IM plugin commands)
       
    62     4000, //range is 4000-KMaxTInt inclusive
       
    63     };
       
    64 
       
    65 const TUint8 KAOMServerElementsIndex[KAOMServerRangeCount] = 
       
    66     {
       
    67     0,                              //applies to 0th range (req num: 0-2)
       
    68     CPolicyServer::ENotSupported,   //applies to 1st range (req num: 3-999)
       
    69     0,                              //applies to 2nd range (req num: 1000-1999)
       
    70     0,                              //applies to 2nd range (req num: 2000-2999)
       
    71     0,                              //applies to 2nd range (req num: 3000-3999)
       
    72     CPolicyServer::ENotSupported,   //applies to 4th range (req num: 4000-KMaxTInt)
       
    73     };
       
    74 const CPolicyServer::TPolicyElement KAOMServerElements[] = 
       
    75     {
       
    76     {_INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), CPolicyServer::EFailClient} //policy "0"; fail call if WriteDeviceData not present
       
    77     };
       
    78     
       
    79 const CPolicyServer::TPolicy KAOMServerPolicy =
       
    80     {
       
    81     CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
       
    82     KAOMServerRangeCount,           
       
    83     KAOMServerRanges,
       
    84     KAOMServerElementsIndex,
       
    85     KAOMServerElements,
       
    86     };
       
    87 
       
    88 
       
    89 /**
       
    90 * CAlwaysOnlineManagerServer
       
    91 * 
       
    92 * Always online server class. Server which is started at bootup and will stay running forever
       
    93 * in the background. Server controls "always online clients" ( ECom plugins )
       
    94 * which contain the actual implementation of always online functionality. 
       
    95 * Server's task is just to start things up and send messages to plugins allowing
       
    96 * or restricting online operation. 
       
    97 */
       
    98 class CAlwaysOnlineManagerServer : public CPolicyServer
       
    99     {
       
   100 public:
       
   101 	enum {EAlwaysOnlineManagerServerPriority=EPriorityBackground};
       
   102 
       
   103 public:										
       
   104 ///////////////////////////////////////////////////////////////////////////////////////
       
   105 
       
   106 	/**
       
   107 	 * Start the server, returning an error if one occurs
       
   108 	 */
       
   109 	static TInt RunServer(TOAManagerStartupSignaller& aSignaller);
       
   110 
       
   111 	/**
       
   112 	 * Start the server, leaving if there's an error
       
   113 	 */
       
   114 	static void	RunServerL(TOAManagerStartupSignaller& aSignaller);
       
   115 
       
   116 //#if defined (__WINS__)
       
   117 
       
   118 	/**
       
   119 	 * In WINS, the EPOCEXE target is a DLL with an entry point called WinsMain,
       
   120 	 * taking no parameters and returning TInt. This is not really valid as a thread
       
   121 	 * function which takes a TAny* parameter which we need.
       
   122 	 * 
       
   123 	 * So the DLL entry-point WinsMain() is used to return a TInt representing the
       
   124 	 * real thread function within the DLL. This is good as long as
       
   125 	 * sizeof(TInt)>=sizeof(TThreadFunction).
       
   126 	 * 
       
   127 	 */
       
   128 	static TInt ServerThreadFunction(TAny* aParameters);
       
   129 
       
   130 //#endif
       
   131     /*
       
   132     * PanicServer
       
   133     */
       
   134 	static void PanicServer(TAlwaysOnlineManagerPanic aPanic);
       
   135 
       
   136     /*
       
   137     * ThreadFunction
       
   138     */
       
   139 	IMPORT_C static TInt ThreadFunction(TAny* aStarted);
       
   140 	
       
   141     /*
       
   142     * NewL constructor
       
   143     */
       
   144 	IMPORT_C static CAlwaysOnlineManagerServer* NewL();
       
   145 
       
   146     /*
       
   147     * ConstructL 
       
   148     */
       
   149 	void ConstructL();
       
   150 
       
   151     /*
       
   152     * ~CAlwaysOnlineManagerServer, destructor
       
   153     */
       
   154 	~CAlwaysOnlineManagerServer();
       
   155 	
       
   156     /**
       
   157     * HandleClientCommandL
       
   158     */
       
   159     IMPORT_C void HandleClientCommandL( TAlwaysOnlineServerAPICommands aCommand, 
       
   160     									TDes8& aParameter );
       
   161 
       
   162 	/*
       
   163     * NewSessionL
       
   164     */
       
   165 	virtual CSession2* NewSessionL( const TVersion& aVersion, 
       
   166                                     const RMessage2& aMessage ) const;
       
   167 
       
   168 
       
   169 private:
       
   170     /*
       
   171     * CAlwaysOnlineManagerServer, c++ constructor
       
   172     */
       
   173 	CAlwaysOnlineManagerServer( TInt aPriority );
       
   174 
       
   175 
       
   176 	//data
       
   177 private:
       
   178     CAlwaysOnlineManager* iManager;
       
   179 
       
   180     };
       
   181 
       
   182 
       
   183 #endif
       
   184 //EOF