update the daemon setting every x time
[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     set_config();
21     glatitude->update(gps->get_lat(),
22                       gps->get_lon(),
23                       gps->get_acc());
24 }
25
26 void Daemon::set_config() {
27     qDebug() << "Daemon: set_config";
28     glatitude->set_login(setting->value("user","my_username").toString(),
29                          setting->value("pass","my_password").toString());
30
31     gps->config(setting->value("interval",1800).toInt(),
32                 setting->value("wait",30).toInt(),
33                 setting->value("usegps",false).toBool());
34 }
35
36 void Daemon::daemon_ok() {
37     qDebug() << "Daemon: ok";
38 }
39
40 void Daemon::daemon_error() {
41     qDebug() << "Daemon: no auth";
42     QCoreApplication::exit();
43 }