qtmobility/plugins/sensors/symbian/sensorbackendsym.h
changeset 4 90517678cc4f
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef SENSORBACKENDSYM_H
       
    43 #define SENSORBACKENDSYM_H
       
    44 
       
    45 // QT Mobility Sensor API headers
       
    46 #include <qsensorbackend.h>
       
    47 
       
    48 // Standard Symbian Headers
       
    49 #include <e32std.h>
       
    50 #include <e32cmn.h>
       
    51 
       
    52 // Sensor client headers
       
    53 // Common Sensor Headers
       
    54 #include <sensrvchannel.h>
       
    55 #include <sensrvchannelinfo.h>
       
    56 #include <sensrvtypes.h>
       
    57 #include <sensrvchannelfinder.h>
       
    58 #include <sensrvdatalistener.h>
       
    59 #include <sensrvpropertylistener.h> 
       
    60 
       
    61 // Internal Headers
       
    62 #include "sensorbackenddatasym.h"
       
    63 
       
    64 QTM_USE_NAMESPACE
       
    65 
       
    66 class CSensorBackendSym : public CBase, public QSensorBackend, public MSensrvDataListener, public MSensrvPropertyListener
       
    67     {
       
    68     public:
       
    69         // From QSensorBackend
       
    70         
       
    71         /**
       
    72          *  start is used to start listening to the sensor
       
    73          */
       
    74         virtual void start();
       
    75         
       
    76         /*
       
    77          * stop is used to stop listening to the sensor
       
    78          */
       
    79         virtual void stop();
       
    80         
       
    81         /*
       
    82          * Backend Destructor
       
    83          */
       
    84         ~CSensorBackendSym();
       
    85 
       
    86         // From MSensrvDataListener
       
    87         
       
    88         /*
       
    89          * DataReceived is called by the Sensor Server when ever data is available in the
       
    90          * sensor buffer
       
    91          */
       
    92         void  DataReceived(CSensrvChannel &aChannel, TInt aCount, TInt aDataLost);
       
    93         
       
    94         /**
       
    95          * DataError is called to indicate an error, fatal errors are inrecoverable
       
    96          */
       
    97         void  DataError(CSensrvChannel &aChannel, TSensrvErrorSeverity aError);
       
    98         
       
    99         /*
       
   100          * GetDataListenerInterfaceL is used to get a pointer to the sensor server backend
       
   101          * It is not required for QT Mobility Sensors API
       
   102          */
       
   103         void  GetDataListenerInterfaceL(TUid aInterfaceUid, TAny *&aInterface);
       
   104         
       
   105         // From MSensrvProeprtyListener        
       
   106         
       
   107         /**
       
   108          * Notification about the changed value of a property.
       
   109          */
       
   110         void  PropertyChanged (CSensrvChannel &aChannel, const TSensrvProperty &aChangedProperty);
       
   111            
       
   112         /**
       
   113          *  Property listening failed.
       
   114          */
       
   115         void  PropertyError (CSensrvChannel &aChannel, TSensrvErrorSeverity aError);
       
   116           
       
   117         /**
       
   118          * Set a listener for the indication, if the setting of the property succeeded.
       
   119          */ 
       
   120         void  SetPropertySuccessIndicationChanged (TSetPropertySuccessIndicator aIndication);
       
   121            
       
   122         /*
       
   123          * Returns a pointer to a specified interface extension - to allow future extension of this class without breaking binary compatibility.
       
   124          */
       
   125         void  GetPropertyListenerInterfaceL (TUid aInterfaceUid, TAny *&aInterface);
       
   126         
       
   127         /*
       
   128          * To enable/disable data/property listening
       
   129          */ 
       
   130         void SetListening(TBool aDataListening, TBool aPropertyListening);
       
   131             
       
   132     protected:
       
   133         
       
   134         /*
       
   135          * Default C++ constructor
       
   136          */
       
   137         CSensorBackendSym(QSensor *sensor);
       
   138         
       
   139         /**
       
   140          * Deriving class implements this if it requires property change notification
       
   141          */
       
   142         virtual void HandlePropertyChange(CSensrvChannel &aChannel, const TSensrvProperty &aChangedProperty);
       
   143         
       
   144         /*
       
   145          * RecvData is used to retrieve the sensor reading from sensor server
       
   146          * It is implemented the the sensor concrete class and handles sensor specific
       
   147          * reading data and provides conversion and utility code
       
   148          */
       
   149         virtual void RecvData(CSensrvChannel &aChannel) = 0;
       
   150         
       
   151         /*
       
   152          * InitializeL is used to create and init the sensor server objects
       
   153          */ 
       
   154         void InitializeL();
       
   155         
       
   156         /*
       
   157          * Close is used to release all the sensor server objects
       
   158          * May change when error handling is supported by mobility apis
       
   159          */
       
   160         TInt Close();
       
   161         
       
   162         /*
       
   163          * FindSensorL is used to find if a specific sensor is available on the
       
   164          * device, if FindSensorL leaves then the sensor is not supported
       
   165          */
       
   166         void FindSensorL();
       
   167         
       
   168         /*
       
   169          * OpenSensorChannelL is used to open the channel for sensor as indicated by
       
   170          * iPrivateData.iChannelInfo
       
   171          */
       
   172         void OpenSensorChannelL();
       
   173         
       
   174         /*
       
   175          * CloseSensorChannel is used to close the sensor channel and release the
       
   176          * resources
       
   177          */
       
   178         void CloseSensorChannelL();
       
   179         
       
   180         /*
       
   181          * Used to start listening to the sensor
       
   182          */
       
   183         void StartListeningL();
       
   184         
       
   185         /*
       
   186          * Used to stop listening to the sensor
       
   187          */
       
   188         void StopListeningL();
       
   189         
       
   190         /*
       
   191          * timerEvent is called when timer expires, this is used for supporting time based
       
   192          * sensor update policies
       
   193          */
       
   194         void timerEvent(QTimerEvent *aTimerEvent);
       
   195 
       
   196     protected:
       
   197         TSensorBackendDataSym iBackendData;
       
   198     };
       
   199 
       
   200 #endif //SENSORBACKENDSYM_H
       
   201