Version 0.6-2, use of cell+gps, fix "start daemon"
authorRodrigo Linfati <rodrigo@linfati.cl>
Thu, 27 Jan 2011 15:09:48 +0000 (16:09 +0100)
committerRodrigo Linfati <rodrigo@linfati.cl>
Thu, 27 Jan 2011 15:09:48 +0000 (16:09 +0100)
data/googlelatitude.desktop
debian/changelog
src/daemon.cpp
src/gps.cpp
src/gps.h
src/latitude.cpp
src/latitude.h

index f5f1df6..091b4ab 100644 (file)
@@ -2,7 +2,7 @@
 Encoding=UTF-8
 Version=1.0
 Type=Application
 Encoding=UTF-8
 Version=1.0
 Type=Application
-Name=Latitude And Buzz
+Name=Latitude & Buzz
 Exec=/opt/linfati.com/GoogleLatitudeGUI
 Icon=googlelatitude
 X-HildonDesk-ShowInToolbar=true
 Exec=/opt/linfati.com/GoogleLatitudeGUI
 Icon=googlelatitude
 X-HildonDesk-ShowInToolbar=true
index b8c83c9..85b8e7d 100644 (file)
@@ -1,3 +1,10 @@
+googlelatitude (0.6-2) unstable; urgency=low
+
+  * enable use of gps+cell
+  * fix the "start daemon" bug
+
+ -- Rodrigo Linfati <rodrigo@linfati.cl>  Thu, 27 Jan 2011 16:07:22 +0100
+
 googlelatitude (0.6-1) unstable; urgency=low
 
   * auto update setting for daemon, fix start at boot time, fix NaN in gps eph
 googlelatitude (0.6-1) unstable; urgency=low
 
   * auto update setting for daemon, fix start at boot time, fix NaN in gps eph
index 481c530..7574870 100644 (file)
@@ -30,7 +30,7 @@ void Daemon::set_config() {
 
     gps->config(setting->value("interval",1800).toInt(),
                 setting->value("wait",30).toInt(),
 
     gps->config(setting->value("interval",1800).toInt(),
                 setting->value("wait",30).toInt(),
-                setting->value("usegps",false).toBool());
+                setting->value("method","cell").toString());
 }
 
 void Daemon::daemon_ok() {
 }
 
 void Daemon::daemon_ok() {
index 833e438..e5c8869 100644 (file)
@@ -3,7 +3,7 @@
 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),
