voicerecorder/RecViewSrc/CVRSystemEventHandler.cpp
branchRCL_3
changeset 20 072a5fa0c63b
parent 19 2f5c9ee7098c
child 21 c6bafb5162d8
equal deleted inserted replaced
19:2f5c9ee7098c 20:072a5fa0c63b
     1 /*
       
     2 * Copyright (c) 2005 - 2006 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:  An active object class that is used to receive
       
    15 *  phone call related events from Publish&Subscribe and forward them
       
    16 *  to an MVRSystemEventObserver instance.
       
    17 *  Has to be attached to certain P&S -key, so it means having multiple
       
    18 *  
       
    19 *
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include <e32base.h>
       
    26 
       
    27 #include "CVRSystemEventHandler.h"
       
    28 #include "MVRSystemEventObserver.h"
       
    29 
       
    30 
       
    31 // ================= MEMBER FUNCTIONS ========================================
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CVRSystemEventHandler::CVRSystemEventHandler
       
    35 // 
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CVRSystemEventHandler::CVRSystemEventHandler() : CActive( EPriorityLow )
       
    39     {
       
    40 	CActiveScheduler::Add( this );
       
    41     }
       
    42 
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CVRSystemEventHandler::ConstructL
       
    46 // 
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 void CVRSystemEventHandler::ConstructL()
       
    50     {
       
    51 	
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CVRSystemEventHandler::NewL
       
    57 // 
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 // Two-phased constructor.
       
    61 CVRSystemEventHandler* CVRSystemEventHandler::NewL()
       
    62     {
       
    63     CVRSystemEventHandler* self = new (ELeave) CVRSystemEventHandler;
       
    64 
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     CleanupStack::Pop();
       
    68 
       
    69     return self;
       
    70     }
       
    71 
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CVRSystemEventHandler::~CVRSystemEventHandler
       
    75 // 
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 // Destructor
       
    79 CVRSystemEventHandler::~CVRSystemEventHandler()
       
    80     {
       
    81 	Cancel();
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CVRSystemEventHandler::IssueRequest
       
    87 // 
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CVRSystemEventHandler::IssueRequest()
       
    91 	{
       
    92 	SetActive();
       
    93 	iProperty.Subscribe( iStatus );
       
    94 	}
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CVRSystemEventHandler::RunL
       
    99 // 
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 void CVRSystemEventHandler::RunL()
       
   103 	{
       
   104 	// Event received
       
   105 
       
   106 	if ( iStatus != KErrCancel )
       
   107 		{
       
   108 		// Request a new event
       
   109 		IssueRequest();
       
   110 		// Notify the observer
       
   111 		iObserver->HandleSystemEventL();
       
   112 		}
       
   113 	}
       
   114 
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CVRSystemEventHandler::Listen
       
   118 // 
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void CVRSystemEventHandler::Listen( TUid aUid, 
       
   122 									TUint aKey, 
       
   123 									MVRSystemEventObserver* aObserver )
       
   124 	{
       
   125 	iProperty.Attach( aUid, aKey );
       
   126 	
       
   127 	iObserver = aObserver;
       
   128 	IssueRequest();
       
   129 	}
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // CVRSystemEventHandler::DoCancel
       
   134 // 
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CVRSystemEventHandler::DoCancel()
       
   138 	{
       
   139 	iProperty.Cancel();	
       
   140 	}
       
   141 
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CVRSystemEventHandler::StateL
       
   145 // 
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 TInt CVRSystemEventHandler::StateL( TUid aUid, TUint aKey )
       
   149 	{
       
   150 	TInt value;
       
   151 	User::LeaveIfError( RProperty::Get( aUid, aKey, value ) );
       
   152 	return value;
       
   153 	}
       
   154 	
       
   155 //  End of File