convergedcallengine/csplugin/src/cspremotealertingtonelistener.cpp
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
       
     1 /*
       
     2 * Copyright (c) 2008-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:  Listens remote alerting tone status changes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cspremotealertingtonelistener.h"
       
    20 #include "mcspremotealertingtoneobserver.h"
       
    21 
       
    22 // ======== MEMBER FUNCTIONS ========
       
    23 
       
    24 // ---------------------------------------------------------------------------
       
    25 // Default constructor
       
    26 // ---------------------------------------------------------------------------
       
    27 //
       
    28 CSPRemoteAlertingToneListener::CSPRemoteAlertingToneListener(
       
    29     RMmCustomAPI& aCustomAPI,
       
    30     MCSPRemoteAlertingToneObserver& aObserver ) : 
       
    31     CActive( CActive::EPriorityStandard ),
       
    32     iCustomAPI( aCustomAPI ),
       
    33     iObserver( aObserver )
       
    34     {
       
    35     CActiveScheduler::Add( this );
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // Static constructor
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CSPRemoteAlertingToneListener* CSPRemoteAlertingToneListener::NewL( 
       
    43     RMmCustomAPI& aCustomAPI,
       
    44     MCSPRemoteAlertingToneObserver& aObserver )
       
    45     {
       
    46     CSPRemoteAlertingToneListener* self = 
       
    47         new( ELeave ) CSPRemoteAlertingToneListener( 
       
    48             aCustomAPI, aObserver );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // Destructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CSPRemoteAlertingToneListener::~CSPRemoteAlertingToneListener()
       
    57     {
       
    58     Cancel();
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Starts listening the remote alerting tone changes, if not already started
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 void CSPRemoteAlertingToneListener::StartListening()
       
    66     {
       
    67     if ( !IsActive() )
       
    68         {
       
    69         iCustomAPI.NotifyRemoteAlertingToneStatusChange( iStatus, iRATStatus );
       
    70         SetActive();
       
    71         }
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // From class CActive.
       
    76 // Cancels the oustanding request.
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 void CSPRemoteAlertingToneListener::DoCancel()
       
    80     {
       
    81     iCustomAPI.CancelAsyncRequest(
       
    82         ECustomNotifyRemoteAlertingToneStatusChangeIPC );
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // From class CActive.
       
    87 // Starts listening next change and notifies the observer if no errors 
       
    88 // in request completion.
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CSPRemoteAlertingToneListener::RunL()
       
    92     {
       
    93     const TInt error( iStatus.Int() );
       
    94     if ( error != KErrNotSupported )
       
    95         {
       
    96         StartListening();
       
    97         }
       
    98     if ( error == KErrNone )
       
    99         {
       
   100         iObserver.RemoteAlertingToneStatusChanged( iRATStatus );
       
   101         }
       
   102     }