+        interval(1800), wait(30), method("cell"),
         emitfix(false), stopgps(true) {
 #ifdef Q_WS_MAEMO_5
     control = location_gpsd_control_get_default();
         emitfix(false), stopgps(true) {
 #ifdef Q_WS_MAEMO_5
     control = location_gpsd_control_get_default();
@@ -32,9 +32,14 @@ void GpsMaemo5::refresh() {
 #endif
 
 #ifdef Q_WS_MAEMO_5
 #endif
 
 #ifdef Q_WS_MAEMO_5
-    g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
-    if (usegps) {
+    if ( method == QString("cell") ) {
+        g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
+    } else if ( method == QString("both") ) {
+        g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_USER_SELECTED, NULL);
+    } else if ( method == QString("agps") ) {
         g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
         g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
+    } else {
+        g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
     }
     location_gpsd_control_start(control);
 #else
     }
     location_gpsd_control_start(control);
 #else
@@ -61,12 +66,12 @@ void GpsMaemo5::forcestop() {
     stop();
 }
 
     stop();
 }
 
-int GpsMaemo5::config(int i, int w, bool g) {
+int GpsMaemo5::config(int i, int w, QString m) {
     qDebug() << "GpsMaemo5: config";
     stopgps = false;
     interval = i;
     wait = w;
     qDebug() << "GpsMaemo5: config";
     stopgps = false;
     interval = i;
     wait = w;
-    usegps = g;
+    method = m;
     return 0;
 }
 
     return 0;
 }
 
index 087e648..c0ba709 100644 (file)
--- a/src/gps.h
+++ b/src/gps.h
@@ -2,6 +2,7 @@
 #define GPS_H
 
 #include <QtCore>
 #define GPS_H
 
 #include <QtCore>
+#include <QtNetwork>
 
 #ifdef Q_WS_MAEMO_5
 extern "C" {
 
 #ifdef Q_WS_MAEMO_5
 extern "C" {
@@ -28,7 +29,7 @@ public slots:
     void refresh();
     void stop();
     void forcestop();
     void refresh();
     void stop();
     void forcestop();
-    int config(int i, int w, bool g);
+    int config(int i, int w, QString m);
 
 private slots:
 #ifdef Q_WS_MAEMO_5
 
 private slots:
 #ifdef Q_WS_MAEMO_5
@@ -43,7 +44,7 @@ private:
     double accuracy;
     int interval;
     int wait;
     double accuracy;
     int interval;
     int wait;
-    bool usegps;
+    QString method;
     bool emitfix;
     bool stopgps;
 #ifdef Q_WS_MAEMO_5
     bool emitfix;
     bool stopgps;
 #ifdef Q_WS_MAEMO_5
index b1b89c1..5f6038a 100644 (file)
@@ -55,7 +55,7 @@ void LatitudeGUI::set_config() {
 
     gps->config(setting->value("interval",1800).toInt(),
                 setting->value("wait",30).toInt(),
 
     gps->config(setting->value("interval",1800).toInt(),
                 setting->value("wait",30).toInt(),
-                setting->value("usegps",false).toBool());
+                setting->value("method","cell").toString());
 }
 
 void LatitudeGUI::latitude_ok() {
 }
 
 void LatitudeGUI::latitude_ok() {
@@ -102,8 +102,8 @@ void LatitudeGUI::mode_demonio() {
         demonio->setText(tr("&Start Daemon"));
     } else {
         QProcess *cli = new QProcess(this);
         demonio->setText(tr("&Start Daemon"));
     } else {
         QProcess *cli = new QProcess(this);
-        cli->start(QCoreApplication::applicationDirPath()+QDir::separator()+"GoogleLatitudeDaemon");
-        qDebug() << "LatitudeGUI: demonio" << QCoreApplication::applicationDirPath()+"/GoogleLatitudeDaemon";
+        cli->startDetached(QCoreApplication::applicationDirPath()+QDir::separator()+"GoogleLatitudeDaemon");
+        qDebug() << "LatitudeGUI: demonio" << QCoreApplication::applicationDirPath()+QDir::separator()+"GoogleLatitudeDaemon";
         if ( ! system("killall -0 GoogleLatitudeDaemon 2> /dev/null" ) ) {
             demonio->setText(tr("&Stop Daemon"));
         }
         if ( ! system("killall -0 GoogleLatitudeDaemon 2> /dev/null" ) ) {
             demonio->setText(tr("&Stop Daemon"));
         }
@@ -121,12 +121,6 @@ void LatitudeGUI::config() {
 
     QLineEdit *gps_interval = new QLineEdit(setting->value("interval",1800).toString());
     QLineEdit *gps_wait = new QLineEdit(setting->value("wait",30).toString());
 
     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() ) {
 
     QCheckBox *daemon_use = new QCheckBox();
     if ( setting->value("daemon",false).toBool() ) {
@@ -135,25 +129,47 @@ void LatitudeGUI::config() {
         daemon_use->setCheckState(Qt::Unchecked);
     }
 
         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);
+    QRadioButton *gps_cell = new QRadioButton(tr("&Cell Tower"));
+    QRadioButton *gps_both = new QRadioButton(tr("&Both"));
+    QRadioButton *gps_agps = new QRadioButton(tr("Only &Gps"));
+
+    QString gps_setting = setting->value("method","cell").toString();
+    if ( gps_setting == QString("cell") ) {
+        gps_cell->setChecked(true);
+    } else if ( gps_setting == QString("both") ) {
+        gps_both->setChecked(true);
+    } else if ( gps_setting == QString("agps") ) {
+        gps_agps->setChecked(true);
+    } else {
+        gps_cell->setChecked(true);
+    }
+
+    QFormLayout *layout_form = new QFormLayout();
 
 
+    layout_form->addRow(tr("&Username"), login_user);
+    layout_form->addRow(tr("&Password"), login_pass);
     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(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()));
 
+    layout_form->addRow(tr("&Interval for Updates"), gps_interval);
+    layout_form->addRow(tr("&Wait for a Fix"), gps_wait);
+    layout_form->addRow(tr("&Daemon at Boot"), daemon_use);
     connect(gps_interval, SIGNAL(textEdited(QString)), this, SLOT(save_interval(QString)));
     connect(gps_wait, SIGNAL(textEdited(QString)), this, SLOT(save_wait(QString)));
     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)));
 
     connect(daemon_use, SIGNAL(stateChanged(int)), this, SLOT(save_daemon(int)));
 
-    dialoglogin->setLayout(layout_config);
+    QHBoxLayout *layout_gps = new QHBoxLayout;
+    layout_gps->addWidget(gps_cell);
+    layout_gps->addWidget(gps_both);
+    layout_gps->addWidget(gps_agps);
+    layout_form->addRow(layout_gps);
+    connect(gps_cell, SIGNAL(clicked()), this, SLOT(save_gps_cell()));
+    connect(gps_both, SIGNAL(clicked()), this, SLOT(save_gps_both()));
+    connect(gps_agps, SIGNAL(clicked()), this, SLOT(save_gps_agps()));
+
+    dialoglogin->setLayout(layout_form);
     dialoglogin->exec();
 
     if ( setting->value("interval",1800).toInt() < 300 )
     dialoglogin->exec();
 
     if ( setting->value("interval",1800).toInt() < 300 )
@@ -161,7 +177,7 @@ void LatitudeGUI::config() {
     if ( setting->value("interval",1800).toInt() > 3600 )
         setting->setValue("interval", 3600);
 
     if ( setting->value("interval",1800).toInt() > 3600 )
         setting->setValue("interval", 3600);
 
-    if ( setting->value("usegps",false).toBool() ) {
+    if ( QString("agps") == setting->value("method","cell").toString() ) {
         if ( setting->value("wait",30).toInt() < 15 )
             setting->setValue("wait", 15);
     } else {
         if ( setting->value("wait",30).toInt() < 15 )
             setting->setValue("wait", 15);
     } else {
index b0e2540..2b2e2a9 100644 (file)
@@ -32,8 +32,10 @@ private slots:
     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_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)); }
     void save_daemon(int _c) { setting->setValue("daemon", (_c == Qt::Checked ? true : false)); }
+    void save_gps_cell() { setting->setValue("method", "cell"); }
+    void save_gps_both() { setting->setValue("method", "both"); }
+    void save_gps_agps() { setting->setValue("method", "agps"); }
 
 private:
     QSettings *setting;
 
 private:
     QSettings *setting;