2
* Copyright (C) 2009 Petri Damstén <damu@iki.fi>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of
7
* the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "location_gps.h"
21
Gpsd::Gpsd(gps_data_t* gpsdata)
30
m_condition.wakeOne();
39
m_condition.wakeOne();
45
#if defined( GPSD_API_MAJOR_VERSION ) && ( GPSD_API_MAJOR_VERSION >= 3 ) && defined( WATCH_ENABLE )
46
gps_stream(m_gpsdata, WATCH_ENABLE, NULL);
48
gps_query(m_gpsdata, "w+x\n");
52
Plasma::DataEngine::Data d;
54
#if GPSD_API_MAJOR_VERSION >= 5
55
if (gps_read(m_gpsdata) != -1) {
57
if (gps_poll(m_gpsdata) != -1) {
59
//kDebug() << "poll ok";
60
if (m_gpsdata->online) {
61
//kDebug() << "online";
62
if (m_gpsdata->status != STATUS_NO_FIX) {
65
d["latitude"] = QString::number(m_gpsdata->fix.latitude);
66
d["longitude"] = QString::number(m_gpsdata->fix.longitude);
73
m_condition.wait(&m_mutex);
77
Gps::Gps(QObject* parent, const QVariantList& args)
78
: GeolocationProvider(parent, args),
80
#if GPSD_API_MAJOR_VERSION >= 5
84
#if GPSD_API_MAJOR_VERSION >= 5
85
m_gpsdata = new gps_data_t;
86
gps_open("localhost", DEFAULT_GPSD_PORT, m_gpsdata);
88
gps_data_t* m_gpsdata = gps_open("localhost", DEFAULT_GPSD_PORT);
91
kDebug() << "gpsd found.";
92
m_gpsd = new Gpsd(m_gpsdata);
93
connect(m_gpsd, SIGNAL(dataReady(const Plasma::DataEngine::Data&)),
94
this, SIGNAL(setData(const Plasma::DataEngine::Data&)));
96
kDebug() << "gpsd not found";
99
setIsAvailable(m_gpsd);
105
#if GPSD_API_MAJOR_VERSION >= 5
117
K_EXPORT_PLASMA_GEOLOCATIONPROVIDER(gps, Gps)
119
#include "location_gps.moc"