telephonyprotocols/umtsgprsscpr/spudtel/src/reteldriverinput.cpp
changeset 64 b34bb05ac869
parent 56 ab72d5c1d770
equal deleted inserted replaced
56:ab72d5c1d770 64:b34bb05ac869
     1 // Copyright (c) 2004-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 // Description:
       
    14 // implementation of etel driver input
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file 
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <e32def.h>
       
    24 #include <e32std.h>
       
    25 
       
    26 #include "ceteldriverfactory.h"
       
    27 #include "ceteldrivercontext.h"
       
    28 #include "reteldriverinput.h"
       
    29 #include "spudteldebuglogger.h"
       
    30 
       
    31 using namespace EtelDriver;
       
    32 
       
    33 REtelDriverInput::REtelDriverInput()
       
    34 : iDriverFactory(NULL)
       
    35 	{
       
    36 	}
       
    37 
       
    38 
       
    39 REtelDriverInput::~REtelDriverInput()
       
    40 	{
       
    41 	SPUDTEL_FNLOG("REtelDriverInput::~REtelDriverInput()");
       
    42 	
       
    43 	if (iDriverFactory)
       
    44 	   {
       
    45 	   delete iDriverFactory;
       
    46 	   }	  
       
    47 	}
       
    48 
       
    49 
       
    50 /** requests to open etel driver
       
    51 
       
    52 @param aPdpFsmInterface - reference to pdp FSM interface
       
    53 */
       
    54 void REtelDriverInput::OpenL (CPdpFsmInterface& aPdpFsmInterface)
       
    55 	{
       
    56 	SPUDTEL_FNLOG("REtelDriverInput::OpenL()");
       
    57 	ASSERT(iDriverFactory==NULL);
       
    58 
       
    59 	// internal check
       
    60 	iDriverFactory = CEtelDriverFactory::NewL(aPdpFsmInterface);
       
    61 	if (iDriverFactory)
       
    62 		{
       
    63 		iDriverFactory->InitL();
       
    64 		}
       
    65 	}
       
    66 
       
    67 
       
    68 /** closes eTel driver and frees underlying resources
       
    69 */
       
    70 void REtelDriverInput::Close()
       
    71 	{
       
    72 	SPUDTEL_FNLOG("REtelDriverInput::Close()");
       
    73 	
       
    74 	// cancel all outstanding requests
       
    75 	if (iDriverFactory)
       
    76 		{
       
    77 		CancelAllPdps();
       
    78 		}
       
    79 
       
    80 	delete iDriverFactory;
       
    81 	iDriverFactory = NULL;
       
    82 	}
       
    83 	
       
    84 /** requests to create new pdp context
       
    85 	Note: this request will not open new primary or secondary context
       
    86 		  But rather allocate necessary resources to do it.
       
    87 		  Creation / deletion of eTel contexts should be done though Input method.
       
    88 
       
    89 @param aPdpId - id of new pdp context
       
    90 */
       
    91 void REtelDriverInput::CreatePdpL (TContextId aPdpId)
       
    92 	{
       
    93 	SPUDTEL_FNLOG("REtelDriverInput::CreatePdpL()");
       
    94 	SPUDTELVERBOSE_INFO_LOG1(_L("pdp id : %d"), aPdpId);
       
    95 	
       
    96 	ASSERT(iDriverFactory);
       
    97 	iDriverFactory->CreatePdpL (aPdpId);
       
    98 	}
       
    99 	
       
   100 /** deletes pdp context
       
   101 
       
   102 @param aPdpId - id of a pdp context
       
   103 */
       
   104 void REtelDriverInput::DeletePdp (TContextId aPdpId)
       
   105 	{
       
   106 	SPUDTEL_FNLOG("REtelDriverInput::DeletePdp()");
       
   107 	SPUDTELVERBOSE_INFO_LOG1(_L("pdp id : %d"), aPdpId);
       
   108 	
       
   109 	ASSERT(iDriverFactory);
       
   110 
       
   111 	iDriverFactory->FreePdp(aPdpId);
       
   112 	}
       
   113 
       
   114 /** requests to perform aOperation for aPdpId context
       
   115 
       
   116 @param aPdpId - id of a pdp context
       
   117 @param aOperation - etel driver operation
       
   118 */
       
   119 void REtelDriverInput::Input(TContextId aPdpId, TEtelInput aOperation)
       
   120 	{
       
   121 	SPUDTEL_FNLOG("REtelDriverInput::Input()");
       
   122 	SPUDTEL_INFO_LOG2(_L("REtelDriverInput::Input: pdp id : %d, operation %d"), aPdpId, aOperation);
       
   123 	ASSERT(iDriverFactory);
       
   124 	
       
   125 	iDriverFactory->Context(aPdpId).Input(aOperation);
       
   126 	}
       
   127 
       
   128 /** cancels last operation for aPdpId context 
       
   129 
       
   130 @param aPdpId - id of a pdp context
       
   131 */
       
   132 void REtelDriverInput::CancelPdp (TContextId aPdpId)
       
   133 	{
       
   134 	SPUDTEL_FNLOG("REtelDriverInput::CancelPdp()");
       
   135 	SPUDTEL_INFO_LOG1(_L("REtelDriverInput::CancelPdp: pdp id : %d"), aPdpId);
       
   136 	ASSERT(iDriverFactory);
       
   137 	
       
   138 	iDriverFactory->Context(aPdpId).Cancel();
       
   139 	}
       
   140 	
       
   141 /** starts network notifications for aPdpId context 
       
   142 
       
   143 @param aPdpId - id of a pdp context
       
   144 */
       
   145 void REtelDriverInput::StartPdpNotifications(TContextId aPdpId)
       
   146 	{
       
   147 	SPUDTEL_FNLOG("REtelDriverInput::StartPdpNotifications()");
       
   148 	ASSERT(iDriverFactory);
       
   149 
       
   150 	iDriverFactory->StartPdpNotifications(aPdpId);
       
   151 	}
       
   152 	
       
   153 /** cancels network notifications for aPdpId context 
       
   154 
       
   155 @param aPdpId - id of a pdp context
       
   156 */
       
   157 void REtelDriverInput::CancelPdpNotifications (TContextId aPdpId)
       
   158 	{
       
   159 	SPUDTEL_FNLOG("REtelDriverInput::CancelPdpNotifications()");
       
   160 	SPUDTEL_INFO_LOG1(_L("REtelDriverInput::CancelPdpNotifications: pdp id : %d"), aPdpId);
       
   161 	ASSERT(iDriverFactory);
       
   162 
       
   163 	iDriverFactory->CancelPdpNotifications (aPdpId);
       
   164 	}
       
   165 	
       
   166 /** cancels last operations for all created pdp contexts */
       
   167 void REtelDriverInput::CancelAllPdps ()
       
   168 	{
       
   169 	SPUDTEL_FNLOG("REtelDriverInput::CancelAllPdps()");
       
   170 	ASSERT(iDriverFactory);
       
   171 	
       
   172 	for(TContextId i = 0; i < static_cast<TContextId>(iDriverFactory->ContextCount()); i++)
       
   173 		{
       
   174 		if (iDriverFactory->HasContext(i))
       
   175 		    {
       
   176     		iDriverFactory->Context(i).Cancel();
       
   177 		    }
       
   178 		}
       
   179 	}
       
   180 
       
   181 /** cancels all notifications for all pdp contexts */
       
   182 void REtelDriverInput::CancelAllPdpNotifications ()
       
   183 	{
       
   184 	SPUDTEL_FNLOG("REtelDriverInput::CancelAllPdpNotifications()");
       
   185 	ASSERT(iDriverFactory);
       
   186 
       
   187 	iDriverFactory->CancelAllPdpNotifications();
       
   188 	}
       
   189 
       
   190 void REtelDriverInput::GetLastErrorCause (TContextId aPdpId, TInt& aLastErrorCause)
       
   191 	{
       
   192 	SPUDTEL_FNLOG("REtelDriverInput::GetLastErrorCause()");
       
   193 	ASSERT(iDriverFactory);
       
   194 
       
   195 	iDriverFactory->GetLastErrorCause(aPdpId, aLastErrorCause);
       
   196 	}