Version 0.6, daemon, gps, battery saver
[googlelatitude] / src / daemon.cpp
1 #include "daemon.h"
2
3 Daemon::Daemon(QObject *parent) : QObject(parent) {
4     setting = new QSettings();
5     gps = new GpsMaemo5(this);
6     glatitude = new GoogleLatitude(this);
7
8     connect(gps, SIGNAL(fix()), this, SLOT(set()));
9     connect(glatitude, SIGNAL(glat_ok()), this, SLOT(daemon_ok()));
10     connect(glatitude, SIGNAL(glat_error()), this, SLOT(daemon_error()));
11
12     set_config();
13     if ( 0 ) gps->config(15, 3, 0);
14
15     gps->refresh();
16 }
17
18 void Daemon::set() {
19     qDebug() << "Daemon: set";
20     glatitude->update(gps->get_lat(),
21                       gps->get_lon(),
22                       gps->get_acc());
23 }
24
25 void Daemon::set_config() {
26     qDebug() << "Daemon: set_config";
27     glatitude->set_login(setting->value("user","my_username").toString(),
28                          setting->value("pass","my_password").toString());
29
30     gps->config(setting->value("interval",1800).toInt(),
31                 setting->value("wait",30).toInt(),
32                 setting->value("usegps",false).toBool());
33 }
34
35 void Daemon::daemon_ok() {
36     qDebug() << "Daemon: ok";
37 }
38
39 void Daemon::daemon_error() {
40     qDebug() << "Daemon: no auth";
41     QCoreApplication::exit();
42 }