phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdManager.cpp
branchRCL_3
changeset 18 594d59766373
parent 12 71268bfa7aea
child 19 7d48bed6ce0c
--- a/phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdManager.cpp	Thu Jul 15 19:16:18 2010 +0300
+++ b/phoneclientserver/phoneserver/Src/Ussd/CPhSrvUssdManager.cpp	Thu Aug 19 10:28:14 2010 +0300
@@ -56,6 +56,8 @@
 #include <telservicesinternalcrkeys.h>
 #include <coreapplicationuisdomainpskeys.h>
 
+//RM-RIM 417-66528
+#include <CUssdExtensionInterface.h>
 
 // CONSTANTS
 const TInt KPhSrvDefaultValue = 0x00000000;
@@ -436,6 +438,10 @@
     
     delete iMoAckCallback;
 
+    // RM-RIM 417-66528
+    delete iUssdExtnInterface;
+    iUssdExtnInterface = NULL;
+        
     _DPRINT( 4, "PhSrv.~CPhSrvUssdManager.end" );       // debug print
     }
 
@@ -492,6 +498,10 @@
 	_DDPRINT( 4, "PhSrv.ConstructL.iSatCanceled ", iSatCanceled );
     _DDPRINT( 4, "PhSrv.ConstructL.iShowDone ", iShowDone );
     iNotifyArray = new( ELeave ) CDesCArrayFlat( KPhrUssdNotifyArraySize );
+    
+    // RM-RIM 417-66528
+    TRAP_IGNORE(iUssdExtnInterface = CUssdExtensionInterface::NewL());
+    _DPRINT( 4, "PhSrv.ConstructL.iUssdExtnInterface Created");
     _DPRINT( 4, "PhSrv.ConstructL.End" );       // debug print
     }
 
@@ -550,6 +560,16 @@
     _DPRINT( 4, "PhSrv.SendUssdL.Start ######" );           // debug print
     _DPRINT_FLAGS();
     
+    //417-66528
+    if (iUssdExtnInterface)
+        {
+        if(!iUssdExtnInterface->ValidateUssdMsgSending(aMsgData,aMsgAttribute))
+            {
+            // invalid attempt to send USSD message. Show the note 
+            User::Leave( KErrAccessDenied );
+            }
+        }
+    
     if ( iObserver && iNetworkReleased ) 
         {
         // Network has been released but the previous send request is still alive.
@@ -810,6 +830,14 @@
         {
         iReceivedMessage = iDecodedMessage;
         }
+    // 4. Invoke UssdExtensionPlugin
+    // 417-66528
+    TBool isResponseValidated = EFalse;
+    if (iUssdExtnInterface)
+        {
+        _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.InvokeExtension" );
+        isResponseValidated = iUssdExtnInterface->ValidateUssdResponse(aMsgData);
+        }
     // 5. Show note.
     // debug print
     _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Note" );
@@ -824,109 +852,155 @@
             return;
             }
         }
