bluetoothengine/headsetsimulator/profiles/hfpprofile/src/features/hfplastnumberredialing.cpp
branchheadsetsimulator
changeset 60 90dbfc0435e3
equal deleted inserted replaced
59:02103bf20ee5 60:90dbfc0435e3
       
     1 /* 
       
     2  *
       
     3  * Copyright (c) <2010> Comarch S.A. and/or its subsidiary(-ies).
       
     4  * All rights reserved.
       
     5  * This component and the accompanying materials are made available
       
     6  * under the terms of the License "Eclipse Public License v1.0"
       
     7  * which accompanies this distribution, and is available
       
     8  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9  *
       
    10  * Original Contributors:
       
    11  * Comarch S.A. - original contribution.
       
    12  *
       
    13  * Contributors:
       
    14  *
       
    15  * Description:
       
    16  *
       
    17  */
       
    18 
       
    19 #include "hfplastnumberredialing.h"
       
    20 #include "hfpcommand.h"
       
    21 #include "hfpsettings.h"
       
    22 #include "debug.h"
       
    23 
       
    24 CHsHFPLastNumberRedialing* CHsHFPLastNumberRedialing::NewL(
       
    25         MHsHFPFeatureProviderObserver* aObserver )
       
    26     {
       
    27     CHsHFPLastNumberRedialing* self = CHsHFPLastNumberRedialing::NewLC(
       
    28             aObserver );
       
    29     CleanupStack::Pop( self );
       
    30     return self;
       
    31     }
       
    32 
       
    33 CHsHFPLastNumberRedialing* CHsHFPLastNumberRedialing::NewLC(
       
    34         MHsHFPFeatureProviderObserver* aObserver )
       
    35     {
       
    36     CHsHFPLastNumberRedialing* self = new ( ELeave ) CHsHFPLastNumberRedialing(
       
    37             aObserver );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     return self;
       
    41     }
       
    42 CHsHFPLastNumberRedialing::~CHsHFPLastNumberRedialing()
       
    43     {
       
    44     TRACE_FUNC_ENTRY
       
    45     if ( iSettings )
       
    46         {
       
    47         iSettings->Release();
       
    48         }
       
    49     TRACE_FUNC_EXIT
       
    50     }
       
    51 
       
    52 TInt CHsHFPLastNumberRedialing::ProcessCommand( const CHsHFPCommand &aInputCmd,
       
    53         CHsHFPCommand &aOutputCmd )
       
    54     {
       
    55     TRACE_FUNC_ENTRY
       
    56 
       
    57     TInt res = KErrNone;
       
    58     if ( aInputCmd.FromAG() )
       
    59         {
       
    60 
       
    61         if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdOK )
       
    62             {
       
    63             iWaitingForOK = EFalse;
       
    64             iWaitingForCIEV = ETrue;
       
    65             }
       
    66         else if ( iWaitingForOK && aInputCmd.Type() == EHFPCmdERROR )
       
    67             {
       
    68             iWaitingForOK = EFalse;
       
    69             iObserver->HandleProcedureCompleted( KErrNotFound );
       
    70             }
       
    71         else if ( iWaitingForCIEV && IsProperCIEV( &aInputCmd ) )
       
    72             {
       
    73             iWaitingForCIEV = EFalse;
       
    74             iObserver->HandleProcedureCompleted( KErrNone );
       
    75             }
       
    76         else
       
    77             {
       
    78             res = KErrArgument;
       
    79             }
       
    80         }
       
    81     else
       
    82         {
       
    83         if ( aInputCmd.Type() == EHFPCmdBLDN )
       
    84             {
       
    85             iWaitingForOK = ETrue;
       
    86             TRAP( res, CHsHFPCommand::CopyL( aInputCmd, aOutputCmd ) );
       
    87             }
       
    88         else
       
    89             {
       
    90             res = KErrArgument;
       
    91             }
       
    92         }
       
    93 
       
    94     TRACE_FUNC_EXIT
       
    95     return res;
       
    96     }
       
    97 
       
    98 CHsHFPLastNumberRedialing::CHsHFPLastNumberRedialing(
       
    99         MHsHFPFeatureProviderObserver* aObserver ) :
       
   100     iObserver( aObserver )
       
   101     {
       
   102     }
       
   103 
       
   104 void CHsHFPLastNumberRedialing::ConstructL()
       
   105     {
       
   106     iSettings = CHsHFPSettings::InstanceL();
       
   107     }
       
   108 
       
   109 TBool CHsHFPLastNumberRedialing::IsProperCIEV( const CHsHFPCommand* aCommand )
       
   110     {
       
   111     TRACE_FUNC_ENTRY
       
   112     TBool res = EFalse;
       
   113 
       
   114     if ( aCommand->Params().Count() == 2 )
       
   115         {
       
   116         TInt expectedIdx = iSettings->FindIndicatorIndex(
       
   117                 KHFPCallsetupIndicatorDes );
       
   118 
       
   119         TInt retrievedIdx = KErrNotFound;
       
   120         TRAPD(errRetrieveIdx, retrievedIdx = aCommand->Params()[0].IntL() )
       
   121 
       
   122         TInt retrievedValue = KErrNotFound;
       
   123         TRAPD(errRetrieveValue, retrievedValue = aCommand->Params()[1].IntL() )
       
   124         TRACE_INFO((_L8(" Index retrieved = %d, expected = %d"),
       
   125                         expectedIdx, retrievedIdx))
       
   126 
       
   127         const TInt expectedCallsetupValue = 2;
       
   128         if ( errRetrieveIdx == KErrNone && errRetrieveValue == KErrNone
       
   129                 && aCommand->Type() == EHFPCmdCIEV && aCommand->FromAG()
       
   130                 && expectedIdx == retrievedIdx && retrievedValue
       
   131                 == expectedCallsetupValue )
       
   132             {
       
   133             res = ETrue;
       
   134             }
       
   135         }
       
   136 
       
   137     TRACE_FUNC_EXIT
       
   138     return res;
       
   139     }