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