Enable Daemon Option, submit for testing
[googlelatitude] / latitudewidget.h
index 26bb749..b4e6e8a 100644 (file)
@@ -3,14 +3,17 @@
 
 #include <QtGui/QWidget>
 #include <QtGui/QPushButton>
 
 #include <QtGui/QWidget>
 #include <QtGui/QPushButton>
-#include <QtGui/QLineEdit>
 #include <QtGui/QLabel>
 #include <QtGui/QLabel>
-#include <QtGui/QVBoxLayout>
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QRadioButton>
 #include <QtGui/QButtonGroup>
 #include <QtGui/QButtonGroup>
+#include <QtGui/QRadioButton>
 #include <QtGui/QSlider>
 #include <QtGui/QSlider>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QHBoxLayout>
 #include <QtGui/QDesktopServices>
 #include <QtGui/QDesktopServices>
+#include <QtCore/QProcess>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
 #include "googlelatitude.h"
 #include "gpscontrol.h"
 
 #include "googlelatitude.h"
 #include "gpscontrol.h"
 
@@ -27,8 +30,13 @@ private slots:
     void gl_GotToken() {
         qDebug() << "LatitudeGUI::gl_GotToken";
         do_oauth->setDisabled(true);
     void gl_GotToken() {
         qDebug() << "LatitudeGUI::gl_GotToken";
         do_oauth->setDisabled(true);
-        do_start->setEnabled(true);
-        do_stop->setDisabled(true);
+        if (system("killall -0 LatitudeUpdaterDaemon 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";
     }
     void gl_NotToken() {
         qDebug() << "LatitudeGUI::gl_NotToken";
@@ -49,26 +57,32 @@ private slots:
         qDebug() << "LatitudeGUI::gps_start";
         do_start->setDisabled(true);
         do_stop->setEnabled(true);
         qDebug() << "LatitudeGUI::gps_start";
         do_start->setDisabled(true);
         do_stop->setEnabled(true);
-        gps.startUpdates();
+        if (demonioOpt.exists()) {
+            qDebug() << "LatitudeGUI:: demonio opt";
+            cli.startDetached(demonioOpt.fileName());
+        } else if (demonioSdk.exists()) {
+            qDebug() << "LatitudeGUI:: demonio sdk";
+            cli.startDetached(demonioSdk.fileName());
+        } else {
+            qDebug() << "LatitudeGUI:: demonio none";
+            gps.startUpdates();
+        }
     }
     void gps_stop() {
         qDebug() << "LatitudeGUI::gps_stop";
         do_start->setEnabled(true);
         do_stop->setDisabled(true);
     }
     void gps_stop() {
         qDebug() << "LatitudeGUI::gps_stop";
         do_start->setEnabled(true);
         do_stop->setDisabled(true);
-        gps.stopUpdates(true);
-    }
-    void get_gps()  {
-        qDebug() << "LatitudeGUI::get_gps";
-        pos_lat->setText(QString("%1").arg(gps.getCurrentLatitude()));
-        pos_lon->setText(QString("%1").arg(gps.getCurrentLongitude()));
-        pos_acc->setText(QString("%1").arg(gps.getCurrentAccuracy()));
-        pos_tis->setText(QString("%1").arg(gps.getCurrentTimestamp()));
+        if (demonioOpt.exists() || demonioSdk.exists() ) {
+            qDebug() << "LatitudeGUI:: demonio kill" << system("killall LatitudeUpdaterDaemon 2> /dev/null");
+        } else {
+            gps.stopUpdates(true);
+        }
     }
     void set_latitude() {
         qDebug() << "LatitudeGUI::set_latitude";
     }
     void set_latitude() {
         qDebug() << "LatitudeGUI::set_latitude";
-        latitude.setCurrentLocation(pos_lat->text().toDouble(),
-                                    pos_lon->text().toDouble(),
-                                    pos_acc->text().toDouble());
+        latitude.setCurrentLocation(gps.getCurrentLatitude(),
+                                    gps.getCurrentLongitude(),
+                                    gps.getCurrentAccuracy());
         latitude.sendCurrentLocation();
     }
     void set_method() {
         latitude.sendCurrentLocation();
     }
     void set_method() {
@@ -100,6 +114,9 @@ private slots:
 private:
     GoogleLatitude latitude;
     GpsControl gps;
 private:
     GoogleLatitude latitude;
     GpsControl gps;
+    QFile demonioOpt;
+    QFile demonioSdk;
+    QProcess cli;
 
     QHBoxLayout *layout_row1;
     QPushButton *do_oauth;
 
     QHBoxLayout *layout_row1;
     QPushButton *do_oauth;
@@ -107,30 +124,23 @@ private:
     QPushButton *do_stop;
 
     QHBoxLayout *layout_row2;
     QPushButton *do_stop;
 
     QHBoxLayout *layout_row2;
-    QLabel *pos_label;
-    QLineEdit *pos_lat;
-    QLineEdit *pos_lon;
-    QLineEdit *pos_acc;
-    QLineEdit *pos_tis;
-
-    QHBoxLayout *layout_row3;
     QLabel *gps_method;
     QButtonGroup *gps_group;
     QRadioButton *gps_cell;
     QRadioButton *gps_both;
     QRadioButton *gps_agps;
 
     QLabel *gps_method;
     QButtonGroup *gps_group;
     QRadioButton *gps_cell;
     QRadioButton *gps_both;
     QRadioButton *gps_agps;
 
-    QHBoxLayout *layout_row4;
+    QHBoxLayout *layout_row3;
     QLabel *gps_to_label;
     QSlider *gps_to_slider;
     QLabel *gps_to_slider_value;
 
     QLabel *gps_to_label;
     QSlider *gps_to_slider;
     QLabel *gps_to_slider_value;
 
-    QHBoxLayout *layout_row5;
+    QHBoxLayout *layout_row4;
     QLabel *gps_i_label;
     QSlider *gps_i_slider;
     QLabel *gps_i_slider_value;
 
     QLabel *gps_i_label;
     QSlider *gps_i_slider;
     QLabel *gps_i_slider_value;
 
-    QHBoxLayout *layout_row6;
+    QHBoxLayout *layout_row5;
     QLabel *gps_ac_label;
     QButtonGroup *gps_ac_group;
     QRadioButton *gps_ac_yes;
     QLabel *gps_ac_label;
     QButtonGroup *gps_ac_group;
     QRadioButton *gps_ac_yes;
@@ -140,3 +150,4 @@ private:
 };
 
 #endif // LATITUDEGUI_H
 };
 
 #endif // LATITUDEGUI_H
+