--- /dev/null
+author "Danilo Luvizotto <danilo.luvizotto@gmail.com>"
+description "Google Latitude Updater Daemon"
+
+start on started hildon-desktop
+
+console output
+
+post-stop script
+ killall -9 GoogleLatitudeDaemon
+end script
+
+exec /bin/su - user -c "/opt/linfati.com/build/GoogleLatitudeDaemon --init"
+
+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
data/googlelatitude.png usr/share/icons/hicolor/64x64/apps
build/GoogleLatitudeGUI opt/linfati.com
build/GoogleLatitudeDaemon opt/linfati.com
+data/glupdater etc/event.d
Daemon::Daemon(QObject *parent) : QObject(parent) {
setting = new QSettings();
- glatitude = new GoogleLatitude(this);
gps = new GpsMaemo5(this);
+ glatitude = new GoogleLatitude(this);
+
connect(gps, SIGNAL(fix()), this, SLOT(set()));
- connect(glatitude, SIGNAL(OK()), this, SLOT(daemon_OK()));
- connect(glatitude, SIGNAL(ERROR()), this, SLOT(daemon_ERROR()));
+ connect(glatitude, SIGNAL(glat_ok()), this, SLOT(daemon_ok()));
+ connect(glatitude, SIGNAL(glat_error()), this, SLOT(daemon_error()));
+
+ set_config();
+ if ( 0 ) gps->config(15, 3, 0);
+
+ gps->refresh();
}
void Daemon::set() {
qDebug() << "Daemon: set";
- glatitude->login(setting->value("user","my_username").toString(),
- setting->value("pass","my_password").toString());
- glatitude->freq(setting->value("freq","120").toInt());
- glatitude->set(gps->get_lat(),
- gps->get_lon(),
- gps->get_acc());
+ glatitude->update(gps->get_lat(),
+ gps->get_lon(),
+ gps->get_acc());
+}
+
+void Daemon::set_config() {
+ qDebug() << "Daemon: set_config";
+ glatitude->set_login(setting->value("user","my_username").toString(),
+ setting->value("pass","my_password").toString());
+
+ gps->config(setting->value("interval",1800).toInt(),
+ setting->value("wait",30).toInt(),
+ setting->value("usegps",false).toBool());
}
-void Daemon::daemon_OK() {
- qDebug() << "Daemon: send";
+void Daemon::daemon_ok() {
+ qDebug() << "Daemon: ok";
}
-void Daemon::daemon_ERROR() {
+void Daemon::daemon_error() {
qDebug() << "Daemon: no auth";
QCoreApplication::exit();
}
#ifndef DAEMON_H
#define DAEMON_H
-#include <QObject>
-#include "glatitude.h"
+#include <QtCore>
#include "gps.h"
+#include "glatitude.h"
class Daemon : public QObject {
Q_OBJECT
private slots:
void set();
- void daemon_OK();
- void daemon_ERROR();
+ void set_config();
+ void daemon_ok();
+ void daemon_error();
private:
- GoogleLatitude *glatitude;
- GpsMaemo5 *gps;
QSettings *setting;
-
+ GpsMaemo5 *gps;
+ GoogleLatitude *glatitude;
};
#endif // DAEMON_H
#include "glatitude.h"
-GoogleLatitude::GoogleLatitude(QObject *parent) : QObject(parent) {
- user = "";
- pass = "";
- latitude = 0.;
- longitude = 0.;
- accuracy = 0.;
- interval = 120;
+GoogleLatitude::GoogleLatitude(QObject *parent) :
+ QObject(parent),
+ user(""), pass(""), login_error(false),
+ latitude(0), longitude(0), accuracy(0) {
worker = new QNetworkAccessManager();
- connect(worker, SIGNAL(finished(QNetworkReply *)), this, SLOT(finishedreply(QNetworkReply *)));
+ connect(worker, SIGNAL(finished(QNetworkReply *)), this, SLOT(glat_reply(QNetworkReply *)));
urllogin = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview");
urldologin = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLoginAuth?service=friendview");
urlupdate = QUrl::fromEncoded("http://maps.google.com/glm/mmap/mwmfr?hl=en");
-
- lastupdate = 0;
- login_error = false;
}
-void GoogleLatitude::login(QString u, QString p) {
+void GoogleLatitude::set_login(QString u, QString p) {
+ qDebug() << "GoogleLatitude: set_login";
if ( !u.contains('@') ) u.append("@gmail.com");
user = u;
pass = p;
}
-void GoogleLatitude::freq(int f) {
- interval = f;
-}
-
-void GoogleLatitude::reset() {
- lastupdate = 0;
- login_error = false;
- set(latitude, longitude, accuracy);
-}
-
-void GoogleLatitude::set(double la, double lo, double ac) {
- latitude = la;
- longitude = lo;
- accuracy = ac>100000? 100000 : ac;
-
- qDebug() << "GoogleLatitude: set la" << la << "lo" << lo << "ac" << ac << "current" << QDateTime::currentDateTime().toUTC().toTime_t();
+void GoogleLatitude::update(double la, double lo, double ac) {
if (login_error) return;
- if (la*lo == 0) return;
- if (!accuracy) return;
- if ( QDateTime::currentDateTime().toUTC().toTime_t() < lastupdate + interval ) return;
+ if (!la) return;
+ if (!lo) return;
+ if (!ac) return;
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
QNetworkConfigurationManager mgr;
}
#endif
+ qDebug() << "GoogleLatitude: update";
+
+ latitude = la;
+ longitude = lo;
+ accuracy = ac;
+
worker->get(QNetworkRequest(urllogin));
}
-void GoogleLatitude::finishedreply(QNetworkReply *r) {
+void GoogleLatitude::reset() {
+ qDebug() << "GoogleLatitude: reset";
+ login_error = false;
+ update(latitude, longitude, accuracy);
+}
+
+void GoogleLatitude::glat_reply(QNetworkReply *r) {
if ( r->url() == urllogin ) {
qDebug() << "GoogleLatitude: login";
QString aidis = r->readAll();
if (regexp.indexIn(output, 1) != -1) {
qDebug() << "GoogleLatitude: update error auth";
login_error = true;
- emit ERROR();
+ emit glat_error();
} else {
- lastupdate = QDateTime::currentDateTime().toUTC().toTime_t();
- qDebug() << "GoogleLatitude: update ok" << "lastupdate" << lastupdate;
+ qDebug() << "GoogleLatitude: update ok";
qDebug() << output;
- emit OK();
+ emit glat_ok();
}
} else {
qDebug() << "GoogleLatitude Error url" << r->url();
#ifndef GLATITUDE_H
#define GLATITUDE_H
+#include <QtCore>
#include <QtNetwork>
class GoogleLatitude : public QObject {
Q_OBJECT
signals:
- void OK();
- void ERROR();
+ void glat_ok();
+ void glat_error();
public:
GoogleLatitude(QObject *parent = 0);
- void login(QString username, QString password);
- void set(double la, double lo, double ac=1000.);
- void freq(int f=120);
+ void set_login(QString username, QString password);
+ void update(double la, double lo, double ac);
void reset();
- double get_lat() { return latitude; }
- double get_lon() { return longitude; }
- double get_acc() { return accuracy; }
private slots:
- void finishedreply(QNetworkReply *r);
+ void glat_reply(QNetworkReply *r);
private:
- // info
QString user;
QString pass;
+ bool login_error;
double latitude;
double longitude;
double accuracy;
- int interval;
- // stuff
+
QNetworkAccessManager *worker;
QUrl urllogin;
QUrl urldologin;
QUrl urlupdate;
- unsigned int lastupdate;
- bool login_error;
};
#endif // GLATITUDE_H
#include "gps.h"
-GpsMaemo5::GpsMaemo5(QObject *parent) : QObject(parent) {
- latitude = 0;
- longitude = 0;
- accuracy = 0;
+GpsMaemo5::GpsMaemo5(QObject *parent) :
+ QObject(parent),
+ latitude(0), longitude(0), accuracy(0),
+ interval(1800), wait(30), usegps(false),
+ emitfix(false), stopgps(true) {
#ifdef Q_WS_MAEMO_5
control = location_gpsd_control_get_default();
device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
-
g_signal_connect(device, "changed", G_CALLBACK(GpsMaemo5_changed), this);
- g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
- g_object_set(G_OBJECT(control), "preferred-interval", LOCATION_INTERVAL_120S, NULL);
-
- location_gpsd_control_start(control);
#else
urlloc = QUrl::fromEncoded("http://www.google.com/loc/json");
worker = new QNetworkAccessManager();
- connect(worker, SIGNAL(finished(QNetworkReply *)), this, SLOT(finishedreply(QNetworkReply *)));
- gloc();
+ connect(worker, SIGNAL(finished(QNetworkReply *)), this, SLOT(gloc_reply(QNetworkReply *)));
+#endif // Q_WS_MAEMO_5
+}
+
+void GpsMaemo5::refresh() {
+ if ( stopgps ) return;
+ qDebug() << "GpsMaemo5: refresh";
+
+ QTimer::singleShot(interval*1000, this, SLOT(refresh()));
+ QTimer::singleShot(wait*1000, this, SLOT(stop()));
+
+#ifdef Q_WS_MAEMO_5
+ g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
+ if (usegps) {
+ g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
+ }
+ location_gpsd_control_start(control);
+#else
+ worker->post(QNetworkRequest(urlloc), QByteArray("{version:\"1.1.0\"}"));
#endif // Q_WS_MAEMO_5
}
+void GpsMaemo5::stop() {
+ qDebug() << "GpsMaemo5: stop";
+#ifdef Q_WS_MAEMO_5
+ location_gpsd_control_stop(control);
+#else
+#endif // Q_WS_MAEMO_5
+ if (emitfix) {
+ emitfix = false;
+ emit fix();
+ }
+}
+
+void GpsMaemo5::forcestop() {
+ qDebug() << "GpsMaemo5: forcestop";
+ stopgps = true;
+}
+
+int GpsMaemo5::config(int i, int w, bool g) {
+ qDebug() << "GpsMaemo5: config";
+ stopgps = false;
+ interval = i;
+ wait = w;
+ usegps = g;
+ return 0;
+}
+
#ifdef Q_WS_MAEMO_5
void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps) {
if (device->fix) {
gps->latitude = gps->device->fix->latitude;
gps->longitude = gps->device->fix->longitude;
gps->accuracy = gps->device->fix->eph/100.;
- emit gps->fix();
+ gps->emitfix = true;
}
}
}
#else
-void GpsMaemo5::gloc() {
- worker->post(QNetworkRequest(urlloc), QByteArray("{version:\"1.1.0\"}"));
- QTimer::singleShot(45*1000, this, SLOT(gloc()));
-}
-
-void GpsMaemo5::finishedreply(QNetworkReply *r) {
+void GpsMaemo5::gloc_reply(QNetworkReply *r) {
if ( r->url() == urlloc ) {
QString loc = r->readAll();
QRegExp regexp ("\\{\"latitude\":(.*),\"longitude\":(.*),\"accuracy\":(.*)\\}");
latitude = regexp.capturedTexts().at(1).toDouble();
longitude = regexp.capturedTexts().at(2).toDouble();
accuracy = regexp.capturedTexts().at(3).toDouble();
+ if ( accuracy > 100000 ) accuracy = 100000;
qDebug() << "GpsIP lat" << latitude << "lon" << longitude << "acc" << accuracy;
- emit fix();
+ emitfix = true;
} else {
qDebug() << "GpsIP Error url" << r->url();
qDebug() << r->rawHeaderList();
#ifndef GPS_H
#define GPS_H
-#include <QObject>
+#include <QtCore>
#ifdef Q_WS_MAEMO_5
extern "C" {
}
#else
#include <QtNetwork>
-#include <QTimer>
#endif // Q_WS_MAEMO_5
class GpsMaemo5 : public QObject {
double get_lat() { return latitude; }
double get_lon() { return longitude; }
double get_acc() { return accuracy; }
-#ifdef Q_WS_MAEMO_5
- friend void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps);
-#endif // Q_WS_MAEMO_5
+public slots:
+ void refresh();
+ void stop();
+ void forcestop();
+ int config(int i, int w, bool g);
+
+private slots:
#ifdef Q_WS_MAEMO_5
+ friend void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps);
#else
-private slots:
- void finishedreply(QNetworkReply *r);
- void gloc();
+ void gloc_reply(QNetworkReply *r);
#endif // Q_WS_MAEMO_5
private:
double latitude;
double longitude;
double accuracy;
+ int interval;
+ int wait;
+ bool usegps;
+ bool emitfix;
+ bool stopgps;
#ifdef Q_WS_MAEMO_5
- GMainLoop *loop;
LocationGPSDControl *control;
LocationGPSDevice *device;
#else
QUrl urlloc;
QNetworkAccessManager *worker;
#endif // Q_WS_MAEMO_5
-
};
#ifdef Q_WS_MAEMO_5
#include "latitude.h"
LatitudeGUI::LatitudeGUI(QMainWindow *parent) : QMainWindow(parent) {
+ setting = new QSettings();
+ gps = new GpsMaemo5(this);
+ glatitude = new GoogleLatitude(this);
+
+ connect(gps, SIGNAL(fix()), this, SLOT(set()));
+ connect(glatitude, SIGNAL(glat_ok()), this, SLOT(latitude_ok()));
+ connect(glatitude, SIGNAL(glat_error()), this, SLOT(latitude_error()));
+
+ set_config();
+ if ( 0 ) gps->config(15, 3, 0);
+
+ gps->refresh();
+
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5AutoOrientation, true);
#endif
setWindowTitle(tr("Latitude & Buzz"));
- setting = new QSettings();
- // GUI
- url = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude");
maps = new QWebView();
- maps->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
connect(maps, SIGNAL(loadFinished(bool)), this, SLOT(maps_login()));
- maps->load(url);
+
+ maps->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
+ maps->load(QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude"));
+
+ setCentralWidget(maps);
+
menuBar()->addAction(tr("&Latitude"), this, SLOT(mode_latitude()));
menuBar()->addAction(tr("&Buzz"), this, SLOT(mode_buzz()));
menuBar()->addAction(tr("&Config"), this, SLOT(config()));
}
connect(demonio, SIGNAL(triggered()), this, SLOT(mode_demonio()));
menuBar()->addAction(demonio);
-
- // updater
- glatitude = new GoogleLatitude(this);
- gps = new GpsMaemo5(this);
- connect(gps, SIGNAL(fix()), this, SLOT(set()));
- connect(glatitude, SIGNAL(OK()), this, SLOT(latitude_OK()));
- connect(glatitude, SIGNAL(ERROR()), this, SLOT(latitude_ERROR()));
-
- // show it
- setCentralWidget(maps);
}
-void LatitudeGUI::config() {
- // login input
- QDialog *dialoglogin = new QDialog(this);
- QLineEdit *login_user = new QLineEdit(setting->value("user","my_username").toString());
- QLineEdit *login_pass = new QLineEdit(setting->value("pass","my_password").toString());
- login_pass->setEchoMode(QLineEdit::Password);
- QLineEdit *login_freq = new QLineEdit(setting->value("freq","120").toString());
- QFormLayout *layout_login = new QFormLayout();
- layout_login->addRow(tr("&Username"), login_user);
- layout_login->addRow(tr("&Password"), login_pass);
- layout_login->addRow(tr("&Interval"), login_freq);
- connect(login_user, SIGNAL(textEdited(QString)), this, SLOT(save_user(QString)));
- connect(login_pass, SIGNAL(textEdited(QString)), this, SLOT(save_pass(QString)));
- connect(login_freq, SIGNAL(textEdited(QString)), this, SLOT(save_freq(QString)));
- connect(login_user, SIGNAL(returnPressed()), login_pass, SLOT(setFocus()));
- connect(login_pass, SIGNAL(returnPressed()), login_freq, SLOT(setFocus()));
- connect(login_freq, SIGNAL(returnPressed()), dialoglogin, SLOT(accept()));
- dialoglogin->setLayout(layout_login);
- dialoglogin->exec();
-
- set();
- mode_latitude();
- glatitude->reset();
+void LatitudeGUI::set() {
+ qDebug() << "LatitudeGUI: set";
+ glatitude->update(gps->get_lat(),
+ gps->get_lon(),
+ gps->get_acc());
}
+void LatitudeGUI::set_config() {
+ qDebug() << "LatitudeGUI: set_config";
+ glatitude->set_login(setting->value("user","my_username").toString(),
+ setting->value("pass","my_password").toString());
-void LatitudeGUI::set() {
- qDebug() << "LatitudeGUI: set";
- glatitude->login(setting->value("user","my_username").toString(),
- setting->value("pass","my_password").toString());
- glatitude->freq(setting->value("freq","120").toInt());
- glatitude->set(gps->get_lat(),
- gps->get_lon(),
- gps->get_acc());
+ gps->config(setting->value("interval",1800).toInt(),
+ setting->value("wait",30).toInt(),
+ setting->value("usegps",false).toBool());
}
-void LatitudeGUI::latitude_OK() {
- qDebug() << "LatitudeGUI: send";
+void LatitudeGUI::latitude_ok() {
+ qDebug() << "LatitudeGUI: ok";
}
-void LatitudeGUI::latitude_ERROR() {
+void LatitudeGUI::latitude_error() {
#ifdef Q_WS_MAEMO_5
QString error_message = tr("<b>Error in Authentification!</b><br><br>") +
tr("Plese verify your login details<br>");
config();
}
-void LatitudeGUI::save_user(QString _user) {
- setting->setValue("user", _user);
-}
-void LatitudeGUI::save_pass(QString _pass) {
- setting->setValue("pass", _pass);
-}
-void LatitudeGUI::save_freq(QString _freq) {
- setting->setValue("freq", _freq);
-}
-void LatitudeGUI::mode_buzz() {
- maps->load(QUrl::fromEncoded("http://www.google.com/maps/m?l-view=map&l-lci=m,com.google.latitudepublicupdates&ac=f,s,l"));
-}
-
-void LatitudeGUI::mode_latitude() {
- maps->load(QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude"));
-}
-
void LatitudeGUI::maps_login() {
- if ( maps->url() == url ) {
+ if ( maps->url() == QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude") ) {
maps->page()->mainFrame()->evaluateJavaScript(
QString("document.getElementById('Email').value = \"%1\";").arg(
setting->value("user").toString()));
setting->value("pass").toString()));
maps->page()->mainFrame()->evaluateJavaScript("document.getElementById('gaia_loginform').submit();");
}
+ if ( maps->url() == QUrl::fromEncoded("https://www.google.com/accounts/ServiceLoginAuth") ) {
+ latitude_error();
+ }
+}
+
+void LatitudeGUI::mode_buzz() {
+ maps->load(QUrl::fromEncoded("http://www.google.com/maps/m?l-view=map&l-lci=m,com.google.latitudepublicupdates&ac=f,s,l"));
+}
+
+void LatitudeGUI::mode_latitude() {
+ maps->load(QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude"));
}
void LatitudeGUI::mode_demonio() {
}
}
}
+
+void LatitudeGUI::config() {
+ gps->forcestop();
+
+ QDialog *dialoglogin = new QDialog(this);
+
+ QLineEdit *login_user = new QLineEdit(setting->value("user","my_username").toString());
+ QLineEdit *login_pass = new QLineEdit(setting->value("pass","my_password").toString());
+ login_pass->setEchoMode(QLineEdit::Password);
+
+ QLineEdit *gps_interval = new QLineEdit(setting->value("interval",1800).toString());
+ QLineEdit *gps_wait = new QLineEdit(setting->value("wait",30).toString());
+ QCheckBox *gps_use = new QCheckBox();
+ if ( setting->value("usegps",false).toBool() ) {
+ gps_use->setCheckState(Qt::Checked);
+ } else {
+ gps_use->setCheckState(Qt::Unchecked);
+ }
+
+ QCheckBox *daemon_use = new QCheckBox();
+ if ( setting->value("daemon",false).toBool() ) {
+ daemon_use->setCheckState(Qt::Checked);
+ } else {
+ daemon_use->setCheckState(Qt::Unchecked);
+ }
+
+ QFormLayout *layout_config = new QFormLayout();
+ layout_config->addRow(tr("&Username"), login_user);
+ layout_config->addRow(tr("&Password"), login_pass);
+ layout_config->addRow(tr("&Interval for Updates"), gps_interval);
+ layout_config->addRow(tr("&Wait for a Fix"), gps_wait);
+ layout_config->addRow(tr("&Use Gps"), gps_use);
+ layout_config->addRow(tr("&Daemon at Boot"), daemon_use);
+
+ connect(login_user, SIGNAL(textEdited(QString)), this, SLOT(save_user(QString)));
+ connect(login_user, SIGNAL(returnPressed()), login_pass, SLOT(setFocus()));
+ connect(login_pass, SIGNAL(textEdited(QString)), this, SLOT(save_pass(QString)));
+ connect(login_pass, SIGNAL(returnPressed()), dialoglogin, SLOT(accept()));
+
+ connect(gps_interval, SIGNAL(textEdited(QString)), this, SLOT(save_interval(QString)));
+ connect(gps_wait, SIGNAL(textEdited(QString)), this, SLOT(save_wait(QString)));
+ connect(gps_use, SIGNAL(stateChanged(int)), this, SLOT(save_gps(int)));
+ connect(daemon_use, SIGNAL(stateChanged(int)), this, SLOT(save_daemon(int)));
+
+ dialoglogin->setLayout(layout_config);
+ dialoglogin->exec();
+
+ if ( setting->value("interval",1800).toInt() < 300 )
+ setting->setValue("interval", 300);
+ if ( setting->value("interval",1800).toInt() > 3600 )
+ setting->setValue("interval", 3600);
+
+ if ( setting->value("usegps",false).toBool() ) {
+ if ( setting->value("wait",30).toInt() < 15 )
+ setting->setValue("wait", 15);
+ } else {
+ if ( setting->value("wait",30).toInt() < 5 )
+ setting->setValue("wait", 5);
+ }
+ if ( setting->value("wait",30).toInt() > 120 )
+ setting->setValue("wait", 120);
+
+ set_config();
+ glatitude->reset();
+ gps->refresh();
+
+ mode_latitude();
+}
+
#include <QtGui>
#include <QtWebKit>
-#include "glatitude.h"
-#include "gps.h"
#ifdef Q_WS_MAEMO_5
#include <QtMaemo5>
#endif
+#include "glatitude.h"
+#include "gps.h"
class LatitudeGUI : public QMainWindow {
Q_OBJECT
private slots:
void set();
- void config();
- void latitude_OK();
- void latitude_ERROR();
- void save_user(QString);
- void save_pass(QString);
- void save_freq(QString);
+ void set_config();
+ void latitude_ok();
+ void latitude_error();
+
void maps_login();
void mode_buzz();
void mode_latitude();
+
void mode_demonio();
+ void config();
+ void save_user(QString _user) { setting->setValue("user", _user); }
+ void save_pass(QString _pass) { setting->setValue("pass", _pass); }
+ void save_interval(QString _inter) { setting->setValue("interval", _inter.toInt()); }
+ void save_wait(QString _wait) { setting->setValue("wait", _wait.toInt()); }
+ void save_gps(int _c) { setting->setValue("usegps", (_c == Qt::Checked ? true : false)); }
+ void save_daemon(int _c) { setting->setValue("daemon", (_c == Qt::Checked ? true : false)); }
+
private:
- GoogleLatitude *glatitude;
- GpsMaemo5 *gps;
QSettings *setting;
+ GpsMaemo5 *gps;
+ GoogleLatitude *glatitude;
+
QWebView *maps;
- QUrl url;
QAction *demonio;
};
QCoreApplication::setApplicationName("GoogleLatitude");
QCoreApplication app(argc, argv);
- Daemon *demonio;
- demonio = new Daemon();
+
+ if ( app.arguments().contains(QString("--init")) ) {
+ QSettings set;
+ if ( ! set.value("daemon",false).toBool() ) {
+ qDebug() << "No Daemon mode enable";
+ return 0;
+ }
+ }
+
+ Daemon demonio;
+ Q_UNUSED(demonio);
return app.exec();
}
QCoreApplication::setApplicationName("GoogleLatitude");
QApplication app(argc, argv);
- LatitudeGUI *gui = new LatitudeGUI();
- gui->show();
+
+ LatitudeGUI gui;
+ gui.show();
return app.exec();
}