qtmobility/plugins/sensors/n900/main.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    43 #include "n900lightsensor.h"
    43 #include "n900lightsensor.h"
    44 #include "n900proximitysensor.h"
    44 #include "n900proximitysensor.h"
    45 #include <qsensorplugin.h>
    45 #include <qsensorplugin.h>
    46 #include <qsensorbackend.h>
    46 #include <qsensorbackend.h>
    47 #include <qsensormanager.h>
    47 #include <qsensormanager.h>
    48 #include <QFile>
       
    49 #include <QDebug>
    48 #include <QDebug>
    50 
    49 
    51 class n900SensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
    50 class n900SensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory
    52 {
    51 {
    53     Q_OBJECT
    52     Q_OBJECT
    61         QSensorManager::registerBackend(QProximitySensor::type, n900proximitysensor::id, this);
    60         QSensorManager::registerBackend(QProximitySensor::type, n900proximitysensor::id, this);
    62     }
    61     }
    63 
    62 
    64     QSensorBackend *createBackend(QSensor *sensor)
    63     QSensorBackend *createBackend(QSensor *sensor)
    65     {
    64     {
    66         if (sensor->identifier() == n900accelerometer::id) {
    65         if (sensor->identifier() == n900accelerometer::id)
    67             if (QFile::exists(QLatin1String(n900accelerometer::filename)))
    66             return new n900accelerometer(sensor);
    68                 return new n900accelerometer(sensor);
       
    69             qDebug() << "can't make" << sensor->identifier() << "because" << n900accelerometer::filename << "doesn't exist";
       
    70         }
       
    71 
    67 
    72         if (sensor->identifier() == n900lightsensor::id) {
    68         if (sensor->identifier() == n900lightsensor::id)
    73             if (QFile::exists(QLatin1String(n900lightsensor::filename)))
    69             return new n900lightsensor(sensor);
    74                 return new n900lightsensor(sensor);
       
    75             qDebug() << "can't make" << sensor->identifier() << "because" << n900lightsensor::filename << "doesn't exist";
       
    76         }
       
    77 
    70 
    78         if (sensor->identifier() == n900proximitysensor::id) {
    71         if (sensor->identifier() == n900proximitysensor::id)
    79             if (QFile::exists(QLatin1String(n900proximitysensor::filename)))
    72             return new n900proximitysensor(sensor);
    80                 return new n900proximitysensor(sensor);
       
    81             qDebug() << "can't make" << sensor->identifier() << "because" << n900proximitysensor::filename << "doesn't exist";
       
    82         }
       
    83 
    73 
    84         return 0;
    74         return 0;
    85     }
    75     }
    86 };
    76 };
    87 
    77