phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdManager.cpp
branchRCL_3
changeset 41 594d59766373
parent 22 71268bfa7aea
child 43 7d48bed6ce0c
equal deleted inserted replaced
40:c58fd5f0c240 41:594d59766373
    54 #include <NcnListInternalPSKeys.h>
    54 #include <NcnListInternalPSKeys.h>
    55 #include <centralrepository.h>
    55 #include <centralrepository.h>
    56 #include <telservicesinternalcrkeys.h>
    56 #include <telservicesinternalcrkeys.h>
    57 #include <coreapplicationuisdomainpskeys.h>
    57 #include <coreapplicationuisdomainpskeys.h>
    58 
    58 
       
    59 //RM-RIM 417-66528
       
    60 #include <CUssdExtensionInterface.h>
    59 
    61 
    60 // CONSTANTS
    62 // CONSTANTS
    61 const TInt KPhSrvDefaultValue = 0x00000000;
    63 const TInt KPhSrvDefaultValue = 0x00000000;
    62 // const TInt KPhSrvUssdNoTone = 0; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
    64 // const TInt KPhSrvUssdNoTone = 0; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
    63 const TInt KPhSrvUssdTone   = 2; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
    65 const TInt KPhSrvUssdTone   = 2; // See SharedDataKeysVariant.h or NcnListInternalPSKeys.h
   434     delete iMeQuHeaderText;
   436     delete iMeQuHeaderText;
   435     iMeQuHeaderText = NULL;
   437     iMeQuHeaderText = NULL;
   436     
   438     
   437     delete iMoAckCallback;
   439     delete iMoAckCallback;
   438 
   440 
       
   441     // RM-RIM 417-66528
       
   442     delete iUssdExtnInterface;
       
   443     iUssdExtnInterface = NULL;
       
   444         
   439     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );       // debug print
   445     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );       // debug print
   440     }
   446     }
   441 
   447 
   442 
   448 
   443 // -----------------------------------------------------------------------------
   449 // -----------------------------------------------------------------------------
   490     CleanupStack::Pop( iMeQuHeaderText );
   496     CleanupStack::Pop( iMeQuHeaderText );
   491 
   497 
   492 	_DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
   498 	_DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
   493     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
   499     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
   494     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
   500     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
       
   501     
       
   502     // RM-RIM 417-66528
       
   503     TRAP_IGNORE(iUssdExtnInterface = CUssdExtensionInterface::NewL());
       
   504     _DPRINT( 4, "PhSrv.ConstructL.iUssdExtnInterface Created");
   495     _DPRINT( 4, "PhSrv.ConstructL.End" );       // debug print
   505     _DPRINT( 4, "PhSrv.ConstructL.End" );       // debug print
   496     }
   506     }
   497 
   507 
   498 
   508 
   499 // -----------------------------------------------------------------------------
   509 // -----------------------------------------------------------------------------
   547     RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute,
   557     RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttribute,
   548     MPhSrvUssdMessageSentObserver& aObserver )
   558     MPhSrvUssdMessageSentObserver& aObserver )
   549     {
   559     {
   550     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );           // debug print
   560     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );           // debug print
   551     _DPRINT_FLAGS();
   561     _DPRINT_FLAGS();
       
   562     
       
   563     //417-66528
       
   564     if (iUssdExtnInterface)
       
   565         {
       
   566         if(!iUssdExtnInterface->ValidateUssdMsgSending(aMsgData,aMsgAttribute))
       
   567             {
       
   568             // invalid attempt to send USSD message. Show the note 
       
   569             User::Leave( KErrAccessDenied );
       
   570             }
       
   571         }
   552     
   572     
   553     if ( iObserver && iNetworkReleased ) 
   573     if ( iObserver && iNetworkReleased ) 
   554         {
   574         {
   555         // Network has been released but the previous send request is still alive.
   575         // Network has been released but the previous send request is still alive.
   556         // Cancel the pervious send operation, complete the old request with error
   576         // Cancel the pervious send operation, complete the old request with error
   808     DecodeL(aMsgData, iDecodedMessage, dcs);
   828     DecodeL(aMsgData, iDecodedMessage, dcs);
   809     if(iDecodedMessage.Length() > 0)
   829     if(iDecodedMessage.Length() > 0)
   810         {
   830         {
   811         iReceivedMessage = iDecodedMessage;
   831         iReceivedMessage = iDecodedMessage;
   812         }
   832         }
       
   833     // 4. Invoke UssdExtensionPlugin
       
   834     // 417-66528
       
   835     TBool isResponseValidated = EFalse;
       
   836     if (iUssdExtnInterface)
       
   837         {
       
   838         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.InvokeExtension" );
       
   839         isResponseValidated = iUssdExtnInterface->ValidateUssdResponse(aMsgData);
       
   840         }
   813     // 5. Show note.
   841     // 5. Show note.
   814     // debug print
   842     // debug print
   815     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Note" );
   843     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Note" );
   816     if ( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType ) ||
   844     if ( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType ) ||
   817             aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   845             aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   822             _DPRINT( 4,
   850             _DPRINT( 4,
   823                 "PhSrv.UssdHandleReceivedEventL.SAtReturn" );
   851                 "PhSrv.UssdHandleReceivedEventL.SAtReturn" );
   824             return;
   852             return;
   825             }
   853             }
   826         }
   854         }
   827 
   855     //6. Check if the response is valid for the extension
       
   856     //RM-RIM 417-66528
       
   857     if (iUssdExtnInterface && isResponseValidated)
       
   858         PorcessReceivedMessageInExtesnionL(aMsgData, aMsgAttributes);
       
   859     else
       
   860         ProcessReceivedMessageL(aMsgData, aMsgAttributes);
       
   861         
       
   862     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Editor" );
       
   863     if (aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest
       
   864             && UssdAppTaskExistsL())
       
   865         {
       
   866         iEmptyEditor = ETrue;
       
   867         } _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.End" );
       
   868     }
       
   869 // -----------------------------------------------------------------------------
       
   870 // CPhSrvUssdManager::ProcessReceivedMessageL
       
   871 //
       
   872 //
       
   873 //
       
   874 // -----------------------------------------------------------------------------
       
   875 //
       
   876 void CPhSrvUssdManager::ProcessReceivedMessageL(const TDes8& /*aMsgData*/,
       
   877         const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
       
   878     {
   828     // empty string is handled as ok message
   879     // empty string is handled as ok message
   829     if ( !iDecodedMessage.Length() )
   880     if (!iDecodedMessage.Length())
   830         {
   881         {
   831         TurnLightsOn(); //Ensure lights on
   882         TurnLightsOn(); //Ensure lights on
       
   883 
   832         // debug print
   884         // debug print
   833         _DPRINT( 4,
   885         _DPRINT( 4,
   834             "PhSrv.UssdHandleReceivedEventL.EmptyString" );
   886                 "PhSrv.UssdHandleReceivedEventL.EmptyString" );
   835         
       
   836         ShowDoneNoteL();
   887         ShowDoneNoteL();
   837 
       
   838         // debug print
   888         // debug print
   839         _DPRINT( 4,
   889         _DPRINT( 4,
   840             "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
   890                 "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
   841         }
   891         }
   842     else
   892     else
   843         {
   893         {
   844        	_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
   894         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
   845         iNotifyMessage = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTNotify );
   895         iNotifyMessage = (aMsgAttributes.iType
   846         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
   896                 == RMobileUssdMessaging::EUssdMTNotify);
       
   897         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage ); 
   847         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
   898         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
   848         iMsgTypeReply = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTReply );
   899         iMsgTypeReply = (aMsgAttributes.iType
       
   900                 == RMobileUssdMessaging::EUssdMTReply);
   849         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
   901         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
   850         
   902 
   851         if ( iNotifyMessage ) 
   903         if (iNotifyMessage)
   852             {
   904             {
   853             // need to send an MO ack
   905             // need to send an MO ack
   854             iAcksToBeSent ++;
   906             iAcksToBeSent++;
   855             }
   907             }
   856         
   908 
   857         if ( iNotifyMessage || iMsgTypeReply )
   909         if (iNotifyMessage || iMsgTypeReply)
   858         	{
   910             {
   859         	//This is for reply message in notifyarray
   911             //This is for reply message in notifyarray
   860         	iNotifyMessage = ETrue;
   912             iNotifyMessage = ETrue;
   861         	_DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
   913             _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
   862 
   914 
   863 	        //Notify added to array
   915             //Notify added to array
   864         	iNotifyArray->AppendL( iReceivedMessage );
   916             iNotifyArray->AppendL(iReceivedMessage);
   865 
   917 
   866         	_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" );       // debug print
   918             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" ); // debug print
   867         	UpdateNotifyMessage();
   919             UpdateNotifyMessage();
   868 
   920 
   869         	if ( !iSendRelease && NotifyCount() <= 1 )
   921             if (!iSendRelease && NotifyCount() <= 1)
   870 				{
   922                 {
   871 				_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" );       // debug print
   923                 _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" ); // debug print
   872 				Cancel();
   924                 Cancel();
   873 				}
   925                 }
   874         	}
   926             }
   875         else
   927         else
   876        		{
   928             {
   877        		// New message deletes old message, i.e. Cancel existing query.
   929             // New message deletes old message, i.e. Cancel existing query.
   878        		Cancel();
   930             Cancel();
   879 			_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" );       // debug print
   931             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" ); // debug print
   880        		}
   932             }
   881 
   933         CreateGlobalMessageQueryL(aMsgAttributes);
   882         if ( !iGlobalMsgQuery )
   934         AsyncProcessMoAcks();
   883             {
   935         } 
   884             iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
   936     _DPRINT( 4, "PhSrv.ProcesdReceivedMessageL.End" );
   885             }
   937     }
   886 
   938 
   887         // Delay after message query so that application execution order will
   939 // -----------------------------------------------------------------------------
   888         // be correct.
   940 // CPhSrvUssdManager::PorcessReceivedMessageInExtesnionL
   889         iGlobalMsgQuery->SetExitDelay( KPhSrvUssdNoteExitPeriod );
   941 //
   890 
   942 //
   891         TInt softkeys = R_AVKON_SOFTKEYS_USSD_ANSWER_EXIT__ANSWER;
   943 //
   892         if( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType )
   944 // -----------------------------------------------------------------------------
   893              || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
   945 //
   894             {
   946 void CPhSrvUssdManager::PorcessReceivedMessageInExtesnionL(
   895             softkeys = R_AVKON_SOFTKEYS_EXIT;
   947         const TDes8& /*aMsgData*/,
   896             }
   948         const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
   897 
   949     {
   898         // Set timer that lauches Global MessageQuery after time interval.
   950     TInt errfromextension = KErrNone;
   899         iSoftkeys = softkeys;
   951     // empty string is handled as ok message
   900 
   952     if (!iDecodedMessage.Length())
       
   953         {
   901         // debug print
   954         // debug print
   902         _DPRINT( 4,
   955         _DPRINT( 4,
   903             "PhSrv.UssdHandleReceivedEventL.String.Middle" );
   956                 "PhSrv.UssdHandleReceivedEventL.EmptyString" );
   904 
   957         //RM-RIM 417-66528
   905         // Play the USSD tone if needed. Logically should be in RunL, but here
   958         TRAP_IGNORE(iUssdExtnInterface->ProcessReceivedUssdL(iDecodedMessage, errfromextension));
   906         // to give better balancing with voice and visible message.
   959         // debug print
   907         if ( IsTelephonyFeatureSupported( KTelSrvLVFlagUssdTone ) )
   960         _DPRINT( 4,
   908             {
   961                 "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
   909             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
   962         }
   910             PlayUssdTone();
   963     else
   911             }
   964         {
   912 
   965         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
   913         // Launch the new message query
   966         iNotifyMessage = (aMsgAttributes.iType
   914         if ( !IsActive() )
   967                 == RMobileUssdMessaging::EUssdMTNotify);
   915             {
   968         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage ); 
   916             iLaunchGMQ = ETrue;
   969         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
   917             iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
   970         iMsgTypeReply = (aMsgAttributes.iType
   918             SetActive();
   971                 == RMobileUssdMessaging::EUssdMTReply);
   919             }
   972         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
   920         AsyncProcessMoAcks();
   973 
   921         }
   974         if (iNotifyMessage)
   922     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Editor" );
   975             {
   923     if( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest && UssdAppTaskExistsL() )
   976             // need to send an MO ack
   924         {
   977             iAcksToBeSent++;
   925         iEmptyEditor = ETrue;
   978             }
   926         }
   979 
   927     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.End" );
   980         if (iNotifyMessage || iMsgTypeReply)
   928     }
   981             {
   929 
   982             //This is for reply message in notifyarray
       
   983             iNotifyMessage = ETrue;
       
   984             _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
       
   985             if (!iSendRelease && NotifyCount() <= 1)
       
   986                 {
       
   987                 _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" ); // debug print
       
   988                 Cancel();
       
   989                 }
       
   990             }
       
   991         else
       
   992             {
       
   993             // New message deletes old message, i.e. Cancel existing query.
       
   994             Cancel();
       
   995             _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" ); // debug print
       
   996             }
       
   997         TInt errfromextension = KErrNone;
       
   998         ProcessMoAcksL();
       
   999         iLaunchGMQ = EFalse;
       
  1000         TRAP_IGNORE(iUssdExtnInterface->ProcessReceivedUssdL(iDecodedMessage, errfromextension)); 
       
  1001         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Extn.ProcessReceivedUssdL.ErrCode", errfromextension);
       
  1002         }
       
  1003     }
   930 // -----------------------------------------------------------------------------
  1004 // -----------------------------------------------------------------------------
   931 // CPhSrvUssdManager::RestartReplyTimerL
  1005 // CPhSrvUssdManager::RestartReplyTimerL
   932 //
  1006 //
   933 //
  1007 //
   934 //
  1008 //
   994     if ( iUssdSendHandler && iSendingAck ) 
  1068     if ( iUssdSendHandler && iSendingAck ) 
   995         {
  1069         {
   996         // if we are sending ack, it can be canceled.
  1070         // if we are sending ack, it can be canceled.
   997         iUssdSendHandler->Cancel();
  1071         iUssdSendHandler->Cancel();
   998         }
  1072         }
   999     
  1073     //417-66528
       
  1074     //Notify Extension on NWRelease
       
  1075     if(iUssdExtnInterface)
       
  1076         {
       
  1077         iUssdExtnInterface->NotifyNWError(aError);
       
  1078         }
  1000     iSatCanceled = EFalse;
  1079     iSatCanceled = EFalse;
  1001     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.iSatCanceled.EFalse" );
  1080     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.iSatCanceled.EFalse" );
  1002     iShowDone = EFalse;
  1081     iShowDone = EFalse;
  1003     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Ending" );
  1082     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.Ending" );
  1004     _DPRINT_FLAGS();
  1083     _DPRINT_FLAGS();
  1339                 break;
  1418                 break;
  1340             }
  1419             }
  1341         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
  1420         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
  1342         }
  1421         }
  1343     }
  1422     }
  1344 
  1423 // RM-RIM 417-66528
       
  1424 // -----------------------------------------------------------------------------
       
  1425 // CPhSrvUssdManager::CreateGlobalMessageQueryL
       
  1426 // -----------------------------------------------------------------------------
       
  1427 //
       
  1428 void CPhSrvUssdManager::CreateGlobalMessageQueryL(
       
  1429         const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
       
  1430     {
       
  1431     if (!iGlobalMsgQuery)
       
  1432         {
       
  1433         iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
       
  1434         }
       
  1435 
       
  1436     // Delay after message query so that application execution order will
       
  1437     // be correct.
       
  1438     iGlobalMsgQuery->SetExitDelay(KPhSrvUssdNoteExitPeriod);
       
  1439 
       
  1440     TInt softkeys = R_AVKON_SOFTKEYS_USSD_ANSWER_EXIT__ANSWER;
       
  1441     if (!(aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType)
       
  1442             || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest)
       
  1443         {
       
  1444         softkeys = R_AVKON_SOFTKEYS_EXIT;
       
  1445         }
       
  1446 
       
  1447     // Set timer that lauches Global MessageQuery after time interval.
       
  1448     iSoftkeys = softkeys;
       
  1449 
       
  1450     // debug print
       
  1451     _DPRINT( 4,
       
  1452             "PhSrv.UssdHandleReceivedEventL.String.Middle" );
       
  1453 
       
  1454     // Play the USSD tone if needed. Logically should be in RunL, but here
       
  1455     // to give better balancing with voice and visible message.
       
  1456     if (IsTelephonyFeatureSupported(KTelSrvLVFlagUssdTone))
       
  1457         {
       
  1458         _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
       
  1459         PlayUssdTone();
       
  1460         }
       
  1461     // Launch the new message query
       
  1462     if (!IsActive())
       
  1463         {
       
  1464         iLaunchGMQ = ETrue;
       
  1465         iTimer.After(iStatus, KPhSrvUssdMessageQueryInterval);
       
  1466         SetActive();
       
  1467         }
       
  1468     }
  1345 // -----------------------------------------------------------------------------
  1469 // -----------------------------------------------------------------------------
  1346 // CPhSrvUssdManager::LaunchGlobalMessageQueryL
  1470 // CPhSrvUssdManager::LaunchGlobalMessageQueryL
  1347 // -----------------------------------------------------------------------------
  1471 // -----------------------------------------------------------------------------
  1348 //
  1472 //
  1349 void CPhSrvUssdManager::LaunchGlobalMessageQueryL()
  1473 void CPhSrvUssdManager::LaunchGlobalMessageQueryL()