-
+    //6. Check if the response is valid for the extension
+    //RM-RIM 417-66528
+    if (iUssdExtnInterface && isResponseValidated)
+        PorcessReceivedMessageInExtesnionL(aMsgData, aMsgAttributes);
+    else
+        ProcessReceivedMessageL(aMsgData, aMsgAttributes);
+        
+    _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Editor" );
+    if (aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest
+            && UssdAppTaskExistsL())
+        {
+        iEmptyEditor = ETrue;
+        } _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.End" );
+    }
+// -----------------------------------------------------------------------------
+// CPhSrvUssdManager::ProcessReceivedMessageL
+//
+//
+//
+// -----------------------------------------------------------------------------
+//
+void CPhSrvUssdManager::ProcessReceivedMessageL(const TDes8& /*aMsgData*/,
+        const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
+    {
     // empty string is handled as ok message
-    if ( !iDecodedMessage.Length() )
+    if (!iDecodedMessage.Length())
         {
         TurnLightsOn(); //Ensure lights on
-        // debug print
-        _DPRINT( 4,
-            "PhSrv.UssdHandleReceivedEventL.EmptyString" );
-        
-        ShowDoneNoteL();
 
         // debug print
         _DPRINT( 4,
-            "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
+                "PhSrv.UssdHandleReceivedEventL.EmptyString" );
+        ShowDoneNoteL();
+        // debug print
+        _DPRINT( 4,
+                "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
         }
     else
         {
-       	_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
-        iNotifyMessage = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTNotify );
-        _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
+        _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
+        iNotifyMessage = (aMsgAttributes.iType
+                == RMobileUssdMessaging::EUssdMTNotify);
+        _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage ); 
         _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
-        iMsgTypeReply = ( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTReply );
+        iMsgTypeReply = (aMsgAttributes.iType
+                == RMobileUssdMessaging::EUssdMTReply);
         _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
-        
-        if ( iNotifyMessage ) 
+
+        if (iNotifyMessage)
             {
             // need to send an MO ack
-            iAcksToBeSent ++;
-            }
-        
-        if ( iNotifyMessage || iMsgTypeReply )
-        	{
-        	//This is for reply message in notifyarray
-        	iNotifyMessage = ETrue;
-        	_DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
-
-	        //Notify added to array
-        	iNotifyArray->AppendL( iReceivedMessage );
-
-        	_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" );       // debug print
-        	UpdateNotifyMessage();
-
-        	if ( !iSendRelease && NotifyCount() <= 1 )
-				{
-				_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" );       // debug print
-				Cancel();
-				}
-        	}
-        else
-       		{
-       		// New message deletes old message, i.e. Cancel existing query.
-       		Cancel();
-			_DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" );       // debug print
-       		}
-
-        if ( !iGlobalMsgQuery )
-            {
-            iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
+            iAcksToBeSent++;
             }
 
-        // Delay after message query so that application execution order will
-        // be correct.
-        iGlobalMsgQuery->SetExitDelay( KPhSrvUssdNoteExitPeriod );
+        if (iNotifyMessage || iMsgTypeReply)
+            {
+            //This is for reply message in notifyarray
+            iNotifyMessage = ETrue;
+            _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
+
+            //Notify added to array
+            iNotifyArray->AppendL(iReceivedMessage);
+
+            _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.AppendL" ); // debug print
+            UpdateNotifyMessage();
 
-        TInt softkeys = R_AVKON_SOFTKEYS_USSD_ANSWER_EXIT__ANSWER;
-        if( !( aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType )
-             || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest )
+            if (!iSendRelease && NotifyCount() <= 1)
+                {
+                _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" ); // debug print
+                Cancel();
+                }
+            }
+        else
             {
-            softkeys = R_AVKON_SOFTKEYS_EXIT;
+            // New message deletes old message, i.e. Cancel existing query.
+            Cancel();
+            _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" ); // debug print
             }
+        CreateGlobalMessageQueryL(aMsgAttributes);
+        AsyncProcessMoAcks();
+        } 
+    _DPRINT( 4, "PhSrv.ProcesdReceivedMessageL.End" );
+    }
 
-        // Set timer that lauches Global MessageQuery after time interval.
-        iSoftkeys = softkeys;
-
+// -----------------------------------------------------------------------------
+// CPhSrvUssdManager::PorcessReceivedMessageInExtesnionL
+//
+//
+//
+// -----------------------------------------------------------------------------
+//
+void CPhSrvUssdManager::PorcessReceivedMessageInExtesnionL(
+        const TDes8& /*aMsgData*/,
+        const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
+    {
+    TInt errfromextension = KErrNone;
+    // empty string is handled as ok message
+    if (!iDecodedMessage.Length())
+        {
         // debug print
         _DPRINT( 4,
-            "PhSrv.UssdHandleReceivedEventL.String.Middle" );
+                "PhSrv.UssdHandleReceivedEventL.EmptyString" );
+        //RM-RIM 417-66528
+        TRAP_IGNORE(iUssdExtnInterface->ProcessReceivedUssdL(iDecodedMessage, errfromextension));
+        // debug print
+        _DPRINT( 4,
+                "PhSrv.UssdHandleReceivedEventL.EmptyString.OK" );
+        }
+    else
+        {
+        _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.String" );
+        iNotifyMessage = (aMsgAttributes.iType
+                == RMobileUssdMessaging::EUssdMTNotify);
+        _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage ); 
+        _DDPRINT( 4, "PhSrv.UssdNOHREventL.iNotifyMessage: ", iNotifyMessage );
+        iMsgTypeReply = (aMsgAttributes.iType
+                == RMobileUssdMessaging::EUssdMTReply);
+        _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iMsgTypeReply: ", iMsgTypeReply );
 
-        // Play the USSD tone if needed. Logically should be in RunL, but here
-        // to give better balancing with voice and visible message.
-        if ( IsTelephonyFeatureSupported( KTelSrvLVFlagUssdTone ) )
+        if (iNotifyMessage)
             {
-            _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
-            PlayUssdTone();
+            // need to send an MO ack
+            iAcksToBeSent++;
             }
 
-        // Launch the new message query
-        if ( !IsActive() )
+        if (iNotifyMessage || iMsgTypeReply)
             {
-            iLaunchGMQ = ETrue;
-            iTimer.After( iStatus , KPhSrvUssdMessageQueryInterval );
-            SetActive();
+            //This is for reply message in notifyarray
+            iNotifyMessage = ETrue;
+            _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.iNotifyMessage: ", iNotifyMessage );
+            if (!iSendRelease && NotifyCount() <= 1)
+                {
+                _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.!SendRelease.Cancel" ); // debug print
+                Cancel();
+                }
             }
-        AsyncProcessMoAcks();
+        else
+            {
+            // New message deletes old message, i.e. Cancel existing query.
+            Cancel();
+            _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.NewAnswerable" ); // debug print
+            }
+        TInt errfromextension = KErrNone;
+        ProcessMoAcksL();
+        iLaunchGMQ = EFalse;
+        TRAP_IGNORE(iUssdExtnInterface->ProcessReceivedUssdL(iDecodedMessage, errfromextension)); 
+        _DDPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Extn.ProcessReceivedUssdL.ErrCode", errfromextension);
         }
