phoneengine/phonemodel/src/cpeclientcallrequestmonitor.cpp
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2006-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:  This module contains the implementation of 
       
    15 *                CPEClientCallRequestMonitor class 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cpeclientcallrequestmonitor.h"
       
    22 #include "cpemessagehandler.h"
       
    23 #include "mpephonemodelinternal.h"
       
    24 #include "pevirtualengine.h"
       
    25 #include <cphcltcallnotify.h>
       
    26 #include <cphcltdialdata.h>
       
    27 #include <mpedatastore.h>
       
    28 #include <talogger.h>
       
    29 
       
    30 
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CPEClientCallRequestMonitor::CPEClientCallRequestMonitor
       
    35 // C++ default constructor can NOT contain any code, that
       
    36 // might leave.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CPEClientCallRequestMonitor::CPEClientCallRequestMonitor( 
       
    40         MPEPhoneModelInternal& aModel,
       
    41         CPhCltCallNotify& aCallNotifier ): 
       
    42             iModel( aModel ),
       
    43             iCallNotifier( aCallNotifier )
       
    44     {
       
    45     TEFLOGSTRING( KTAOBJECT, 
       
    46         "PE CPEClientCallRequestMonitor::CPEClientCallRequestMonitor complete");
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CPEClientCallRequestMonitor::ConstructL
       
    51 // Two-phased constructor.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CPEClientCallRequestMonitor::ConstructL()
       
    55     {
       
    56     iDialData = NULL;    
       
    57     }
       
    58     
       
    59 // -----------------------------------------------------------------------------
       
    60 // CPEClientCallRequestMonitor::NewL
       
    61 // Two-phased constructor.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CPEClientCallRequestMonitor* CPEClientCallRequestMonitor::NewL( 
       
    65     MPEPhoneModelInternal& aModel,
       
    66     CPhCltCallNotify& aCallNotifier )
       
    67     {
       
    68     CPEClientCallRequestMonitor* self = new( ELeave ) 
       
    69         CPEClientCallRequestMonitor( aModel, aCallNotifier  );
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     CleanupStack::Pop( self );
       
    73     return self;
       
    74     }
       
    75 
       
    76 // Destructor
       
    77 CPEClientCallRequestMonitor::~CPEClientCallRequestMonitor()
       
    78     {
       
    79     Cancel();
       
    80     if( iDialData )
       
    81         {
       
    82         delete iDialData;
       
    83         iDialData = NULL;
       
    84         }
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CPEClientCallRequestMonitor::SendRespond
       
    89 // Sends respond to the phone client.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CPEClientCallRequestMonitor::SendRespond( 
       
    93         const TInt aRespond )
       
    94     {
       
    95     if ( iClientOriginatedCall )
       
    96         {
       
    97         TEFLOGSTRING2( KTAMESOUT, 
       
    98             "PE CPEClientCallRequestMonitor::SendRespond, CPhCltCallNotify::RespondClient( %d )"
       
    99             ,aRespond );
       
   100         iCallNotifier.RespondClient( aRespond );
       
   101         iClientOriginatedCall = EFalse;
       
   102         StartMonitoring();
       
   103         }    
       
   104     }
       
   105 
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CPEClientCallRequestMonitor::DialRequest
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CPEClientCallRequestMonitor::DialRequest( CPhCltDialData* aDialData )
       
   112     {
       
   113     TEFLOGSTRING( KTAMESOUT, 
       
   114         "PE CPEClientCallRequestMonitor::DialRequest" );
       
   115     iMonitoring = EFalse;
       
   116     iDialData = aDialData;
       
   117     iClientOriginatedCall = ETrue;
       
   118     iModel.DataStore()->SetPhoneNumber( 
       
   119         static_cast<TPEPhoneNumber>( iDialData->TelephoneNumber() ) );
       
   120         
       
   121     if ( aDialData->SATCall() )
       
   122         {
       
   123         iModel.DataStore()->SetCallOriginCommand( EPECallOriginSAT );
       
   124         }
       
   125     else
       
   126         {
       
   127         iModel.DataStore()->SetCallOriginCommand( EPECallOriginClient );
       
   128         }
       
   129 
       
   130     iModel.HandleInternalMessage( MPEPhoneModel::EPEMessageClientDial );
       
   131     
       
   132     // Clear data so that following dials during created call does not
       
   133     // use these values.
       
   134     iModel.DataStore()->SetUserToUserInformation( KNullDesC() );
       
   135     iModel.DataStore()->SetCallOriginCommand( EPECallOriginPhone );
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CPEClientCallRequestMonitor::StartMonitoring
       
   140 // Starts monitoring phone client for client dials.
       
   141 // -----------------------------------------------------------------------------
       
   142 //
       
   143 void CPEClientCallRequestMonitor::StartMonitoring()
       
   144     {
       
   145     TEFLOGSTRING( KTAMESOUT, 
       
   146         "PE CPEClientCallRequestMonitor::StartMonitoring, RPhCltCallNotify::NotifyDialRequest( )" );
       
   147     
       
   148     iCallNotifier.NotifyDialRequest( this );
       
   149     if( iDialData )
       
   150         {
       
   151         delete iDialData;
       
   152         iDialData = NULL;
       
   153         }
       
   154     iMonitoring = ETrue;
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CPEClientCallRequestMonitor::DoCancel
       
   159 // Cancel active object request
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 void CPEClientCallRequestMonitor::Cancel()
       
   163     {
       
   164     TEFLOGSTRING( KTAREQEND, "PE CPEClientCallRequestMonitor::DoCancel" );
       
   165     iCallNotifier.CancelNotifyDialRequest( );
       
   166     iMonitoring = EFalse;
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CPEClientCallRequestMonitor::ClientDialData
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 CPhCltDialData* CPEClientCallRequestMonitor::ClientDialData()
       
   174     {
       
   175     return iDialData;
       
   176     }
       
   177     
       
   178 // -----------------------------------------------------------------------------
       
   179 // CPEClientCallRequestMonitor::IsActive
       
   180 // -----------------------------------------------------------------------------
       
   181 //    
       
   182 TBool CPEClientCallRequestMonitor::IsActive()
       
   183     {
       
   184     return iMonitoring;
       
   185     }
       
   186         
       
   187 // End of File