telephonyserverplugins/multimodetsy/Multimode/gprs/Gprs.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 64 b34bb05ac869
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2001-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 // This file implements the CGprs class. Used to implement the RPacketService API.
       
    15 // This file also implements the CGprsContextEntry class used to store a pointer to a CGprsContext object.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #include "Gprscontext.h"
       
    24 #include "mSLOGGER.H"
       
    25 #include "NOTIFY.H"
       
    26 #include "ATGprsAttach.H"
       
    27 #include "ATGprsDetach.H"
       
    28 #include "AtGprsClass.h"
       
    29 #include "atgprsntwkregstatus.h"					// for CATGprsNtwkRegStatus
       
    30 #include "atgprsntwkregstatuschange.h"		// for CATGprsNtwkRegStatusChange
       
    31 #include "ATIO.H"
       
    32 #include "ATHANGUP.H"
       
    33 
       
    34 
       
    35 CGprs* CGprs::NewL(CATIO* aIo, CATInit* aInit, CPhoneGlobals* aPhoneGlobals)
       
    36 /**
       
    37  * Standard 2 phase constructor.
       
    38  *
       
    39  * @param aIo pointer to communication object.
       
    40  * @param aInit pointer to AT phone init object.
       
    41  * @param aPhoneGlobals pointer to phone global wide states.
       
    42  */
       
    43     {
       
    44     CGprs* gprs=new(ELeave) CGprs(aIo, aInit, aPhoneGlobals);
       
    45     CleanupStack::PushL(gprs);
       
    46     gprs->ConstructL();
       
    47     CleanupStack::Pop();
       
    48     return gprs;
       
    49     }
       
    50 
       
    51 
       
    52 CGprs::CGprs(CATIO* aIo, CATInit*   aInit, CPhoneGlobals* aPhoneGlobals) 
       
    53         : CSubSessionExtBase(), iIo(aIo), iInit(aInit), iPhoneGlobals(aPhoneGlobals)
       
    54 /**
       
    55  * Constructor
       
    56  *
       
    57  * @param aIo pointer to communication object.
       
    58  * @param aInit pointer to AT phone init object.
       
    59  * @param aPhoneGlobals pointer to phone global wide states.
       
    60  */
       
    61     {
       
    62     LOGTEXT(_L8("CGprs: Entered constructor"));
       
    63     }    
       
    64 
       
    65 
       
    66 void CGprs::ConstructL()
       
    67 /**
       
    68  * Construct all objects that can leave.
       
    69  */
       
    70     {
       
    71     LOGTEXT(_L8("CGprs: ConstructL"));
       
    72     iContexts.SetOffset(_FOFF(CGprsContextEntry,iLink));
       
    73     iATGPRSAttach       = CATGprsAttach::NewL(iIo, this, iInit, iPhoneGlobals); 
       
    74     iATGprsDetach       = CATGprsDetach::NewL(iIo, this, iInit, iPhoneGlobals); 
       
    75     iATGprsClass        = CATGprsClass::NewL(iIo, this, iInit, iPhoneGlobals);
       
    76     iATGprsNtwkRegStatusChange= CATGprsNtwkRegStatusChange::NewL(iIo,this,iPhoneGlobals);
       
    77     iATGprsNtwkRegStatus= CATGprsNtwkRegStatus::NewL(iIo, this, iInit, iPhoneGlobals,iATGprsNtwkRegStatusChange);
       
    78    	iMutex.CreateGlobal(KNullDesC, EOwnerProcess);
       
    79     }
       
    80     
       
    81 RHandleBase* CGprs::GlobalKernelObjectHandle()
       
    82 /**
       
    83 * Implements CSubSessionExtBase virtual method, which provides
       
    84 * handle of the mutex object to etel server that passes it up to clients.
       
    85 * @return pointer to synchronisation mutex object
       
    86 */
       
    87 	{
       
    88 		return &iMutex;
       
    89 	}
       
    90 
       
    91 
       
    92 CGprs::~CGprs()
       
    93 /**
       
    94  * Destructor
       
    95  */
       
    96     {
       
    97     LOGTEXT(_L8("CGprs: Entered destructor"));
       
    98 	iMutex.Close();
       
    99     iPhoneGlobals->iNotificationStore->RemoveClientFromLastEvents(this);
       
   100     CGprsContextEntry* contextEntry;
       
   101     TDblQueIter<CGprsContextEntry> iter(iContexts);
       
   102     while (contextEntry=iter++, contextEntry)
       
   103         {
       
   104         contextEntry->Deque();
       
   105         contextEntry->iContext->Close();
       
   106         delete contextEntry;
       
   107         __ASSERT_ALWAYS(iContexts.IsEmpty(),Panic(EPacketContextsRemaining));
       
   108         }
       
   109 
       
   110 		delete iATGprsNtwkRegStatusChange;
       
   111 		delete iATGprsNtwkRegStatus;
       
   112     delete iATGprsClass;
       
   113     delete iATGprsDetach; 
       
   114 		delete iATGPRSAttach;
       
   115     }
       
   116 
       
   117 
       
   118 void CGprs::Init()
       
   119 /**
       
   120  * This function does nothing.
       
   121  */
       
   122     {
       
   123     LOGTEXT(_L8("CGprs: init()"));
       
   124     }
       
   125 
       
   126 
       
   127 CTelObject* CGprs::OpenNewObjectByNameL(const TDesC& /*aName*/)
       
   128 /**
       
   129  * This functionality does not have to be supported as it is
       
   130  * not requitred by the Etel Packet API (etelpckt).
       
   131  */
       
   132     {  
       
   133     LOGTEXT(_L8("CGprs::OpenNewObjectByNameL Leaving with KErrNotFound as this is not supported"));
       
   134 
       
   135     User::Leave(KErrNotFound);		// Have to leave otherwise etel will think we have returned a
       
   136 		                              // valid CTelObject and will cause an access violation.
       
   137 
       
   138 		return NULL;
       
   139     }
       
   140 
       
   141 
       
   142 CTelObject* CGprs::OpenNewObjectL(TDes& aNewName)
       
   143 /**
       
   144  * This function returns a pointer to a new context object.
       
   145  *
       
   146  * @param  aNewName name of the new context.
       
   147  */
       
   148     {
       
   149     TInt cid = 0;
       
   150     GenerateNewContextNameAndCid(aNewName, cid);
       
   151     if(cid > MaxNumberOfContexts())
       
   152         User::Leave(KErrOverflow);
       
   153 #if defined __LOGDEB__ 
       
   154     TBuf8<40> tmpLog;
       
   155     tmpLog.Copy(aNewName);
       
   156     LOGTEXT2(_L8("CGprs::OpenNewObjectL(), %S"), &tmpLog);
       
   157 #endif
       
   158     RPacketContext::TContextConfigGPRS contextConfigV01;
       
   159     ContextConfigGPRS(&contextConfigV01);
       
   160     CGprsContext* context = CGprsContext::NewL(this, iIo, iInit, iPhoneGlobals, aNewName,  cid, &contextConfigV01);
       
   161 	CleanupStack::PushL(context);
       
   162     AppendNewContextL(context);
       
   163 	CleanupStack::Pop(context);
       
   164     iPhoneGlobals->iNotificationStore->CheckNotification(this, EPacketContextAddedChanged);
       
   165     return context;
       
   166     } 
       
   167 
       
   168 
       
   169 CTelObject::TReqMode CGprs::ReqModeL(const TInt aIpc)
       
   170 /**
       
   171  * This function is called from the framework and checks the flow control for a IPC call.
       
   172  * @param aIpc IPC call from client.
       
   173  */
       
   174 	{
       
   175 	CTelObject::TReqMode ret=0;
       
   176 	switch (aIpc)
       
   177 		{
       
   178 		case EPacketAttach:
       
   179 		case EPacketDetach:
       
   180 		case EPacketSetMSClass:
       
   181 			ret = KReqModeFlowControlObeyed;
       
   182 			break;
       
   183 		case EPacketGetNtwkRegStatus:
       
   184 			if (!iPhoneGlobals->iPhoneStatus.iDataPortLoaned)
       
   185 				{
       
   186 				ret = KReqModeFlowControlObeyed;
       
   187 				}
       
   188 			break;
       
   189 		case EPacketGetMSClass:
       
   190 		case EPacketGetDynamicCaps:
       
   191 		case EPacketGetDefaultContextParams:
       
   192 		case EPacketGetStatus:
       
   193 		case EPacketEnumerateContexts:
       
   194 		case EPacketGetContextInfo:
       
   195 		case EPacketGetAttachMode:
       
   196 		case EPacketGetStaticCaps: 
       
   197 		case EPacketSetDefaultContextParams:
       
   198 		case EPacketRejectActivationRequest:
       
   199 		case EPacketSetAttachMode:
       
   200 			break;
       
   201 		case EPacketNotifyContextAdded:
       
   202 		case EPacketNotifyStatusChange:
       
   203 		case EPacketNotifyChangeOfNtwkRegStatus:	
       
   204 			ret=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately;
       
   205 			break; 
       
   206 		default:
       
   207 			User::Leave(KErrNotSupported);
       
   208 			break;
       
   209 		}
       
   210 
       
   211 	// Check if the data port is currently loaned. If it is and the requested IPC
       
   212 	// is flow controlled then block Etel calling the IPC by leaving with KErrInUse
       
   213 	if((ret&KReqModeFlowControlObeyed) && iPhoneGlobals->iPhoneStatus.iDataPortLoaned)
       
   214 		{
       
   215 		LOGTEXT2(_L8("ReqModeL Leaving with KErrInUse as data port is loaned (aIpc=%d)"),aIpc);
       
   216 		User::Leave(KErrInUse);
       
   217 		}
       
   218 
       
   219     return ret;
       
   220     }
       
   221 
       
   222 TInt CGprs::RegisterNotification(const TInt aIpc)
       
   223 /**
       
   224  * This function is called from the framework.
       
   225  * @param  aIpc IPC call from client.
       
   226  */
       
   227     {
       
   228 	LOGTEXT2(_L8("CGprs::RegisterNotification called with aIpc=%d"),aIpc);
       
   229     switch (aIpc)
       
   230         {
       
   231         case EPacketNotifyContextAdded:
       
   232         case EPacketNotifyStatusChange:
       
   233         case EPacketNotifyContextActivationRequested:
       
   234         case EPacketNotifyChangeOfNtwkRegStatus:
       
   235         case EPacketNotifyMSClassChange:
       
   236         case EPacketNotifyDynamicCapsChange:
       
   237             return KErrNone;
       
   238         default:
       
   239             // Unknown or invalid IPC
       
   240             LOGTEXT2(_L8("CGprs::RegisterNotification Error Unknown IPC, aIpc=%d"),aIpc);
       
   241             return KErrNotSupported;
       
   242         }
       
   243     }
       
   244 
       
   245 
       
   246 TInt CGprs::DeregisterNotification(const TInt aIpc)
       
   247 /**
       
   248  * This function is called when there is no client listening to a notification anymore.
       
   249  * @param aIpc IPC call from client.
       
   250  */
       
   251     {
       
   252 	LOGTEXT2(_L8("CGprs::DeregisterNotification called with aIpc=%d"),aIpc);
       
   253     switch (aIpc)
       
   254         {
       
   255         case EPacketNotifyContextAdded:
       
   256         case EPacketNotifyStatusChange:
       
   257         case EPacketNotifyContextActivationRequested:
       
   258         case EPacketNotifyChangeOfNtwkRegStatus:
       
   259         case EPacketNotifyMSClassChange:
       
   260         case EPacketNotifyDynamicCapsChange:
       
   261             return KErrNone;
       
   262         default:
       
   263             // Unknown or invalid IPC
       
   264             LOGTEXT2(_L8("CGprs::DeregisterNotification Error Unknown IPC, aIpc=%d"),aIpc);
       
   265             return KErrNotSupported;
       
   266         }
       
   267     }
       
   268 
       
   269 
       
   270 TInt CGprs::NumberOfSlotsL(const TInt aIpc)
       
   271 /**
       
   272  * This function is called from the framework and checks the number of slots for a notification.
       
   273  * @param aIpc IPC call from client.
       
   274  */
       
   275     {
       
   276     TInt numberOfSlots=0;
       
   277     switch (aIpc)
       
   278         {
       
   279         case EPacketNotifyStatusChange:
       
   280         case EPacketNotifyDynamicCapsChange:
       
   281             LOGTEXT(_L8("CGprs: Registered with 10 slot"));
       
   282             numberOfSlots=10;
       
   283             break;
       
   284         case EPacketNotifyContextAdded:
       
   285         case EPacketNotifyContextActivationRequested:
       
   286         case EPacketNotifyChangeOfNtwkRegStatus:
       
   287         case EPacketNotifyMSClassChange:
       
   288             LOGTEXT(_L8("CGprs: Registered with 2 slot"));
       
   289             numberOfSlots=2;
       
   290             break;
       
   291         default:
       
   292             // Unknown or invalid IPC
       
   293             LOGTEXT2(_L8("CGprs: Number of Slots error, unknown IPC:%d"),aIpc);
       
   294             User::Leave(KErrNotSupported);
       
   295             break;
       
   296         }  
       
   297     return numberOfSlots;
       
   298     }
       
   299 
       
   300 
       
   301 TInt CGprs::ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc,const TDataPackage& aPackage)
       
   302 /**
       
   303  * This function is called from the framework.
       
   304  * @param aTsyReqHandle handle to client.
       
   305  * @param aIpc IPC call from client.
       
   306  * @param aPackage agruments with the IPC call.
       
   307  */
       
   308     {
       
   309     TAny* dataPtr=aPackage.Ptr1();
       
   310     TAny* dataPtr2=aPackage.Ptr2();
       
   311     switch (aIpc)
       
   312         {
       
   313         case EPacketNotifyContextAdded:
       
   314             return NotifyContextAdded(aTsyReqHandle, aPackage.Des1u());
       
   315         case EPacketGetStatus:
       
   316             return GetStatus(aTsyReqHandle,
       
   317             REINTERPRET_CAST(RPacketService::TStatus*, dataPtr));
       
   318         case EPacketNotifyStatusChange:
       
   319             return NotifyStatusChange(aTsyReqHandle,
       
   320             REINTERPRET_CAST(RPacketService::TStatus*, dataPtr));
       
   321         case EPacketNotifyContextActivationRequested:
       
   322             return NotifyContextActivationRequested(aTsyReqHandle,
       
   323 			REINTERPRET_CAST(RPacketContext::TProtocolType*, dataPtr));
       
   324         case EPacketEnumerateContexts:
       
   325             return EnumerateContexts(aTsyReqHandle,
       
   326             REINTERPRET_CAST(TInt*, dataPtr),
       
   327             REINTERPRET_CAST(TInt*, dataPtr2));
       
   328         case EPacketGetContextInfo:
       
   329             return GetContextInfo(aTsyReqHandle,
       
   330             *REINTERPRET_CAST(TInt*, dataPtr),
       
   331             REINTERPRET_CAST(RPacketService::TContextInfo*, dataPtr2));
       
   332         case EPacketGetNtwkRegStatus:
       
   333             return GetNtwkRegStatus(aTsyReqHandle,
       
   334             REINTERPRET_CAST(RPacketService::TRegistrationStatus*, dataPtr));
       
   335         case EPacketNotifyChangeOfNtwkRegStatus:
       
   336             return NotifyChangeOfNtwkRegStatus(aTsyReqHandle,
       
   337             REINTERPRET_CAST(RPacketService::TRegistrationStatus*, dataPtr));
       
   338         case EPacketGetMSClass:
       
   339             return GetMSClass(aTsyReqHandle,
       
   340             REINTERPRET_CAST(RPacketService::TMSClass*, dataPtr),
       
   341             REINTERPRET_CAST(RPacketService::TMSClass*, dataPtr2));
       
   342         case EPacketSetMSClass:
       
   343             return SetMSClass(aTsyReqHandle,
       
   344             REINTERPRET_CAST(RPacketService::TMSClass*, dataPtr));
       
   345         case EPacketNotifyMSClassChange:
       
   346             return NotifyMSClassChange(aTsyReqHandle,
       
   347             REINTERPRET_CAST(RPacketService::TMSClass*, dataPtr));
       
   348         case EPacketGetStaticCaps:
       
   349             return GetStaticCaps(aTsyReqHandle, 
       
   350 				REINTERPRET_CAST(TUint*, dataPtr),
       
   351 				REINTERPRET_CAST(RPacketContext::TProtocolType*, dataPtr2));
       
   352         case EPacketGetDynamicCaps:
       
   353             return GetDynamicCaps(aTsyReqHandle,
       
   354             REINTERPRET_CAST(RPacketService::TDynamicCapsFlags*, dataPtr));
       
   355         case EPacketNotifyDynamicCapsChange:
       
   356             return NotifyDynamicCapsChange(aTsyReqHandle,
       
   357             REINTERPRET_CAST(RPacketService::TDynamicCapsFlags*, dataPtr));
       
   358         case EPacketSetAttachMode:
       
   359             return SetAttachMode(aTsyReqHandle,
       
   360             REINTERPRET_CAST(RPacketService::TAttachMode*, dataPtr));
       
   361         case EPacketGetAttachMode:
       
   362             return GetAttachMode(aTsyReqHandle,
       
   363             REINTERPRET_CAST(RPacketService::TAttachMode*, dataPtr));
       
   364         case EPacketAttach:
       
   365             return Attach(aTsyReqHandle);
       
   366         case EPacketDetach:
       
   367             return Detach(aTsyReqHandle);
       
   368         case EPacketRejectActivationRequest:
       
   369             return RejectActivationRequest(aTsyReqHandle);
       
   370         case EPacketSetDefaultContextParams:
       
   371             return SetDefaultContextParams(aTsyReqHandle, aPackage.Des1n());
       
   372         case EPacketGetDefaultContextParams:
       
   373             return GetDefaultContextParams(aTsyReqHandle, aPackage.Des1n());
       
   374         default:
       
   375             return KErrNotSupported;
       
   376         }
       
   377     }
       
   378 
       
   379 
       
   380 TInt CGprs::CancelService(const TInt aIpc, const TTsyReqHandle aTsyReqHandle)
       
   381 /**
       
   382  * This function is called from the framework and cancels a outstanding request.
       
   383  * @param aIpc The IPC to cancel.
       
   384  * @param aTsyReqHandle the client handle to cancel.
       
   385  */
       
   386     {
       
   387     LOGTEXT(_L8("CGprs: - CancelService called"));
       
   388     switch (aIpc)
       
   389         {
       
   390         case EPacketNotifyContextAdded:
       
   391             return NotifyContextAddedCancel(aTsyReqHandle);
       
   392         case EPacketAttach:
       
   393             return AttachCancel(aTsyReqHandle);
       
   394         case EPacketDetach:
       
   395             return DetachCancel(aTsyReqHandle);
       
   396         case EPacketNotifyStatusChange:
       
   397             return NotifyStatusChangeCancel(aTsyReqHandle);
       
   398         case EPacketNotifyContextActivationRequested:
       
   399             return NotifyContextActivationRequestedCancel(aTsyReqHandle);
       
   400         case EPacketRejectActivationRequest:
       
   401             return RejectActivationRequestCancel(aTsyReqHandle);
       
   402         case EPacketGetContextInfo:
       
   403             return GetContextInfoCancel(aTsyReqHandle);
       
   404         case EPacketNotifyChangeOfNtwkRegStatus:
       
   405             return NotifyChangeOfNtwkRegStatusCancel(aTsyReqHandle);
       
   406         case EPacketGetMSClass:
       
   407             return GetMSClassCancel(aTsyReqHandle);
       
   408         case EPacketSetMSClass:
       
   409             return SetMSClassCancel(aTsyReqHandle);
       
   410         case EPacketNotifyMSClassChange:
       
   411             return NotifyMSClassChangeCancel(aTsyReqHandle);
       
   412         case EPacketNotifyDynamicCapsChange:
       
   413             return NotifyDynamicCapsChangeCancel(aTsyReqHandle);
       
   414 				case EPacketGetNtwkRegStatus:
       
   415             return GetNtwkRegStatusCancel(aTsyReqHandle);
       
   416         default:
       
   417             return KErrGeneral; // Should never get to this point, as Etel should try to cancel IPC we do not support
       
   418         } 
       
   419     }
       
   420 
       
   421 
       
   422 void CGprs::AppendNewContextL(CGprsContext* aNewContext)
       
   423 /**
       
   424  * This function adds a context to the list.
       
   425  *
       
   426  * @param aNewContext Adds a context to the linked list of contexts.
       
   427  */
       
   428     {
       
   429     LOGTEXT(_L8("CGprs::AppendNewContextL called"));
       
   430     CGprsContextEntry* entry = new (ELeave) CGprsContextEntry(aNewContext);
       
   431     iContexts.AddLast(*entry);
       
   432     }
       
   433 
       
   434 
       
   435 void CGprs::RemoveContext(CGprsContext* aContext)
       
   436 /**
       
   437  * This function removes a context from the list.
       
   438  *
       
   439  * @param aContext Context to remove from linked list.
       
   440  */
       
   441     {
       
   442 #ifdef _DEBUG
       
   443     TBuf8<KMaxName> tmpLog;
       
   444     tmpLog.Copy(*(aContext->ContextName()));		// Convert 16bit string to 8bit so we can log it
       
   445     LOGTEXT2(_L8("CGprs::RemoveContext called, %S"), &tmpLog);
       
   446 #endif
       
   447     CGprsContextEntry* contextEntry;
       
   448     TDblQueIter<CGprsContextEntry> iter(iContexts);
       
   449     while (contextEntry=iter++, contextEntry)
       
   450         {
       
   451         if (contextEntry->iContext == aContext)
       
   452             {
       
   453             contextEntry->Deque();
       
   454             delete contextEntry;    // just deletes list entry, not the context itself
       
   455             break;
       
   456             }
       
   457         }
       
   458     }
       
   459 
       
   460 
       
   461 TDes* CGprs::NameOfLastAddedContext()
       
   462 /**
       
   463  * This function gets the name of the last added context.
       
   464  */
       
   465     {
       
   466     if (iContexts.IsEmpty())
       
   467         return NULL;
       
   468     CGprsContextEntry* contextEntry = iContexts.Last();
       
   469     __ASSERT_ALWAYS(contextEntry,Panic(EPacketContextDoesNotExist));
       
   470     return (contextEntry->iContext->ContextName());
       
   471     }
       
   472 
       
   473 
       
   474 RPacketService::TStatus CGprs::Status()
       
   475 /**
       
   476  * This function returns the GPRS status.
       
   477  */
       
   478     {
       
   479     return iPhoneGlobals->iGprsStatus;
       
   480     }
       
   481 
       
   482 
       
   483 void CGprs::SetStatus(RPacketService::TStatus aStatus)
       
   484 /**
       
   485  * This function sets the GPRS status.
       
   486  * @param aStatus Status to set.
       
   487  */
       
   488 
       
   489     {
       
   490     iPhoneGlobals->iGprsStatus = aStatus;
       
   491     }
       
   492 
       
   493 RPacketService::TRegistrationStatus CGprs::RegistrationStatus()
       
   494 /**
       
   495  * This function returns the GPRS network registration status.
       
   496  */
       
   497     {
       
   498     return iPhoneGlobals->iGprsRegistrationStatus;
       
   499     }
       
   500 
       
   501 
       
   502 void CGprs::SetRegistrationStatus(RPacketService::TRegistrationStatus aStatus)
       
   503 /**
       
   504  * This function sets the GPRS registration status.
       
   505  * @param aStatus Status to set.
       
   506  */
       
   507     {
       
   508     iPhoneGlobals->iGprsRegistrationStatus = aStatus;
       
   509     }
       
   510 
       
   511 
       
   512 TInt CGprs::NumberOfContexts()
       
   513 /**
       
   514  * This function returns the number of contexts.
       
   515  */
       
   516     {
       
   517     TInt count=0;
       
   518     TDblQueIter<CGprsContextEntry> iter(iContexts);
       
   519     while (iter++)
       
   520         {
       
   521         count++;
       
   522         }
       
   523     return count;
       
   524     }
       
   525 
       
   526 
       
   527 void CGprs::GenerateNewContextNameAndCid(TDes& aName, TInt& aCid)
       
   528 /**
       
   529  * This function generates a unique context name and the first not taken cid number.
       
   530  * There is a 1 to 1 mapping between this Cid and the one in the phone. 
       
   531  * In order to do this we need to check all existing Cids, since they may not
       
   532  * be in conical order and there can be holes in the list(3,1,4,6,5) we need 
       
   533  * to loop around and find the lowest that we can use to create a name and a new
       
   534  * Cid.
       
   535  * @param aName New name that is generated.
       
   536  * @param aCid New context id.
       
   537  */
       
   538     {
       
   539     TInt lowestAvailableCid = 1;
       
   540     TInt count = NumberOfContexts();
       
   541     if(count != 0 )
       
   542         {
       
   543         // There can be gaps between the Cids that the tsy has, so get the
       
   544         // Cid number between them, if any. This nested for loop will find 
       
   545         // the lowest available cid there is.
       
   546         for(TInt k = 0; k < count;k++)
       
   547             {
       
   548             for(TInt i = 0; i < count;i++)
       
   549                 {
       
   550                 CGprsContext* context = Context(i);
       
   551                 if(context->Cid() == lowestAvailableCid)
       
   552                     ++lowestAvailableCid;
       
   553                 }
       
   554             }
       
   555         }
       
   556     aCid = lowestAvailableCid;
       
   557     _LIT(KGprsName, "GPRS_CONTEXT");
       
   558 	aName.Zero();
       
   559     aName.Append(KGprsName);
       
   560     aName.AppendNum(lowestAvailableCid);
       
   561     }
       
   562 
       
   563 
       
   564 RPacketService::TMSClass CGprs::CurrentMSClass()
       
   565 /**
       
   566  * This function returns the current MS class.
       
   567  */
       
   568     {
       
   569     return iPhoneGlobals->iMSClass;
       
   570     }
       
   571 
       
   572 
       
   573 void CGprs::SetCurrentMSClass(RPacketService::TMSClass aMSClass)
       
   574 /**
       
   575  * This function sets the current MS class.
       
   576  *
       
   577  * @param aMSClass Current MSClass to set.
       
   578  */
       
   579     {
       
   580     iPhoneGlobals->iMSClass = aMSClass;
       
   581     }
       
   582 
       
   583 
       
   584 RPacketService::TMSClass CGprs::MaxMSClass()
       
   585 /**
       
   586  * This function returns the maximum MS class.
       
   587  */
       
   588     {
       
   589     return iPhoneGlobals->iMaxMSClass;
       
   590     }
       
   591 
       
   592 
       
   593 
       
   594 void CGprs::SetContextConfigGPRS(const RPacketContext::TContextConfigGPRS* aContextConfigV01)
       
   595 /**
       
   596  * This function sets the default context configuration.
       
   597  *
       
   598  * @param aContextConfigV01 Set default context configuration.
       
   599  */
       
   600     {
       
   601     iDefContextConfigGPRS.iPdpType = aContextConfigV01->iPdpType;
       
   602     iDefContextConfigGPRS.iAccessPointName.Copy(aContextConfigV01->iAccessPointName);
       
   603     iDefContextConfigGPRS.iPdpAddress.Copy(aContextConfigV01->iPdpAddress);
       
   604     iDefContextConfigGPRS.iPdpCompression = aContextConfigV01->iPdpCompression;
       
   605     iDefContextConfigGPRS.iAnonymousAccessReqd = aContextConfigV01->iAnonymousAccessReqd;
       
   606     }
       
   607 
       
   608 
       
   609 void CGprs::ContextConfigGPRS(RPacketContext::TContextConfigGPRS* aContextConfigV01)
       
   610 /**
       
   611  * This function gets the default context configuration.
       
   612  *
       
   613  * @param aContextConfigV01 Default context configuration to get.
       
   614  */
       
   615     {
       
   616     aContextConfigV01->iPdpType = iDefContextConfigGPRS.iPdpType;
       
   617     aContextConfigV01->iAccessPointName.Copy(iDefContextConfigGPRS.iAccessPointName);
       
   618     aContextConfigV01->iPdpAddress.Copy(iDefContextConfigGPRS.iPdpAddress);
       
   619     aContextConfigV01->iPdpCompression = iDefContextConfigGPRS.iPdpCompression;
       
   620     aContextConfigV01->iAnonymousAccessReqd = iDefContextConfigGPRS.iAnonymousAccessReqd;
       
   621     }
       
   622 
       
   623 
       
   624 TInt CGprs::MaxNumberOfContexts()
       
   625 /**
       
   626  * This function returns the maximum number of contexts that the phone supports.
       
   627  */
       
   628 
       
   629     {
       
   630     return iPhoneGlobals->iGprsMaxNumContexts;
       
   631     }
       
   632 
       
   633 
       
   634 CGprsContext* CGprs::Context(TInt aCount)
       
   635 /**
       
   636  * This function returns a specific context
       
   637  * @param aCount context to Retrieve in linked list.
       
   638  */
       
   639     {
       
   640     if(aCount >= NumberOfContexts())
       
   641         return NULL;
       
   642     CGprsContextEntry* contextEntry;
       
   643     TDblQueIter<CGprsContextEntry> iter(iContexts);
       
   644     iter.SetToFirst();
       
   645     for (TInt i=0;i<(aCount);i++)
       
   646         {
       
   647         iter++;
       
   648         }
       
   649     contextEntry = iter;    
       
   650     return contextEntry->iContext;
       
   651     }
       
   652 
       
   653 
       
   654 TInt CGprs::NotifyContextAdded(const TTsyReqHandle aTsyReqHandle, TDes* aContextId)
       
   655     {
       
   656     LOGTEXT(_L8("CGprs::NotifyContextAdded called"));
       
   657     iPhoneGlobals->iNotificationStore->RegisterNotification(EPacketContextAdded, aTsyReqHandle, this, aContextId);
       
   658     return KErrNone;
       
   659     }
       
   660 
       
   661 
       
   662 TInt CGprs::NotifyContextAddedCancel(const TTsyReqHandle aTsyReqHandle)
       
   663 /**
       
   664  * Cancels a outstanding request. Called via CancelService.
       
   665  * @param aTsyReqHandle  The handle to cancel
       
   666  */
       
   667     {
       
   668     LOGTEXT(_L8("CGprs::NotifyContextAddedCancel called"));
       
   669     iPhoneGlobals->iNotificationStore->RemoveNotification(aTsyReqHandle);
       
   670     return KErrNone;
       
   671     }
       
   672 
       
   673 
       
   674 TInt CGprs::Attach(const TTsyReqHandle aTsyReqHandle)
       
   675 /**
       
   676  * Called from a client via ExtFunc.
       
   677  * This function will start the sending of a AT command(AT+CGATT=1). 
       
   678  * @param aTsyReqHandle  request handle that is completed when done with request.
       
   679  * @return 
       
   680  */
       
   681     {
       
   682     LOGTEXT(_L8("CGprs::Attach called"));
       
   683     iATGPRSAttach->ExecuteCommand(aTsyReqHandle, NULL);		
       
   684     return KErrNone;
       
   685     }
       
   686 
       
   687 
       
   688 TInt CGprs::AttachCancel(const TTsyReqHandle aTsyReqHandle)
       
   689 /**
       
   690  * Cancels a outstanding request. Called via CancelService.
       
   691  * @param aTsyReqHandle  The handle to cancel
       
   692  */
       
   693     {
       
   694     LOGTEXT(_L8("CGprs::AttachCancel called"));
       
   695     iATGPRSAttach->CancelCommand(aTsyReqHandle);	
       
   696     return KErrNone;
       
   697     }
       
   698 
       
   699 
       
   700 TInt CGprs::Detach(const TTsyReqHandle aTsyReqHandle)
       
   701 /**
       
   702  * Called from a client via ExtFunc.
       
   703  * This function will start the sending of a AT command(AT+CGATT=0). 
       
   704  * @param aTsyReqHandle  request handle that is completed when done with request.
       
   705  * @return 
       
   706  */
       
   707     {
       
   708     LOGTEXT(_L8("CGprs::Detach called"));
       
   709     iATGprsDetach->ExecuteCommand(aTsyReqHandle, NULL);	
       
   710     return KErrNone;
       
   711     }
       
   712 
       
   713 
       
   714 TInt CGprs::DetachCancel(const TTsyReqHandle aTsyReqHandle)
       
   715 /**
       
   716  * Cancels a outstanding request. Called via CancelService.
       
   717  * @param aTsyReqHandle  The handle to cancel
       
   718  */
       
   719     {
       
   720     LOGTEXT(_L8("CGprs::DetachCancel called"));
       
   721     iATGprsDetach->CancelCommand(aTsyReqHandle);	
       
   722     return KErrNone;
       
   723     }
       
   724 
       
   725 
       
   726 TInt CGprs::GetStatus(const TTsyReqHandle aTsyReqHandle, RPacketService::TStatus* aGprsStatus)
       
   727 /**
       
   728  * Called from a client via ExtFunc.
       
   729  * This function will return the state of the CGprs object
       
   730  * @param aTsyReqHandle  request handle that is completed when done with request.
       
   731  * @param  aGprsStatus   Pointer to a RPacketService::TStatus.
       
   732  */
       
   733     {
       
   734     LOGTEXT(_L8("CGprs::GetStatus called"));
       
   735     *aGprsStatus = Status();
       
   736     ReqCompleted(aTsyReqHandle,KErrNone);
       
   737     return KErrNone;
       
   738     }
       
   739 
       
   740  
       
   741 TInt CGprs::NotifyStatusChange(const TTsyReqHandle aTsyReqHandle, RPacketService::TStatus* aGprsStatus)
       
   742 /**
       
   743  * Called from a client via ExtFunc.
       
   744  * This function will complete when EPacketStatusChanged event is triggered.
       
   745  * @param aTsyReqHandle  request handle that is completed.
       
   746  * @param  aConfig  Pointer to a RPacketService::TStatus
       
   747  */
       
   748     {
       
   749     LOGTEXT(_L8("CGprs::NotifyStatusChange called"));
       
   750     iPhoneGlobals->iNotificationStore->RegisterNotification(EPacketStatusChange, aTsyReqHandle, this, aGprsStatus);
       
   751     return KErrNone;
       
   752     }
       
   753 
       
   754 
       
   755 TInt CGprs::NotifyStatusChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
   756 /**
       
   757  * Cancels a outstanding notification request. Called via CancelService.
       
   758  * @param aTsyReqHandle  The handle to cancel
       
   759  */
       
   760     {
       
   761     LOGTEXT(_L8("CGprs::NotifyStatusChangeCancel called"));
       
   762     iPhoneGlobals->iNotificationStore->RemoveNotification(aTsyReqHandle);
       
   763     return KErrNone;
       
   764     }
       
   765 
       
   766 
       
   767 TInt CGprs::NotifyContextActivationRequested(const TTsyReqHandle aTsyReqHandle, RPacketContext::TProtocolType* /*aPdpType*/)
       
   768 /**
       
   769  * This function is not supported.
       
   770  * @param aTsyReqHandle   request handle that is completed.
       
   771  */
       
   772     {
       
   773     LOGTEXT(_L8("CGprs::NotifyContextActivationRequested called"));
       
   774     ReqCompleted(aTsyReqHandle, KErrNotSupported); // Req22
       
   775     return KErrNone;
       
   776     }
       
   777 
       
   778 
       
   779 TInt CGprs::NotifyContextActivationRequestedCancel(const TTsyReqHandle aTsyReqHandle)
       
   780 /**
       
   781  * Cancels a outstanding notification request. Called via CancelService.
       
   782  * @param aTsyReqHandle  The handle to cancel
       
   783  */
       
   784     {
       
   785     LOGTEXT(_L8("CGprs::NotifyContextActivationRequestedCancel called"));
       
   786     ReqCompleted(aTsyReqHandle, KErrNone); // Req23
       
   787     return KErrNone;
       
   788     }
       
   789 
       
   790 
       
   791 TInt CGprs::RejectActivationRequest(const TTsyReqHandle aTsyReqHandle)
       
   792 /**
       
   793  * This function is not supported.
       
   794  * @param aTsyReqHandle   request handle that is completed.
       
   795  */
       
   796     {
       
   797     LOGTEXT(_L8("CGprs::RejectActivationRequest called"));
       
   798     ReqCompleted(aTsyReqHandle, KErrNotSupported); // Req24
       
   799     return KErrNone;
       
   800     }
       
   801 
       
   802 
       
   803 TInt CGprs::RejectActivationRequestCancel(const TTsyReqHandle aTsyReqHandle)
       
   804 /**
       
   805  * Cancels a outstanding request. Called via CancelService.
       
   806  * @param aTsyReqHandle  The handle to cancel
       
   807  */
       
   808     {
       
   809     LOGTEXT(_L8("CGprs::RejectActivationRequestCancel called"));
       
   810     ReqCompleted(aTsyReqHandle, KErrCancel); // Req25
       
   811     return KErrNone;
       
   812     }
       
   813 
       
   814 
       
   815 TInt CGprs::EnumerateContexts(const TTsyReqHandle aTsyReqHandle, TInt* aCount, TInt* aMaxAllowed)
       
   816 /**
       
   817  * Called from a client via ExtFunc.
       
   818  * This function will return the current amount of contexts that the TSY has loaded and the
       
   819  * maximum amount of contexts that the phone support.
       
   820  * @param aTsyReqHandle  request handle that is completed.
       
   821  * @param  aCount Number of CGprsContext that the CGprs object has in its list.
       
   822  * @param  aMaxAllowed The largest context number, this is read from the phone.
       
   823  */
       
   824     {
       
   825     LOGTEXT(_L8("CGprs::EnumerateContexts called"));
       
   826     *aCount = NumberOfContexts();
       
   827     *aMaxAllowed = MaxNumberOfContexts();
       
   828     ReqCompleted(aTsyReqHandle,KErrNone);
       
   829     return KErrNone;
       
   830     }
       
   831 
       
   832 
       
   833 TInt CGprs::GetContextInfo(const TTsyReqHandle aTsyReqHandle, TInt aIndex, RPacketService::TContextInfo* aInfo)
       
   834 /**
       
   835  * Called from a client via ExtFunc.
       
   836  * Returns the context info of aIndex in context list.
       
   837  * @param aTsyReqHandle  request handle that is completed.
       
   838  * @param  aIndex Context number
       
   839  * @param  aInfo  Pointer to a RPacketService::TContextInfo
       
   840  */
       
   841     {
       
   842     LOGTEXT2(_L8("CGprs::GetContextInfo called with aIndex=%d"),aIndex);
       
   843 
       
   844 	TInt ret(KErrNone);
       
   845 	if(aIndex>=0 &&	aIndex<=MaxNumberOfContexts())
       
   846 		{
       
   847 		TDblQueIter<CGprsContextEntry> iter(iContexts);
       
   848 		iter.SetToFirst();
       
   849 		for (TInt i=0;i!=aIndex;++i)
       
   850 			iter++;
       
   851 	    
       
   852 	    CGprsContextEntry* contextEntry=iter;
       
   853 		if (contextEntry)
       
   854 			*aInfo = *contextEntry->iContext->ContextInfo();
       
   855 		else
       
   856 			ret=KErrArgument;
       
   857 		}
       
   858 	else
       
   859 		ret=KErrArgument;
       
   860 
       
   861 	ReqCompleted(aTsyReqHandle,ret);
       
   862     return KErrNone;
       
   863     }
       
   864 
       
   865 
       
   866 TInt CGprs::GetContextInfoCancel(const TTsyReqHandle aTsyReqHandle) 
       
   867 /**
       
   868  * Cancels a outstanding request. Called via CancelService.
       
   869  * @param aTsyReqHandle  The handle to cancel
       
   870  */
       
   871     {
       
   872     LOGTEXT(_L8("CGprs::GetContextInfoCancel called"));
       
   873     ReqCompleted(aTsyReqHandle, KErrCancel);
       
   874     return KErrNone;
       
   875     }
       
   876 
       
   877 
       
   878 TInt CGprs::GetNtwkRegStatus(const TTsyReqHandle aTsyReqHandle, RPacketService::TRegistrationStatus* aRegistrationStatus)
       
   879 /**
       
   880  * @param aTsyReqHandle request handle that is completed.
       
   881  */
       
   882 	{
       
   883 	LOGTEXT(_L8("CGprs::GetNtwkRegStatus called"));
       
   884 	if (iPhoneGlobals->iPhoneStatus.iDataPortLoaned)
       
   885 		{
       
   886 		ReqCompleted(aTsyReqHandle, KErrNone);
       
   887 		}
       
   888 	else
       
   889 		{
       
   890 		iATGprsNtwkRegStatus->ExecuteCommand(aTsyReqHandle,aRegistrationStatus);
       
   891 		}
       
   892 	return KErrNone;
       
   893 	}
       
   894 
       
   895 TInt CGprs::GetNtwkRegStatusCancel(const TTsyReqHandle aTsyReqHandle) 
       
   896 /**
       
   897  * Cancels a outstanding request. Called via CancelService.
       
   898  * @param aTsyReqHandle  The handle to cancel
       
   899  */
       
   900   {
       
   901   LOGTEXT(_L8("CGprs::GetNtwkRegStatusCancel called"));
       
   902   iATGprsNtwkRegStatus->CancelCommand(aTsyReqHandle);			
       
   903   return KErrNone;
       
   904   }
       
   905 
       
   906 
       
   907 TInt CGprs::NotifyChangeOfNtwkRegStatus(const TTsyReqHandle aTsyReqHandle, RPacketService::TRegistrationStatus* aRegistrationStatus)
       
   908 /**
       
   909  * This function is not supported.
       
   910  * @param aTsyReqHandle   request handle that is completed.
       
   911  */
       
   912     {
       
   913     LOGTEXT(_L8("CGprs::NotifyChangeOfNtwkRegStatus called"));		
       
   914 	if(iPhoneGlobals->iModemSupportsCGREGNotification)
       
   915 		{
       
   916 		// Make sure AT class watching for unsolicited registration result code is enabled
       
   917 		iATGprsNtwkRegStatusChange->Enable();
       
   918 		iPhoneGlobals->iNotificationStore->RegisterNotification(EPacketNtwkRegStatusChange,aTsyReqHandle,this,aRegistrationStatus);
       
   919 		return KErrNone;
       
   920 		}
       
   921 
       
   922     LOGTEXT(_L8("CGprs::NotifyChangeOfNtwkRegStatus returning KErrNotSupported"));		
       
   923 	return KErrNotSupported;		// Etel will complete the client request for us
       
   924 	}
       
   925 
       
   926 
       
   927 TInt CGprs::NotifyChangeOfNtwkRegStatusCancel(const TTsyReqHandle aTsyReqHandle)
       
   928 /**
       
   929  * Cancels a outstanding request. Called via CancelService.
       
   930  * @param aTsyReqHandle  The handle to cancel
       
   931  */
       
   932     {
       
   933     LOGTEXT(_L8("CGprs::NotifyChangeOfNtwkRegStatusCancel called"));
       
   934     iPhoneGlobals->iNotificationStore->RemoveNotification(aTsyReqHandle);
       
   935     return KErrNone;
       
   936     }
       
   937 
       
   938 TInt CGprs::GetMSClass(const TTsyReqHandle aTsyReqHandle, RPacketService::TMSClass* aCurrentClass, RPacketService::TMSClass* aMaxClass)
       
   939 /**
       
   940  * Called from a client via ExtFunc.
       
   941  * This function returns the current RPacketService::TMSClass. It also returns the maximum class that the 
       
   942  * phone supports.
       
   943  * @param aTsyReqHandle  request handle that is completed.
       
   944  * @param  aCurrentClass  pointer to a  RPacketService::TMSClass
       
   945  * @param  aMaxClass      pointer to a  RPacketService::TMSClass
       
   946  */
       
   947     {
       
   948     LOGTEXT(_L8("CGprs::GetMSClass called"));
       
   949     *aMaxClass = MaxMSClass();
       
   950     *aCurrentClass = CurrentMSClass();
       
   951     ReqCompleted(aTsyReqHandle, KErrNone);
       
   952     return KErrNone;
       
   953     }
       
   954 
       
   955 
       
   956 TInt CGprs::GetMSClassCancel(const TTsyReqHandle aTsyReqHandle)
       
   957 /**
       
   958  * Cancels a outstanding request. Called via CancelService.
       
   959  * @param aTsyReqHandle  The handle to cancel
       
   960  */
       
   961     {
       
   962     LOGTEXT(_L8("CGprs::GetMSClassCancel called"));
       
   963     ReqCompleted(aTsyReqHandle, KErrCancel);
       
   964     return KErrNone;
       
   965     }
       
   966 
       
   967 
       
   968 TInt CGprs::SetMSClass(const TTsyReqHandle aTsyReqHandle, RPacketService::TMSClass* aClass)
       
   969 /**
       
   970  * Called from a client via ExtFunc.
       
   971  * This function will start the sending of a AT command to the phone(AT+CGCLASS).
       
   972  * @param aTsyReqHandle  request handle that is completed.
       
   973  * @param  aClass  pointer to a  RPacketService::TMSClass
       
   974  */
       
   975     {
       
   976     LOGTEXT(_L8("CGprs::SetMSClass called"));
       
   977     iATGprsClass->ExecuteCommand(aTsyReqHandle, aClass);		
       
   978     return KErrNone;
       
   979     }
       
   980 
       
   981 
       
   982 TInt CGprs::SetMSClassCancel(const TTsyReqHandle aTsyReqHandle)
       
   983 /**
       
   984  * Cancels a outstanding request. Called via CancelService.
       
   985  * @param aTsyReqHandle  The handle to cancel
       
   986  */
       
   987     {
       
   988     LOGTEXT(_L8("CGprs::SetMSClassCancel called"));
       
   989     iATGprsClass->CancelCommand(aTsyReqHandle);			
       
   990     return KErrNone;
       
   991     }   
       
   992 
       
   993 
       
   994 TInt CGprs::NotifyMSClassChange(const TTsyReqHandle aTsyReqHandle, RPacketService::TMSClass* /*aNewClass*/)
       
   995 /**
       
   996  * This function is not supported.
       
   997  * @param aTsyReqHandle   request handle that is completed.
       
   998  */
       
   999     {
       
  1000     LOGTEXT(_L8("CGprs::NotifyMSClassChange called"));
       
  1001     ReqCompleted(aTsyReqHandle, KErrNotSupported); // Req26
       
  1002     return KErrNone;
       
  1003     }
       
  1004 
       
  1005 
       
  1006 TInt CGprs::NotifyMSClassChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
  1007 /**
       
  1008  * Cancels a outstanding request. Called via CancelService.
       
  1009  * @param aTsyReqHandle  The handle to cancel
       
  1010  */
       
  1011     {
       
  1012     LOGTEXT(_L8("CGprs::NotifyMSClassChangeCancel called"));
       
  1013     ReqCompleted(aTsyReqHandle, KErrCancel); // Req27
       
  1014     return KErrNone;
       
  1015     }
       
  1016    
       
  1017 
       
  1018 TInt CGprs::GetStaticCaps(const TTsyReqHandle aTsyReqHandle, TUint* aCaps, RPacketContext::TProtocolType* aPdpType)
       
  1019 /**
       
  1020  * Called from a client via ExtFunc.
       
  1021  * This function returns the static caps that from the phone.
       
  1022  * Note that in this function we validate the value of aPdpType.
       
  1023  * @param aTsyReqHandle request handle that is completed. 
       
  1024  * @param  aCaps     Pointer to a RPacketService::TStaticCaps  
       
  1025  * @param  aPdpType  Pointer to a TPdpType
       
  1026  */
       
  1027     {
       
  1028     LOGTEXT(_L8("CGprs::GetStaticCaps called"));
       
  1029     if (*aPdpType!=RPacketContext::EPdpTypeIPv4) 
       
  1030         {
       
  1031         LOGTEXT(_L8("CGprs::GetStaticCaps aPdpType is not EPdpTypeIPv4, completeing with KErrNotSupported"));
       
  1032 				ReqCompleted(aTsyReqHandle,KErrNotSupported);
       
  1033         return KErrNone;
       
  1034         }
       
  1035 		//
       
  1036 		// Static caps are hardcoded according to the MMTSY design document.
       
  1037 		*aCaps=RPacketService::KCapsSetDefaultContextSupported;
       
  1038 		*aCaps|=RPacketService::KCapsMSClassSupported;
       
  1039 
       
  1040     ReqCompleted(aTsyReqHandle,KErrNone);
       
  1041     return KErrNone;
       
  1042     }
       
  1043 
       
  1044 
       
  1045 TInt CGprs::GetDynamicCaps(const TTsyReqHandle aTsyReqHandle, RPacketService::TDynamicCapsFlags* /*aCaps*/)
       
  1046 /**
       
  1047  * This function is not supported.
       
  1048  * @param aTsyReqHandle   request handle that is completed.
       
  1049  */
       
  1050     {
       
  1051     LOGTEXT(_L8("CGprs::GetDynamicCaps called"));
       
  1052     ReqCompleted(aTsyReqHandle, KErrNotSupported); // Req28
       
  1053     return KErrNone;
       
  1054     }
       
  1055 
       
  1056 
       
  1057 TInt CGprs::NotifyDynamicCapsChange(const TTsyReqHandle aTsyReqHandle, RPacketService::TDynamicCapsFlags* /*aCaps*/)
       
  1058 /**
       
  1059  * This function is not supported.
       
  1060  * @param aTsyReqHandle   request handle that is completed.
       
  1061  */
       
  1062     {
       
  1063     LOGTEXT(_L8("CGprs::NotifyDynamicCapsChange called"));
       
  1064     ReqCompleted(aTsyReqHandle, KErrNotSupported); // Req29
       
  1065     return KErrNone;
       
  1066     }
       
  1067 
       
  1068 
       
  1069 TInt CGprs::NotifyDynamicCapsChangeCancel(const TTsyReqHandle aTsyReqHandle)
       
  1070 /**
       
  1071  * Cancels a outstanding request. Called via CancelService.
       
  1072  * @param aTsyReqHandle  The handle to cancel
       
  1073  */
       
  1074     {
       
  1075     LOGTEXT(_L8("CGprs::NotifyDynamicCapsChangeCancel called"));
       
  1076     ReqCompleted(aTsyReqHandle, KErrCancel); // Req30
       
  1077     return KErrNone;
       
  1078     }
       
  1079 
       
  1080 
       
  1081 TInt CGprs::SetAttachMode(const TTsyReqHandle aTsyReqHandle, RPacketService::TAttachMode* /*aMode*/)
       
  1082 /**
       
  1083  * This function is not supported.
       
  1084  * @param aTsyReqHandle   request handle that is completed.
       
  1085  */
       
  1086     {
       
  1087     LOGTEXT(_L8("CGprs::SetAttachMode called"));
       
  1088     ReqCompleted(aTsyReqHandle, KErrNotSupported); // Req40
       
  1089     return KErrNone;
       
  1090     }
       
  1091 
       
  1092 
       
  1093 TInt CGprs::GetAttachMode(const TTsyReqHandle aTsyReqHandle, RPacketService::TAttachMode* /*aMode*/)
       
  1094 /**
       
  1095  * This function is not supported.
       
  1096  * @param aTsyReqHandle   request handle that is completed.
       
  1097  */
       
  1098     {
       
  1099     LOGTEXT(_L8("CGprs::GetAttachMode called"));
       
  1100     ReqCompleted(aTsyReqHandle, KErrNotSupported); // Req41
       
  1101     return KErrNone;
       
  1102     }
       
  1103 
       
  1104 
       
  1105 TInt CGprs::SetDefaultContextParams(const TTsyReqHandle aTsyReqHandle, const TDesC8* aPckg)
       
  1106 /**
       
  1107  * Called from a client via ExtFunc.
       
  1108  * This function will set the default parameters for a context.
       
  1109  * These parameters are used when a new context is created.
       
  1110  * @param aTsyReqHandle  request handle that is completed.
       
  1111  * @param  aPckg Pointer to a RPacketContext::TContextConfigPckg
       
  1112  */
       
  1113 
       
  1114     {
       
  1115     LOGTEXT(_L8("CGprs::SetDefaultContextParams called"));
       
  1116 	TPckg<RPacketContext::TContextConfigGPRS>* defaultContextV1Pckg = (TPckg<RPacketContext::TContextConfigGPRS>*) aPckg;
       
  1117 	RPacketContext::TContextConfigGPRS& defaultContextV1 = (*defaultContextV1Pckg)();
       
  1118 	SetContextConfigGPRS(&defaultContextV1);
       
  1119     ReqCompleted(aTsyReqHandle,KErrNone);
       
  1120     return KErrNone;
       
  1121     }
       
  1122 
       
  1123 
       
  1124 TInt CGprs::GetDefaultContextParams(const TTsyReqHandle aTsyReqHandle, TDes8* aPckg)
       
  1125 /**
       
  1126  * Called from a client via ExtFunc.
       
  1127  * This function will get the default parameters for a context.
       
  1128  * @param aTsyReqHandle  request handle that is completed.
       
  1129  * @param  aPckg Pointer to a RPacketContext::TContextConfigPckg
       
  1130  */
       
  1131 
       
  1132     {
       
  1133     LOGTEXT(_L8("CGprs::GetDefaultContextParams called"));
       
  1134 	TPckg<RPacketContext::TContextConfigGPRS>* defaultContextV1Pckg = (TPckg<RPacketContext::TContextConfigGPRS>*) aPckg;
       
  1135 	RPacketContext::TContextConfigGPRS& defaultContextV1 = (*defaultContextV1Pckg)();
       
  1136     ContextConfigGPRS(&defaultContextV1);
       
  1137     ReqCompleted(aTsyReqHandle,KErrNone);
       
  1138     return KErrNone;
       
  1139     }
       
  1140 
       
  1141 
       
  1142 //
       
  1143 // CGprsContextEntry class
       
  1144 //
       
  1145 CGprsContextEntry::CGprsContextEntry(CGprsContext* aContext)
       
  1146 : iContext(aContext)
       
  1147 /**
       
  1148  * Constructor
       
  1149  * @param aContext Context to add to entry
       
  1150  */
       
  1151     {}
       
  1152 
       
  1153 
       
  1154 CGprsContextEntry::~CGprsContextEntry()
       
  1155 /**
       
  1156  * Destructor
       
  1157  */
       
  1158     {}
       
  1159 
       
  1160 
       
  1161 void CGprsContextEntry::Deque()
       
  1162 /**
       
  1163  * Remove entry from TDblQue link
       
  1164  */
       
  1165     {
       
  1166     iLink.Deque();
       
  1167     iLink.iPrev=iLink.iNext=NULL;
       
  1168     }