telephonyprotocols/pdplayer/umts/spudfsm/src/cpdpfsmfactory.cpp
branchRCL_3
changeset 65 630d2f34d719
parent 14 7ef16719d8cb
child 66 07a122eea281
child 73 70d75957b98f
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 /**
    18 /**
    19  @file 
    19  @file 
    20  @internalComponent
    20  @internalComponent
    21 */
    21 */
    22  
    22  
       
    23 
       
    24 
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "cpdpfsmfactoryTraces.h"
       
    28 #endif
       
    29 
    23 #include "cpdpfsmfactory.h"
    30 #include "cpdpfsmfactory.h"
    24 #include "spudfsmdebuglogger.h"
       
    25 
    31 
    26 // NewL 
    32 // NewL 
    27 CPdpFsmFactory* CPdpFsmFactory::NewL ()
    33 CPdpFsmFactory* CPdpFsmFactory::NewL ()
    28     {
    34     {
    29 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::NewL()");
    35 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWL_1, ">>CPdpFsmFactory::NewL()");
    30 	
    36 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWL_2, "<<CPdpFsmFactory::NewL()");
    31 	return new (ELeave) CPdpFsmFactory ();	
    37 	return new (ELeave) CPdpFsmFactory ();	
    32     }
    38     }
    33 
    39 
    34 #if defined(__VC32__)
    40 #if defined(__VC32__)
    35 #if (_MSC_VER >= 1200)
    41 #if (_MSC_VER >= 1200)
    62   iStateStopping (this),
    68   iStateStopping (this),
    63   iStateCreatingMbms(this),
    69   iStateCreatingMbms(this),
    64   iStateActivatingMbms(this),
    70   iStateActivatingMbms(this),
    65   iStateCreatedMbms(this)
    71   iStateCreatedMbms(this)
    66     {
    72     {
    67 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::CPdpFsmFactory()");
    73 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CTOR_1, ">>CPdpFsmFactory::CPdpFsmFactory()");
       
    74 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CTOR_2, "<<CPdpFsmFactory::CPdpFsmFactory()");
    68     }
    75     }
    69 
    76 
    70 
    77 
    71 CPdpFsmFactory::~CPdpFsmFactory()
    78 CPdpFsmFactory::~CPdpFsmFactory()
    72     {
    79     {
    73 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::~CPdpFsmFactory()");
    80 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DTOR_1, ">>CPdpFsmFactory::~CPdpFsmFactory()");
    74 
    81 
    75 	iContexts.DeleteAll();
    82 	iContexts.DeleteAll();
    76     iContexts.Reset();
    83     iContexts.Reset();
    77 	
    84 	
    78     delete iEtelDriverInput;   
    85     delete iEtelDriverInput;   
       
    86     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DTOR_2, "<<CPdpFsmFactory::~CPdpFsmFactory()");
    79     }
    87     }
    80 
    88 
    81 
    89 
    82 void CPdpFsmFactory::InitL(const TName& aTsyName, CPdpFsmInterface * aPdpFsmInterface)
    90 void CPdpFsmFactory::InitL(const TName& aTsyName, CPdpFsmInterface * aPdpFsmInterface)
    83     {
    91     {
    84 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::InitL()");
    92 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_INITL_1, ">>CPdpFsmFactory::InitL()");
    85 
    93 
    86 	iPdpFsmInterface = aPdpFsmInterface;
    94 	iPdpFsmInterface = aPdpFsmInterface;
    87 	
    95 	
    88 	iTsyName = aTsyName;
    96 	iTsyName = aTsyName;
    89 
    97 
    90 	// lets kick off the ETelDriver first then we only alloc FSMs if it works
    98 	// lets kick off the ETelDriver first then we only alloc FSMs if it works
    91 	//
    99 	//
    92 	iEtelDriverInput = new (ELeave) REtelDriverInput;
   100 	iEtelDriverInput = new (ELeave) REtelDriverInput;
    93 
   101 
    94 	iEtelDriverInput->OpenL (*iPdpFsmInterface);
   102 	iEtelDriverInput->OpenL (*iPdpFsmInterface);
    95 
   103 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_INITL_2, "<<CPdpFsmFactory::InitL()");
    96 	// Only create PDP contexts if specifically requested.
   104 	// Only create PDP contexts if specifically requested.
    97     }
   105     }
    98 
   106 
    99 
   107 
   100 void CPdpFsmFactory::Close (void)
   108 void CPdpFsmFactory::Close (void)
   101     {
   109     {
   102 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::Close()");
   110 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CLOSE_1, ">>CPdpFsmFactory::Close()");
   103 	// in OOM conditions iEtelDriveInput may not have successfully
   111 	// in OOM conditions iEtelDriveInput may not have successfully
   104 	// been created, check here for safety.
   112 	// been created, check here for safety.
   105 	if (iEtelDriverInput != NULL)
   113 	if (iEtelDriverInput != NULL)
   106 	    {
   114 	    {
   107         iEtelDriverInput->Close();
   115         iEtelDriverInput->Close();
   108 	    }
   116 	    }
       
   117 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_CLOSE_2, "<<CPdpFsmFactory::Close()");
   109     }
   118     }
   110 
   119 
   111 
   120 
   112 /** 
   121 /** 
   113 @return may return NULL if there is no PDP context with that Id
   122 @return may return NULL if there is no PDP context with that Id
   114 */
   123 */
   115 CPdpFsm* CPdpFsmFactory::GetFsmContext (TContextId aPdpId)
   124 CPdpFsm* CPdpFsmFactory::GetFsmContext (TContextId aPdpId)
   116     {
   125     {
   117 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::GetContext()");
   126 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_GETFSMCONTEXT_1, ">>CPdpFsmFactory::GetContext()");
   118 
   127 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_GETFSMCONTEXT_2, "<<CPdpFsmFactory::GetContext()");
   119 	return iContexts[aPdpId];
   128 	return iContexts[aPdpId];
   120     }
   129     }
   121 
   130 
   122 
   131 
   123 const TName& CPdpFsmFactory::TsyName(void)
   132 const TName& CPdpFsmFactory::TsyName(void)
   129 TInt CPdpFsmFactory::NewFsmContext(TContextId aPdpId)
   138 TInt CPdpFsmFactory::NewFsmContext(TContextId aPdpId)
   130 #else
   139 #else
   131 TContextId CPdpFsmFactory::NewFsmContextL(MPdpFsmEventHandler& aPdpFsmEventHandler,SpudMan::TPdpContextType aContextType)
   140 TContextId CPdpFsmFactory::NewFsmContextL(MPdpFsmEventHandler& aPdpFsmEventHandler,SpudMan::TPdpContextType aContextType)
   132 #endif
   141 #endif
   133     {
   142     {
   134 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::NewFsmContext()");
   143 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWFSMCONTEXTL_1, ">>CPdpFsmFactory::NewFsmContext()");
   135 
   144 
   136 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
   145 #ifndef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
   137 	TInt ret = KErrNone;
   146 	TInt ret = KErrNone;
   138 	ASSERT(ContextIdIsValid(aPdpId));
   147 	ASSERT(ContextIdIsValid(aPdpId));
   139     if (!HaveFsmContext(aPdpId))
   148     if (!HaveFsmContext(aPdpId))
   143 	    TRAP(ret,
   152 	    TRAP(ret,
   144 	         CPdpFsm* p = CPdpFsm::NewL(aPdpId, this, iEtelDriverInput);
   153 	         CPdpFsm* p = CPdpFsm::NewL(aPdpId, this, iEtelDriverInput);
   145 	         iContexts[aPdpId] = p;       
   154 	         iContexts[aPdpId] = p;       
   146 	         );
   155 	         );
   147 	    }
   156 	    }
       
   157     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWFSMCONTEXTL_2, "<<CPdpFsmFactory::NewFsmContext()");
   148    return ret;
   158    return ret;
   149 #else
   159 #else
   150 	TInt i=0;
   160 	TInt i=0;
   151     while (i < KMaxPdpContexts && iContexts[i] != NULL)
   161     while (i < KMaxPdpContexts && iContexts[i] != NULL)
   152     	{
   162     	{
   156         {
   166         {
   157         CPdpFsm* p = CPdpFsm::NewL(i, this, iEtelDriverInput, aPdpFsmEventHandler, aContextType);
   167         CPdpFsm* p = CPdpFsm::NewL(i, this, iEtelDriverInput, aPdpFsmEventHandler, aContextType);
   158         iContexts[i] = p;
   168         iContexts[i] = p;
   159         iEtelDriverInput->CreatePdpL(i, aContextType);
   169         iEtelDriverInput->CreatePdpL(i, aContextType);
   160         }
   170         }
   161         return i;
   171     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_NEWFSMCONTEXTL_3, "<<CPdpFsmFactory::NewFsmContext()");
       
   172     return i;
   162 #endif	
   173 #endif	
   163     }
   174     }
   164    
   175    
   165 TInt CPdpFsmFactory::DeleteFsmContext(TContextId aPdpId)
   176 TInt CPdpFsmFactory::DeleteFsmContext(TContextId aPdpId)
   166     {
   177     {
   167 	SPUDFSMVERBOSE_FNLOG("CPdpFsmFactory::DeleteFsmContext()");
   178 	OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DELETEFSMCONTEXT_1, ">>CPdpFsmFactory::DeleteFsmContext()");
   168 	ASSERT(ContextIsValid(aPdpId));
   179 	ASSERT(ContextIsValid(aPdpId));
   169 
   180 
   170     delete iContexts[aPdpId];
   181     delete iContexts[aPdpId];
   171     iContexts[aPdpId] = NULL;
   182     iContexts[aPdpId] = NULL;
   172     
   183     OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CPDPFSMFACTORY_DELETEFSMCONTEXT_2, "<<CPdpFsmFactory::DeleteFsmContext()");
   173 	return KErrNone;
   184 	return KErrNone;
   174     }
   185     }
   175     
   186