phoneengine/phonemodel/src/cpeparservoipnumberhandler.cpp
changeset 0 5f000ab63145
child 3 8871b09be73b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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     TUint32 serviceId = iDataStore.ServiceIdCommand();
       
   130     iServiceHandling.EnableServiceL( serviceId );
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CPEParserVoipNumberHandler::FilterPostfix
       
   135 // -----------------------------------------------------------------------------
       
   136 // 
       
   137 TPtrC CPEParserVoipNumberHandler::FilterPostfix( TPtrC aPostfix )
       
   138     {
       
   139     TLex input( aPostfix );
       
   140     TInt stripStart = KErrNotFound;
       
   141     TInt postfixLength = aPostfix.Length();
       
   142     for ( TInt i = 0; i != postfixLength; i ++ )
       
   143         {
       
   144         TChar ch( input.Peek() );
       
   145         if ( ch == KDtmfWait ||
       
   146              ch == KDtmfPlus )
       
   147             {
       
   148             if ( i < stripStart || stripStart == KErrNotFound )
       
   149                 {
       
   150                 stripStart = i;
       
   151                 }
       
   152             }
       
   153         }
       
   154     if ( stripStart != KErrNotFound )
       
   155         {
       
   156         return aPostfix.Left( stripStart );
       
   157         }
       
   158     else
       
   159         {
       
   160         return aPostfix;
       
   161         }
       
   162     } 
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CPEParserVoipNumberHandler::::ContinueVoipDial
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 TInt CPEParserVoipNumberHandler::ContinueVoipDial() const
       
   169     {
       
   170     TEFLOGSTRING( KTAINT, "PE CPEParserVoipNumberHandler::ContinueVoipDial" );
       
   171     TInt callId = 0;
       
   172     
       
   173     TPEPhoneNumber phoneNumber = iDataStore.PhoneNumber();
       
   174     TEFLOGSTRING2( KTAINT, 
       
   175           "PE CPEParserVoipNumberHandler::ContinueVoipDial, phoneNumber: %S", 
       
   176           &phoneNumber );
       
   177     TBool clientCall = ( iDataStore.CallOriginCommand() != EPECallOriginPhone );
       
   178     // DialCall method will set call origin as unknow
       
   179     TInt errorCode = iCallHandling.DialCall( phoneNumber, callId );
       
   180     
       
   181     // Set dtmf string to dataStore
       
   182     iDataStore.SetDtmfPostFix( iDtmfString, callId );
       
   183     
       
   184     //PhoneClient originated call
       
   185     if( clientCall && ( ECCPErrorNone == errorCode ) )
       
   186         {
       
   187         iOwner.SetClientInformation( callId, phoneNumber );
       
   188         }
       
   189     
       
   190     TEFLOGSTRING2( KTAINT, 
       
   191             "PE CPEParserVoipNumberHandler::ContinueVoipDial, error code: %d"
       
   192             , errorCode );
       
   193 
       
   194     return errorCode;
       
   195     }
       
   196 
       
   197 //  End of File