phoneengine/phonemodel/src/cpeparservoipnumberhandler.cpp
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CPEParserVoipNumberHandler class methods implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cpeclientcallrequestmonitor.h"
       
    22 #include "cpemessagehandler.h"
       
    23 #include "cpeparservoipnumberhandler.h"
       
    24 #include "mpeservicehandling.h"
       
    25 #include "pevirtualengine.h"
       
    26 #include <featmgr.h>
       
    27 #include <mpecallhandling.h>
       
    28 #include <mpedatastore.h>
       
    29 #include <talogger.h>
       
    30 
       
    31 
       
    32 // CONSTANTS
       
    33 const TUint KDtmfPlus = '+';
       
    34 const TUint KDtmfWait = 'w';
       
    35 // ================= MEMBER FUNCTIONS =======================================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CPEParserVoipNumberHandler::CPEParserVoipNumberHandler
       
    39 // C++ default constructor can NOT contain any code, that
       
    40 // might leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CPEParserVoipNumberHandler::CPEParserVoipNumberHandler( 
       
    44         CPEMessageHandler& aOwner, 
       
    45         MPECallHandling& aCallHandling,
       
    46         MPEServiceHandling& aServiceHandling,
       
    47         MPEDataStore& aDataStore
       
    48         ) : iOwner( aOwner ), 
       
    49             iCallHandling( aCallHandling ),
       
    50             iDataStore( aDataStore ),
       
    51             iServiceHandling( aServiceHandling )
       
    52     {
       
    53     TEFLOGSTRING( KTAOBJECT, "PE CPEParserVoipNumberHandler::CPEParserVoipNumberHandler" )
       
    54     }
       
    55     
       
    56 CPEParserVoipNumberHandler* CPEParserVoipNumberHandler::NewL( CPEMessageHandler& aOwner, 
       
    57                                      MPECallHandling& aCallHandling,
       
    58                                      MPEServiceHandling& aServiceHandling,
       
    59                                      MPEDataStore& aDataStore )
       
    60     {
       
    61     CPEParserVoipNumberHandler* self = CPEParserVoipNumberHandler::NewLC( aOwner, aCallHandling, aServiceHandling, aDataStore );
       
    62     CleanupStack::Pop( self );
       
    63     return self;
       
    64     }
       
    65 
       
    66 CPEParserVoipNumberHandler* CPEParserVoipNumberHandler::NewLC( CPEMessageHandler& aOwner, 
       
    67                                       MPECallHandling& aCallHandling,
       
    68                                       MPEServiceHandling& aServiceHandling,
       
    69                                       MPEDataStore& aDataStore )
       
    70     {
       
    71     CPEParserVoipNumberHandler* self = new( ELeave ) CPEParserVoipNumberHandler( aOwner, aCallHandling, aServiceHandling, aDataStore );
       
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL();
       
    74     return self;
       
    75     }
       
    76 
       
    77 void CPEParserVoipNumberHandler::ConstructL()
       
    78     {
       
    79     }
       
    80 
       
    81 CPEParserVoipNumberHandler::~CPEParserVoipNumberHandler()
       
    82     {
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CPEParserVoipNumberHandler::ProcessDialToVoipNumberL
       
    87 // Process dial to number.
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CPEParserVoipNumberHandler::ProcessDialToVoipNumberL( 
       
    91         const TDesC& aNumber,
       
    92         const TDesC& aDtmfPostfix
       
    93         )
       
    94     {
       
    95     TEFLOGSTRING3( KTAINT, 
       
    96           "PE CPEParserVoipNumberHandler::ProcessDialToVoipNumberL, aNumber: %S, aDtmfPostfix: %S", 
       
    97           &aNumber, 
       
    98           &aDtmfPostfix );
       
    99 
       
   100     TPEPhoneNumber phoneNumber;
       
   101     
       
   102     // Check if phone is locked
       
   103     iOwner.CheckIfPhoneIsLockedL();
       
   104   
       
   105     if ( aNumber.Length() == 0 )
       
   106         {
       
   107         User::Leave( ECCPErrorInvalidPhoneNumber );
       
   108         }
       
   109     
       
   110     phoneNumber.Append( aNumber );
       
   111     
       
   112     TPECallType processType = iDataStore.CallTypeCommand();
       
   113  
       
   114     // Remove possible + or w chartes.      
       
   115     TPEPhoneNumber postfix = FilterPostfix( aDtmfPostfix );
       
   116     if( postfix.Length() )
       
   117         {
       
   118         phoneNumber.Append( postfix );
       
   119         }
       
   120     iDtmfString = aDtmfPostfix;
       
   121      
       
   122     TEFLOGSTRING3( KTAINT, 
       
   123           "PE CPEParserVoipNumberHandler::ProcessDialToVoipNumberL, phoneNumber: %S, iDtmfString: %S"
       
   124             , &phoneNumber
       
   125             , &iDtmfString );
       
   126   
       
   127     // Temporary hack for enabling client calls with service id 3
       
   128     // Proper solution to be done to CallUi and AIW dial data
       
   129         
       
   130 
       
   131     TUint32 serviceId = iDataStore.ServiceIdCommand();
       
   132     iServiceHandling.EnableServiceL( serviceId );
       
   133 
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CPEParserVoipNumberHandler::FilterPostfix
       
   138 // -----------------------------------------------------------------------------
       
   139 // 
       
   140 TPtrC CPEParserVoipNumberHandler::FilterPostfix( TPtrC aPostfix )
       
   141     {
       
   142     TLex input( aPostfix );
       
   143     TInt stripStart = KErrNotFound;
       
   144     TInt postfixLength = aPostfix.Length();
       
   145     for ( TInt i = 0; i != postfixLength; i ++ )
       
   146         {
       
   147         TChar ch( input.Peek() );
       
   148         if ( ch == KDtmfWait ||
       
   149              ch == KDtmfPlus )
       
   150             {
       
   151             if ( i < stripStart || stripStart == KErrNotFound )
       
   152                 {
       
   153                 stripStart = i;
       
   154                 }
       
   155             }
       
   156         }
       
   157     if ( stripStart != KErrNotFound )
       
   158         {
       
   159         return aPostfix.Left( stripStart );
       
   160         }
       
   161     else
       
   162         {
       
   163         return aPostfix;
       
   164         }
       
   165     } 
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CPEParserVoipNumberHandler::::ContinueVoipDial
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 TInt CPEParserVoipNumberHandler::ContinueVoipDial() const
       
   172     {
       
   173     TEFLOGSTRING( KTAINT, "PE CPEParserVoipNumberHandler::ContinueVoipDial" );
       
   174     TInt callId = 0;
       
   175     
       
   176     TPEPhoneNumber phoneNumber = iDataStore.PhoneNumber();
       
   177     TEFLOGSTRING2( KTAINT, 
       
   178           "PE CPEParserVoipNumberHandler::ContinueVoipDial, phoneNumber: %S", 
       
   179           &phoneNumber );
       
   180     TBool clientCall = ( iDataStore.CallOriginCommand() != EPECallOriginPhone );
       
   181     // DialCall method will set call origin as unknow
       
   182     TInt errorCode = iCallHandling.DialCall( phoneNumber, callId );
       
   183     
       
   184     // Set dtmf string to dataStore
       
   185     iDataStore.SetDtmfPostFix( iDtmfString, callId );
       
   186     
       
   187     //PhoneClient originated call
       
   188     if( clientCall && ( ECCPErrorNone == errorCode ) )
       
   189         {
       
   190         iOwner.SetClientInformation( callId, phoneNumber );
       
   191         }
       
   192     
       
   193     TEFLOGSTRING2( KTAINT, 
       
   194             "PE CPEParserVoipNumberHandler::ContinueVoipDial, error code: %d"
       
   195             , errorCode );
       
   196 
       
   197     return errorCode;
       
   198     }
       
   199 
       
   200 //  End of File