mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-27 04:13:02 +00:00

requires:
d4a4386d9f
for reference:
https://github.com/fluxer/katana/issues/26
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
71 lines
2.4 KiB
C++
71 lines
2.4 KiB
C++
/* This file is part of the KDE project
|
|
Copyright (C) 2022 Ivailo Monev <xakepa10@gmail.com>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License version 2, as published by the Free Software Foundation.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#define QT_NO_KEYWORDS
|
|
|
|
#include "location_geoclue.h"
|
|
|
|
#include <KDebug>
|
|
|
|
#include <libgeoclue-2.0/gclue-simple.h>
|
|
|
|
|
|
GeoClue::GeoClue(QObject* parent, const QVariantList& args)
|
|
: GeolocationProvider(parent, args)
|
|
{
|
|
setUpdateTriggers(GeolocationProvider::SourceEvent | GeolocationProvider::NetworkConnected);
|
|
}
|
|
|
|
GeoClue::~GeoClue()
|
|
{
|
|
}
|
|
|
|
void GeoClue::update()
|
|
{
|
|
Plasma::DataEngine::Data enginedata;
|
|
setData(enginedata);
|
|
|
|
GError *gliberror = NULL;
|
|
GClueSimple* gcluesimple = gclue_simple_new_sync("location_geoclue", GCLUE_ACCURACY_LEVEL_CITY, NULL, &gliberror);
|
|
if (!gcluesimple) {
|
|
kWarning() << "Null GClueSimple pointer";
|
|
return;
|
|
} else if (gliberror != NULL) {
|
|
kWarning() << gliberror->message;
|
|
return;
|
|
}
|
|
|
|
GClueLocation* gcluelocaiton = gclue_simple_get_location(gcluesimple);
|
|
if (!gcluelocaiton) {
|
|
kWarning() << "Null GClueLocation pointer";
|
|
return;
|
|
}
|
|
|
|
// qDebug() << Q_FUNC_INFO << gclue_location_get_description(gcluelocaiton);
|
|
// qDebug() << Q_FUNC_INFO << gclue_location_get_accuracy(gcluelocaiton);
|
|
// qDebug() << Q_FUNC_INFO << gclue_location_get_latitude(gcluelocaiton)
|
|
// qDebug() << Q_FUNC_INFO << gclue_location_get_longitude(gcluelocaiton);
|
|
enginedata["accuracy"] = qRound(qreal(gclue_location_get_accuracy(gcluelocaiton)));
|
|
enginedata["latitude"] = qreal(gclue_location_get_latitude(gcluelocaiton));
|
|
enginedata["longitude"] = qreal(gclue_location_get_longitude(gcluelocaiton));
|
|
setData(enginedata);
|
|
}
|
|
|
|
K_EXPORT_PLASMA_GEOLOCATIONPROVIDER(geoclue, GeoClue)
|
|
|
|
#include "moc_location_geoclue.cpp"
|