telephonyserverplugins/licenseetsystub/licensee_tsy_stub/src/cmmmessagerouter.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 
       
    14 //  INCLUDE FILES
       
    15 #include "cmmmessagerouter.h"
       
    16 #include "mmmmesshandlerbase.h"
       
    17 #include "SatMessaging.h"       // SAT messaging inerface
       
    18 #include <ctsy/rmmcustomapi.h>
       
    19 #include <pcktcs.h>             // for packet data IPCs
       
    20 
       
    21 // ======== MEMBER FUNCTIONS ========
       
    22 
       
    23 CMmMessageRouter::CMmMessageRouter()
       
    24     : iMmMockMessHandler( NULL ),
       
    25     iMessageManager( NULL ),
       
    26     iSatService( NULL )    
       
    27     {
       
    28     }
       
    29 
       
    30 void CMmMessageRouter::ConstructL()
       
    31     {
       
    32     InitL();
       
    33     InitModulesL(); 
       
    34     }
       
    35 
       
    36 CMmMessageRouter* CMmMessageRouter::NewL()
       
    37     {
       
    38     CMmMessageRouter* self = new( ELeave ) CMmMessageRouter();
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();   
       
    41     CleanupStack::Pop();
       
    42     return self;
       
    43     }
       
    44 
       
    45 CMmMessageRouter::~CMmMessageRouter()
       
    46     {
       
    47     delete iMmMockMessHandler;
       
    48     iMmMockMessHandler = NULL;
       
    49     iSatService = NULL;
       
    50      
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CMmMessageRouter::InitL
       
    55 // First initialization phase
       
    56 // (other items were commented in a header).
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CMmMessageRouter::InitL()
       
    60     {
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CMmMessageRouter::InitModulesL
       
    65 // Second initialization phase
       
    66 // (other items were commented in a header).
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void CMmMessageRouter::InitModulesL()
       
    70     {
       
    71     // only one commmon message handler, minimum functionality   
       
    72     iMmMockMessHandler = CMmMockMessHandler::NewL( this );
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CMmMessageRouter::RouteRequest
       
    77 // Returns pointer to the message handler for this request,based on IPC number
       
    78 // (other items were commented in a header).
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 MMmMessHandlerBase* CMmMessageRouter::RouteRequest(    
       
    82     const TInt /*aIpc*/ ) 
       
    83     {
       
    84     MMmMessHandlerBase* messHandler = NULL;
       
    85     messHandler = iMmMockMessHandler;
       
    86     
       
    87     return messHandler;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CMmMessageRouter::MessageManager
       
    92 // Returns pointer to the MessageManager
       
    93 // (other items were commented in a header).
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 MmMessageManagerCallback* CMmMessageRouter::MessageManager()
       
    97     {
       
    98     return iMessageManager;
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // CMmMessageRouter::GetMessageRouter
       
   103 // Returns pointer to the message router object.
       
   104 // (other items were commented in a header).
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 MMessageRouter* CMmMessageRouter::GetMessageRouter( 
       
   108     MmMessageManagerCallback &aMessageManager )
       
   109     {    
       
   110     iMessageManager = &aMessageManager; 
       
   111     return this;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CMmMessageRouter::GetSatMessagingService
       
   116 // Create and return pointer to the message router object.
       
   117 // (other items were commented in a header).
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 CTsySatMessagingBase* CMmMessageRouter::GetSatMessagingService()
       
   121     {    
       
   122     CTsySatMessaging* satService =  NULL; 
       
   123         
       
   124     // check has the SIM ATK TSY STUB already initialized
       
   125     if ( !iSatService )
       
   126         {
       
   127         // create instanse of the SIM ATK TSY STUB
       
   128         TRAPD( error, satService = CTsySatMessaging::NewL( this ) );
       
   129             
       
   130         if ( error != KErrNone )
       
   131             {
       
   132             iSatService = NULL;
       
   133             } 
       
   134         else
       
   135             {
       
   136             iSatService = static_cast<CTsySatMessagingBase*>( satService );
       
   137             }
       
   138         }
       
   139         
       
   140     // NOTE: client (ETEL) will handle the destruction of created object
       
   141     return iSatService; 
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // CMmMessageRouter::GetSatMessagingService
       
   146 // Create and return pointer to the message router object.
       
   147 // (other items were commented in a header).
       
   148 // ---------------------------------------------------------------------------
       
   149 //
       
   150 CTsySatMessagingBase* CMmMessageRouter::GetSatMessagingService(MCtsySatService & /*aSatMessagingService*/)
       
   151 	{
       
   152 		// No need to use MCtsySatService argument since the stub won't call it.
       
   153 		return GetSatMessagingService();
       
   154 	}
       
   155     
       
   156 // ---------------------------------------------------------------------------
       
   157 // CMmMessageRouter::Version
       
   158 // Returns the version of the interface
       
   159 // (other items were commented in a header).
       
   160 // ---------------------------------------------------------------------------
       
   161 //
       
   162 MLtsyFactoryBase::TCtsyInterfaceVersion CMmMessageRouter::Version()
       
   163     {
       
   164     // currently support for version 1 only
       
   165     return MLtsyFactoryBase::EIfVersion1;
       
   166     }
       
   167     
       
   168 // ---------------------------------------------------------------------------
       
   169 // CMmMessageRouter::ExtFuncL
       
   170 // Directs requests to messhandler
       
   171 // (other items were commented in a header).
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 TInt CMmMessageRouter::ExtFuncL( 
       
   175     TInt aIpc,
       
   176     const CMmDataPackage* aDataPackage )    
       
   177     {
       
   178     TInt ret( KErrNone );
       
   179     
       
   180     //check if the IPC is supported
       
   181     MMmMessHandlerBase* messageHandler = RouteRequest( aIpc );
       
   182    
       
   183     if ( NULL == messageHandler )
       
   184         {
       
   185         ret = KErrNotSupported;
       
   186         }
       
   187     else
       
   188         {
       
   189         // call to DOS layer
       
   190         ret = messageHandler->ExtFuncL( aIpc, aDataPackage ); 
       
   191         }
       
   192         
       
   193     return ret;
       
   194     }
       
   195     
       
   196 // ---------------------------------------------------------------------------
       
   197 // CMmMessageRouter::Release
       
   198 // Release the created LTSY objects
       
   199 // (other items were commented in a header).
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 void CMmMessageRouter::Release() 
       
   203     { 
       
   204     // call destructor
       
   205     delete this; 
       
   206     } 
       
   207 
       
   208 // ======== EXPORTED FUNCTIONS ========
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // MLtsyFactoryBase* LTsyFactoryL
       
   212 // Libraty entry function
       
   213 // (other items were commented in a header).
       
   214 // ---------------------------------------------------------------------------
       
   215 //
       
   216 EXPORT_C MLtsyFactoryBase* LTsyFactoryL()
       
   217     {
       
   218     // create new instance of the message router object and return it
       
   219     CMmMessageRouter* router = NULL;
       
   220     router = CMmMessageRouter::NewL();
       
   221     return router;
       
   222     }        
       
   223         
       
   224 //  End of File