--- /dev/null
+
+Migrated to:
+https://github.com/rlinfati/latitudeupdater
+++ /dev/null
-# This file was generated by an application wizard of Qt Creator.
-# The code below handles deployment to Symbian and Maemo, aswell as copying
-# of the application data to shadow build directories on desktop.
-# It is recommended not to modify this file, since newer versions of Qt Creator
-# may offer an updated version of it.
-
-defineTest(qtcAddDeployment) {
-for(deploymentfolder, DEPLOYMENTFOLDERS) {
- item = item$${deploymentfolder}
- itemsources = $${item}.sources
- $$itemsources = $$eval($${deploymentfolder}.source)
- itempath = $${item}.path
- $$itempath= $$eval($${deploymentfolder}.target)
- export($$itemsources)
- export($$itempath)
- DEPLOYMENT += $$item
-}
-
-MAINPROFILEPWD = $$PWD
-
-symbian {
- isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg
- isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
-} else:win32 {
- copyCommand =
- for(deploymentfolder, DEPLOYMENTFOLDERS) {
- source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
- source = $$replace(source, /, \\)
- sourcePathSegments = $$split(source, \\)
- target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
- target = $$replace(target, /, \\)
- !isEqual(source,$$target) {
- !isEmpty(copyCommand):copyCommand += &&
- isEqual(QMAKE_DIR_SEP, \\) {
- copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
- } else {
- source = $$replace(source, \\\\, /)
- target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
- target = $$replace(target, \\\\, /)
- copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\"
- }
- }
- }
- !isEmpty(copyCommand) {
- copyCommand = @echo Copying application data... && $$copyCommand
- copydeploymentfolders.commands = $$copyCommand
- first.depends = $(first) copydeploymentfolders
- export(first.depends)
- export(copydeploymentfolders.commands)
- QMAKE_EXTRA_TARGETS += first copydeploymentfolders
- }
-} else:unix {
- maemo5 {
- desktopfile.files = $${TARGET}_fremantle.desktop
- desktopfile.path = /usr/share/applications/hildon
- icon.files = $${TARGET}64.png
- icon.path = /usr/share/icons/hicolor/64x64/apps
- } else:!isEmpty(MEEGO_VERSION_MAJOR) {
- desktopfile.files = $${TARGET}_harmattan.desktop
- desktopfile.path = /usr/share/applications
- icon.files = $${TARGET}80.png
- icon.path = /usr/share/icons/hicolor/80x80/apps
- } else { # Assumed to be a Desktop Unix
- copyCommand =
- for(deploymentfolder, DEPLOYMENTFOLDERS) {
- source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
- source = $$replace(source, \\\\, /)
- macx {
- target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
- } else {
- target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
- }
- target = $$replace(target, \\\\, /)
- sourcePathSegments = $$split(source, /)
- targetFullPath = $$target/$$last(sourcePathSegments)
- !isEqual(source,$$targetFullPath) {
- !isEmpty(copyCommand):copyCommand += &&
- copyCommand += $(MKDIR) \"$$target\"
- copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
- }
- }
- !isEmpty(copyCommand) {
- copyCommand = @echo Copying application data... && $$copyCommand
- copydeploymentfolders.commands = $$copyCommand
- first.depends = $(first) copydeploymentfolders
- export(first.depends)
- export(copydeploymentfolders.commands)
- QMAKE_EXTRA_TARGETS += first copydeploymentfolders
- }
- }
- installPrefix = /opt/linfati.com
- for(deploymentfolder, DEPLOYMENTFOLDERS) {
- item = item$${deploymentfolder}
- itemfiles = $${item}.files
- $$itemfiles = $$eval($${deploymentfolder}.source)
- itempath = $${item}.path
- $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target)
- export($$itemfiles)
- export($$itempath)
- INSTALLS += $$item
- }
-
- !isEmpty(desktopfile.path) {
- export(icon.files)
- export(icon.path)
- export(desktopfile.files)
- export(desktopfile.path)
- INSTALLS += icon desktopfile
- }
-
- target.path = $${installPrefix}/bin
- export(target.path)
- INSTALLS += target
-}
-
-export (ICON)
-export (INSTALLS)
-export (DEPLOYMENT)
-export (TARGET.EPOCHEAPSIZE)
-export (TARGET.CAPABILITY)
-export (LIBS)
-export (QMAKE_EXTRA_TARGETS)
-}
+++ /dev/null
-import QtQuick 1.1
-import com.nokia.meego 1.0
-import QtWebKit 1.0
-
-Page {
- id: mainPage
- orientationLock: PageOrientation.LockPortrait
- Column {
- spacing: 16
- Row {
-// width: rootWindow.width
- Button {
- id: do_staff
- width: rootWindow.width / 3
- text: "..."
- enabled: false
- onClicked: {
- if (text.match("Start")) {
- console.log("match start")
- if (!demonio.demonio_start()) {
- gps.startUpdates()
- }
- text = "Stop"
- } else if (text.match("Stop")) {
- console.log("match stop")
- if (!demonio.demonio_stop()) {
- gps.stopUpdates(true)
- }
- text = "Start"
- }
- }
- }
- }
- Row {
- Label {
- id: method_label
- text: "Method"
- width: mainPage.width / 4
- anchors.verticalCenter: method_button.verticalCenter
- }
- ButtonColumn {
- id: method_button
- width: mainPage.width * 1 / 3
- Button {
- id: method_cell
- text: "Cell Tower"
- checked: gps.getPositioningMethod() == "cell" ? true : false
- onClicked: gps.setPositioningMethod("cell")
- }
- Button {
- id: method_all
- text: "Both"
- checked: gps.getPositioningMethod() == "all" ? true : false
- onClicked: gps.setPositioningMethod("all")
- }
- Button {
- id: method_agps
- text: "Only GPS"
- checked: gps.getPositioningMethod() == "gps" ? true : false
- onClicked: gps.setPositioningMethod("gps")
- }
- }
- }
- Row {
- Label {
- id: timeout_label
- text: "Time Out"
- width: rootWindow.width / 4
- anchors.verticalCenter: timeout_slider.verticalCenter
- }
- Slider {
- id: timeout_slider
- width: rootWindow.width / 4
- valueIndicatorVisible: true
- minimumValue: 5
- maximumValue: 120
- stepSize: 5
- value: gps.getTimeOut()
- }
- Label {
- id: timeout_value
- text: timeout_slider.value + " seg."
- width: rootWindow.width / 4
- anchors.verticalCenter: timeout_slider.verticalCenter
- }
- Connections {
- target: timeout_slider
- onValueChanged: {
- timeout_value.text = timeout_slider.value + " seg."
- gps.setTimeOut(timeout_slider.value)
- }
- }
- }
- Row {
- Label {
- id: interval_label
- text: "Interval"
- width: rootWindow.width / 4
- anchors.verticalCenter: interval_slider.verticalCenter
- }
- Slider {
- id: interval_slider
- width: rootWindow.width / 4
- valueIndicatorVisible: true
- minimumValue: 5
- maximumValue: 60
- stepSize: 5
- value: gps.getInterval() / 60
- }
- Label {
- id: interval_value
- text: interval_slider.value + " min."
- width: rootWindow.width / 4
- anchors.verticalCenter: interval_slider.verticalCenter
- }
- Connections {
- target: interval_slider
- onValueChanged: {
- interval_value.text = interval_slider.value + " min."
- gps.setInterval(interval_slider.value*60)
- }
- }
- }
- Row {
- Label {
- id: connect_label
- text: "Auto Connect"
- width: rootWindow.width / 4
- anchors.verticalCenter: connect_switch.verticalCenter
- }
- Switch {
- id: connect_switch
- width: rootWindow.width / 4
- checked: latitude.getAutoConnect() ? true : false
- onCheckedChanged: {
- connect_value.text = checked
- latitude.setAutoConnect(checked)
- }
- }
- Label {
- id: connect_value
- text: connect_switch.checked
- width: rootWindow.width / 4
- anchors.verticalCenter: connect_switch.verticalCenter
- }
- }
- Row {
- Label {
- id: daemon_label
- text: "Daemon at boot time"
- width: rootWindow.width / 4
- anchors.verticalCenter: daemon_switch.verticalCenter
- }
- Switch {
- id: daemon_switch
- width: rootWindow.width / 4
- checked: latitude.getDaemonMode() ? true : false
- onCheckedChanged: {
- daemon_value.text = checked
- latitude.setDaemonMode(checked) }
- }
- Label {
- id: daemon_value
- text: daemon_switch.checked
- width: rootWindow.width / 4
- anchors.verticalCenter: daemon_switch.verticalCenter
- }
- }
-
- Connections {
- target: latitude
- onGotToken: {
- if (demonio.demonio_status()) {
- do_staff.text = "Stop"
- do_staff.enabled = true;
- } else {
- do_staff.text = "Start"
- do_staff.enabled = true;
- }
- pageStack.pop(login)
- }
- }
-
- Connections {
- target: latitude
- onNotToken: {
- do_staff.text = "..."
- do_staff.enabled = false;
- if (!demonio.demonio_stop()) {
- gps.stopUpdates(true)
- }
- latitude.getAccess()
- }
- }
- Connections {
- target: latitude
- onNeedAuth: {
- pageStack.push(login)
- }
- }
-
- Connections {
- target: gps
- onGotFix: {
- latitude.setCurrentLocation(gps.getCurrentLatitude(),
- gps.getCurrentLongitude(),
- gps.getCurrentAccuracy())
- latitude.sendCurrentLocation()
- }
- }
- }
-
- Component {
- id: login
- Page {
- orientationLock: PageOrientation.LockPortrait
- Flickable {
- id: flickable
- width: parent.width
- height: parent.height
- contentWidth: webView.width
- contentHeight: webView.height
- WebView {
- id: webView
- url: latitude.getUserAuthorization()
- preferredWidth: parent.width
- preferredHeight: parent.height
- onLoadFinished: {
- console.log(url)
- flickable.contentY = 0;
- if (url.toString().match("ServiceLogin")) {
- console.log("* QML WebView go w/2,0")
- flickable.contentX = width/2;
- } else {
- console.log("* QML WebView go 0,0")
- flickable.contentX = 0;
- }
- }
- }
- }
- }
- }
-}
+++ /dev/null
-TEMPLATE = app
-TARGET = latitude.qml
-
-QT += network
-CONFIG += mobility
-MOBILITY += location
-
-INCLUDEPATH += ../liblatitudeupdater
-INCLUDEPATH += ../libkqoauth
-
-LIBS += ../liblatitudeupdater/liblatitudeupdater.a
-LIBS += ../libkqoauth/libkqoauth.a
-
-QT += declarative
-HEADERS += qml.h
-SOURCES += qml.cpp main.cpp
-RESOURCES += resouses.qrc
-OTHER_FILES += main.qml MainPage.qml
-
-include(../deployment.pri)
-qtcAddDeployment()
-
-
-
-
+++ /dev/null
-#include <QtGui/QApplication>
-#include <QtGui/QInputContext>
-#include "qml.h"
-
-class EventFilter : public QObject {
-protected:
- bool eventFilter(QObject *obj, QEvent *event) {
- QInputContext *ic = qApp->inputContext();
- if (ic) {
- if (ic->focusWidget() == 0 && prevFocusWidget) {
- QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
- ic->filterEvent(&closeSIPEvent);
- } else if (prevFocusWidget == 0 && ic->focusWidget()) {
- QEvent openSIPEvent(QEvent::RequestSoftwareInputPanel);
- ic->filterEvent(&openSIPEvent);
- }
- prevFocusWidget = ic->focusWidget();
- }
- return QObject::eventFilter(obj,event);
- }
-
-private:
- QWidget *prevFocusWidget;
-};
-
-int main(int argc, char *argv[]) {
- qDebug() << "* Main QML";
- QCoreApplication::setOrganizationName("linfati.com");
- QCoreApplication::setOrganizationDomain("linfati.com");
- QCoreApplication::setApplicationName("latitudeupdater");
-
- QApplication lu(argc, argv);
-
- LatitudeQML mygui;
- EventFilter ef;
- mygui.installEventFilter(&ef);
- mygui.showFullScreen();
-
- return lu.exec();
-}
+++ /dev/null
-import QtQuick 1.1
-import com.nokia.meego 1.0
-
-PageStackWindow {
- id: rootWindow
- initialPage: mainPage
- MainPage {
- id: mainPage
- }
- showToolBar: false
- showStatusBar: true
-}
+++ /dev/null
-#include "qml.h"
-#include <QtDeclarative/QDeclarativeContext>
-
-LatitudeQML::LatitudeQML(QDeclarativeView *parent) :
- QDeclarativeView(parent),
- latitude(this),
- gps(this),
- demonio("/opt/linfati.com/bin/latituded"),
- cli(this) {
- qDebug() << "* LatitudeQML::LatitudeQML";
-
- rootContext()->setContextProperty("latitude", &latitude);
- rootContext()->setContextProperty("gps", &gps);
- rootContext()->setContextProperty("demonio", this);
- setSource(QUrl("qrc:/main.qml"));
-
- latitude.getAccess();
-}
+++ /dev/null
-#ifndef LatitudeQML_H
-#define LatitudeQML_H
-
-#include <QObject>
-#include <QtDeclarative/QDeclarativeView>
-#include <QtCore/QProcess>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QDir>
-#include <QtCore/QFile>
-#include "googlelatitude.h"
-#include "gpscontrol.h"
-
-class LatitudeQML : public QDeclarativeView {
- Q_OBJECT
-public:
- LatitudeQML(QDeclarativeView *parent = 0);
-
-signals:
-
-public slots:
- bool demonio_status() {
- qDebug() << "LatitudeQML::demonio_status";
- if (system("killall -0 latituded 2> /dev/null" )) {
- return false;
- }
- return true;
- }
- bool demonio_start() {
- qDebug() << "LatitudeQML::demonio_start";
- if (demonio.exists()) {
- cli.startDetached(demonio.fileName());
- return true;
- }
- qDebug() << "LatitudeQML:: demonio none";
- return false;
- }
- bool demonio_stop() {
- qDebug() << "LatitudeQML::demonio_stop";
- if (demonio.exists()) {
- qDebug() << "LatitudeQML:: demonio kill" << system("killall latituded 2> /dev/null");
- return true;
- }
- return false;
- }
-
-private slots:
-
-private:
- GoogleLatitude latitude;
- GpsControl gps;
- QFile demonio;
- QProcess cli;
-};
-
-#endif // LatitudeQML_H
+++ /dev/null
-<RCC>
- <qresource prefix="/">
- <file>main.qml</file>
- <file>MainPage.qml</file>
- </qresource>
-</RCC>
+++ /dev/null
-TEMPLATE = app
-TARGET = latitude.qt
-
-QT += network
-CONFIG += mobility
-MOBILITY += location
-
-INCLUDEPATH += ../liblatitudeupdater
-INCLUDEPATH += ../libkqoauth
-
-LIBS += ../liblatitudeupdater/liblatitudeupdater.a
-LIBS += ../libkqoauth/libkqoauth.a
-
-HEADERS += widget.h
-SOURCES += widget.cpp main.cpp
-
-include(../deployment.pri)
-qtcAddDeployment()
+++ /dev/null
-#include <QtGui/QApplication>
-#include "widget.h"
-
-int main(int argc, char *argv[]) {
- qDebug() << "* Main Widget";
- QCoreApplication::setOrganizationName("linfati.com");
- QCoreApplication::setOrganizationDomain("linfati.com");
- QCoreApplication::setApplicationName("latitudeupdater");
-
- QApplication lu(argc, argv);
-
- LatitudeGUI mygui;
- mygui.showMaximized();
-
- return lu.exec();
-}
+++ /dev/null
-#include "widget.h"
-
-LatitudeGUI::LatitudeGUI(QWidget *parent) :
- QWidget(parent),
- latitude(this),
- gps(this),
- demonio("/opt/linfati.com/bin/latituded"),
- cli(this) {
- qDebug() << "* LatitudeGUI::LatitudeGUI";
- setWindowTitle(tr("LatitudeUpdater"));
-
- // row 1
- layout_row1 = new QHBoxLayout();
- do_oauth = new QPushButton("Auth");
- do_start = new QPushButton("Start");
- do_stop = new QPushButton("Stop");
- layout_row1->addWidget(do_oauth);
- layout_row1->addWidget(do_start);
- layout_row1->addWidget(do_stop);
-
- do_oauth->setDisabled(true);
- do_start->setDisabled(true);
- do_stop->setDisabled(true);
-
- connect(do_oauth, SIGNAL(clicked()), this, SLOT(gl_webauth()) );
- connect(do_start, SIGNAL(clicked()), this, SLOT(gps_start()) );
- connect(do_stop, SIGNAL(clicked()), this, SLOT(gps_stop()) );
-
- connect(&latitude, SIGNAL(gotToken()), this, SLOT(gl_GotToken()) );
- connect(&latitude, SIGNAL(notToken()), this, SLOT(gl_NotToken()) );
- connect(&latitude, SIGNAL(needAuth()), this, SLOT(gl_needAuth()) );
-
- connect(&gps, SIGNAL(gotFix()), this, SLOT(set_latitude()) );
-
- // row 2
- layout_row2 = new QHBoxLayout();
- gps_group = new QButtonGroup();
- gps_method = new QLabel("Method");
- gps_cell = new QRadioButton("Cell Tower");
- gps_both = new QRadioButton("Both");
- gps_agps = new QRadioButton("Only Gps");
- gps_group->addButton(gps_cell);
- gps_group->addButton(gps_both);
- gps_group->addButton(gps_agps);
- layout_row2->addWidget(gps_method);
- layout_row2->addWidget(gps_cell);
- layout_row2->addWidget(gps_both);
- layout_row2->addWidget(gps_agps);
-
- if ( gps.getPositioningMethod() == "gps" ) gps_agps->setChecked(true);
- if ( gps.getPositioningMethod() == "cell" ) gps_cell->setChecked(true);
- if ( gps.getPositioningMethod() == "all" ) gps_both->setChecked(true);
-
- connect(gps_cell, SIGNAL(clicked()), this, SLOT(set_method()) );
- connect(gps_both, SIGNAL(clicked()), this, SLOT(set_method()) );
- connect(gps_agps, SIGNAL(clicked()), this, SLOT(set_method()) );
-
- // row 3
- layout_row3 = new QHBoxLayout();
- gps_to_label = new QLabel("Time Out");
- gps_to_slider = new QSlider(Qt::Horizontal);
- gps_to_slider->setSingleStep(5);
- gps_to_slider->setRange(5, 120);
- gps_to_slider->setValue(gps.getTimeOut());
- gps_to_slider_value = new QLabel(QString("%1 sec.").arg(gps_to_slider->value()));
- layout_row3->addWidget(gps_to_label);
- layout_row3->addWidget(gps_to_slider);
- layout_row3->addWidget(gps_to_slider_value);
-
- connect(gps_to_slider, SIGNAL(valueChanged(int)), this, SLOT(set_to(int)) );
-
- // row 4
- layout_row4 = new QHBoxLayout();
- gps_i_label = new QLabel("Interval");
-
- gps_i_slider = new QSlider(Qt::Horizontal);
- gps_i_slider->setSingleStep(5);
- gps_i_slider->setRange(5, 60);
- gps_i_slider->setValue(gps.getInterval()/60);
- gps_i_slider_value = new QLabel(QString("%1 min.").arg(gps_i_slider->value()));
- layout_row4->addWidget(gps_i_label);
- layout_row4->addWidget(gps_i_slider);
- layout_row4->addWidget(gps_i_slider_value);
-
- connect(gps_i_slider, SIGNAL(valueChanged(int)), this, SLOT(set_i(int)) );
-
- // row 5
- layout_row5 = new QHBoxLayout();
- gps_ac_group = new QButtonGroup();
- gps_ac_label = new QLabel("Auto Connect");
- gps_ac_yes = new QRadioButton("Yes");
- gps_ac_not = new QRadioButton("No");
- gps_ac_group->addButton(gps_ac_yes);
- gps_ac_group->addButton(gps_ac_not);
- layout_row5->addWidget(gps_ac_label);
- layout_row5->addWidget(gps_ac_yes);
- layout_row5->addWidget(gps_ac_not);
-
- if ( latitude.getAutoConnect() == true ) gps_ac_yes->setChecked(true);
- if ( latitude.getAutoConnect() == false ) gps_ac_not->setChecked(true);
-
- connect(gps_ac_yes, SIGNAL(clicked()), this, SLOT(set_ac_yes()) );
- connect(gps_ac_not, SIGNAL(clicked()), this, SLOT(set_ac_not()) );
-
- // gui
- layout_gui = new QVBoxLayout();
- layout_gui->addLayout(layout_row1);
- layout_gui->addLayout(layout_row2);
- layout_gui->addLayout(layout_row3);
- layout_gui->addLayout(layout_row4);
- layout_gui->addLayout(layout_row5);
-
- setLayout(layout_gui);
- latitude.getAccess();
-}
-
+++ /dev/null
-#ifndef LATITUDEGUI_H
-#define LATITUDEGUI_H
-
-#include <QtGui/QWidget>
-#include <QtGui/QPushButton>
-#include <QtGui/QLabel>
-#include <QtGui/QButtonGroup>
-#include <QtGui/QRadioButton>
-#include <QtGui/QSlider>
-#include <QtGui/QVBoxLayout>
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QDesktopServices>
-#include <QtCore/QProcess>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QDir>
-#include <QtCore/QFile>
-#include "googlelatitude.h"
-#include "gpscontrol.h"
-
-class LatitudeGUI : public QWidget {
- Q_OBJECT
-public:
- LatitudeGUI(QWidget *parent = 0);
-
-signals:
-
-public slots:
-
-private slots:
- void gl_GotToken() {
- qDebug() << "* LatitudeGUI::gl_GotToken";
- do_oauth->setDisabled(true);
- if (system("killall -0 latituded 2> /dev/null" )) {
- do_start->setEnabled(true);
- do_stop->setDisabled(true);
- } else {
- do_start->setDisabled(true);
- do_stop->setEnabled(true);
- }
- }
- void gl_NotToken() {
- qDebug() << "* LatitudeGUI::gl_NotToken";
- do_oauth->setEnabled(true);
- do_start->setDisabled(true);
- do_stop->setDisabled(true);
- gps.stopUpdates(true);
- }
- void gl_needAuth() {
- qDebug() << "* LatitudeGUI::gl_needAuth";
- do_oauth->setEnabled(true);
- }
- void gl_webauth() {
- qDebug() << "* LatitudeGUI::gl_webauth";
- QDesktopServices::openUrl(latitude.getUserAuthorization());
- }
- void gps_start() {
- qDebug() << "* LatitudeGUI::gps_start";
- do_start->setDisabled(true);
- do_stop->setEnabled(true);
- if (demonio.exists()) {
- qDebug() << "* LatitudeGUI:: demonio";
- cli.startDetached(demonio.fileName());
- return;
- }
- qDebug() << "* LatitudeGUI:: demonio none";
- gps.startUpdates();
- }
- void gps_stop() {
- qDebug() << "* LatitudeGUI::gps_stop";
- do_start->setEnabled(true);
- do_stop->setDisabled(true);
- if (demonio.exists()) {
- qDebug() << "* LatitudeGUI:: demonio kill" << system("killall latituded 2> /dev/null");
- } else {
- gps.stopUpdates(true);
- }
- }
- void set_latitude() {
- qDebug() << "* LatitudeGUI::set_latitude";
- latitude.setCurrentLocation(gps.getCurrentLatitude(),
- gps.getCurrentLongitude(),
- gps.getCurrentAccuracy());
- latitude.sendCurrentLocation();
- }
- void set_method() {
- qDebug() << "* LatitudeGUI::set_method";
- if (gps_cell->isChecked()) gps.setPositioningMethod("cell");
- if (gps_both->isChecked()) gps.setPositioningMethod("all");
- if (gps_agps->isChecked()) gps.setPositioningMethod("gps");
- }
- void set_to(int value) {
- qDebug() << "* LatitudeGUI::set_to()" << value;
- gps.setTimeOut(value);
- gps_to_slider_value->setText(QString("%1 sec.").arg(value));
-
- }
- void set_i(int value) {
- qDebug() << "* LatitudeGUI::set_i()" << value;
- gps.setInterval(value*60);
- gps_i_slider_value->setText(QString("%1 min.").arg(value));
- }
- void set_ac_yes() {
- qDebug() << "* LatitudeGUI::set_ac_yes";
- latitude.setAutoConnect(true);
- }
- void set_ac_not() {
- qDebug() << "* LatitudeGUI::set_ac_not";
- latitude.setAutoConnect(false);
- }
-
-private:
- GoogleLatitude latitude;
- GpsControl gps;
- QFile demonio;
- QProcess cli;
-
- QHBoxLayout *layout_row1;
- QPushButton *do_oauth;
- QPushButton *do_start;
- QPushButton *do_stop;
-
- QHBoxLayout *layout_row2;
- QLabel *gps_method;
- QButtonGroup *gps_group;
- QRadioButton *gps_cell;
- QRadioButton *gps_both;
- QRadioButton *gps_agps;
-
- QHBoxLayout *layout_row3;
- QLabel *gps_to_label;
- QSlider *gps_to_slider;
- QLabel *gps_to_slider_value;
-
- QHBoxLayout *layout_row4;
- QLabel *gps_i_label;
- QSlider *gps_i_slider;
- QLabel *gps_i_slider_value;
-
- QHBoxLayout *layout_row5;
- QLabel *gps_ac_label;
- QButtonGroup *gps_ac_group;
- QRadioButton *gps_ac_yes;
- QRadioButton *gps_ac_not;
-
- QVBoxLayout *layout_gui;
-};
-
-#endif // LATITUDEGUI_H
-
+++ /dev/null
-#include "daemon.h"
-
-LatitudeDaemon::LatitudeDaemon(QObject *parent) :
- QObject(parent),
- latitude(this),
- gps(this) {
- qDebug() << "* LatitudeDaemon::LatitudeDaemon";
-
- connect(&latitude, SIGNAL(gotToken()), this, SLOT(gl_GotToken()) );
- connect(&latitude, SIGNAL(notToken()), this, SLOT(gl_NotToken()) );
- connect(&latitude, SIGNAL(needAuth()), this, SLOT(gl_needAuth()) );
-
- connect(&gps, SIGNAL(gotUpdate()), this, SLOT(get_gps()) );
- connect(&gps, SIGNAL(gotFix()), this, SLOT(set_latitude()) );
-
- latitude.getAccess();
-}
+++ /dev/null
-#ifndef LATITUDEDAEMON_H
-#define LATITUDEDAEMON_H
-
-#include <QObject>
-#include <QtCore/QCoreApplication>
-#include "googlelatitude.h"
-#include "gpscontrol.h"
-
-class LatitudeDaemon : public QObject {
- Q_OBJECT
-public:
- LatitudeDaemon(QObject *parent = 0);
-signals:
-
-public slots:
-
-private slots:
- void gl_GotToken() {
- qDebug() << "LatitudeDaemon::gl_GotToken()";
- gps.startUpdates();
- }
- void gl_NotToken() {
- qDebug() << "LatitudeDaemon::gl_NotToken()";
- QCoreApplication::exit();
- }
- void gl_needAuth() {
- qDebug() << "LatitudeDaemon::gl_needAuth()";
- QCoreApplication::exit();
- }
- void get_gps() {
- qDebug() << "LatitudeDaemon::get_gps()"
- << gps.getCurrentLatitude()
- << gps.getCurrentLongitude()
- << gps.getCurrentAccuracy()
- << gps.getCurrentTimestamp();
- }
- void set_latitude() {
- qDebug() << "LatitudeDaemon::set_latitude()"
- << gps.getCurrentLatitude()
- << gps.getCurrentLongitude()
- << gps.getCurrentAccuracy()
- << gps.getCurrentTimestamp();
- latitude.setCurrentLocation(gps.getCurrentLatitude(),
- gps.getCurrentLongitude(),
- gps.getCurrentAccuracy());
- latitude.sendCurrentLocation();
- }
-
-private:
- GoogleLatitude latitude;
- GpsControl gps;
-};
-
-#endif // LATITUDEDAEMON_H
+++ /dev/null
-#
-# Example 3rd party application startup script.
-#
-# Install the startup script to /etc/init/apps.
-#
-# Applications are started after official stuff is done.
-#
-# The name of the script has to be unique, suffix .conf is mandatory.
-#
-# Applications are started in alphabetical order; note that
-# 3rd party applications are not run in malfunction state.
-#
-# Only these tags ("stanzas") are allowed.
-#
-# During installation, application can be started by issuing command
-# "start apps/myapp" in post-install script. Note that suffix .conf is
-# not allowed.
-#
-# If your app does not get started, run command /etc/init/xsession/app-precheck.sh
-
-description "Google Latitude Updater"
-author "rodrigo@linfati.cl"
-
-stop on stopping xsession
-
-console none
-
-# respawn
-# respawn limit 3 30
-# nice 2
-# normal exit 0
-
-exec /usr/bin/aegis-exec -s -u user -l "/opt/linfati.com/bin/latituded --init"
-
+++ /dev/null
-TEMPLATE = app
-TARGET = latituded
-
-QT += network
-CONFIG += mobility
-MOBILITY += location
-
-INCLUDEPATH += ../liblatitudeupdater
-INCLUDEPATH += ../libkqoauth
-
-LIBS += ../liblatitudeupdater/liblatitudeupdater.a
-LIBS += ../libkqoauth/libkqoauth.a
-
-HEADERS += daemon.h
-SOURCES += daemon.cpp main.cpp
-
-OTHER_FILES += latituded.conf
-
-launcher.files = latituded.conf
-launcher.path = /etc/init/apps/
-INSTALLS += launcher
-
-include(../deployment.pri)
-qtcAddDeployment()
+++ /dev/null
-#include <QtCore/QCoreApplication>
-#include <QtCore/QStringList>
-#include "daemon.h"
-
-int main(int argc, char *argv[]) {
- qDebug() << "* Main Daemon";
- QCoreApplication::setOrganizationName("linfati.com");
- QCoreApplication::setOrganizationDomain("linfati.com");
- QCoreApplication::setApplicationName("latitudeupdater");
-
- QCoreApplication lu(argc, argv);
- LatitudeDaemon mygui;
-
- Q_UNUSED(mygui)
-
- if ( lu.arguments().contains(QString("--init")) ) {
- QSettings set;
- if ( ! set.value("daemon",false).toBool() ) {
- qDebug() << "No Daemon mode enable";
- return 0;
- }
- }
-
- return lu.exec();
-}
+++ /dev/null
-TEMPLATE = subdirs
-CONFIG += ordered
-
-SUBDIRS = \
- liblocationmaemo5 \
- libkqoauth \
- liblatitudeupdater \
- latituded \
- latitude.qt \
- latitude.qml
-
-contains(QT_CONFIG, maemo5): message(Maemo5)
-contains(MEEGO_EDITION,harmattan): message(Maemo6)
-linux-g++-maemo:!contains(MEEGO_EDITION,harmattan): {
- MEEGO_VERSION_MAJOR = 1
- MEEGO_VERSION_MINOR = 2
- MEEGO_VERSION_PATCH = 0
- MEEGO_EDITION = harmattan
- DEFINES += MEEGO_EDITION_HARMATTAN
- message(Maemo6-beta)
-}
-
-include(deployment.pri)
-qtcAddDeployment()
-
-OTHER_FILES += \
- qtc_packaging/debian_harmattan/rules \
- qtc_packaging/debian_harmattan/rules.real \
- qtc_packaging/debian_harmattan/README \
- qtc_packaging/debian_harmattan/copyright \
- qtc_packaging/debian_harmattan/control \
- qtc_packaging/debian_harmattan/compat \
- qtc_packaging/debian_harmattan/changelog \
- qtc_packaging/debian_harmattan/latitudeupdater.aegis \
- qtc_packaging/debian_harmattan/latitudeupdater.postinst \
- qtc_packaging/debian_harmattan/latitudeupdater.prerm \
- qtc_packaging/debian_fremantle/rules \
- qtc_packaging/debian_fremantle/rules.real \
- qtc_packaging/debian_fremantle/README \
- qtc_packaging/debian_fremantle/copyright \
- qtc_packaging/debian_fremantle/control \
- qtc_packaging/debian_fremantle/compat \
- qtc_packaging/debian_fremantle/changelog
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=LatitudeUpdater
-Exec=/opt/linfati.com/bin/latitude.qt
-Icon=latitudeupdater64
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=false
-Name=LatitudeUpdater
-Exec=/usr/bin/invoker --single-instance --type=e /opt/linfati.com/bin/latitude.qml
-Icon=/usr/share/icons/hicolor/80x80/apps/latitudeupdater80.png
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
+++ /dev/null
-#include "kqoauthrequest.h"
-#include "kqoauthrequest_1.h"
-#include "kqoauthrequest_xauth.h"
-#include "kqoauthmanager.h"
-#include "kqoauthglobals.h"
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <QTcpSocket>
-#include <QStringList>
-#include <QUrl>
-
-#include "kqoauthauthreplyserver.h"
-#include "kqoauthauthreplyserver_p.h"
-
-KQOAuthAuthReplyServerPrivate::KQOAuthAuthReplyServerPrivate(KQOAuthAuthReplyServer *parent):
- q_ptr(parent)
-{
-
-}
-
-KQOAuthAuthReplyServerPrivate::~KQOAuthAuthReplyServerPrivate()
-{
-
-}
-
-void KQOAuthAuthReplyServerPrivate::onIncomingConnection() {
- Q_Q(KQOAuthAuthReplyServer);
-
- socket = q->nextPendingConnection();
- connect(socket, SIGNAL(readyRead()),
- this, SLOT(onBytesReady()), Qt::UniqueConnection);
-}
-
-void KQOAuthAuthReplyServerPrivate::onBytesReady() {
- Q_Q(KQOAuthAuthReplyServer);
-
- QByteArray reply;
- QByteArray content;
- content.append("<HTML></HTML>");
-
- reply.append("HTTP/1.0 200 OK \r\n");
- reply.append("Content-Type: text/html; charset=\"utf-8\"\r\n");
- reply.append(QString("Content-Length: %1\r\n").arg(content.size()));
- reply.append("\r\n");
- reply.append(content);
- socket->write(reply);
-
- QByteArray data = socket->readAll();
- QMultiMap<QString, QString> queryParams = parseQueryParams(&data);
-
- socket->disconnectFromHost();
- q->close();
- emit q->verificationReceived(queryParams);
-}
-
-QMultiMap<QString, QString> KQOAuthAuthReplyServerPrivate::parseQueryParams(QByteArray *data) {
- QString splitGetLine = QString(*data).split("\r\n").first(); // Retrieve the first line with query params.
- splitGetLine.remove("GET "); // Clean the line from GET
- splitGetLine.remove("HTTP/1.1"); // From HTTP
- splitGetLine.remove("\r\n"); // And from rest.
- splitGetLine.prepend("http://localhost"); // Now, make it a URL
-
- QUrl getTokenUrl(splitGetLine);
- QList< QPair<QString, QString> > tokens = getTokenUrl.queryItems(); // Ask QUrl to do our work.
-
- QMultiMap<QString, QString> queryParams;
- QPair<QString, QString> tokenPair;
- foreach (tokenPair, tokens) {
- queryParams.insert(tokenPair.first.trimmed(), tokenPair.second.trimmed());
- }
-
- return queryParams;
-}
-
-
-
-KQOAuthAuthReplyServer::KQOAuthAuthReplyServer(QObject *parent) :
- QTcpServer(parent),
- d_ptr( new KQOAuthAuthReplyServerPrivate(this) )
-{
- Q_D(KQOAuthAuthReplyServer);
-
- connect(this, SIGNAL(newConnection()),
- d, SLOT(onIncomingConnection()));
-}
-
-KQOAuthAuthReplyServer::~KQOAuthAuthReplyServer()
-{
- delete d_ptr;
-}
-
-
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHAUTHREPLYSERVER_H
-#define KQOAUTHAUTHREPLYSERVER_H
-
-#include <QTcpServer>
-
-#include "kqoauthglobals.h"
-
-class KQOAuthAuthReplyServerPrivate;
-class KQOAUTH_EXPORT KQOAuthAuthReplyServer : public QTcpServer
-{
- Q_OBJECT
-public:
- explicit KQOAuthAuthReplyServer(QObject *parent);
- ~KQOAuthAuthReplyServer();
-
-Q_SIGNALS:
- void verificationReceived(QMultiMap<QString, QString>);
-
-
-private:
- KQOAuthAuthReplyServerPrivate * const d_ptr;
- Q_DECLARE_PRIVATE(KQOAuthAuthReplyServer);
- Q_DISABLE_COPY(KQOAuthAuthReplyServer);
-
-
-};
-
-#endif // KQOAUTHAUTHREPLYSERVER_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-// Note this class shouldn't be copied or used and the implementation might change later.
-#ifndef KQOAUTHAUTHREPLYSERVER_P_H
-#define KQOAUTHAUTHREPLYSERVER_P_H
-
-#include "kqoauthauthreplyserver.h"
-#include <QMultiMap>
-#include <QString>
-
-class KQOAUTH_EXPORT KQOAuthAuthReplyServerPrivate: public QObject
-{
- Q_OBJECT
-public:
- KQOAuthAuthReplyServerPrivate( KQOAuthAuthReplyServer * parent );
- ~KQOAuthAuthReplyServerPrivate();
- QMultiMap<QString, QString> parseQueryParams(QByteArray *sdata);
-
-public Q_SLOTS:
- void onIncomingConnection();
- void onBytesReady();
-
-public:
- KQOAuthAuthReplyServer * q_ptr;
- Q_DECLARE_PUBLIC(KQOAuthAuthReplyServer);
- QTcpSocket *socket;
-
-};
-
-#endif // KQOAUTHAUTHREPLYSERVER_P_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHGLOBALS_H
-#define KQOAUTHGLOBALS_H
-
-#include <QtCore/qglobal.h>
-
-#if defined(KQOAUTH)
-# define KQOAUTH_EXPORT Q_DECL_EXPORT
-#else
-# define KQOAUTH_EXPORT Q_DECL_IMPORT
-#endif
-
-//////////// Static constant definitions ///////////
-const QString OAUTH_KEY_CONSUMER("oauth_consumer");
-const QString OAUTH_KEY_CONSUMER_KEY("oauth_consumer_key");
-const QString OAUTH_KEY_TOKEN("oauth_token");
-const QString OAUTH_KEY_TOKEN_SECRET("oauth_token_secret");
-const QString OAUTH_KEY_SIGNATURE_METHOD("oauth_signature_method");
-const QString OAUTH_KEY_TIMESTAMP("oauth_timestamp");
-const QString OAUTH_KEY_NONCE("oauth_nonce");
-const QString OAUTH_KEY_SIGNATURE("oauth_signature");
-const QString OAUTH_KEY_CALLBACK("oauth_callback");
-const QString OAUTH_KEY_VERIFIER("oauth_verifier");
-const QString OAUTH_KEY_VERSION("oauth_version");
-
-#endif // KQOAUTHGLOBALS_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <QtCore>
-
-#include "kqoauthmanager.h"
-#include "kqoauthmanager_p.h"
-
-
-////////////// Private d_ptr implementation ////////////////
-
-KQOAuthManagerPrivate::KQOAuthManagerPrivate(KQOAuthManager *parent) :
- error(KQOAuthManager::NoError) ,
- r(0) ,
- opaqueRequest(new KQOAuthRequest) ,
- q_ptr(parent) ,
- callbackServer(new KQOAuthAuthReplyServer(parent)) ,
- isVerified(false) ,
- isAuthorized(false) ,
- autoAuth(false),
- networkManager(new QNetworkAccessManager),
- managerUserSet(false)
-{
-
-}
-
-KQOAuthManagerPrivate::~KQOAuthManagerPrivate() {
- delete opaqueRequest;
- opaqueRequest = 0;
-
- if (!managerUserSet) {
- delete networkManager;
- networkManager = 0;
- }
-}
-
-QList< QPair<QString, QString> > KQOAuthManagerPrivate::createQueryParams(const KQOAuthParameters &requestParams) {
- QList<QString> requestKeys = requestParams.keys();
- QList<QString> requestValues = requestParams.values();
-
- QList< QPair<QString, QString> > result;
- for(int i=0; i<requestKeys.size(); i++) {
- result.append( qMakePair(requestKeys.at(i),
- requestValues.at(i))
- );
- }
-
- return result;
-}
-
-QMultiMap<QString, QString> KQOAuthManagerPrivate::createTokensFromResponse(QByteArray reply) {
- QMultiMap<QString, QString> result;
- QString replyString(reply);
-
- QStringList parameterPairs = replyString.split('&', QString::SkipEmptyParts);
- foreach (const QString ¶meterPair, parameterPairs) {
- QStringList parameter = parameterPair.split('=');
- result.insert(parameter.value(0), parameter.value(1));
- }
-
- return result;
-}
-
-bool KQOAuthManagerPrivate::setSuccessfulRequestToken(const QMultiMap<QString, QString> &request) {
- if (currentRequestType == KQOAuthRequest::TemporaryCredentials) {
- hasTemporaryToken = (!QString(request.value("oauth_token")).isEmpty() && !QString(request.value("oauth_token_secret")).isEmpty());
- } else {
- return false;
- }
-
- if (hasTemporaryToken) {
- requestToken = QUrl::fromPercentEncoding( QString(request.value("oauth_token")).toLocal8Bit() );
- requestTokenSecret = QUrl::fromPercentEncoding( QString(request.value("oauth_token_secret")).toLocal8Bit() );
- }
-
- return hasTemporaryToken;
-}
-
-bool KQOAuthManagerPrivate::setSuccessfulAuthorized(const QMultiMap<QString, QString> &request ) {
- if (currentRequestType == KQOAuthRequest::AccessToken) {
- isAuthorized = (!QString(request.value("oauth_token")).isEmpty() && !QString(request.value("oauth_token_secret")).isEmpty());
- } else {
- return false;
- }
-
- if (isAuthorized) {
- requestToken = QUrl::fromPercentEncoding( QString(request.value("oauth_token")).toLocal8Bit() );
- requestTokenSecret = QUrl::fromPercentEncoding( QString(request.value("oauth_token_secret")).toLocal8Bit() );
- }
-
- return isAuthorized;
-}
-
-void KQOAuthManagerPrivate::emitTokens() {
- Q_Q(KQOAuthManager);
-
- if (this->requestToken.isEmpty() || this->requestTokenSecret.isEmpty()) {
- error = KQOAuthManager::RequestUnauthorized;
- }
-
- if (currentRequestType == KQOAuthRequest::TemporaryCredentials) {
- // Signal that we are ready to use the protected resources.
- emit q->temporaryTokenReceived(this->requestToken, this->requestTokenSecret);
- }
-
- if (currentRequestType == KQOAuthRequest::AccessToken) {
- // Signal that we are ready to use the protected resources.
- emit q->accessTokenReceived(this->requestToken, this->requestTokenSecret);
- }
-
- emit q->receivedToken(this->requestToken, this->requestTokenSecret);
-}
-
-bool KQOAuthManagerPrivate::setupCallbackServer() {
- return callbackServer->listen();
-}
-
-
-/////////////// Public implementation ////////////////
-
-KQOAuthManager::KQOAuthManager(QObject *parent) :
- QObject(parent) ,
- d_ptr(new KQOAuthManagerPrivate(this))
-{
-
-}
-
-KQOAuthManager::~KQOAuthManager()
-{
- delete d_ptr;
-}
-
-void KQOAuthManager::executeRequest(KQOAuthRequest *request) {
- Q_D(KQOAuthManager);
-
- d->r = request;
-
- if (request == 0) {
- qWarning() << "Request is NULL. Cannot proceed.";
- d->error = KQOAuthManager::RequestError;
- return;
- }
-
- if (!request->requestEndpoint().isValid()) {
- qWarning() << "Request endpoint URL is not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestEndpointError;
- return;
- }
-
- if (!request->isValid()) {
- qWarning() << "Request is not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestValidationError;
- return;
- }
-
- d->currentRequestType = request->requestType();
-
- QNetworkRequest networkRequest;
- networkRequest.setUrl( request->requestEndpoint() );
-
- if (d->autoAuth && d->currentRequestType == KQOAuthRequest::TemporaryCredentials) {
- d->setupCallbackServer();
- connect(d->callbackServer, SIGNAL(verificationReceived(QMultiMap<QString, QString>)),
- this, SLOT( onVerificationReceived(QMultiMap<QString, QString>)));
-
- QString serverString = "http://localhost:";
- serverString.append(QString::number(d->callbackServer->serverPort()));
- request->setCallbackUrl(QUrl(serverString));
- }
-
- // And now fill the request with "Authorization" header data.
- QList<QByteArray> requestHeaders = request->requestParameters();
- QByteArray authHeader;
-
- bool first = true;
- foreach (const QByteArray header, requestHeaders) {
- if (!first) {
- authHeader.append(", ");
- } else {
- authHeader.append("OAuth ");
- first = false;
- }
-
- authHeader.append(header);
- }
- networkRequest.setRawHeader("Authorization", authHeader);
-
- connect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
- this, SLOT(onRequestReplyReceived(QNetworkReply *)), Qt::UniqueConnection);
- disconnect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
- this, SLOT(onAuthorizedRequestReplyReceived(QNetworkReply *)));
-
- if (request->httpMethod() == KQOAuthRequest::GET) {
- // Get the requested additional params as a list of pairs we can give QUrl
- QList< QPair<QString, QString> > urlParams = d->createQueryParams(request->additionalParameters());
-
- // Take the original URL and append the query params to it.
- QUrl urlWithParams = networkRequest.url();
- urlWithParams.setQueryItems(urlParams);
- networkRequest.setUrl(urlWithParams);
-
- // Submit the request including the params.
- QNetworkReply *reply = d->networkManager->get(networkRequest);
- connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(slotError(QNetworkReply::NetworkError)));
-
- } else if (request->httpMethod() == KQOAuthRequest::POST) {
-
- networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
-
- qDebug() << networkRequest.rawHeaderList();
- qDebug() << networkRequest.rawHeader("Authorization");
- qDebug() << networkRequest.rawHeader("Content-Type");
-
- QNetworkReply *reply;
- if (request->contentType() == "application/x-www-form-urlencoded") {
- reply = d->networkManager->post(networkRequest, request->requestBody());
- } else {
- reply = d->networkManager->post(networkRequest, request->rawData());
- }
-
- connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(slotError(QNetworkReply::NetworkError)));
- }
-
- d->r->requestTimerStart();
-}
-
-void KQOAuthManager::executeAuthorizedRequest(KQOAuthRequest *request, int id) {
- Q_D(KQOAuthManager);
-
- d->r = request;
-
- if (request == 0) {
- qWarning() << "Request is NULL. Cannot proceed.";
- d->error = KQOAuthManager::RequestError;
- return;
- }
-
- if (!request->requestEndpoint().isValid()) {
- qWarning() << "Request endpoint URL is not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestEndpointError;
- return;
- }
-
- if (!request->isValid()) {
- qWarning() << "Request is not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestValidationError;
- return;
- }
-
- d->currentRequestType = request->requestType();
-
- QNetworkRequest networkRequest;
- networkRequest.setUrl( request->requestEndpoint() );
-
- if ( d->currentRequestType != KQOAuthRequest::AuthorizedRequest){
- qWarning() << "Not Authorized Request. Cannot proceed";
- d->error = KQOAuthManager::RequestError;
- return;
- }
-
-
- // And now fill the request with "Authorization" header data.
- QList<QByteArray> requestHeaders = request->requestParameters();
- QByteArray authHeader;
-
- bool first = true;
- foreach (const QByteArray header, requestHeaders) {
- if (!first) {
- authHeader.append(", ");
- } else {
- authHeader.append("OAuth ");
- first = false;
- }
-
- authHeader.append(header);
- }
- networkRequest.setRawHeader("Authorization", authHeader);
-
-
- disconnect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
- this, SLOT(onRequestReplyReceived(QNetworkReply *)));
- connect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
- this, SLOT(onAuthorizedRequestReplyReceived(QNetworkReply*)), Qt::UniqueConnection);
-
- if (request->httpMethod() == KQOAuthRequest::GET) {
- // Get the requested additional params as a list of pairs we can give QUrl
- QList< QPair<QString, QString> > urlParams = d->createQueryParams(request->additionalParameters());
-
- // Take the original URL and append the query params to it.
- QUrl urlWithParams = networkRequest.url();
- urlWithParams.setQueryItems(urlParams);
- networkRequest.setUrl(urlWithParams);
-
- // Submit the request including the params.
- QNetworkReply *reply = d->networkManager->get(networkRequest);
- connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(slotError(QNetworkReply::NetworkError)));
-
- } else if (request->httpMethod() == KQOAuthRequest::POST) {
-
- networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, request->contentType());
-
- /*
- qDebug() << networkRequest.rawHeaderList();
- qDebug() << networkRequest.rawHeader("Authorization");
- qDebug() << networkRequest.rawHeader("Content-Type");
- */
- QNetworkReply *reply;
- if (request->contentType() == "application/x-www-form-urlencoded") {
- reply = d->networkManager->post(networkRequest, request->requestBody());
- } else {
- reply = d->networkManager->post(networkRequest, request->rawData());
- }
-
- d->requestIds.insert(reply, id);
-
- connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(slotError(QNetworkReply::NetworkError)));
- }
-
- d->r->requestTimerStart();
-}
-
-
-void KQOAuthManager::setHandleUserAuthorization(bool set) {
- Q_D(KQOAuthManager);
-
- d->autoAuth = set;
-}
-
-bool KQOAuthManager::hasTemporaryToken() {
- Q_D(KQOAuthManager);
-
- return d->hasTemporaryToken;
-}
-
-bool KQOAuthManager::isVerified() {
- Q_D(KQOAuthManager);
-
- return d->isVerified;
-}
-
-bool KQOAuthManager::isAuthorized() {
- Q_D(KQOAuthManager);
-
- return d->isAuthorized;
-}
-
-KQOAuthManager::KQOAuthError KQOAuthManager::lastError() {
- Q_D(KQOAuthManager);
-
- return d->error;
-}
-
-void KQOAuthManager::setNetworkManager(QNetworkAccessManager *manager) {
- Q_D(KQOAuthManager);
-
- if (manager == 0) {
- d->error = KQOAuthManager::ManagerError;
- return;
- }
-
- if (!d->managerUserSet) {
- delete d->networkManager;
- }
-
- d->managerUserSet = true;
- d->networkManager = manager;
-}
-
-QNetworkAccessManager * KQOAuthManager::networkManager() const {
- Q_D(const KQOAuthManager);
-
- if (d->managerUserSet) {
- return d->networkManager;
- } else {
- return NULL;
- }
-
-}
-
-
-//////////// Public convenience API /////////////
-
-QUrl KQOAuthManager::getUserAuthorization(QUrl authorizationEndpoint) {
- Q_D(KQOAuthManager);
-
- if (!d->hasTemporaryToken) {
- qWarning() << "No temporary tokens retreieved. Cannot get user authorization.";
- d->error = KQOAuthManager::RequestUnauthorized;
- return QString();
- }
-
- if (!authorizationEndpoint.isValid()) {
- qWarning() << "Authorization endpoint not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestEndpointError;
- return QString();
- }
-
- d->error = KQOAuthManager::NoError;
-
- QPair<QString, QString> tokenParam = qMakePair(QString("oauth_token"), QString(d->requestToken));
- QUrl openWebPageUrl(authorizationEndpoint.toString(), QUrl::StrictMode);
- openWebPageUrl.addQueryItem(tokenParam.first, tokenParam.second);
-
- // Return the resource authorization page provided by the service.
- qDebug() << "KQOAuthManager::getUserAuthorization " << openWebPageUrl;
- return openWebPageUrl;
-}
-
-void KQOAuthManager::getUserAccessTokens(QUrl accessTokenEndpoint) {
- Q_D(KQOAuthManager);
-
- if (!d->isVerified) {
- qWarning() << "Not verified. Cannot get access tokens.";
- d->error = KQOAuthManager::RequestUnauthorized;
- return;
- }
-
- if (!accessTokenEndpoint.isValid()) {
- qWarning() << "Endpoint for access token exchange is not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestEndpointError;
- return;
- }
-
- d->error = KQOAuthManager::NoError;
-
- d->opaqueRequest->clearRequest();
- d->opaqueRequest->initRequest(KQOAuthRequest::AccessToken, accessTokenEndpoint);
- d->opaqueRequest->setToken(d->requestToken);
- d->opaqueRequest->setTokenSecret(d->requestTokenSecret);
- d->opaqueRequest->setVerifier(d->requestVerifier);
- d->opaqueRequest->setConsumerKey(d->consumerKey);
- d->opaqueRequest->setConsumerSecretKey(d->consumerKeySecret);
-
- executeRequest(d->opaqueRequest);
-}
-
-void KQOAuthManager::sendAuthorizedRequest(QUrl requestEndpoint, const KQOAuthParameters &requestParameters) {
- Q_D(KQOAuthManager);
-
- if (!d->isAuthorized) {
- qWarning() << "No access tokens retrieved. Cannot send authorized requests.";
- d->error = KQOAuthManager::RequestUnauthorized;
- return;
- }
-
- if (!requestEndpoint.isValid()) {
- qWarning() << "Endpoint for authorized request is not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestEndpointError;
- return;
- }
-
- d->error = KQOAuthManager::NoError;
-
- d->opaqueRequest->clearRequest();
- d->opaqueRequest->initRequest(KQOAuthRequest::AuthorizedRequest, requestEndpoint);
- d->opaqueRequest->setAdditionalParameters(requestParameters);
- d->opaqueRequest->setToken(d->requestToken);
- d->opaqueRequest->setTokenSecret(d->requestTokenSecret);
- d->opaqueRequest->setConsumerKey(d->consumerKey);
- d->opaqueRequest->setConsumerSecretKey(d->consumerKeySecret);
-
- executeRequest(d->opaqueRequest);
-}
-
-
-/////////////// Private slots //////////////////
-
-void KQOAuthManager::onRequestReplyReceived( QNetworkReply *reply ) {
- Q_D(KQOAuthManager);
-
- QNetworkReply::NetworkError networkError = reply->error();
- switch (networkError) {
- case QNetworkReply::NoError:
- d->error = KQOAuthManager::NoError;
- break;
-
- case QNetworkReply::ContentAccessDenied:
- case QNetworkReply::AuthenticationRequiredError:
- d->error = KQOAuthManager::RequestUnauthorized;
- break;
-
- default:
- d->error = KQOAuthManager::NetworkError;
- break;
- }
-
- // Let's disconnect this slot first
- /*
- disconnect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
- this, SLOT(onRequestReplyReceived(QNetworkReply *)));
- */
-
- // Read the content of the reply from the network.
- QByteArray networkReply = reply->readAll();
-
- // Stop any timer we have set on the request.
- d->r->requestTimerStop();
-
- // Just don't do anything if we didn't get anything useful.
- if(networkReply.isEmpty()) {
- reply->deleteLater();
- return;
- }
- QMultiMap<QString, QString> responseTokens;
-
- // We need to emit the signal even if we got an error.
- if (d->error != KQOAuthManager::NoError) {
- reply->deleteLater();
- emit requestReady(networkReply);
- d->emitTokens();
- return;
- }
-
- responseTokens = d->createTokensFromResponse(networkReply);
- d->opaqueRequest->clearRequest();
- d->opaqueRequest->setHttpMethod(KQOAuthRequest::POST); // XXX FIXME: Convenient API does not support GET
- if (!d->isAuthorized || !d->isVerified) {
- if (d->setSuccessfulRequestToken(responseTokens)) {
- qDebug() << "Successfully got request tokens.";
- d->consumerKey = d->r->consumerKeyForManager();
- d->consumerKeySecret = d->r->consumerKeySecretForManager();
- d->opaqueRequest->setSignatureMethod(KQOAuthRequest::HMAC_SHA1);
- d->opaqueRequest->setCallbackUrl(d->r->callbackUrlForManager());
-
- d->emitTokens();
-
- } else if (d->setSuccessfulAuthorized(responseTokens)) {
- qDebug() << "Successfully got access tokens.";
- d->opaqueRequest->setSignatureMethod(KQOAuthRequest::HMAC_SHA1);
-
- d->emitTokens();
- } else if (d->currentRequestType == KQOAuthRequest::AuthorizedRequest) {
- emit authorizedRequestDone();
- }
- }
-
- emit requestReady(networkReply);
-
- reply->deleteLater(); // We need to clean this up, after the event processing is done.
-}
-
-void KQOAuthManager::onAuthorizedRequestReplyReceived( QNetworkReply *reply ) {
- Q_D(KQOAuthManager);
-
- QNetworkReply::NetworkError networkError = reply->error();
- switch (networkError) {
- case QNetworkReply::NoError:
- d->error = KQOAuthManager::NoError;
- break;
-
- case QNetworkReply::ContentAccessDenied:
- case QNetworkReply::AuthenticationRequiredError:
- d->error = KQOAuthManager::RequestUnauthorized;
- break;
-
- default:
- d->error = KQOAuthManager::NetworkError;
- break;
- }
-
- /*
- disconnect(d->networkManager, SIGNAL(finished(QNetworkReply *)),
- this, SLOT(onAuthorizedRequestReplyReceived(QNetworkReply *)));
- */
-
- // Read the content of the reply from the network.
- QByteArray networkReply = reply->readAll();
-
- // Stop any timer we have set on the request.
- d->r->requestTimerStop();
-
- // Just don't do anything if we didn't get anything useful.
- if(networkReply.isEmpty()) {
- reply->deleteLater();
- return;
- }
-
- // We need to emit the signal even if we got an error.
- if (d->error != KQOAuthManager::NoError) {
- qWarning() << "Network reply error";
- return;
- }
-
-
- d->opaqueRequest->clearRequest();
- d->opaqueRequest->setHttpMethod(KQOAuthRequest::POST); // XXX FIXME: Convenient API does not support GET
- if (d->currentRequestType == KQOAuthRequest::AuthorizedRequest) {
- emit authorizedRequestDone();
- }
-
- int id = d->requestIds.take(reply);
- emit authorizedRequestReady(networkReply, id);
- reply->deleteLater();
-}
-
-
-void KQOAuthManager::onVerificationReceived(QMultiMap<QString, QString> response) {
- Q_D(KQOAuthManager);
-
- QString token = response.value("oauth_token");
- QString verifier = response.value("oauth_verifier");
- if (verifier.isEmpty()) {
- d->error = KQOAuthManager::RequestUnauthorized;
- }
-
- verifier = QUrl::fromPercentEncoding(verifier.toUtf8()); // We get the raw URL response here so we need to convert it back
- // to plain string so we can percent encode it again later in requests.
-
- if (d->error == KQOAuthManager::NoError) {
- d->requestVerifier = verifier;
- d->isVerified = true;
- }
-
- emit authorizationReceived(token, verifier);
-}
-
-void KQOAuthManager::slotError(QNetworkReply::NetworkError error) {
- Q_UNUSED(error)
- Q_D(KQOAuthManager);
-
- d->error = KQOAuthManager::NetworkError;
- QByteArray emptyResponse;
- emit requestReady(emptyResponse);
- emit authorizedRequestDone();
-
- QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
- d->requestIds.remove(reply);
- reply->deleteLater();
-}
-
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHMANAGER_H
-#define KQOAUTHMANAGER_H
-
-#include <QObject>
-#include <QMultiMap>
-#include <QNetworkReply>
-
-#include "kqoauthrequest.h"
-
-class KQOAuthRequest;
-class KQOAuthManagerThread;
-class KQOAuthManagerPrivate;
-class QNetworkAccessManager;
-class QUrl;
-class QByteArray;
-class KQOAUTH_EXPORT KQOAuthManager : public QObject
-{
- Q_OBJECT
-public:
-
- enum KQOAuthError {
- NoError, // No error
- NetworkError, // Network error: timeout, cannot connect.
- RequestEndpointError, // Request endpoint is not valid.
- RequestValidationError, // Request is not valid: some parameter missing?
- RequestUnauthorized, // Authorization error: trying to access a resource without tokens.
- RequestError, // The given request to KQOAuthManager is invalid: NULL?,
- ManagerError // Manager error, cannot use for sending requests.
- };
-
- explicit KQOAuthManager(QObject *parent = 0);
- ~KQOAuthManager();
-
- KQOAuthError lastError();
-
- /**
- * The manager executes the given request. It takes the HTTP parameters from the
- * request and uses QNetworkAccessManager to submit the HTTP request to the net.
- * When the request is done it will emit signal requestReady(QByteArray networkReply).
- * NOTE: At the moment there is no timeout for the request.
- */
- void executeRequest(KQOAuthRequest *request);
- void executeAuthorizedRequest(KQOAuthRequest *request, int id);
- /**
- * Indicates to the user that KQOAuthManager should handle user authorization by
- * opening the user's default browser and parsing the reply from the service.
- * By setting the parameter to true, KQOAuthManager will store intermediate results
- * of the OAuth 1.0 process in its own opaque request. This information is used in
- * the user authorization process and also when calling sendAuthorizedRequest().
- * NOTE: You need to set this to true if you want to use getUserAccessTokens() or
- * sendAuthorizedRequest().
- */
- void setHandleUserAuthorization(bool set);
-
- /**
- * Returns true if the KQOAuthManager has retrieved the oauth_token value. Otherwise
- * return false.
- */
- bool hasTemporaryToken();
- /**
- * Returns true if the user has authorized us to use the protected resources. Otherwise
- * returns false.
- * NOTE: In order for KQOAuthManager to know if the user has authorized us to use the
- * protected resources, KQOAuthManager must be in control of the user authorization
- * process. Hence, this returns true if setHandleUserAuthorization() is set to true
- * and the user is authorized with getUserAuthorization().
- */
- bool isVerified();
- /**
- * Returns true if KQOAuthManager has the access token and hence can access the protected
- * resources. Otherwise returns false.
- * NOTE: In order for KQOAuthManager to know if we have access to protected resource
- * KQOAuthManager must be in control of the user authorization process and requesting
- * the acess token. Hence, this returns true if setHandleUserAuthorization() is set to true
- * and the user is authorized with getUserAuthorization() and the access token must be retrieved
- * with getUserAccessTokens.
- */
- bool isAuthorized();
-
- /**
- * This is a convenience API for authorizing the user.
- * The call will open the user's default browser, setup a local HTTP server and parse the reply from the
- * service after the user has authorized us to access protected resources. If the user authorizes
- * us to access protected resources, the verifier token is stored in KQOAuthManager for further use.
- * In order to use this method, you must set setHandleUserAuthorization() to true.
- */
- QUrl getUserAuthorization(QUrl authorizationEndpoint);
- /**
- * This is a convenience API for retrieving the access token in exchange for the temporary token and the
- * verifier.
- * This call will create a KQOAuthRequest and use the previously stored temporary token and verifier to
- * exchange for the access token, which will be used to access the protected resources.
- * Note that in order to use this method, KQOAuthManager must be in control of the user authorization process.
- * Set setHandleUserAuthorization() to true and retrieve user authorization with void getUserAuthorization.
- */
- void getUserAccessTokens(QUrl accessTokenEndpoint);
- /**
- * Sends a request to the protected resources. Parameters for the request are service specific and
- * are given to the 'requestParameters' as parameters.
- * Note that in order to use this method, KQOAuthManager must be in control of the user authorization process.
- * Set setHandleUserAuthorization() to true and retrieve user authorization with void getUserAuthorization.
- */
- void sendAuthorizedRequest(QUrl requestEndpoint, const KQOAuthParameters &requestParameters);
-
- /**
- * Sets a custom QNetworkAccessManager to handle network requests. This method can be useful if the
- * application is using some proxy settings for example.
- * The application is responsible for deleting this manager. KQOAuthManager will not delete any
- * previously given manager.
- * If the manager is NULL, the manager will not be set and the KQOAuthManager::Error.
- * If no manager is given, KQOAuthManager will use the default one it will create by itself.
- */
- void setNetworkManager(QNetworkAccessManager *manager);
-
- /**
- * Returns the given QNetworkAccessManager. Returns NULL if none is given.
- */
- QNetworkAccessManager* networkManager() const;
-
-Q_SIGNALS:
- // This signal will be emitted after each request has got a reply.
- // Parameter is the raw response from the service.
- void requestReady(QByteArray networkReply);
-
- void authorizedRequestReady(QByteArray networkReply, int id);
-
- // This signal will be emited when we have an request tokens available
- // (either temporary resource tokens, or authorization tokens).
- void receivedToken(QString oauth_token, QString oauth_token_secret); // oauth_token, oauth_token_secret
-
- // This signal is emited when temporary tokens are returned from the service.
- // Note that this signal is also emited in case temporary tokens are not available.
- void temporaryTokenReceived(QString oauth_token, QString oauth_token_secret); // oauth_token, oauth_token_secret
-
- // This signal is emited when the user has authenticated the application to
- // communicate with the protected resources. Next we need to exchange the
- // temporary tokens for access tokens.
- // Note that this signal is also emited if user denies access.
- void authorizationReceived(QString oauth_token, QString oauth_verifier); // oauth_token, oauth_verifier
-
- // This signal is emited when access tokens are received from the service. We are
- // ready to start communicating with the protected resources.
- void accessTokenReceived(QString oauth_token, QString oauth_token_secret); // oauth_token, oauth_token_secret
-
- // This signal is emited when the authorized request is done.
- // This ends the kQOAuth interactions.
- void authorizedRequestDone();
-
-private Q_SLOTS:
- void onRequestReplyReceived( QNetworkReply *reply );
- void onAuthorizedRequestReplyReceived( QNetworkReply *reply );
- void onVerificationReceived(QMultiMap<QString, QString> response);
- void slotError(QNetworkReply::NetworkError error);
-
-private:
- KQOAuthManagerPrivate *d_ptr;
- Q_DECLARE_PRIVATE(KQOAuthManager);
- Q_DISABLE_COPY(KQOAuthManager);
-
-};
-
-#endif // KQOAUTHMANAGER_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHMANAGER_P_H
-#define KQOAUTHMANAGER_P_H
-
-#include "kqoauthauthreplyserver.h"
-#include "kqoauthrequest.h"
-
-class KQOAUTH_EXPORT KQOAuthManagerPrivate {
-
-public:
- KQOAuthManagerPrivate(KQOAuthManager *parent);
- ~KQOAuthManagerPrivate();
-
- QList< QPair<QString, QString> > createQueryParams(const KQOAuthParameters &requestParams);
- QMultiMap<QString, QString> createTokensFromResponse(QByteArray reply);
- bool setSuccessfulRequestToken(const QMultiMap<QString, QString> &request);
- bool setSuccessfulAuthorized(const QMultiMap<QString, QString> &request);
- void emitTokens();
- bool setupCallbackServer();
-
- KQOAuthManager::KQOAuthError error;
- KQOAuthRequest *r; // This request is used to cache the user sent request.
- KQOAuthRequest *opaqueRequest; // This request is used to creating opaque convenience requests for the user.
- KQOAuthManager * const q_ptr;
-
- /**
- * The items below are needed in order to store the state of the manager and
- * by that be able to do convenience operations for the user.
- */
- KQOAuthRequest::RequestType currentRequestType;
-
- // Variables we store here for opaque request handling.
- // NOTE: The variables are labeled the same for both access token request
- // and protected resource access.
- QString requestToken;
- QString requestTokenSecret;
- QString consumerKey;
- QString consumerKeySecret;
- QString requestVerifier;
-
- KQOAuthAuthReplyServer *callbackServer;
-
- bool hasTemporaryToken;
- bool isVerified;
- bool isAuthorized;
- bool autoAuth;
- QNetworkAccessManager *networkManager;
- bool managerUserSet;
- QMap<QNetworkReply*, int> requestIds;
-
- Q_DECLARE_PUBLIC(KQOAuthManager);
-};
-
-#endif // KQOAUTHMANAGER_P_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <QByteArray>
-#include <QDateTime>
-#include <QCryptographicHash>
-#include <QPair>
-#include <QStringList>
-
-#include <QtDebug>
-#include <QtAlgorithms>
-
-#include "kqoauthrequest.h"
-#include "kqoauthrequest_p.h"
-#include "kqoauthutils.h"
-#include "kqoauthglobals.h"
-
-
-//////////// Private d_ptr implementation /////////
-
-KQOAuthRequestPrivate::KQOAuthRequestPrivate() :
- timeout(0)
-{
-
-}
-
-KQOAuthRequestPrivate::~KQOAuthRequestPrivate()
-{
-
-}
-
-// This method will not include the "oauthSignature" paramater, since it is calculated from these parameters.
-void KQOAuthRequestPrivate::prepareRequest() {
-
- // If parameter list is not empty, we don't want to insert these values by
- // accident a second time. So giving up.
- if( !requestParameters.isEmpty() ) {
- return;
- }
-
- switch ( requestType ) {
- case KQOAuthRequest::TemporaryCredentials:
- requestParameters.append( qMakePair( OAUTH_KEY_CALLBACK, oauthCallbackUrl.toString()) ); // This is so ugly that it is almost beautiful.
- requestParameters.append( qMakePair( OAUTH_KEY_SIGNATURE_METHOD, oauthSignatureMethod) );
- requestParameters.append( qMakePair( OAUTH_KEY_CONSUMER_KEY, oauthConsumerKey ));
- requestParameters.append( qMakePair( OAUTH_KEY_VERSION, oauthVersion ));
- requestParameters.append( qMakePair( OAUTH_KEY_TIMESTAMP, this->oauthTimestamp() ));
- requestParameters.append( qMakePair( OAUTH_KEY_NONCE, this->oauthNonce() ));
- break;
-
- case KQOAuthRequest::AccessToken:
- requestParameters.append( qMakePair( OAUTH_KEY_SIGNATURE_METHOD, oauthSignatureMethod ));
- requestParameters.append( qMakePair( OAUTH_KEY_CONSUMER_KEY, oauthConsumerKey ));
- requestParameters.append( qMakePair( OAUTH_KEY_VERSION, oauthVersion ));
- requestParameters.append( qMakePair( OAUTH_KEY_TIMESTAMP, this->oauthTimestamp() ));
- requestParameters.append( qMakePair( OAUTH_KEY_NONCE, this->oauthNonce() ));
- requestParameters.append( qMakePair( OAUTH_KEY_VERIFIER, oauthVerifier ));
- requestParameters.append( qMakePair( OAUTH_KEY_TOKEN, oauthToken ));
- break;
-
- case KQOAuthRequest::AuthorizedRequest:
- requestParameters.append( qMakePair( OAUTH_KEY_SIGNATURE_METHOD, oauthSignatureMethod ));
- requestParameters.append( qMakePair( OAUTH_KEY_CONSUMER_KEY, oauthConsumerKey ));
- requestParameters.append( qMakePair( OAUTH_KEY_VERSION, oauthVersion ));
- requestParameters.append( qMakePair( OAUTH_KEY_TIMESTAMP, this->oauthTimestamp() ));
- requestParameters.append( qMakePair( OAUTH_KEY_NONCE, this->oauthNonce() ));
- requestParameters.append( qMakePair( OAUTH_KEY_TOKEN, oauthToken ));
- break;
-
- default:
- break;
- }
-}
-
-void KQOAuthRequestPrivate::signRequest() {
- QString signature = this->oauthSignature();
- requestParameters.append( qMakePair( OAUTH_KEY_SIGNATURE, signature) );
-}
-
-QString KQOAuthRequestPrivate::oauthSignature() {
- /**
- * http://oauth.net/core/1.0/#anchor16
- * The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104] where the
- * Signature Base String is the text and the key is the concatenated values (each first encoded per Parameter
- * Encoding) of the Consumer Secret and Token Secret, separated by an ‘&’ character (ASCII code 38) even if empty.
- **/
- QByteArray baseString = this->requestBaseString();
-
- QString secret = QString(QUrl::toPercentEncoding(oauthConsumerSecretKey)) + "&" + QString(QUrl::toPercentEncoding(oauthTokenSecret));
- QString signature = KQOAuthUtils::hmac_sha1(baseString, secret);
-
- if (debugOutput) {
- qDebug() << "========== KQOAuthRequest has the following signature:";
- qDebug() << " * Signature : " << QUrl::toPercentEncoding(signature) << "\n";
- }
- return QString( QUrl::toPercentEncoding(signature) );
-}
-
-bool normalizedParameterSort(const QPair<QString, QString> &left, const QPair<QString, QString> &right) {
- QString keyLeft = left.first;
- QString valueLeft = left.second;
- QString keyRight = right.first;
- QString valueRight = right.second;
-
- if(keyLeft == keyRight) {
- return (valueLeft < valueRight);
- } else {
- return (keyLeft < keyRight);
- }
-}
-QByteArray KQOAuthRequestPrivate::requestBaseString() {
- QByteArray baseString;
-
- // Every request has these as the commont parameters.
- baseString.append( oauthHttpMethodString.toUtf8() + "&"); // HTTP method
- baseString.append( QUrl::toPercentEncoding( oauthRequestEndpoint.toString(QUrl::RemoveQuery) ) + "&" ); // The path and query components
-
- QList< QPair<QString, QString> > baseStringParameters;
- baseStringParameters.append(requestParameters);
- baseStringParameters.append(additionalParameters);
-
- // Sort the request parameters. These parameters have been
- // initialized earlier.
- qSort(baseStringParameters.begin(),
- baseStringParameters.end(),
- normalizedParameterSort
- );
-
- // Last append the request parameters correctly encoded.
- baseString.append( encodedParamaterList(baseStringParameters) );
-
- if (debugOutput) {
- qDebug() << "========== KQOAuthRequest has the following base string:";
- qDebug() << baseString << "\n";
- }
-
- return baseString;
-}
-
-QByteArray KQOAuthRequestPrivate::encodedParamaterList(const QList< QPair<QString, QString> > ¶meters) {
- QByteArray resultList;
-
- bool first = true;
- QPair<QString, QString> parameter;
-
- // Do the debug output.
- if (debugOutput) {
- qDebug() << "========== KQOAuthRequest has the following parameters:";
- }
- foreach (parameter, parameters) {
- if(!first) {
- resultList.append( "&" );
- } else {
- first = false;
- }
-
- // Here we don't need to explicitely encode the strings to UTF-8 since
- // QUrl::toPercentEncoding() takes care of that for us.
- resultList.append( QUrl::toPercentEncoding(parameter.first) // Parameter key
- + "="
- + QUrl::toPercentEncoding(parameter.second) // Parameter value
- );
- if (debugOutput) {
- qDebug() << " * "
- << parameter.first
- << " : "
- << parameter.second;
- }
- }
- if (debugOutput) {
- qDebug() << "\n";
- }
-
- return QUrl::toPercentEncoding(resultList);
-}
-
-QString KQOAuthRequestPrivate::oauthTimestamp() const {
- // This is basically for unit tests only. In most cases we don't set the nonce beforehand.
- if (!oauthTimestamp_.isEmpty()) {
- return oauthTimestamp_;
- }
-
-#if QT_VERSION >= 0x040700
- return QString::number(QDateTime::currentDateTimeUtc().toTime_t());
-#else
- return QString::number(QDateTime::currentDateTime().toUTC().toTime_t());
-#endif
-
-}
-
-QString KQOAuthRequestPrivate::oauthNonce() const {
- // This is basically for unit tests only. In most cases we don't set the nonce beforehand.
- if (!oauthNonce_.isEmpty()) {
- return oauthNonce_;
- }
-
- return QString::number(qrand());
-}
-
-bool KQOAuthRequestPrivate::validateRequest() const {
- switch ( requestType ) {
- case KQOAuthRequest::TemporaryCredentials:
- if (oauthRequestEndpoint.isEmpty()
- || oauthConsumerKey.isEmpty()
- || oauthNonce_.isEmpty()
- || oauthSignatureMethod.isEmpty()
- || oauthTimestamp_.isEmpty()
- || oauthVersion.isEmpty())
- {
- return false;
- }
- return true;
-
- case KQOAuthRequest::AccessToken:
- if (oauthRequestEndpoint.isEmpty()
- || oauthVerifier.isEmpty()
- || oauthConsumerKey.isEmpty()
- || oauthNonce_.isEmpty()
- || oauthSignatureMethod.isEmpty()
- || oauthTimestamp_.isEmpty()
- || oauthToken.isEmpty()
- || oauthTokenSecret.isEmpty()
- || oauthVersion.isEmpty())
- {
- return false;
- }
- return true;
-
- case KQOAuthRequest::AuthorizedRequest:
- if (oauthRequestEndpoint.isEmpty()
- || oauthConsumerKey.isEmpty()
- || oauthNonce_.isEmpty()
- || oauthSignatureMethod.isEmpty()
- || oauthTimestamp_.isEmpty()
- || oauthToken.isEmpty()
- || oauthTokenSecret.isEmpty()
- || oauthVersion.isEmpty())
- {
- return false;
- }
- return true;
-
- default:
- return false;
- }
-
- // We should not come here.
- return false;
-}
-
-//////////// Public implementation ////////////////
-
-KQOAuthRequest::KQOAuthRequest(QObject *parent) :
- QObject(parent),
- d_ptr(new KQOAuthRequestPrivate)
-{
- d_ptr->debugOutput = false; // No debug output by default.
- qsrand(QTime::currentTime().msec()); // We need to seed the nonce random number with something.
- // However, we cannot do this while generating the nonce since
- // we might get the same seed. So initializing here should be fine.
-}
-
-KQOAuthRequest::~KQOAuthRequest()
-{
- delete d_ptr;
-}
-
-void KQOAuthRequest::initRequest(KQOAuthRequest::RequestType type, const QUrl &requestEndpoint) {
- Q_D(KQOAuthRequest);
-
- if (!requestEndpoint.isValid()) {
- qWarning() << "Endpoint URL is not valid. Ignoring. This request might not work.";
- return;
- }
-
- if (type < 0 || type > KQOAuthRequest::AuthorizedRequest) {
- qWarning() << "Invalid request type. Ignoring. This request might not work.";
- return;
- }
-
- // Clear the request
- clearRequest();
-
- // Set smart defaults.
- d->requestType = type;
- d->oauthRequestEndpoint = requestEndpoint;
- d->oauthTimestamp_ = d->oauthTimestamp();
- d->oauthNonce_ = d->oauthNonce();
- this->setSignatureMethod(KQOAuthRequest::HMAC_SHA1);
- this->setHttpMethod(KQOAuthRequest::POST);
- d->oauthVersion = "1.0"; // Currently supports only version 1.0
-
- d->contentType = "application/x-www-form-urlencoded";
-}
-
-void KQOAuthRequest::setConsumerKey(const QString &consumerKey) {
- Q_D(KQOAuthRequest);
- d->oauthConsumerKey = consumerKey;
-}
-
-void KQOAuthRequest::setConsumerSecretKey(const QString &consumerSecretKey) {
- Q_D(KQOAuthRequest);
- d->oauthConsumerSecretKey = consumerSecretKey;
-}
-
-void KQOAuthRequest::setCallbackUrl(const QUrl &callbackUrl) {
- Q_D(KQOAuthRequest);
-
- d->oauthCallbackUrl = callbackUrl;
-}
-
-void KQOAuthRequest::setSignatureMethod(KQOAuthRequest::RequestSignatureMethod requestMethod) {
- Q_D(KQOAuthRequest);
- QString requestMethodString;
-
- switch (requestMethod) {
- case KQOAuthRequest::PLAINTEXT:
- requestMethodString = "PLAINTEXT";
- break;
- case KQOAuthRequest::HMAC_SHA1:
- requestMethodString = "HMAC-SHA1";
- break;
- case KQOAuthRequest::RSA_SHA1:
- requestMethodString = "RSA-SHA1";
- break;
- default:
- // We should not come here
- qWarning() << "Invalid signature method set.";
- break;
- }
-
- d->oauthSignatureMethod = requestMethodString;
-}
-
-void KQOAuthRequest::setTokenSecret(const QString &tokenSecret) {
- Q_D(KQOAuthRequest);
-
- d->oauthTokenSecret = tokenSecret;
-}
-
-void KQOAuthRequest::setToken(const QString &token) {
- Q_D(KQOAuthRequest);
-
- d->oauthToken = token;
-}
-
-void KQOAuthRequest::setVerifier(const QString &verifier) {
- Q_D(KQOAuthRequest);
-
- d->oauthVerifier = verifier;
-}
-
-
-void KQOAuthRequest::setHttpMethod(KQOAuthRequest::RequestHttpMethod httpMethod) {
- Q_D(KQOAuthRequest);
-
- QString requestHttpMethodString;
-
- switch (httpMethod) {
- case KQOAuthRequest::GET:
- requestHttpMethodString = "GET";
- break;
- case KQOAuthRequest::POST:
- requestHttpMethodString = "POST";
- break;
- default:
- qWarning() << "Invalid HTTP method set.";
- break;
- }
-
- d->oauthHttpMethod = httpMethod;
- d->oauthHttpMethodString = requestHttpMethodString;
-}
-
-KQOAuthRequest::RequestHttpMethod KQOAuthRequest::httpMethod() const {
- Q_D(const KQOAuthRequest);
-
- return d->oauthHttpMethod;
-}
-
-void KQOAuthRequest::setAdditionalParameters(const KQOAuthParameters &additionalParams) {
- Q_D(KQOAuthRequest);
-
- QList<QString> additionalKeys = additionalParams.keys();
- QList<QString> additionalValues = additionalParams.values();
-
- int i=0;
- foreach(QString key, additionalKeys) {
- QString value = additionalValues.at(i);
- d->additionalParameters.append( qMakePair(key, value) );
- i++;
- }
-}
-
-KQOAuthParameters KQOAuthRequest::additionalParameters() const {
- Q_D(const KQOAuthRequest);
-
- QMultiMap<QString, QString> additionalParams;
- for(int i=0; i<d->additionalParameters.size(); i++) {
- additionalParams.insert(d->additionalParameters.at(i).first,
- d->additionalParameters.at(i).second);
- }
-
- return additionalParams;
-}
-
-KQOAuthRequest::RequestType KQOAuthRequest::requestType() const {
- Q_D(const KQOAuthRequest);
- return d->requestType;
-}
-
-QUrl KQOAuthRequest::requestEndpoint() const {
- Q_D(const KQOAuthRequest);
- return d->oauthRequestEndpoint;
-}
-
-QList<QByteArray> KQOAuthRequest::requestParameters() {
- Q_D(KQOAuthRequest);
-
- QList<QByteArray> requestParamList;
-
- d->prepareRequest();
- if (!isValid() ) {
- qWarning() << "Request is not valid! I will still sign it, but it will probably not work.";
- }
- d->signRequest();
-
- QPair<QString, QString> requestParam;
- QString param;
- QString value;
- foreach (requestParam, d->requestParameters) {
- param = requestParam.first;
- value = requestParam.second;
- requestParamList.append(QString(param + "=\"" + value +"\"").toUtf8());
- }
-
- return requestParamList;
-}
-
-QString KQOAuthRequest::contentType()
-{
- Q_D(const KQOAuthRequest);
- return d->contentType;
-}
-
-void KQOAuthRequest::setContentType(const QString &contentType)
-{
- Q_D(KQOAuthRequest);
- d->contentType = contentType;
-}
-
-QByteArray KQOAuthRequest::rawData()
-{
- Q_D(const KQOAuthRequest);
- return d->postRawData;
-}
-
-void KQOAuthRequest::setRawData(const QByteArray &rawData)
-{
- Q_D(KQOAuthRequest);
- d->postRawData = rawData;
-}
-
-QByteArray KQOAuthRequest::requestBody() const {
- Q_D(const KQOAuthRequest);
-
- QByteArray postBodyContent;
- bool first = true;
- for(int i=0; i < d->additionalParameters.size(); i++) {
- if(!first) {
- postBodyContent.append("&");
- } else {
- first = false;
- }
-
- QString key = d->additionalParameters.at(i).first;
- QString value = d->additionalParameters.at(i).second;
-
- postBodyContent.append(QUrl::toPercentEncoding(key) + QString("=").toUtf8() +
- QUrl::toPercentEncoding(value));
- }
- return postBodyContent;
-}
-
-bool KQOAuthRequest::isValid() const {
- Q_D(const KQOAuthRequest);
-
- return d->validateRequest();
-}
-
-void KQOAuthRequest::setTimeout(int timeoutMilliseconds) {
- Q_D(KQOAuthRequest);
- d->timeout = timeoutMilliseconds;
-}
-
-void KQOAuthRequest::clearRequest() {
- Q_D(KQOAuthRequest);
-
- d->oauthRequestEndpoint = "";
- d->oauthHttpMethodString = "";
- d->oauthConsumerKey = "";
- d->oauthConsumerSecretKey = "";
- d->oauthToken = "";
- d->oauthTokenSecret = "";
- d->oauthSignatureMethod = "";
- d->oauthCallbackUrl = "";
- d->oauthVerifier = "";
- d->oauthTimestamp_ = "";
- d->oauthNonce_ = "";
- d->requestParameters.clear();
- d->additionalParameters.clear();
- d->timeout = 0;
-}
-
-void KQOAuthRequest::setEnableDebugOutput(bool enabled) {
- Q_D(KQOAuthRequest);
- d->debugOutput = enabled;
-}
-
-/**
- * Protected implementations for inherited classes
- */
-bool KQOAuthRequest::validateXAuthRequest() const {
- Q_D(const KQOAuthRequest);
-
- if (d->oauthRequestEndpoint.isEmpty()
- || d->oauthConsumerKey.isEmpty()
- || d->oauthNonce_.isEmpty()
- || d->oauthSignatureMethod.isEmpty()
- || d->oauthTimestamp_.isEmpty()
- || d->oauthVersion.isEmpty())
- {
- return false;
- }
- return true;
-}
-
-
-/**
- * Private implementations for friend classes
- */
-QString KQOAuthRequest::consumerKeyForManager() const {
- Q_D(const KQOAuthRequest);
- return d->oauthConsumerKey;
-}
-
-QString KQOAuthRequest::consumerKeySecretForManager() const {
- Q_D(const KQOAuthRequest);
- return d->oauthConsumerSecretKey;
-}
-
-QUrl KQOAuthRequest::callbackUrlForManager() const {
- Q_D(const KQOAuthRequest);
- return d->oauthCallbackUrl;
-}
-
-void KQOAuthRequest::requestTimerStart()
-{
- Q_D(KQOAuthRequest);
- if (d->timeout > 0) {
- connect(&(d->timer), SIGNAL(timeout()), this, SIGNAL(requestTimedout()));
- d->timer.start(d->timeout);
- }
-}
-
-void KQOAuthRequest::requestTimerStop()
-{
- Q_D(KQOAuthRequest);
- if (d->timeout > 0) {
- disconnect(&(d->timer), SIGNAL(timeout()), this, SIGNAL(requestTimedout()));
- d->timer.stop();
- }
-}
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHREQUEST_H
-#define KQOAUTHREQUEST_H
-
-#include <QObject>
-#include <QUrl>
-#include <QMultiMap>
-
-#include "kqoauthglobals.h"
-
-typedef QMultiMap<QString, QString> KQOAuthParameters;
-
-class KQOAuthRequestPrivate;
-class KQOAUTH_EXPORT KQOAuthRequest : public QObject
-{
- Q_OBJECT
-public:
- explicit KQOAuthRequest(QObject *parent = 0);
- ~KQOAuthRequest();
-
- enum RequestType {
- TemporaryCredentials = 0,
- AccessToken,
- AuthorizedRequest
- };
-
- enum RequestSignatureMethod {
- PLAINTEXT = 0,
- HMAC_SHA1,
- RSA_SHA1
- };
-
- enum RequestHttpMethod {
- GET = 0,
- POST
- };
-
- /**
- * These methods can be overridden in child classes which are different types of
- * OAuth requests.
- */
- // Validate the request of this type.
- virtual bool isValid() const;
-
- /**
- * These methods are OAuth request type specific and not overridden in child
- * classes.
- * NOTE: Refactorting still a TODO
- */
- // Initialize the request of this type.
- void initRequest(KQOAuthRequest::RequestType type, const QUrl &requestEndpoint);
-
- void setConsumerKey(const QString &consumerKey);
- void setConsumerSecretKey(const QString &consumerSecretKey);
-
- // Mandatory methods for acquiring a request token
- void setCallbackUrl(const QUrl &callbackUrl);
-
- // Mandator methods for acquiring a access token
- void setTokenSecret(const QString &tokenSecret);
- void setToken(const QString &token);
- void setVerifier(const QString &verifier);
-
- // Request signature method to use - HMAC_SHA1 currently only supported
- void setSignatureMethod(KQOAuthRequest::RequestSignatureMethod = KQOAuthRequest::HMAC_SHA1);
-
- // Request's HTTP method.
- void setHttpMethod(KQOAuthRequest::RequestHttpMethod = KQOAuthRequest::POST);
- KQOAuthRequest::RequestHttpMethod httpMethod() const;
-
- // Sets the timeout for this request. If the timeout expires, signal "requestTimedout" will be
- // emitted from the manager.
- // 0 = If set to zero, timeout is disabled.
- // TODO: Do we need some request ID now?
- void setTimeout(int timeoutMilliseconds);
-
- // Additional optional parameters to the request.
- void setAdditionalParameters(const KQOAuthParameters &additionalParams);
- KQOAuthParameters additionalParameters() const;
- QList<QByteArray> requestParameters(); // This will return all request's parameters in the raw format given
- // to the QNetworkRequest.
- QByteArray requestBody() const; // This will return the POST body as given to the QNetworkRequest.
-
- KQOAuthRequest::RequestType requestType() const;
- QUrl requestEndpoint() const;
-
- void setContentType(const QString &contentType);
- QString contentType();
-
- void setRawData(const QByteArray &rawData);
- QByteArray rawData();
-
- void clearRequest();
-
- // Enable verbose debug output for request content.
- void setEnableDebugOutput(bool enabled);
-
-Q_SIGNALS:
- // This signal is emited if the request is not completed before the request's timeout
- // value has expired.
- void requestTimedout();
-
-protected:
- bool validateXAuthRequest() const;
-
-private:
- KQOAuthRequestPrivate * const d_ptr;
- Q_DECLARE_PRIVATE(KQOAuthRequest);
- Q_DISABLE_COPY(KQOAuthRequest);
-
- // These classes are only for the internal use of KQOAuthManager so it can
- // work with the opaque request.
- QString consumerKeyForManager() const;
- QString consumerKeySecretForManager() const;
- QUrl callbackUrlForManager() const;
-
- // This method is for timeout handling by the KQOAuthManager.
- void requestTimerStart();
- void requestTimerStop();
-
- friend class KQOAuthManager;
-#ifdef UNIT_TEST
- friend class Ut_KQOAuth;
-#endif
-};
-
-#endif // KQOAUTHREQUEST_H
+++ /dev/null
-#include "kqoauthrequest_1.h"
-
-KQOAuthRequest_1::KQOAuthRequest_1()
-{
-}
+++ /dev/null
-#ifndef KQOAUTHREQUEST_1_H
-#define KQOAUTHREQUEST_1_H
-
-#include "kqoauthrequest.h"
-
-class KQOAUTH_EXPORT KQOAuthRequest_1 : public KQOAuthRequest
-{
-public:
- KQOAuthRequest_1();
-};
-
-#endif // KQOAUTHREQUEST_1_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHREQUEST_P_H
-#define KQOAUTHREQUEST_P_H
-#include "kqoauthglobals.h"
-#include "kqoauthrequest.h"
-
-#include <QString>
-#include <QUrl>
-#include <QMap>
-#include <QPair>
-#include <QMultiMap>
-#include <QTimer>
-
-class KQOAUTH_EXPORT KQOAuthRequestPrivate {
-
-public:
- KQOAuthRequestPrivate();
- ~KQOAuthRequestPrivate();
-
- // Helper methods to get the values for the OAuth request parameters.
- QString oauthTimestamp() const;
- QString oauthNonce() const;
- QString oauthSignature();
-
- // Utility methods for making the request happen.
- void prepareRequest();
- void signRequest();
- bool validateRequest() const;
- QByteArray requestBaseString();
- QByteArray encodedParamaterList(const QList< QPair<QString, QString> > &requestParameters);
- void insertAdditionalParams();
- void insertPostBody();
-
- QUrl oauthRequestEndpoint;
- KQOAuthRequest::RequestHttpMethod oauthHttpMethod;
- QString oauthHttpMethodString;
- QString oauthConsumerKey;
- QString oauthConsumerSecretKey;
- QString oauthToken;
- QString oauthTokenSecret;
- QString oauthSignatureMethod;
- QUrl oauthCallbackUrl;
- QString oauthVersion;
- QString oauthVerifier;
-
- // These will be generated by the helper methods
- QString oauthTimestamp_;
- QString oauthNonce_;
-
- // User specified additional parameters needed for the request.
- QList< QPair<QString, QString> > additionalParameters;
-
- // The raw POST body content as given to the HTTP request.
- QByteArray postBodyContent;
-
- // Protocol parameters.
- // These parameters are used in the "Authorized" header of the HTTP request.
- QList< QPair<QString, QString> > requestParameters;
-
- KQOAuthRequest::RequestType requestType;
-
- //The Content-Type HTTP header
- QString contentType;
-
- //Raw data to post if type is not url-encoded
- QByteArray postRawData;
-
- // Timeout for this request in milliseconds.
- int timeout;
- QTimer timer;
-
- bool debugOutput;
-
-};
-#endif // KQOAUTHREQUEST_P_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <QtDebug>
-
-#include "kqoauthrequest_xauth_p.h"
-#include "kqoauthrequest_xauth.h"
-
-/**
- * Private d_ptr implementations.
- */
-KQOAuthRequest_XAuthPrivate::KQOAuthRequest_XAuthPrivate()
-{
-
-}
-
-KQOAuthRequest_XAuthPrivate::~KQOAuthRequest_XAuthPrivate()
-{
-}
-
-/**
- * Public implementations.
- */
-KQOAuthRequest_XAuth::KQOAuthRequest_XAuth(QObject *parent) :
- KQOAuthRequest(parent),
- d_ptr(new KQOAuthRequest_XAuthPrivate)
-{
-}
-
-bool KQOAuthRequest_XAuth::isValid() const {
- // An xAuth can never request temporary credentials.
- if (requestType() == KQOAuthRequest::TemporaryCredentials) {
- qWarning() << "XAuth request cannot be of type KQOAuthRequest::TemporaryCredentials. Aborting.";
- return false;
- }
-
- // Access token must always be retrieved using the POST HTTP method.
- if (requestType() == KQOAuthRequest::AccessToken
- && httpMethod() != KQOAuthRequest::POST) {
-
- qWarning() << "Access tokens must be fetched using the POST HTTP method. Aborting.";
-
- return false;
- }
-
- if (!xauth_parameters_set) {
- qWarning() << "No XAuth parameters set. Aborting.";
- return false;
- }
-
- // And then check the validity of the XAuth request.
- // Provided by the base class as a protected method for us.
- return validateXAuthRequest();
-}
-
-void KQOAuthRequest_XAuth::setXAuthLogin(const QString &username,
- const QString &password) {
-
- if (username.isEmpty() || password.isEmpty()) {
- qWarning() << "Username or password cannot be empty. Aborting.";
- return;
- }
-
- xauth_parameters_set = true;
-
- KQOAuthParameters xauthParams;
- xauthParams.insert("x_auth_username", username);
- xauthParams.insert("x_auth_password", password);
- xauthParams.insert("x_auth_mode", "client_auth");
-
- setAdditionalParameters(xauthParams);
-}
-
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHREQUEST_XAUTH_H
-#define KQOAUTHREQUEST_XAUTH_H
-
-#include "kqoauthrequest.h"
-#include "kqoauthrequest_1.h"
-
-class KQOAuthRequest_XAuthPrivate;
-class KQOAUTH_EXPORT KQOAuthRequest_XAuth : public KQOAuthRequest
-{
- Q_OBJECT
-public:
- KQOAuthRequest_XAuth(QObject *parent = 0);
-
- /**
- * These methods can be overridden in child classes which are different types of
- * OAuth requests.
- */
- // Validate the request of this type.
- bool isValid() const;
-
- // Give the xAuth specific parameters.
- void setXAuthLogin(const QString &username = "",
- const QString &password = "");
-
-private:
- KQOAuthRequest_XAuthPrivate * const d_ptr;
- bool xauth_parameters_set;
-};
-
-#endif // KQOAUTHREQUEST_XAUTH_H
+++ /dev/null
-#ifndef KQOAUTHREQUEST_XAUTH_P_H
-#define KQOAUTHREQUEST_XAUTH_P_H
-
-#include "kqoauthglobals.h"
-
-class KQOAuthRequest;
-class KQOAUTH_EXPORT KQOAuthRequest_XAuthPrivate
-{
-public:
- KQOAuthRequest_XAuthPrivate();
- ~KQOAuthRequest_XAuthPrivate();
-};
-
-#endif // KQOAUTHREQUEST_XAUTH_P_H
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#include <QString>
-#include <QCryptographicHash>
-#include <QByteArray>
-
-#include <QtDebug>
-#include "kqoauthutils.h"
-
-QString KQOAuthUtils::hmac_sha1(const QString &message, const QString &key)
-{
- QByteArray keyBytes = key.toAscii();
- int keyLength; // Lenght of key word
- const int blockSize = 64; // Both MD5 and SHA-1 have a block size of 64.
-
- keyLength = keyBytes.size();
- // If key is longer than block size, we need to hash the key
- if (keyLength > blockSize) {
- QCryptographicHash hash(QCryptographicHash::Sha1);
- hash.addData(keyBytes);
- keyBytes = hash.result();
- }
-
- /* http://tools.ietf.org/html/rfc2104 - (1) */
- // Create the opad and ipad for the hash function.
- QByteArray ipad;
- QByteArray opad;
-
- ipad.fill( 0, blockSize);
- opad.fill( 0, blockSize);
-
- ipad.replace(0, keyBytes.length(), keyBytes);
- opad.replace(0, keyBytes.length(), keyBytes);
-
- /* http://tools.ietf.org/html/rfc2104 - (2) & (5) */
- for (int i=0; i<64; i++) {
- ipad[i] = ipad[i] ^ 0x36;
- opad[i] = opad[i] ^ 0x5c;
- }
-
- QByteArray workArray;
- workArray.clear();
-
- workArray.append(ipad, 64);
- /* http://tools.ietf.org/html/rfc2104 - (3) */
- workArray.append(message.toAscii());
-
-
- /* http://tools.ietf.org/html/rfc2104 - (4) */
- QByteArray sha1 = QCryptographicHash::hash(workArray, QCryptographicHash::Sha1);
-
- /* http://tools.ietf.org/html/rfc2104 - (6) */
- workArray.clear();
- workArray.append(opad, 64);
- workArray.append(sha1);
-
- sha1.clear();
-
- /* http://tools.ietf.org/html/rfc2104 - (7) */
- sha1 = QCryptographicHash::hash(workArray, QCryptographicHash::Sha1);
- return QString(sha1.toBase64());
-}
+++ /dev/null
-/**
- * KQOAuth - An OAuth authentication library for Qt.
- *
- * Author: Johan Paul (johan.paul@d-pointer.com)
- * http://www.d-pointer.com
- *
- * KQOAuth is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * KQOAuth 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef KQOAUTHUTILS_H
-#define KQOAUTHUTILS_H
-
-#include "kqoauthglobals.h"
-
-class QString;
-class KQOAUTH_EXPORT KQOAuthUtils
-{
-public:
-
- static QString hmac_sha1(const QString &message, const QString &key);
-};
-
-#endif // KQOAUTHUTILS_H
+++ /dev/null
-TEMPLATE = lib
-CONFIG += staticlib
-TARGET = kqoauth
-
-QT -= gui
-QT += network
-
-HEADERS += kqoauthauthreplyserver.h \
- kqoauthauthreplyserver_p.h \
- kqoauthglobals.h \
- kqoauthmanager.h \
- kqoauthmanager_p.h \
- kqoauthrequest.h \
- kqoauthrequest_1.h \
- kqoauthrequest_p.h \
- kqoauthrequest_xauth.h \
- kqoauthrequest_xauth_p.h \
- kqoauthutils.h
-SOURCES += kqoauthauthreplyserver.cpp \
- kqoauthmanager.cpp \
- kqoauthrequest.cpp \
- kqoauthrequest_1.cpp \
- kqoauthrequest_xauth.cpp \
- kqoauthutils.cpp
-
-target.path = /opt/linfati.com/lib
-INSTALLS += target
+++ /dev/null
-diff -up ../../kqoauth/src//kqoauthmanager.cpp ./kqoauthmanager.cpp
---- ../../kqoauth/src//kqoauthmanager.cpp 2011-10-22 22:23:12.391025442 +0200
-+++ ./kqoauthmanager.cpp 2011-10-22 22:44:06.897246201 +0200
-@@ -18,7 +18,6 @@
- * along with KQOAuth. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <QtCore>
--#include <QDesktopServices>
-
- #include "kqoauthmanager.h"
- #include "kqoauthmanager_p.h"
-@@ -401,19 +400,19 @@ QNetworkAccessManager * KQOAuthManager::
-
- //////////// Public convenience API /////////////
-
--void KQOAuthManager::getUserAuthorization(QUrl authorizationEndpoint) {
-+QUrl KQOAuthManager::getUserAuthorization(QUrl authorizationEndpoint) {
- Q_D(KQOAuthManager);
-
- if (!d->hasTemporaryToken) {
- qWarning() << "No temporary tokens retreieved. Cannot get user authorization.";
- d->error = KQOAuthManager::RequestUnauthorized;
-- return;
-+ return QString();
- }
-
- if (!authorizationEndpoint.isValid()) {
- qWarning() << "Authorization endpoint not valid. Cannot proceed.";
- d->error = KQOAuthManager::RequestEndpointError;
-- return;
-+ return QString();
- }
-
- d->error = KQOAuthManager::NoError;
-@@ -422,9 +421,9 @@ void KQOAuthManager::getUserAuthorizatio
- QUrl openWebPageUrl(authorizationEndpoint.toString(), QUrl::StrictMode);
- openWebPageUrl.addQueryItem(tokenParam.first, tokenParam.second);
-
-- // Open the user's default browser to the resource authorization page provided
-- // by the service.
-- QDesktopServices::openUrl(openWebPageUrl);
-+ // Return the resource authorization page provided by the service.
-+ qDebug() << "KQOAuthManager::getUserAuthorization " << openWebPageUrl;
-+ return openWebPageUrl;
- }
-
- void KQOAuthManager::getUserAccessTokens(QUrl accessTokenEndpoint) {
-diff -up ../../kqoauth/src//kqoauthmanager.h ./kqoauthmanager.h
---- ../../kqoauth/src//kqoauthmanager.h 2011-10-22 22:23:12.391025442 +0200
-+++ ./kqoauthmanager.h 2011-10-22 22:39:48.715965943 +0200
-@@ -103,7 +103,7 @@ public:
- * us to access protected resources, the verifier token is stored in KQOAuthManager for further use.
- * In order to use this method, you must set setHandleUserAuthorization() to true.
- */
-- void getUserAuthorization(QUrl authorizationEndpoint);
-+ QUrl getUserAuthorization(QUrl authorizationEndpoint);
- /**
- * This is a convenience API for retrieving the access token in exchange for the temporary token and the
- * verifier.
+++ /dev/null
-#include "googlelatitude.h"
-#include <QtNetwork/QNetworkConfigurationManager>
-
-GoogleLatitude::GoogleLatitude(QObject *parent) :
- QObject(parent),
- OauthSettings(this),
- OAuthGetRequestToken("https://www.google.com/accounts/OAuthGetRequestToken"),
- OAuthAuthorizeToken("https://www.google.com/accounts/OAuthAuthorizeToken"),
- OAuthGetAccessToken("https://www.google.com/accounts/OAuthGetAccessToken"),
- CurrentLocation("https://www.googleapis.com/latitude/v1/currentLocation"),
- UserAuthorization(""),
- ConsumerKey("1062862865804.apps.googleusercontent.com"),
- ConsumerSecretKey("EYQaRaUJ9Fznw8mPMor660Kx"),
- CurrentLatitude(0),
- CurrentLongitude(0),
- CurrentAccuracy(0) {
- qDebug() << "* GoogleLatitude::GoogleLatitude";
- OauthRequest = new KQOAuthRequest(this);
- OauthManager = new KQOAuthManager(this);
- GoogleOauthAdditional.insert("scope", "https://www.googleapis.com/auth/latitude");
- GoogleOauthAdditional.insert("xoauth_displayname", "LatitudeUpdater");
-
- connect(OauthManager, SIGNAL(temporaryTokenReceived(QString,QString)),
- this, SLOT(onTemporaryTokenReceived(QString, QString)));
-
- connect(OauthManager, SIGNAL(authorizationReceived(QString,QString)),
- this, SLOT(onAuthorizationReceived(QString, QString)));
-
- connect(OauthManager, SIGNAL(accessTokenReceived(QString,QString)),
- this, SLOT(onAccessTokenReceived(QString,QString)));
-
- connect(OauthManager, SIGNAL(requestReady(QByteArray)),
- this, SLOT(onRequestReady(QByteArray)));
-
- connect(OauthManager, SIGNAL(authorizedRequestDone()),
- this, SLOT(onAuthorizedRequestDone()));
-
- connect(this, SIGNAL(gotToken()),
- this, SLOT(getCurrentLocation()));
-
- connect(this, SIGNAL(notToken()),
- this, SLOT(onNotToken()));
-
- connect(this, SIGNAL(gotToken()),
- this, SLOT(onGotToken()));
-
- connect(this, SIGNAL(needAuth()),
- this, SLOT(onNeedAuth()));
-}
-
-GoogleLatitude::~GoogleLatitude() {
- qDebug() << "* GoogleLatitude::~GoogleLatitude";
- delete OauthManager;
- delete OauthRequest;
-}
-
-void GoogleLatitude::getAccess() {
- qDebug() << "* GoogleLatitude::getAccess";
- if ( OauthSettings.value("oauth_token").isNull() || OauthSettings.value("oauth_token_secret").isNull() ) {
- OauthRequest->clearRequest();
- OauthRequest->initRequest(KQOAuthRequest::TemporaryCredentials, OAuthGetRequestToken);
- OauthRequest->setConsumerKey(ConsumerKey);
- OauthRequest->setConsumerSecretKey(ConsumerSecretKey);
- OauthRequest->setAdditionalParameters(GoogleOauthAdditional);
- OauthManager->setHandleUserAuthorization(true);
- OauthRequest->setHttpMethod(KQOAuthRequest::POST);
- OauthManager->executeRequest(OauthRequest);
- } else {
- emit gotToken();
- }
-}
-
-void GoogleLatitude::getCurrentLocation() {
- qDebug() << "* GoogleLatitude::getCurrentLocation";
- if ( OauthSettings.value("oauth_token").isNull() || OauthSettings.value("oauth_token_secret").isNull() ) {
- emit notToken();
- } else {
- OauthRequest->clearRequest();
- OauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, CurrentLocation);
- OauthRequest->setToken(OauthSettings.value("oauth_token").toString());
- OauthRequest->setTokenSecret(OauthSettings.value("oauth_token_secret").toString());
- OauthRequest->setConsumerKey(ConsumerKey);
- OauthRequest->setConsumerSecretKey(ConsumerSecretKey);
- OauthRequest->setHttpMethod(KQOAuthRequest::GET);
- OauthManager->executeRequest(OauthRequest);
- }
-}
-
-void GoogleLatitude::sendCurrentLocation() {
- qDebug() << "* GoogleLatitude::sendCurrentLocation";
- if (OauthSettings.value("oauth_token").isNull() || OauthSettings.value("oauth_token_secret").isNull()) {
- emit notToken();
- } else {
- if (abs(CurrentLatitude) <= 0.01) return;
- if (abs(CurrentLongitude) <= 0.01) return;
- if (abs(CurrentAccuracy) <= 0.01) return;
-
- QNetworkConfigurationManager mgr;
- if (!OauthSettings.value("net_auto").toBool() && !mgr.isOnline()) {
- qDebug() << "* GoogleLatitude::sendCurrentLocation" << "offline";
- return;
- }
-
- QByteArray json_location;
- json_location = "{\"data\": {\"kind\":\"latitude#location\",";
- json_location += QString("\"latitude\":%1,").arg(CurrentLatitude);
- json_location += QString("\"longitude\":%1,").arg(CurrentLongitude);
- json_location += QString("\"accuracy\":%1").arg(CurrentAccuracy);
- json_location += "}}";
- qDebug() << "json_location" << json_location;
-
- OauthRequest->clearRequest();
- OauthRequest->initRequest(KQOAuthRequest::AuthorizedRequest, CurrentLocation);
- OauthRequest->setToken(OauthSettings.value("oauth_token").toString());
- OauthRequest->setTokenSecret(OauthSettings.value("oauth_token_secret").toString());
- OauthRequest->setConsumerKey(ConsumerKey);
- OauthRequest->setConsumerSecretKey(ConsumerSecretKey);
- OauthRequest->setHttpMethod(KQOAuthRequest::POST);
- OauthRequest->setContentType("application/json");
- OauthRequest->setRawData(json_location);
- OauthManager->executeRequest(OauthRequest);
- }
-}
-
-void GoogleLatitude::setCurrentLocation(double lat, double lon, double acc) {
- qDebug() << "* GoogleLatitude::setCurrentLocation" << lat << lon << acc;
- CurrentLatitude = lat;
- CurrentLongitude = lon;
- CurrentAccuracy = acc;
-}
-
-QUrl GoogleLatitude::getUserAuthorization() {
- qDebug() << "* GoogleLatitude::getUserAuthorization";
- return UserAuthorization;
-}
-
-void GoogleLatitude::setAutoConnect(bool status) {
- qDebug() << "* GoogleLatitude::setAutoConnect" << status;
- OauthSettings.setValue("net_auto", status);
-}
-
-bool GoogleLatitude::getAutoConnect() {
- qDebug() << "* GoogleLatitude::getAutoConnect";
- return OauthSettings.value("net_auto", true).toBool();
-}
-
-void GoogleLatitude::setDaemonMode(bool status) {
- qDebug() << "* GoogleLatitude::setDaemonMode" << status;
- OauthSettings.setValue("daemon", status);
-}
-
-bool GoogleLatitude::getDaemonMode() {
- qDebug() << "* GoogleLatitude::getDaemonMode";
- return OauthSettings.value("daemon", true).toBool();
-}
-
-void GoogleLatitude::onTemporaryTokenReceived(QString temporaryToken, QString temporaryTokenSecret) {
- qDebug() << "* GoogleLatitude::onTemporaryTokenReceived" << temporaryToken << temporaryTokenSecret;
- if( OauthManager->lastError() == KQOAuthManager::NoError) {
- UserAuthorization = OauthManager->getUserAuthorization(OAuthAuthorizeToken);
- qDebug() << "* GoogleLatitude::onTemporaryTokenReceived" << "UserAuthorization" << UserAuthorization;
- emit needAuth();
- }
-}
-
-void GoogleLatitude::onAuthorizationReceived(QString token, QString verifier) {
- qDebug() << "* GoogleLatitude::onAuthorizationReceived" << token << verifier;
- OauthManager->getUserAccessTokens(OAuthGetAccessToken);
- if(OauthManager->lastError() != KQOAuthManager::NoError) {
- emit notToken();
- }
-}
-
-void GoogleLatitude::onAccessTokenReceived(QString token, QString tokenSecret) {
- qDebug() << "* GoogleLatitude::onAccessTokenReceived" << token << tokenSecret;
- OauthSettings.setValue("oauth_token", token);
- OauthSettings.setValue("oauth_token_secret", tokenSecret);
- emit gotToken();
-}
-
-void GoogleLatitude::onRequestReady(QByteArray response) {
- qDebug() << "* GoogleLatitude::onRequestReady" << response;
- if (response.contains("Invalid Credentials") ) {
- qDebug() << "* GoogleLatitude::onRequestReady" << "Invalid Credentials";
- OauthSettings.remove("oauth_token");
- OauthSettings.remove("oauth_token_secret");
- UserAuthorization.clear();
- emit notToken();
- }
-}
+++ /dev/null
-#ifndef GOOGLELATITUDE_H
-#define GOOGLELATITUDE_H
-
-#include <QtCore/QObject>
-#include <QtCore/QSettings>
-#include <QtCore/QtDebug>
-#include <QtKOAuth>
-
-class GoogleLatitude : public QObject {
- Q_OBJECT
-
-public:
- GoogleLatitude(QObject *parent = 0);
- ~GoogleLatitude();
-
-public slots:
- void getAccess();
- void getCurrentLocation();
- void sendCurrentLocation();
- void setCurrentLocation(double la, double lo, double ac);
- QUrl getUserAuthorization();
- void setAutoConnect(bool status);
- bool getAutoConnect();
- void setDaemonMode(bool status);
- bool getDaemonMode();
-
-private slots:
- void onTemporaryTokenReceived(QString temporaryToken, QString temporaryTokenSecret);
- void onAuthorizationReceived(QString token, QString verifier);
- void onAccessTokenReceived(QString token, QString tokenSecret);
- void onRequestReady(QByteArray response);
- void onAuthorizedRequestDone() { qDebug() << "* GoogleLatitude::onAuthorizedRequestDone"; }
- void onNotToken() { qDebug() << "* GoogleLatitude::onNotToken"; }
- void onGotToken() { qDebug() << "* GoogleLatitude::onGotToken"; }
- void onNeedAuth() { qDebug() << "* GoogleLatitude::onNeedAuth"; }
-
-signals:
- void notToken();
- void gotToken();
- void needAuth();
-
-private:
- QSettings OauthSettings;
- QUrl OAuthGetRequestToken;
- QUrl OAuthAuthorizeToken;
- QUrl OAuthGetAccessToken;
- QUrl CurrentLocation;
- QUrl UserAuthorization;
- KQOAuthParameters GoogleOauthAdditional;
- QString ConsumerKey;
- QString ConsumerSecretKey;
- double CurrentLatitude;
- double CurrentLongitude;
- double CurrentAccuracy;
- KQOAuthManager *OauthManager;
- KQOAuthRequest *OauthRequest;
-};
-
-#endif // GOOGLELATITUDE_H
+++ /dev/null
-#include "gpscontrol.h"
-#include <QtNetwork/QNetworkConfigurationManager>
-
-GpsControl::GpsControl(QObject *parent) :
- QObject(parent),
- GpsSettings(this),
- GpsSource(QGeoPositionInfoSource::createDefaultSource(this)),
- GpsPosition(),
- GpsTimeout(this),
- GpsInterval(this) {
- qDebug() << "* GpsControl::GpsControl";
-
- GpsTimeout.setSingleShot(true);
- GpsInterval.setSingleShot(true);
-
- setPositioningMethod(GpsSettings.value("gps_method", "all").toString());
- setTimeOut(GpsSettings.value("gps_timeout", 60).toInt());
- setInterval(GpsSettings.value("gps_interval", 15*60).toInt());
-
- if (!GpsSource) qDebug() << "* GpsControl::GpsControl" << "Not GpsSource";
-
- if (GpsSource) connect(GpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
- this, SLOT(setCurrentLocation(QGeoPositionInfo)));
-
- connect(this, SIGNAL(gotUpdate()),
- this, SLOT(onGotUpdate()));
-
- connect(this, SIGNAL(gotFix()),
- this, SLOT(onGotFix()));
-
-}
-
-void GpsControl::setTimeOut(int sec) {
- qDebug() << "* GpsControl::setTimeOut" << sec;
- GpsSettings.setValue("gps_timeout", sec);
-}
-
-int GpsControl::getTimeOut() {
- qDebug() << "* GpsControl::getTimeOut";
- return GpsSettings.value("gps_timeout").toInt();
-}
-
-void GpsControl::setInterval(int sec) {
- qDebug() << "* GpsControl::setInterval" << sec;
- GpsSettings.setValue("gps_interval", sec);
-}
-
-int GpsControl::getInterval() {
- qDebug() << "* GpsControl::getInterval";
- return GpsSettings.value("gps_interval").toInt();
-}
-
-void GpsControl::setPositioningMethod(QString method) {
- qDebug() << "* GpsControl::setPositioningMethod" << method;
- if (method == "gps") {
- GpsSettings.setValue("gps_method", method);
- if (GpsSource) GpsSource->setPreferredPositioningMethods(
- QGeoPositionInfoSource::SatellitePositioningMethods);
- }
- if (method == "cell") {
- GpsSettings.setValue("gps_method", method);
- if (GpsSource) GpsSource->setPreferredPositioningMethods(
- QGeoPositionInfoSource::NonSatellitePositioningMethods);
- }
- if (method == "all") {
- GpsSettings.setValue("gps_method", method);
- if (GpsSource) GpsSource->setPreferredPositioningMethods(
- QGeoPositionInfoSource::AllPositioningMethods);
- }
-}
-
-void GpsControl::startUpdates() {
- qDebug() << "* GpsControl::startUpdates";
-
- GpsTimeout.singleShot(GpsSettings.value("gps_timeout").toInt()*1000,
- this, SLOT(stopUpdates()));
- GpsInterval.singleShot(GpsSettings.value("gps_interval").toInt()*1000,
- this, SLOT(startUpdates()));
-
- QNetworkConfigurationManager mgr;
- if (!GpsSettings.value("net_auto").toBool() && !mgr.isOnline()) {
- qDebug() << "* GpsControl::startUpdates" << "offline";
- return;
- }
-
- if (GpsSource) GpsSource->startUpdates();
-}
-
-void GpsControl::stopUpdates(bool force) {
- qDebug() << "* GpsControl::stopUpdates" << force;
-
- if (GpsSource) GpsSource->stopUpdates();
-
- if (force) {
- GpsTimeout.stop();
- GpsInterval.stop();
- } else {
- if (GpsSource && GpsSource->lastKnownPosition(GpsSettings.value("gps_method")
- == "gps" ? true : false).isValid() ) {
- emit gotFix();
- }
- }
-}
-
-double GpsControl::getCurrentLatitude() {
- qDebug() << "* GpsControl::getCurrentLatitude";
- return GpsPosition.coordinate().latitude();
-}
-
-double GpsControl::getCurrentLongitude() {
- qDebug() << "* GpsControl::getCurrentLongitude";
- return GpsPosition.coordinate().longitude();
-}
-
-double GpsControl::getCurrentAccuracy() {
- qDebug() << "* GpsControl::getCurrentAccuracy";
- return GpsPosition.attribute(QGeoPositionInfo::HorizontalAccuracy);
-}
-
-unsigned int GpsControl::getCurrentTimestamp() {
- qDebug() << "* GpsControl::getCurrentTimestamp";
- return GpsPosition.timestamp().toTime_t();
-}
-
-void GpsControl::setCurrentLocation(QGeoPositionInfo pos) {
- qDebug() << "* GpsControl::setCurrentLocation" << pos;
- if (pos.isValid()) {
- GpsPosition = pos;
- emit gotUpdate();
- }
-}
+++ /dev/null
-#ifndef GPSCONTROL_H
-#define GPSCONTROL_H
-
-#include <QObject>
-#include <QtCore/QDebug>
-#include <QtCore/QSettings>
-#include <QtCore/QTimer>
-#include <QtLocation/QGeoPositionInfo>
-#include <QtLocation/QGeoPositionInfoSource>
-
-using namespace QtMobility;
-
-class GpsControl : public QObject {
- Q_OBJECT
-public:
- GpsControl(QObject *parent = 0);
-
-signals:
- void gotUpdate();
- void gotFix();
-
-public slots:
- void setTimeOut(int sec);
- int getTimeOut();
- void setInterval(int sec);
- int getInterval();
- void setPositioningMethod(QString method);
- QString getPositioningMethod() {return GpsSettings.value("gps_method").toString();}
- void startUpdates();
- void stopUpdates(bool force = false);
- double getCurrentLatitude();
- double getCurrentLongitude();
- double getCurrentAccuracy();
- unsigned int getCurrentTimestamp();
-
-private slots:
- void setCurrentLocation(QGeoPositionInfo pos);
- void onGotUpdate() { qDebug() << "* GpsControl::ongotUpdate"; }
- void onGotFix() { qDebug() << "* GpsControl::ongotFix"; }
-
-private:
- QSettings GpsSettings;
- QGeoPositionInfoSource *GpsSource;
- QGeoPositionInfo GpsPosition;
- QTimer GpsTimeout;
- QTimer GpsInterval;
-};
-
-#endif // GPSCONTROL_H
+++ /dev/null
-TEMPLATE = lib
-CONFIG += staticlib
-TARGET = latitudeupdater
-
-QT += network
-CONFIG += mobility
-MOBILITY += location
-
-INCLUDEPATH += ../libkqoauth
-
-HEADERS += googlelatitude.h gpscontrol.h
-SOURCES += googlelatitude.cpp gpscontrol.cpp
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QString>
-#include <QStringList>
-#include <QByteArray>
-#include <QVariant>
-#include <QtDebug>
-
-#include "gconfitem_p.h"
-
-#include <glib.h>
-#include <gconf/gconf-value.h>
-#include <gconf/gconf-client.h>
-
-struct GConfItemPrivate {
- QString key;
- QVariant value;
- guint notify_id;
-
- static void notify_trampoline(GConfClient*, guint, GConfEntry *, gpointer);
-};
-
-#define withClient(c) for(GConfClient *c = (g_type_init(), gconf_client_get_default()); c; g_object_unref(c), c=NULL)
-
-static QByteArray convertKey(QString key)
-{
- if (key.startsWith('/'))
- return key.toUtf8();
- else {
- qWarning() << "Using dot-separated key names with GConfItem is deprecated.";
- qWarning() << "Please use" << '/' + key.replace('.', '/') << "instead of" << key;
- return '/' + key.replace('.', '/').toUtf8();
- }
-}
-
-static QString convertKey(const char *key)
-{
- return QString::fromUtf8(key);
-}
-
-static QVariant convertValue(GConfValue *src)
-{
- if (!src) {
- return QVariant();
- } else {
- switch (src->type) {
- case GCONF_VALUE_INVALID:
- return QVariant(QVariant::Invalid);
- case GCONF_VALUE_BOOL:
- return QVariant((bool)gconf_value_get_bool(src));
- case GCONF_VALUE_INT:
- return QVariant(gconf_value_get_int(src));
- case GCONF_VALUE_FLOAT:
- return QVariant(gconf_value_get_float(src));
- case GCONF_VALUE_STRING:
- return QVariant(QString::fromUtf8(gconf_value_get_string(src)));
- case GCONF_VALUE_LIST:
- switch (gconf_value_get_list_type(src)) {
- case GCONF_VALUE_STRING: {
- QStringList result;
- for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
- result.append(QString::fromUtf8(gconf_value_get_string((GConfValue *)elts->data)));
- return QVariant(result);
- }
- default: {
- QList<QVariant> result;
- for (GSList *elts = gconf_value_get_list(src); elts; elts = elts->next)
- result.append(convertValue((GConfValue *)elts->data));
- return QVariant(result);
- }
- }
- case GCONF_VALUE_SCHEMA:
- default:
- return QVariant();
- }
- }
-}
-
-static GConfValue *convertString(const QString &str)
-{
- GConfValue *v = gconf_value_new(GCONF_VALUE_STRING);
- gconf_value_set_string(v, str.toUtf8().data());
- return v;
-}
-
-static GConfValueType primitiveType(const QVariant &elt)
-{
- switch (elt.type()) {
- case QVariant::String:
- return GCONF_VALUE_STRING;
- case QVariant::Int:
- return GCONF_VALUE_INT;
- case QVariant::Double:
- return GCONF_VALUE_FLOAT;
- case QVariant::Bool:
- return GCONF_VALUE_BOOL;
- default:
- return GCONF_VALUE_INVALID;
- }
-}
-
-static GConfValueType uniformType(const QList<QVariant> &list)
-{
- GConfValueType result = GCONF_VALUE_INVALID;
-
- foreach(const QVariant &elt, list) {
- GConfValueType elt_type = primitiveType(elt);
-
- if (elt_type == GCONF_VALUE_INVALID)
- return GCONF_VALUE_INVALID;
-
- if (result == GCONF_VALUE_INVALID)
- result = elt_type;
- else if (result != elt_type)
- return GCONF_VALUE_INVALID;
- }
-
- if (result == GCONF_VALUE_INVALID)
- return GCONF_VALUE_STRING; // empty list.
- else
- return result;
-}
-
-static int convertValue(const QVariant &src, GConfValue **valp)
-{
- GConfValue *v;
-
- switch (src.type()) {
- case QVariant::Invalid:
- v = NULL;
- break;
- case QVariant::Bool:
- v = gconf_value_new(GCONF_VALUE_BOOL);
- gconf_value_set_bool(v, src.toBool());
- break;
- case QVariant::Int:
- v = gconf_value_new(GCONF_VALUE_INT);
- gconf_value_set_int(v, src.toInt());
- break;
- case QVariant::Double:
- v = gconf_value_new(GCONF_VALUE_FLOAT);
- gconf_value_set_float(v, src.toDouble());
- break;
- case QVariant::String:
- v = convertString(src.toString());
- break;
- case QVariant::StringList: {
- GSList *elts = NULL;
- v = gconf_value_new(GCONF_VALUE_LIST);
- gconf_value_set_list_type(v, GCONF_VALUE_STRING);
- foreach(const QString &str, src.toStringList())
- elts = g_slist_prepend(elts, convertString(str));
- gconf_value_set_list_nocopy(v, g_slist_reverse(elts));
- break;
- }
- case QVariant::List: {
- GConfValueType elt_type = uniformType(src.toList());
- if (elt_type == GCONF_VALUE_INVALID)
- v = NULL;
- else {
- GSList *elts = NULL;
- v = gconf_value_new(GCONF_VALUE_LIST);
- gconf_value_set_list_type(v, elt_type);
- foreach(const QVariant &elt, src.toList()) {
- GConfValue *val = NULL;
- convertValue(elt, &val); // guaranteed to succeed.
- elts = g_slist_prepend(elts, val);
- }
- gconf_value_set_list_nocopy(v, g_slist_reverse(elts));
- }
- break;
- }
- default:
- return 0;
- }
-
- *valp = v;
- return 1;
-}
-
-void GConfItemPrivate::notify_trampoline(GConfClient*,
- guint,
- GConfEntry *,
- gpointer data)
-{
- GConfItem *item = (GConfItem *)data;
- item->update_value(true);
-}
-
-void GConfItem::update_value(bool emit_signal)
-{
- QVariant new_value;
-
- withClient(client) {
- GError *error = NULL;
- QByteArray k = convertKey(priv->key);
- GConfValue *v = gconf_client_get(client, k.data(), &error);
-
- if (error) {
- qWarning() << error->message;
- g_error_free(error);
- new_value = priv->value;
- } else {
- new_value = convertValue(v);
- if (v)
- gconf_value_free(v);
- }
- }
-
- if (new_value != priv->value) {
- priv->value = new_value;
- if (emit_signal)
- emit valueChanged();
- }
-}
-
-QString GConfItem::key() const
-{
- return priv->key;
-}
-
-QVariant GConfItem::value() const
-{
- return priv->value;
-}
-
-QVariant GConfItem::value(const QVariant &def) const
-{
- if (priv->value.isNull())
- return def;
- else
- return priv->value;
-}
-
-void GConfItem::set(const QVariant &val)
-{
- withClient(client) {
- QByteArray k = convertKey(priv->key);
- GConfValue *v;
- if (convertValue(val, &v)) {
- GError *error = NULL;
-
- if (v) {
- gconf_client_set(client, k.data(), v, &error);
- gconf_value_free(v);
- } else {
- gconf_client_unset(client, k.data(), &error);
- }
-
- if (error) {
- qWarning() << error->message;
- g_error_free(error);
- } else if (priv->value != val) {
- priv->value = val;
- emit valueChanged();
- }
-
- } else
- qWarning() << "Can't store a" << val.typeName();
- }
-}
-
-void GConfItem::unset()
-{
- set(QVariant());
-}
-
-QList<QString> GConfItem::listDirs() const
-{
- QList<QString> children;
-
- withClient(client) {
- QByteArray k = convertKey(priv->key);
- GSList *dirs = gconf_client_all_dirs(client, k.data(), NULL);
- for (GSList *d = dirs; d; d = d->next) {
- children.append(convertKey((char *)d->data));
- g_free(d->data);
- }
- g_slist_free(dirs);
- }
-
- return children;
-}
-
-QList<QString> GConfItem::listEntries() const
-{
- QList<QString> children;
-
- withClient(client) {
- QByteArray k = convertKey(priv->key);
- GSList *entries = gconf_client_all_entries(client, k.data(), NULL);
- for (GSList *e = entries; e; e = e->next) {
- children.append(convertKey(((GConfEntry *)e->data)->key));
- gconf_entry_free((GConfEntry *)e->data);
- }
- g_slist_free(entries);
- }
-
- return children;
-}
-
-GConfItem::GConfItem(const QString &key, QObject *parent)
- : QObject(parent)
-{
- priv = new GConfItemPrivate;
- priv->key = key;
- withClient(client) {
- update_value(false);
- QByteArray k = convertKey(priv->key);
- gconf_client_add_dir(client, k.data(), GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
- priv->notify_id = gconf_client_notify_add(client, k.data(),
- GConfItemPrivate::notify_trampoline, this,
- NULL, NULL);
- }
-}
-
-GConfItem::~GConfItem()
-{
- withClient(client) {
- QByteArray k = convertKey(priv->key);
- gconf_client_notify_remove(client, priv->notify_id);
- gconf_client_remove_dir(client, k.data(), NULL);
- }
- delete priv;
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GCONFITEM_H
-#define GCONFITEM_H
-
-#include <QVariant>
-#include <QStringList>
-#include <QObject>
-
-/*!
-
- \brief GConfItem is a simple C++ wrapper for GConf.
-
- Creating a GConfItem instance gives you access to a single GConf
- key. You can get and set its value, and connect to its
- valueChanged() signal to be notified about changes.
-
- The value of a GConf key is returned to you as a QVariant, and you
- pass in a QVariant when setting the value. GConfItem converts
- between a QVariant and GConf values as needed, and according to the
- following rules:
-
- - A QVariant of type QVariant::Invalid denotes an unset GConf key.
-
- - QVariant::Int, QVariant::Double, QVariant::Bool are converted to
- and from the obvious equivalents.
-
- - QVariant::String is converted to/from a GConf string and always
- uses the UTF-8 encoding. No other encoding is supported.
-
- - QVariant::StringList is converted to a list of UTF-8 strings.
-
- - QVariant::List (which denotes a QList<QVariant>) is converted
- to/from a GConf list. All elements of such a list must have the
- same type, and that type must be one of QVariant::Int,
- QVariant::Double, QVariant::Bool, or QVariant::String. (A list of
- strings is returned as a QVariant::StringList, however, when you
- get it back.)
-
- - Any other QVariant or GConf value is essentially ignored.
-
- \warning GConfItem is as thread-safe as GConf.
-
-*/
-
-class GConfItem : public QObject
-{
- Q_OBJECT
-
-public:
- /*! Initializes a GConfItem to access the GConf key denoted by
- \a key. Key names should follow the normal GConf conventions
- like "/myapp/settings/first".
-
- \param key The name of the key.
- \param parent Parent object
- */
- explicit GConfItem(const QString &key, QObject *parent = 0);
-
- /*! Finalizes a GConfItem.
- */
- virtual ~GConfItem();
-
- /*! Returns the key of this item, as given to the constructor.
- */
- QString key() const;
-
- /*! Returns the current value of this item, as a QVariant.
- */
- QVariant value() const;
-
- /*! Returns the current value of this item, as a QVariant. If
- * there is no value for this item, return \a def instead.
- */
- QVariant value(const QVariant &def) const;
-
- /*! Set the value of this item to \a val. If \a val can not be
- represented in GConf or GConf refuses to accept it for other
- reasons, the current value is not changed and nothing happens.
-
- When the new value is different from the old value, the
- changedValue() signal is emitted on this GConfItem as part
- of calling set(), but other GConfItem:s for the same key do
- only receive a notification once the main loop runs.
-
- \param val The new value.
- */
- void set(const QVariant &val);
-
- /*! Unset this item. This is equivalent to
-
- \code
- item.set(QVariant(QVariant::Invalid));
- \endcode
- */
- void unset();
-
- /*! Return a list of the directories below this item. The
- returned strings are absolute key names like
- "/myapp/settings".
-
- A directory is a key that has children. The same key might
- also have a value, but that is confusing and best avoided.
- */
- QList<QString> listDirs() const;
-
- /*! Return a list of entries below this item. The returned
- strings are absolute key names like "/myapp/settings/first".
-
- A entry is a key that has a value. The same key might also
- have children, but that is confusing and is best avoided.
- */
- QList<QString> listEntries() const;
-
-signals:
- /*! Emitted when the value of this item has changed.
- */
- void valueChanged();
-
-private:
- friend struct GConfItemPrivate;
- struct GConfItemPrivate *priv;
-
- void update_value(bool emit_signal);
-};
-
-#endif // GCONFITEM_H
+++ /dev/null
-TEMPLATE = lib
-CONFIG += staticlib
-TARGET = locationmaemo5
-
-CONFIG += mobility
-MOBILITY += location
-
-contains(QT_CONFIG, maemo5): {
-QT += maemo5
-CONFIG += link_pkgconfig
-PKGCONFIG += glib-2.0 liblocation
-
-HEADERS += gconfitem_p.h \
- liblocationwrapper_p.h \
- qgeopositioninfosource_maemo5_p.h \
- qgeosatelliteinfosource_maemo5_p.h
-SOURCES += gconfitem.cpp \
- liblocationwrapper.cpp \
- qgeopositioninfosource_maemo5.cpp \
- qgeosatelliteinfosource_maemo5.cpp
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "liblocationwrapper_p.h"
-
-#include <QDateTime>
-
-using namespace std;
-
-QTM_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(LiblocationWrapper, LocationEngine)
-
-LiblocationWrapper *LiblocationWrapper::instance()
-{
- return LocationEngine();
-}
-
-LiblocationWrapper::LiblocationWrapper()
- : file(NULL),
- locationControl(NULL),
- locationDevice(NULL),
- errorHandlerId(0),
- posChangedId(0),
- origUpdateInterval(0),
- startcounter(0),
- validLastUpdate(false),
- validLastSatUpdate(false),
- locationState(LiblocationWrapper::Undefined) {
- qDebug() << "* LiblocationWrapper Fremantle Backport";
-}
-
-LiblocationWrapper::~LiblocationWrapper()
-{
- if (locationDevice)
- g_object_unref(locationDevice);
- if (locationControl)
- g_object_unref(locationControl);
-}
-
-bool LiblocationWrapper::inited()
-{
- int retval = false;
- if (!(locationState & LiblocationWrapper::Inited)) {
- g_type_init();
-
- locationControl = location_gpsd_control_get_default();
-
- if (locationControl) {
- g_object_set(G_OBJECT(locationControl),
- "preferred-method", LOCATION_METHOD_USER_SELECTED,
- "preferred-interval", LOCATION_INTERVAL_1S,
- NULL);
- locationDevice =
- (LocationGPSDevice*)g_object_new(LOCATION_TYPE_GPS_DEVICE,
- NULL);
-
- if (locationDevice) {
- errorHandlerId =
- g_signal_connect(G_OBJECT(locationControl), "error-verbose",
- G_CALLBACK(&locationError),
- static_cast<void*>(this));
- posChangedId =
- g_signal_connect(G_OBJECT(locationDevice), "changed",
- G_CALLBACK(&locationChanged),
- static_cast<void*>(this));
- locationState = LiblocationWrapper::Inited;
- retval = true;
- startcounter = 0;
- }
- }
- } else {
- retval = true;
- }
- return retval;
-}
-
-void LiblocationWrapper::locationError(LocationGPSDevice *device,
- gint errorCode, gpointer data)
-{
- Q_UNUSED(device);
- QString locationError;
-
- switch (errorCode) {
- case LOCATION_ERROR_USER_REJECTED_DIALOG:
- locationError = "User didn't enable requested methods";
- break;
- case LOCATION_ERROR_USER_REJECTED_SETTINGS:
- locationError = "User changed settings, which disabled location.";
- break;
- case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE:
- locationError = "Problems with BT GPS";
- break;
- case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE:
- locationError = "Requested method is not allowed in offline mode";
- break;
- case LOCATION_ERROR_SYSTEM:
- locationError = "System error.";
- break;
- default:
- locationError = "Unknown error.";
- }
-
- qDebug() << "Location error:" << locationError;
-
- LiblocationWrapper *object;
- object = (LiblocationWrapper *)data;
- emit object->error();
-}
-
-void LiblocationWrapper::locationChanged(LocationGPSDevice *device,
- gpointer data)
-{
- QGeoPositionInfo posInfo;
- QGeoCoordinate coordinate;
- QGeoSatelliteInfo satInfo;
- int satellitesInUseCount = 0;
- LiblocationWrapper *object;
-
- if (!data || !device) {
- return;
- }
-
- object = (LiblocationWrapper *)data;
-
- if (device) {
- if (device->fix) {
- if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) {
- posInfo.setTimestamp(QDateTime::fromTime_t(device->fix->time));
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) {
- coordinate.setLatitude(device->fix->latitude);
- coordinate.setLongitude(device->fix->longitude);
- posInfo.setAttribute(QGeoPositionInfo::HorizontalAccuracy,
- device->fix->eph / 100.0);
- posInfo.setAttribute(QGeoPositionInfo::VerticalAccuracy,
- device->fix->epv);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET) {
- coordinate.setAltitude(device->fix->altitude);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
- posInfo.setAttribute(QGeoPositionInfo::GroundSpeed,
- device->fix->speed / 3.6);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_CLIMB_SET) {
- posInfo.setAttribute(QGeoPositionInfo::VerticalSpeed,
- device->fix->climb);
- }
-
- if (device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET) {
- posInfo.setAttribute(QGeoPositionInfo::Direction,
- device->fix->track);
- }
- }
-
- if (device->satellites_in_view) {
- QList<QGeoSatelliteInfo> satsInView;
- QList<QGeoSatelliteInfo> satsInUse;
- unsigned int i;
- for (i = 0;i < device->satellites->len;i++) {
- LocationGPSDeviceSatellite *satData =
- (LocationGPSDeviceSatellite *)g_ptr_array_index(device->satellites,
- i);
- satInfo.setSignalStrength(satData->signal_strength);
- satInfo.setPrnNumber(satData->prn);
- satInfo.setAttribute(QGeoSatelliteInfo::Elevation,
- satData->elevation);
- satInfo.setAttribute(QGeoSatelliteInfo::Azimuth,
- satData->azimuth);
-
- satsInView.append(satInfo);
- if (satData->in_use) {
- satellitesInUseCount++;
- satsInUse.append(satInfo);
- }
- }
-
- if (!satsInView.isEmpty())
- object->satellitesInViewUpdated(satsInView);
-
- if (!satsInUse.isEmpty())
- object->satellitesInUseUpdated(satsInUse);
- }
- }
-
- posInfo.setCoordinate(coordinate);
-
- emit object->positionUpdated(posInfo);
-}
-
-QGeoPositionInfo LiblocationWrapper::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- QGeoPositionInfo posInfo;
- QGeoCoordinate coordinate;
- double time;
- double latitude;
- double longitude;
- double altitude;
- double speed;
- double track;
- double climb;
-
- GConfItem lastKnownPositionTime("/system/nokia/location/lastknown/time");
- GConfItem lastKnownPositionLatitude("/system/nokia/location/lastknown/latitude");
- GConfItem lastKnownPositionLongitude("/system/nokia/location/lastknown/longitude");
- GConfItem lastKnownPositionAltitude("/system/nokia/location/lastknown/altitude");
- GConfItem lastKnownPositionSpeed("/system/nokia/location/lastknown/speed");
- GConfItem lastKnownPositionTrack("/system/nokia/location/lastknown/track");
- GConfItem lastKnownPositionClimb("/system/nokia/location/lastknown/climb");
-
- if (validLastSatUpdate)
- return lastSatUpdate;
-
- if (!fromSatellitePositioningMethodsOnly)
- if (validLastUpdate)
- return lastUpdate;
-
- time = lastKnownPositionTime.value().toDouble();
- latitude = lastKnownPositionLatitude.value().toDouble();
- longitude = lastKnownPositionLongitude.value().toDouble();
- altitude = lastKnownPositionAltitude.value().toDouble();
- speed = lastKnownPositionSpeed.value().toDouble();
- track = lastKnownPositionTrack.value().toDouble();
- climb = lastKnownPositionClimb.value().toDouble();
-
- if (longitude && latitude) {
- coordinate.setLongitude(longitude);
- coordinate.setLatitude(latitude);
- if (altitude) {
- coordinate.setAltitude(altitude);
- }
- posInfo.setCoordinate(coordinate);
- }
-
- if (speed) {
- posInfo.setAttribute(QGeoPositionInfo::GroundSpeed, speed);
- }
-
- if (track) {
- posInfo.setAttribute(QGeoPositionInfo::Direction, track);
- }
-
- if (climb) {
- posInfo.setAttribute(QGeoPositionInfo::VerticalSpeed, climb);
- }
-
- // Only positions with time (3D) are provided.
- if (time) {
- posInfo.setTimestamp(QDateTime::fromTime_t(time));
- return posInfo;
- }
-
- return QGeoPositionInfo();
-}
-
-void LiblocationWrapper::satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites)
-{
- satsInView = satellites;
-}
-
-void LiblocationWrapper::satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites)
-{
- satsInUse = satellites;
-}
-
-QList<QGeoSatelliteInfo> LiblocationWrapper::satellitesInView()
-{
- return satsInView;
-}
-
-QList<QGeoSatelliteInfo> LiblocationWrapper::satellitesInUse()
-{
- return satsInUse;
-}
-
-void LiblocationWrapper::start() {
- startcounter++;
-
- if ((locationState & LiblocationWrapper::Inited) &&
- !(locationState & LiblocationWrapper::Started)) {
- if (!errorHandlerId) {
- errorHandlerId =
- g_signal_connect(G_OBJECT(locationControl), "error-verbose",
- G_CALLBACK(&locationError),
- static_cast<void*>(this));
- }
-
- if (!posChangedId) {
- posChangedId =
- g_signal_connect(G_OBJECT(locationDevice), "changed",
- G_CALLBACK(&locationChanged),
- static_cast<void*>(this));
- }
-
- location_gpsd_control_start(locationControl);
-
- locationState |= LiblocationWrapper::Started;
- locationState &= ~LiblocationWrapper::Stopped;
- }
-}
-
-void LiblocationWrapper::stop() {
- startcounter--;
-
- if (startcounter > 0)
- return;
-
- if ((locationState & (LiblocationWrapper::Started |
- LiblocationWrapper::Inited)) &&
- !(locationState & LiblocationWrapper::Stopped)) {
- if (errorHandlerId)
- g_signal_handler_disconnect(G_OBJECT(locationControl),
- errorHandlerId);
- if (posChangedId)
- g_signal_handler_disconnect(G_OBJECT(locationDevice),
- posChangedId);
- errorHandlerId = 0;
- posChangedId = 0;
- startcounter = 0;
- location_gpsd_control_stop(locationControl);
-
- locationState &= ~LiblocationWrapper::Started;
- locationState |= LiblocationWrapper::Stopped;
- }
-}
-
-bool LiblocationWrapper::isActive() {
- if (locationState & LiblocationWrapper::Started)
- return true;
- else
- return false;
-}
-
-#include "moc_liblocationwrapper_p.cpp"
-QTM_END_NAMESPACE
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef LIBLOCATIONWRAPPER_H
-#define LIBLOCATINWRAPPER_H
-
-// INCLUDES
-#include <QDebug>
-#include <QFile>
-
-#include "qgeocoordinate.h"
-#include "qgeopositioninfo.h"
-#include "qgeosatelliteinfo.h"
-
-#include "gconfitem_p.h"
-
-extern "C" {
- #include <glib.h>
- #include <location/location-gpsd-control.h>
- #include <location/location-gps-device.h>
- #include <location/location-misc.h>
- #include <location/location-distance-utils.h>
-}
-
-QTM_BEGIN_NAMESPACE
-
-class LiblocationWrapper : public QObject
-{
- Q_OBJECT
-
-public:
- static LiblocationWrapper *instance();
- LiblocationWrapper();
- ~LiblocationWrapper();
-
- void start();
- void stop();
- QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
- bool inited();
- bool isActive();
- QList<QGeoSatelliteInfo> satellitesInView();
- QList<QGeoSatelliteInfo> satellitesInUse();
-
-private:
- QFile *file;
- LocationGPSDControl *locationControl;
- LocationGPSDevice *locationDevice;
-
- static void locationError(LocationGPSDevice *device, gint code, gpointer data);
- static void locationChanged(LocationGPSDevice *device, gpointer data);
-
- int errorHandlerId;
- int posChangedId;
- int origUpdateInterval;
- int startcounter;
- QGeoPositionInfo lastUpdate;
- QGeoPositionInfo lastSatUpdate;
- bool validLastUpdate;
- bool validLastSatUpdate;
- bool fromSatellite;
-
- void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
- void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
- QList<QGeoSatelliteInfo> satsInView;
- QList<QGeoSatelliteInfo> satsInUse;
-
- enum LocationState {
- Undefined = 0,
- Inited = 1,
- Started = 2,
- Stopped = 4,
- RequestActive = 8,
- RequestSingleShot = 16
- };
- int locationState;
-
-signals:
- void positionUpdated(const QGeoPositionInfo &position);
- void error();
-};
-
-QTM_END_NAMESPACE
-#endif // LIBLOCATIONWRAPPER_H
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeopositioninfosource_maemo5_p.h"
-#include "liblocationwrapper_p.h"
-#include <qnumeric.h>
-
-using namespace std;
-
-QTM_BEGIN_NAMESPACE
-
-QGeoPositionInfoSourceMaemo::QGeoPositionInfoSourceMaemo(QObject *parent)
- : QGeoPositionInfoSource(parent)
-{
- qDebug() << "* QGeoPositionInfoSourceMaemo Fremantle Backport";
- // default values
- timerInterval = DEFAULT_UPDATE_INTERVAL;
- updateTimer = new QTimer(this);
- updateTimer->setSingleShot(true);
- connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateTimeoutElapsed()));
-
- requestTimer = new QTimer(this);
- requestTimer->setSingleShot(true);
- connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimeoutElapsed()));
-
- connect(LiblocationWrapper::instance(), SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(newPositionUpdate(QGeoPositionInfo)));
-
- errorOccurred = false;
- errorSent = false;
-
- positionInfoState = QGeoPositionInfoSourceMaemo::Undefined;
-}
-
-int QGeoPositionInfoSourceMaemo::init()
-{
- if (LiblocationWrapper::instance()->inited()) {
- connect(LiblocationWrapper::instance(), SIGNAL(error()), this, SLOT(error()));
- return INIT_OK;
- } else {
- return INIT_FAILED;
- }
-}
-
-QGeoPositionInfo QGeoPositionInfoSourceMaemo::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const
-{
- return (LiblocationWrapper::instance()->lastKnownPosition(fromSatellitePositioningMethodsOnly));
-}
-
-QGeoPositionInfoSource::PositioningMethods QGeoPositionInfoSourceMaemo::supportedPositioningMethods() const
-{
- QGeoPositionInfoSource::PositioningMethods methods;
-
- if (!GConfItem("/system/nokia/location/gps-disabled").value().toBool())
- methods |= SatellitePositioningMethods;
- if (!GConfItem("/system/nokia/location/network-disabled").value().toBool())
- methods |= NonSatellitePositioningMethods;
- if (methods.testFlag(SatellitePositioningMethods) && methods.testFlag(NonSatellitePositioningMethods))
- methods |= AllPositioningMethods;
-
- return methods;
-}
-
-void QGeoPositionInfoSourceMaemo::setUpdateInterval(int msec)
-{
- bool updateTimerInterval = false;
-
- if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive)
- if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)
- updateTimerInterval = true;
-
- if (!msec) {
- timerInterval = MINIMUM_UPDATE_INTERVAL;
- QGeoPositionInfoSource::setUpdateInterval(0);
- } else {
- timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec;
- QGeoPositionInfoSource::setUpdateInterval(timerInterval);
- }
-
- if (timerInterval >= POWERSAVE_THRESHOLD)
- positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive;
- else
- positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive;
-
- // If powersave has been active when new update interval has been set,
- // ensure that timer is started.
- if (updateTimerInterval)
- startLocationDaemon();
-
- // Ensure that new timer interval is taken into use immediately.
- activateTimer();
-}
-
-void QGeoPositionInfoSourceMaemo::setPreferredPositioningMethods(PositioningMethods methods)
-{
- QGeoPositionInfoSource::setPreferredPositioningMethods(methods);
-}
-
-int QGeoPositionInfoSourceMaemo::minimumUpdateInterval() const
-{
- return MINIMUM_UPDATE_INTERVAL;
-}
-
-// public slots:
-void QGeoPositionInfoSourceMaemo::startUpdates()
-{
- startLocationDaemon();
-
- // Ensure that powersave is selected, if stopUpdates() has been called,
- // but selected update interval is still greater than POWERSAVE_THRESHOLD.
- if (timerInterval >= POWERSAVE_THRESHOLD)
- positionInfoState |= QGeoPositionInfoSourceMaemo::PowersaveActive;
-
- activateTimer();
-}
-
-void QGeoPositionInfoSourceMaemo::stopUpdates()
-{
- positionInfoState &= ~QGeoPositionInfoSourceMaemo::PowersaveActive;
-
- if (!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive)) {
- updateTimer->stop();
- if (LiblocationWrapper::instance()->isActive())
- LiblocationWrapper::instance()->stop();
- }
-
- errorOccurred = false;
- errorSent = false;
-
- positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started;
- positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped;
-}
-
-void QGeoPositionInfoSourceMaemo::requestUpdate(int timeout)
-{
- int timeoutForRequest = 0;
-
- if (!timeout) {
- if (LiblocationWrapper::instance()->isActive())
- // If GPS is active, assume quick fix.
- timeoutForRequest = DEFAULT_UPDATE_INTERVAL;
- else
- // Otherwise reserve longer time to get a fix.
- timeoutForRequest = POWERSAVE_POWERON_PERIOD;
- } else if (timeout < MINIMUM_UPDATE_INTERVAL) {
- if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive)
- return;
-
- emit updateTimeout();
- return;
- } else {
- timeoutForRequest = timeout;
- }
-
- positionInfoState |= QGeoPositionInfoSourceMaemo::RequestActive;
-
- if (!(LiblocationWrapper::instance()->isActive()))
- LiblocationWrapper::instance()->start();
-
- activateTimer();
- requestTimer->start(timeoutForRequest);
-}
-
-void QGeoPositionInfoSourceMaemo::newPositionUpdate(const QGeoPositionInfo &position)
-{
- /*
- Invalid fixes have NaN for horizontal accuracy regardless of
- whether they come from satellite or non-satellite position methods.
-
- Satellite fixes always have LOCATION_GPS_DEVICE_TIME_SET.
- If this is not set and we have a numeric value for horizontal
- accuracy then we are dealing with a non-satellite based positioning
- method.
-
- Since QGeoPositionInfo instances are only considered valid if
- they have a valid coordinate and a valid timestamp, we use
- the current date and time as the timestamp for the network based
- positioning. This will help in the case where someone wants to
- reply a journey from a log file.
-
- Based on some logging it looks like satellite and non-satellite
- methods can be distinguished (after the initial fix) by whether
- the time has been set and / or whether the horizontal accuracy
- is above or below around 500 metres. Using the timestamp
- appears to be more definitive than using the accuracy.
- */
-
- const bool horizontalAccuracyDefined = !qIsNaN(position.attribute(QGeoPositionInfo::HorizontalAccuracy));
- const bool hasTimeStamp = !position.timestamp().isNull();
-
- if (horizontalAccuracyDefined) {
- if (hasTimeStamp) {
- //Valid satellite fix
- lastUpdateFromSatellite = position;
- } else {
- //Valid non-satellite fix
- QGeoPositionInfo networkPosition(position);
- networkPosition.setTimestamp(QDateTime::currentDateTime());
- lastUpdateFromNetwork = networkPosition;
- }
- } else {
- //Invalid position update
- if (hasTimeStamp) {
- lastUpdateFromSatellite = QGeoPositionInfo();
- } else {
- lastUpdateFromNetwork = QGeoPositionInfo();
- }
- }
-}
-
-void QGeoPositionInfoSourceMaemo::updateTimeoutElapsed()
-{
- QGeoPositionInfo position;
-
- QGeoPositionInfoSource::PositioningMethods methods = preferredPositioningMethods();
-
- if (methods.testFlag(AllPositioningMethods)) {
- methods |= SatellitePositioningMethods;
- methods |= NonSatellitePositioningMethods;
- }
-
- if (methods.testFlag(SatellitePositioningMethods) && !methods.testFlag(NonSatellitePositioningMethods)) {
- //only SatellitePositioningMethods preferred
- position = lastUpdateFromSatellite;
- } else if (methods.testFlag(NonSatellitePositioningMethods) && !methods.testFlag(SatellitePositioningMethods)) {
- //only NonSatellitePositioningMethods preferred
- position = lastUpdateFromNetwork;
- } else {
- //AllPositioningMethods or none preferred
- if (lastUpdateFromSatellite.isValid())
- position = lastUpdateFromSatellite;
- else
- position = lastUpdateFromNetwork;
- }
-
- if (position.isValid()) {
- errorOccurred = false;
- errorSent = false;
-
- if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) {
- positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive;
- requestTimer->stop();
-
- if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)
- if (LiblocationWrapper::instance()->isActive())
- LiblocationWrapper::instance()->stop();
-
- // Ensure that requested position fix is emitted even though
- // powersave is active and GPS would normally be off.
- if ((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) &&
- (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)) {
- emit positionUpdated(position);
- }
- }
-
- // Make sure that if update is triggered when waking up, there
- // is no false position update.
- if (!((positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) &&
- (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)))
- emit positionUpdated(position);
- } else {
- // if an error occurs when we are updating periodically and we haven't
- // sent an error since the last fix...
- if (!(positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) &&
- errorOccurred && !errorSent) {
- errorSent = true;
- // we need to emit the updateTimeout signal
- emit updateTimeout();
- }
- }
- activateTimer();
-}
-
-void QGeoPositionInfoSourceMaemo::requestTimeoutElapsed()
-{
- updateTimer->stop();
- emit updateTimeout();
-
- positionInfoState &= ~QGeoPositionInfoSourceMaemo::RequestActive;
-
- if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped)
- if (LiblocationWrapper::instance()->isActive())
- LiblocationWrapper::instance()->stop();
-
- activateTimer();
-}
-
-void QGeoPositionInfoSourceMaemo::error()
-{
- errorOccurred = true;
-}
-
-void QGeoPositionInfoSourceMaemo::activateTimer()
-{
- if (positionInfoState & QGeoPositionInfoSourceMaemo::RequestActive) {
- updateTimer->start(MINIMUM_UPDATE_INTERVAL);
- return;
- }
-
- if (positionInfoState & QGeoPositionInfoSourceMaemo::PowersaveActive) {
- if (positionInfoState & QGeoPositionInfoSourceMaemo::Started) {
- // Cannot call stopUpdates() here since we want to keep powersave
- // active.
- if (LiblocationWrapper::instance()->isActive())
- LiblocationWrapper::instance()->stop();
- updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD);
- errorOccurred = false;
- errorSent = false;
-
- positionInfoState &= ~QGeoPositionInfoSourceMaemo::Started;
- positionInfoState |= QGeoPositionInfoSourceMaemo::Stopped;
- } else if (positionInfoState & QGeoPositionInfoSourceMaemo::Stopped) {
- startLocationDaemon();
- updateTimer->start(POWERSAVE_POWERON_PERIOD);
- }
- return;
- }
-
- if (positionInfoState & QGeoPositionInfoSourceMaemo::Started)
- updateTimer->start(timerInterval);
-}
-
-void QGeoPositionInfoSourceMaemo::startLocationDaemon()
-{
- if (!(LiblocationWrapper::instance()->isActive()))
- LiblocationWrapper::instance()->start();
- positionInfoState |= QGeoPositionInfoSourceMaemo::Started;
- positionInfoState &= ~QGeoPositionInfoSourceMaemo::Stopped;
-}
-
-#include "moc_qgeopositioninfosource_maemo5_p.cpp"
-QTM_END_NAMESPACE
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOPOSITIONINFOSOURCEMAEMO5_H
-#define QGEOPOSITIONINFOSOURCEMAEMO5_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QTimer>
-#include "qgeopositioninfosource.h"
-
-#define INIT_OK 0
-#define INIT_FAILED -1
-#define MINIMUM_UPDATE_INTERVAL 1000
-#define DEFAULT_UPDATE_INTERVAL 5000
-#define POWERSAVE_THRESHOLD 180000
-#define POWERSAVE_POWERON_PERIOD 120000
-
-QTM_BEGIN_NAMESPACE
-
-class LiblocationWrapper;
-
-class QGeoPositionInfoSourceMaemo : public QGeoPositionInfoSource
-{
- Q_OBJECT
-
-public:
-
- QGeoPositionInfoSourceMaemo(QObject *parent = 0);
-
- int init();
-
- virtual void setUpdateInterval(int interval);
- virtual void setPreferredPositioningMethods(PositioningMethods methods);
- virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const;
- virtual PositioningMethods supportedPositioningMethods() const;
- virtual int minimumUpdateInterval() const;
-
-private:
- bool positionInited;
- QTimer *updateTimer;
- QTimer *requestTimer;
- int timerInterval;
- bool errorOccurred;
- bool errorSent;
-
- void activateTimer();
- void startLocationDaemon();
-
- enum PositionInfoState {
- Undefined = 0,
- Started = 1,
- Stopped = 2,
- RequestActive = 4,
- PowersaveActive = 8
- };
- int positionInfoState;
-
- QGeoPositionInfo lastUpdateFromSatellite;
- QGeoPositionInfo lastUpdateFromNetwork;
-
-signals:
- void positionUpdated(const QGeoPositionInfo &update);
-
-public slots:
- void startUpdates();
- void stopUpdates();
- void requestUpdate(int timeout = DEFAULT_UPDATE_INTERVAL);
-
-private slots:
- void requestTimeoutElapsed();
- void error();
- void newPositionUpdate(const QGeoPositionInfo &position);
- void updateTimeoutElapsed();
-
-private:
- Q_DISABLE_COPY(QGeoPositionInfoSourceMaemo)
-};
-
-QTM_END_NAMESPACE
-
-#endif // QGEOPOSITIONINFOSOURCEMAEMO5_H
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgeosatelliteinfosource_maemo5_p.h"
-#include "liblocationwrapper_p.h"
-
-QTM_BEGIN_NAMESPACE
-
-QGeoSatelliteInfoSourceMaemo::QGeoSatelliteInfoSourceMaemo(QObject *parent)
- : QGeoSatelliteInfoSource(parent)
-{
- qDebug() << "* QGeoSatelliteInfoSourceMaemo Fremantle Backport";
- client_id_ = -1;
- timerInterval = DEFAULT_UPDATE_INTERVAL;
- updateTimer = new QTimer(this);
- updateTimer->setSingleShot(true);
- connect(updateTimer, SIGNAL(timeout()), this, SLOT(satelliteStatus()));
-
- requestTimer = new QTimer(this);
- requestTimer->setSingleShot(true);
- connect(requestTimer, SIGNAL(timeout()), this, SLOT(requestTimeoutElapsed()));
-
- satelliteInfoState = QGeoSatelliteInfoSourceMaemo::Undefined;
-}
-
-int QGeoSatelliteInfoSourceMaemo::init()
-{
- if (LiblocationWrapper::instance()->inited())
- return INIT_OK;
- else
- return INIT_FAILED;
-}
-
-void QGeoSatelliteInfoSourceMaemo::setUpdateInterval(int msec)
-{
- bool updateTimerInterval = false;
-
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive)
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)
- updateTimerInterval = true;
-
- timerInterval = (msec < MINIMUM_UPDATE_INTERVAL) ? MINIMUM_UPDATE_INTERVAL : msec;
-
- if (timerInterval >= POWERSAVE_THRESHOLD)
- satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive;
- else
- satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive;
-
- // If powersave has been active when new update interval has been set,
- // ensure that timer is started.
- if (updateTimerInterval)
- startLocationDaemon();
-
- // Ensure that new timer interval is taken into use immediately.
- activateTimer();
-}
-
-void QGeoSatelliteInfoSourceMaemo::startUpdates()
-{
- startLocationDaemon();
-
- // Ensure that powersave is selected, if stopUpdates() has been called,
- // but selected update interval is still greater than POWERSAVE_THRESHOLD.
- if (timerInterval >= POWERSAVE_THRESHOLD)
- satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::PowersaveActive;
-
- activateTimer();
-}
-
-void QGeoSatelliteInfoSourceMaemo::stopUpdates()
-{
- satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::PowersaveActive;
-
- if (!(satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive)) {
- updateTimer->stop();
- if (LiblocationWrapper::instance()->isActive())
- LiblocationWrapper::instance()->stop();
- }
-
- satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started;
- satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped;
-}
-
-void QGeoSatelliteInfoSourceMaemo::requestUpdate(int timeout)
-{
- int timeoutForRequest = 0;
-
- if (!timeout) {
- if (LiblocationWrapper::instance()->isActive())
- // If GPS is active, assume quick fix.
- timeoutForRequest = DEFAULT_UPDATE_INTERVAL;
- else
- // Otherwise reserve longer time to get a fix.
- timeoutForRequest = POWERSAVE_POWERON_PERIOD;
- } else if (timeout < MINIMUM_UPDATE_INTERVAL) {
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive)
- return;
-
- emit requestTimeout();
- return;
- } else {
- timeoutForRequest = timeout;
- }
-
- satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::RequestActive;
-
- if (!(LiblocationWrapper::instance()->isActive()))
- LiblocationWrapper::instance()->start();
-
- activateTimer();
- requestTimer->start(timeoutForRequest);
-}
-
-void QGeoSatelliteInfoSourceMaemo::satelliteStatus()
-{
- QList<QGeoSatelliteInfo> satellitesInView =
- LiblocationWrapper::instance()->satellitesInView();
- QList<QGeoSatelliteInfo> satellitesInUse =
- LiblocationWrapper::instance()->satellitesInUse();
-
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) {
- satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive;
-
- requestTimer->stop();
-
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) {
- if (LiblocationWrapper::instance()->isActive()) {
- LiblocationWrapper::instance()->stop();
- }
- }
-
- // Ensure that requested satellite info is emitted even though
- // powersave is active and GPS would normally be off.
- if ((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) &&
- (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)) {
- if (satellitesInView.length()) {
- emit satellitesInViewUpdated(satellitesInView);
- emit satellitesInUseUpdated(satellitesInUse);
- }
- }
- }
-
- // Make sure that if update is triggered when waking up, there
- // is no false position update.
- if (!((satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) &&
- (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped))) {
- if (satellitesInView.length()) {
- emit satellitesInViewUpdated(satellitesInView);
- emit satellitesInUseUpdated(satellitesInUse);
- }
- }
-
- activateTimer();
-}
-
-void QGeoSatelliteInfoSourceMaemo::requestTimeoutElapsed()
-{
- updateTimer->stop();
- emit requestTimeout();
-
- satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::RequestActive;
-
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped)
- if (LiblocationWrapper::instance()->isActive())
- LiblocationWrapper::instance()->stop();
-
- activateTimer();
-}
-
-void QGeoSatelliteInfoSourceMaemo::activateTimer()
-{
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::RequestActive) {
- updateTimer->start(MINIMUM_UPDATE_INTERVAL);
- return;
- }
-
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::PowersaveActive) {
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started) {
- // Cannot call stopUpdates() here since we want to keep powersave
- // active.
- if (LiblocationWrapper::instance()->isActive())
- LiblocationWrapper::instance()->stop();
- updateTimer->start(timerInterval - POWERSAVE_POWERON_PERIOD);
-
- satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Started;
- satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Stopped;
- } else if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Stopped) {
- startLocationDaemon();
- updateTimer->start(POWERSAVE_POWERON_PERIOD);
- }
- return;
- }
-
- if (satelliteInfoState & QGeoSatelliteInfoSourceMaemo::Started)
- updateTimer->start(timerInterval);
-}
-
-void QGeoSatelliteInfoSourceMaemo::startLocationDaemon()
-{
- if (!(LiblocationWrapper::instance()->isActive()))
- LiblocationWrapper::instance()->start();
- satelliteInfoState |= QGeoSatelliteInfoSourceMaemo::Started;
- satelliteInfoState &= ~QGeoSatelliteInfoSourceMaemo::Stopped;
-}
-
-#include "moc_qgeosatelliteinfosource_maemo5_p.cpp"
-QTM_END_NAMESPACE
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGEOSATELLITEINFOSOURCE_MAEMO5_H
-#define QGEOSATELLITEINFOSOURCE_MAEMO5_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QTimer>
-#include "qgeosatelliteinfosource.h"
-#include "qgeosatelliteinfo.h"
-
-#define INIT_OK 0
-#define INIT_FAILED -1
-#define MINIMUM_UPDATE_INTERVAL 1000
-#define DEFAULT_UPDATE_INTERVAL 5000
-#define POWERSAVE_THRESHOLD 180000
-#define POWERSAVE_POWERON_PERIOD 120000
-
-QTM_BEGIN_NAMESPACE
-
-class LiblocationWrapper;
-
-class QGeoSatelliteInfoSourceMaemo : public QGeoSatelliteInfoSource
-{
- Q_OBJECT
-
-public:
- explicit QGeoSatelliteInfoSourceMaemo(QObject *parent = 0);
-
- int init();
-
-private:
- int client_id_;
- void setUpdateInterval(int interval);
- QTimer *updateTimer;
- QTimer *requestTimer;
- int timerInterval;
- void activateTimer();
- void startLocationDaemon();
-
- enum SatelliteInfoState {
- Undefined = 0,
- Started = 1,
- Stopped = 2,
- RequestActive = 4,
- PowersaveActive = 8
- };
- int satelliteInfoState;
-
-public slots:
- virtual void startUpdates();
- void stopUpdates();
- void requestUpdate(int timeout = 5000);
- void satelliteStatus();
-
-signals:
- void satellitesInViewUpdated(const QList<QGeoSatelliteInfo> &satellites);
- void satellitesInUseUpdated(const QList<QGeoSatelliteInfo> &satellites);
- void requestTimeout();
-
-private slots:
- void requestTimeoutElapsed();
-
-private:
- Q_DISABLE_COPY(QGeoSatelliteInfoSourceMaemo)
-};
-
-QTM_END_NAMESPACE
-
-#endif // QGEOSATELLITEINFOSOURCE_MAEMO5_H
-
+++ /dev/null
-The Debian Package googlelatitude
-----------------------------
-
-Comments regarding the Package
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> sab, 02 gen 2010 22:12:52 +0100
-
-Thanks to:
-Joppu http://talk.maemo.org/member.php?u=24013
-http://talk.maemo.org/showpost.php?p=449435&postcount=83
+++ /dev/null
-googlelatitude (0.8.0) unstable; urgency=low
-
- * Ovi Store
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sun, 11 Sep 2011 19:01:01 +0200
-
-googlelatitude (0.7-1) unstable; urgency=low
-
- * Enable invoker
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 10 Aug 2011 19:48:00 +0200
-
-googlelatitude (0.7-0) unstable; urgency=low
-
- * OAuth Support
- * Google Latitude 1.0 API Support
- * QtMobility Support
- * QGeoPositionInfoSourceMaemo5 Backport from QtMobility 1.2
- * Qwidget gui for Fremantle
- * QML gui for harmattan
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Thu, 21 Jul 2011 21:58:20 +0200
-
-googlelatitude (0.6-2) unstable; urgency=low
-
- * enable use of gps+cell
- * fix the "start daemon" bug
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Thu, 27 Jan 2011 16:07:22 +0100
-
-googlelatitude (0.6-1) unstable; urgency=low
-
- * auto update setting for daemon, fix start at boot time, fix NaN in gps eph
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 26 Jan 2011 17:23:41 +0100
-
-googlelatitude (0.6-0) unstable; urgency=low
-
- * Daemon at boot time (default off)
- * If not network, do not try to update
- * Use of gps
- * Max 120s for a fix, min of 5 in cell-mode and 15 in gps-mode, default 30s
- * Updates between 1800s, min 300, max 3600
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 26 Jan 2011 16:32:34 +0100
-
-googlelatitude (0.4-7) unstable; urgency=low
-
- * fix maximal accuracy
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 25 Jan 2011 00:48:01 +0100
-
-googlelatitude (0.4-6) unstable; urgency=low
-
- * GUI for the daemon mode
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 22 Jan 2011 23:26:09 +0100
-
-googlelatitude (0.4-5) unstable; urgency=low
-
- * New daemon mode
- * bugs fix
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 22 Jan 2011 18:51:23 +0100
-
-googlelatitude (0.4-0) unstable; urgency=low
-
- * Bump version
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 05 May 2010 16:14:00 +0200
-
-googlelatitude (0.3-9) unstable; urgency=low
-
- * Cleanup, preparation for pr1.2
- * Now Google Location and Buzz
- * TODO: geolocation on webkit
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 05 May 2010 16:05:51 +0200
-
-googlelatitude (0.3-8) unstable; urgency=low
-
- * Testing, minor bugs fix
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 02 Jan 2010 03:53:51 +0100
-
-googlelatitude (0.3-7) unstable; urgency=low
-
- * libqt4 -> diablo = OK, fremantle -> fail
- * libqt4-maemo5 -> fremantle => OK
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 02 Jan 2010 03:40:22 +0100
-
-googlelatitude (0.3-6) unstable; urgency=low
-
- * test libqt4 + libqt4-maemo5
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 02 Jan 2010 02:44:33 +0100
-
-googlelatitude (0.3-5) unstable; urgency=low
-
- * some fix, support to auto update, auto stop on real-fix
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Fri, 01 Jan 2010 23:32:32 +0100
-
-googlelatitude (0.3-1) unstable; urgency=low
-
- * initial support to liblocation
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Fri, 01 Jan 2010 16:20:56 +0100
-
-googlelatitude (0.2-2) unstable; urgency=low
-
- * minor change in gui
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 29 Dec 2009 23:23:46 +0100
-
-googlelatitude (0.2-1) unstable; urgency=low
-
- * more fix...
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 29 Dec 2009 21:53:01 +0100
-
-googlelatitude (0.2-0) unstable; urgency=low
-
- * Google Maps via WebKit
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 29 Dec 2009 12:58:25 +0100
-
-googlelatitude (0.1-4) unstable; urgency=low
-
- * add libgconf2-dev depend... ¿why?
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 16 Dec 2009 19:08:20 +0100
-
-googlelatitude (0.1-3) unstable; urgency=low
-
- * fix depend from libqt4-dev to libqt4-maemo5-dev
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 16 Dec 2009 16:35:12 +0100
-
-googlelatitude (0.1-2) unstable; urgency=low
-
- * fix section
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 16 Dec 2009 15:34:52 +0100
-
-googlelatitude (0.1-1) unstable; urgency=low
-
- * Initial release
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 15 Dec 2009 20:42:16 +0100
+++ /dev/null
-Source: googlelatitude
-Section: user/navigation
-Priority: optional
-Maintainer: Rodrigo Linfati <rodrigo@linfati.cl>
-Build-Depends: debhelper (>= 5), libqt4-dev, libqtm-dev, liblocation-dev, libgconf2-dev
-Standards-Version: 3.7.3
-Homepage: http://www.linfati.com/
-XSBC-Bugtracker: mailto:rodrigo@linfati.cl
-
-Package: googlelatitude
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Google Latitude Updater
- Features:
- - Retrieve location using Cell Tower and/or Gps and send to Google Latitude
- - Run as Daemon
- Note: This is an unofficial client
-XB-Maemo-Display-Name: LatitudeUpdater
-XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAABrRJREFUaIHNmX9oHGUaxz+T3U3StNvG5tqYNgRNkzMH8XKeyxXleqUgaPHAnnpWOTiItCdivKtFkYJ/+IcoRbQXTgmU07YgFUVoK/3jKtiUu6PkIGkttN2kadIYzk2TbLJJ92d2dt73/pjM/pzZ3dnZyn1gmJl33nfm+8z7vM/7vDMKpvy1D/gL0GF+/UfnJtAP7uPQF8m+oBTW/WgdpMI/ji67yHl4bXN2ibuwUuryEx88iW9HKwBCCKSU6WMAKWXOsbHZrW+1md1n2h/jX2//e1O+WhMD6Oj4VStSSm5FFAJxl403ZBMFUx/IZ2t0knt/tt70mpkBeD36m5hLKHSdPeBEYlVY2nUAt0hSVwcrK7nXTA1QkKiaJCX11zMwMHDXReajadDX9zIASenCI5K4TJyhxqxxti/+v2PaA07FaxrMzsLYGCST+haNQmMjdHTomx3yB3g2pgYIIVgNGmU+ACYnYXAQrl3TzwHi8SFUdQJFuYfa2m24XD/B7W7KbsmhQwrNzaUNEBaCTA2wy7ffwtCQJBjUx0wsdoGamhH279/Jgw8+ixCCiYkJQqHrXLw4z8zM7zBC0HvvafT0pHjhhTrq660NsMLShcr1okAAzp0TqKo+nCKRI7z44nYeeeQgipKJkd3d3QDs2AHvv3+O6elf43KtBVxcueJiYWGU11/vsnyOlREVu1A4DGfOwMiIRMoaUqlZHnjgNK+++lrxhsAbbzxOOAxHj8YZH/ezfftVenv/WFR89sSWjWUUKsU338DlywIpFUDicn3OSy/1lmxnEImAqqo8/PCVouINPbZ6oBwXunRJQ9P0wByNnuHNN39LbW1tGdJ1Wlrgscdu4POVNrqiMSCEdaOrVyEazcwqhw//ho0bN5YUko/P5yurXrEoZNuFpISRkdyySsTbodg8YGqA0ciMSARmZtTsmo4Fmj+/PD22o9DUFMzNZc41bQm4pwKJhcTj+pavVQiBYncQW+W5wSAI4UmfK4rHtF65aBqkUpBI6HsrqhaFPAV67a8XDNFGnlSKisJodhTSNH1fUwNbtgAkAH3eV5Q1SEl6M1xPCD13T6UKXcIuxSaysnpgaSlzvLwM58/HkbIeIXRxi4vOBJZCSmm5cLM9BrZuBa83TiiUGbizs4s0N5cOpdEoXLigJ39mHDoEmwpWvRW4kBACIRVTG1wuOHlyC7t3Z8qeeSbO4KDZ+MgwPLzExx//g+Hhf1JXp+LxSJLJV2hoeChdx0y8YYAtFzIaWfXbunW554qyld7eUT77zDqb9PkaOXbseeD5dNm+fTHGxiybFOoxoeJkTlXHc86//76LTz65VZ4amxTTY2qAPpEVz6eHhjrZufM/SKmly44fv5+BgViFMq2pKBcqpxfeeWc7nZ2ncspOnmxg794lgsHibYWg7GVrMT22c6F8jh17FlVdyCkLBBp5+ukEX32lr9jybxUIwNmzEAqVNwlWtKiXsoxPZqsMDTWxvLzE4cOfcv78H/B4mpGynv5+6O+3lEUs9h3btn3I3r1PsXv3U8BaSwOsZkPHa2KDDRsaeffdg5w+/SWnTg1z/XqcSKQdt3sLbnczoKCqN1HVMVpbA7S1eXj00V+yf/8XJe9dkQFlfbQ0Yc+e59iz5zkAwuE7zM/PMjc3y8LCPPfd56Ot7fd4vebfOYthPxeSNj4MWeD1rsfrXU97e6ej+zjOhd5662VHApxiex6QEpACpQq9UBVSydWXWujWZj1wc/p6pKO1aw2bw5PM7jwI5MZi4zixpgm1foMzceEgcvG/ADmTVfbztGiIOz8oCFH41cPMgP5Lf7/6N/e+n7Kp04uHuOVfk4ZklBhtjoyQAT8g05HG7G9NeDrJ1NfLpu2L/iNzu6VphimlpGlbA7/4Uzc1DR7CLT2VqQ8HUW98h//EOHemMx8K8n1e0+qMKwX/yCqLlQAc8YPS1dJVx0MHekg2tZNa01i2cBnwo4YTXHx7ApCj4NkFfbftqrBMJUrj2QVydGZ0hVRkBU9wAlesvKWZIX70xE2ciAdHBvTdNoy4cvTaqhGTpZuF59PiF28pOBEPjlwoG92dNne66Pnzz9E2dyDWNuVWCc8jfvCTiqw4dptsHPRANnpPzI1rqOEEyu0bKJHcfNoQ7z8+TrXEQ9UMyLjTtU9HSUVWUG7fSF+Vd+ZIRVYYPTFOaKqGaomHqrlQNro7NbVLul/pRkpZdbfJpko9kI3eEwuTCmo4sTpgq+s22dyFHgD46F5QBzfeL7uklISmXIC7pdri4a4ZYHDEr++r/+YN/gc9CxXyOCXFlQAAAABJRU5ErkJggg==
-
+++ /dev/null
-This package was debianized by Rodrigo Linfati <rodrigo@linfati.cl> on
-sab, 02 gen 2010 22:12:52 +0100.
-
-It was downloaded from <http://www.linfati.com/>
-
-Upstream Author(s):
-
- Rodrigo Linfati <rodrigo@linfati.cl>
-
-Copyright:
-
- Copyright (C) 2009 Rodrigo Linfati
-
-License:
-
- This package is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This package 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this package; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-On Debian systems, the complete text of the GNU Lesser General
-Public License can be found in `/usr/share/common-licenses/LGPL'.
-
-The Debian packaging is (C) 2010, Rodrigo Linfati <rodrigo@linfati.cl> and
-is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
+++ /dev/null
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # qmake latitudeupdater.pro PREFIX=/usr
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
- # $(MAKE)
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- -$(MAKE) clean
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
- $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/googlelatitude install
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+++ /dev/null
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- qmake latitudeupdater.pro
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
- $(MAKE)
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- -$(MAKE) clean
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
- $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/googlelatitude install
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+++ /dev/null
-The Debian Package latitudeupdater
-----------------------------
-
-Comments regarding the Package
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> sab, 02 gen 2010 22:12:52 +0100
-
-Thanks to:
-Joppu http://talk.maemo.org/member.php?u=24013
-http://talk.maemo.org/showpost.php?p=449435&postcount=83
+++ /dev/null
-latitudeupdater (0.8.0) unstable; urgency=low
-
- * Ovi Store
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sun, 11 Sep 2011 19:01:01 +0200
-
-latitudeupdater (0.8.0) unstable; urgency=low
-
- * Enable invoker
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 10 Aug 2011 19:48:00 +0200
-
-latitudeupdater (0.7-0) unstable; urgency=low
-
- * OAuth Support
- * Google Latitude 1.0 API Support
- * QtMobility Support
- * QGeoPositionInfoSourceMaemo5 Backport from QtMobility 1.2
- * Qwidget gui for Fremantle
- * QML gui for harmattan
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Thu, 21 Jul 2011 21:58:20 +0200
-
-latitudeupdater (0.6-2) unstable; urgency=low
-
- * enable use of gps+cell
- * fix the "start daemon" bug
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Thu, 27 Jan 2011 16:07:22 +0100
-
-latitudeupdater (0.6-1) unstable; urgency=low
-
- * auto update setting for daemon, fix start at boot time, fix NaN in gps eph
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 26 Jan 2011 17:23:41 +0100
-
-latitudeupdater (0.6-0) unstable; urgency=low
-
- * Daemon at boot time (default off)
- * If not network, do not try to update
- * Use of gps
- * Max 120s for a fix, min of 5 in cell-mode and 15 in gps-mode, default 30s
- * Updates between 1800s, min 300, max 3600
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 26 Jan 2011 16:32:34 +0100
-
-latitudeupdater (0.4-7) unstable; urgency=low
-
- * fix maximal accuracy
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 25 Jan 2011 00:48:01 +0100
-
-latitudeupdater (0.4-6) unstable; urgency=low
-
- * GUI for the daemon mode
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 22 Jan 2011 23:26:09 +0100
-
-latitudeupdater (0.4-5) unstable; urgency=low
-
- * New daemon mode
- * bugs fix
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 22 Jan 2011 18:51:23 +0100
-
-latitudeupdater (0.4-0) unstable; urgency=low
-
- * Bump version
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 05 May 2010 16:14:00 +0200
-
-latitudeupdater (0.3-9) unstable; urgency=low
-
- * Cleanup, preparation for pr1.2
- * Now Google Location and Buzz
- * TODO: geolocation on webkit
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 05 May 2010 16:05:51 +0200
-
-latitudeupdater (0.3-8) unstable; urgency=low
-
- * Testing, minor bugs fix
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 02 Jan 2010 03:53:51 +0100
-
-latitudeupdater (0.3-7) unstable; urgency=low
-
- * libqt4 -> diablo = OK, fremantle -> fail
- * libqt4-maemo5 -> fremantle => OK
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 02 Jan 2010 03:40:22 +0100
-
-latitudeupdater (0.3-6) unstable; urgency=low
-
- * test libqt4 + libqt4-maemo5
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Sat, 02 Jan 2010 02:44:33 +0100
-
-latitudeupdater (0.3-5) unstable; urgency=low
-
- * some fix, support to auto update, auto stop on real-fix
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Fri, 01 Jan 2010 23:32:32 +0100
-
-latitudeupdater (0.3-1) unstable; urgency=low
-
- * initial support to liblocation
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Fri, 01 Jan 2010 16:20:56 +0100
-
-latitudeupdater (0.2-2) unstable; urgency=low
-
- * minor change in gui
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 29 Dec 2009 23:23:46 +0100
-
-latitudeupdater (0.2-1) unstable; urgency=low
-
- * more fix...
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 29 Dec 2009 21:53:01 +0100
-
-latitudeupdater (0.2-0) unstable; urgency=low
-
- * Google Maps via WebKit
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 29 Dec 2009 12:58:25 +0100
-
-latitudeupdater (0.1-4) unstable; urgency=low
-
- * add libgconf2-dev depend... ¿why?
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 16 Dec 2009 19:08:20 +0100
-
-latitudeupdater (0.1-3) unstable; urgency=low
-
- * fix depend from libqt4-dev to libqt4-maemo5-dev
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 16 Dec 2009 16:35:12 +0100
-
-latitudeupdater (0.1-2) unstable; urgency=low
-
- * fix section
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Wed, 16 Dec 2009 15:34:52 +0100
-
-latitudeupdater (0.1-1) unstable; urgency=low
-
- * Initial release
-
- -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 15 Dec 2009 20:42:16 +0100
+++ /dev/null
-Source: latitudeupdater
-Section: user/location
-Priority: optional
-Maintainer: Rodrigo Linfati <rodrigo@linfati.cl>
-Build-Depends: debhelper (>= 5), libqt4-dev, libqtm-dev, applauncherd-dev, aegis-builder, pkg-config
-Standards-Version: 3.7.3
-Homepage: http://www.linfati.com/
-XSBC-Bugtracker: mailto:rodrigo@linfati.cl
-
-Package: latitudeupdater
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Google Latitude Updater
- Features:
- - Retrieve location using Cell Tower and/or Gps and send to Google Latitude
- - Run as Daemon
- Note: This is an unofficial client
-XSBC-Maemo-Display-Name: LatitudeUpdater
-XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAOxAAADsQBlSsOGwAABrRJREFUaIHNmX9oHGUaxz+T3U3StNvG5tqYNgRNkzMH8XKeyxXleqUgaPHAnnpWOTiItCdivKtFkYJ/+IcoRbQXTgmU07YgFUVoK/3jKtiUu6PkIGkttN2kadIYzk2TbLJJ92d2dt73/pjM/pzZ3dnZyn1gmJl33nfm+8z7vM/7vDMKpvy1D/gL0GF+/UfnJtAP7uPQF8m+oBTW/WgdpMI/ji67yHl4bXN2ibuwUuryEx88iW9HKwBCCKSU6WMAKWXOsbHZrW+1md1n2h/jX2//e1O+WhMD6Oj4VStSSm5FFAJxl403ZBMFUx/IZ2t0knt/tt70mpkBeD36m5hLKHSdPeBEYlVY2nUAt0hSVwcrK7nXTA1QkKiaJCX11zMwMHDXReajadDX9zIASenCI5K4TJyhxqxxti/+v2PaA07FaxrMzsLYGCST+haNQmMjdHTomx3yB3g2pgYIIVgNGmU+ACYnYXAQrl3TzwHi8SFUdQJFuYfa2m24XD/B7W7KbsmhQwrNzaUNEBaCTA2wy7ffwtCQJBjUx0wsdoGamhH279/Jgw8+ixCCiYkJQqHrXLw4z8zM7zBC0HvvafT0pHjhhTrq660NsMLShcr1okAAzp0TqKo+nCKRI7z44nYeeeQgipKJkd3d3QDs2AHvv3+O6elf43KtBVxcueJiYWGU11/vsnyOlREVu1A4DGfOwMiIRMoaUqlZHnjgNK+++lrxhsAbbzxOOAxHj8YZH/ezfftVenv/WFR89sSWjWUUKsU338DlywIpFUDicn3OSy/1lmxnEImAqqo8/PCVouINPbZ6oBwXunRJQ9P0wByNnuHNN39LbW1tGdJ1Wlrgscdu4POVNrqiMSCEdaOrVyEazcwqhw//ho0bN5YUko/P5yurXrEoZNuFpISRkdyySsTbodg8YGqA0ciMSARmZtTsmo4Fmj+/PD22o9DUFMzNZc41bQm4pwKJhcTj+pavVQiBYncQW+W5wSAI4UmfK4rHtF65aBqkUpBI6HsrqhaFPAV67a8XDNFGnlSKisJodhTSNH1fUwNbtgAkAH3eV5Q1SEl6M1xPCD13T6UKXcIuxSaysnpgaSlzvLwM58/HkbIeIXRxi4vOBJZCSmm5cLM9BrZuBa83TiiUGbizs4s0N5cOpdEoXLigJ39mHDoEmwpWvRW4kBACIRVTG1wuOHlyC7t3Z8qeeSbO4KDZ+MgwPLzExx//g+Hhf1JXp+LxSJLJV2hoeChdx0y8YYAtFzIaWfXbunW554qyld7eUT77zDqb9PkaOXbseeD5dNm+fTHGxiybFOoxoeJkTlXHc86//76LTz65VZ4amxTTY2qAPpEVz6eHhjrZufM/SKmly44fv5+BgViFMq2pKBcqpxfeeWc7nZ2ncspOnmxg794lgsHibYWg7GVrMT22c6F8jh17FlVdyCkLBBp5+ukEX32lr9jybxUIwNmzEAqVNwlWtKiXsoxPZqsMDTWxvLzE4cOfcv78H/B4mpGynv5+6O+3lEUs9h3btn3I3r1PsXv3U8BaSwOsZkPHa2KDDRsaeffdg5w+/SWnTg1z/XqcSKQdt3sLbnczoKCqN1HVMVpbA7S1eXj00V+yf/8XJe9dkQFlfbQ0Yc+e59iz5zkAwuE7zM/PMjc3y8LCPPfd56Ot7fd4vebfOYthPxeSNj4MWeD1rsfrXU97e6ej+zjOhd5662VHApxiex6QEpACpQq9UBVSydWXWujWZj1wc/p6pKO1aw2bw5PM7jwI5MZi4zixpgm1foMzceEgcvG/ADmTVfbztGiIOz8oCFH41cPMgP5Lf7/6N/e+n7Kp04uHuOVfk4ZklBhtjoyQAT8g05HG7G9NeDrJ1NfLpu2L/iNzu6VphimlpGlbA7/4Uzc1DR7CLT2VqQ8HUW98h//EOHemMx8K8n1e0+qMKwX/yCqLlQAc8YPS1dJVx0MHekg2tZNa01i2cBnwo4YTXHx7ApCj4NkFfbftqrBMJUrj2QVydGZ0hVRkBU9wAlesvKWZIX70xE2ciAdHBvTdNoy4cvTaqhGTpZuF59PiF28pOBEPjlwoG92dNne66Pnzz9E2dyDWNuVWCc8jfvCTiqw4dptsHPRANnpPzI1rqOEEyu0bKJHcfNoQ7z8+TrXEQ9UMyLjTtU9HSUVWUG7fSF+Vd+ZIRVYYPTFOaKqGaomHqrlQNro7NbVLul/pRkpZdbfJpko9kI3eEwuTCmo4sTpgq+s22dyFHgD46F5QBzfeL7uklISmXIC7pdri4a4ZYHDEr++r/+YN/gc9CxXyOCXFlQAAAABJRU5ErkJggg==
-
+++ /dev/null
-This package was debianized by Rodrigo Linfati <rodrigo@linfati.cl> on
-sab, 02 gen 2010 22:12:52 +0100.
-
-It was downloaded from <http://www.linfati.com/>
-
-Upstream Author(s):
-
- Rodrigo Linfati <rodrigo@linfati.cl>
-
-Copyright:
-
- Copyright (C) 2009 Rodrigo Linfati
-
-License:
-
- This package is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This package 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this package; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-On Debian systems, the complete text of the GNU Lesser General
-Public License can be found in `/usr/share/common-licenses/LGPL'.
-
-The Debian packaging is (C) 2010, Rodrigo Linfati <rodrigo@linfati.cl> and
-is licensed under the GPL, see `/usr/share/common-licenses/GPL'.
+++ /dev/null
-<aegis>
- <request policy="add">
- <credential name="Location" />
- <for path="/opt/linfati.com/bin/latitude.qml" />
- <for path="/opt/linfati.com/bin/latitude.qt" />
- <for path="/opt/linfati.com/bin/latituded" />
- </request>
-</aegis>
+++ /dev/null
-#!/bin/sh
-
-if [ ! -f /targets/links/scratchbox.config ]
- then
- echo "Starting latituded"
- start apps/latituded
- fi
-
-exit 0
+++ /dev/null
-#!/bin/sh
-
-if [ ! -f /targets/links/scratchbox.config ]
- then
- echo "Stoping latituded"
- stop apps/latituded
- fi
-
-exit 0
+++ /dev/null
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # qmake latitudeupdater.pro PREFIX=/usr
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
- # $(MAKE)
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- -$(MAKE) clean
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
- $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/latitudeupdater install
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+++ /dev/null
-#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- qmake latitudeupdater.pro
- touch configure-stamp
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
- $(MAKE)
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- -$(MAKE) clean
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
- $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/latitudeupdater install
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
- dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
- aegis-deb-add -control debian/latitudeupdater/DEBIAN/control .. debian/latitudeupdater.aegis=_aegis
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure