satengine/SatServer/Commands/SendUSSDCmd/src/CSendUssdHandler.cpp
changeset 52 d841fb1cc818
parent 32 1f002146abb4
equal deleted inserted replaced
50:2313cb430f28 52:d841fb1cc818
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include    <cphcltussdsatclient.h>
    19 #include    <cphcltussdsatclient.h>
    20 #include	<cphcltussd.h>
    20 #include    <cphcltussd.h>
    21 #include    <exterror.h>
    21 #include    <exterror.h>
       
    22 #include    <centralrepository.h>
       
    23 #include    <SATPrivateCRKeys.h>
       
    24 #include    <hbdevicemessageboxsymbian.h>
    22 
    25 
    23 #include    "MSatSystemState.h"
    26 #include    "MSatSystemState.h"
    24 #include    "MSatApi.h"
    27 #include    "MSatApi.h"
    25 #include    "MSatUtils.h"
    28 #include    "MSatUtils.h"
       
    29 #include    "msatmultimodeapi.h"
    26 #include    "MSatUiSession.h"
    30 #include    "MSatUiSession.h"
    27 #include    "SatSOpcodes.h"
    31 #include    "SatSOpcodes.h"
    28 #include    "MSatSUiClientHandler.h"
    32 #include    "MSatSUiClientHandler.h"
    29 #include    "CSendUssdHandler.h"
    33 #include    "CSendUssdHandler.h"
    30 #include    "TSatExtErrorUtils.h"
    34 #include    "TSatExtErrorUtils.h"
    31 #include    "SatLog.h"
    35 #include    "SatLog.h"
    32 
    36 
    33 const TUint8 KQuarterShift( 2 );
    37  /** 
    34 const TUint8 KHighNibbleShift( 4 );
    38   * USSD messages coded as a packed string within 160 octets, as defined for a 
    35 const TUint8 KDcsCharacterSet7Bit( 0x00 );
    39   * ussd-String within GSM 04.80 and GSM 03.38. if the Dcs is 7 bit, a ussd 
    36 const TUint8 KDcsCharacterSet8Bit( 0x01 );
    40   * string can have 182 charactor
    37 const TUint8 KDcsCharacterSet16Bit( 0x02 );
    41   */
    38 const TUint8 KDcsCharacterSet7Bit2( 0x00 );
       
    39 const TUint8 KDcsCharacterSet16Bit2( 0x01 );
       
    40 const TInt   KSatMaxUSSDString( 182 );
    42 const TInt   KSatMaxUSSDString( 182 );
    41 
    43 
    42 // USSD DCS coding.
    44 // USSD DCS coding.
    43 const TUint8 KSatDcs7Bit( 0x40 );
    45 const TUint8 KSatDcs7Bit( 0x40 );
    44 const TUint8 KSatDcs8Bit( 0x44 );
    46 const TUint8 KSatDcs8Bit( 0x44 );
   307 
   309 
   308         if ( dataValid )
   310         if ( dataValid )
   309             {
   311             {
   310             LOG( SIMPLE, "SENDUSSD:  dataValid true" )
   312             LOG( SIMPLE, "SENDUSSD:  dataValid true" )
   311             // Validate Data Coding Scheme.
   313             // Validate Data Coding Scheme.
   312             dataValid = DcsValid( iSendUssdData.iUssdString.iDcs );
   314             dataValid = iUtils->MultiModeApi().IsValidUssdDcs(
       
   315                 iSendUssdData.iUssdString.iDcs );
   313             if ( !dataValid )
   316             if ( !dataValid )
   314                 {
   317                 {
   315                 LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::CommandAllowed Dcs \
   318                 LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::CommandAllowed Dcs \
   316                 not acceptable" )
   319                 not acceptable" )
   317                 }
   320                 }
   562     iNotificationData(),
   565     iNotificationData(),
   563     iNotificationDataPckg( iNotificationData ),
   566     iNotificationDataPckg( iNotificationData ),
   564     iNotificationRsp(),
   567     iNotificationRsp(),
   565     iNotificationRspPckg( iNotificationRsp ),
   568     iNotificationRspPckg( iNotificationRsp ),
   566     // To be removed when icons are allowed in this command
   569     // To be removed when icons are allowed in this command
   567     iIconCommand( EFalse )
   570     iIconCommand( EFalse ),
       
   571     iIsSatDisplayUssdResult( EFalse )
   568     {
   572     {
   569     LOG( SIMPLE,
   573     LOG( SIMPLE,
   570         "SENDUSSD: CSendUssdHandler::CSendUssdHandler calling - exiting" )
   574         "SENDUSSD: CSendUssdHandler::CSendUssdHandler calling" )
       
   575     TRAPD( result, iIsSatDisplayUssdResult = SatDisplayUssdResultL(); )
       
   576     LOG2( NORMAL, "SENDUSSD: CSendUssdHandler::CSendUssdHandler \
       
   577             get CRepository key failed result: %d", result )
       
   578 
       
   579     LOG( SIMPLE,
       
   580         "SENDUSSD: CSendUssdHandler::CSendUssdHandler exiting" )
   571     }
   581     }
   572 
   582 
   573 
   583 
   574 // -----------------------------------------------------------------------------
   584 // -----------------------------------------------------------------------------
   575 // Handles the Ussd string sending
   585 // Handles the Ussd string sending
   592         receiveMessage,
   602         receiveMessage,
   593         sendCompletedFirst,
   603         sendCompletedFirst,
   594         iSendUssdRsp.iUssdString.iDcs ) );
   604         iSendUssdRsp.iUssdString.iDcs ) );
   595 
   605 
   596     iSendUssdRsp.iUssdString.iUssdString.Copy( receiveMessage );
   606     iSendUssdRsp.iUssdString.iUssdString.Copy( receiveMessage );
       
   607 
       
   608     if ( ( RSat::EAlphaIdProvided != iSendUssdData.iAlphaId.iStatus )
       
   609         && iIsSatDisplayUssdResult )
       
   610         {
       
   611         // if no Alpha ID provided, show the text note.
       
   612         LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SendUssdString Show Note" )
       
   613         TRAP_IGNORE(
       
   614         ShowUssdResponseNoteL( iSendUssdRsp.iUssdString.iUssdString ) );
       
   615         }
   597 
   616 
   598     HandleSendUssdResult( error );
   617     HandleSendUssdResult( error );
   599 
   618 
   600     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SendUssdString exiting" )
   619     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SendUssdString exiting" )
   601     }
   620     }
   666     ConvertReceivedDcs( aReceivedDcs );
   685     ConvertReceivedDcs( aReceivedDcs );
   667 
   686 
   668     User::LeaveIfError( error );
   687     User::LeaveIfError( error );
   669 
   688 
   670     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SendUssdStringL exiting" )
   689     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SendUssdStringL exiting" )
       
   690     }
       
   691     
       
   692 // -----------------------------------------------------------------------------
       
   693 // Show the ussd response note.
       
   694 // -----------------------------------------------------------------------------
       
   695 //
       
   696 void CSendUssdHandler::ShowUssdResponseNoteL( const TDesC& aText )
       
   697     {
       
   698     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::ShowUssdResponseNoteL calling" )
       
   699     CHbDeviceMessageBoxSymbian::InformationL( aText );
       
   700 
       
   701     CHbDeviceMessageBoxSymbian* messageNote = CHbDeviceMessageBoxSymbian::NewL();
       
   702     CleanupStack::PushL( messageNote );
       
   703     messageNote->SetButton( CHbDeviceMessageBoxSymbian::ERejectButton, EFalse );
       
   704     CleanupStack::PopAndDestroy(); // messageNote
       
   705 
       
   706     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::ShowUssdResponseNoteL exiting" )
   671     }
   707     }
   672     
   708     
   673 // -----------------------------------------------------------------------------
   709 // -----------------------------------------------------------------------------
   674 // Handles the result of Ussd sending.
   710 // Handles the result of Ussd sending.
   675 // -----------------------------------------------------------------------------
   711 // -----------------------------------------------------------------------------
   900         }
   936         }
   901 
   937 
   902     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SendTerminalResponse exiting" )
   938     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SendTerminalResponse exiting" )
   903     }
   939     }
   904 
   940 
   905 // -----------------------------------------------------------------------------
       
   906 // Check validity of a given Data Coding Cheme (Dcs).
       
   907 // -----------------------------------------------------------------------------
       
   908 //
       
   909 TBool CSendUssdHandler::DcsValid( const TUint8 aDcs ) const
       
   910     {
       
   911     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::DcsValid calling" )
       
   912 
       
   913     TBool isDcsValid( EFalse );
       
   914                                                                //      76543210
       
   915     TUint8 codingGroup  = ( aDcs & 0xF0 ) >> KHighNibbleShift; // bits XXXX____
       
   916     TUint8 characterSet = ( aDcs & 0x0C ) >> KQuarterShift;    // bits ____XX__
       
   917     TUint8 lowQuartet   = ( aDcs & 0x0F );                     // bits ____XXXX
       
   918     LOG2( SIMPLE, 
       
   919     "SENDUSSD: CSendUssdHandler::DcsValid codingGroup: %x", codingGroup)
       
   920     switch ( codingGroup )
       
   921         {
       
   922         case 0x00:
       
   923         case 0x02:
       
   924         case 0x03:
       
   925         case 0x0F:
       
   926             {
       
   927             isDcsValid = ETrue;
       
   928             break;
       
   929             }
       
   930 
       
   931         case 0x01:
       
   932             {
       
   933             if ( ( KDcsCharacterSet7Bit2 == lowQuartet ) ||
       
   934                  ( KDcsCharacterSet16Bit2 == lowQuartet ) )
       
   935                 {
       
   936                 LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::DcsValid valid" )
       
   937                 isDcsValid = ETrue;
       
   938                 }
       
   939             break;
       
   940             }
       
   941 
       
   942         case 0x04:
       
   943         case 0x05:
       
   944         case 0x06:
       
   945         case 0x07:
       
   946         case 0x09:
       
   947             {
       
   948             if ( ( KDcsCharacterSet7Bit == characterSet ) ||
       
   949                  ( KDcsCharacterSet8Bit == characterSet ) ||
       
   950                  ( KDcsCharacterSet16Bit == characterSet ) )
       
   951                 {
       
   952                 LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::DcsValid isDcsValid" )
       
   953                 isDcsValid = ETrue;
       
   954                 }
       
   955             break;
       
   956             }
       
   957 
       
   958         default:
       
   959             {
       
   960             LOG2( SIMPLE, "SENDUSSD:   Reserved Dcs found: %x", aDcs )
       
   961             }
       
   962         }
       
   963 
       
   964     LOG2(
       
   965         SIMPLE,
       
   966         "SENDUSSD: CSendUssdHandler::DcsValid exiting, valid = %d",
       
   967         isDcsValid )
       
   968     return isDcsValid;
       
   969     }
       
   970 
   941 
   971 // -----------------------------------------------------------------------------
   942 // -----------------------------------------------------------------------------
   972 // USSD sending should be transparent if alpha identifier is provided but it's
   943 // USSD sending should be transparent if alpha identifier is provided but it's
   973 // length is 0. Also user query setting is not on.
   944 // length is 0. Also user query setting is not on.
   974 // -----------------------------------------------------------------------------
   945 // -----------------------------------------------------------------------------
  1000     LOG2( SIMPLE, 
   971     LOG2( SIMPLE, 
  1001     "SENDUSSD: CSendUssdHandler::TransparentUssdSending exiting: %i", result )
   972     "SENDUSSD: CSendUssdHandler::TransparentUssdSending exiting: %i", result )
  1002     return result;
   973     return result;
  1003     }
   974     }
  1004 
   975 
       
   976 // -----------------------------------------------------------------------------
       
   977 // Check whether the ussd sending result is displayed
       
   978 // -----------------------------------------------------------------------------
       
   979 //
       
   980 TInt CSendUssdHandler::SatDisplayUssdResultL()
       
   981     {
       
   982     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SatDisplayUssdResultL calling" )
       
   983     TInt result( KErrNone );
       
   984     TInt ussdDisplayResult( KErrNone );
       
   985 
       
   986     CRepository* repository = NULL;
       
   987     repository = CRepository::NewL( KCRUidSatServer );
       
   988     
       
   989     if ( repository )
       
   990         {
       
   991         result = repository->Get( KSatDisplayUssdResult, ussdDisplayResult );
       
   992         LOG3( NORMAL,
       
   993         "SENDUSSD: CSendUssdHandler::CSendUssdHandler \
       
   994         get CRepository key DisplayResult: %d, result: %d ", 
       
   995         ussdDisplayResult, result )
       
   996         }
       
   997 
       
   998     delete repository;
       
   999     repository = NULL;
       
  1000     
       
  1001     LOG( SIMPLE, "SENDUSSD: CSendUssdHandler::SatDisplayUssdResultL exiting" )
       
  1002     return ussdDisplayResult;
       
  1003     }
       
  1004