CAccMonitor Class Reference

class CAccMonitor : public CBase

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 );
    }
       
AccMonitor.lib
Since
S60 5.0

Inherits from

Constructor & Destructor Documentation

CAccMonitor()

CAccMonitor ( ) [protected]

Default Constructor

Member Functions Documentation

ConstructL()

void ConstructL ( ) [protected, pure virtual]

Symbian OS 2nd phase constructor

GetCapabilityValueL(const CAccMonitorInfo *, const TUint32, TInt &)

void 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.

leave
KErrNotFound if no capability is not defined for this accessory, KErrArgument if this accessory is not connected, otherwise standard Symbian error code.

Parameters

const CAccMonitorInfo * aInfo
const TUint32 aCapability is capability which value needs to be fetched.
TInt & aValue is the value for the capability.

GetConnectedAccessoriesL(RConnectedAccessories &)

TInt GetConnectedAccessoriesL ( RConnectedAccessories & aAccessoriesArray ) const [pure virtual]

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

leave
KErrNotFound if no accessories are connected. KErrNotReady if a device is not ready to start operation.

Parameters

RConnectedAccessories & aAccessoriesArray is a reference to an array that is filled with CAccMonitorInfo instances which are accessories connected to the S60 device.

IsObserving()

TBool IsObserving ( ) const [pure virtual]

Checks whether observer is already observing.

NewL()

IMPORT_C CAccMonitor * NewL ( ) [static]

Symbian two phased constructor.

NewLC()

IMPORT_C CAccMonitor * NewLC ( ) [static]

Symbian two phased constructor. Puts the instance to cleanup stack.

StartObservingL(MAccMonitorObserver *)

void StartObservingL ( MAccMonitorObserver * aObserver ) [pure virtual]

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

leave
TInt KErrAlreadyExists if observer is active allready, otherwise KErrNone or standard Symbian error code.

Parameters

MAccMonitorObserver * aObserver is the pointer to the callback functions.

StartObservingL(MAccMonitorObserver *, const CAccMonitorInfo *)

void 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.

leave
TInt KErrAlreadyExists if observer is active allready, otherwise KErrNone or standard Symbian error code.

Parameters

MAccMonitorObserver * aObserver is the pointer to the callback functions.
const CAccMonitorInfo * 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.

StartObservingL(MAccMonitorObserver *, const RAccMonCapabilityArray &)

void 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.

leave
TInt KErrAlreadyExists if observer is active already, otherwise KErrNone or standard Symbian error code.

Parameters

MAccMonitorObserver * aObserver is the pointer to the callback functions.
const RAccMonCapabilityArray & 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.

StopObserving()

void StopObserving ( ) [pure virtual]

Stops observing accessory connection status changes. Listening will be automatically stopped when CAccMonintoringApi object is deleted.