src/location/liblocationwrapper_p.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 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_p.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     bool isActive();
       
    78     QList<QGeoSatelliteInfo> satellitesInView();
       
    79     QList<QGeoSatelliteInfo> satellitesInUse();
       
    80 
       
    81 private:
       
    82     QFile *file;
       
    83     LocationGPSDControl *locationControl;
       
    84     LocationGPSDevice *locationDevice;
       
    85 
       
    86     static void locationError(LocationGPSDevice *device, gint code, gpointer data);
       
    87     static void locationChanged(LocationGPSDevice *device, gpointer data);
       
    88 
       
    89     int errorHandlerId;
       
    90     int posChangedId;
       
    91     int origUpdateInterval;
       
    92     int startcounter;
       
    93     QGeoPositionInfo lastUpdate;
       
    94     QGeoPositionInfo lastSatUpdate;
       
    95     bool validLastUpdate;
       
    96     bool validLastSatUpdate;
       
    97     bool fromSatellite;
       
    98 
       
    99     void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
       
   100     void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
       
   101     QList<QGeoSatelliteInfo> satsInView;
       
   102     QList<QGeoSatelliteInfo> satsInUse;
       
   103 
       
   104     enum LocationState {
       
   105         Undefined = 0,
       
   106         Inited = 1,
       
   107         Started = 2,
       
   108         Stopped = 4,
       
   109         RequestActive = 8,
       
   110         RequestSingleShot = 16
       
   111     };
       
   112     int locationState;
       
   113 
       
   114 signals:
       
   115     void positionUpdated(const QGeoPositionInfo &position);
       
   116     void error();
       
   117 };
       
   118 
       
   119 QTM_END_NAMESPACE
       
   120 #endif // LIBLOCATIONWRAPPER_H