telephonyserverplugins/simatktsy/src/CSatNotifySendUssd.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
child 42 3adadc800673
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        : CSatNotifySendUssd.cpp
       
    15 // Part of     : Common SIM ATK TSY / commonsimatktsy
       
    16 // SendUssd 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 "CSatNotifySendUssd.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 // CSatNotifySendUssd::NewL
       
    37 // Two-phased constructor.
       
    38 // -----------------------------------------------------------------------------
       
    39 //  
       
    40 CSatNotifySendUssd* CSatNotifySendUssd::NewL
       
    41         ( 
       
    42         CSatNotificationsTsy* aNotificationsTsy 
       
    43         )
       
    44     {
       
    45     TFLOGSTRING("CSAT: CSatNotifySendUssd::NewL");
       
    46    	CSatNotifySendUssd* const satNotifySendUssd = 
       
    47         new ( ELeave ) CSatNotifySendUssd( aNotificationsTsy );
       
    48     CleanupStack::PushL( satNotifySendUssd );
       
    49     satNotifySendUssd->ConstructL();
       
    50     CleanupStack::Pop( satNotifySendUssd );
       
    51     TFLOGSTRING("CSAT: CSatNotifySendUssd::NewL, end of method");
       
    52     return satNotifySendUssd;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CSatNotifySendUssd::~CSatNotifySendUssd
       
    57 // Destructor
       
    58 // -----------------------------------------------------------------------------
       
    59 //  
       
    60 CSatNotifySendUssd::~CSatNotifySendUssd
       
    61         ( 
       
    62 		// None
       
    63         )
       
    64     {
       
    65     TFLOGSTRING("CSAT: CSatNotifySendUssd::~CSatNotifySendUssd");
       
    66     }
       
    67     
       
    68 // -----------------------------------------------------------------------------
       
    69 // CSatNotifySendUssd::CSatNotifySendUssd
       
    70 // Default C++ constructor
       
    71 // -----------------------------------------------------------------------------
       
    72 //  
       
    73 CSatNotifySendUssd::CSatNotifySendUssd
       
    74         ( 
       
    75         CSatNotificationsTsy* aNotificationsTsy 
       
    76         ) : iNotificationsTsy ( aNotificationsTsy )
       
    77     {
       
    78     // None
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSatNotifySendUssd::ConstructL
       
    83 // Symbian 2nd phase constructor
       
    84 // -----------------------------------------------------------------------------
       
    85 //  
       
    86 void CSatNotifySendUssd::ConstructL
       
    87         (
       
    88         // None
       
    89         )
       
    90     {
       
    91     TFLOGSTRING("CSAT: CSatNotifySendUssd::ConstructL");
       
    92     }
       
    93    
       
    94 // -----------------------------------------------------------------------------
       
    95 // CSatNotifySendUssd::Notify
       
    96 // This request allows a client to be notified of a SEND USSD proactive 
       
    97 // command
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 TInt CSatNotifySendUssd::Notify
       
   101         (
       
   102         const TTsyReqHandle aTsyReqHandle,
       
   103         const TDataPackage& aPackage 
       
   104         )
       
   105     {
       
   106     TFLOGSTRING("CSAT: CSatNotifySendUssd::Notify");
       
   107 
       
   108     // Save data pointer to client side for completion
       
   109     iSendUssdV1Pckg = reinterpret_cast<RSat::TSendUssdV1Pckg*>( 
       
   110         aPackage.Des1n() );
       
   111     
       
   112     // Save the request handle
       
   113     iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, 
       
   114 		CSatTsy::ESatNotifySendUssdPCmdReqType );
       
   115 
       
   116     // Check if requested notification is already pending
       
   117     iNotificationsTsy->NotifySatReadyForNotification( KSendUssd );   
       
   118 
       
   119     return KErrNone;
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CSatNotifySendUssd::CancelNotification
       
   124 // This method cancels an outstanding asynchronous 
       
   125 // NotifySendUssd request.
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 TInt CSatNotifySendUssd::CancelNotification
       
   129         (
       
   130         const TTsyReqHandle aTsyReqHandle 
       
   131         )
       
   132     {
       
   133     TFLOGSTRING("CSAT: CSatNotifySendUssd::CancelNotification");
       
   134     
       
   135     // Reset the request handle
       
   136     TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore->
       
   137         ResetTsyReqHandle( CSatTsy::ESatNotifySendUssdPCmdReqType );
       
   138 	// Reset the data pointer
       
   139 	iSendUssdV1Pckg = NULL;
       
   140 	// Complete the request with KErrCancel
       
   141 	iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel );
       
   142     return KErrNone;    
       
   143     }
       
   144     
       
   145 // -----------------------------------------------------------------------------
       
   146 // CSatNotifySendUssd::CompleteNotifyL
       
   147 // This method completes an outstanding asynchronous 
       
   148 // NotifySendUssd request. 
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 TInt CSatNotifySendUssd::CompleteNotifyL
       
   152         (
       
   153         CSatDataPackage* aDataPackage,   
       
   154         TInt aErrorCode                  
       
   155         )
       
   156     {
       
   157     TFLOGSTRING("CSAT: CSatNotifySendUssd::CompleteNotifyL");	
       
   158 	TInt ret( KErrNone );
       
   159 	TInt returnValue( KErrNone );
       
   160 	TBuf<1> additionalInfo;
       
   161 	TBuf<1> emptyText;	
       
   162     // Unpack parameters
       
   163     TPtrC8* data;
       
   164     aDataPackage->UnPackData( &data );
       
   165     // Reset req handle. Returns the deleted req handle
       
   166     TTsyReqHandle reqHandle = 
       
   167 		iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( 
       
   168         CSatTsy::ESatNotifySendUssdPCmdReqType );
       
   169         	
       
   170 	// Get ber tlv
       
   171 	CBerTlv berTlv;
       
   172     berTlv.SetData( *data );	
       
   173 	// Get command details tlv
       
   174     CTlv commandDetails;
       
   175     berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag );
       
   176     // Store command details tlv
       
   177     iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( 
       
   178     		commandDetails.Data() );
       
   179     		
       
   180 	TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) );
       
   181     
       
   182     // In case the request was ongoing, continue..
       
   183     if ( CSatTsy::ESatReqHandleUnknown != reqHandle )
       
   184         {
       
   185         // Complete right away if error has occured, otherwise continue..
       
   186         if ( KErrNone == aErrorCode )
       
   187             {
       
   188 			// Fill the Send Ussd structure             
       
   189 			RSat::TSendUssdV1& sendUssdV1 = ( *iSendUssdV1Pckg )();			
       
   190 			// Store command number
       
   191 			sendUssdV1.SetPCmdNumber( pCmdNumber );
       
   192 			                   
       
   193 			TPtrC8 sourceStr; // Used with Copy8to16 function
       
   194 
       
   195 			// Alpha id string (optional)
       
   196 			sendUssdV1.iAlphaId.iAlphaId.Zero();
       
   197 			CTlv alphaIdentifier;
       
   198 			returnValue = berTlv.TlvByTagValue( &alphaIdentifier, 
       
   199 				KTlvAlphaIdentifierTag );
       
   200 				
       
   201 			if ( KErrNotFound != returnValue )
       
   202 				{
       
   203 				TUint16 alphaIdLength = alphaIdentifier.GetLength() ;
       
   204 				if ( RSat::KAlphaIdMaxSize < alphaIdLength )
       
   205 					{
       
   206 					TFLOGSTRING("CSAT: CSatNotifySendUssd::CompleteNotifyL,\
       
   207 					    Alpha ID length exceeded");
       
   208 					// String too long
       
   209 					additionalInfo.Zero();
       
   210                     additionalInfo.Append( KNoCause );
       
   211 					CreateTerminalRespL( pCmdNumber,
       
   212 						RSat::KMeUnableToProcessCmd, additionalInfo, 
       
   213 						emptyText );
       
   214 					ret = KErrCorrupt;
       
   215 					}
       
   216 				else if ( alphaIdLength )
       
   217 					{
       
   218 					// get the alpha id
       
   219 					sourceStr.Set( alphaIdentifier.GetData( ETLV_AlphaIdentifier ) );
       
   220 					// convert and set the alpha id
       
   221 					TSatUtility::SetAlphaId( sourceStr , 
       
   222 						sendUssdV1.iAlphaId.iAlphaId ); 
       
   223 					}
       
   224 
       
   225 				// Check alpha id status
       
   226 				// Alpha Tag present
       
   227 				if ( sendUssdV1.iAlphaId.iAlphaId.Length() )
       
   228 					{
       
   229 					sendUssdV1.iAlphaId.iStatus = RSat::EAlphaIdProvided;
       
   230 					}
       
   231 				else
       
   232 					{
       
   233 					TFLOGSTRING("CSAT: CSatNotifySendUssd::CompleteNotifyL,\
       
   234 					    Alpha ID is NULL");
       
   235 					sendUssdV1.iAlphaId.iStatus = RSat::EAlphaIdNull;
       
   236 					}  
       
   237 				}
       
   238 			else
       
   239 				{
       
   240 				TFLOGSTRING("CSAT: CSatNotifySendUssd::CompleteNotifyL,\
       
   241 				    Alpha ID not present");
       
   242 				sendUssdV1.iAlphaId.iStatus = RSat::EAlphaIdNotPresent;
       
   243 				}
       
   244 
       
   245 
       
   246 			// Ussd string (mandatory)
       
   247 			CTlv ussdTlv;
       
   248 			sendUssdV1.iUssdString.iUssdString.Zero();
       
   249 			returnValue = berTlv.TlvByTagValue( &ussdTlv, 
       
   250 				KTlvUssdStringTag );
       
   251 
       
   252 			if ( KErrNone == returnValue )
       
   253 				{
       
   254 	            // Get the data coding scheme from the ISI msg
       
   255 	            // and set the corresponding ETel Sat data field.
       
   256 	            // The DCS is coded as for Cell Broadcast.
       
   257 	            sendUssdV1.iUssdString.iDcs = 
       
   258 	                ussdTlv.GetShortInfo( ETLV_DataCodingScheme );
       
   259 	                
       
   260 	            // Decode DCS
       
   261 	            TSmsDcs decodedDcs( ESmsUnknownOrReservedDcs );
       
   262 	            decodedDcs = TSatUtility::DecodeCbsDcs( 
       
   263 	            	sendUssdV1.iUssdString.iDcs );
       
   264 	            
       
   265 	            TPtrC8 ussdString = ussdTlv.GetData( ETLV_UssdString ); 
       
   266 	            TUint16 ussdStringLengthInBytes = (TUint16) ( 
       
   267 	                ussdString.Length() );
       
   268 	            if ( (  ( ESms16BitDcs==decodedDcs ) 
       
   269 	                   && 2*RSat::KStringMaxSize<ussdStringLengthInBytes)
       
   270 	               || ( ( ESms8BitDcs==decodedDcs ) 
       
   271 	                  && RSat::KStringMaxSize<ussdStringLengthInBytes)
       
   272 	               || ( ( ESms7BitDcs==decodedDcs ) 
       
   273 	                  && RSat::KStringMaxSize<8*ussdStringLengthInBytes/7))
       
   274                 	{
       
   275                 	// The Ussd text string is too long.
       
   276                 	TFLOGSTRING("CSAT:CSatNotifySendUssd::CompleteNotifyL, \
       
   277                 	    USSD String too long");
       
   278 					// Text string too long
       
   279 					ret = KErrCorrupt;
       
   280 					additionalInfo.Zero();
       
   281 					CreateTerminalRespL( pCmdNumber, 
       
   282 					    RSat::KCmdDataNotUnderstood, additionalInfo, 
       
   283 						emptyText);   
       
   284 					}
       
   285 				else
       
   286 					{
       
   287 					
       
   288 	                // Conversion to 16-bit following the DCS
       
   289 	                switch ( decodedDcs )
       
   290 	                    {
       
   291 	                    case ESms7BitDcs:
       
   292 	                        {
       
   293 	                        TBuf8<RSat::KStringMaxSize> ussdString8;
       
   294 	                        TSatUtility::Packed7to8Unpacked( ussdString, 
       
   295 	                            ussdString8 );
       
   296 	                        TSatUtility::Convert7BitToUnicode16( ussdString8,
       
   297 	                            sendUssdV1.iUssdString.iUssdString );
       
   298 	                        break;
       
   299 	                        }
       
   300 	                    case ESms8BitDcs:
       
   301 	                        {
       
   302 	                        TSatUtility::Convert7BitToUnicode16( ussdString,
       
   303 	                            sendUssdV1.iUssdString.iUssdString );	                        
       
   304 	                        break;
       
   305 	                        }
       
   306 	                    case ESms16BitDcs:
       
   307 	                        {
       
   308 	                        TSatUtility::Copy8to16LE( ussdString , 
       
   309 	                        	sendUssdV1.iUssdString.iUssdString );
       
   310 	                        break;
       
   311 	                        }
       
   312 	                    default:
       
   313 	                        {
       
   314 	                        TFLOGSTRING("CSAT:CSatNotifySendUssd::CompleteNotifyL, \
       
   315 	                            USSD DCS has a reserved value");
       
   316 	                        // The DCS has a reserved value
       
   317 	                        ret = KErrCorrupt;
       
   318 							additionalInfo.Zero();
       
   319 							CreateTerminalRespL( pCmdNumber,
       
   320 								RSat::KCmdDataNotUnderstood, additionalInfo,
       
   321 								emptyText );  
       
   322 	                        break;
       
   323 	                        }     
       
   324 	                    }
       
   325 					}
       
   326 				}
       
   327 			else
       
   328 				{
       
   329 				// Mandatory field missing
       
   330 				ret = KErrCorrupt;
       
   331 				additionalInfo.Zero();
       
   332 				CreateTerminalRespL(
       
   333 					pCmdNumber, RSat::KErrorRequiredValuesMissing,
       
   334 					additionalInfo, emptyText );  
       
   335 				}
       
   336 
       
   337         	if ( KErrNone == ret )
       
   338             	{
       
   339 				// Iconid 
       
   340 				TSatUtility::FillIconStructure( berTlv, 
       
   341 					sendUssdV1.iIconId );
       
   342             	}
       
   343             	
       
   344 		    } // End of if (KErrNone == aErrorCode)
       
   345         else
       
   346         	{
       
   347         	ret = aErrorCode;
       
   348         	}
       
   349 
       
   350         iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret );
       
   351 
       
   352         } // End of if ( reqHandle != CSatTsy::ESatReqHandleUnknown )	
       
   353 	else 
       
   354         {
       
   355         TFLOGSTRING("CSAT: CSatNotifySendUssd::CompleteNotifyL,\
       
   356             Request not ongoing");
       
   357         // Request not on, returning response immediately
       
   358         additionalInfo.Zero();
       
   359         additionalInfo.Append( KNoCause );
       
   360 		CreateTerminalRespL(
       
   361 			pCmdNumber, RSat::KMeUnableToProcessCmd,
       
   362 			additionalInfo, emptyText);  
       
   363 		}
       
   364 
       
   365     return ret;
       
   366     }
       
   367 
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // CSatNotifySendUssd::TerminalResponseL
       
   371 // Called by ETel server, passes terminal response to DOS
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 TInt CSatNotifySendUssd::TerminalResponseL
       
   375         ( 
       
   376         TDes8* aRsp 
       
   377         )
       
   378     {
       
   379     TFLOGSTRING("CSAT: CSatNotifySendUssd::TerminalResponseL");
       
   380 	
       
   381     TInt ret( KErrNone );
       
   382     TBuf<RSat::KAdditionalInfoMaxSize> additionalInfo;
       
   383     RSat::TSendUssdRspV1Pckg* aRspPckg = 
       
   384             reinterpret_cast<RSat::TSendUssdRspV1Pckg*>( aRsp );
       
   385     RSat::TSendUssdRspV1& rspV1 = ( *aRspPckg ) ();
       
   386     // Get Proactive command number
       
   387     TUint8 pCmdNumber( rspV1.PCmdNumber() );
       
   388     // Check that general result values are valid
       
   389     if ( ( RSat::KSuccess != rspV1.iGeneralResult )
       
   390         && ( RSat::KPartialComprehension != rspV1.iGeneralResult )
       
   391         && ( RSat::KMissingInformation != rspV1.iGeneralResult )
       
   392         && ( RSat::KSuccessRequestedIconNotDisplayed != rspV1.iGeneralResult )
       
   393         && ( RSat::KModifiedByCallControl != rspV1.iGeneralResult )
       
   394         && ( RSat::KUssdTransactionTerminatedByUser != rspV1.iGeneralResult )
       
   395         && ( RSat::KInteractionWithCCTemporaryError != rspV1.iGeneralResult )
       
   396         && ( RSat::KCmdTypeNotUnderstood != rspV1.iGeneralResult )
       
   397         && ( RSat::KCmdDataNotUnderstood != rspV1.iGeneralResult )
       
   398         && ( RSat::KCmdNumberNotKnown != rspV1.iGeneralResult )
       
   399         && ( RSat::KErrorRequiredValuesMissing != rspV1.iGeneralResult )
       
   400         && ( RSat::KInteractionWithCCPermanentError != rspV1.iGeneralResult )     
       
   401         && ( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult )
       
   402         && ( RSat::KNetworkUnableToProcessCmd != rspV1.iGeneralResult )
       
   403         && ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult )
       
   404         && ( RSat::KUssdReturnError != rspV1.iGeneralResult ) )
       
   405         {
       
   406         TFLOGSTRING("CSAT: CSatNotifySendUssd::CompleteNotifyL,\
       
   407             Invalid General Result");
       
   408         // Invalid general result
       
   409         ret = KErrCorrupt;
       
   410         }
       
   411 
       
   412     // If there is Me (Mobile Entity) error, network error or text string,
       
   413     // additional info is needed
       
   414     additionalInfo.Zero();
       
   415     if ( ( RSat::KMeProblem == rspV1.iInfoType )
       
   416         || ( RSat::KCallControlRequestedAction == rspV1.iInfoType )
       
   417         || ( RSat::KSatNetworkErrorInfo == rspV1.iInfoType )
       
   418         || ( RSat::KTextString == rspV1.iInfoType ) )
       
   419         {
       
   420         // Check the length of additional info:
       
   421         if ( 0 == rspV1.iAdditionalInfo.Length() )
       
   422             {
       
   423             // No info
       
   424             TFLOGSTRING("CSAT:CSatNotifySendUssd::TerminalResponseL, \
       
   425             	AdditionalInfoType set, but no additional info available");            
       
   426             ret = KErrCorrupt;
       
   427             }
       
   428         else if ( RSat::KTextString == rspV1.iInfoType )
       
   429             {
       
   430             // Text string - additional info for a 
       
   431             // successful GET INKEY, GET INPUT or SEND USSD.
       
   432             // --> Not used by SAT Server when the command has been
       
   433             // performed successfully, SAT Server uses the 
       
   434             // rspV1.iUssdString.iUssdString to return the USSD string
       
   435             // sent by the network.
       
   436             TFLOGSTRING("CSAT:CSatNotifySendUssd::TerminalResponseL, \
       
   437             	AdditionalInfoType set to TextString.");            
       
   438             }            
       
   439         else
       
   440             {
       
   441             additionalInfo.Zero();          
       
   442             additionalInfo.Append( rspV1.iAdditionalInfo[0] );
       
   443             }
       
   444         }
       
   445     
       
   446     TInt response = CreateTerminalRespL( pCmdNumber, static_cast<TUint8>( rspV1.iGeneralResult ), 
       
   447         additionalInfo, rspV1.iUssdString.iUssdString,                            
       
   448         rspV1.iUssdString.iDcs );                    
       
   449 
       
   450     if( KErrNone == ret)
       
   451     	{
       
   452     	ret = response;
       
   453     	}
       
   454     
       
   455     return ret;
       
   456     }
       
   457 
       
   458 
       
   459 // -----------------------------------------------------------------------------
       
   460 // CSatNotifySendUssd::CreateTerminalRespL
       
   461 // Constructs SendUssd specific part of terminal response and calls 
       
   462 // DOS to send the actual message.
       
   463 // -----------------------------------------------------------------------------
       
   464 //
       
   465 TInt CSatNotifySendUssd::CreateTerminalRespL
       
   466         ( 
       
   467         TUint8 aPCmdNumber,         
       
   468         TUint8 aGeneralResult,      
       
   469         TDesC16& aAdditionalInfo,	
       
   470         TDesC16& aTextString,       
       
   471 		TUint8 aDcs		
       
   472 		)
       
   473     {
       
   474 	TFLOGSTRING("CSAT: CSatNotifySendUssd::CreateTerminalRespL");
       
   475     TTlv tlvSpecificData;
       
   476     TBuf8<RSat::KStringMaxSize> string;
       
   477 
       
   478     tlvSpecificData.AddTag( KTlvResultTag );
       
   479     tlvSpecificData.AddByte( aGeneralResult );
       
   480 
       
   481     if( !iNotificationsTsy->CommandPerformedSuccessfully( aGeneralResult ) )
       
   482     	{
       
   483 	    // For the general results '20', '21', '37', '38' it is mandatory for the 
       
   484 	    // ME to provide a specific cause value as additional info
       
   485 	    if ( ( RSat::KMeUnableToProcessCmd == aGeneralResult ) || 
       
   486 	         ( RSat::KNetworkUnableToProcessCmd == aGeneralResult ) || 
       
   487 	         ( RSat::KUssdReturnError == aGeneralResult) || 
       
   488 	         ( RSat::KMultipleCardCmdsError == aGeneralResult) )
       
   489 	        {
       
   490 	        for ( TInt i = 0; i < aAdditionalInfo.Length(); i++ )
       
   491 	            {
       
   492 	            tlvSpecificData.AddByte( ( TUint8 ) ( 
       
   493 	            	aAdditionalInfo[i] & 0x00FF ) );
       
   494 	            }
       
   495 	        }
       
   496         }
       
   497     else
       
   498         {
       
   499         // Append received Ussd text string, with a Text string tag
       
   500         tlvSpecificData.AddTag( KTlvTextStringTag );  
       
   501                               
       
   502         // Decode DCS
       
   503         // Remains to know if SatServer sets the general result to
       
   504         // KUssdReturnError when the DCS has a reserved value. 
       
   505         TSmsDcs decodedDcs( ESmsUnknownOrReservedDcs );
       
   506         decodedDcs = TSatUtility::DecodeCbsDcs( aDcs ); 
       
   507         //Data Coding Scheme for Text String
       
   508         tlvSpecificData.AddByte( (TUint8)decodedDcs );        
       
   509         
       
   510         switch ( decodedDcs )
       
   511             {
       
   512             case ESms7BitDcs:
       
   513                 {
       
   514                 // Convert the Response string (which comes in the form of 
       
   515                 // a TBuf (unicode)) to 7-bit gsm format.                      
       
   516                 TSatUtility::UCSToPacked7( aTextString, string );                                
       
   517                 break;
       
   518                 }
       
   519             case ESms8BitDcs:            
       
   520                 {
       
   521                 // Convert the Response string (which comes in the form of 
       
   522                 // a TBuf (unicode)) to 7-bit gsm format.      
       
   523                 TSatUtility::ConvertUnicode16To7Bit( aTextString, string );
       
   524                 break;
       
   525                 }
       
   526             case ESms16BitDcs:
       
   527                 {
       
   528                 TSatUtility::Copy16to8LE( aTextString, string );
       
   529                 break;
       
   530                 }
       
   531             default:
       
   532                 {
       
   533                 // Reserved
       
   534                 // The general result should in fact prevent reaching this branch of
       
   535                 // the switch.
       
   536                 TFLOGSTRING("TSY:CSatMessHandler::SendUssdTerminalRespL, \
       
   537                     The DCS sent by the network has a reserved value. The general result \
       
   538                     should have been set to UssdReturnError");
       
   539                 break;
       
   540                 }                        
       
   541             }                   
       
   542         // Text
       
   543         tlvSpecificData.AddData( string );       
       
   544         }
       
   545    
       
   546 	// Prepare data
       
   547     iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber;
       
   548     TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag();
       
   549     // Pack data
       
   550     CSatDataPackage dataPackage;
       
   551 	dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data );
       
   552     // Forward request to the DOS
       
   553     return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( 
       
   554 		ESatTerminalRsp, &dataPackage );
       
   555     }
       
   556     
       
   557 // End of File