telephonyserverplugins/common_tsy/commontsy/src/mmpacket/Cmmpacketservicetsy.cpp
changeset 0 3553901f7fa8
child 16 fe8b59ab9fa0
child 20 244d7c5f118e
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2006-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 //
       
    15 
       
    16 
       
    17 
       
    18 //  INCLUDE FILES
       
    19 #include "Cmmpacketservicetsy.h"
       
    20 #include <ctsy/tflogger.h>
       
    21 #include <ctsy/serviceapi/mmtsy_defaults.h>
       
    22 #include "MmTsy_timeoutdefs.h"
       
    23 #include "MmTsy_numberOfSlots.h"
       
    24 #include "CMmCommonStaticUtility.h"
       
    25 #include "Cmmpacketcontextlist.h"
       
    26 #include "cmmpacketservicegsmwcdmaext.h"
       
    27 #include "cmmcalllist.h"
       
    28 #include "cmmcalltsy.h"
       
    29 #include "CMmCustomTsy.h"
       
    30 #include "CMmPacketTsy.h"
       
    31 #include <ctsy/serviceapi/mmtsy_ipcdefs.h>
       
    32 #include <ctsy/pluginapi/cmmdatapackage.h>
       
    33 
       
    34 #include "cmmmbmscontextlist.h"
       
    35 #include "cmmmbmsmonitoredlist.h"
       
    36 
       
    37 // ======== MEMBER FUNCTIONS ========
       
    38 
       
    39 CMmPacketServiceTsy::CMmPacketServiceTsy()
       
    40     {
       
    41     }
       
    42 
       
    43 CMmPacketServiceTsy* CMmPacketServiceTsy::NewL(
       
    44         CMmPhoneTsy* const aMmPhone,           
       
    45         CMmMessageManagerBase* const aMessageManager,
       
    46         MLtsyFactoryBase* aFactory  ) 
       
    47     {
       
    48 TFLOGSTRING("TSY: CMmPacketServiceTsy::NewL" );
       
    49     CMmPacketServiceTsy* const packetService =
       
    50         new ( ELeave ) CMmPacketServiceTsy();
       
    51 
       
    52     CleanupClosePushL( *packetService );
       
    53     packetService->iMmPhone = aMmPhone;
       
    54 	packetService->iMessageManager = aMessageManager;
       
    55     packetService->ConstructL( aFactory );
       
    56     CleanupStack::Pop();
       
    57 
       
    58 TFLOGSTRING("TSY: CMmPacketServiceTsy::NewL." );
       
    59     return packetService;
       
    60 
       
    61     }
       
    62 
       
    63 void CMmPacketServiceTsy::ConstructL( MLtsyFactoryBase* aFactory )
       
    64     {
       
    65 
       
    66     InitModulesL( aFactory );
       
    67 
       
    68     InitStoresAndListsL();
       
    69 
       
    70 	iMessageManager->RegisterTsyObject( CMmMessageManagerBase::EPacketDataTsy,
       
    71         this  );
       
    72 
       
    73     // Current Network Mode is initialized to be EMSClassUnknown
       
    74     iCurrentMode = RMobilePhone::ENetworkModeGsm;
       
    75 
       
    76     }
       
    77 
       
    78 CMmPacketServiceTsy::~CMmPacketServiceTsy()
       
    79     {
       
    80 TFLOGSTRING("TSY: CMmPacketServiceTsy::~CMmPacketServiceTsy" );
       
    81 
       
    82     if ( iMmPhone )
       
    83         {
       
    84         // deregister tsy object from message manager
       
    85         iMmPhone->MessageManager()->DeregisterTsyObject(this);
       
    86         
       
    87         // Reset packet data session pointer in phone
       
    88         iMmPhone->ResetPacketDataSession();
       
    89         }
       
    90 
       
    91     // Delete CMmTsyReqHandleStore object
       
    92     delete iTsyReqHandleStore;
       
    93     // Delete CMmPacketContextList object
       
    94     delete iPacketContextList;
       
    95     // Delete CMmPacketServiceGsmWcdmaExt object
       
    96     delete iMmPacketServiceGsmWcdmaExt;
       
    97     if(iMBMSContextList != NULL)
       
    98     	{
       
    99     	// Delete CMmMBMSContextList object
       
   100     	delete iMBMSContextList;
       
   101     	}
       
   102     if(iGetMbmsMonitoredServiceLists != NULL)
       
   103     	{
       
   104     	// Delete CArrayPtrFlat object
       
   105     	delete iGetMbmsMonitoredServiceLists;
       
   106     	}    
       
   107 
       
   108     if ( NULL != iDialUpContext )
       
   109         {
       
   110 TFLOGSTRING("TSY: CMmPacketServiceTsy::~CMmPacketServiceTsy: Close Dial-up Object." );
       
   111 
       
   112         iDialUpContext->Close();
       
   113         }
       
   114 
       
   115     if ( NULL != iSecondaryDialUpContext )
       
   116         {
       
   117 TFLOGSTRING("TSY: CMmPacketServiceTsy::~CMmPacketServiceTsy: Close Secondary Dial-up Object." );
       
   118 
       
   119         iSecondaryDialUpContext->Close();
       
   120         }
       
   121         
       
   122 TFLOGSTRING("TSY: CMmPacketServiceTsy::~CMmPacketServiceTsy: Closing iMutex Object." );
       
   123     iMutex.Close();
       
   124 
       
   125 #ifdef USING_CTSY_DISPATCHER
       
   126     //CTSY defect (memory leak) this maybe allocated, but it is never deleted.
       
   127     //no need for NULL check as C++ guarantees that operator delete checks its argument for null-ness.
       
   128     delete iMBMSMonitoredList;
       
   129     iMBMSMonitoredList = NULL;
       
   130 #endif //USING_CTSY_DISPATCHER    
       
   131     }
       
   132     
       
   133 
       
   134 //----------------------------------------------------------------------------
       
   135 // CMmPacketServiceTsy::InitModulesL
       
   136 // Initialises extension modules for CMmPacketServiceTsy.
       
   137 // if GSM flag is defined
       
   138 // allocate memory for CMmPacketServiceGsmWcdmaExt object
       
   139 //----------------------------------------------------------------------------
       
   140 //
       
   141 void CMmPacketServiceTsy::InitModulesL( MLtsyFactoryBase* aFactory )
       
   142     {
       
   143     // Create Packet Service Gsm extension
       
   144     iMmPacketServiceGsmWcdmaExt =
       
   145         CMmPacketServiceGsmWcdmaExt::NewL( this, aFactory );
       
   146     }
       
   147 
       
   148 //----------------------------------------------------------------------------
       
   149 // CMmPacketServiceTsy::InitStoresAndListsL
       
   150 // Initialises needed stores and lists.
       
   151 //----------------------------------------------------------------------------
       
   152 //
       
   153 void CMmPacketServiceTsy::InitStoresAndListsL()
       
   154     {
       
   155 
       
   156 #ifdef REQHANDLE_TIMER
       
   157     // Create req handle store
       
   158     iTsyReqHandleStore = CMmTsyReqHandleStore::NewL( this, iMmPhone,
       
   159         ENumOfMultimodePacketServiceRequests, iPacketServiceReqHandles );
       
   160 #else
       
   161     // Create req handle store
       
   162     iTsyReqHandleStore = CMmTsyReqHandleStore::NewL(
       
   163         ENumOfMultimodePacketServiceRequests, iPacketServiceReqHandles );
       
   164 
       
   165 #endif // REQHANDLE_TIMER
       
   166 
       
   167     // Create Packet Context List
       
   168     iPacketContextList = CMmPacketContextList::NewL( this );
       
   169 
       
   170     // create mbms context list 
       
   171     iMBMSContextList = CMmMBMSContextList::NewL();
       
   172     
       
   173     // create MBMS monitored service list
       
   174     iGetMbmsMonitoredServiceLists = new CArrayPtrFlat<CListReadAllAttempt>(1);
       
   175     
       
   176             
       
   177     // Set pointer to externally created dial-up context to be NULL
       
   178     iDialUpContext = NULL;
       
   179     
       
   180     // Set pointer to externally created dial-up context to be NULL
       
   181     iSecondaryDialUpContext = NULL;
       
   182 
       
   183     // Set phone not attached to the network
       
   184     iInternalSavedData.iServiceStatus = RPacketService::EStatusUnattached;
       
   185 
       
   186     // Current Mobile Station Class is initialized to be EMSClassUnknown
       
   187     iInternalSavedData.iMsClass = RPacketService::EMSClassUnknown;
       
   188 
       
   189     // If Gpds is suspended this flag is ETrue, otherwise EFalse
       
   190     iSuspended = EFalse;
       
   191 
       
   192     }
       
   193 
       
   194 //----------------------------------------------------------------------------
       
   195 // CMmPacketServiceTsy::Init
       
   196 // Initialisation method that is called from ETel Server.
       
   197 //----------------------------------------------------------------------------
       
   198 //
       
   199 void CMmPacketServiceTsy::Init()
       
   200     {
       
   201     }
       
   202 
       
   203 //----------------------------------------------------------------------------
       
   204 // CMmPacketServiceTsy::CustomTsy
       
   205 // Returns a pointer to Custom TSY object.
       
   206 // return custom tsy owned by phone tsy
       
   207 //----------------------------------------------------------------------------
       
   208 //
       
   209 CMmCustomTsy* CMmPacketServiceTsy::CustomTsy() const
       
   210     {
       
   211     // Return custom tsy
       
   212     return iMmPhone->GetCustomTsy();
       
   213     }
       
   214 
       
   215 //----------------------------------------------------------------------------
       
   216 // CMmPacketServiceTsy::ActivePacketServiceExtension
       
   217 // Returns a pointer to the active packet service extension.
       
   218 // The packet data extension implements functionality that is specific for
       
   219 // selected mode. There should always be some extension active.
       
   220 //----------------------------------------------------------------------------
       
   221 //
       
   222 CMmPacketServiceGsmWcdmaExt* CMmPacketServiceTsy::ActivePacketServiceExtension()
       
   223     {
       
   224     // Return active packet service extension
       
   225     return iMmPacketServiceGsmWcdmaExt;
       
   226     }
       
   227 
       
   228 //----------------------------------------------------------------------------
       
   229 // CMmPacketServiceTsy::TsyReqHandleStore
       
   230 // Returns a pointer to the tsy request handle store.
       
   231 // return tsy request handle store
       
   232 //----------------------------------------------------------------------------
       
   233 //
       
   234 CMmTsyReqHandleStore* CMmPacketServiceTsy::TsyReqHandleStore()
       
   235     {
       
   236     // Return tsy request handle store
       
   237     return iTsyReqHandleStore;
       
   238     }
       
   239 
       
   240 //----------------------------------------------------------------------------
       
   241 // CMmPacketServiceTsy::IsContextStatusActive
       
   242 // Checks if context status is active from service point of view
       
   243 //----------------------------------------------------------------------------
       
   244 //
       
   245 TBool CMmPacketServiceTsy::IsContextStatusActive(
       
   246     const RPacketContext::TContextStatus aContextStatus  ) const
       
   247     {
       
   248 
       
   249     if ( ( RPacketContext::EStatusActive == aContextStatus ) ||
       
   250          ( RPacketContext::EStatusDeactivating == aContextStatus ) )
       
   251         {
       
   252         // Context is active from the service point of view
       
   253         return ETrue;
       
   254         }
       
   255 
       
   256     return EFalse;
       
   257     }
       
   258 
       
   259 //----------------------------------------------------------------------------
       
   260 // CMmPacketServiceTsy::UpdateAttachedPacketStatus
       
   261 // Sets service status to active or attached and completes status changed
       
   262 // notification to the client if needed.
       
   263 //----------------------------------------------------------------------------
       
   264 //
       
   265 void CMmPacketServiceTsy::UpdateAttachedPacketStatus(
       
   266     const TBool aIsActiveContext ) //is context active
       
   267     {
       
   268     TBool isActive( aIsActiveContext );
       
   269     
       
   270     // If external context exist and there are no active internal context
       
   271     if ( iDialUpContext != NULL && isActive == EFalse )
       
   272         {
       
   273         // If external context is active then active context found
       
   274         isActive = IsContextStatusActive( iDialUpContext->ContextStatus() );
       
   275         } 
       
   276 
       
   277     // If external context exist and there are no active internal context
       
   278     if ( iSecondaryDialUpContext != NULL && isActive == EFalse )
       
   279         {
       
   280         // If external context is active then active context found
       
   281         isActive = IsContextStatusActive( 
       
   282             iSecondaryDialUpContext->ContextStatus() );
       
   283         }
       
   284 
       
   285     if ( isActive && ( RPacketService::EStatusActive !=
       
   286          iInternalSavedData.iServiceStatus ) )
       
   287         {
       
   288         // Complete status change notification to the client and
       
   289         // set service status EStatusActive
       
   290         CMmPacketServiceTsy::CompleteNotifyStatusChange(
       
   291 		    RPacketService::EStatusActive, KErrNone );
       
   292 
       
   293         }
       
   294     else if ( !isActive && ( RPacketService::EStatusAttached !=
       
   295               iInternalSavedData.iServiceStatus ) )
       
   296         {
       
   297 
       
   298         // Complete status change notification to the client and
       
   299         // set service status EStatusAttached
       
   300 		CMmPacketServiceTsy::CompleteNotifyStatusChange(
       
   301 		    RPacketService::EStatusAttached, KErrNone );
       
   302 
       
   303         }
       
   304 TFLOGSTRING2("TSY: CMmPacketServiceTsy::UpdateAttachedPacketStatus. Service Status: %d", iInternalSavedData.iServiceStatus );
       
   305     }
       
   306 
       
   307 //----------------------------------------------------------------------------
       
   308 // CMmPacketServiceTsy::CompletePacketStatusChanged
       
   309 // Called from active extension to notify service that transfer status
       
   310 // is changed.
       
   311 //----------------------------------------------------------------------------
       
   312 //
       
   313 void CMmPacketServiceTsy::CompletePacketStatusChanged(
       
   314     CMmDataPackage* aDataPackage,
       
   315     TInt aErrorCode )
       
   316     {
       
   317 	RPacketService::TStatus packetStatus;
       
   318 	TBool isresumed;
       
   319 	TBool isActiveContext( EFalse );
       
   320 
       
   321 	//Pack data
       
   322 	aDataPackage->UnPackData( packetStatus, isresumed  );
       
   323 
       
   324     // Get number of created contexts
       
   325     const TInt numberOfContext( iPacketContextList->NumberOfContexts() );
       
   326 
       
   327     if ( isresumed )
       
   328         {
       
   329         // If current status is suspended
       
   330         if ( iSuspended )
       
   331             {
       
   332 
       
   333             CMmPacketContextTsy* packetContext;
       
   334             CMmMBMSContextTsy* mbmsContext;
       
   335 
       
   336             // check pdp context's
       
   337             for ( TInt i = 0; i < numberOfContext; i++ )
       
   338                 {
       
   339                 // Get context by index from context list
       
   340                 packetContext = iPacketContextList->PacketContextByIndex( i );
       
   341 
       
   342                 if ( NULL != packetContext )
       
   343                     {
       
   344                     // Inform context that service resumed from suspend
       
   345                     packetContext->ContextResumed();
       
   346                     }
       
   347                 }
       
   348                 
       
   349             // check mbms context's
       
   350             for ( TInt i = 0; i < iMBMSContextList->NumberOfContexts(); i++ )
       
   351                 {
       
   352                 // Get context by index from context list
       
   353                 mbmsContext = iMBMSContextList->ContextByIndex( i );
       
   354 
       
   355                 if ( NULL != mbmsContext )
       
   356                     {
       
   357                     // Inform context that service resumed from suspend
       
   358                     mbmsContext->ContextResumed();
       
   359                     }
       
   360                 }                
       
   361 
       
   362             if ( iDialUpContext != NULL )
       
   363                 {
       
   364 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompletePacketStatusChanged.  DialUp Context Resumed" );
       
   365 
       
   366                 iDialUpContext->ContextResumed();
       
   367                 }
       
   368 
       
   369             if ( iSecondaryDialUpContext != NULL )
       
   370                 {
       
   371 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompletePacketStatusChanged. Secondary DialUp Context Resumed" );
       
   372 
       
   373                 iSecondaryDialUpContext->ContextResumed();
       
   374                 }
       
   375 
       
   376             // Get service status before suspend
       
   377             packetStatus = iInternalSavedData.iServiceStatusBeforeSuspend;
       
   378             // Current status is not suspended
       
   379             iSuspended = EFalse;
       
   380 
       
   381             }
       
   382         else
       
   383             {
       
   384             // Resumed without suspend, continue with current status
       
   385             packetStatus = iInternalSavedData.iServiceStatus;
       
   386             }
       
   387         }
       
   388 
       
   389     // If current status is not suspended or
       
   390     // current status is suspended and new status is unattached
       
   391     if ( !iSuspended || ( RPacketService::EStatusUnattached == packetStatus ) )
       
   392         {
       
   393         switch ( packetStatus )
       
   394             {
       
   395             case RPacketService::EStatusUnattached:
       
   396                 if ( iSuspended )
       
   397                     {
       
   398                     // If previous status was suspended it is not valid 
       
   399                     // anymore
       
   400                     iSuspended = EFalse;
       
   401                     }
       
   402 
       
   403                 // Complete status change notification with EStatusUnattached
       
   404                 CMmPacketServiceTsy::CompleteNotifyStatusChange(
       
   405 				    RPacketService::EStatusUnattached, aErrorCode );
       
   406 
       
   407                 break;
       
   408             case RPacketService::EStatusAttached:
       
   409             case RPacketService::EStatusActive:
       
   410                 CMmPacketContextTsy* packetContext;
       
   411 
       
   412                 for ( TInt i = 0; i < numberOfContext; i++ )
       
   413                     {
       
   414                     packetContext =
       
   415                         iPacketContextList->PacketContextByIndex( i );
       
   416 
       
   417                     // If no active context found yet
       
   418                     if ( NULL != packetContext )
       
   419                         {
       
   420                         // Get context status
       
   421                         RPacketContext::TContextStatus contextStatus =
       
   422                             packetContext->ContextStatus();
       
   423 
       
   424                         // Check if context is active ( from service point 
       
   425                         // of view )
       
   426                         isActiveContext =
       
   427                             IsContextStatusActive( contextStatus );
       
   428                         }
       
   429                     if ( isActiveContext )
       
   430                         {
       
   431                         // Active context found, break
       
   432                         i = numberOfContext;
       
   433                         }
       
   434                     }
       
   435                     
       
   436                 // no active pdp context's, check if any mbms context is active
       
   437                 if( !isActiveContext )
       
   438                     {
       
   439                     CMmMBMSContextTsy* mbmsContext;
       
   440                     
       
   441                     // check mbms context's
       
   442                     for ( TInt i = 0; i < iMBMSContextList->NumberOfContexts(); i++ )
       
   443                         {
       
   444                         // Get context by index from context list
       
   445                         mbmsContext = iMBMSContextList->ContextByIndex( i );
       
   446 
       
   447                         if ( NULL != mbmsContext )
       
   448                             {
       
   449                             // Get context status
       
   450                             RPacketContext::TContextStatus contextStatus =
       
   451                                 mbmsContext->ContextStatus();
       
   452 
       
   453                             // Check if context is active ( from service point 
       
   454                             // of view )
       
   455                             isActiveContext =
       
   456                                 IsContextStatusActive( contextStatus );
       
   457                             }
       
   458                         if ( isActiveContext )
       
   459                             {
       
   460                             // Active context found, break
       
   461                             i = iMBMSContextList->NumberOfContexts();                                                   
       
   462                             }  
       
   463                         }
       
   464                     }
       
   465 
       
   466                 // Update service status
       
   467                 UpdateAttachedPacketStatus( isActiveContext );
       
   468 
       
   469                 break;
       
   470             case RPacketService::EStatusSuspended:
       
   471                 if ( !iSuspended && ( RPacketService::EStatusUnattached !=
       
   472                      iInternalSavedData.iServiceStatus ) )
       
   473                     {
       
   474                     // Save status before suspend internally
       
   475                     iInternalSavedData.iServiceStatusBeforeSuspend =
       
   476                         iInternalSavedData.iServiceStatus;
       
   477 
       
   478                     // Set iSuspended to be ETrue
       
   479                     iSuspended = ETrue;
       
   480 
       
   481                     CMmPacketContextTsy* packetContext;
       
   482 
       
   483                     for ( TInt i = 0; i < numberOfContext; i++ )
       
   484                         {
       
   485                         // Get next context
       
   486                         packetContext =
       
   487                             iPacketContextList->PacketContextByIndex( i );
       
   488 
       
   489                         if ( NULL != packetContext )
       
   490                             {
       
   491                             // Inform context that service is suspend
       
   492                             packetContext->ContextSuspended();
       
   493                             }
       
   494                         }
       
   495                     CMmMBMSContextTsy* mbmsContext;
       
   496                     
       
   497                     // check mbms context's
       
   498                     for ( TInt i = 0; i < iMBMSContextList->NumberOfContexts(); i++ )
       
   499                         {
       
   500                         // Get context by index from context list
       
   501                         mbmsContext = iMBMSContextList->ContextByIndex( i );
       
   502 
       
   503                         if ( NULL != mbmsContext )
       
   504                             {
       
   505                             // Inform context that service is suspend
       
   506                             mbmsContext->ContextSuspended();
       
   507                             }
       
   508                         }                       
       
   509 
       
   510                     if ( iDialUpContext != NULL )
       
   511                         {
       
   512 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompletePacketStatusChanged.  DialUp Context Suspended" );
       
   513                         iDialUpContext->ContextSuspended();
       
   514                         }
       
   515 
       
   516                     if ( iSecondaryDialUpContext != NULL )
       
   517                         {
       
   518 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompletePacketStatusChanged.  DialUp Context Suspended" );
       
   519                         iSecondaryDialUpContext->ContextSuspended();
       
   520                         }
       
   521 
       
   522                     // Complete status change notification with
       
   523                     // EStatusSuspended
       
   524                     CMmPacketServiceTsy::CompleteNotifyStatusChange(
       
   525                         RPacketService::EStatusSuspended, aErrorCode );
       
   526 
       
   527                     }
       
   528 
       
   529                 break;
       
   530             default:
       
   531                 break;
       
   532             }
       
   533         }
       
   534 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompletePacketStatusChanged. Service Status: %d", iInternalSavedData.iServiceStatus );
       
   535     }
       
   536 
       
   537 //----------------------------------------------------------------------------
       
   538 // CMmPacketServiceTsy::ContextStatusChanged
       
   539 // Context status is changed from the Service point of view.
       
   540 // Called from CMmPacketContextTsy to notify service that context status is
       
   541 // changed to inactive, activate or deleted state. These states indicate that
       
   542 // context is changed to inactive or active state from the Packet Service
       
   543 // point of view.
       
   544 //----------------------------------------------------------------------------
       
   545 //
       
   546 void CMmPacketServiceTsy::ContextStatusChanged(
       
   547     const RPacketContext::TContextStatus aContextStatus )
       
   548     {
       
   549 TFLOGSTRING2("TSY: CMmPacketServiceTsy::ContextStatusChanged. Context Status: %d", aContextStatus );
       
   550 
       
   551     if ( !iSuspended && ( RPacketService::EStatusUnattached !=
       
   552          iInternalSavedData.iServiceStatus ) )
       
   553         {
       
   554 
       
   555         TBool isActiveContext( EFalse );
       
   556 
       
   557         if ( ( RPacketContext::EStatusInactive == aContextStatus ) ||
       
   558              ( RPacketContext::EStatusDeleted == aContextStatus ) )
       
   559             {
       
   560             const TInt numberOfContext(
       
   561                 iPacketContextList->NumberOfContexts() );
       
   562 
       
   563             RPacketContext::TContextStatus contextStatus;
       
   564 
       
   565             for ( TInt i = 0; i < numberOfContext; i++ )
       
   566                 {
       
   567                 TInt ret( iPacketContextList->GetContextStatusByIndex(
       
   568                     i, contextStatus ) );
       
   569 
       
   570                 if ( KErrNone == ret )
       
   571                     {
       
   572                     isActiveContext = IsContextStatusActive( contextStatus );
       
   573 
       
   574                     if ( isActiveContext )
       
   575                         {
       
   576                         // Active context found, break
       
   577                         i = numberOfContext;
       
   578                         }
       
   579                     }
       
   580                 }
       
   581             }
       
   582 
       
   583         else if ( RPacketContext::EStatusActive == aContextStatus )
       
   584             {
       
   585 
       
   586             isActiveContext = ETrue;
       
   587 
       
   588             }
       
   589 
       
   590         UpdateAttachedPacketStatus( isActiveContext );
       
   591         }
       
   592     }
       
   593 
       
   594 //----------------------------------------------------------------------------
       
   595 // CMmPacketServiceTsy::PreferredBearerChanged
       
   596 // Preferred bearer has been changed save new
       
   597 //----------------------------------------------------------------------------
       
   598 //
       
   599 void CMmPacketServiceTsy::PreferredBearerChanged(
       
   600     CMmDataPackage* aPackage )      
       
   601     {
       
   602 	RPacketService::TPreferredBearer preferredBearer;
       
   603 
       
   604 	aPackage->UnPackData( preferredBearer );
       
   605 
       
   606 TFLOGSTRING2("TSY: CMmPacketServiceTsy::PreferredBearerChanged. PreferredBearer: %d", preferredBearer );
       
   607 
       
   608     iInternalSavedData.iPreferredBearer = preferredBearer;
       
   609 
       
   610     }
       
   611 
       
   612 //----------------------------------------------------------------------------
       
   613 // CMmPacketServiceTsy::Attach
       
   614 // Starts asynchronous attach request to the network.
       
   615 // This function will cause the phone to attempt an attach to the packet
       
   616 // network, if it is not already attached.  If it is, the error
       
   617 // KErrAlreadyExists should be returned.
       
   618 //----------------------------------------------------------------------------
       
   619 //
       
   620 TInt CMmPacketServiceTsy::AttachL()
       
   621     {
       
   622 TFLOGSTRING("TSY: CMmPacketServiceTsy::AttachL." );
       
   623 
       
   624     TInt ret( KErrAlreadyExists );
       
   625 
       
   626     if ( RPacketService::EStatusUnattached ==
       
   627          iInternalSavedData.iServiceStatus )
       
   628         {
       
   629 
       
   630         const TTsyReqHandle attachHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
   631             EMultimodePacketServiceAttach ) );
       
   632 
       
   633         if ( EMultimodePacketServiceReqHandleUnknown != attachHandle )
       
   634             {
       
   635             ret = KErrServerBusy;
       
   636             }
       
   637         else
       
   638             {
       
   639             // Attach
       
   640             ret = iMmPacketServiceGsmWcdmaExt->AttachL();
       
   641 
       
   642             if ( KErrNone == ret )
       
   643                 {
       
   644                 // Set request handle
       
   645                 iReqHandleType = EMultimodePacketServiceAttach;
       
   646                 }
       
   647             else
       
   648                 {
       
   649                 // Sending to the phonet failed for some reason
       
   650                 ret = CMmCommonStaticUtility::EpocErrorCode(
       
   651                     KErrGeneral, KErrGsmMMNetworkFailure );
       
   652                 }
       
   653             }
       
   654         }
       
   655 
       
   656     return ret;
       
   657     }
       
   658 
       
   659 //----------------------------------------------------------------------------
       
   660 // CMmPacketServiceTsy::CompleteAttach
       
   661 // Completes asynchronous attach request.
       
   662 //----------------------------------------------------------------------------
       
   663 //
       
   664 void CMmPacketServiceTsy::CompleteAttach(
       
   665     const TInt aError )  //error value
       
   666     {
       
   667 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteAttach. Error Value: %d", aError );
       
   668 
       
   669     // Reset request handle. Returns the deleted request handle
       
   670     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
   671         EMultimodePacketServiceAttach ) );
       
   672 
       
   673     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
   674         {
       
   675         // Complete the client request
       
   676         CMmPacketServiceTsy::ReqCompleted( reqHandle, aError );
       
   677         }
       
   678     }
       
   679 
       
   680 //----------------------------------------------------------------------------
       
   681 // CMmPacketServiceTsy::Detach
       
   682 // Starts asynchronous detach request to the network.
       
   683 // This function will cause the phone to attempt to detach from the packet
       
   684 // network, if it is not already detached. If it is, the error
       
   685 // KErrAlreadyExists should be returned. If at least one context is active the
       
   686 // error KErrInUse should be returned.
       
   687 //----------------------------------------------------------------------------
       
   688 //
       
   689 TInt CMmPacketServiceTsy::DetachL()
       
   690     {
       
   691 TFLOGSTRING("TSY: CMmPacketServiceTsy::DetachL." );
       
   692 
       
   693     TInt ret( KErrAlreadyExists );
       
   694 
       
   695     if ( RPacketService::EStatusUnattached !=
       
   696         iInternalSavedData.iServiceStatus )
       
   697         {
       
   698 
       
   699         // Get number of created contexts
       
   700         const TInt numberOfContext( iPacketContextList->NumberOfContexts() );
       
   701         RPacketContext::TContextStatus contextStatus;
       
   702 
       
   703         for ( TInt i = 0; i < numberOfContext; i++ )
       
   704             {
       
   705             ret = iPacketContextList->GetContextStatusByIndex(
       
   706                 i, contextStatus );
       
   707 
       
   708             if ( KErrNone == ret )
       
   709                 {
       
   710                 if ( IsContextStatusActive( contextStatus ) )
       
   711                     {
       
   712                     // Atleast one of the contexts is active.
       
   713                     ret = KErrInUse;
       
   714                     i= numberOfContext;
       
   715                     }
       
   716                 }
       
   717             }
       
   718 
       
   719         // If not KErrInUse, no active contexts found and detach can be done
       
   720         if ( KErrInUse != ret )
       
   721             {
       
   722 
       
   723             const TTsyReqHandle reqHandle( iTsyReqHandleStore->
       
   724                 GetTsyReqHandle( EMultimodePacketServiceDetach ) );
       
   725 
       
   726             if ( EMultimodePacketServiceReqHandleUnknown == reqHandle )
       
   727                 {
       
   728                 // Detach
       
   729                 ret = iMmPacketServiceGsmWcdmaExt->DetachL();
       
   730 
       
   731                 if ( KErrNone == ret )
       
   732                     {
       
   733                     // Set request handle
       
   734                     iReqHandleType = EMultimodePacketServiceDetach;
       
   735                     }
       
   736                 else
       
   737                     {
       
   738                     // Sending to the phonet failed for some reason
       
   739                     ret = CMmCommonStaticUtility::EpocErrorCode(
       
   740                         KErrGeneral, KErrGsmMMNetworkFailure );
       
   741                     }
       
   742                 }
       
   743             else
       
   744                 {
       
   745                 // The request is already in processing because of previous
       
   746                 // request. Complete request with KErrServerBusy informing the
       
   747                 // client about the situation.
       
   748                 ret = KErrServerBusy;
       
   749                 }
       
   750             }
       
   751         }
       
   752 
       
   753     return ret;
       
   754     }
       
   755 
       
   756 //----------------------------------------------------------------------------
       
   757 // CMmPacketServiceTsy::CompleteDetachL
       
   758 // Completes asynchronous detach request.
       
   759 //----------------------------------------------------------------------------
       
   760 //
       
   761 void CMmPacketServiceTsy::CompleteDetachL(
       
   762     const TInt aError ) 
       
   763     {
       
   764 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteDetachL. Error Value: %d", aError );
       
   765 
       
   766     // Reset request handle. Returns the deleted request handle
       
   767     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
   768         EMultimodePacketServiceDetach ) );
       
   769 
       
   770     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
   771         {
       
   772         // Complete the client request
       
   773         CMmPacketServiceTsy::ReqCompleted( reqHandle, aError );
       
   774         }
       
   775     if ( RPacketService::EAttachWhenPossible == iAttachMode )
       
   776         {
       
   777         SetAttachModeL( &iAttachMode );
       
   778         }
       
   779     }
       
   780     
       
   781 //----------------------------------------------------------------------------
       
   782 // CMmPacketServiceTsy::EnumerateContexts
       
   783 // Enumerates contexts.
       
   784 // This function will retrieve both the number of opened contexts in the TSY,
       
   785 // the aCount parameter containing this value on completion of the function,
       
   786 // and the maximum possible number of contexts, passed back in the aMaxAllowed
       
   787 // parameter. Note that this is not the maximum number of simultaneously
       
   788 // active contexts, but the total number allowed.
       
   789 //----------------------------------------------------------------------------
       
   790 //
       
   791 TInt CMmPacketServiceTsy::EnumerateContexts(
       
   792     TInt* const aCount,    
       
   793     TInt* const aMaxAllowed ) 
       
   794     {
       
   795     *aCount = iPacketContextList->NumberOfContexts();
       
   796     *aMaxAllowed = KMmMaxNumberOfContexts;
       
   797 
       
   798 TFLOGSTRING3("TSY: CMmPacketServiceTsy::EnumerateContexts. Count: %d Max Allowed: %d", *aCount, *aMaxAllowed );
       
   799     // Complete the request with KErrNone
       
   800     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
   801 
       
   802     return KErrNone;
       
   803     }
       
   804 
       
   805 //----------------------------------------------------------------------------
       
   806 // CMmPacketServiceTsy::GetAttachMode
       
   807 // Retrieves the current mode of GPRS Attach operation.
       
   808 //----------------------------------------------------------------------------
       
   809 //
       
   810 TInt CMmPacketServiceTsy::GetAttachModeL(
       
   811     RPacketService::TAttachMode* const aMode ) 
       
   812     {
       
   813 TFLOGSTRING2("TSY: CMmPacketServiceTsy::GetAttachModeL. Mode:%d", *aMode );
       
   814 
       
   815     TInt ret( KErrServerBusy );
       
   816 
       
   817     const TTsyReqHandle reqHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
   818         EMultimodePacketServiceGetAttachMode ) );
       
   819 
       
   820     if ( EMultimodePacketServiceReqHandleUnknown == reqHandle )
       
   821         {
       
   822         // Get attach mode
       
   823         ret = iMmPacketServiceGsmWcdmaExt->GetAttachModeL();
       
   824 
       
   825         if ( KErrNone == ret )
       
   826             {
       
   827             // Save pointer to aMode internally
       
   828             iTemporarySavedData.iGetAttachMode = aMode;
       
   829             // Set req handle
       
   830             iReqHandleType = EMultimodePacketServiceGetAttachMode;
       
   831             }
       
   832         }
       
   833     return ret;
       
   834     }
       
   835 
       
   836 //----------------------------------------------------------------------------
       
   837 // CMmPacketServiceTsy::CompleteGetAttachMode
       
   838 // Completes asynchronous attach request.
       
   839 //----------------------------------------------------------------------------
       
   840 //
       
   841 void CMmPacketServiceTsy::CompleteGetAttachMode(
       
   842     const RPacketService::TAttachMode aAttachMode, TInt aResult ) 
       
   843     {
       
   844 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteGetAttachMode. Attach Mode: %d", aAttachMode );
       
   845 
       
   846     // Reset request handle. Returns the deleted request handle
       
   847     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
   848         EMultimodePacketServiceGetAttachMode ) );
       
   849 
       
   850     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
   851         {
       
   852         *iTemporarySavedData.iGetAttachMode = aAttachMode;
       
   853         iTemporarySavedData.iGetAttachMode = NULL;
       
   854 
       
   855         // Complete the client request
       
   856         CMmPacketServiceTsy::ReqCompleted( reqHandle, aResult );
       
   857         }
       
   858     }
       
   859 
       
   860 //----------------------------------------------------------------------------
       
   861 // CMmPacketServiceTsy::GetContextInfo
       
   862 // Gets Context info of the context defined by aIndex.
       
   863 //----------------------------------------------------------------------------
       
   864 //
       
   865 TInt CMmPacketServiceTsy::GetContextInfo(
       
   866     const TInt* const aIndex,                 
       
   867     RPacketService::TContextInfo* const aInfo ) 
       
   868     {
       
   869     TInt ret( KErrNone );
       
   870 
       
   871     // Call ContextStatusByIndex() to set context status to aInfo->iStatus
       
   872     ret = iPacketContextList->GetContextStatusByIndex(
       
   873         *aIndex, aInfo->iStatus );
       
   874 
       
   875     if ( KErrNone == ret )
       
   876         {
       
   877         // Call GetContextNameByIndex() to set context name to aInfo->iName
       
   878         ret = iPacketContextList->GetContextNameByIndex(
       
   879             *aIndex, aInfo->iName );
       
   880 
       
   881 TFLOGSTRING3("TSY: CMmPacketServiceTsy::GetContextInfo. Context Status: %d Context Name: %S", aInfo->iStatus, &aInfo->iName );
       
   882         }
       
   883 
       
   884     // Complete request with ret
       
   885     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, ret );
       
   886     
       
   887     return KErrNone;
       
   888     }
       
   889 
       
   890 //----------------------------------------------------------------------------
       
   891 // CMmPacketServiceTsy::GetDynamicCaps
       
   892 // Returns the dynamic capabilities of the phone.
       
   893 // call active extension to get dynamic capabilities to aCaps
       
   894 // complete request with KErrNone
       
   895 // return KErrNone
       
   896 //----------------------------------------------------------------------------
       
   897 //
       
   898 TInt CMmPacketServiceTsy::GetDynamicCaps(
       
   899     RPacketService::TDynamicCapsFlags* const aCaps ) 
       
   900     {
       
   901     // Call DynamicCaps() from extension
       
   902     iMmPacketServiceGsmWcdmaExt->GetDynamicCaps( aCaps );
       
   903 TFLOGSTRING("TSY: CMmPacketServiceTsy::GetDynamicCaps." );
       
   904 
       
   905     // Complete the request with KErrNone
       
   906     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
   907     
       
   908     return KErrNone;
       
   909     }
       
   910 
       
   911 //----------------------------------------------------------------------------
       
   912 // CMmPacketServiceTsy::GetMSClass
       
   913 // Gets current and maximum value of the Mobile Station Class.
       
   914 // This function will retrieve both the current class and the highest class of
       
   915 // the mobile station. The parameters aCurrentClass and aMaxClass may take one
       
   916 // of the following values which are ordered in terms of class from highest to
       
   917 // lowest:
       
   918 //----------------------------------------------------------------------------
       
   919 //
       
   920 TInt CMmPacketServiceTsy::GetMSClass(
       
   921     RPacketService::TMSClass* const aCurrentClass, 
       
   922     RPacketService::TMSClass* const aMaxClass )    
       
   923     {
       
   924     *aCurrentClass = iInternalSavedData.iMsClass;
       
   925     *aMaxClass = KMaxMsClass;
       
   926 TFLOGSTRING3("TSY: CMmPacketServiceTsy::GetMSClass. Current Class: %d Max Class: %d", *aCurrentClass, *aMaxClass );
       
   927 
       
   928     // Complete the request with KErrNone
       
   929     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
   930 
       
   931     return KErrNone;
       
   932     }
       
   933 
       
   934 //----------------------------------------------------------------------------
       
   935 // CMmPacketServiceTsy::GetNtwkRegStatus
       
   936 // Gets network registration status.
       
   937 // This function allows the client to retrieve the current registration status
       
   938 // of the phone on the packet network as defined by the enum
       
   939 // TRegistrationStatus.
       
   940 //------------------------------------------------------------------------------
       
   941 //
       
   942 TInt CMmPacketServiceTsy::GetNtwkRegStatusL(
       
   943     RPacketService::TRegistrationStatus* const aRegistrationStatus ) 
       
   944     {
       
   945 TFLOGSTRING2("TSY: CMmPacketServiceTsy::GetNtwkRegStatusL. Tsy Req Handle: %d", iTsyReqHandle );
       
   946 
       
   947     const TTsyReqHandle regHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
   948         EMultimodePacketServiceGetNtwkRegStatus ) );
       
   949 
       
   950     TInt ret( KErrServerBusy );
       
   951 
       
   952     if ( EMultimodePacketServiceReqHandleUnknown == regHandle )
       
   953         {
       
   954 
       
   955         // Get network registration status
       
   956         ret = iMmPacketServiceGsmWcdmaExt->GetNtwkRegStatusL();
       
   957 
       
   958         if ( KErrNone == ret )
       
   959             {
       
   960             iRegistrationStatus = aRegistrationStatus;
       
   961             // Set request handle type
       
   962             iReqHandleType = EMultimodePacketServiceGetNtwkRegStatus;
       
   963             }
       
   964         }
       
   965 
       
   966     return ret;
       
   967     }
       
   968 
       
   969 //----------------------------------------------------------------------------
       
   970 // CMmPacketServiceTsy::CompleteGetNtwkRegStatus
       
   971 // Completes get network registration status request.
       
   972 //----------------------------------------------------------------------------
       
   973 //
       
   974 void CMmPacketServiceTsy::CompleteGetNtwkRegStatus(
       
   975     const RPacketService::TRegistrationStatus aRegistrationStatus,
       
   976     const TInt aError )                             
       
   977     {
       
   978     // Reset request handle. Returns the deleted request handle
       
   979     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
   980         EMultimodePacketServiceGetNtwkRegStatus ) );
       
   981 
       
   982     // If request handle ok
       
   983     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
   984         {
       
   985 
       
   986         if ( KErrNone == aError )
       
   987             {
       
   988             *iRegistrationStatus = aRegistrationStatus;
       
   989             iRegistrationStatus = NULL;
       
   990             }
       
   991         // Complete the client request
       
   992         CMmPacketServiceTsy::ReqCompleted( reqHandle, aError );
       
   993 
       
   994         }
       
   995     else
       
   996         {
       
   997         // Request was sent during initialisation from active extension
       
   998         CMmPacketServiceTsy::CompleteNotifyChangeOfNtwkRegStatus(
       
   999 												aRegistrationStatus );
       
  1000         }
       
  1001 TFLOGSTRING3("TSY: CMmPacketServiceTsy::CompleteGetNtwkRegStatus. TSY Req Handle: %d Registration Status: %d", reqHandle, aRegistrationStatus );
       
  1002     }
       
  1003 
       
  1004 //----------------------------------------------------------------------------
       
  1005 // CMmPacketServiceTsy::GetPreferredBearer
       
  1006 // Returns preferred bearer.
       
  1007 // This function will retrieve the currently selected preferred bearer to
       
  1008 // attach to when in Class C operation. The TSY should cache this value, so
       
  1009 // the function should return quickly meaning there is no need for an
       
  1010 // asynchronous version.
       
  1011 //----------------------------------------------------------------------------
       
  1012 //
       
  1013 TInt CMmPacketServiceTsy::GetPreferredBearer(
       
  1014     RPacketService::TPreferredBearer* const aBearer )   
       
  1015     {
       
  1016     *aBearer = iInternalSavedData.iPreferredBearer;
       
  1017 TFLOGSTRING2("TSY: CMmPacketServiceTsy::GetPreferredBearer. Preferred Bearer: %d", *aBearer );
       
  1018 
       
  1019     // Complete the request with KErrNone
       
  1020     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  1021     
       
  1022     return KErrNone;
       
  1023     }
       
  1024 
       
  1025 //----------------------------------------------------------------------------
       
  1026 // CMmPacketServiceTsy::GetStaticCaps
       
  1027 // Retrieves those capabilities of the TSY that are constant.
       
  1028 // call active extension to set static capabilities to aCaps
       
  1029 //----------------------------------------------------------------------------
       
  1030 //
       
  1031 TInt CMmPacketServiceTsy::GetStaticCaps(
       
  1032     TUint* const aCaps,                       
       
  1033     const RPacketContext::TProtocolType* const aPdpType) 
       
  1034     {
       
  1035     TInt ret = KErrNone;
       
  1036     
       
  1037     switch (*aPdpType)
       
  1038         {
       
  1039         case RPacketContext::EPdpTypeIPv4:
       
  1040         case RPacketContext::EPdpTypeIPv6:
       
  1041         case RPacketContext::EPdpTypeX25:
       
  1042         case RPacketContext::EPdpTypePPP:
       
  1043         case RPacketContext::EPdpTypeCDPD:
       
  1044             iMmPacketServiceGsmWcdmaExt->GetStaticCaps( aCaps );
       
  1045             TFLOGSTRING("TSY: CMmPacketServiceTsy::GetStaticCaps." );
       
  1046             
       
  1047             // Complete the request with KErrNone
       
  1048             CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, ret );
       
  1049             break;
       
  1050         default:
       
  1051             ret = KErrArgument;
       
  1052             break;
       
  1053         }
       
  1054     
       
  1055     return ret;
       
  1056     }
       
  1057 
       
  1058 //----------------------------------------------------------------------------
       
  1059 // CMmPacketServiceTsy::GetStatus
       
  1060 // Returns current status of the packet service.
       
  1061 //----------------------------------------------------------------------------
       
  1062 //
       
  1063 TInt CMmPacketServiceTsy::GetStatus(
       
  1064     RPacketService::TStatus* const aPacketStatus )   
       
  1065     {
       
  1066     *aPacketStatus = iInternalSavedData.iServiceStatus;
       
  1067 
       
  1068 TFLOGSTRING2("TSY: CMmPacketServiceTsy::GetStatus. Service Status: %d", *aPacketStatus );
       
  1069 
       
  1070     // Complete the request with KErrNone
       
  1071     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  1072     
       
  1073     return KErrNone;
       
  1074     }
       
  1075 
       
  1076 //----------------------------------------------------------------------------
       
  1077 // CMmPacketServiceTsy::NotifyChangeOfNtwkRegStatus
       
  1078 // Requests notification of network registration status change.
       
  1079 // Allows a client to be notified whenever a change in the status of the
       
  1080 // packet network registration is detected.
       
  1081 //----------------------------------------------------------------------------
       
  1082 //
       
  1083 TInt CMmPacketServiceTsy::NotifyChangeOfNtwkRegStatus(
       
  1084     RPacketService::TRegistrationStatus* const aRegistrationStatus )
       
  1085     {
       
  1086 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyChangeOfNtwkRegStatus." );
       
  1087 
       
  1088     // Set request handle and save pointer to aRegistrationStatus
       
  1089     iNotifyDataPointers.iChangeOfNtwkRegStatus = aRegistrationStatus;
       
  1090     iReqHandleType =  EMultimodePacketServiceNotifyNtwkRegStatusChange;
       
  1091 
       
  1092     return KErrNone;
       
  1093     }
       
  1094 
       
  1095 //----------------------------------------------------------------------------
       
  1096 // CMmPacketServiceTsy::CompleteNotifyChangeOfNtwkRegStatus
       
  1097 // Completes notify change of ntwk registration status to client.
       
  1098 //----------------------------------------------------------------------------
       
  1099 //
       
  1100 void CMmPacketServiceTsy::CompleteNotifyChangeOfNtwkRegStatus(
       
  1101     const RPacketService::TRegistrationStatus aRegistrationStatus )
       
  1102     {
       
  1103 TFLOGSTRING3("TSY: CMmPacketServiceTsy::CompleteNotifyChangeOfNtwkRegStatus. Current reg Status: %d New reg Status: %d", iInternalSavedData.iRegistrationStatus, aRegistrationStatus );
       
  1104 
       
  1105     // If registration status changed
       
  1106     if ( aRegistrationStatus != iInternalSavedData.iRegistrationStatus )
       
  1107         {
       
  1108         // Save new status internally
       
  1109         iInternalSavedData.iRegistrationStatus = aRegistrationStatus;
       
  1110 
       
  1111         // Reset request handle. Returns the deleted request handle
       
  1112         const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1113             EMultimodePacketServiceNotifyNtwkRegStatusChange ) );
       
  1114 
       
  1115         // If notification is requested by client
       
  1116         if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1117             {
       
  1118             // Set aRegistrationStatus to the etel side memory
       
  1119             *iNotifyDataPointers.iChangeOfNtwkRegStatus = aRegistrationStatus;
       
  1120             iNotifyDataPointers.iChangeOfNtwkRegStatus = NULL;
       
  1121 
       
  1122             // Complete request with KErrNone
       
  1123             CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1124             }
       
  1125         }
       
  1126     }
       
  1127 
       
  1128 //----------------------------------------------------------------------------
       
  1129 // CMmPacketServiceTsy::CompleteNotifyChangeOfNtwkRegStatus
       
  1130 // Completes notify change of ntwk registration status to client.
       
  1131 // Handles request coming from MessHandler
       
  1132 //----------------------------------------------------------------------------
       
  1133 //
       
  1134 void CMmPacketServiceTsy::CompleteNotifyChangeOfNtwkRegStatus(
       
  1135     CMmDataPackage* aDataPackage, TInt aResult )		
       
  1136     {
       
  1137 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyChangeOfNtwkRegStatus.");
       
  1138 
       
  1139 	//Unpack necessary data from datapackage
       
  1140 	RPacketService::TRegistrationStatus registrationStatus;
       
  1141 	aDataPackage->UnPackData( registrationStatus );
       
  1142 
       
  1143     // If registration status changed
       
  1144     if ( registrationStatus != iInternalSavedData.iRegistrationStatus )
       
  1145         {
       
  1146 
       
  1147         // Save new status internally
       
  1148         iInternalSavedData.iRegistrationStatus = registrationStatus;
       
  1149 
       
  1150         // Reset request handle. Returns the deleted request handle
       
  1151         const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1152             EMultimodePacketServiceNotifyNtwkRegStatusChange ) );
       
  1153 
       
  1154         // If notification is requested by client
       
  1155         if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1156             {
       
  1157 
       
  1158             // Set registrationStatus to the etel side memory
       
  1159             *iNotifyDataPointers.iChangeOfNtwkRegStatus = registrationStatus;
       
  1160             iNotifyDataPointers.iChangeOfNtwkRegStatus = NULL;
       
  1161 
       
  1162             // Complete the client request
       
  1163             CMmPacketServiceTsy::ReqCompleted( reqHandle, aResult );
       
  1164 
       
  1165             }
       
  1166         }
       
  1167     }
       
  1168 
       
  1169 //----------------------------------------------------------------------------
       
  1170 // CMmPacketServiceTsy::NotifyContextActivationRequested
       
  1171 // Requests notification of network requests context activation.
       
  1172 // This function will complete when the phone receives a request from the
       
  1173 // packet network to activate a PDP context. Depending on the type of
       
  1174 // network, this request may contain the PDP type requested, the PDP address
       
  1175 // for this context, and possibly the Access Point Name (APN) of the gateway
       
  1176 // to connect to.
       
  1177 //----------------------------------------------------------------------------
       
  1178 //
       
  1179 TInt CMmPacketServiceTsy::NotifyContextActivationRequested(
       
  1180     TPacketDataConfigBase* const aContextParameters ) 
       
  1181     {
       
  1182 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyContextActivationRequested." );
       
  1183 
       
  1184     TInt ret = KErrNone;
       
  1185 
       
  1186     // If class of aContextParameters is TContextConfigGPRS
       
  1187     if ( TPacketDataConfigBase::KConfigGPRS ==
       
  1188          aContextParameters->ExtensionId() )
       
  1189         {
       
  1190         // Cast aContextParameters from TPacketDataConfigBase to
       
  1191         // TContextConfigGPRS and save internally
       
  1192         iNotifyDataPointers.iContextActivationRequested =
       
  1193             ( RPacketContext::TContextConfigGPRS* ) aContextParameters;
       
  1194 
       
  1195         // Set request handle
       
  1196         iReqHandleType =
       
  1197             EMultimodePacketServiceNotifyContextActivationRequested;
       
  1198         }
       
  1199     // Else if class of aContextParameters is TContextConfigR99_R4
       
  1200     else if ( TPacketDataConfigBase::KConfigRel99Rel4 ==
       
  1201          aContextParameters->ExtensionId() )
       
  1202         {
       
  1203         // Cast aContextParameters from TPacketDataConfigBase to
       
  1204         // TContextConfigR99_R4 and save internally
       
  1205         iNotifyDataPointers.iContextActivationRequested99 =
       
  1206             ( RPacketContext::TContextConfigR99_R4* ) aContextParameters;
       
  1207 
       
  1208         // Set request handle
       
  1209         iReqHandleType =
       
  1210             EMultimodePacketServiceNotifyContextActivationRequested99;
       
  1211         }
       
  1212     // Else if class of aContextParameters is TContextConfigR5
       
  1213     else if ( TPacketDataConfigBase::KConfigRel5 ==
       
  1214          aContextParameters->ExtensionId() )
       
  1215         {
       
  1216         // Cast aContextParameters from TPacketDataConfigBase to
       
  1217         // TContextConfig_R5 and save internally
       
  1218         iNotifyDataPointers.iContextActivationRequested5 =
       
  1219             ( RPacketContext::TContextConfig_R5* ) aContextParameters;
       
  1220 
       
  1221         // Set request handle
       
  1222         iReqHandleType =
       
  1223             EMultimodePacketServiceNotifyContextActivationRequested5;           
       
  1224         }                
       
  1225     // Else class of aContextParameters is not supported
       
  1226     else
       
  1227         {
       
  1228         ret = KErrNotSupported;
       
  1229         }
       
  1230 
       
  1231     return ret;
       
  1232     }
       
  1233 
       
  1234 //----------------------------------------------------------------------------
       
  1235 // CMmPacketServiceTsy::CompleteNotifyContextActivationRequested
       
  1236 // Completes context activation requested notification to client.
       
  1237 //----------------------------------------------------------------------------
       
  1238 //
       
  1239 void CMmPacketServiceTsy::CompleteNotifyContextActivationRequested(
       
  1240     CMmDataPackage* aDataPackage )		//contains initial data
       
  1241     {
       
  1242 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyContextActivationRequested.");
       
  1243 
       
  1244 	//Check if there is client request
       
  1245 	if ( EMultimodePacketServiceReqHandleUnknown != 
       
  1246 			CMmPacketServiceTsy::TsyReqHandleStore()->GetTsyReqHandle( 
       
  1247 				CMmPacketServiceTsy::
       
  1248 					EMultimodePacketServiceNotifyContextActivationRequested ) ||
       
  1249 		 EMultimodePacketServiceReqHandleUnknown != 
       
  1250 		  	CMmPacketServiceTsy::TsyReqHandleStore()->
       
  1251               	GetTsyReqHandle( CMmPacketServiceTsy::
       
  1252 					EMultimodePacketServiceNotifyContextActivationRequested99 ) ||
       
  1253 		 EMultimodePacketServiceReqHandleUnknown != 
       
  1254 		 	CMmPacketServiceTsy::TsyReqHandleStore()->
       
  1255               	GetTsyReqHandle( CMmPacketServiceTsy::
       
  1256 					EMultimodePacketServiceNotifyContextActivationRequested5 ) )						
       
  1257 		{
       
  1258 		//ETel API client may call RPacketService::NotifyContextActivationRequested
       
  1259 		//method using one of following parameter class: 
       
  1260 		//RPacketContext::TContextConfigGPRS, RPacketContext::TContextConfigR99_R4
       
  1261 		//or RPacketContext::TContextConfig_R5. LTSY may complete 
       
  1262 		//NotifyContextActivationRequested request using one of these parameter 
       
  1263 		//classes. CTSY has to complete RPacketService::NotifyContextActivationRequested
       
  1264 		//requests in all situations.
       
  1265 		
       
  1266 		//Copy data temporary from aDataPackage to 
       
  1267 		//RPacketContext::TContextConfig_R5
       
  1268 		
       
  1269 		RPacketContext::TContextConfig_R5 config_R5;
       
  1270 		TBool config_R5Filled = ETrue;
       
  1271 		
       
  1272 		//Before copying initialize GPRS specific fields
       
  1273 		TUint iPdpCompression = 0;
       
  1274 		RPacketContext::TAnonymousAccess iAnonymousAccessReqd = 
       
  1275 			RPacketContext::ENotApplicable;
       
  1276 		
       
  1277 		//Before copying reset R99_R4 and R5 specific fields
       
  1278 		config_R5.iPFI = RPacketContext::EBestEffort;																		
       
  1279     	config_R5.iPdpHeaderCompression = RPacketContext::ENoHeaderCompression;     	    
       
  1280     	config_R5.iPdpDataCompression = RPacketContext::ENoDataCompression;			
       
  1281 		
       
  1282 	
       
  1283 		TPacketDataConfigBase configBase;
       
  1284 		aDataPackage->UnPackData( configBase );
       
  1285 		if ( configBase.ExtensionId() == TPacketDataConfigBase::KConfigGPRS )
       
  1286 			{		
       
  1287 	    	RPacketContext::TContextConfigGPRS configGPRS;
       
  1288 	    	aDataPackage->UnPackData( configGPRS );
       
  1289 	    	
       
  1290 			config_R5.iPdpType =configGPRS.iPdpType;			
       
  1291 			config_R5.iAccessPointName = configGPRS.iAccessPointName;							
       
  1292 			config_R5.iPdpAddress = configGPRS.iPdpAddress;
       
  1293 			iPdpCompression = configGPRS.iPdpCompression;
       
  1294 			iAnonymousAccessReqd = configGPRS.iAnonymousAccessReqd;
       
  1295 			config_R5.iUseEdge = configGPRS.iUseEdge;
       
  1296 			config_R5.iProtocolConfigOption.iAuthInfo = 
       
  1297 				configGPRS.iProtocolConfigOption.iAuthInfo;
       
  1298 			config_R5.iProtocolConfigOption.iChallenge = 
       
  1299 				configGPRS.iProtocolConfigOption.iChallenge;
       
  1300 			config_R5.iProtocolConfigOption.iResponse = 
       
  1301 				configGPRS.iProtocolConfigOption.iResponse;
       
  1302 			config_R5.iProtocolConfigOption.iId = 
       
  1303 				configGPRS.iProtocolConfigOption.iId;
       
  1304 			config_R5.iProtocolConfigOption.iDnsAddresses = 
       
  1305 				configGPRS.iProtocolConfigOption.iDnsAddresses;
       
  1306 			config_R5.iProtocolConfigOption.iMiscBuffer = 
       
  1307 				configGPRS.iProtocolConfigOption.iMiscBuffer;				
       
  1308 			config_R5.iNWIContext = configGPRS.iNWIContext;
       
  1309 			}
       
  1310 		else if ( configBase.ExtensionId() == TPacketDataConfigBase::KConfigRel99Rel4 )
       
  1311 			{	
       
  1312 	    	RPacketContext::TContextConfigR99_R4 config_R99_R4;
       
  1313 	    	aDataPackage->UnPackData( config_R99_R4 );			
       
  1314 			
       
  1315 			config_R5.iPdpType = config_R99_R4.iPdpType;			
       
  1316 			config_R5.iAccessPointName = config_R99_R4.iAccessPointName;							
       
  1317 			config_R5.iPdpAddress = config_R99_R4.iPdpAddress;
       
  1318 			config_R5.iUseEdge = config_R99_R4.iUseEdge;
       
  1319 			config_R5.iProtocolConfigOption.iAuthInfo =
       
  1320 				config_R99_R4.iProtocolConfigOption.iAuthInfo;
       
  1321 			config_R5.iProtocolConfigOption.iChallenge =
       
  1322 				config_R99_R4.iProtocolConfigOption.iChallenge;
       
  1323 			config_R5.iProtocolConfigOption.iResponse =
       
  1324 				config_R99_R4.iProtocolConfigOption.iResponse;
       
  1325 			config_R5.iProtocolConfigOption.iId =
       
  1326 				config_R99_R4.iProtocolConfigOption.iId;
       
  1327 			config_R5.iProtocolConfigOption.iDnsAddresses =
       
  1328 				config_R99_R4.iProtocolConfigOption.iDnsAddresses;
       
  1329 			config_R5.iProtocolConfigOption.iMiscBuffer =
       
  1330 				config_R99_R4.iProtocolConfigOption.iMiscBuffer;								
       
  1331 			config_R5.iNWIContext = config_R99_R4.iNWIContext;
       
  1332 			config_R5.iPFI = config_R99_R4.iPFI;	
       
  1333 			}
       
  1334 		else if ( configBase.ExtensionId() == TPacketDataConfigBase::KConfigRel5 )
       
  1335 			{			
       
  1336 			//Just unpack to config_R5
       
  1337 	    	aDataPackage->UnPackData( config_R5 );
       
  1338 			}
       
  1339 		else
       
  1340 			{				
       
  1341 			//Unknown parameter class.
       
  1342 			config_R5Filled = EFalse;
       
  1343 			}
       
  1344 			
       
  1345 		//Copy data to clients and complete client requests
       
  1346 		
       
  1347 		TTsyReqHandle reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  1348        		EMultimodePacketServiceNotifyContextActivationRequested );	
       
  1349 		if ( config_R5Filled &&
       
  1350 		     EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1351 			{
       
  1352 			// Deliver R97/98 parameters to the ETel Packet API client
       
  1353 			iNotifyDataPointers.iContextActivationRequested->iPdpType =
       
  1354 				config_R5.iPdpType;			
       
  1355 			iNotifyDataPointers.iContextActivationRequested->iAccessPointName =
       
  1356 				config_R5.iAccessPointName;							
       
  1357 			iNotifyDataPointers.iContextActivationRequested->iPdpAddress =
       
  1358 				config_R5.iPdpAddress;
       
  1359 			iNotifyDataPointers.iContextActivationRequested->iPdpCompression =
       
  1360 				iPdpCompression;
       
  1361 			iNotifyDataPointers.iContextActivationRequested->iAnonymousAccessReqd =
       
  1362 				iAnonymousAccessReqd;
       
  1363 			iNotifyDataPointers.iContextActivationRequested->iUseEdge =
       
  1364 				config_R5.iUseEdge;
       
  1365 			iNotifyDataPointers.iContextActivationRequested->iProtocolConfigOption.iAuthInfo =
       
  1366 				config_R5.iProtocolConfigOption.iAuthInfo;
       
  1367 			iNotifyDataPointers.iContextActivationRequested->iProtocolConfigOption.iChallenge =
       
  1368 				config_R5.iProtocolConfigOption.iChallenge;
       
  1369 			iNotifyDataPointers.iContextActivationRequested->iProtocolConfigOption.iResponse =
       
  1370 				config_R5.iProtocolConfigOption.iResponse;
       
  1371 			iNotifyDataPointers.iContextActivationRequested->iProtocolConfigOption.iId =
       
  1372 				config_R5.iProtocolConfigOption.iId;
       
  1373 			iNotifyDataPointers.iContextActivationRequested->iProtocolConfigOption.iDnsAddresses =
       
  1374 				config_R5.iProtocolConfigOption.iDnsAddresses;
       
  1375 			iNotifyDataPointers.iContextActivationRequested->iProtocolConfigOption.iMiscBuffer =
       
  1376 				config_R5.iProtocolConfigOption.iMiscBuffer;				
       
  1377 			iNotifyDataPointers.iContextActivationRequested->iNWIContext =
       
  1378 				config_R5.iNWIContext;
       
  1379 			iNotifyDataPointers.iContextActivationRequested = NULL;
       
  1380 		
       
  1381 			// Complete request with KErrNone
       
  1382 			CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1383 		    }		
       
  1384 
       
  1385 		reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  1386        		EMultimodePacketServiceNotifyContextActivationRequested99 );	
       
  1387 		if ( config_R5Filled &&
       
  1388 		     EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1389 			{		
       
  1390 			// Deliver R99_R4 parameters to the ETel Packet API client
       
  1391 			iNotifyDataPointers.iContextActivationRequested99->iPdpType =
       
  1392 				config_R5.iPdpType;			
       
  1393 			iNotifyDataPointers.iContextActivationRequested99->iAccessPointName =
       
  1394 				config_R5.iAccessPointName;							
       
  1395 			iNotifyDataPointers.iContextActivationRequested99->iPdpAddress =
       
  1396 				config_R5.iPdpAddress;
       
  1397 			iNotifyDataPointers.iContextActivationRequested99->iUseEdge =
       
  1398 				config_R5.iUseEdge;
       
  1399 			iNotifyDataPointers.iContextActivationRequested99->iProtocolConfigOption.iAuthInfo =
       
  1400 				config_R5.iProtocolConfigOption.iAuthInfo;
       
  1401 			iNotifyDataPointers.iContextActivationRequested99->iProtocolConfigOption.iChallenge =
       
  1402 				config_R5.iProtocolConfigOption.iChallenge;
       
  1403 			iNotifyDataPointers.iContextActivationRequested99->iProtocolConfigOption.iResponse =
       
  1404 				config_R5.iProtocolConfigOption.iResponse;
       
  1405 			iNotifyDataPointers.iContextActivationRequested99->iProtocolConfigOption.iId =
       
  1406 				config_R5.iProtocolConfigOption.iId;
       
  1407 			iNotifyDataPointers.iContextActivationRequested99->iProtocolConfigOption.iDnsAddresses =
       
  1408 				config_R5.iProtocolConfigOption.iDnsAddresses;
       
  1409 			iNotifyDataPointers.iContextActivationRequested99->iProtocolConfigOption.iMiscBuffer =
       
  1410 				config_R5.iProtocolConfigOption.iMiscBuffer;								
       
  1411 			iNotifyDataPointers.iContextActivationRequested99->iNWIContext =
       
  1412 				config_R5.iNWIContext;
       
  1413 			iNotifyDataPointers.iContextActivationRequested99->iPFI =
       
  1414 				config_R5.iPFI;	
       
  1415 			iNotifyDataPointers.iContextActivationRequested99 = NULL;	
       
  1416 
       
  1417 			// Complete request with KErrNone
       
  1418 			CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1419 			}
       
  1420 		
       
  1421 		reqHandle = iTsyReqHandleStore->ResetTsyReqHandle(
       
  1422        		EMultimodePacketServiceNotifyContextActivationRequested5 );	
       
  1423 		if ( config_R5Filled &&
       
  1424 		     EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1425 			{	
       
  1426 			// Deliver R5 parameters to the ETel Packet API client
       
  1427 			iNotifyDataPointers.iContextActivationRequested5->iPdpType =
       
  1428 				config_R5.iPdpType;			
       
  1429 			iNotifyDataPointers.iContextActivationRequested5->iAccessPointName =
       
  1430 				config_R5.iAccessPointName;							
       
  1431 			iNotifyDataPointers.iContextActivationRequested5->iPdpAddress =
       
  1432 				config_R5.iPdpAddress;
       
  1433 			iNotifyDataPointers.iContextActivationRequested5->iUseEdge =
       
  1434 				config_R5.iUseEdge;
       
  1435 			iNotifyDataPointers.iContextActivationRequested5->iProtocolConfigOption.iAuthInfo =
       
  1436 				config_R5.iProtocolConfigOption.iAuthInfo;
       
  1437 			iNotifyDataPointers.iContextActivationRequested5->iProtocolConfigOption.iChallenge =
       
  1438 				config_R5.iProtocolConfigOption.iChallenge;
       
  1439 			iNotifyDataPointers.iContextActivationRequested5->iProtocolConfigOption.iResponse =
       
  1440 				config_R5.iProtocolConfigOption.iResponse;
       
  1441 			iNotifyDataPointers.iContextActivationRequested5->iProtocolConfigOption.iId =
       
  1442 				config_R5.iProtocolConfigOption.iId;
       
  1443 			iNotifyDataPointers.iContextActivationRequested5->iProtocolConfigOption.iDnsAddresses =
       
  1444 				config_R5.iProtocolConfigOption.iDnsAddresses;
       
  1445 			iNotifyDataPointers.iContextActivationRequested5->iProtocolConfigOption.iMiscBuffer =
       
  1446 				config_R5.iProtocolConfigOption.iMiscBuffer;								
       
  1447 			iNotifyDataPointers.iContextActivationRequested5->iNWIContext =
       
  1448 				config_R5.iNWIContext;
       
  1449 			iNotifyDataPointers.iContextActivationRequested5->iPFI =
       
  1450 				config_R5.iPFI;																		
       
  1451 	    	iNotifyDataPointers.iContextActivationRequested5->iPdpHeaderCompression =
       
  1452 	    	    config_R5.iPdpHeaderCompression;      	    
       
  1453 	    	iNotifyDataPointers.iContextActivationRequested5->iPdpDataCompression =
       
  1454 	            config_R5.iPdpDataCompression;
       
  1455 	       	iNotifyDataPointers.iContextActivationRequested5 = NULL;
       
  1456 	            
       
  1457 	        // Complete request with KErrNone
       
  1458 	        CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1459 			}
       
  1460 		}
       
  1461     }
       
  1462 
       
  1463 //----------------------------------------------------------------------------
       
  1464 // CMmPacketServiceTsy::NotifyContextAdded
       
  1465 // Requests notification of context has been added.
       
  1466 // Allows a client to be notified whenever a new context has been created. It
       
  1467 // should be noted that once the notification completes, the client must then
       
  1468 // re-post the notification if they wish to continue receiving further
       
  1469 // notifications.
       
  1470 //----------------------------------------------------------------------------
       
  1471 //
       
  1472 TInt CMmPacketServiceTsy::NotifyContextAdded(
       
  1473     const TDataPackage& aPackage )   
       
  1474     {
       
  1475 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyContextAdded." );
       
  1476 
       
  1477 	TDes* const context = aPackage.Des1u();
       
  1478 
       
  1479     // Save request handle type and context Name
       
  1480     iReqHandleType = EMultimodePacketServiceNotifyContextAdded;
       
  1481     iNotifyDataPointers.iContextAdded = context;
       
  1482 
       
  1483     return KErrNone;
       
  1484     }
       
  1485 
       
  1486 //----------------------------------------------------------------------------
       
  1487 // CMmPacketServiceTsy::CompleteNotifyContextAdded
       
  1488 // Completes the context added notification to client.
       
  1489 //----------------------------------------------------------------------------
       
  1490 //
       
  1491 void CMmPacketServiceTsy::CompleteNotifyContextAdded(
       
  1492     CMmDataPackage* aPackage )  
       
  1493     {
       
  1494     TInfoName tempHostCID;
       
  1495     tempHostCID.Zero();
       
  1496     
       
  1497 	//Variables needed for unpacking data
       
  1498 
       
  1499 	TInfoName contextName;
       
  1500 	contextName.Zero();
       
  1501 	TInt result ( 0 );
       
  1502 
       
  1503     TInt trapError( KErrNone );
       
  1504     TInt ret( KErrNone );
       
  1505 
       
  1506 	aPackage->UnPackData( contextName, result  );
       
  1507 
       
  1508 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyContextAdded." );
       
  1509 
       
  1510 	if ( KErrNone != result )
       
  1511         {
       
  1512         //if one Dial-up context is created
       
  1513         if ( iDialUpContext )
       
  1514             {
       
  1515             // External context, service has no control to the context.
       
  1516             // Context name forced to External2.
       
  1517             contextName.Copy( KStringExternal2 );
       
  1518 
       
  1519 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyContextAdded :Create Secondary Dial-up Object." );
       
  1520         
       
  1521             // Create object for externally created dial-up context
       
  1522             TRAP( trapError, iSecondaryDialUpContext = CMmPacketContextTsy::NewL(
       
  1523                 this, tempHostCID, contextName ); );
       
  1524             }
       
  1525 
       
  1526         else  
       
  1527             {
       
  1528             // External context, service has no control to the context.
       
  1529             // Context name forced to External.
       
  1530             contextName.Copy( KStringExternal );
       
  1531 
       
  1532 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyContextAdded :Create Dial-up Object." );
       
  1533         
       
  1534             // Create object for externally created dial-up context
       
  1535             TRAP( trapError, iDialUpContext = CMmPacketContextTsy::NewL(
       
  1536                 this, tempHostCID, contextName ); );
       
  1537             }
       
  1538 
       
  1539         if ( KErrNone == trapError )
       
  1540             {
       
  1541             if ( contextName.Compare( KStringExternal2 ) == 0 )
       
  1542                 {
       
  1543                 ret = iPacketContextList->AddObject(
       
  1544                     iSecondaryDialUpContext, 0x00, 0x00, 
       
  1545                     contextName );
       
  1546                 }
       
  1547             else if ( contextName.Compare( KStringExternal ) == 0 )
       
  1548                 {
       
  1549                 ret = iPacketContextList->AddObject( iDialUpContext,
       
  1550                     0x00, 0x00, contextName );
       
  1551                 }
       
  1552 
       
  1553             if( KErrNone != ret )
       
  1554                 {
       
  1555 
       
  1556                 if ( contextName.Compare( KStringExternal2 ) == 0 )
       
  1557                     {
       
  1558                     iSecondaryDialUpContext->Close();
       
  1559                     }
       
  1560                 else if ( contextName.Compare( KStringExternal ) == 0 )
       
  1561                     {
       
  1562                     iDialUpContext->Close();
       
  1563                     }
       
  1564                 }
       
  1565 
       
  1566 	        if ( KErrNone != ret || KErrNone != trapError )
       
  1567 	            {
       
  1568 	            if ( contextName.Compare( KStringExternal2 ) == 0 )
       
  1569 	                {
       
  1570 	                iSecondaryDialUpContext = NULL;
       
  1571 	                }
       
  1572 	            else if ( contextName.Compare( KStringExternal ) == 0 )
       
  1573 	              	{
       
  1574 	                iDialUpContext = NULL;
       
  1575 	                }
       
  1576 	           	}
       
  1577 	     	}
       
  1578         
       
  1579         //Check if dial-up context is created, and set default params
       
  1580         if ( contextName.Compare( KStringExternal2 ) == 0 )
       
  1581             {
       
  1582 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyContextAdded :Reset Secondary Dial-up Object." );
       
  1583             // Reset secondary dial-up context
       
  1584             if(iSecondaryDialUpContext)
       
  1585             	{
       
  1586             	iSecondaryDialUpContext->ResetDialUpContext();
       
  1587             	}
       
  1588 			
       
  1589             }
       
  1590         else if ( contextName.Compare( KStringExternal ) == 0 )
       
  1591             {
       
  1592 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyContextAdded :Reset Dial-up Object." );
       
  1593             // Reset dial-up context
       
  1594             if(iDialUpContext)
       
  1595             	{
       
  1596             	iDialUpContext->ResetDialUpContext();
       
  1597             	}
       
  1598             }
       
  1599         }
       
  1600 
       
  1601     // Reset request handle. Returns the deleted request handle
       
  1602     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1603         EMultimodePacketServiceNotifyContextAdded ) );
       
  1604 
       
  1605     // Check that request handle is valid
       
  1606     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1607         {
       
  1608         // Add context name to the etel side memory
       
  1609         *iNotifyDataPointers.iContextAdded = contextName;
       
  1610         iNotifyDataPointers.iContextAdded = NULL;
       
  1611 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteNotifyContextAdded. Context Name: %S", &contextName );
       
  1612 
       
  1613         // Complete request with KErrNone
       
  1614         CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1615         }
       
  1616     }
       
  1617 
       
  1618 //----------------------------------------------------------------------------
       
  1619 // CMmPacketServiceTsy::NotifyDynamicCapsChange
       
  1620 // Requests notification of dynamic capabilities change.
       
  1621 // This function will complete when the dynamic packet data capabilities
       
  1622 // change; that is, either some action has become possible and/or some action
       
  1623 // is no longer possible. A common usage of the dynamic capabilities functions
       
  1624 // would be for GetDynamicCaps() to be called first to retrieve the current
       
  1625 // set of capabilities, and then the NotifyDynamicCapsChange() request to be
       
  1626 // posted to be kept informed of any changes.
       
  1627 //----------------------------------------------------------------------------
       
  1628 //
       
  1629 TInt CMmPacketServiceTsy::NotifyDynamicCapsChange(
       
  1630     RPacketService::TDynamicCapsFlags* const aCaps ) 
       
  1631     {
       
  1632 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyDynamicCapsChange." );
       
  1633 
       
  1634     // Save pointer to aCaps
       
  1635     iNotifyDataPointers.iDynamicCapsChange = aCaps;
       
  1636 
       
  1637     // Set request handle type
       
  1638     iReqHandleType = EMultimodePacketServiceNotifyDynamicCapsChange;
       
  1639 
       
  1640     return KErrNone;
       
  1641     }
       
  1642 
       
  1643 //----------------------------------------------------------------------------
       
  1644 // CMmPacketServiceTsy::CompleteNotifyDynamicCapsChange
       
  1645 // Completes dynamic capabilities notification to client.
       
  1646 //----------------------------------------------------------------------------
       
  1647 //
       
  1648 void CMmPacketServiceTsy::CompleteNotifyDynamicCapsChange(
       
  1649     const RPacketService::TDynamicCapsFlags aCaps ) 
       
  1650     {
       
  1651 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyDynamicCapsChange." );
       
  1652 
       
  1653     // Reset request handle. Returns the deleted request handle
       
  1654     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1655         EMultimodePacketServiceNotifyDynamicCapsChange ) );
       
  1656 
       
  1657     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1658         {
       
  1659         *iNotifyDataPointers.iDynamicCapsChange = aCaps;
       
  1660         iNotifyDataPointers.iDynamicCapsChange = NULL;
       
  1661 
       
  1662         CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1663         }
       
  1664     }
       
  1665 
       
  1666 //----------------------------------------------------------------------------
       
  1667 // CMmPacketServiceTsy::NotifyMSClassChange
       
  1668 // Requests notification of mobile station class change.
       
  1669 // This function will complete when there is a change in the current GPRS
       
  1670 // class of the mobile station. The new class is passed back in the aNewClass
       
  1671 // parameter.
       
  1672 //----------------------------------------------------------------------------
       
  1673 //
       
  1674 TInt CMmPacketServiceTsy::NotifyMSClassChange(
       
  1675     RPacketService::TMSClass* const aNewClass ) 
       
  1676     {
       
  1677 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyMSClassChange." );
       
  1678 
       
  1679     // Save aNewClass internally
       
  1680     iNotifyDataPointers.iMSClassChange = aNewClass;
       
  1681 
       
  1682     iReqHandleType = EMultimodePacketServiceNotifyMSClassChange;
       
  1683 
       
  1684     return KErrNone;
       
  1685     }
       
  1686 
       
  1687 //----------------------------------------------------------------------------
       
  1688 // CMmPacketServiceTsy::CompleteNotifyMSClassChange
       
  1689 // Completes mobile station class notification to client.
       
  1690 //----------------------------------------------------------------------------
       
  1691 //
       
  1692 void CMmPacketServiceTsy::CompleteNotifyMSClassChange(
       
  1693     CMmDataPackage* aDataPackage )				
       
  1694     {
       
  1695 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyMSClassChange." );
       
  1696 
       
  1697 	RPacketService::TMSClass newClass;
       
  1698 	aDataPackage->UnPackData( newClass );
       
  1699 
       
  1700     if ( newClass != iInternalSavedData.iMsClass )
       
  1701         {
       
  1702         // Save new ms class internally
       
  1703         iInternalSavedData.iMsClass = newClass;
       
  1704 
       
  1705         // Reset request handle. Returns the deleted request handle
       
  1706         const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1707             EMultimodePacketServiceNotifyMSClassChange ) );
       
  1708 
       
  1709         if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1710             {
       
  1711             // Save changed MS Class to ETel side memory
       
  1712             *iNotifyDataPointers.iMSClassChange = newClass;
       
  1713             iNotifyDataPointers.iMSClassChange = NULL;
       
  1714 
       
  1715 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteNotifyMSClassChange. New Ms Class: %d", newClass );
       
  1716             // Complete request with KErrNone
       
  1717             CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1718             }
       
  1719         }
       
  1720     }
       
  1721 
       
  1722 //----------------------------------------------------------------------------
       
  1723 // CMmPacketServiceTsy::NotifyStatusChange
       
  1724 // informs client that service status change.
       
  1725 // Allows a client to be notified of a change in the status
       
  1726 // of the connection to the packet service. The new status is
       
  1727 // passed back to the client via aPacketStatus parameter.
       
  1728 //----------------------------------------------------------------------------
       
  1729 //
       
  1730 TInt CMmPacketServiceTsy::NotifyStatusChange(
       
  1731     RPacketService::TStatus* const aPacketStatus ) 
       
  1732     {
       
  1733 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyStatusChange." );
       
  1734 
       
  1735     // Save aPacketStatus to internal memory
       
  1736     iNotifyDataPointers.iStatusChange = aPacketStatus;
       
  1737 
       
  1738     // Set request handle type
       
  1739     iReqHandleType = EMultimodePacketServiceNotifyStatusChange;
       
  1740 
       
  1741     return KErrNone;
       
  1742     }
       
  1743 
       
  1744 //----------------------------------------------------------------------------
       
  1745 // CMmPacketServiceTsy::CompleteNotifyStatusChange
       
  1746 // Completes service status notification to client.
       
  1747 //----------------------------------------------------------------------------
       
  1748 //
       
  1749 void CMmPacketServiceTsy::CompleteNotifyStatusChange(
       
  1750     const RPacketService::TStatus& aPacketStatus,
       
  1751     TInt aErrorCode )
       
  1752     {
       
  1753 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyStatusChange." );
       
  1754     if ( aPacketStatus != iInternalSavedData.iServiceStatus )
       
  1755         {
       
  1756         iInternalSavedData.iServiceStatus = aPacketStatus;
       
  1757 
       
  1758         // Reset req handle. Returns the deleted req handle
       
  1759         const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1760             EMultimodePacketServiceNotifyStatusChange ) );
       
  1761 
       
  1762         if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1763             {
       
  1764             *iNotifyDataPointers.iStatusChange = aPacketStatus;
       
  1765             iNotifyDataPointers.iStatusChange = NULL;
       
  1766 
       
  1767 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteNotifyStatusChange. Service Status:%d", aPacketStatus );
       
  1768             CMmPacketServiceTsy::ReqCompleted( reqHandle, aErrorCode );
       
  1769             }
       
  1770         }
       
  1771     }
       
  1772 
       
  1773 //----------------------------------------------------------------------------
       
  1774 // CMmPacketServiceTsy::RejectActivationRequest
       
  1775 // Reject activation request from the network.
       
  1776 // This function will cause the phone to reject the network's request for a
       
  1777 // PDP context activation. Note, there is no corresponding "accept" message
       
  1778 // for the phone to send. To accept, the phone should simply begin to activate
       
  1779 // a PDP context with the appropriate IP address before the network's timer
       
  1780 // expires. On GPRS, this timer is between 5 and 8 seconds, but may
       
  1781 // effectively be between around 25 and 40 seconds as the specifications state
       
  1782 // that the activation request should be re-sent up to five times.
       
  1783 //----------------------------------------------------------------------------
       
  1784 //
       
  1785 TInt CMmPacketServiceTsy::RejectActivationRequestL()
       
  1786     {
       
  1787 TFLOGSTRING("TSY: CMmPacketServiceTsy::RejectActivationRequestL." );
       
  1788 
       
  1789     const TTsyReqHandle tsyRegHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
  1790         EMultimodePacketServiceRejectActivationRequest ) );
       
  1791 
       
  1792     TInt ret( KErrServerBusy );
       
  1793 
       
  1794     if ( EMultimodePacketServiceReqHandleUnknown == tsyRegHandle )
       
  1795         {
       
  1796 		// Reject network activation
       
  1797 		ret = iMessageManager->HandleRequestL( 
       
  1798 		    EPacketRejectActivationRequest );
       
  1799 
       
  1800         if ( KErrNone == ret )
       
  1801             {
       
  1802             // Set request handle
       
  1803             iReqHandleType = EMultimodePacketServiceRejectActivationRequest;
       
  1804             }
       
  1805         }
       
  1806 
       
  1807     return ret;
       
  1808     }
       
  1809 
       
  1810 //----------------------------------------------------------------------------
       
  1811 // CMmPacketServiceTsy::CompleteRejectActivationRequest
       
  1812 // Completes asynchronous reject activation request.
       
  1813 //----------------------------------------------------------------------------
       
  1814 //
       
  1815 void CMmPacketServiceTsy::CompleteRejectActivationRequest()
       
  1816     {
       
  1817 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteRejectActivationRequest." );
       
  1818 
       
  1819     // Reset request handle. Returns the deleted request handle
       
  1820     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1821         EMultimodePacketServiceRejectActivationRequest ) );
       
  1822 
       
  1823     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1824         {
       
  1825         // Complete the client request
       
  1826         CMmPacketServiceTsy::ReqCompleted( reqHandle, KErrNone );
       
  1827         }
       
  1828     }
       
  1829 
       
  1830 //----------------------------------------------------------------------------
       
  1831 // CMmPacketServiceTsy::SetAttachMode
       
  1832 // Sets attach mode given in parameter to the server.
       
  1833 //----------------------------------------------------------------------------
       
  1834 //
       
  1835 TInt CMmPacketServiceTsy::SetAttachModeL(
       
  1836     const RPacketService::TAttachMode* aMode )
       
  1837     {
       
  1838 TFLOGSTRING("TSY: CMmPacketServiceTsy::SetAttachModeL." );
       
  1839 
       
  1840     iAttachMode = *aMode;
       
  1841 
       
  1842     TInt ret( KErrServerBusy );
       
  1843     const TTsyReqHandle reqHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
  1844         EMultimodePacketServiceSetAttachMode ) );
       
  1845 
       
  1846     if ( EMultimodePacketServiceReqHandleUnknown == reqHandle )
       
  1847         {
       
  1848  		//Set attach mode
       
  1849 		ret = iMmPacketServiceGsmWcdmaExt->SetAttachModeL( *aMode );
       
  1850 
       
  1851 		if ( KErrNone == ret )
       
  1852             {
       
  1853             // Set req handle
       
  1854             iReqHandleType = EMultimodePacketServiceSetAttachMode;
       
  1855             }
       
  1856         }
       
  1857 
       
  1858     return ret;
       
  1859     }
       
  1860 
       
  1861 //----------------------------------------------------------------------------
       
  1862 // CMmPacketServiceTsy::CompleteSetAttachMode
       
  1863 // Completes the Set Attach Mode request.
       
  1864 //----------------------------------------------------------------------------
       
  1865 //
       
  1866 void CMmPacketServiceTsy::CompleteSetAttachMode(
       
  1867     const TInt aError )  //error value
       
  1868     {
       
  1869 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteSetAttachMode. Error Value: %d", aError );
       
  1870 
       
  1871     // Reset request handle. Returns the deleted request handle
       
  1872     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1873         EMultimodePacketServiceSetAttachMode ) );
       
  1874 
       
  1875     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1876         {
       
  1877         // Complete the client request
       
  1878         CMmPacketServiceTsy::ReqCompleted( reqHandle, aError );
       
  1879         }
       
  1880     }
       
  1881 
       
  1882 //----------------------------------------------------------------------------
       
  1883 // CMmPacketServiceTsy::SetPreferredBearer
       
  1884 // Sets preferred bearer given in parameter to the GPDS server.
       
  1885 // This function will set the preferred bearer for the MT to default to when
       
  1886 // dropping from Class B operation to Class C, for instance when the MT moves
       
  1887 // into a Routing Area of cells or new GPRS network which operates in Network
       
  1888 // Mode III. Class C operation requires that the MT is attached to either GSM
       
  1889 // or GPRS, not both.
       
  1890 //----------------------------------------------------------------------------
       
  1891 //
       
  1892 TInt CMmPacketServiceTsy::SetPreferredBearerL(
       
  1893     const TDataPackage& aPackage )		
       
  1894     {
       
  1895 	TAny* const dataPtr = aPackage.Ptr1();
       
  1896 
       
  1897 TFLOGSTRING2("TSY: CMmPacketServiceTsy::SetPreferredBearerL. Preferred Bearer: %d", &dataPtr );
       
  1898 
       
  1899     const TTsyReqHandle reqHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
  1900         EMultimodePacketServiceSetPreferredBearer ) );
       
  1901 
       
  1902     TInt ret( KErrServerBusy );
       
  1903 
       
  1904     if ( EMultimodePacketServiceReqHandleUnknown == reqHandle )
       
  1905         {
       
  1906         RPacketService::TPreferredBearer* abearer = REINTERPRET_CAST(
       
  1907             RPacketService::TPreferredBearer*, dataPtr );
       
  1908 
       
  1909         // Set preferred beareraPackage
       
  1910         ret = iMmPacketServiceGsmWcdmaExt->SetPreferredBearerL( aPackage );
       
  1911 
       
  1912         if ( KErrNone == ret )
       
  1913             {
       
  1914             iTemporarySavedData.iPreferredBearer = *abearer;
       
  1915 
       
  1916             // Set request handle type
       
  1917             iReqHandleType = EMultimodePacketServiceSetPreferredBearer;
       
  1918             }
       
  1919         }
       
  1920 
       
  1921     return ret;
       
  1922     }
       
  1923 
       
  1924 //----------------------------------------------------------------------------
       
  1925 // CMmPacketServiceTsy::CompleteSetPreferredBearer
       
  1926 // Completes the Set Preferred Bearer request.
       
  1927 //----------------------------------------------------------------------------
       
  1928 //
       
  1929 void CMmPacketServiceTsy::CompleteSetPreferredBearer(
       
  1930     const TInt aError )  //epoc error code
       
  1931     {
       
  1932 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteSetPreferredBearer. Error: %d", aError );
       
  1933 
       
  1934     // Reset request handle. Returns the deleted request handle
       
  1935     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  1936         EMultimodePacketServiceSetPreferredBearer ) );
       
  1937 
       
  1938     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  1939         {
       
  1940         if ( KErrNone == aError )
       
  1941             {
       
  1942             iInternalSavedData.iPreferredBearer =
       
  1943                 iTemporarySavedData.iPreferredBearer;
       
  1944 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteSetPreferredBearer. Preferred Bearer: %d", iInternalSavedData.iPreferredBearer );
       
  1945             }
       
  1946 
       
  1947         // Complete the client request
       
  1948         CMmPacketServiceTsy::ReqCompleted( reqHandle, aError );
       
  1949         }
       
  1950     }
       
  1951 
       
  1952 //----------------------------------------------------------------------------
       
  1953 // CMmPacketServiceTsy::ExtFunc
       
  1954 // ExtFunc is called by the ETel when it has request for the TSY.
       
  1955 // For TSY to process request a request handle, request type and request data
       
  1956 // are passed to the TSY.
       
  1957 //----------------------------------------------------------------------------
       
  1958 //
       
  1959 TInt CMmPacketServiceTsy::ExtFunc(
       
  1960     const TTsyReqHandle aTsyReqHandle,  
       
  1961     const TInt aIpc,                    
       
  1962     const TDataPackage& aPackage )     
       
  1963     {
       
  1964 TFLOGSTRING2("TSY: CMmPacketServiceTsy::ExtFunc. IPC: %d", aIpc );
       
  1965 
       
  1966     TInt ret( KErrNone );
       
  1967     TInt trapError( KErrNone );
       
  1968 
       
  1969     // Reset request handle type
       
  1970     iReqHandleType = EMultimodePacketServiceReqHandleUnknown;
       
  1971 
       
  1972     // Set tsy request handle
       
  1973     iTsyReqHandle = aTsyReqHandle;
       
  1974 
       
  1975     // Call DoExtFuncL()
       
  1976     TRAP( trapError, ret = DoExtFuncL( aIpc, aPackage ); );
       
  1977 
       
  1978     if ( KErrNone != trapError )
       
  1979         {
       
  1980         CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, trapError );
       
  1981         }
       
  1982     else if ( KErrNone != ret )
       
  1983         {
       
  1984         CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, ret );
       
  1985         }
       
  1986 
       
  1987     if ( EMultimodePacketServiceReqHandleUnknown != iReqHandleType )
       
  1988         {
       
  1989         // Save request handle type
       
  1990 
       
  1991 #ifdef REQHANDLE_TIMER
       
  1992         SetTypeOfResponse( iReqHandleType );
       
  1993 #else
       
  1994         iTsyReqHandleStore->SetTsyReqHandle( iReqHandleType, iTsyReqHandle );
       
  1995 #endif // REQHANDLE_TIMER
       
  1996 
       
  1997         }
       
  1998 
       
  1999     return KErrNone;
       
  2000     }
       
  2001 
       
  2002 //----------------------------------------------------------------------------
       
  2003 // CMmPacketServiceTsy::DoExtFuncL
       
  2004 // Calls correct method to handle ETel server request.
       
  2005 // unpack packaged parameters
       
  2006 // call correct method implemention using the IPC number and return the
       
  2007 // return value back to the caller.
       
  2008 // in case IPC number is not understood by switch, KErrNotSupported will
       
  2009 // be returned.
       
  2010 //----------------------------------------------------------------------------
       
  2011 //
       
  2012 TInt CMmPacketServiceTsy::DoExtFuncL(
       
  2013     const TInt aIpc,                
       
  2014     const TDataPackage& aPackage )  
       
  2015     {
       
  2016 TFLOGSTRING3("TSY: CMmPacketServiceTsy::DoExtFuncL. IPC: %d TSY Req Handle:%d", aIpc, iTsyReqHandle);
       
  2017 
       
  2018     TInt ret( KErrNotSupported );
       
  2019 
       
  2020     TAny* const dataPtr = aPackage.Ptr1();
       
  2021     TAny* const dataPtr2 = aPackage.Ptr2();
       
  2022 
       
  2023     switch ( aIpc )
       
  2024         {
       
  2025         case EPacketNotifyContextAdded:
       
  2026 			ret = NotifyContextAdded( aPackage );
       
  2027             break;
       
  2028         case EPacketAttach:
       
  2029             ret = AttachL();
       
  2030             break;
       
  2031         case EPacketDetach:
       
  2032             ret = DetachL();
       
  2033             break;
       
  2034         case EPacketGetStatus:
       
  2035             ret = GetStatus(
       
  2036                 REINTERPRET_CAST( RPacketService::TStatus*, dataPtr ) );
       
  2037             break;
       
  2038         case EPacketNotifyStatusChange:
       
  2039             ret = NotifyStatusChange(
       
  2040                 REINTERPRET_CAST( RPacketService::TStatus*, dataPtr ) );
       
  2041             break;
       
  2042         case EPacketNotifyContextActivationRequested:
       
  2043             ret = NotifyContextActivationRequested(
       
  2044                 REINTERPRET_CAST( TPacketDataConfigBase*, dataPtr ) );
       
  2045             break;
       
  2046         case EPacketRejectActivationRequest:
       
  2047             ret = RejectActivationRequestL();
       
  2048             break;
       
  2049         case EPacketEnumerateContexts:
       
  2050             ret = EnumerateContexts(
       
  2051                 REINTERPRET_CAST( TInt*, dataPtr ),
       
  2052                 REINTERPRET_CAST( TInt*, dataPtr2 ) );
       
  2053             break;
       
  2054         case EPacketGetContextInfo:
       
  2055             ret = GetContextInfo(
       
  2056                 REINTERPRET_CAST( TInt*, dataPtr ),
       
  2057                 REINTERPRET_CAST( RPacketService::TContextInfo*, dataPtr2 ) );
       
  2058             break;
       
  2059         case EPacketGetNtwkRegStatus:
       
  2060             ret = GetNtwkRegStatusL(
       
  2061                 REINTERPRET_CAST( RPacketService::TRegistrationStatus*,
       
  2062                     dataPtr ) );
       
  2063             break;
       
  2064         case EPacketNotifyChangeOfNtwkRegStatus:
       
  2065             ret = NotifyChangeOfNtwkRegStatus(
       
  2066                 REINTERPRET_CAST( RPacketService::TRegistrationStatus*,
       
  2067                     dataPtr ) );
       
  2068             break;
       
  2069         case EPacketGetMSClass:
       
  2070             ret = GetMSClass(
       
  2071                 REINTERPRET_CAST( RPacketService::TMSClass*, dataPtr ),
       
  2072                 REINTERPRET_CAST( RPacketService::TMSClass*, dataPtr2 ) );
       
  2073             break;
       
  2074         case EPacketNotifyMSClassChange:
       
  2075             ret = NotifyMSClassChange(
       
  2076                 REINTERPRET_CAST( RPacketService::TMSClass*, dataPtr ) );
       
  2077             break;
       
  2078         case EPacketSetPrefBearer:
       
  2079 			ret = SetPreferredBearerL( aPackage );
       
  2080             break;
       
  2081         case EPacketGetPrefBearer:
       
  2082             ret = GetPreferredBearer( REINTERPRET_CAST(
       
  2083                 RPacketService::TPreferredBearer*, dataPtr ) );
       
  2084             break;
       
  2085         case EPacketGetStaticCaps:
       
  2086             ret = GetStaticCaps(
       
  2087                 REINTERPRET_CAST( TUint*, dataPtr ),
       
  2088                 REINTERPRET_CAST( RPacketContext::TProtocolType*, dataPtr2 ) );
       
  2089             break;
       
  2090         case EPacketGetDynamicCaps:
       
  2091             ret = GetDynamicCaps( REINTERPRET_CAST(
       
  2092                 RPacketService::TDynamicCapsFlags*, dataPtr ) );
       
  2093             break;
       
  2094         case EPacketNotifyDynamicCapsChange:
       
  2095             ret = NotifyDynamicCapsChange( REINTERPRET_CAST(
       
  2096                 RPacketService::TDynamicCapsFlags*, dataPtr ) );
       
  2097             break;
       
  2098         case EPacketSetAttachMode:
       
  2099             ret = SetAttachModeL(
       
  2100                 REINTERPRET_CAST( RPacketService::TAttachMode*, dataPtr ) );
       
  2101             break;
       
  2102         case EPacketGetAttachMode:
       
  2103             ret = GetAttachModeL(
       
  2104                 REINTERPRET_CAST( RPacketService::TAttachMode*, dataPtr ) );
       
  2105             break;
       
  2106         case EPacketPrepareOpenSecondary:
       
  2107             ret = PrepareOpenSecondary( aPackage.Des1u() );
       
  2108             break;
       
  2109         case EPacketEnumerateNifs:
       
  2110             ret = EnumerateNifs( REINTERPRET_CAST ( TInt*, dataPtr ) );
       
  2111             break;
       
  2112         case EPacketGetNifInfo:
       
  2113         	// Check that dataPtr2 is not null
       
  2114         	if (dataPtr2)
       
  2115         		{
       
  2116         		// Get the TDes8 version of the parameter and find its MaxLength()
       
  2117         		TInt parameterLength = aPackage.Des2n()->MaxLength();
       
  2118         		
       
  2119         		// Create a temporary object of the expected type and find the expected MaxLength()
       
  2120         		RPacketService::TNifInfoV2 temp;
       
  2121         		RPacketService::TNifInfoV2Pckg tempPckg(temp);
       
  2122         		TInt expectedLength = tempPckg.MaxLength();
       
  2123 
       
  2124 				// Compare the expected length with the actual length of the sent parameter
       
  2125 	        	if ( parameterLength == expectedLength )
       
  2126 	        		{
       
  2127 		            ret = GetNifInfo( REINTERPRET_CAST( TInt*, dataPtr ),
       
  2128 	    	            REINTERPRET_CAST( RPacketService::TNifInfoV2*, dataPtr2 ) );
       
  2129 	        		}
       
  2130 	        	else
       
  2131 	        		{
       
  2132 	        		ret = KErrArgument;
       
  2133 	        		}
       
  2134         		}
       
  2135         	else
       
  2136         		{
       
  2137         		ret = KErrArgument;
       
  2138         		}	
       
  2139             break;
       
  2140         case EPacketEnumerateContextsInNif:
       
  2141             ret = EnumerateContextsInNif( aPackage.Des2u(),
       
  2142                 REINTERPRET_CAST( TInt*, dataPtr ) );
       
  2143             break;
       
  2144         case EPacketGetContextNameInNif:
       
  2145             ret = GetContextNameInNif(
       
  2146                 REINTERPRET_CAST( RPacketService::TContextNameInNif*,
       
  2147                     dataPtr ), aPackage.Des2u() );
       
  2148             break;
       
  2149         case EPacketSetDefaultContextParams:
       
  2150 			ret = SetDefaultContextParamsL( aPackage );
       
  2151             break;
       
  2152         case EPacketGetDefaultContextParams:
       
  2153             ret = GetDefaultContextParams(
       
  2154                 REINTERPRET_CAST( TPacketDataConfigBase*, dataPtr ) );
       
  2155             break;
       
  2156         case EPacketNotifyMbmsNetworkServiceStatusChange:
       
  2157         	ret = NotifyMbmsNetworkServiceStatusChange( 
       
  2158         		reinterpret_cast<TMbmsNetworkServiceStatus*> (dataPtr ) );
       
  2159             break;
       
  2160         case EPacketNotifyMbmsServiceAvailabilityChange:
       
  2161         	ret = NotifyMbmsServiceAvailabilityChange();
       
  2162             break;
       
  2163         case EPacketGetMbmsNetworkServiceStatus:
       
  2164         	ret = GetMbmsNetworkServiceStatus(
       
  2165         	    *reinterpret_cast<TBool*> (dataPtr ),
       
  2166         	    reinterpret_cast<TMbmsNetworkServiceStatus*> (dataPtr2 ) );
       
  2167         	break; 
       
  2168         case EPacketEnumerateMbmsMonitorServiceList:
       
  2169             ret = EnumerateMonitorServiceList(
       
  2170                 *reinterpret_cast<TInt*> ( dataPtr ),
       
  2171                 *reinterpret_cast<TInt*> ( dataPtr2 ) );
       
  2172             break;
       
  2173         case EPacketEnumerateMbmsActiveServiceList:
       
  2174             ret = EnumerateMbmsActiveServiceList(
       
  2175                 *reinterpret_cast<TInt*> ( dataPtr),
       
  2176                 *reinterpret_cast<TInt*>(dataPtr2) );
       
  2177             break;
       
  2178         case EPacketUpdateMbmsMonitorServiceList:
       
  2179 			TMbmsAction action;
       
  2180 			action = *reinterpret_cast< TMbmsAction*> (dataPtr );
       
  2181         	if(dataPtr2)
       
  2182 				{
       
  2183 				ret = UpdateMbmsMonitorServiceListL(
       
  2184                		action,
       
  2185                       aPackage.Des2n() );
       
  2186 				}
       
  2187 			else
       
  2188 				{
       
  2189 				ret = UpdateMbmsMonitorServiceListL(
       
  2190 					action, NULL );
       
  2191 				}                            
       
  2192             break;
       
  2193 		case EPacketGetMbmsMonitoredServicesPhase1:
       
  2194             ret = GetMbmsMonitoredServicesPhase1L(
       
  2195                 reinterpret_cast<RMobilePhone::TClientId*> (dataPtr),
       
  2196                 *reinterpret_cast<TUint*>(dataPtr2 ) );
       
  2197             break;
       
  2198         case EPacketGetMbmsMonitoredServicesPhase2:
       
  2199             ret = GetMbmsMonitoredServicesPhase2(
       
  2200                 reinterpret_cast<RMobilePhone::TClientId*>( dataPtr ),
       
  2201                 aPackage.Des2n());
       
  2202             break;           
       
  2203         //case EPacketSetMSClass:
       
  2204         default:
       
  2205             break;
       
  2206         }
       
  2207 
       
  2208     return ret;
       
  2209     }
       
  2210 
       
  2211 
       
  2212 
       
  2213 //----------------------------------------------------------------------------
       
  2214 // CMmPacketServiceTsy::ReqModeL
       
  2215 // Returns request mode for given IPC.
       
  2216 // leave if given IPC is not supported
       
  2217 // return request mode for IPC number given in parameter
       
  2218 //----------------------------------------------------------------------------
       
  2219 //
       
  2220 CTelObject::TReqMode CMmPacketServiceTsy::ReqModeL(
       
  2221     const TInt aIpc ) 
       
  2222     {
       
  2223 TFLOGSTRING2("TSY: CMmPacketServiceTsy::ReqModeL. IPC: %d", aIpc );
       
  2224 
       
  2225     CTelObject::TReqMode reqMode( 0 );
       
  2226     switch ( aIpc )
       
  2227         {
       
  2228         // All disabled TSYs wishing to implement their own buffering 
       
  2229         // algorithm will place all requests in this category.
       
  2230 
       
  2231         // Get methods that do not use DOS and return immediately.
       
  2232         // Other methods that return immediately.
       
  2233         // Methods that can propably take a long time flow control not 
       
  2234         // required.
       
  2235         case EPacketGetNtwkRegStatus:
       
  2236         case EPacketGetDynamicCaps:
       
  2237         case EPacketGetStatus:
       
  2238         case EPacketEnumerateContexts:
       
  2239         case EPacketGetContextInfo:
       
  2240         case EPacketGetAttachMode:
       
  2241         case EPacketGetStaticCaps:
       
  2242         case EPacketRejectActivationRequest:
       
  2243         case EPacketSetAttachMode:
       
  2244         case EPacketAttach:
       
  2245         case EPacketDetach:
       
  2246         case EPacketSetPrefBearer:
       
  2247         case EPacketGetPrefBearer:
       
  2248         case EPacketPrepareOpenSecondary:
       
  2249         case EPacketEnumerateNifs:
       
  2250         case EPacketGetNifInfo:
       
  2251         case EPacketEnumerateContextsInNif:
       
  2252         case EPacketGetContextNameInNif:
       
  2253         case EPacketSetDefaultContextParams:
       
  2254         case EPacketGetDefaultContextParams:
       
  2255         case EPacketUpdateMbmsMonitorServiceList:
       
  2256         case EPacketEnumerateMbmsMonitorServiceList:
       
  2257         case EPacketGetMbmsNetworkServiceStatus:
       
  2258         case EPacketEnumerateMbmsActiveServiceList:        
       
  2259         case EPacketGetMbmsMonitoredServicesPhase1:
       
  2260         case EPacketGetMbmsMonitoredServicesPhase2:
       
  2261             break;
       
  2262 
       
  2263         // Commands that change the state of the phone.
       
  2264         case EPacketGetMSClass:
       
  2265             reqMode = KReqModeFlowControlObeyed;
       
  2266             break;
       
  2267 
       
  2268         // Requests that notify a client about a change of state.
       
  2269         case EPacketNotifyContextAdded:
       
  2270         case EPacketNotifyStatusChange:
       
  2271         case EPacketNotifyChangeOfNtwkRegStatus:
       
  2272         case EPacketNotifyContextActivationRequested:
       
  2273         case EPacketNotifyDynamicCapsChange:
       
  2274         case EPacketNotifyMSClassChange:
       
  2275         case EPacketNotifyMbmsNetworkServiceStatusChange:
       
  2276             reqMode = KReqModeMultipleCompletionEnabled |
       
  2277                 KReqModeRePostImmediately;
       
  2278         case EPacketNotifyMbmsServiceAvailabilityChange:       
       
  2279             break;
       
  2280 
       
  2281         // Following requests are not supported
       
  2282         //case EPacketSetMSClass:
       
  2283         default:
       
  2284             User::Leave( KErrNotSupported );
       
  2285             break;
       
  2286         }
       
  2287 
       
  2288     return reqMode;
       
  2289     }
       
  2290 
       
  2291 //----------------------------------------------------------------------------
       
  2292 // CMmPacketServiceTsy::NumberOfSlotsL
       
  2293 // Returns number of slots to be used for given IPC.
       
  2294 // return number of slots to be used for IPC number given in parameter
       
  2295 // leave with KErrNotSupported if invalid IPC
       
  2296 //----------------------------------------------------------------------------
       
  2297 //
       
  2298 TInt CMmPacketServiceTsy::NumberOfSlotsL(
       
  2299     const TInt aIpc ) 
       
  2300     {
       
  2301 TFLOGSTRING2("TSY: CMmPacketServiceTsy::NumberOfSlotsL. IPC: %d", aIpc );
       
  2302 
       
  2303     TInt numberOfSlots( 0 );
       
  2304     switch ( aIpc )
       
  2305         {
       
  2306 
       
  2307         case EPacketNotifyStatusChange:
       
  2308             numberOfSlots = KMmPacketServiceNotifyStatusChangeSlots;
       
  2309             break;
       
  2310         case EPacketNotifyDynamicCapsChange:
       
  2311             numberOfSlots = KMmPacketServiceNotifyDynamicCapsChangeSlots;
       
  2312             break;
       
  2313         case EPacketNotifyContextAdded:
       
  2314             numberOfSlots = KMmPacketServiceNotifyContextAddedSlots;
       
  2315             break;
       
  2316         case EPacketNotifyContextActivationRequested:
       
  2317             numberOfSlots =
       
  2318                 KMmPacketServiceNotifyContextActivationRequestedSlots;
       
  2319             break;
       
  2320         case EPacketNotifyChangeOfNtwkRegStatus:
       
  2321             numberOfSlots = KMmPacketServiceNotifyChangeOfNtwkRegStatusSlots;
       
  2322             break;
       
  2323         case EPacketNotifyMSClassChange:
       
  2324             numberOfSlots = KMmPacketServiceNotifyMSClassChangeSlots;
       
  2325             break;
       
  2326         case EPacketNotifyMbmsNetworkServiceStatusChange:
       
  2327             numberOfSlots = KMmPacketServiceNotifyMBMSServiceStatusSlots;
       
  2328             break;
       
  2329         default:
       
  2330             // Unknown or invalid IPC
       
  2331             User::Leave( KErrNotSupported );
       
  2332             break;
       
  2333         }
       
  2334 
       
  2335     return numberOfSlots;
       
  2336     }
       
  2337 
       
  2338 //----------------------------------------------------------------------------
       
  2339 // CMmPacketServiceTsy::CancelService
       
  2340 // When the clients close their sub-sessions (eg. by calling RPhone::Close),
       
  2341 // they may not have cancelled all their outstanding asynchronous requests
       
  2342 // before closing. It is up to the ETel server to clean up in this situation,
       
  2343 // so the server will find the list of outstanding requests related to that
       
  2344 // sub-session object and pass these outstanding IPC request numbers, one at a
       
  2345 // time, to the CancelService function in the TSY.
       
  2346 // This method is also called when client initiates normal cancel to the
       
  2347 // request.
       
  2348 //----------------------------------------------------------------------------
       
  2349 //
       
  2350 TInt CMmPacketServiceTsy::CancelService(
       
  2351     const TInt aIpc,                    
       
  2352     const TTsyReqHandle aTsyReqHandle ) 
       
  2353     {
       
  2354 TFLOGSTRING3("TSY: CMmPacketServiceTsy::CancelService. IPC: %d Tsy Req Handle:%d", aIpc, aTsyReqHandle);
       
  2355 
       
  2356     TInt ret( KErrNone );
       
  2357     
       
  2358     // Reset last tsy request type
       
  2359     iReqHandleType = EMultimodePacketServiceReqHandleUnknown;
       
  2360 
       
  2361     // When the clients close their sub-sessions (eg. by calling
       
  2362     // RPacketService::Close), they may not have cancelled all their
       
  2363     // outstanding asynchronous requests before closing.  It is up to the ETel
       
  2364     // server to clean up in this situation, so the server will find the list
       
  2365     // of outstanding requests related to that sub-session object and pass
       
  2366     // these outstanding IPC request numbers, one at a time, to the
       
  2367     // CancelService method in the TSY.
       
  2368 
       
  2369     switch ( aIpc )
       
  2370         {
       
  2371 
       
  2372         case EPacketNotifyContextAdded:
       
  2373             iNotifyDataPointers.iContextAdded = NULL;
       
  2374             iReqHandleType = EMultimodePacketServiceNotifyContextAdded;
       
  2375             break;
       
  2376         case EPacketNotifyStatusChange:
       
  2377             iNotifyDataPointers.iStatusChange = NULL;
       
  2378             iReqHandleType = EMultimodePacketServiceNotifyStatusChange;
       
  2379             break;
       
  2380         case EPacketNotifyContextActivationRequested:
       
  2381             if ( aTsyReqHandle == iTsyReqHandleStore->GetTsyReqHandle(
       
  2382                 EMultimodePacketServiceNotifyContextActivationRequested ) )
       
  2383                 {
       
  2384                 iNotifyDataPointers.iContextActivationRequested = NULL;
       
  2385                 iReqHandleType =
       
  2386                     EMultimodePacketServiceNotifyContextActivationRequested;
       
  2387                 }
       
  2388             else if ( aTsyReqHandle == iTsyReqHandleStore->GetTsyReqHandle(
       
  2389                 EMultimodePacketServiceNotifyContextActivationRequested99 ) )
       
  2390                 {
       
  2391                 iNotifyDataPointers.iContextActivationRequested99 = NULL;
       
  2392                 iReqHandleType =
       
  2393                     EMultimodePacketServiceNotifyContextActivationRequested99;
       
  2394                 }
       
  2395             else if ( aTsyReqHandle == iTsyReqHandleStore->GetTsyReqHandle(
       
  2396                 EMultimodePacketServiceNotifyContextActivationRequested5 ) )
       
  2397                 {
       
  2398                 iNotifyDataPointers.iContextActivationRequested5 = NULL;
       
  2399                 iReqHandleType =
       
  2400                     EMultimodePacketServiceNotifyContextActivationRequested5;
       
  2401                 }                
       
  2402             break;
       
  2403         case EPacketNotifyChangeOfNtwkRegStatus:
       
  2404             iNotifyDataPointers.iChangeOfNtwkRegStatus = NULL;
       
  2405             iReqHandleType = EMultimodePacketServiceNotifyNtwkRegStatusChange;
       
  2406             break;
       
  2407         case EPacketNotifyMSClassChange:
       
  2408             iNotifyDataPointers.iMSClassChange = NULL;
       
  2409             iReqHandleType = EMultimodePacketServiceNotifyMSClassChange;
       
  2410             break;
       
  2411         case EPacketNotifyDynamicCapsChange:
       
  2412             iNotifyDataPointers.iDynamicCapsChange = NULL;
       
  2413             iReqHandleType = EMultimodePacketServiceNotifyDynamicCapsChange;
       
  2414             break;
       
  2415         case EPacketNotifyMbmsNetworkServiceStatusChange:
       
  2416         	iNotifyDataPointers.iMBMSStatusChange = NULL;
       
  2417         	iReqHandleType = EMultimodePacketServiceNotifyMBMSStatusChange;
       
  2418         	break;
       
  2419         case EPacketNotifyMbmsServiceAvailabilityChange:
       
  2420          	iReqHandleType = EMultimodePacketServiceNotifyMbmsServiceAvailabilityChange;
       
  2421         	break;       
       
  2422         case EPacketGetMbmsNetworkServiceStatus:
       
  2423          	iReqHandleType = EMultimodePacketServiceGetMBMSStatus;
       
  2424         	break;       
       
  2425         case EPacketGetMbmsMonitoredServicesPhase1:
       
  2426         case EPacketGetMbmsMonitoredServicesPhase2:
       
  2427         	GetMbmsMonitoredServicesCancel( aTsyReqHandle );
       
  2428         	break;
       
  2429         case EPacketUpdateMbmsMonitorServiceList:
       
  2430         	UpdateMbmsMonitorServiceListCancel(aTsyReqHandle);	
       
  2431         	break;
       
  2432         // TSY has started a request and it is not possible to then
       
  2433         // cancel this request. The best thing for the TSY to do in this case
       
  2434         // is to proceed as though the Cancel never happened. The server's 
       
  2435         // call to the TSY cancel function will return synchronously.
       
  2436         case EPacketAttach:
       
  2437         case EPacketDetach:
       
  2438         case EPacketGetStatus:
       
  2439         case EPacketRejectActivationRequest:
       
  2440         case EPacketEnumerateContexts:
       
  2441         case EPacketGetContextInfo:
       
  2442         case EPacketGetNtwkRegStatus:
       
  2443         case EPacketGetMSClass:
       
  2444         case EPacketSetPrefBearer:
       
  2445         case EPacketGetPrefBearer:
       
  2446         case EPacketGetStaticCaps:
       
  2447         case EPacketGetDynamicCaps:
       
  2448         case EPacketSetAttachMode:
       
  2449         case EPacketGetAttachMode:
       
  2450         case EPacketEnumerateNifs:
       
  2451         case EPacketGetNifInfo:
       
  2452         case EPacketEnumerateContextsInNif:
       
  2453         case EPacketGetContextNameInNif:
       
  2454         case EPacketSetDefaultContextParams:
       
  2455         case EPacketGetDefaultContextParams:
       
  2456         case EPacketEnumerateMbmsMonitorServiceList:
       
  2457         case EPacketEnumerateMbmsActiveServiceList:
       
  2458             break;
       
  2459 
       
  2460         // Cancel methods that are not supported.
       
  2461         //case EPacketSetMSClass:
       
  2462         default:
       
  2463             ret = KErrNotSupported;
       
  2464             break;
       
  2465         }
       
  2466 
       
  2467     if ( EMultimodePacketServiceReqHandleUnknown != iReqHandleType )
       
  2468         {
       
  2469         // Reset tsy request handle
       
  2470         iTsyReqHandleStore->ResetTsyReqHandle( iReqHandleType );
       
  2471 
       
  2472         // Complete request with KErrCancel
       
  2473         CMmPacketServiceTsy::ReqCompleted( aTsyReqHandle, KErrCancel );
       
  2474         }
       
  2475 
       
  2476     return ret;
       
  2477     }
       
  2478 
       
  2479 //----------------------------------------------------------------------------
       
  2480 // TInt CMmPacketServiceTsy::RegisterNotification
       
  2481 // Register notification.
       
  2482 // Returns KErrNone to ETel server in case of known notification request type.
       
  2483 //----------------------------------------------------------------------------
       
  2484 //
       
  2485 TInt CMmPacketServiceTsy::RegisterNotification(
       
  2486     const TInt aIpc ) 
       
  2487 	{
       
  2488 TFLOGSTRING2("TSY: CMmPacketServiceTsy::RegisterNotification. IPC: %d", aIpc );
       
  2489 
       
  2490     TInt ret( KErrNone );
       
  2491 
       
  2492     switch ( aIpc )
       
  2493         {
       
  2494         case EPacketNotifyContextAdded:
       
  2495         case EPacketNotifyStatusChange:
       
  2496         case EPacketNotifyContextActivationRequested:
       
  2497         case EPacketNotifyChangeOfNtwkRegStatus:
       
  2498         case EPacketNotifyMSClassChange:
       
  2499         case EPacketNotifyDynamicCapsChange:
       
  2500         case EPacketNotifyMbmsNetworkServiceStatusChange:
       
  2501         case EPacketNotifyMbmsServiceAvailabilityChange:
       
  2502             break;
       
  2503         default:
       
  2504             // Not supported
       
  2505             ret = KErrNotSupported;
       
  2506             break;
       
  2507         }
       
  2508 
       
  2509     return ret;
       
  2510     }
       
  2511 
       
  2512 //----------------------------------------------------------------------------
       
  2513 // CMmPacketServiceTsy::DeregisterNotification
       
  2514 // Deregister notification.
       
  2515 // Returns KErrNone to ETel server in case of known notification request type.
       
  2516 //----------------------------------------------------------------------------
       
  2517 //
       
  2518 TInt CMmPacketServiceTsy::DeregisterNotification(
       
  2519     const TInt aIpc ) 
       
  2520     {
       
  2521 TFLOGSTRING2("TSY: CMmPacketServiceTsy::DeregisterNotification. IPC: %d", aIpc );
       
  2522 
       
  2523     TInt ret( KErrNone );
       
  2524 
       
  2525     switch ( aIpc )
       
  2526         {
       
  2527         case EPacketNotifyContextAdded:
       
  2528         case EPacketNotifyStatusChange:
       
  2529         case EPacketNotifyContextActivationRequested:
       
  2530         case EPacketNotifyChangeOfNtwkRegStatus:
       
  2531         case EPacketNotifyMSClassChange:
       
  2532         case EPacketNotifyDynamicCapsChange:
       
  2533         case EPacketNotifyMbmsNetworkServiceStatusChange:
       
  2534         case EPacketNotifyMbmsServiceAvailabilityChange:
       
  2535             break;
       
  2536         default:
       
  2537             // Not supported
       
  2538             ret = KErrNotSupported;
       
  2539             break;
       
  2540         }
       
  2541 
       
  2542     return ret;
       
  2543     }
       
  2544     
       
  2545   
       
  2546 
       
  2547 //-----------------------------------------------------------------------------
       
  2548 // TInt CMmPacketServiceTsy::GetMbmsNetworkServiceStatus
       
  2549 // Requests Get MBMS network service status 
       
  2550 //-----------------------------------------------------------------------------
       
  2551 //
       
  2552 TInt CMmPacketServiceTsy::GetMbmsNetworkServiceStatus(
       
  2553 		TBool aAttemptAttach, 
       
  2554 		TMbmsNetworkServiceStatus* aMBMSServiceStatus )
       
  2555 {
       
  2556 TFLOGSTRING2("TSY: CMmPacketServiceTsy:: TMbmsNetworkServiceStatus = %d", aMBMSServiceStatus );	
       
  2557 
       
  2558    const TTsyReqHandle regHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
  2559    EMultimodePacketServiceGetMBMSStatus ) );
       
  2560    
       
  2561    TInt ret( KErrServerBusy ); 
       
  2562    if ( !iMbmsStatusCached )
       
  2563     	{
       
  2564     	if ( EMultimodePacketServiceReqHandleUnknown == regHandle )  
       
  2565     		{
       
  2566     		// Save pointer to aMBMSServiceStatus
       
  2567     		iTemporarySavedData.iMbmsStatus = aMBMSServiceStatus;  
       
  2568     		    			    
       
  2569 	    	// Get MBMS network service status
       
  2570 	    	CMmDataPackage dataPackage;
       
  2571 	    	dataPackage.PackData( &aAttemptAttach );
       
  2572 			TRAPD(err, ret = iMessageManager->HandleRequestL( EPacketGetMbmsNetworkServiceStatus, &dataPackage));
       
  2573 			if(err != KErrNone)
       
  2574 				{
       
  2575 				ret = err;
       
  2576 				}
       
  2577 			}
       
  2578 			if ( KErrNone == ret )
       
  2579    				{
       
  2580    	 			// Set request handle type
       
  2581 	    		iReqHandleType = EMultimodePacketServiceGetMBMSStatus;	
       
  2582    				}
       
  2583     		
       
  2584     	}
       
  2585     else // iMbmsStatusCached == ETrue
       
  2586     	{
       
  2587     	
       
  2588 		*aMBMSServiceStatus = iInternalSavedData.iMbmsStatus;
       
  2589 		
       
  2590    		// Complete the request with KErrNone
       
  2591     	CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  2592 
       
  2593     	ret = KErrNone;
       
  2594     
       
  2595    		}
       
  2596    		
       
  2597  	return ret;	
       
  2598 }
       
  2599 	
       
  2600 //-----------------------------------------------------------------------------
       
  2601 // void CMmPacketServiceTsy::CompleteGetMbmsNetworkServiceStatus
       
  2602 // Completes Get MBMS network service status request 
       
  2603 //-----------------------------------------------------------------------------
       
  2604 //
       
  2605 void CMmPacketServiceTsy::CompleteGetMbmsNetworkServiceStatus( 
       
  2606 	CMmDataPackage* aDataPackage, TInt aError )
       
  2607 	{
       
  2608 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteGetMbmsNetworkServiceStatus.");
       
  2609 
       
  2610 	//Update the cache
       
  2611 	TMbmsNetworkServiceStatus mbmsNetworkServiceStatus = EMbmsSupportUnknown;
       
  2612 	if ( KErrNone == aError )
       
  2613 		{
       
  2614 		//Unpack necessary data from datapackage
       
  2615 		if ( aDataPackage )
       
  2616 			{
       
  2617 			aDataPackage->UnPackData( mbmsNetworkServiceStatus );
       
  2618 			}
       
  2619             
       
  2620 		// Change MBMS cache indicator value
       
  2621 		iMbmsStatusCached = ETrue;
       
  2622 		iInternalSavedData.iMbmsStatus = mbmsNetworkServiceStatus;
       
  2623 		}
       
  2624 
       
  2625 	// Reset request handle. Returns the deleted request handle
       
  2626 	const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  2627 	EMultimodePacketServiceGetMBMSStatus ) );
       
  2628 
       
  2629    // If request handle ok
       
  2630     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  2631     	{
       
  2632     	*iTemporarySavedData.iMbmsStatus = mbmsNetworkServiceStatus;
       
  2633         // Complete the client request
       
  2634         CMmPacketServiceTsy::ReqCompleted( reqHandle, aError );
       
  2635         }
       
  2636 	}
       
  2637 	
       
  2638 //-----------------------------------------------------------------------------
       
  2639 // TInt CMmPacketServiceTsy::NotifyMbmsNetworkServiceStatusChange
       
  2640 // Requests notification of MBMS network service status change.
       
  2641 // Allows a client to be notified whenever a change in the status of the
       
  2642 // MBMS network service is detected.
       
  2643 //-----------------------------------------------------------------------------
       
  2644 //
       
  2645 
       
  2646 TInt CMmPacketServiceTsy::NotifyMbmsNetworkServiceStatusChange(
       
  2647 	TMbmsNetworkServiceStatus* aMBMSServiceStatus )
       
  2648 	{
       
  2649 TFLOGSTRING2("TSY: CMmPacketServiceTsy::NotifyMbmsNetworkServiceStatusChange TMbmsNetworkServiceStatus = %d", aMBMSServiceStatus );
       
  2650 	
       
  2651 	// Set request handle and save pointer to aMBMSServiceStatus
       
  2652     iNotifyDataPointers.iMBMSStatusChange = aMBMSServiceStatus;
       
  2653     iReqHandleType =  EMultimodePacketServiceNotifyMBMSStatusChange;
       
  2654 
       
  2655     return KErrNone;
       
  2656 	}
       
  2657 	
       
  2658 //-----------------------------------------------------------------------------
       
  2659 // Void CMmPacketServiceTsy::NotifyMbmsNetworkServiceStatusChange
       
  2660 // Completes notification of MBMS network service status request 
       
  2661 //-----------------------------------------------------------------------------
       
  2662 //	
       
  2663 void CMmPacketServiceTsy::CompleteNotifyMbmsNetworkServiceStatusChange( 
       
  2664 	CMmDataPackage* aDataPackage, TInt aResult )
       
  2665 	{
       
  2666 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyMbmsNetworkServiceStatusChange.");
       
  2667 	        
       
  2668 	TInt result = aResult;        
       
  2669 	if (aResult == KErrNone)
       
  2670 		{	        
       
  2671 		//Unpack necessary data from datapackage
       
  2672 		TMbmsNetworkServiceStatus newMbmsNetworkServiceStatus;
       
  2673 		aDataPackage->UnPackData( newMbmsNetworkServiceStatus );
       
  2674 	
       
  2675 		// If Mbms network service status changed
       
  2676 		if ( newMbmsNetworkServiceStatus != iInternalSavedData.iMbmsStatus )
       
  2677         	{
       
  2678 
       
  2679         	// Save new status internally
       
  2680         	iInternalSavedData.iMbmsStatus = newMbmsNetworkServiceStatus;
       
  2681         	iMbmsStatusCached = ETrue;
       
  2682         	
       
  2683         	// Reset request handle. Returns the deleted request handle
       
  2684 			const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  2685 	        EMultimodePacketServiceNotifyMBMSStatusChange ) );
       
  2686 	        	
       
  2687 	        // If request handle ok
       
  2688 	    	if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  2689 	        	{
       
  2690            		// Set MbmsNetworkServiceStatus to the etel side memory
       
  2691            		*iNotifyDataPointers.iMBMSStatusChange = newMbmsNetworkServiceStatus;
       
  2692            		iNotifyDataPointers.iMBMSStatusChange = NULL;
       
  2693 
       
  2694 	       		// Complete the client request
       
  2695 	       		CMmPacketServiceTsy::ReqCompleted( reqHandle, result );
       
  2696 
       
  2697         		}
       
  2698        	 	} 
       
  2699        	 		
       
  2700 		}
       
  2701 	else // result is != KErrNone
       
  2702 		{
       
  2703 		// Reset request handle. Returns the deleted request handle
       
  2704 		const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  2705 	    EMultimodePacketServiceNotifyMBMSStatusChange ) );
       
  2706 	   	// Complete the client request
       
  2707 	    CMmPacketServiceTsy::ReqCompleted( reqHandle, result );
       
  2708 		}
       
  2709 	}
       
  2710 	
       
  2711 //-----------------------------------------------------------------------------
       
  2712 // TInt CMmPacketServiceTsy::NotifyMbmsServiceAvailabilityChange
       
  2713 // Requests notification of MBMS service availability status change.
       
  2714 // Allows a client to be notified whenever a change in the status of the
       
  2715 // MBMS network service is detected.
       
  2716 //-----------------------------------------------------------------------------
       
  2717 //
       
  2718 TInt CMmPacketServiceTsy::NotifyMbmsServiceAvailabilityChange()
       
  2719 	{
       
  2720 TFLOGSTRING("TSY: CMmPacketServiceTsy::NotifyMbmsServiceAvailabilityChange.");
       
  2721 	
       
  2722 	// Set request handle
       
  2723     iReqHandleType =  EMultimodePacketServiceNotifyMbmsServiceAvailabilityChange;
       
  2724 
       
  2725     return KErrNone;
       
  2726 	}
       
  2727 	
       
  2728 //-----------------------------------------------------------------------------
       
  2729 // Void CMmPacketServiceTsy::CompleteNotifyMbmsServiceAvailabilityChange
       
  2730 // Completes notification of MBMS service availability status request 
       
  2731 //-----------------------------------------------------------------------------
       
  2732 //	
       
  2733 void CMmPacketServiceTsy::CompleteNotifyMbmsServiceAvailabilityChangeL(CMmDataPackage* aDataPackage, TInt aResult)
       
  2734 	{
       
  2735 	// Reset request handle. Returns the deleted request handle
       
  2736 	const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  2737 	        EMultimodePacketServiceNotifyMbmsServiceAvailabilityChange ) );
       
  2738 		
       
  2739 	// If request handle ok
       
  2740 	if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  2741 		{
       
  2742 #ifdef USING_CTSY_DISPATCHER
       
  2743 		//three defects, 
       
  2744 		//1) no need to allocate a list all we need is a pointer and we unpack over this
       
  2745 		//2) PopAndDestroy at the end could cause issues, in the iMBMSMonitoredList null case
       
  2746 		//3) if completed with an Error,this will cause subsequent  notifys to have no effect as
       
  2747 		//the request handle has been removed from the store. Here as before the request is completed 
       
  2748 		//with aResult on aDataPackage or iMBMSMonitoredList being null.
       
  2749 		if((aResult == KErrNone) && aDataPackage && iMBMSMonitoredList)
       
  2750 			{
       
  2751 			CPcktMbmsMonitoredServiceList* updatedMonitorList = NULL;
       
  2752 			//Unpack necessary data from datapackage
       
  2753 			aDataPackage->UnPackData(&updatedMonitorList);
       
  2754 			iMBMSMonitoredList->SetServicesAvailabilityL(updatedMonitorList);
       
  2755 			}
       
  2756 		
       
  2757 		// Complete the client request
       
  2758  	   	CMmPacketServiceTsy::ReqCompleted( reqHandle, aResult );
       
  2759 				
       
  2760 #else
       
  2761 		if (aResult == KErrNone)
       
  2762 			{
       
  2763 			if (aDataPackage)
       
  2764 				{
       
  2765 				if(iMBMSMonitoredList != NULL)
       
  2766 					{
       
  2767 					// Create new list for changes
       
  2768 					CPcktMbmsMonitoredServiceList* updatedMonitorList = CPcktMbmsMonitoredServiceList::NewL();
       
  2769 					CleanupStack::PushL(updatedMonitorList);
       
  2770 				
       
  2771 					//Unpack necessary data from datapackage
       
  2772 					aDataPackage->UnPackData( &updatedMonitorList );
       
  2773 					iMBMSMonitoredList->SetServicesAvailabilityL(updatedMonitorList);
       
  2774 					}
       
  2775 				// Complete the client request
       
  2776 		 	   	CMmPacketServiceTsy::ReqCompleted( reqHandle, aResult );
       
  2777 	 	  	 	CleanupStack::PopAndDestroy();		 	   	
       
  2778 	 	   		}
       
  2779 	 	   	else
       
  2780 	 	   		{
       
  2781 				CMmPacketServiceTsy::ReqCompleted( reqHandle, aResult );	
       
  2782 	 	   		}
       
  2783 			}
       
  2784 #endif //USING_CTSY_DISPATCHER
       
  2785 		}
       
  2786 	}					
       
  2787 
       
  2788 //----------------------------------------------------------------------------
       
  2789 // CMmPacketServiceTsy::EnumerateMonitorServiceList
       
  2790 // Enumrates monitored service list
       
  2791 //----------------------------------------------------------------------------
       
  2792 //
       
  2793 TInt CMmPacketServiceTsy::EnumerateMonitorServiceList( TInt& aCount, TInt& aMaxAllowed )
       
  2794     {
       
  2795 		if (iMBMSMonitoredList != NULL)
       
  2796 			{
       
  2797 			aCount = iMBMSMonitoredList->NumberOfMonitoredList(  );	
       
  2798 			}
       
  2799 		else
       
  2800 			{
       
  2801 			aCount = 0;
       
  2802 			}
       
  2803     	aMaxAllowed = iMaxMonitoredServices;
       
  2804     	
       
  2805 TFLOGSTRING("TSY: CMmPacketServiceTsy::EnumerateMonitorServiceList." ); 
       
  2806       		
       
  2807        	// Complete the request with KErrNone
       
  2808     	CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );	  
       
  2809 
       
  2810     return KErrNone;
       
  2811     } 
       
  2812 
       
  2813 //----------------------------------------------------------------------------
       
  2814 // CMmPacketServiceTsy::CompleteMaxMonitoredServicesChange
       
  2815 // Enumrates monitored service list
       
  2816 //----------------------------------------------------------------------------
       
  2817 //    
       
  2818 void CMmPacketServiceTsy::CompleteMaxMonitoredServicesChange( TInt aMaxMonitorValue )
       
  2819 	{
       
  2820 	iMaxMonitoredServices = aMaxMonitorValue;
       
  2821 	}
       
  2822 //----------------------------------------------------------------------------
       
  2823 // CMmPacketServiceTsy::UpdateMbmsMonitorServiceListL
       
  2824 // Request to update monitored service list
       
  2825 //----------------------------------------------------------------------------
       
  2826 //
       
  2827 TInt CMmPacketServiceTsy::UpdateMbmsMonitorServiceListL( TMbmsAction aAction,   
       
  2828              TDes8* aList )
       
  2829     { 
       
  2830     const TTsyReqHandle reqHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
  2831    	EMultimodePacketServiceUpdateMBMSMonitorServiceList ) );
       
  2832     
       
  2833     TInt ret( KErrServerBusy ); 
       
  2834    
       
  2835 	if ( EMultimodePacketServiceReqHandleUnknown == reqHandle )  
       
  2836 		{ 
       
  2837 		if (iMBMSMonitoredList == NULL)
       
  2838 			{
       
  2839 			// create MBMS monitored service list
       
  2840 	 		iMBMSMonitoredList = CMmMBMSMonitoredList::NewL( this, iMaxMonitoredServices );	
       
  2841 			}
       
  2842 		iActionType = aAction;
       
  2843 		// Save changes of Monitored service list and action
       
  2844 		ret = iMBMSMonitoredList->SaveUpdateValuesToTempL(aList, aAction); 
       
  2845 		
       
  2846 		// temp list was ok
       
  2847 		if( KErrNone == ret )
       
  2848 			{
       
  2849 			// Get correct data packet and send it to LTSY
       
  2850 			ret = iMBMSMonitoredList->PackDataL();	
       
  2851 			
       
  2852 			if ( KErrNone == ret )
       
  2853 				{
       
  2854 				// Set request handle type
       
  2855 				iReqHandleType = EMultimodePacketServiceUpdateMBMSMonitorServiceList;	
       
  2856 				}
       
  2857 			}
       
  2858 		else if( KErrAlreadyExists == ret )
       
  2859 			{
       
  2860 			// there were no new entries client tried to supply. Complete with KErrNone
       
  2861 			// to client to think updating was ok
       
  2862 			CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  2863 			ret = KErrNone;
       
  2864 			}
       
  2865 		else if( KErrNotFound == ret )
       
  2866 			{
       
  2867 			// there were no new entries client tried to supply. Complete with KErrNotfound
       
  2868 			CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, ret );
       
  2869 			ret = KErrNone;
       
  2870 			}
       
  2871 		}	
       
  2872 	
       
  2873  	return ret;	
       
  2874     
       
  2875     }
       
  2876 
       
  2877 //----------------------------------------------------------------------------
       
  2878 // CMmPacketServiceTsy::CompleteUpdateMbmsMonitorServiceListL
       
  2879 // Completes update monitored service list request
       
  2880 //----------------------------------------------------------------------------
       
  2881 //
       
  2882 void CMmPacketServiceTsy::CompleteUpdateMbmsMonitorServiceList( 
       
  2883     CMmDataPackage* aDataPackage, 
       
  2884     const TInt aResult)
       
  2885 	{
       
  2886 	TFLOGSTRING( "TSY: CMmPacketServiceTsy::CompleteUpdateMbmsMonitorServiceListL." );
       
  2887 
       
  2888 	TInt result= aResult;
       
  2889 	// Reset request handle. Returns the deleted request handle
       
  2890 	const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  2891 	        EMultimodePacketServiceUpdateMBMSMonitorServiceList ) );
       
  2892 	        
       
  2893 	if( aResult == KErrNone )
       
  2894 		{
       
  2895 		result = iMBMSMonitoredList->ProcessEntriesL(NULL, iActionType);
       
  2896         CompleteNotifyMbmsServiceAvailabilityChangeL( NULL, aResult );		
       
  2897 		}
       
  2898 	//there were problem managing entries
       
  2899 	else if( (aResult == KErrMbmsImpreciseServiceEntries) && (aDataPackage != NULL) )
       
  2900 		{
       
  2901 		CPcktMbmsMonitoredServiceList* failedMonitorEntries = NULL;
       
  2902 		aDataPackage->UnPackData( &failedMonitorEntries ); 
       
  2903 		// there were a problems with some entries, 
       
  2904 		// Check failed entries exists and add succesful entries to main list
       
  2905 		if( failedMonitorEntries != NULL )
       
  2906 			{
       
  2907 			iMBMSMonitoredList->ProcessEntriesL( failedMonitorEntries, iActionType );
       
  2908 			}
       
  2909 		else // There was a general error, don't add anything to main list
       
  2910 			{
       
  2911 			iMBMSMonitoredList->ResetTempListL();
       
  2912 			}
       
  2913 		}
       
  2914 	 if( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  2915 		 {
       
  2916 		 //complete with error to client
       
  2917 		 CMmPacketServiceTsy::ReqCompleted( reqHandle, result );
       
  2918 		 }
       
  2919 	    
       
  2920 	}
       
  2921 	
       
  2922 //----------------------------------------------------------------------------
       
  2923 // CMmPacketServiceTsy::UpdateMbmsMonitorServiceListCancel
       
  2924 // Completes update monitored service list request
       
  2925 //----------------------------------------------------------------------------
       
  2926 //
       
  2927 TInt CMmPacketServiceTsy::UpdateMbmsMonitorServiceListCancel( TTsyReqHandle aTsyReqHandle )	
       
  2928 	{
       
  2929 	TFLOGSTRING2( "TSY: CMmPacketServiceTsy::UpdateMbmsMonitorServiceListCancel ReqHandle %d", aTsyReqHandle );
       
  2930 	
       
  2931 	if ( aTsyReqHandle != EMultimodePacketServiceReqHandleUnknown )
       
  2932         {
       
  2933         // Reset tsy request handle
       
  2934         iTsyReqHandleStore->ResetTsyReqHandle( EMultimodePacketServiceUpdateMBMSMonitorServiceList );
       
  2935 
       
  2936         // Complete request to client with KErrCancel
       
  2937         ReqCompleted( aTsyReqHandle, KErrCancel );
       
  2938         }	
       
  2939         
       
  2940     return KErrNone;
       
  2941 	}
       
  2942 
       
  2943 
       
  2944 
       
  2945 //----------------------------------------------------------------------------
       
  2946 // CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase1L
       
  2947 // Returns size of the monitored service list.
       
  2948 //----------------------------------------------------------------------------
       
  2949 //
       
  2950 TInt CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase1L(RMobilePhone::TClientId* aClient,  TUint& aBufSize)
       
  2951 	{
       
  2952 	TFLOGSTRING("TSY: CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase1L called.");
       
  2953 	// Initialize ret value
       
  2954 	TInt ret( KErrNone );
       
  2955 	TInt leaveCode( KErrNone );
       
  2956 	
       
  2957 
       
  2958 	if( !iMBMSMonitoredList )
       
  2959 		{
       
  2960 		// No current monitor servece list exist. Complete error.
       
  2961 		ReqCompleted( iTsyReqHandle, KErrNotFound );
       
  2962 		}
       
  2963 	else
       
  2964 		{
       
  2965 		// Get current size of monitor service list
       
  2966 		TRAP( leaveCode, ret = GetSizeOfMonitoredServiceListL( aClient, aBufSize ) );
       
  2967 		if (leaveCode == KErrNone)
       
  2968 			{
       
  2969 			leaveCode = ret;
       
  2970 			}
       
  2971 		if ( leaveCode != KErrNone )
       
  2972 			{
       
  2973 			ReqCompleted( iTsyReqHandle, leaveCode );
       
  2974 			}
       
  2975 		}
       
  2976 	
       
  2977 	return leaveCode;
       
  2978 	}
       
  2979 
       
  2980 // ---------------------------------------------------------------------------
       
  2981 // CMmMBMSMonitoredList::GetSizeOfMonitoredServiceList
       
  2982 // This function returns size of monitored servicelist.
       
  2983 // ---------------------------------------------------------------------------
       
  2984 //  
       
  2985 TInt CMmPacketServiceTsy::GetSizeOfMonitoredServiceListL(RMobilePhone::TClientId* aClient,  TUint& aBufSize)
       
  2986 	{
       
  2987 	// read the list, store its content and then return size of this buffer to client
       
  2988 	TFLOGSTRING("TSY: CMmPacketServiceTsy::GetSizeOfMonitoredServiceList called.");
       
  2989 	// create new list
       
  2990 	CPcktMbmsMonitoredServiceList* currentList=CPcktMbmsMonitoredServiceList::NewL();
       
  2991 	CleanupStack::PushL(currentList);
       
  2992 	RPacketService::TMbmsServiceAvailabilityV1 entry;
       
  2993 	
       
  2994 	if (!iMBMSMonitoredList)
       
  2995 		{
       
  2996 		// create MBMS monitored service list
       
  2997  		iMBMSMonitoredList = CMmMBMSMonitoredList::NewL( this, iMaxMonitoredServices );	
       
  2998 		}
       
  2999 	
       
  3000 	// fill TMbmsServiceAvailabilityV1 information
       
  3001 	for (TInt i=0; i < iMBMSMonitoredList->ServiceList()->Enumerate(); i++)
       
  3002 		{
       
  3003 		
       
  3004 		entry = iMBMSMonitoredList->ServiceList()->GetEntryL(i);
       
  3005 		// Add the entry into the list, at the next empty location
       
  3006 		currentList->AddEntryL(entry);
       
  3007 		}
       
  3008 	// Store the streamed list and the client ID
       
  3009 	CListReadAllAttempt* read = CListReadAllAttempt::NewL( aClient );
       
  3010 	CleanupStack::PushL(read);
       
  3011 
       
  3012 	read->iListBuf = currentList->StoreLC();
       
  3013 	CleanupStack::Pop(); // pop the CBufFlat allocated by StoreLC; iListBuf will be destroy by read destructor 
       
  3014 	
       
  3015 	iGetMbmsMonitoredServiceLists->AppendL(read);
       
  3016 	CleanupStack::Pop(); // pop the CListReadAllAttempt; the read will be destroy in phase 2
       
  3017 	
       
  3018     // return the CBufFlat's size to client
       
  3019 	aBufSize=(read->iListBuf)->Size();
       
  3020 TFLOGSTRING2("TSY: CMmPacketServiceTsy::GetSizeOfMonitoredServiceList: size=%d",aBufSize);  	
       
  3021     // Complete first phase of list retrieval
       
  3022     ReqCompleted( iTsyReqHandle, KErrNone );
       
  3023     CleanupStack::PopAndDestroy( currentList ); // Pop & destroy list
       
  3024     return KErrNone;	
       
  3025 	}
       
  3026 			
       
  3027 //----------------------------------------------------------------------------
       
  3028 // CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase2
       
  3029 // Returns monitored service list.
       
  3030 //----------------------------------------------------------------------------
       
  3031 //
       
  3032 TInt CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase2(RMobilePhone::TClientId* aClient, TDes8* aBuf)
       
  3033 	{
       
  3034 	// Initialize ret value
       
  3035     TInt ret( KErrNotFound );
       
  3036     
       
  3037 	TFLOGSTRING("TSY: CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase2 called");
       
  3038 	CListReadAllAttempt* read=NULL;
       
  3039 	
       
  3040 	// Find the get Mbms monitored services from this client
       
  3041 	for (TInt i=0; i<iGetMbmsMonitoredServiceLists->Count(); ++i)
       
  3042 		{
       
  3043 		// Check that session and client are rigth ones
       
  3044 		read = iGetMbmsMonitoredServiceLists->At(i);
       
  3045 		
       
  3046 		if ((read->iClient.iSessionHandle == aClient->iSessionHandle) &&
       
  3047 		    (read->iClient.iSubSessionHandle == aClient->iSubSessionHandle))
       
  3048 			{
       
  3049 			TPtr8 bufPtr((read->iListBuf)->Ptr(0));
       
  3050 			
       
  3051 	  	
       
  3052 	  		if ( bufPtr.Length() <= aBuf->Length() )
       
  3053 		  		{
       
  3054 		  		// Copy the streamed list to the client
       
  3055 				// Set pointer to list buffer
       
  3056 				aBuf->Copy( bufPtr );
       
  3057 				ret = KErrNone;
       
  3058 				}
       
  3059 			else
       
  3060 				{
       
  3061 				ret = KErrArgument;
       
  3062 				}
       
  3063 			
       
  3064 			// Delete read and item from internal array
       
  3065 			delete read;
       
  3066 			iGetMbmsMonitoredServiceLists->Delete(i);
       
  3067 			
       
  3068 			// Complete request
       
  3069 			ReqCompleted(iTsyReqHandle, ret);
       
  3070 			
       
  3071             return ret;
       
  3072 			}
       
  3073 		}
       
  3074 		
       
  3075     // Doesn't found the matching client for read all phase 1
       
  3076     return ret;	
       
  3077 	}
       
  3078 	
       
  3079 //-----------------------------------------------------------------------------
       
  3080 // TInt CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase1LCancel
       
  3081 // Cancels Set Always On request
       
  3082 //-----------------------------------------------------------------------------
       
  3083 //
       
  3084 TInt CMmPacketServiceTsy::GetMbmsMonitoredServicesCancel( TTsyReqHandle aTsyReqHandle )
       
  3085 	{
       
  3086 	
       
  3087 TFLOGSTRING("TSY: CMmPacketServiceTsy::GetMbmsMonitoredServicesPhase1LCancel called");	
       
  3088     // Remove the read all attempt
       
  3089     CListReadAllAttempt* read = NULL;
       
  3090 
       
  3091     // Check that read all array does not contain any data.
       
  3092     // If it does, delete it.
       
  3093     // NOTE: functions request mode "Flow control obeyed" currently blocks
       
  3094     // request so that only one client can request data at the time.
       
  3095     // Therefore, loop-functionality is not needed.
       
  3096     if ( iGetMbmsMonitoredServiceLists->Count() > 0 )
       
  3097         {
       
  3098         read = iGetMbmsMonitoredServiceLists->At( 0 );
       
  3099         delete read;
       
  3100         iGetMbmsMonitoredServiceLists->Delete( 0 );
       
  3101         }
       
  3102 
       
  3103     ReqCompleted( aTsyReqHandle, KErrCancel );
       
  3104 
       
  3105     return KErrNone;	
       
  3106 	}	
       
  3107 	
       
  3108 //----------------------------------------------------------------------------
       
  3109 // CMmPacketServiceTsy::MBMSContextList
       
  3110 // Returns pointer to MBMS context list.
       
  3111 //----------------------------------------------------------------------------
       
  3112 //
       
  3113 CMmMBMSContextList* CMmPacketServiceTsy::MBMSContextList()
       
  3114     {
       
  3115     return iMBMSContextList;
       
  3116     }
       
  3117        
       
  3118 
       
  3119 //----------------------------------------------------------------------------
       
  3120 // CMmPacketServiceTsy::OpenNewObjectL
       
  3121 // Creates new Context object and returns a pointer to it.
       
  3122 //----------------------------------------------------------------------------
       
  3123 //
       
  3124 CTelObject* CMmPacketServiceTsy::OpenNewObjectL(
       
  3125     TDes& aNewName )  
       
  3126     {
       
  3127 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectL. %S", &aNewName );
       
  3128     CTelObject* newContext = NULL;
       
  3129     TUint8 proxyId( 0 );    
       
  3130     TInt ret( KErrNone );
       
  3131              
       
  3132     if(0 == aNewName.Compare(KMBMSContextName))
       
  3133         {
       
  3134         ret = iMBMSContextList->GenerateNewContextName( aNewName, proxyId, iMaxActiveServices );
       
  3135 
       
  3136         if( KErrNone != ret )
       
  3137             {
       
  3138 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectL. Mbms Leaves with: %d", ret );
       
  3139             User::Leave( ret );            
       
  3140             }
       
  3141             
       
  3142         CMmMBMSContextTsy* context = CMmMBMSContextTsy::NewL( this, aNewName, proxyId ); 
       
  3143         ret = iMBMSContextList->AddObject( context );
       
  3144         if( KErrNone != ret )
       
  3145             {
       
  3146             // Created context couldn't save.
       
  3147             // Call Close() to context to remove it completely
       
  3148             context->Close();
       
  3149             context = NULL;
       
  3150 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectL. Mbms Leaves  with: %d", ret );
       
  3151             User::Leave( ret );
       
  3152             }
       
  3153         else
       
  3154             {
       
  3155 TFLOGSTRING3("TSY: CMmPacketServiceTsy::OpenNewObjectL. New MBMS Context Name: %S Proxy Id: %d",&aNewName, proxyId );            
       
  3156             newContext = context;            
       
  3157             }        
       
  3158         }
       
  3159     else
       
  3160         {            
       
  3161         ret = iPacketContextList->GenerateNewContextName( aNewName, proxyId );
       
  3162 
       
  3163         if ( KErrNone != ret )
       
  3164             {
       
  3165             // Reason to leave is that maximum number of Contexts already exists.
       
  3166             // Leaving from here requires that TSY is configurated with max number
       
  3167             // of context supported by this phone ( value KMmMaxNumberOfContexts )
       
  3168             ret = CMmCommonStaticUtility::EpocErrorCode(
       
  3169                 KErrOverflow, KErrUmtsMaxNumOfContextExceededByPhone );
       
  3170 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectL. Leaves with: %d", ret );
       
  3171             User::Leave( ret );
       
  3172             }
       
  3173         CMmPacketContextTsy* context = CMmPacketContextTsy::NewL( this, iHostCID, aNewName, proxyId );
       
  3174 
       
  3175     	// reset cotext name 
       
  3176     	iHostCID.Zero();
       
  3177         ret = iPacketContextList->AddObject( context, proxyId, 0x00, aNewName );
       
  3178         if( KErrNone != ret )
       
  3179             {
       
  3180             // Created context couldn't save.
       
  3181             // Call Close() to context to remove it completely
       
  3182             context->Close();
       
  3183             context = NULL;
       
  3184 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectL. Leaves with: %d", ret );
       
  3185             User::Leave( ret );
       
  3186             }
       
  3187         else
       
  3188             {
       
  3189 TFLOGSTRING3("TSY: CMmPacketServiceTsy::OpenNewObjectL. New Context Name: %S Proxy Id: %d",&aNewName, proxyId );            
       
  3190             newContext = context;            
       
  3191             }
       
  3192         }               
       
  3193     return newContext;
       
  3194     }
       
  3195 
       
  3196 //----------------------------------------------------------------------------
       
  3197 // CMmPacketServiceTsy::OpenNewObjectByNameL
       
  3198 // Returns context object defined in parameter aName.
       
  3199 //----------------------------------------------------------------------------
       
  3200 //
       
  3201 CTelObject* CMmPacketServiceTsy::OpenNewObjectByNameL(
       
  3202     const TDesC& aName )   
       
  3203     {
       
  3204 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectByNameL. Context Name: %S", &aName );
       
  3205 
       
  3206     // length of object's name cannot be over 16 chars
       
  3207     if ( 16 < aName.Length() )
       
  3208         {
       
  3209 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectByNameL. Leaves with: %d", KErrOverflow  );
       
  3210         User::Leave( KErrOverflow  );
       
  3211         }
       
  3212 
       
  3213     const TInfoName mmPacketContextName( aName );
       
  3214     CMmPacketContextTsy* mmPacketContext = NULL;
       
  3215 
       
  3216     if ( mmPacketContextName.Compare( KStringExternal ) == 0 )
       
  3217         {
       
  3218 TFLOGSTRING("TSY: CMmPacketServiceTsy::OpenNewObjectByNameL :Open Existing Dial-up Object." );
       
  3219         mmPacketContext = iDialUpContext;
       
  3220         }
       
  3221     else if ( mmPacketContextName.Compare( KStringExternal2 ) == 0 )
       
  3222         {
       
  3223 TFLOGSTRING("TSY: CMmPacketServiceTsy::OpenNewObjectByNameL :Open Existing Secondary Dial-up Object." );
       
  3224         mmPacketContext = iSecondaryDialUpContext;
       
  3225         }
       
  3226     else
       
  3227         {
       
  3228         mmPacketContext =
       
  3229             iPacketContextList->PacketContextByName( &mmPacketContextName );
       
  3230         }
       
  3231 
       
  3232     // If not found, Leaves
       
  3233     if ( NULL == mmPacketContext )
       
  3234         {
       
  3235 TFLOGSTRING2("TSY: CMmPacketServiceTsy::OpenNewObjectByNameL. Leaves with: %d", KErrNotFound );
       
  3236         User::Leave( KErrNotFound );
       
  3237         }
       
  3238 
       
  3239     return mmPacketContext;
       
  3240     }
       
  3241 
       
  3242 //----------------------------------------------------------------------------
       
  3243 // CMmPacketServiceTsy::PacketContextList
       
  3244 // Returns pointer to the context list object.
       
  3245 //----------------------------------------------------------------------------
       
  3246 //
       
  3247 CMmPacketContextList* CMmPacketServiceTsy::PacketContextList()
       
  3248     {
       
  3249     return iPacketContextList;
       
  3250     }
       
  3251 
       
  3252 //----------------------------------------------------------------------------
       
  3253 // CMmPacketServiceTsy::ServiceStatus
       
  3254 // Returns current status of Packet Service.
       
  3255 //----------------------------------------------------------------------------
       
  3256 //
       
  3257 RPacketService::TStatus CMmPacketServiceTsy::ServiceStatus() const
       
  3258     {
       
  3259 	return iInternalSavedData.iServiceStatus;
       
  3260     }
       
  3261 //----------------------------------------------------------------------------
       
  3262 // CMmPacketServiceTsy::DialUpContext
       
  3263 // Returns externally created dial-up context.
       
  3264 //----------------------------------------------------------------------------
       
  3265 //
       
  3266 CMmPacketContextTsy* CMmPacketServiceTsy::DialUpContext(
       
  3267     const TInfoName aContextName )
       
  3268     {
       
  3269 
       
  3270     CMmPacketContextTsy* mmpacketContext = NULL;
       
  3271 
       
  3272     if ( aContextName.Compare( KStringExternal ) == 0 )
       
  3273         {
       
  3274         mmpacketContext = iDialUpContext;
       
  3275         }
       
  3276 
       
  3277     else if ( aContextName.Compare( KStringExternal2 ) == 0 )
       
  3278         {
       
  3279         mmpacketContext =  iSecondaryDialUpContext;
       
  3280         }
       
  3281 
       
  3282     return mmpacketContext;
       
  3283     }
       
  3284 
       
  3285 //----------------------------------------------------------------------------
       
  3286 // CMmPacketServiceTsy::ResetPointerToDialUpContex
       
  3287 // Resets pointer to dial-up context.
       
  3288 //----------------------------------------------------------------------------
       
  3289 //
       
  3290 void CMmPacketServiceTsy::ResetPointerToDialUpContext(
       
  3291     const TInfoName aContextName )
       
  3292     {
       
  3293 
       
  3294     if ( aContextName.Compare( KStringExternal ) == 0 )
       
  3295         {
       
  3296         iDialUpContext = NULL;
       
  3297         }
       
  3298 
       
  3299     else if ( aContextName.Compare( KStringExternal2 ) == 0 )
       
  3300         {
       
  3301         iSecondaryDialUpContext = NULL;
       
  3302         }
       
  3303     }
       
  3304 
       
  3305 #ifdef REQHANDLE_TIMER
       
  3306 
       
  3307 //---------------------------------------------------------------------------
       
  3308 // CMmPacketServiceTsy::PhoneTsy
       
  3309 // Returns pointer to the phone tsy object.
       
  3310 //---------------------------------------------------------------------------
       
  3311 //
       
  3312 CMmPhoneTsy* CMmPacketServiceTsy::PhoneTsy()
       
  3313     {
       
  3314     return iMmPhone;
       
  3315     }
       
  3316 
       
  3317 //----------------------------------------------------------------------------
       
  3318 // CMmPacketServiceTsy::SetTypeOfResponse
       
  3319 // Sets the type of response for a given Handle.
       
  3320 // Automatic mode includes an automatic response in case of non response from
       
  3321 // the DOS in a specified time.
       
  3322 //----------------------------------------------------------------------------
       
  3323 //
       
  3324 void CMmPacketServiceTsy::SetTypeOfResponse(
       
  3325     const TInt aReqHandleType ) 
       
  3326     {
       
  3327 
       
  3328     TInt timeOut( 0 );
       
  3329 
       
  3330     switch ( aReqHandleType )
       
  3331         {
       
  3332         case EMultimodePacketServiceAttach:
       
  3333             timeOut = KMmPacketServiceAttachTimeOut;
       
  3334             break;
       
  3335         case EMultimodePacketServiceDetach:
       
  3336             timeOut = KMmPacketServiceDetachTimeOut;
       
  3337             break;
       
  3338         case EMultimodePacketServiceGetNtwkRegStatus:
       
  3339             timeOut = KMmPacketServiceGetNtwkRegStatusTimeOut;
       
  3340             break;
       
  3341         case EMultimodePacketServiceSetPreferredBearer:
       
  3342             timeOut = KMmPacketServiceSetPreferredBearerTimeOut;
       
  3343             break;
       
  3344         case EMultimodePacketServiceRejectActivationRequest:
       
  3345             timeOut = KMmPacketServiceRejectActivationRequest;
       
  3346             break;
       
  3347         case EMultimodePacketServiceSetAttachMode:
       
  3348             timeOut = KMmPacketServiceSetAttachModeTimeOut;
       
  3349             break;
       
  3350         case EMultimodePacketServiceGetAttachMode:
       
  3351             timeOut = KMmPacketServiceGetAttachModeTimeOut;
       
  3352             break;
       
  3353         case EMultimodePacketServiceSetDefaultContextParams:
       
  3354             timeOut = KMmPacketSetDefaultContextParamsTimeOut;
       
  3355             break;
       
  3356         case EMultimodePacketServiceGetMBMSStatus:
       
  3357             timeOut = KMmPacketServiceGetMbmsNetworkServiceStatusTimeOut;
       
  3358             break;
       
  3359         case EMultimodePacketServiceUpdateMBMSMonitorServiceList:
       
  3360             timeOut = KMmPacketServiceUpdateMbmsMonitorServiceListTimeOut;
       
  3361             break;            
       
  3362         // Can't use timer:
       
  3363         //  - all notifications
       
  3364         //case EMultimodePacketServiceNotifyNtwkRegStatusChange:
       
  3365         //case EMultimodePacketServiceNotifyContextActivationRequested:
       
  3366         //case EMultimodePacketServiceNotifyContextAdded:
       
  3367         //case EMultimodePacketServiceNotifyDynamicCapsChange:
       
  3368         //case EMultimodePacketServiceNotifyMSClassChange:
       
  3369         //case EMultimodePacketServiceNotifyStatusChange:
       
  3370 
       
  3371         default:
       
  3372             // Does not use timer
       
  3373             iTsyReqHandleStore->SetTsyReqHandle(
       
  3374                 aReqHandleType, iTsyReqHandle );
       
  3375             break;
       
  3376         }
       
  3377 
       
  3378     if ( 0 < timeOut )
       
  3379         {
       
  3380         // The timeout parameter is given in seconds.
       
  3381         iTsyReqHandleStore->SetTsyReqHandle(
       
  3382             aReqHandleType, iTsyReqHandle, timeOut );
       
  3383         }
       
  3384     }
       
  3385 
       
  3386 //----------------------------------------------------------------------------
       
  3387 // CMmPacketServiceTsy::Complete
       
  3388 // Completes the request due timer expiration
       
  3389 //----------------------------------------------------------------------------
       
  3390 //
       
  3391 void CMmPacketServiceTsy::Complete(
       
  3392     const CTelObject* const aObject, 
       
  3393     const TInt aReqHandleType,      
       
  3394     const TInt aError )              
       
  3395     {
       
  3396 
       
  3397     if ( this == aObject )
       
  3398         {
       
  3399         // Call service's Complete()
       
  3400         Complete( aReqHandleType, aError );
       
  3401         }
       
  3402     else if ( aObject == iDialUpContext && NULL != iDialUpContext )
       
  3403         {
       
  3404 TFLOGSTRING("TSY: CMmPacketServiceTsy::OpenNewObjectByNameL :Complete Dial-up Object Request." );
       
  3405 
       
  3406         iDialUpContext->Complete( aReqHandleType, aError );
       
  3407         }
       
  3408     else if ( aObject == iSecondaryDialUpContext 
       
  3409               && NULL != iSecondaryDialUpContext )
       
  3410         {
       
  3411 TFLOGSTRING("TSY: CMmPacketServiceTsy::OpenNewObjectByNameL :Complete Dial-up Object Request." );
       
  3412 
       
  3413         iSecondaryDialUpContext->Complete( aReqHandleType, aError );
       
  3414 
       
  3415         }
       
  3416     else
       
  3417         {
       
  3418 
       
  3419         CMmPacketContextTsy* context;
       
  3420 
       
  3421         const TInt numberOfContexts( iPacketContextList->NumberOfContexts() );
       
  3422 
       
  3423         // Check if the object is a Context object
       
  3424         for ( TInt i = 0; i < numberOfContexts; i++ )
       
  3425             {
       
  3426 
       
  3427             // Get context object
       
  3428             context = iPacketContextList->PacketContextByIndex( i );
       
  3429             
       
  3430             if (context == NULL)
       
  3431             	{
       
  3432             	continue;
       
  3433             	}
       
  3434             // Check if the current context is the object that we are
       
  3435             // trying to find
       
  3436             if ( context == aObject )
       
  3437                 {
       
  3438                 // Call context's Complete() method
       
  3439                 context->Complete( aReqHandleType, aError );
       
  3440                 // Object found, break
       
  3441                 return ;
       
  3442                 }
       
  3443 
       
  3444             else if ( context->PacketQoSTsy() == aObject )
       
  3445                 {
       
  3446                 // Call qos's Complete() method
       
  3447                 context->PacketQoSTsy()->Complete( aReqHandleType, aError );
       
  3448 
       
  3449                 // Object found, break
       
  3450                 return ;
       
  3451                 }
       
  3452             }  
       
  3453            
       
  3454         CMmMBMSContextTsy* mbms;
       
  3455         
       
  3456         const TInt numberOfMbms( iMBMSContextList->GetNumberOfObjects() );
       
  3457         
       
  3458         for( TInt i = 0; i < numberOfMbms; i++ )
       
  3459             {
       
  3460             mbms = MBMSContextList( )->ContextByIndex( i );
       
  3461             
       
  3462             // Check if the current context is the object that we are
       
  3463             // trying to find
       
  3464             if ( mbms == aObject )
       
  3465                 {
       
  3466                 // Call context's Complete() method
       
  3467                 mbms->Complete( aReqHandleType, aError );
       
  3468                 // Object found, break
       
  3469                 return ;
       
  3470                 }            
       
  3471             }          
       
  3472         }
       
  3473     }
       
  3474 
       
  3475 //----------------------------------------------------------------------------
       
  3476 // CMmPacketServiceTsy::Complete
       
  3477 // Completes the request due timer expiration.
       
  3478 //----------------------------------------------------------------------------
       
  3479 
       
  3480 void CMmPacketServiceTsy::Complete(
       
  3481     const TInt aReqHandleType,    
       
  3482     const TInt aError )            
       
  3483     {
       
  3484     // All possible TSY req handle types are listed in the
       
  3485     // switch case below.
       
  3486     switch ( aReqHandleType )
       
  3487         {
       
  3488 
       
  3489         case EMultimodePacketServiceAttach:
       
  3490             CMmPacketServiceTsy::CompleteAttach( aError );
       
  3491             break;
       
  3492         case EMultimodePacketServiceDetach:
       
  3493             TRAP_IGNORE( CMmPacketServiceTsy::CompleteDetachL( aError ));
       
  3494             break;
       
  3495         case EMultimodePacketServiceGetNtwkRegStatus:
       
  3496             CMmPacketServiceTsy::CompleteGetNtwkRegStatus( 
       
  3497                 RPacketService::EUnknown, aError );
       
  3498             break;
       
  3499         case EMultimodePacketServiceSetPreferredBearer:
       
  3500             CMmPacketServiceTsy::CompleteSetPreferredBearer( aError );
       
  3501             break;
       
  3502         case EMultimodePacketServiceSetAttachMode:
       
  3503             CMmPacketServiceTsy::CompleteSetAttachMode( aError );
       
  3504             break;
       
  3505         case EMultimodePacketServiceSetDefaultContextParams:
       
  3506             CMmPacketServiceTsy::CompleteSetDefaultContextParams( aError );
       
  3507             break;
       
  3508         case EMultimodePacketServiceGetMBMSStatus:
       
  3509             CMmPacketServiceTsy::CompleteGetMbmsNetworkServiceStatus( NULL, aError );
       
  3510             break;   
       
  3511         case EMultimodePacketServiceEnumerateMbmsActiveServices:
       
  3512             CMmPacketServiceTsy::CompleteEnumerateMbmsActiveServiceList( NULL, aError );
       
  3513             break;
       
  3514         case EMultimodePacketServiceUpdateMBMSMonitorServiceList:
       
  3515            CMmPacketServiceTsy::CompleteUpdateMbmsMonitorServiceList( NULL, aError );
       
  3516            break;
       
  3517 
       
  3518         // Can't use timer:
       
  3519         //  - all notifications
       
  3520         //case EMultimodePacketServiceNotifyNtwkRegStatusChange:
       
  3521         //case EMultimodePacketServiceNotifyContextActivationRequested:
       
  3522         //case EMultimodePacketServiceNotifyContextAdded:
       
  3523         //case EMultimodePacketServiceNotifyDynamicCapsChange:
       
  3524         //case EMultimodePacketServiceNotifyMSClassChange:
       
  3525         //case EMultimodePacketServiceNotifyStatusChange:
       
  3526 
       
  3527         default:
       
  3528             CMmPacketServiceTsy::ReqCompleted( iTsyReqHandleStore->
       
  3529 				ResetTsyReqHandle( aReqHandleType ), aError );
       
  3530             break;
       
  3531         }
       
  3532     }
       
  3533 #endif // REQHANDLE_TIMER
       
  3534 
       
  3535 
       
  3536 #ifdef TF_LOGGING_ENABLED
       
  3537 
       
  3538 
       
  3539 //----------------------------------------------------------------------------
       
  3540 // CMmPacketServiceTsy::ReqCompleted
       
  3541 // Overloads CTelObject::ReqCompleted for logging purposes.
       
  3542 // Prints the aTsyReqHandle and aError variable in the log file and then
       
  3543 // calls CTelObject::ReqCompleted.
       
  3544 //----------------------------------------------------------------------------
       
  3545 //
       
  3546 void CMmPacketServiceTsy::ReqCompleted(
       
  3547     const TTsyReqHandle aTsyReqHandle,  
       
  3548     const TInt aError )                   
       
  3549     {
       
  3550 TFLOGSTRING3("TSY: CMmPacketServiceTsy::Request Completed. TSY Req Handle: %d Error:%d", aTsyReqHandle, aError );
       
  3551 
       
  3552     CTelObject::ReqCompleted( aTsyReqHandle, aError );
       
  3553     }
       
  3554 
       
  3555 #endif // TF_LOGGING_ENABLED
       
  3556 
       
  3557 
       
  3558 //----------------------------------------------------------------------------
       
  3559 // CMmPacketServiceTsy::PrepareOpenSecondary
       
  3560 // Prepares to open secondary from given primary context
       
  3561 // Next Context that client wants to open is secondary context. Secondary
       
  3562 // context copies configuration from context given by client
       
  3563 //----------------------------------------------------------------------------
       
  3564 //
       
  3565 TInt CMmPacketServiceTsy::PrepareOpenSecondary(
       
  3566     TDes16* aPrimaryContextName )  
       
  3567     {
       
  3568 
       
  3569     if ( aPrimaryContextName->Length() <= iHostCID.MaxLength() )
       
  3570         {
       
  3571         // Check if primary context exists; return KErrArgument if it doesn't
       
  3572         TInfoName primaryContextName = *aPrimaryContextName;
       
  3573         CMmPacketContextTsy* mmPacketContextTsy = iPacketContextList->PacketContextByName(&primaryContextName );
       
  3574 
       
  3575         if( NULL == mmPacketContextTsy )
       
  3576             {
       
  3577             return KErrArgument;        
       
  3578             }
       
  3579 
       
  3580         iHostCID = *aPrimaryContextName;
       
  3581         // Complete request with ret
       
  3582         CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  3583         return KErrNone;
       
  3584         }
       
  3585 
       
  3586     return KErrArgument;
       
  3587     }
       
  3588 
       
  3589 //----------------------------------------------------------------------------
       
  3590 // CMmPacketServiceTsy::EnumerateNifs
       
  3591 // Method returns number of network interfaces
       
  3592 // call method EnumerateNifs from CMmPacketContextList
       
  3593 // complete request to client
       
  3594 // return KErrNone
       
  3595 //----------------------------------------------------------------------------
       
  3596 //
       
  3597 TInt CMmPacketServiceTsy::EnumerateNifs(
       
  3598     TInt* aCount )   
       
  3599     {
       
  3600 TFLOGSTRING("TSY: CMmPacketServiceTsy::EnumerateNifs." );
       
  3601 
       
  3602     iPacketContextList->EnumerateNifs( aCount );
       
  3603 
       
  3604     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  3605 
       
  3606     return KErrNone;
       
  3607     }
       
  3608 
       
  3609 //----------------------------------------------------------------------------
       
  3610 // CMmPacketServiceTsy::GetNifInfo
       
  3611 // Return information about network interface
       
  3612 //----------------------------------------------------------------------------
       
  3613 //
       
  3614 TInt CMmPacketServiceTsy::GetNifInfo(
       
  3615     TInt* aIndex,                            
       
  3616     RPacketService::TNifInfoV2* aNifInfoV2 ) 
       
  3617     {
       
  3618 TFLOGSTRING("TSY: CMmPacketServiceTsy::GetNifInfo." );
       
  3619 
       
  3620     TInt ret = iPacketContextList->GetNifInfo( aIndex, aNifInfoV2 );
       
  3621 
       
  3622     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, ret );
       
  3623 
       
  3624     return KErrNone;
       
  3625     }
       
  3626 
       
  3627 //----------------------------------------------------------------------------
       
  3628 // CMmPacketServiceTsy::EnumerateContextsInNif
       
  3629 // Returns number of contexts in Nif
       
  3630 // get existingContextName from parameter aExistingContextName
       
  3631 // call method EnumerateContextsInNif from CMmPacketContextList
       
  3632 // complete request to client
       
  3633 // return KErrNone
       
  3634 //----------------------------------------------------------------------------
       
  3635 //
       
  3636 TInt CMmPacketServiceTsy::EnumerateContextsInNif(
       
  3637     TDesC* aExistingContextName,    
       
  3638     TInt* aCount )                   
       
  3639     {
       
  3640 TFLOGSTRING("TSY: CMmPacketServiceTsy::EnumerateContextsInNif." );
       
  3641 
       
  3642 	TInt ret = KErrNone;
       
  3643 	if (aExistingContextName->Length() > KMaxInfoName)
       
  3644 		{
       
  3645 		ret = KErrArgument;
       
  3646 		}
       
  3647 	else
       
  3648 		{		
       
  3649 	    TInfoName existingContextName = *aExistingContextName;
       
  3650 
       
  3651 	    iPacketContextList->EnumerateContextsInNif( existingContextName, aCount );
       
  3652 
       
  3653 	    CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  3654 		}
       
  3655 
       
  3656     return ret;
       
  3657     }
       
  3658 
       
  3659 //----------------------------------------------------------------------------
       
  3660 // CMmPacketServiceTsy::GetContextNameInNif
       
  3661 // Returns name of context in network interface
       
  3662 //----------------------------------------------------------------------------
       
  3663 //
       
  3664 TInt CMmPacketServiceTsy::GetContextNameInNif(
       
  3665     RPacketService::TContextNameInNif* aContextNameInNif,
       
  3666     TDes* aContextName )                
       
  3667     {
       
  3668 TFLOGSTRING("TSY: CMmPacketServiceTsy::GetContextNameInNif." );
       
  3669 
       
  3670     TInt ret = iPacketContextList->GetContextNameInNif( aContextNameInNif,
       
  3671         aContextName );
       
  3672 
       
  3673     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, ret );
       
  3674 
       
  3675     return KErrNone;
       
  3676     }
       
  3677 
       
  3678 //----------------------------------------------------------------------------
       
  3679 // CMmPacketServiceTsy::SetDefaultContextParams
       
  3680 // Sets default context parameters
       
  3681 //----------------------------------------------------------------------------
       
  3682 //
       
  3683 TInt CMmPacketServiceTsy::SetDefaultContextParamsL(
       
  3684     const TDataPackage& aPackage )
       
  3685     {
       
  3686 TFLOGSTRING("TSY: CMmPacketServiceTsy::SetDefaultContextParamsL." );
       
  3687 
       
  3688     TInt ret(KErrServerBusy);
       
  3689 
       
  3690     const TTsyReqHandle reqHandle( iTsyReqHandleStore->GetTsyReqHandle(
       
  3691     EMultimodePacketServiceSetDefaultContextParams ) );
       
  3692 
       
  3693     if ( EMultimodePacketServiceReqHandleUnknown == reqHandle )
       
  3694         {
       
  3695 		ret = iMmPacketServiceGsmWcdmaExt->
       
  3696             SetDefaultContextParamsL( aPackage );
       
  3697 
       
  3698         if ( KErrNone == ret )
       
  3699             {
       
  3700             // Set req handle
       
  3701             iReqHandleType = EMultimodePacketServiceSetDefaultContextParams;
       
  3702             }
       
  3703         }
       
  3704 
       
  3705     return ret;
       
  3706     }
       
  3707 
       
  3708 //----------------------------------------------------------------------------
       
  3709 // CMmPacketServiceTsy::CompleteSetDefaultContextParams
       
  3710 // Completes call SetDefaultContextParameters
       
  3711 //----------------------------------------------------------------------------
       
  3712 //
       
  3713 void CMmPacketServiceTsy::CompleteSetDefaultContextParams(
       
  3714     TInt aCause )    
       
  3715     {
       
  3716 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteSetDefaultContextParams. aCause: %d", aCause );
       
  3717 
       
  3718     // Reset request handle. Returns the deleted request handle
       
  3719     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  3720         EMultimodePacketServiceSetDefaultContextParams ) );
       
  3721 
       
  3722     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  3723         {
       
  3724         // Complete the client request
       
  3725         CMmPacketServiceTsy::ReqCompleted( reqHandle, aCause );
       
  3726         }
       
  3727     }
       
  3728 
       
  3729 //----------------------------------------------------------------------------
       
  3730 // CMmPacketServiceTsy::GetDefaultContextParams
       
  3731 // Gets default context parameters
       
  3732 //----------------------------------------------------------------------------
       
  3733 //
       
  3734 TInt CMmPacketServiceTsy::GetDefaultContextParams(
       
  3735     TPacketDataConfigBase* aContextConfig )      
       
  3736     {
       
  3737 TFLOGSTRING("TSY: CMmPacketServiceTsy::GetDefaultContextParams." );
       
  3738 
       
  3739     TInt ret = iMmPacketServiceGsmWcdmaExt->GetDefaultContextParams(
       
  3740         aContextConfig );
       
  3741 
       
  3742     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, ret );
       
  3743 
       
  3744     return KErrNone;
       
  3745     }
       
  3746 
       
  3747 //----------------------------------------------------------------------------
       
  3748 // CMmPacketServiceTsy::IsActivationAllowed
       
  3749 // Returns true if Packet Data is currently allowed
       
  3750 //----------------------------------------------------------------------------
       
  3751 //
       
  3752 TBool CMmPacketServiceTsy::IsActivationAllowed()
       
  3753     {
       
  3754     TBool isAllowed = ETrue;
       
  3755 
       
  3756     if ( RMobilePhone::ENetworkModeGsm == iCurrentMode &&
       
  3757         RPacketService::EMSClassDualMode != iInternalSavedData.iMsClass )
       
  3758         {
       
  3759         //Check if the object is a Call object
       
  3760         for( TInt i = 0; i < iMmPhone->CallList()->GetNumberOfObjects() ; i++ )
       
  3761             {
       
  3762             //Get call object
       
  3763             CMmCallTsy* call = iMmPhone->CallList()->GetMmCallByIndex( i );
       
  3764             //check if the current call object exist
       
  3765             if( call != NULL )
       
  3766                 {
       
  3767                 //call the complete method
       
  3768                 RCall::TStatus status = call->Status();
       
  3769 
       
  3770                 if ( RCall::EStatusUnknown != status &&
       
  3771                      RCall::EStatusIdle != status )
       
  3772                     {
       
  3773     TFLOGSTRING("TSY: CMmPacketServiceTsy::IsActivationAllowed. CS call active, Context Activation not allowed" );
       
  3774                     isAllowed = EFalse;
       
  3775                     i = iMmPhone->CallList()->GetNumberOfObjects();
       
  3776                     }
       
  3777                 }
       
  3778             }
       
  3779         }
       
  3780 
       
  3781     return isAllowed;
       
  3782     }
       
  3783 
       
  3784 //----------------------------------------------------------------------------
       
  3785 // CMmPacketServiceTsy::MessageManagerBase
       
  3786 // returns pointer to CMmMessageManager
       
  3787 //----------------------------------------------------------------------------
       
  3788 //
       
  3789 CMmMessageManagerBase* CMmPacketServiceTsy::MessageManager()
       
  3790 	{
       
  3791 	return iMessageManager;
       
  3792 	}
       
  3793 
       
  3794 //----------------------------------------------------------------------------
       
  3795 // CMmPacketServiceTsy::CompleteNotifyEGprsInfoChange
       
  3796 // Completes notification t
       
  3797 //----------------------------------------------------------------------------
       
  3798 //
       
  3799 void CMmPacketServiceTsy::CompleteNotifyEGprsInfoChange(
       
  3800     CMmDataPackage* aDataPackage )		
       
  3801 	{
       
  3802 TFLOGSTRING("TSY: CMmPacketServiceTsy::CompleteNotifyEGprsInfoChange." );
       
  3803 
       
  3804 	//Unpack data
       
  3805 	TBool lastEdgeGprsSupport;
       
  3806 	aDataPackage->UnPackData( lastEdgeGprsSupport );
       
  3807 
       
  3808 	iMmPacketServiceGsmWcdmaExt->SetEdgeGprsSupport( lastEdgeGprsSupport );
       
  3809 
       
  3810 	CMmCustomTsy* customTsy = CMmPacketServiceTsy::CustomTsy();
       
  3811 
       
  3812         if ( NULL != customTsy )
       
  3813             {
       
  3814             CMmPacketTsy* packetTsy = customTsy->PacketTsy();
       
  3815 
       
  3816             if ( NULL != packetTsy )
       
  3817                 {
       
  3818                 packetTsy->
       
  3819                     CompleteNotifyEGprsInfoChange( lastEdgeGprsSupport );
       
  3820                 }
       
  3821             }
       
  3822 	}
       
  3823 
       
  3824 //----------------------------------------------------------------------------
       
  3825 // CMmPacketServiceTsy::QosTsy
       
  3826 // Gets pointer to right qos by context name given as parameter.
       
  3827 //----------------------------------------------------------------------------
       
  3828 //
       
  3829 CMmPacketQoSTsy* CMmPacketServiceTsy::QosTsy(
       
  3830     TInfoName aMmPacketContextName )
       
  3831 	{
       
  3832 	CMmPacketQoSTsy* packetQoSTsy = NULL;
       
  3833 
       
  3834 	CMmPacketContextTsy* mmPacketContextTsy = iPacketContextList->
       
  3835 		PacketContextByName( &aMmPacketContextName );
       
  3836 
       
  3837 	if ( NULL != mmPacketContextTsy )
       
  3838 		{
       
  3839 		packetQoSTsy = mmPacketContextTsy->PacketQoSTsy();
       
  3840 		}
       
  3841 
       
  3842 	if ( NULL != packetQoSTsy )
       
  3843 		{
       
  3844 		return packetQoSTsy;
       
  3845 		}
       
  3846 
       
  3847 	else
       
  3848 		{
       
  3849 		return NULL;
       
  3850 		}
       
  3851 	}
       
  3852 
       
  3853 //----------------------------------------------------------------------------
       
  3854 // CMmPacketServiceTsy::CompleteNetworkModeChange
       
  3855 // Completes Network Mode Change
       
  3856 //----------------------------------------------------------------------------
       
  3857 //
       
  3858 void CMmPacketServiceTsy::CompleteNetworkModeChange(
       
  3859     CMmDataPackage* aDataPackage )  
       
  3860     {
       
  3861     RMobilePhone::TMobilePhoneNetworkMode ntwkMode( 
       
  3862         RMobilePhone::ENetworkModeUnknown );
       
  3863     //Unpack data
       
  3864     aDataPackage->UnPackData( ntwkMode );
       
  3865 
       
  3866 TFLOGSTRING2("TSY: CMmPacketServiceTsy::CompleteNetworkModeChange. ntwkMode: %d", ntwkMode );
       
  3867     iCurrentMode = ntwkMode;
       
  3868     }
       
  3869 
       
  3870 //----------------------------------------------------------------------------
       
  3871 // CMmPacketServiceTsy::Context
       
  3872 // Accessory method to get right context.
       
  3873 //----------------------------------------------------------------------------
       
  3874 //
       
  3875 CMmPacketContextTsy* CMmPacketServiceTsy::ContextTsy(
       
  3876     TInfoName& contextName )
       
  3877     {
       
  3878     CMmPacketContextTsy* mmPacketContextTsy = iPacketContextList->
       
  3879         PacketContextByName( &contextName );
       
  3880 
       
  3881     if( NULL == mmPacketContextTsy )
       
  3882         {
       
  3883         mmPacketContextTsy = iMBMSContextList->ContextByName( contextName );        
       
  3884         }
       
  3885     return mmPacketContextTsy;
       
  3886     }
       
  3887     
       
  3888 //----------------------------------------------------------------------------
       
  3889 // CMmPacketServiceTsy::GlobalKernelObjectHandle
       
  3890 // Returns unnamed mutex handle owned by TSY 
       
  3891 //----------------------------------------------------------------------------
       
  3892 //
       
  3893 RHandleBase* CMmPacketServiceTsy::GlobalKernelObjectHandle()
       
  3894     {
       
  3895 TFLOGSTRING("TSY: CMmPacketServiceTsy::GlobalKernelObjectHandle" );
       
  3896 
       
  3897     if ( KNullHandle == iMutex.Handle() )
       
  3898         {
       
  3899         TInt ret = iMutex.CreateLocal( EOwnerProcess );
       
  3900     
       
  3901         if ( KErrNone == ret )
       
  3902             {
       
  3903 TFLOGSTRING("TSY: CMmPacketServiceTsy::GlobalKernelObjectHandle - Mutex created" );
       
  3904             }
       
  3905         else
       
  3906             {
       
  3907 TFLOGSTRING("TSY: CMmPacketServiceTsy::GlobalKernelObjectHandle - Mutex creation failed" );
       
  3908             }                  
       
  3909         }
       
  3910     else
       
  3911         {
       
  3912 TFLOGSTRING("TSY: CMmPacketServiceTsy::GlobalKernelObjectHandle - Mutex creation skipped" );
       
  3913         }
       
  3914          
       
  3915     return &iMutex;
       
  3916     }
       
  3917 
       
  3918 //-----------------------------------------------------------------------------
       
  3919 // CMmPacketServiceTsy::SetAlwaysOnL
       
  3920 // Requests Set Always On with mode given as parameter aMode
       
  3921 //-----------------------------------------------------------------------------
       
  3922 //
       
  3923 TInt CMmPacketServiceTsy::SetAlwaysOnL(	
       
  3924     TTsyReqHandle aTsyReqHandle,
       
  3925     RMmCustomAPI::TSetAlwaysOnMode aMode )
       
  3926 	{
       
  3927 TFLOGSTRING2("TSY: CMmPacketServiceTsy::SetAlwaysOn Mode = %d", aMode );
       
  3928 TFLOGSTRING2( "TSY: CMmPacketServiceTsy::CompleteSetAlwaysOn ReqHandle %d", aTsyReqHandle );
       
  3929 	TInt ret( KErrServerBusy );
       
  3930 	
       
  3931 	//Check if request is allready pending
       
  3932 	TTsyReqHandle reqHandle = iTsyReqHandleStore->GetTsyReqHandle( 
       
  3933         EMultimodePacketSetAlwaysOn );
       
  3934 	
       
  3935 	if( EMultimodePacketServiceReqHandleUnknown == reqHandle )
       
  3936 		{
       
  3937         //Pack 
       
  3938 		CMmDataPackage data;
       
  3939 		data.PackData( &aMode );
       
  3940 		
       
  3941 		iTsyReqHandleStore->SetTsyReqHandle( 
       
  3942             EMultimodePacketSetAlwaysOn, aTsyReqHandle );
       
  3943 		
       
  3944 		ret = iMessageManager->HandleRequestL( ECustomSetAlwaysOnMode, &data );
       
  3945 		
       
  3946 		if ( KErrNone != ret)
       
  3947 			{
       
  3948 			iTsyReqHandleStore->ResetTsyReqHandle( EMultimodePacketSetAlwaysOn );
       
  3949 			}
       
  3950 		}
       
  3951 	
       
  3952 	return ret;
       
  3953 	}
       
  3954 
       
  3955 //-----------------------------------------------------------------------------
       
  3956 // TInt CMmPacketServiceTsy::CompleteSetAlwaysOn
       
  3957 // Completes Set Always On request 
       
  3958 //-----------------------------------------------------------------------------
       
  3959 //
       
  3960 void CMmPacketServiceTsy::CompleteSetAlwaysOn( 
       
  3961     TInt aError )
       
  3962 	{
       
  3963 TFLOGSTRING2( "TSY: CMmPacketServiceTsy::CompleteSetAlwaysOn Error %d", aError );	
       
  3964 
       
  3965     const TTsyReqHandle reqHandle( iTsyReqHandleStore->ResetTsyReqHandle(
       
  3966             								  EMultimodePacketSetAlwaysOn ) );
       
  3967 
       
  3968 TFLOGSTRING2( "TSY: CMmPacketServiceTsy::CompleteSetAlwaysOn ReqHandle %d", reqHandle );
       
  3969 
       
  3970     if ( EMultimodePacketServiceReqHandleUnknown != reqHandle )
       
  3971     	{
       
  3972     	CMmCustomTsy* customTsy = CMmPacketServiceTsy::CustomTsy();
       
  3973 
       
  3974         if ( NULL != customTsy )
       
  3975             {
       
  3976             CMmPacketTsy* packetTsy = customTsy->PacketTsy();
       
  3977 
       
  3978             if ( NULL != packetTsy )
       
  3979                 {
       
  3980 				packetTsy->CompleteSetAlwaysOn( reqHandle, aError );
       
  3981                 }
       
  3982             }	
       
  3983     	}
       
  3984 	}
       
  3985 
       
  3986 //-----------------------------------------------------------------------------
       
  3987 // TInt CMmPacketServiceTsy::CancelSetAlwaysOn
       
  3988 // Cancels Set Always On request
       
  3989 //-----------------------------------------------------------------------------
       
  3990 //
       
  3991 void CMmPacketServiceTsy::CancelSetAlwaysOn( 
       
  3992     TTsyReqHandle aTsyReqHandle )
       
  3993 	{
       
  3994 TFLOGSTRING2( "TSY: CMmPacketServiceTsy::CancelSetAlwaysOn ReqHandle %d", aTsyReqHandle );
       
  3995 	
       
  3996 	if ( aTsyReqHandle != EMultimodePacketServiceReqHandleUnknown )
       
  3997         {
       
  3998         // Reset tsy request handle
       
  3999         iTsyReqHandleStore->ResetTsyReqHandle( EMultimodePacketSetAlwaysOn );
       
  4000 
       
  4001         // Complete request to client with KErrCancel
       
  4002         ReqCompleted( aTsyReqHandle, KErrCancel );
       
  4003         }
       
  4004 	}
       
  4005 
       
  4006 //-----------------------------------------------------------------------------
       
  4007 // TInt CMmPacketServiceTsy::EnumerateActiveServiceList
       
  4008 // Enumerates all active services
       
  4009 //-----------------------------------------------------------------------------
       
  4010 //
       
  4011 TInt CMmPacketServiceTsy::EnumerateMbmsActiveServiceList( TInt &aCount, TInt &aMaxAllowed )
       
  4012     {   
       
  4013 TFLOGSTRING2( "TSY: CMmPacketServiceTsy::EnumerateMbmsActiveServiceList. max: %d", aMaxAllowed );     
       
  4014      
       
  4015     aCount = EnumerateMbmsActiveServices();
       
  4016     aMaxAllowed = iMaxActiveServices;
       
  4017     
       
  4018 TFLOGSTRING3( "TSY: CMmPacketServiceTsy::EnumerateActiveServiceList Count: %d, Max allowed %d", aCount, aMaxAllowed );     
       
  4019     // Complete the request with KErrNone
       
  4020     CMmPacketServiceTsy::ReqCompleted( iTsyReqHandle, KErrNone );
       
  4021     return KErrNone;    
       
  4022     }
       
  4023     
       
  4024 //-----------------------------------------------------------------------------
       
  4025 // TInt CMmPacketServiceTsy::EnumerateMbmsActiveServices
       
  4026 // Enumerates all active services
       
  4027 //-----------------------------------------------------------------------------
       
  4028 //   
       
  4029 TInt CMmPacketServiceTsy::EnumerateMbmsActiveServices()
       
  4030     {
       
  4031 TFLOGSTRING2( "TSY: CMmPacketServiceTsy::EnumerateMbmsActiveService. max: %d", iMaxActiveServices );     
       
  4032     TInt ret( 0 );    
       
  4033     
       
  4034     for( TInt i = 0; i< iMBMSContextList->NumberOfContexts(); i++ )
       
  4035         {
       
  4036         CMmMBMSContextTsy* context = iMBMSContextList->ContextByIndex( i );
       
  4037         
       
  4038         if( RPacketContext::EStatusActive == context->ContextStatus() ||
       
  4039             RPacketContext::EStatusReceiving == context->ContextStatus() ||
       
  4040             RPacketContext::EStatusSuspended == context->ContextStatus() ||
       
  4041             RPacketContext::EStatusDeactivating == context->ContextStatus() )
       
  4042             {
       
  4043             TInt count = context->SessionCount();
       
  4044             if(  0 == count)
       
  4045 	            {
       
  4046 	            ret +=1;	
       
  4047 	            }
       
  4048 	        else
       
  4049 		        {
       
  4050 	            ret += count;	        	
       
  4051 		        }
       
  4052 
       
  4053             }        
       
  4054         }    
       
  4055         
       
  4056     return ret;
       
  4057     }
       
  4058     
       
  4059 //-----------------------------------------------------------------------------
       
  4060 // TInt CMmPacketServiceTsy::CompleteEnumerateMbmsActiveServiceList
       
  4061 // Saves the maximum value for active services
       
  4062 //-----------------------------------------------------------------------------
       
  4063 //
       
  4064 void CMmPacketServiceTsy::CompleteEnumerateMbmsActiveServiceList(        
       
  4065     CMmDataPackage* aDataPackage,
       
  4066     const TInt aResult)
       
  4067     {
       
  4068 TFLOGSTRING2( "TSY: CMmPacketServiceTsy::CompleteEnumerateMbmsActiveServiceList. Error: %d", aResult ); 
       
  4069            
       
  4070     if( KErrNone == aResult && NULL != aDataPackage )
       
  4071         {
       
  4072         aDataPackage->UnPackData( iMaxActiveServices );
       
  4073         }       
       
  4074     }
       
  4075     
       
  4076 //-----------------------------------------------------------------------------
       
  4077 // TInt CMmPacketServiceTsy::MaximumActiveServices
       
  4078 // Maximum number of active services
       
  4079 //-----------------------------------------------------------------------------
       
  4080 //    
       
  4081 TInt CMmPacketServiceTsy::MaximumActiveServices()
       
  4082     {
       
  4083     return iMaxActiveServices;
       
  4084     }
       
  4085 
       
  4086 //  End of File
       
  4087