From f66076c2991b0519cde383b2d09167333d55f5d6 Mon Sep 17 00:00:00 2001 From: Rodrigo Linfati Date: Thu, 27 Jan 2011 16:09:48 +0100 Subject: [PATCH] Version 0.6-2, use of cell+gps, fix "start daemon" --- data/googlelatitude.desktop | 2 +- debian/changelog | 7 ++++++ src/daemon.cpp | 2 +- src/gps.cpp | 15 ++++++++---- src/gps.h | 5 ++-- src/latitude.cpp | 54 ++++++++++++++++++++++++++++--------------- src/latitude.h | 4 +++- 7 files changed, 60 insertions(+), 29 deletions(-) diff --git a/data/googlelatitude.desktop b/data/googlelatitude.desktop index f5f1df6..091b4ab 100644 --- a/data/googlelatitude.desktop +++ b/data/googlelatitude.desktop @@ -2,7 +2,7 @@ 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 diff --git a/debian/changelog b/debian/changelog index b8c83c9..85b8e7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +googlelatitude (0.6-2) unstable; urgency=low + + * enable use of gps+cell + * fix the "start daemon" bug + + -- Rodrigo Linfati 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 diff --git a/src/daemon.cpp b/src/daemon.cpp index 481c530..7574870 100644 --- a/src/daemon.cpp +++ b/src/daemon.cpp @@ -30,7 +30,7 @@ void Daemon::set_config() { 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() { diff --git a/src/gps.cpp b/src/gps.cpp index 833e438..e5c8869 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -3,7 +3,7 @@ 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(); @@ -32,9 +32,14 @@ void GpsMaemo5::refresh() { #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); + } else { + g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL); } location_gpsd_control_start(control); #else @@ -61,12 +66,12 @@ void GpsMaemo5::forcestop() { 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; - usegps = g; + method = m; return 0; } diff --git a/src/gps.h b/src/gps.h index 087e648..c0ba709 100644 --- a/src/gps.h +++ b/src/gps.h @@ -2,6 +2,7 @@ #define GPS_H #include +#include #ifdef Q_WS_MAEMO_5 extern "C" { @@ -28,7 +29,7 @@ public slots: 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 @@ -43,7 +44,7 @@ private: double accuracy; int interval; int wait; - bool usegps; + QString method; bool emitfix; bool stopgps; #ifdef Q_WS_MAEMO_5 diff --git a/src/latitude.cpp b/src/latitude.cpp index b1b89c1..5f6038a 100644 --- a/src/latitude.cpp +++ b/src/latitude.cpp @@ -55,7 +55,7 @@ void LatitudeGUI::set_config() { 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() { @@ -102,8 +102,8 @@ void LatitudeGUI::mode_demonio() { 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")); } @@ -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()); - 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() ) { @@ -135,25 +129,47 @@ void LatitudeGUI::config() { 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())); + 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_use, SIGNAL(stateChanged(int)), this, SLOT(save_gps(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 ) @@ -161,7 +177,7 @@ void LatitudeGUI::config() { 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 { diff --git a/src/latitude.h b/src/latitude.h index b0e2540..2b2e2a9 100644 --- a/src/latitude.h +++ b/src/latitude.h @@ -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_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_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; -- 1.7.9.5