qtmobility/src/location/liblocationwrapper_p.h
changeset 4 90517678cc4f
child 8 71781823f776
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 LIBLOCATIONWRAPPER_H
       
    43 #define LIBLOCATINWRAPPER_H
       
    44 
       
    45 // INCLUDES
       
    46 #include <QDebug>
       
    47 #include <QFile>
       
    48 
       
    49 #include "qgeocoordinate.h"
       
    50 #include "qgeopositioninfo.h"
       
    51 #include "qgeosatelliteinfo.h"
       
    52 
       
    53 #include "gconfitem.h"
       
    54 
       
    55 extern "C" {
       
    56    #include <glib.h>
       
    57    #include <location/location-gpsd-control.h>
       
    58    #include <location/location-gps-device.h>
       
    59    #include <location/location-misc.h>
       
    60    #include <location/location-distance-utils.h>
       
    61 }
       
    62 
       
    63 QTM_BEGIN_NAMESPACE
       
    64 
       
    65 class LiblocationWrapper : public QObject
       
    66 {
       
    67     Q_OBJECT
       
    68 
       
    69 public:
       
    70     static LiblocationWrapper *instance();
       
    71     ~LiblocationWrapper();
       
    72 
       
    73     void start();
       
    74     void stop();
       
    75     QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
       
    76     bool inited();
       
    77     QGeoPositionInfo position();
       
    78     bool fixIsValid();
       
    79     bool isActive();
       
    80     QList<QGeoSatelliteInfo> satellitesInView();
       
    81     QList<QGeoSatelliteInfo> satellitesInUse();
       
    82 
       
    83 private:
       
    84     QFile *file;
       
    85     LocationGPSDControl *locationControl;
       
    86     LocationGPSDevice *locationDevice;
       
    87 
       
    88     static void locationError(LocationGPSDevice *device, gint code, gpointer data);
       
    89     static void locationChanged(LocationGPSDevice *device, gpointer data);
       
    90 
       
    91     int errorHandlerId;
       
    92     int posChangedId;
       
    93     int origUpdateInterval;
       
    94     int startcounter;
       
    95     QGeoPositionInfo lastUpdate;
       
    96     QGeoPositionInfo lastSatUpdate;
       
    97     bool validLastUpdate;
       
    98     bool validLastSatUpdate;
       
    99 
       
   100     void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
       
   101     void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
       
   102     QList<QGeoSatelliteInfo> satsInView;
       
   103     QList<QGeoSatelliteInfo> satsInUse;
       
   104 
       
   105     enum LocationState {
       
   106         Undefined = 0,
       
   107         Inited = 1,
       
   108         Started = 2,
       
   109         Stopped = 4,
       
   110         RequestActive = 8,
       
   111         RequestSingleShot = 16
       
   112     };
       
   113     int locationState;
       
   114 
       
   115 private slots:
       
   116     void setLocation(const QGeoPositionInfo &update, bool locationValid);
       
   117 
       
   118 signals:
       
   119     void error();
       
   120 };
       
   121 
       
   122 QTM_END_NAMESPACE
       
   123 #endif // LIBLOCATIONWRAPPER_H