-    _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.Editor" );
-    if( aMsgAttributes.iType == RMobileUssdMessaging::EUssdMTRequest && UssdAppTaskExistsL() )
-        {
-        iEmptyEditor = ETrue;
-        }
-    _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.End" );
     }
-
 // -----------------------------------------------------------------------------
 // CPhSrvUssdManager::RestartReplyTimerL
 //
@@ -996,7 +1070,12 @@
         // if we are sending ack, it can be canceled.
         iUssdSendHandler->Cancel();
         }
-    
+    //417-66528
+    //Notify Extension on NWRelease
+    if(iUssdExtnInterface)
+        {
+        iUssdExtnInterface->NotifyNWError(aError);
+        }
     iSatCanceled = EFalse;
     _DPRINT( 4, "PhSrv.UssdNetworkObserverHandleNotifyNWReleaseL.iSatCanceled.EFalse" );
     iShowDone = EFalse;
@@ -1341,7 +1420,52 @@
         _DPRINT( 4, "PhSrv.RunL.End" );     // debug print
         }
     }
+// RM-RIM 417-66528
+// -----------------------------------------------------------------------------
+// CPhSrvUssdManager::CreateGlobalMessageQueryL
+// -----------------------------------------------------------------------------
+//
+void CPhSrvUssdManager::CreateGlobalMessageQueryL(
+        const RMobileUssdMessaging::TMobileUssdAttributesV1& aMsgAttributes)
+    {
+    if (!iGlobalMsgQuery)
+        {
+        iGlobalMsgQuery = CAknGlobalMsgQuery::NewL();
+        }
 
+    // Delay after message query so that application execution order will
+    // be correct.
+    iGlobalMsgQuery->SetExitDelay(KPhSrvUssdNoteExitPeriod);
+
+    TInt softkeys = R_AVKON_SOFTKEYS_USSD_ANSWER_EXIT__ANSWER;
+    if (!(aMsgAttributes.iFlags & RMobileUssdMessaging::KUssdMessageType)
+            || aMsgAttributes.iType != RMobileUssdMessaging::EUssdMTRequest)
+        {
+        softkeys = R_AVKON_SOFTKEYS_EXIT;
+        }
+
+    // Set timer that lauches Global MessageQuery after time interval.
+    iSoftkeys = softkeys;
+
+    // debug print
+    _DPRINT( 4,
+            "PhSrv.UssdHandleReceivedEventL.String.Middle" );
+
+    // Play the USSD tone if needed. Logically should be in RunL, but here
+    // to give better balancing with voice and visible message.
+    if (IsTelephonyFeatureSupported(KTelSrvLVFlagUssdTone))
+        {
+        _DPRINT( 4, "PhSrv.UssdHandleReceivedEventL.PlayTone" );
+        PlayUssdTone();
+        }
+    // Launch the new message query
+    if (!IsActive())
+        {
+        iLaunchGMQ = ETrue;
+        iTimer.After(iStatus, KPhSrvUssdMessageQueryInterval);
+        SetActive();
+        }
+    }
 // -----------------------------------------------------------------------------
 // CPhSrvUssdManager::LaunchGlobalMessageQueryL
 // -----------------------------------------------------------------------------