javacommons/utils/functionserver/inc.s60/os_functionserver.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef OS_FUNCTIONSERVER_H
       
    20 #define OS_FUNCTIONSERVER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <string>
       
    24 
       
    25 #include "javaosheaders.h"
       
    26 
       
    27 namespace java
       
    28 {
       
    29 namespace util
       
    30 {
       
    31 
       
    32 class FunctionServer;
       
    33 
       
    34 NONSHARABLE_CLASS(ServerShutdown) : public CActive
       
    35 {
       
    36 public:
       
    37     ServerShutdown();
       
    38     void startShutDown();
       
    39 
       
    40 protected:
       
    41     virtual void RunL();
       
    42     virtual TInt RunError(TInt error);
       
    43     virtual void DoCancel();
       
    44 
       
    45 };
       
    46 
       
    47 
       
    48 /**
       
    49  *
       
    50  */
       
    51 NONSHARABLE_CLASS(OsFunctionServer) : public CServer2
       
    52 {
       
    53 // Data types
       
    54 public:
       
    55     enum TAction
       
    56     {
       
    57         EExecute = 0,
       
    58         EStop
       
    59     };
       
    60 
       
    61 private:
       
    62     class CFunctionSession;
       
    63 // Methods
       
    64 public:
       
    65     ~OsFunctionServer();
       
    66 
       
    67     OsFunctionServer();
       
    68     inline void osThreadInit();
       
    69     inline void osThreadClean();
       
    70     void startOsServer();
       
    71 
       
    72     void startShutDown();
       
    73     void stopServerInsideServerThread();
       
    74 
       
    75 // From CServer2
       
    76 protected:
       
    77     TInt RunError(TInt aError);
       
    78 
       
    79 private:
       
    80     CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
    81 
       
    82     CTrapCleanup* mCleanUp;
       
    83 
       
    84     ServerShutdown mShutdown;
       
    85 };
       
    86 
       
    87 
       
    88 NONSHARABLE_CLASS(OsFunctionServer::CFunctionSession)
       
    89         : public CSession2
       
    90 {
       
    91 public:
       
    92     inline CFunctionSession();
       
    93 
       
    94 private:
       
    95     TInt doServiceL(TAction aAction, const TAny* aParam);
       
    96 
       
    97 // From CSession2
       
    98 public:
       
    99     void ServiceL(const RMessage2& aMessage);
       
   100 
       
   101 };
       
   102 
       
   103 
       
   104 /**
       
   105  *
       
   106  */
       
   107 inline void OsFunctionServer::osThreadInit()
       
   108 {
       
   109     mCleanUp = CTrapCleanup::New();
       
   110 }
       
   111 
       
   112 /**
       
   113  *
       
   114  */
       
   115 inline void OsFunctionServer::osThreadClean()
       
   116 {
       
   117     delete mCleanUp;
       
   118     mCleanUp = 0;
       
   119 }
       
   120 
       
   121 } //end namespace util
       
   122 } //end namespace java
       
   123 #endif // OS_FUNCTIONSERVER_H
       
   124