phoneengine/callhandling/src/cpecallhandling.cpp
changeset 1 838b0a10d15b
parent 0 5f000ab63145
child 9 8871b09be73b
child 21 92ab7f8d0eab
--- a/phoneengine/callhandling/src/cpecallhandling.cpp	Mon Jan 18 20:18:27 2010 +0200
+++ b/phoneengine/callhandling/src/cpecallhandling.cpp	Tue Jan 26 11:57:27 2010 +0200
@@ -29,6 +29,7 @@
 #include    "mpecallhandling.h"
 #include    "cpecceobserver.h"
 #include    "cpesystemcallstate.h"
+#include    "tpematcher.h"
 
 #include    <gsmerror.h>
 #include    <mpedatastore.h>
@@ -39,6 +40,8 @@
 #include    <mccecall.h>
 #include    <PsetSAObserver.h>
 #include    <cccecallparameters.h>
+#include    <centralrepository.h>
+#include    <telconfigcrkeys.h>
 
 // EXTERNAL DATA STRUCTURES
 // None
@@ -47,7 +50,7 @@
 // None
 
 // CONSTANTS
-// None
+const TInt KPEMatchDefault = 7;
 
 // MACROS
 // None
@@ -92,6 +95,7 @@
     {  
     TEFLOGSTRING( KTAOBJECT, "CALL CPECallHandling::~CPECallHandling() start");
     
+    delete iRepository;
     delete iSystemCallState;
     delete iDtmfHandling;
     
@@ -164,6 +168,8 @@
     
     iSystemCallState = CPESystemCallState::NewL( *iCallArrayOwner, *iModel.DataStore() );
     
+    iRepository = CRepository::NewL( KCRUidTelConfiguration );
+    
     TEFLOGSTRING( KTAOBJECT, "CALL CPECallHandling::BaseConstructL() complete");
     }
 
@@ -442,7 +448,8 @@
             
             if( connectedCall )
                 {
-                CCPCall::TCallType callType = connectedCall->Call().Parameters().CallType();
+                MCCECall& call = connectedCall->Call();
+                CCPCall::TCallType callType = call.Parameters().CallType();
                 
                 if ( callType == CCPCall::ECallTypePS ) 
                     {
@@ -458,14 +465,20 @@
                         "CALL CPECallHandling::SendMessage -> EPEMessageRemotePartyInfoChanged->update call type to CS");
                     iCallOpenParams->SetCallType( CCPCall::ECallTypeCSVoice );
                     iModel.DataStore()->SetServiceIdCommand( 1 );
-                    iModel.DataStore()->SetCallType( EPECallTypeCSVoice, aCallId );    
+                    iModel.DataStore()->SetCallType( EPECallTypeCSVoice, aCallId );  
+                    SetColpNumber( aCallId, call );
                     }
+                
+                iModel.DataStore()->SetRemotePartyName( call.RemotePartyName(), aCallId );                
+                iModel.DataStore()->SetRemotePhoneNumber( call.RemoteParty(), aCallId );
+                iModel.DataStore()->SetCallIndex(call.CallIndex(), aCallId );
                 }
+            break;
             }
-       // Flow throught
-            
+                   
         case MEngineMonitor::EPEMessageIncoming:
             {
+            TEFLOGSTRING( KTAMESINT, "CALL CPECallHandling::SendMessage -> EPEMessageIncoming");
             CPESingleCall* callData = iCallArrayOwner->GetCallObject( aCallId );
             if( callData )
                 {
@@ -2419,5 +2432,40 @@
         }                
     }
 
+// -----------------------------------------------------------------------------
+// CPECallHandling::SetColpNumber
+// -----------------------------------------------------------------------------
+//
+void CPECallHandling::SetColpNumber( TInt aCallId, const MCCECall& aCall ) const
+    {
+    TEFLOGSTRING( KTAINT, "CALL CPECallHandling::SetColpNumber" );
+    
+    TInt errorCode( KErrNone );
+    TInt value( KPEMatchDefault );
+    TPEMatcher matcher;    
+    
+    const TPEPhoneNumber& origRemoteNumber = iModel.DataStore()->RemotePhoneNumber( aCallId );    
+    const TPEPhoneNumber& remoteNumber = aCall.RemoteParty();
+    
+    errorCode = iRepository->Get( KTelMatchDigits, value );
+
+    if ( !errorCode == KErrNone )
+        {
+        TEFLOGSTRING( KTAOBJECT, "Reading KTelMatchDigits failed, use default value for matching");
+        }    
+    
+    //check if remote number is different from dialled number
+    if ( !matcher.numbersMatch( origRemoteNumber, remoteNumber, value ) )
+        {
+        //set COLP number        
+        iModel.DataStore()->SetRemoteColpNumber( remoteNumber, aCallId );
+        
+        TEFLOGSTRING3( KTAMESINT, 
+                "CPECallHandling::SetColpNumber, colp number: '%S', call id: %d", 
+                &remoteNumber, aCallId );
+        }        
+    }
+        
+
 
 //  End of File