Nokia N97 SDK
Example Applications Guide

sensorexampledatalistener.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : sensorexampledatalistener.h
00004 *  Part of     : sensorexample
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2007, 2008 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #include <sensrvchannel.h>
00017 #include <sensrvtappingsensor.h>
00018 #include "sensorexampledatalistener.h"
00019 #include "SensorExampleAppView.h"
00020 
00021 
00022 // CLASS DECLARATION
00023 
00024 // -----------------------------------------------------------------------------
00025 // CSensorExampleDataListener::NewL()
00026 // Two-phased constructor.
00027 // -----------------------------------------------------------------------------
00028 //
00029 CSensorExampleDataListener* CSensorExampleDataListener::NewL( CSensorExampleAppView* aAppView )
00030     {
00031     return new ( ELeave ) CSensorExampleDataListener( aAppView );
00032     }
00033 
00034 // -----------------------------------------------------------------------------
00035 // CSensorExampleDataListener::CSensorExampleDataListener()
00036 // C++ default constructor can NOT contain any code, that might leave.
00037 // -----------------------------------------------------------------------------
00038 //
00039 CSensorExampleDataListener::CSensorExampleDataListener( CSensorExampleAppView* aAppView )
00040     : iAppView( aAppView )
00041     {
00042     // No implementation required
00043     }
00044 
00045 // -----------------------------------------------------------------------------
00046 // CSensorExampleDataListener::~CSensorExampleDataListener()
00047 // Destructor.
00048 // -----------------------------------------------------------------------------
00049 //
00050 CSensorExampleDataListener::~CSensorExampleDataListener()
00051     {
00052     // No implementation required
00053     }
00054 
00055 // -----------------------------------------------------------------------------
00056 // CSensorExampleDataListener::DataReceived
00057 // New data is available in the receiving buffer.
00058 // -----------------------------------------------------------------------------
00059 //
00060 void CSensorExampleDataListener::DataReceived( CSensrvChannel& aChannel,
00061                                                TInt /*aCount*/,
00062                                                TInt /*aDataLost*/ )
00063     {
00064     TSensrvChannelInfo info = aChannel.GetChannelInfo();
00065 
00066     if( info.iChannelType == KSensrvChannelTypeIdAccelerometerDoubleTappingData )
00067         {
00068         TSensrvTappingData tappingData;
00069         TPckg<TSensrvTappingData> tappingPackage( tappingData );
00070         aChannel.GetData( tappingPackage );
00071         iAppView->TappingEvent( tappingData.iDirection );
00072         }
00073 
00074     else if( info.iChannelType == KSensrvChannelTypeIdAccelerometerXYZAxisData )
00075         {
00076         TSensrvAccelerometerAxisData accData;
00077         TPckg<TSensrvAccelerometerAxisData> accPackage( accData );
00078         aChannel.GetData( accPackage );
00079         iAppView->AccelerometerData( accData.iAxisX, accData.iAxisY );
00080         }
00081 
00082     else if( info.iChannelType == KSensrvChannelTypeIdOrientationData )
00083         {
00084         TSensrvOrientationData accData;
00085         TPckg<TSensrvOrientationData> accPackage( accData );
00086         aChannel.GetData( accPackage );
00087         iAppView->OrientationEvent( accData.iDeviceOrientation );
00088         }
00089     }
00090 
00091 // -----------------------------------------------------------------------------
00092 // CSensorExampleDataListener::DataReceived
00093 // Data listening failed.
00094 // -----------------------------------------------------------------------------
00095 //
00096 void CSensorExampleDataListener::DataError( CSensrvChannel& /*aChannel*/,
00097                                             TSensrvErrorSeverity /*aError*/ )
00098     {
00099     }
00100 
00101 // -----------------------------------------------------------------------------
00102 // CSensorExampleDataListener::GetDataListenerInterfaceL
00103 // Get supported interface.
00104 // -----------------------------------------------------------------------------
00105 //
00106 void CSensorExampleDataListener::GetDataListenerInterfaceL( 
00107     TUid /*aInterfaceUid*/, TAny*& aInterface )
00108     {
00109     // Set interface as NULL to indicate only default interface currently supported.
00110     // If new interface(s) is being introduced and application wants to support that
00111     // aInterfaceUid must be checked and aInterface set accordingly.
00112     aInterface = NULL;
00113     }

© Nokia 2009

Back to top