telephonyserverplugins/simatktsy/src/CSatNotifySelectItem.cpp
changeset 0 3553901f7fa8
child 19 630d2f34d719
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-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 // Name        : CSatNotifySelectItem.cpp
       
    15 // Part of     : Common SIM ATK TSY / commonsimatktsy
       
    16 // SelectItem notification functionality of Sat Tsy
       
    17 // Version     : 1.0
       
    18 //
       
    19 
       
    20 
       
    21 
       
    22 //INCLUDES
       
    23 #include <satcs.h>                  // Etel SAT IPC definitions
       
    24 #include "CSatTsy.h"                // Tsy class header
       
    25 #include "CSatNotifySelectItem.h"   // Tsy class header
       
    26 #include "CSatNotificationsTsy.h"   // Class header
       
    27 #include "CBerTlv.h"                // Ber Tlv data handling
       
    28 #include "TTlv.h"					// TTlv class
       
    29 #include "CSatDataPackage.h"        // Parameter packing 
       
    30 #include "TfLogger.h"               // For TFLOGSTRING
       
    31 #include "TSatUtility.h"            // Utilities
       
    32 #include "CSatTsyReqHandleStore.h"  // Request handle class
       
    33 #include "cmmmessagemanagerbase.h"  // Message manager class for forwarding req.
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CSatNotifySelectItem::NewL
       
    37 // Two-phased constructor.
       
    38 // -----------------------------------------------------------------------------
       
    39 //  
       
    40 CSatNotifySelectItem* CSatNotifySelectItem::NewL
       
    41         ( 
       
    42         CSatNotificationsTsy* aNotificationsTsy 
       
    43         )
       
    44     {
       
    45     TFLOGSTRING("CSAT: CSatNotifySelectItem::NewL");
       
    46    	CSatNotifySelectItem* const satNotifySelectItem = 
       
    47         new ( ELeave ) CSatNotifySelectItem( aNotificationsTsy );
       
    48     CleanupStack::PushL( satNotifySelectItem );
       
    49     satNotifySelectItem->ConstructL();
       
    50     CleanupStack::Pop( satNotifySelectItem );
       
    51     TFLOGSTRING("CSAT: CSatNotifySelectItem::NewL, end of method");
       
    52     return satNotifySelectItem;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSatNotifySelectItem::~CSatNotifySelectItem
       
    57 // Destructor
       
    58 // -----------------------------------------------------------------------------
       
    59 //  
       
    60 CSatNotifySelectItem::~CSatNotifySelectItem
       
    61         ( 
       
    62 		// None
       
    63         )
       
    64     {
       
    65     TFLOGSTRING("CSAT: CSatNotifySelectItem::~CSatNotifySelectItem");
       
    66     }
       
    67     
       
    68 // -----------------------------------------------------------------------------
       
    69 // CSatNotifySelectItem::CSatNotifySelectItem
       
    70 // Default C++ constructor
       
    71 // -----------------------------------------------------------------------------
       
    72 //  
       
    73 CSatNotifySelectItem::CSatNotifySelectItem
       
    74         ( 
       
    75         CSatNotificationsTsy* aNotificationsTsy 
       
    76         ) : iNotificationsTsy ( aNotificationsTsy ), iItemsIconIdListRemoved ( EFalse )
       
    77     {
       
    78     // None
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSatNotifySelectItem::ConstructL
       
    83 // Symbian 2nd phase constructor
       
    84 // -----------------------------------------------------------------------------
       
    85 //  
       
    86 void CSatNotifySelectItem::ConstructL
       
    87         (
       
    88         // None
       
    89         )
       
    90     {
       
    91     TFLOGSTRING("CSAT: CSatNotifySelectItem::ConstructL");
       
    92     // Initiliaze Item Next Indicator flag
       
    93     iItemNextIndicatorRemoved = EFalse;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CSatNotifySelectItem::Notify
       
    98 // This request allows a client to be notified of a SELECT ITEM proactive 
       
    99 // command
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TInt CSatNotifySelectItem::Notify
       
   103         (
       
   104         const TTsyReqHandle aTsyReqHandle,
       
   105         const TDataPackage& aPackage    
       
   106         )
       
   107     {
       
   108     TFLOGSTRING("CSAT: CSatNotifySelectItem::Notify");
       
   109     // Save data pointer to client side for completion
       
   110     iSelectItemV2Pckg = reinterpret_cast<RSat::TSelectItemV2Pckg*>( 
       
   111         aPackage.Des1n() );
       
   112     // Save the request handle
       
   113     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
       
   114 		CSatTsy::ESatNotifySelectItemPCmdReqType );
       
   115     // Check if requested notification is already pending
       
   116     iNotificationsTsy->NotifySatReadyForNotification( KSelectItem );   
       
   117     return KErrNone;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CSatNotifySelectItem::CancelNotification
       
   122 // This method cancels an outstanding asynchronous 
       
   123 // NotifyDisplayText request.
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TInt CSatNotifySelectItem::CancelNotification
       
   127         (
       
   128         const TTsyReqHandle aTsyReqHandle 
       
   129         )
       
   130     {
       
   131     TFLOGSTRING("CSAT: CSatNotifySelectItem::CancelNotification");  
       
   132     // Reset the request handle
       
   133     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
       
   134         ResetTsyReqHandle( CSatTsy::ESatNotifySelectItemPCmdReqType );
       
   135 	// Reset the data pointer
       
   136 	iSelectItemV2Pckg = NULL;
       
   137 	// Complete the request with KErrCancel
       
   138 	iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
       
   139     return KErrNone;    
       
   140     }
       
   141 
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CSatNotifySelectItem::CompleteNotifyL
       
   145 // Complete Sim Session End notification to the client
       
   146 // -----------------------------------------------------------------------------
       
   147 // 
       
   148 TInt CSatNotifySelectItem::CompleteNotifyL
       
   149         (
       
   150 		CSatDataPackage* aDataPackage, 
       
   151 		TInt aErrorCode
       
   152         )
       
   153     {
       
   154 	TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL");
       
   155 	TInt ret( KErrNone );
       
   156     // Unpack parameters
       
   157     TPtrC8* data;
       
   158     aDataPackage->UnPackData( &data );
       
   159 	TBuf<1> additionalInfo;
       
   160     // Reset req handle. Returns the deleted req handle
       
   161     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
       
   162     	ResetTsyReqHandle( CSatTsy::ESatNotifySelectItemPCmdReqType );
       
   163     
       
   164     // Get ber tlv 
       
   165     CBerTlv berTlv;
       
   166     berTlv.SetData( *data );
       
   167     // Get command details tlv
       
   168     CTlv commandDetails;
       
   169     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
   170     // Store command details tlv
       
   171     iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( 
       
   172     	commandDetails.Data() );
       
   173     // Get command qualifier
       
   174     TUint8 cmdQualifier( commandDetails.GetShortInfo( 
       
   175         ETLV_CommandQualifier ) );        
       
   176     TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
   177         
       
   178 	// In case the request was ongoing, continue..
       
   179     if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
       
   180 		{
       
   181         // Complete right away if error has occured, otherwise continue..
       
   182         if ( KErrNone == aErrorCode )
       
   183             {
       
   184 			// Fill the select item structure
       
   185 			RSat::TSelectItemV2& selectItemV2 = ( *iSelectItemV2Pckg )();
       
   186 			selectItemV2.Reset();
       
   187 
       
   188 			// Store Transaction id place of command number
       
   189 			// This is done because we keep interface same as in Calimero.
       
   190 			// Client returns back same value in response package.
       
   191 			selectItemV2.SetPCmdNumber( pCmdNumber );
       
   192 
       
   193 			TPtrC8 sourceString; // Used in unicode conversions
       
   194 
       
   195 			// Alpha id string (optional)
       
   196 			selectItemV2.iAlphaId.iAlphaId.Zero();
       
   197 			CTlv alphaIdentifier;
       
   198 			TInt returnValue( berTlv.TlvByTagValue( &alphaIdentifier, 
       
   199 				KTlvAlphaIdentifierTag ) );
       
   200 			// If alpha id string exist
       
   201 			if ( KErrNone == returnValue ) 
       
   202 				{
       
   203 				TUint16 alphaIdLength( alphaIdentifier.GetLength() );
       
   204         
       
   205 			   if ( alphaIdLength )
       
   206 					{
       
   207 					// Get the alpha id
       
   208 					sourceString.Set( alphaIdentifier.GetData( 
       
   209 						ETLV_AlphaIdentifier ) );
       
   210                 
       
   211 					// Convert and set the alpha id
       
   212 					TSatUtility::SetAlphaId( sourceString,
       
   213 					    selectItemV2.iAlphaId.iAlphaId );
       
   214 					}
       
   215 
       
   216 				// Check alpha tag (id) status
       
   217 				if ( alphaIdLength )
       
   218 					{
       
   219 					// Alpha tag present
       
   220 					if ( selectItemV2.iAlphaId.iAlphaId.Length() )
       
   221 						{
       
   222 						selectItemV2.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
   223 						}
       
   224 					else
       
   225 						{
       
   226 						TFLOGSTRING("CSAT: CSatNotifySelectItem::\
       
   227 						    CompleteNotifyL, Alpha ID is NULL");
       
   228 						selectItemV2.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
   229 						}
       
   230 					}
       
   231 				}
       
   232 			// Alpha id not present
       
   233 			else 
       
   234 				{
       
   235 				TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL\
       
   236 				    Alpha ID not present");
       
   237 				selectItemV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
   238 				}
       
   239 			// Help information
       
   240 			if ( KHelpAvailabilityMask & cmdQualifier )
       
   241 				{
       
   242 				// Help information available
       
   243 				selectItemV2.iHelp = RSat::EHelpAvailable;
       
   244 				}
       
   245 			else
       
   246 				{
       
   247 				TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL,\
       
   248 				    No Help available");
       
   249 				// No help
       
   250 				selectItemV2.iHelp = RSat::ENoHelpAvailable;
       
   251 				}
       
   252 			// Presentation as a choice of navigation options 
       
   253 			if ( KSelectItemChoiceOfNavigation == ( KSelectItemPresentationTypeMask & cmdQualifier ) )
       
   254 				{
       
   255 				selectItemV2.iPresentationType = RSat::ENavigationOptions;
       
   256 				}
       
   257 			// Presentation as a choice of data values 
       
   258 			else if ( KSelectItemChoiceOfData == ( KSelectItemPresentationTypeMask & cmdQualifier ) )
       
   259 				{
       
   260 				selectItemV2.iPresentationType = RSat::EDataValues;
       
   261 				}
       
   262 			else
       
   263 				{
       
   264 				selectItemV2.iPresentationType = RSat::ENotSpecified;
       
   265 				}
       
   266 			// Selection preference
       
   267 			if ( KSelectItemSelectUsingSoftKeyMask & cmdQualifier ) 
       
   268 				{
       
   269 				// Preference = soft key
       
   270 				selectItemV2.iPreference = RSat::ESoftKeyPreferred;
       
   271 				}
       
   272 			else
       
   273 				{
       
   274 				// Preference not set
       
   275 				selectItemV2.iPreference = RSat::ESelectionPreferenceNotSet;
       
   276 				}
       
   277 			// Default item id ( optional )
       
   278 			CTlv defaultItem;
       
   279 			returnValue = berTlv.TlvByTagValue( &defaultItem, 
       
   280 			    KTlvItemIdentifierTag );
       
   281 
       
   282 			if ( KErrNone == returnValue ) 
       
   283 				{
       
   284 				selectItemV2.iDefaultItemId = 
       
   285 					defaultItem.GetShortInfo( ETLV_IdentifierOfItemChosen );
       
   286 				}
       
   287         
       
   288 			// Icon qualifier list ( optional )
       
   289 			// Each item of a list of items has an icon identifier coded on one 
       
   290 			// byte. The length of the Items icon identifier list shall be the 
       
   291 			// number of items of the list of items (X-1 shall be the number of 
       
   292 			// items in the list). The order of each item icon identifier, 
       
   293 			// shall reflect the order of the items in the list of items.
       
   294 			// Each icon identifier addresses a record 
       
   295 			// in EFIMG as defined in TS 11.11 
       
   296 
       
   297 			CTlv itemsIconIdentifierList;
       
   298 			TInt retValue( berTlv.TlvByTagValue( &itemsIconIdentifierList, 
       
   299 												 KTlvItemIconIdentifierListTag ) );
       
   300 
       
   301 			selectItemV2.iIconListQualifier = RSat::EIconQualifierNotSet;
       
   302 			TPtrC8 iconIdList;
       
   303 			if ( KErrNone == retValue )
       
   304 				{
       
   305 				TUint8 iconListQualifier( itemsIconIdentifierList.GetShortInfo( 
       
   306 					ETLV_IconListQualifier ) );
       
   307 				// Set iconIdList pointer
       
   308 				iconIdList.Set( 
       
   309 					itemsIconIdentifierList.GetData( ETLV_IconIdentifierList ));
       
   310 				// The icon list qualifier indicates to the ME how 
       
   311 				// the icons are to be used
       
   312 				if( iconListQualifier )
       
   313 					{
       
   314 					// icon is not self-explanatory, i.e. if displayed, 
       
   315 					// it shall be displayed together with the item text
       
   316 					selectItemV2.iIconListQualifier = RSat::ENotSelfExplanatory;
       
   317 					}
       
   318 				else
       
   319 					{
       
   320 					// icon is self-explanatory, i.e. if displayed, 
       
   321 					// it replaces the item text
       
   322 					selectItemV2.iIconListQualifier = RSat::ESelfExplanatory;
       
   323 					}
       
   324 				}
       
   325 			else if ( KErrNotFound == retValue )
       
   326 				{
       
   327 				TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL,\
       
   328 				    No Icon ID");
       
   329 				selectItemV2.iIconListQualifier = RSat::ENoIconId;
       
   330 				}
       
   331 			else
       
   332 				{
       
   333         		TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL, \
       
   334         			Return value not valid.");
       
   335 				}
       
   336              
       
   337             ret = HandleItemsL( pCmdNumber, &berTlv, ret, iconIdList, 
       
   338             	&selectItemV2 );
       
   339                         
       
   340 			// Iconid 
       
   341 			TSatUtility::FillIconStructure( berTlv, selectItemV2.iIconId );
       
   342 
       
   343             } // End of if ( KErrNone == aErrorCode )
       
   344         else
       
   345         	{
       
   346         	ret = aErrorCode;
       
   347         	}
       
   348         iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
       
   349 
       
   350         } // End of if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
       
   351 	else 
       
   352         {
       
   353         TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL,\
       
   354             Request not ongoing");
       
   355         // Request not on, returning response immediately       
       
   356 		additionalInfo.Zero();
       
   357         additionalInfo.Append( KNoCause );
       
   358 		CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd,        
       
   359 			additionalInfo );					
       
   360     	}
       
   361 	
       
   362 	return ret;
       
   363 	}
       
   364 
       
   365 // -----------------------------------------------------------------------------
       
   366 // CSatNotifySelectItem::TerminalResponseL
       
   367 // Called by ETel server, passes terminal response to DOS
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 TInt CSatNotifySelectItem::TerminalResponseL
       
   371         ( 
       
   372         TDes8* aRsp 
       
   373         ) 
       
   374     {
       
   375     TFLOGSTRING("CSAT:: CSatNotifySelectItem::TerminalResponseL");
       
   376 
       
   377     TInt   ret( KErrNone );
       
   378     TBuf<1> additionalInfo;
       
   379     RSat::TSelectItemRspV1Pckg* aRspPckg = 
       
   380             reinterpret_cast<RSat::TSelectItemRspV1Pckg*> ( aRsp );
       
   381     RSat::TSelectItemRspV1& rspV1 = ( *aRspPckg ) ();	
       
   382 	// Get Proactive command number
       
   383 	TUint8 pCmdNumber( rspV1.PCmdNumber() );
       
   384    
       
   385     // Check that general result values are valid
       
   386     if ( ( RSat::KSuccess != rspV1.iGeneralResult ) 
       
   387         && ( RSat::KSuccessRequestedIconNotDisplayed != rspV1.iGeneralResult )
       
   388         && ( RSat::KPSessionTerminatedByUser != rspV1.iGeneralResult )
       
   389         && ( RSat::KBackwardModeRequestedByUser != rspV1.iGeneralResult )
       
   390         && ( RSat::KNoResponseFromUser != rspV1.iGeneralResult )
       
   391         && ( RSat::KHelpRequestedByUser != rspV1.iGeneralResult )
       
   392         && ( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult )
       
   393         && ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult ) )
       
   394         {
       
   395         TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL,\
       
   396             Invalid General Result");
       
   397         ret = KErrCorrupt;
       
   398         }
       
   399     // If there is ME (Mobile Entity) error or there there should be 
       
   400     // item identifier or
       
   401     // general result is success, additional info is needed
       
   402     if ( ( RSat::KMeProblem == rspV1.iInfoType )
       
   403         || ( RSat::KItemIdentifier == rspV1.iInfoType ) 
       
   404         || ( RSat::KSuccess == rspV1.iGeneralResult ) )
       
   405         {
       
   406         // Check the length of additional info
       
   407         if ( rspV1.iAdditionalInfo.Length() != 0 )
       
   408             {
       
   409             TFLOGSTRING2("CSAT: CSatNotifySelectItem::TerminalResponseL, \
       
   410                 Additional info: %S", &rspV1.iAdditionalInfo);
       
   411             additionalInfo.Zero();
       
   412             additionalInfo.Append( rspV1.iAdditionalInfo[0] );
       
   413             TFLOGSTRING2("CSAT: CSatNotifySelectItem::TerminalResponseL, \
       
   414                 Additional info: %S", &additionalInfo);
       
   415 			}
       
   416         else
       
   417             {
       
   418             TFLOGSTRING("CSAT: CSatNotifySelectItem::CompleteNotifyL,\
       
   419                 Invalid Additional Info");
       
   420             ret = KErrCorrupt;
       
   421             }
       
   422         }
       
   423         
       
   424     if ( RSat::KSuccess == rspV1.iGeneralResult ) 
       
   425     	{
       
   426     	if (iItemNextIndicatorRemoved)
       
   427     		{
       
   428     		TFLOGSTRING("CSatNotifySelectItem::TerminalResponseL, Partial Comprehension, \
       
   429     			iItemNextIndicatorRemoved");
       
   430         	rspV1.iGeneralResult = RSat::KPartialComprehension;
       
   431     		}
       
   432     	if (iItemsIconIdListRemoved)
       
   433     		{
       
   434         	TFLOGSTRING("CSatNotifySelectItem::TerminalResponseL, Partial Comprehension, \
       
   435         		iItemsIconIdListRemoved");
       
   436         	rspV1.iGeneralResult = RSat::KPartialComprehension;
       
   437     		}
       
   438     	}
       
   439     	
       
   440     iItemNextIndicatorRemoved = EFalse;
       
   441     iItemsIconIdListRemoved = EFalse;
       
   442     
       
   443     CreateTerminalRespL( pCmdNumber, static_cast<TUint8>( 
       
   444         rspV1.iGeneralResult ), additionalInfo );                            
       
   445 	
       
   446 	return ret;
       
   447     }
       
   448 
       
   449 
       
   450 // -----------------------------------------------------------------------------
       
   451 // CSatNotifySelectItem::CreateTerminalRespL
       
   452 // Constructs SelectItem specific part of terminal response and calls 
       
   453 // DOS to send the actual message.
       
   454 // -----------------------------------------------------------------------------
       
   455 //
       
   456 TInt CSatNotifySelectItem::CreateTerminalRespL
       
   457 	    ( 
       
   458     	TUint8 aPCmdNumber,         
       
   459 	    TUint8 aGeneralResult,      
       
   460 	    TDesC16& aAdditionalInfo			
       
   461 	    )	
       
   462 	{	    
       
   463 	TFLOGSTRING2("CSAT: CSatNotifySelectItem::CreateTerminalRespL, \
       
   464         Additional info: %S", &aAdditionalInfo);
       
   465 
       
   466 	TTlv tlvSpecificData;    
       
   467     // Create General Result TLV here
       
   468     tlvSpecificData.AddTag( KTlvResultTag );    
       
   469     // General result
       
   470     tlvSpecificData.AddByte( aGeneralResult );
       
   471         
       
   472     if ( !( iNotificationsTsy->CommandPerformedSuccessfully( aGeneralResult ) ) )
       
   473         {
       
   474         switch ( aGeneralResult )
       
   475             {
       
   476             case RSat::KHelpRequestedByUser:   
       
   477                 {
       
   478                 // Add selected Item Id tag
       
   479                 tlvSpecificData.AddTag( KTlvItemIdentifierTag );
       
   480                 tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] ); 
       
   481 				break;
       
   482                 }
       
   483             case RSat::KPSessionTerminatedByUser:
       
   484             case RSat::KBackwardModeRequestedByUser:
       
   485             case RSat::KNoResponseFromUser:
       
   486                 {
       
   487                 break;
       
   488                 }
       
   489             default:
       
   490                 {
       
   491                 if (aAdditionalInfo.Length() > 0)
       
   492                 	{
       
   493                 	tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] );
       
   494                 	}
       
   495                 break;
       
   496                 }
       
   497             }
       
   498         }
       
   499     else
       
   500         {
       
   501         // Add selected Item Id tag
       
   502         tlvSpecificData.AddTag( KTlvItemIdentifierTag );
       
   503         tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] );
       
   504         }
       
   505 
       
   506     // Prepare data
       
   507     iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
       
   508     TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
       
   509 
       
   510     // Pack data
       
   511     CSatDataPackage dataPackage;
       
   512 	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
       
   513 
       
   514     // Forward request to the DOS
       
   515     return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   516 		ESatTerminalRsp, &dataPackage );
       
   517     }
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 // CSatNotifySelectItem::HandleItemsL
       
   521 // Handle menu items
       
   522 // -----------------------------------------------------------------------------
       
   523 //
       
   524 TInt CSatNotifySelectItem::HandleItemsL
       
   525 		(
       
   526 		TUint8 aPCmdNumber,
       
   527 		CBerTlv* aBerTlv,
       
   528 		TInt aRet,
       
   529 		TPtrC8 aIconIdList,
       
   530 		RSat::TSelectItemV2* aSelectItemV2
       
   531 		)
       
   532 	{
       
   533 	TFLOGSTRING("CSAT: CSatNotifySelectItem::HandleItemsL");
       
   534 	TInt ret( aRet );
       
   535 
       
   536 	CTlv item;
       
   537 	// Get all items
       
   538 	TInt returnValue = aBerTlv->TlvByTagValueMulti( &item, KTlvItemTag );
       
   539 
       
   540 	TPtrC8 itemData = item.Data();
       
   541 	TUint8 numberOfItemData( 0 );
       
   542 	TInt ind( 0 );
       
   543 	TUint16 tlvLength( 0 );
       
   544 	TInt currentTlv( 0 );
       
   545 	TInt i( 0 );
       
   546 	
       
   547 	// Set numberOfItemData
       
   548 	for ( i = 0; i < itemData.Length(); i += ( TInt ) tlvLength )
       
   549 		{
       
   550 		// First determine if the length of the TLV is 
       
   551 		// coded with 1 or 2 bytes.
       
   552 		if ( KTwoByteLengthCoding == itemData[ind+1] )
       
   553 			{
       
   554 			// Length is coded with 2 bytes -> real length is in second 
       
   555 			// byte first byte is 81 and it is "tag" for 2 byte length 
       
   556 			// coding.
       
   557 			tlvLength = ( TUint16 ) 
       
   558 				( itemData[ind + 2] + KTlvHeaderLength + 1 );
       
   559 			}        
       
   560 		else
       
   561 			{
       
   562 			// TLV header bytes (2) must be added to total length
       
   563 			tlvLength = ( TUint16 ) 
       
   564 				( itemData[ind + 1]  + KTlvHeaderLength );
       
   565 			}
       
   566 
       
   567 		currentTlv = itemData[ind]&KTagValueMask;
       
   568 
       
   569 		if ( KTlvItemTag == currentTlv )
       
   570 			{
       
   571 			numberOfItemData++;   
       
   572 			}
       
   573 
       
   574 		ind += tlvLength;
       
   575 		}
       
   576 		
       
   577     // See if itemnextindicator is included ( optional )
       
   578     CTlv nextIndicator;
       
   579                  
       
   580     returnValue = aBerTlv->TlvByTagValue( &nextIndicator, 
       
   581         KTlvItemsNextActionIndicatorTag );
       
   582         
       
   583     TPtrC8 itemNextIndicator;
       
   584     
       
   585     if ( KErrNone == returnValue ) 
       
   586         {
       
   587         TPtrC8 itemNextIndicatorTemp;
       
   588         itemNextIndicatorTemp.Set( nextIndicator.GetData( 
       
   589             ETLV_ItemsNextActionIndicator ) );
       
   590             
       
   591         // In case the number of items in this list doesn't match the nr of 
       
   592         // items in the menu, Items Next Action Indicator list is ignored by ME
       
   593         if( itemNextIndicatorTemp.Length() != numberOfItemData )
       
   594         	{
       
   595         	iItemNextIndicatorRemoved = ETrue;
       
   596         	}
       
   597         else
       
   598         	{
       
   599         	itemNextIndicator.Set( itemNextIndicatorTemp );
       
   600         	}
       
   601         }
       
   602 
       
   603     if ( ( aIconIdList.Length() > 0 ) && 
       
   604     	 ( aIconIdList.Length() != numberOfItemData ) )
       
   605     	{
       
   606         // In case the number of items in this list doesn't match the nr of 
       
   607         // items in the menu, Items Icon Identifier list is ignored by ME
       
   608     	iItemsIconIdListRemoved = ETrue;
       
   609     	aIconIdList.Set( KNullDesC8 ); 
       
   610     	}
       
   611     
       
   612 	// Filling up the menu items
       
   613 	RSat::TItem newItem;
       
   614 	// Set string length and pos
       
   615 	TUint8 stringLength( 0 );
       
   616 	TUint8  pos( 2 );
       
   617 
       
   618 	// LOOP Through ALL MENU ITEMS AND TAKE THE DATA
       
   619 	for ( i = 0; ( i < numberOfItemData ) && ( KErrNone == ret ); i++ )
       
   620 		{
       
   621 		// Check if two byte length coding is used
       
   622 		if ( KTwoByteLengthCoding == itemData[pos - 1] )
       
   623 			{
       
   624 			// Set new offset
       
   625 			pos++;
       
   626 			}
       
   627 		// Fill the newitem
       
   628 		newItem.iItemId = itemData[pos];
       
   629 		stringLength = itemData[pos - 1];
       
   630 		// Copying the string from 8-bit to 16-bit
       
   631 		
       
   632 		if ( RSat::KMenuItemMaxSize < stringLength )
       
   633 			{
       
   634 			// String too long
       
   635 			ret = KErrCorrupt;
       
   636 			}
       
   637 			
       
   638 		newItem.iItemString.Zero();
       
   639 		// ArabicCoding, GreekCoding and TurkishCoding have different 
       
   640 		// coding method. There is a tag for each type of alphabet 
       
   641 		// (resp. 80, 81 or 82) before the text, and there are base 
       
   642 		// pointers used for expanding 1 byte to 2 bytes as required
       
   643 		// in UCS2  
       
   644 		// Ref: 3gpp 11.11, Annex B
       
   645 		
       
   646 		// Check if string present
       
   647         if ( 0 < ( stringLength - 1 ) )
       
   648         	{
       
   649 
       
   650 			TBuf8<RSat::KTextStringMaxSize> itemText;
       
   651 			itemText = itemData.Mid( pos + 1, stringLength - 1 );
       
   652 	    
       
   653 			if ( ( KUCS2ArabicCoding == itemText[0] )
       
   654 				|| ( KUCS2GreekCoding == itemText[0] )
       
   655 				|| ( KUCS2TurkishCoding == itemText[0] ) )
       
   656 				{
       
   657 				TSatUtility::ConvertAlphaFieldsToUnicode( itemText, 
       
   658 					newItem.iItemString );
       
   659 				}
       
   660 			else
       
   661 				{
       
   662 				// 8-bit format
       
   663 				TSatUtility::Convert7BitToUnicode16( itemText, 
       
   664 				    newItem.iItemString );
       
   665 				}       
       
   666         	}
       
   667         	
       
   668 		if ( ( NULL != aIconIdList.Size() )
       
   669 			&& ( i < aIconIdList.Length() ) )
       
   670 			{
       
   671 			if ( ( NULL != itemNextIndicator.Size() ) 
       
   672 				&& ( i < itemNextIndicator.Length() ) )
       
   673 				{
       
   674 				// ADD ITEM WITH ITEM NEXT INDICATOR AND ICON IDENTIFIER
       
   675 				if ( KErrNoMemory == aSelectItemV2->AddItem( 
       
   676 					newItem, itemNextIndicator[i], aIconIdList[i] ) )
       
   677 					{
       
   678 					TFLOGSTRING("CSAT: CSatNotifySelectItem::HandleItemsL,\
       
   679 					    Icon data length exceeded, AddItem1");
       
   680 					// Too many or long menu items
       
   681 					ret = KErrCorrupt;
       
   682 					}
       
   683 				}
       
   684 			// ADD ITEM WITH ICON
       
   685 			else if ( KErrNoMemory == aSelectItemV2->AddItemIcon( 
       
   686 				newItem, aIconIdList[i] ) )
       
   687 				{
       
   688 				TFLOGSTRING("CSAT: CSatNotifySelectItem::HandleItemsL,\
       
   689 			        Icon data length exceeded, AddItemIcon");
       
   690 				// Too many or long menu items
       
   691 				ret = KErrCorrupt;
       
   692 				}
       
   693 			}
       
   694 		else 
       
   695 			{
       
   696 			if ( ( NULL != itemNextIndicator.Size() ) 
       
   697 				&& ( i < itemNextIndicator.Length() ) )
       
   698 				{
       
   699 				// ADD ITEM WITH ITEM NEXT INDICATOR
       
   700 				if ( KErrNoMemory == aSelectItemV2->AddItem( 
       
   701 					newItem, itemNextIndicator[i] ) )
       
   702 					{
       
   703 					TFLOGSTRING("CSAT: CSatNotifySelectItem::HandleItemsL,\
       
   704 			            Icon data length exceeded, AddItem2");
       
   705 					// Too many or long menu items
       
   706 					ret = KErrCorrupt;
       
   707 					}
       
   708 				}
       
   709 			//ADD ITEM
       
   710 			else 
       
   711 				{
       
   712 				TInt retAdd = aSelectItemV2->AddItem( newItem );
       
   713 				if ( KErrNoMemory == retAdd ) 
       
   714 					{
       
   715 					TFLOGSTRING("CSAT: CSatNotifySelectItem::HandleItemsL,\
       
   716 			            AddItem failed -> KErrNoMemory");
       
   717 					// Too many or long menu items
       
   718 					// If there is not enough space left in the buffer used
       
   719 					// by the menu KErrNoMemory is returned.
       
   720 					TBuf<1> additionalInfo;
       
   721 					additionalInfo.Zero();
       
   722                     additionalInfo.Append( KNoCause );
       
   723 					// Send terminal response
       
   724 					CreateTerminalRespL( aPCmdNumber, 
       
   725 					    RSat::KCmdDataNotUnderstood, additionalInfo );
       
   726 					ret = KErrCorrupt;
       
   727 					}
       
   728 				}
       
   729 			}
       
   730 
       
   731 		// Calculating the new position
       
   732 		pos = TUint8( pos + itemData[pos - 1] + 2 );
       
   733 		}
       
   734 		
       
   735 	return ret;
       
   736 	}
       
   737 			
       
   738 // End of File