adaptationlayer/tsy/simatktsy_dll/src/satcc.cpp
changeset 8 6295dc2169f3
parent 7 fa67e03b87df
child 9 8486d82aef45
--- a/adaptationlayer/tsy/simatktsy_dll/src/satcc.cpp	Wed Feb 17 13:58:55 2010 +0200
+++ b/adaptationlayer/tsy/simatktsy_dll/src/satcc.cpp	Wed Apr 21 14:29:55 2010 +0300
@@ -66,6 +66,7 @@
 
 const TUint8 KMSBMask = 0x80;
 const TUint8 KSw1Sw2Unknown = 0;
+const TUint8 KValidTonNpi   = 0x3F;
 
 
 // ==================== MEMBER FUNCTIONS ====================================
@@ -1150,6 +1151,8 @@
 
     TBuf8<KMaximumCcBufferSize> isiMessage;
     TInt ret( KErrNotFound );
+    TBool checkInfoNeeded( EFalse );
+    TUint8 checkInfoParams( 0 );
     CBerTlv response;
     response.SetData( aApduData );
     // Set initial cc result, e.g. the SIM has responded with sw1/sw2 90 00
@@ -1227,6 +1230,8 @@
                 isiMessage.Append( CALL_MODEM_RESOURCE_ALLOWED );
                 isiMessage.Append( KPadding );
                 internalCcResult = KModified;
+                checkInfoNeeded = ETrue;
+                checkInfoParams += CALL_MODEM_CHK_DISABLE_FDN;
                 }
             break;
             }
@@ -1296,7 +1301,21 @@
         if ( KErrNone == ret  )
             {
             // CALL_MODEM_ADDRESS_TYPE, mask MSB off
-            isiMessage.Append( addressTlv.GetValue()[ 0 ] ^KMSBMask );
+            TUint8 tonNpi( addressTlv.GetValue()[ 0 ] ^ KMSBMask );
+
+            // check if valid TON/NPI
+            if( KValidTonNpi >= tonNpi )
+                {
+                isiMessage.Append( tonNpi );
+                }
+            else
+                {
+                // use default TON/NPI in reserved cases
+                isiMessage.Append( 
+                    CALL_MODEM_NBR_TYPE_UNKNOWN | 
+                    CALL_MODEM_NBR_PLAN_ISDN_TELEPHONY );
+                }
+
             isiMessage.Append( KPadding );
             isiMessage.Append( KPadding );
 
@@ -1305,6 +1324,18 @@
             TSatUtility::BCDToAscii( addressTlv.GetValue().Mid( 1 ),
                 asciiAddress );
 
+            // let's check is new number "112". This because of if number 
+            // is "112" emergency call is needed to establish. otherwise 
+            // normal call needs to be established, even new number is found 
+            // from EFecc. So if number is not "112" we need to add subblock 
+            // CALL_MODEM_CHECK_INFO with CALL_MODEM_CHK_DISABLE_EMERG
+            _LIT8(KEccNbr, "112");
+            if( 0 != asciiAddress.Compare( KEccNbr ) )
+                {
+                checkInfoNeeded = ETrue;
+                checkInfoParams += CALL_MODEM_CHK_DISABLE_EMERG;
+                }
+
             //add the number string as unicode.
             TBuf16<KCallServerMaxAddressLenght> unicodeNumber;
             TSatUtility::ConvertSms7ToUnicode16( unicodeNumber, asciiAddress );
@@ -1350,9 +1381,35 @@
     // should be ignored in Call Modem Server
     if ( aTcc.iCheckInfo.Length() )
         {
-        isiMessage.Append( aTcc.iCheckInfo );
         sbcount++;
+        if( checkInfoNeeded )
+            {
+            TUint8 oldInfo( aTcc.iCheckInfo[CALL_MODEM_SB_CHECK_INFO_OFFSET_CHECKINFO] );
+            TUint8 newInfo( checkInfoParams | oldInfo );
+            TIsiSubBlock checkInfo(
+                isiMessage,
+                CALL_MODEM_SB_CHECK_INFO,
+                EIsiSubBlockTypeId8Len8 );
+            isiMessage.Append( newInfo );
+            checkInfo.CompleteSubBlock();
+            }
+        else
+            {
+            isiMessage.Append( aTcc.iCheckInfo );
+            }
         }
+    else if( checkInfoNeeded )
+        {
+        sbcount++;
+        TIsiSubBlock checkInfo(
+            isiMessage,
+            CALL_MODEM_SB_CHECK_INFO,
+            EIsiSubBlockTypeId8Len8 );
+        isiMessage.Append( checkInfoParams );
+        checkInfo.CompleteSubBlock();
+        }
+    // no else
+
     TBuf8<1> numOfSubblocks;
     numOfSubblocks.Append( sbcount);
     isiMessage.Insert( 1, numOfSubblocks );