CAccMonitor Class Reference

Link against: accmonitor.lib


#include <
AccMonitor.h>

Detailed Description

The Accessory Monitoring API interface offers accessory information about connected accessories.

It also offers an easy-to-use implementation of a CActive-based wrapper for accessory connection status changed event notifications. The clients can get information about the connected accessories capabilities and, if the capabilities have values, get the values from these capabilites. This API consist of classes CAccMonitor, CAccMonitorInfo and MAccMonitorObserver. If the user wants to use the observer this API offers, the user has to implement callback function for receiving accessory connection and disconnection status notifications. The connected accessories are offered to the client in an array. This array presents the connected accessories as instances of CAccMonitorInfo class. The CAccMonitorInfo offers accessory information encapsulated to a class. It presents accessory device type, physical connection and device address information with basic getter functions. The rest of the accessories features are contained in an array. This array can be accessed with functions that are in CAccMonitorInfo. This class is not intended for user derivation.

Usage:

Example query for some accessory's information. All connected accessories are fetched and the instance of CAccessoryInfo is getted:

 CAccMonitor* accMonitor = CAccMonitor::NewLC();
 RConnectedAccessories connectedAccessories;
 CleanupClosePushL( connectedAccessories );
 accMonitor->GetConnectedAccessoriesL( connectedAccessories );
 CAccMonitorInfo* accInfo = CAccMonitorInfo::NewLC();
 TInt countOfArray = connectedAccessories.Count();
 for( TInt i = 0; i != countOfArray; i++ )
   {
   TAccMonCapability deviceType = connectedAccessories[ i ]->AccDeviceType();
   if( deviceType == KAccMonHeadset )
     {
     // Some Headset is connected, get the information to accInfo
     accInfo->CopyL( connectedAccessories[ i ] );
     }
   }
 // Destroy the pointers from the array, because those are owned by the client
 CleanupStack::PopAndDestroy( accInfo );
 CleanupStack::PopAndDestroy( &connectedAccessories );
 CleanupStack::PopAndDestroy( accMonitor );

Example query for some accessorys capabilties. The user has fetched the CAccMonitorInfo to accInfo instance from connected accessories:

 TInt arrayCount = accInfo->Count();
 for( TInt i = 0; i != arrayCount; i++ )
   {
   TAccMonCapability accCapa = accInfo->AccCapabilityAtIndex( i );
   if( accCapa == KAccMonStereoAudio )
     {
     // Accessory has stereo capability, handle this situation.
     }
   }

Initialization example for the observer(from a class that implements MAccMonitorObserver interface). Observer starts to listen for headset connects:

 CAccMonitor* accMonitor = CAccMonitor::NewLC();
 RAccMonCapabilityArray capabilityArray;
 CleanupClosePushL( capabilityArray );
 capabilityArray.Append( KAccMonHeadset );
 accMonitor->StartObservingL( this, capabilityArray );
 CleanupStack::PopAndDestroy( &capabilityArray );
 CleanupStack::PopAndDestroy( accMonitor );

Uninitialization example:

 accMonitor->StopObserving(); 

Connected method implementation example:

 void CMyAccMonitorTest::Connected( CAccMonitorInfo* aAccessoryInfo )
    {
    // Notification about the connected accessory. aAccessoryInfo must
    // be copied because the pointer is deleted after connected method
    iAccessoryInfo->CopyL( aAccessoryInfo );
    }
Dll AccMonitor.lib
Since:
S60 5.0

Public Member Functions

virtual TInt GetConnectedAccessoriesL (RConnectedAccessories &aAccessoriesArray) const =0
 Used to get the connected accessories which are returned in an RPointerArray that is typed to RConnectedAccessories.
virtual void StartObservingL (MAccMonitorObserver *aObserver)=0
 Sets observer to listen all connect/disconnect accessory notifications and starts the observer.
virtual void StartObservingL (MAccMonitorObserver *aObserver, const CAccMonitorInfo *aInfo)=0
 Sets observer to listen connect/disconnect accessory notifications and starts the observer.
virtual void StartObservingL (MAccMonitorObserver *aObserver, const RAccMonCapabilityArray &aCapabilityArray)=0
 Sets observer to listen connect/disconnect accessory notifications and starts the observer.
virtual void StopObserving ()=0
 Stops observing accessory connection status changes.
virtual TBool IsObserving () const =0
 Checks whether observer is already observing.
