Version 0.6-2, use of cell+gps, fix "start daemon"
[googlelatitude] / src / daemon.cpp
index 7e9886d..7574870 100644 (file)
@@ -2,26 +2,42 @@
 
 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->set(gps->get_lat(),
-                   gps->get_lon(),
-                   gps->get_acc());
+    set_config();
+    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("method","cell").toString());
 }
 
-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();
 }