phoneclientserver/phoneserver/src/standard/standard_aiw/cphsrvemergencyrequestmanager.cpp
changeset 33 8d5d7fcf9b59
child 53 25b8d29b7c59
equal deleted inserted replaced
32:1f002146abb4 33:8d5d7fcf9b59
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Call Request Manager.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDES
       
    21 #include "cphsrvemergencyrequestmanager.h" 
       
    22 #include "cphsrvsubsessionbase.h" 
       
    23 #include "phsrvutils.h" 
       
    24 
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // The size of the Notification manager storage.
       
    29 //const TInt KPhSrvNotificationManagerPendingCallGranularity = 4;
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CPhSrvEmergencyRequestManager::CPhSrvEmergencyRequestManager
       
    36 // 
       
    37 // C++ constructor.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CPhSrvEmergencyRequestManager::CPhSrvEmergencyRequestManager()
       
    41     : iIsRequestPending( EFalse )
       
    42     {
       
    43     }
       
    44 
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CPhSrvEmergencyRequestManager::~CPhSrvEmergencyRequestManager
       
    48 // 
       
    49 // C++ destructor.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 CPhSrvEmergencyRequestManager::~CPhSrvEmergencyRequestManager()
       
    53     {
       
    54     }
       
    55 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CPhSrvEmergencyRequestManager::ConstructL
       
    59 // 
       
    60 // Complete construction.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CPhSrvEmergencyRequestManager::ConstructL()
       
    64     {
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CPhSrvEmergencyRequestManager::EmergencyDialL
       
    70 // 
       
    71 // Initiate a dial request - called by the external call
       
    72 // interface. Checks if emergency initiator is ready and sets request pending if 
       
    73 // emergency initiator hasn't been registered yet 
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void CPhSrvEmergencyRequestManager::EmergencyDialL( 
       
    77     const RMessage2& aMessage )
       
    78     {
       
    79     // If we have no registered initiator then we can't make a call.
       
    80     if ( !iEmergencyInitiator )
       
    81         {
       
    82         if( iIsRequestPending )
       
    83             {
       
    84             User::Leave( KErrAlreadyExists );
       
    85             }
       
    86         else
       
    87             {
       
    88             iPendingRequest = aMessage;
       
    89             iIsRequestPending = ETrue;
       
    90             }
       
    91         }
       
    92     else
       
    93         {
       
    94         DoMakeEmergencyDial( aMessage );
       
    95         }
       
    96     }
       
    97 
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CPhSrvEmergencyRequestManager::DoMakeEmergencyDial
       
   101 // 
       
   102 // Do the actual emergency dial request for emergency initiator.
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CPhSrvEmergencyRequestManager::DoMakeEmergencyDial( const RMessage2& aMessage )
       
   106     {
       
   107     iPendingRequestPointer= aMessage;
       
   108     
       
   109     // Clear pending request status 
       
   110     iIsRequestPending = EFalse;
       
   111     
       
   112     // Now see if the call notifier (initiator) is ready 
       
   113     if ( iEmergencyInitiator ->InitiatorIsReadyToMakeEmergencyCall() )
       
   114         {
       
   115         // Ask the call initiator to make the call (basically completes the
       
   116         //phone app engine's outstanding call notifier request).
       
   117         iEmergencyInitiator ->InitiatorMakeEmergencyCall( aMessage );
       
   118         }
       
   119     }
       
   120 
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CPhSrvEmergencyRequestManager::EmergencyDialCancel
       
   124 // 
       
   125 // Cancel a pending dial request.
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CPhSrvEmergencyRequestManager::EmergencyDialCancel()
       
   129     {
       
   130     // Clear pending request status 
       
   131     iIsRequestPending = EFalse;
       
   132     
       
   133     if ( !iPendingRequestPointer.IsNull() )
       
   134         {
       
   135         iPendingRequestPointer.Complete( KErrCancel );
       
   136         }
       
   137     }
       
   138 
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CPhSrvEmergencyRequestManager::SetNegotiatorReadyCall
       
   142 // 
       
   143 // Updates the negotiator so that it knows if the notifier
       
   144 // session is able to make a call.
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void CPhSrvEmergencyRequestManager::SetNegotiatorReadyCall(
       
   148     MPhSrvEmergencyCall& aInitiator )
       
   149     {
       
   150     // There mustn't already be a call initiator, or the existing call
       
   151     // initiator must be the same as the new one (otherwise, panic).
       
   152     __ASSERT_ALWAYS( !iEmergencyInitiator || &aInitiator == iEmergencyInitiator, 
       
   153         PhoneServerUtils::Panic( 
       
   154         EPhoneServerPanicExistingCallInitiatorFault ) );
       
   155 
       
   156     // Update our pointer
       
   157     iEmergencyInitiator  = &aInitiator;
       
   158     
       
   159     if( iIsRequestPending )
       
   160         {
       
   161         DoMakeEmergencyDial( iPendingRequest );
       
   162         }
       
   163     }
       
   164 
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CPhSrvEmergencyRequestManager::SetNegotiatorReadyCallCancel
       
   168 // 
       
   169 // Indicates that the initiator is no longer available
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 void CPhSrvEmergencyRequestManager::SetNegotiatorReadyCallCancel( 
       
   173     MPhSrvEmergencyCall& aInitiator )
       
   174     {
       
   175     if ( iEmergencyInitiator && iEmergencyInitiator == &aInitiator )
       
   176         {
       
   177         iEmergencyInitiator = NULL;
       
   178         }
       
   179     }
       
   180 
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CPhSrvEmergencyRequestManager::SetNegotiatorAttemptedCallResponseValue
       
   184 // 
       
   185 // Handle a response from the phone app engine - this is the 
       
   186 // result of attempting to make a call (based upon a previous
       
   187 // clients external call request)
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 void CPhSrvEmergencyRequestManager::SetNegotiatorAttemptedCallResponseValue( 
       
   191     TPhCltPhoneResults aResult )
       
   192     {
       
   193     if ( !iPendingRequestPointer.IsNull() )
       
   194         {
       
   195         iPendingRequestPointer.Complete( aResult );
       
   196         }
       
   197     }
       
   198 
       
   199 
       
   200 // End of File
       
   201