virtual void GetCapabilityValueL (const CAccMonitorInfo *aInfo, const TUint32 aCapability, TInt &aValue) const =0
 Gets the value for a capability that is defined in Accessory Monitoring API.

Static Public Member Functions

static IMPORT_C CAccMonitorNewL ()
 Symbian two phased constructor.
static IMPORT_C CAccMonitorNewLC ()
 Symbian two phased constructor.

Protected Member Functions

 CAccMonitor ()
 Default Constructor.
virtual void ConstructL ()=0
 Symbian OS 2nd phase constructor.

Constructor & Destructor Documentation

CAccMonitor::CAccMonitor  )  [protected]
 

Default Constructor.


Member Function Documentation

virtual void CAccMonitor::ConstructL  )  [protected, pure virtual]
 

Symbian OS 2nd phase constructor.

virtual void CAccMonitor::GetCapabilityValueL const CAccMonitorInfo aInfo,
const TUint32  aCapability,
TInt &  aValue
const [pure virtual]
 

Gets the value for a capability that is defined in Accessory Monitoring API.

Parameters:
aAccInfo is the accessory for which the value needs to be fetched.
aCapability is capability which value needs to be fetched.
aValue is the value for the capability.
Leave:
KErrNotFound if no capability is not defined for this accessory, KErrArgument if this accessory is not connected, otherwise standard Symbian error code.
virtual TInt CAccMonitor::GetConnectedAccessoriesL RConnectedAccessories aAccessoriesArray  )  const [pure virtual]
 

Used to get the connected accessories which are returned in an RPointerArray that is typed to RConnectedAccessories.

Parameters:
aAccessoriesArray is a reference to an array that is filled with CAccMonitorInfo instances which are accessories connected to the S60 device.
Leave:
KErrNotFound if no accessories are connected. KErrNotReady if a device is not ready to start operation.
Returns:
The amount of connected accessories.
virtual TBool CAccMonitor::IsObserving  )  const [pure virtual]
 

Checks whether observer is already observing.

Returns:
ETrue if observing
static IMPORT_C CAccMonitor* CAccMonitor::NewL  )  [static]
 

Symbian two phased constructor.

static IMPORT_C CAccMonitor* CAccMonitor::NewLC  )  [static]
 

Symbian two phased constructor.

Puts the instance to cleanup stack.

virtual void CAccMonitor::StartObservingL MAccMonitorObserver aObserver,
const RAccMonCapabilityArray aCapabilityArray
[pure virtual]
 

Sets observer to listen connect/disconnect accessory notifications and starts the observer.

Accessories that need to be listened can be defined.

Parameters:
aObserver is the pointer to the callback functions.
aCapabilityArray is an array of capabilities. Accessory type that needs to be listened is constructed with this capability array. For exmple if KAccMonHeadset capability is inserted to the array the observer receives all notifications about connected/disconnected headsets. If an empty array is set as parameter no notifications are sent to the observer.
Leave:
TInt KErrAlreadyExists if observer is active already, otherwise KErrNone or standard Symbian error code.
virtual void CAccMonitor::StartObservingL MAccMonitorObserver aObserver,
const CAccMonitorInfo aInfo
[pure virtual]
 

Sets observer to listen connect/disconnect accessory notifications and starts the observer.

Accessories that need to be listened can be defined with CAccMonitorInfo. This CAccMonitorInfo represents an instance of some connected or previously connected accessory.

Parameters:
aObserver is the pointer to the callback functions.
aInfo is the instance of the accessory that needs to be listened. Accessory that needs to be listened is copied from connected accessories array. If an empty instance is set as the parameter no notifications are sent.
Leave:
TInt KErrAlreadyExists if observer is active allready, otherwise KErrNone or standard Symbian error code.
virtual void CAccMonitor::StartObservingL MAccMonitorObserver aObserver  )  [pure virtual]
 

Sets observer to listen all connect/disconnect accessory notifications and starts the observer.

Parameters:
aObserver is the pointer to the callback functions.
Leave:
TInt KErrAlreadyExists if observer is active allready, otherwise KErrNone or standard Symbian error code.
virtual void CAccMonitor::StopObserving  )  [pure virtual]
 

Stops observing accessory connection status changes.

Listening will be automatically stopped when CAccMonintoringApi object is deleted.


The documentation for this class was generated from the following file:

Copyright © Nokia Corporation 2001-2007
Back to top