+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Version=1.0
-Type=Application
-Terminal=true
-Name=LatitudeDaemon
-Exec=/opt/LatitudeUpdaterDaemon/bin/LatitudeUpdaterDaemon
-Icon=LatitudeUpdaterDaDaemon
-X-Window-Icon=
-X-HildonDesk-ShowInToolbar=true
-X-Osso-Type=application/x-executable
LatitudeQML::LatitudeQML(QDeclarativeView *parent) :
QDeclarativeView(parent),
latitude(this),
- gps(this) {
+ gps(this),
+ demonioOpt("/opt/LatitudeUpdaterDaemon/bin/LatitudeUpdaterDaemon"),
+ demonioSdk(QCoreApplication::applicationDirPath()+
+ QDir::separator()+
+ "LatitudeUpdaterDaemon"),
+ cli(this) {
qDebug() << "* LatitudeQML::LatitudeQML";
rootContext()->setContextProperty("latitude", &latitude);
rootContext()->setContextProperty("gps", &gps);
+ rootContext()->setContextProperty("demonio", this);
setSource(QUrl("qrc:/qml/main.qml"));
latitude.getAccess();
#include <QObject>
#include <QtDeclarative/QDeclarativeView>
+#include <QtCore/QProcess>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
#include "googlelatitude.h"
#include "gpscontrol.h"
signals:
public slots:
+ bool demonio_status() {
+ qDebug() << "LatitudeQML::demonio_status";
+ if (system("killall -0 LatitudeUpdaterDaemon 2> /dev/null" )) {
+ return false;
+ }
+ return true;
+ }
+ bool demonio_start() {
+ qDebug() << "LatitudeQML::demonio_start";
+ if (demonioOpt.exists()) {
+ qDebug() << "LatitudeQML:: demonio opt";
+ cli.startDetached(demonioOpt.fileName());
+ return true;
+ }
+ if (demonioSdk.exists()) {
+ qDebug() << "LatitudeQML:: demonio sdk";
+ cli.startDetached(demonioSdk.fileName());
+ return true;
+ }
+ qDebug() << "LatitudeQML:: demonio none";
+ return false;
+ }
+ bool demonio_stop() {
+ qDebug() << "LatitudeQML::demonio_stop";
+ if (demonioOpt.exists() || demonioSdk.exists() ) {
+ qDebug() << "LatitudeQML:: demonio kill" << system("killall LatitudeUpdaterDaemon 2> /dev/null");
+ return true;
+ }
+ return false;
+ }
private slots:
private:
GoogleLatitude latitude;
GpsControl gps;
+ QFile demonioOpt;
+ QFile demonioSdk;
+ QProcess cli;
};
#endif // LatitudeQML_H
LatitudeGUI::LatitudeGUI(QWidget *parent) :
QWidget(parent),
latitude(this),
- gps(this) {
+ gps(this),
+ demonioOpt("/opt/LatitudeUpdaterDaemon/bin/LatitudeUpdaterDaemon"),
+ demonioSdk(QCoreApplication::applicationDirPath()+
+ QDir::separator()+
+ "LatitudeUpdaterDaemon"),
+ cli(this) {
qDebug() << "* LatitudeGUI::LatitudeGUI";
setWindowTitle(tr("LatitudeUpdater"));
connect(&latitude, SIGNAL(notToken()), this, SLOT(gl_NotToken()) );
connect(&latitude, SIGNAL(needAuth()), this, SLOT(gl_needAuth()) );
- latitude.getAccess();
+ connect(&gps, SIGNAL(gotFix()), this, SLOT(set_latitude()) );
// row 2
layout_row2 = new QHBoxLayout();
- pos_label = new QLabel("Position");
- pos_lat = new QLineEdit("lat");
- pos_lon = new QLineEdit("lon");
- pos_acc = new QLineEdit("acc");
- pos_tis = new QLineEdit("tis");
-
- pos_lat->setReadOnly(true);
- pos_lon->setReadOnly(true);
- pos_acc->setReadOnly(true);
- pos_tis->setReadOnly(true);
-
- layout_row2->addWidget(pos_label);
- layout_row2->addWidget(pos_lat);
- layout_row2->addWidget(pos_lon);
- layout_row2->addWidget(pos_acc);
- layout_row2->addWidget(pos_tis);
-
- connect(&gps, SIGNAL(gotUpdate()), this, SLOT(get_gps()) );
- connect(&gps, SIGNAL(gotFix()), this, SLOT(set_latitude()) );
-
- // row 3
- layout_row3 = new QHBoxLayout();
gps_group = new QButtonGroup();
gps_method = new QLabel("Method");
gps_cell = new QRadioButton("Cell Tower");
gps_group->addButton(gps_cell);
gps_group->addButton(gps_both);
gps_group->addButton(gps_agps);
- layout_row3->addWidget(gps_method);
- layout_row3->addWidget(gps_cell);
- layout_row3->addWidget(gps_both);
- layout_row3->addWidget(gps_agps);
+ layout_row2->addWidget(gps_method);
+ layout_row2->addWidget(gps_cell);
+ layout_row2->addWidget(gps_both);
+ layout_row2->addWidget(gps_agps);
if ( gps.getPositioningMethod() == "gps" ) gps_agps->setChecked(true);
if ( gps.getPositioningMethod() == "cell" ) gps_cell->setChecked(true);
connect(gps_both, SIGNAL(clicked()), this, SLOT(set_method()) );
connect(gps_agps, SIGNAL(clicked()), this, SLOT(set_method()) );
- // row 4
- layout_row4 = new QHBoxLayout();
+ // row 3
+ layout_row3 = new QHBoxLayout();
gps_to_label = new QLabel("Time Out");
gps_to_slider = new QSlider(Qt::Horizontal);
gps_to_slider->setSingleStep(5);
gps_to_slider->setRange(5, 120);
gps_to_slider->setValue(gps.getTimeOut());
gps_to_slider_value = new QLabel(QString("%1 sec.").arg(gps_to_slider->value()));
- layout_row4->addWidget(gps_to_label);
- layout_row4->addWidget(gps_to_slider);
- layout_row4->addWidget(gps_to_slider_value);
+ layout_row3->addWidget(gps_to_label);
+ layout_row3->addWidget(gps_to_slider);
+ layout_row3->addWidget(gps_to_slider_value);
connect(gps_to_slider, SIGNAL(valueChanged(int)), this, SLOT(set_to(int)) );
- // row 5
- layout_row5 = new QHBoxLayout();
+ // row 4
+ layout_row4 = new QHBoxLayout();
gps_i_label = new QLabel("Interval");
gps_i_slider = new QSlider(Qt::Horizontal);
gps_i_slider->setRange(5, 60);
gps_i_slider->setValue(gps.getInterval()/60);
gps_i_slider_value = new QLabel(QString("%1 min.").arg(gps_i_slider->value()));
- layout_row5->addWidget(gps_i_label);
- layout_row5->addWidget(gps_i_slider);
- layout_row5->addWidget(gps_i_slider_value);
+ layout_row4->addWidget(gps_i_label);
+ layout_row4->addWidget(gps_i_slider);
+ layout_row4->addWidget(gps_i_slider_value);
connect(gps_i_slider, SIGNAL(valueChanged(int)), this, SLOT(set_i(int)) );
- // row 6
- layout_row6 = new QHBoxLayout();
+ // row 5
+ layout_row5 = new QHBoxLayout();
gps_ac_group = new QButtonGroup();
gps_ac_label = new QLabel("Auto Connect");
gps_ac_yes = new QRadioButton("Yes");
gps_ac_not = new QRadioButton("No");
gps_ac_group->addButton(gps_ac_yes);
gps_ac_group->addButton(gps_ac_not);
- layout_row6->addWidget(gps_ac_label);
- layout_row6->addWidget(gps_ac_yes);
- layout_row6->addWidget(gps_ac_not);
+ layout_row5->addWidget(gps_ac_label);
+ layout_row5->addWidget(gps_ac_yes);
+ layout_row5->addWidget(gps_ac_not);
if ( latitude.getAutoConnect() == true ) gps_ac_yes->setChecked(true);
if ( latitude.getAutoConnect() == false ) gps_ac_not->setChecked(true);
layout_gui->addLayout(layout_row3);
layout_gui->addLayout(layout_row4);
layout_gui->addLayout(layout_row5);
- layout_gui->addLayout(layout_row6);
setLayout(layout_gui);
+ latitude.getAccess();
}
#include <QtGui/QWidget>
#include <QtGui/QPushButton>
-#include <QtGui/QLineEdit>
#include <QtGui/QLabel>
-#include <QtGui/QVBoxLayout>
-#include <QtGui/QHBoxLayout>
-#include <QtGui/QRadioButton>
#include <QtGui/QButtonGroup>
+#include <QtGui/QRadioButton>
#include <QtGui/QSlider>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QHBoxLayout>
#include <QtGui/QDesktopServices>
+#include <QtCore/QProcess>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
#include "googlelatitude.h"
#include "gpscontrol.h"
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";
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);
- 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";
- 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() {
private:
GoogleLatitude latitude;
GpsControl gps;
+ QFile demonioOpt;
+ QFile demonioSdk;
+ QProcess cli;
QHBoxLayout *layout_row1;
QPushButton *do_oauth;
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;
- QHBoxLayout *layout_row4;
+ QHBoxLayout *layout_row3;
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;
- QHBoxLayout *layout_row6;
+ QHBoxLayout *layout_row5;
QLabel *gps_ac_label;
QButtonGroup *gps_ac_group;
QRadioButton *gps_ac_yes;
};
#endif // LATITUDEGUI_H
+
#include "latitudedaemon.h"
int main(int argc, char *argv[]) {
- qDebug() << "* main";
+ qDebug() << "* Main Daemon";
QCoreApplication::setOrganizationName("linfati.com");
QCoreApplication::setOrganizationDomain("linfati.com");
QCoreApplication::setApplicationName("latitudeupdater");
#include "latitudeqml.h"
int main(int argc, char *argv[]) {
- qDebug() << "* main";
+ qDebug() << "* Main QML";
QCoreApplication::setOrganizationName("linfati.com");
QCoreApplication::setOrganizationDomain("linfati.com");
QCoreApplication::setApplicationName("latitudeupdater");
#include "latitudewidget.h"
int main(int argc, char *argv[]) {
- qDebug() << "* main";
+ qDebug() << "* Main Widget";
QCoreApplication::setOrganizationName("linfati.com");
QCoreApplication::setOrganizationDomain("linfati.com");
QCoreApplication::setApplicationName("latitudeupdater");
onClicked: {
do_start.enabled = false;
do_stop.enabled = true;
- gps.startUpdates()
+ if (!demonio.demonio_start()) {
+ gps.startUpdates()
+ }
}
}
Button {
onClicked: {
do_start.enabled = true;
do_stop.enabled = false;
- gps.stopUpdates(true)
- }
- }
- }
- Row {
- width: rootWindow.width
- Label {
- id: pos_label
- text: "Position"
- width: rootWindow.width / 4
- anchors.verticalCenter: position.verticalCenter
- }
- Row {
- id: position
- width: rootWindow.width * 3 / 4
- TextField {
- id: pos_lat
- width: parent / 4
- placeholderText: "pos_lat"
- readOnly: true
- }
- TextField {
- id: pos_lon
- width: parent / 4
- placeholderText: "pos_lon"
- readOnly: true
- }
- TextField {
- id: pos_acc
- width: parent / 4
- placeholderText: "pos_acc"
- readOnly: true
- }
- TextField {
- id: pos_tis
- width: parent / 4
- placeholderText: "pos_tis"
- readOnly: true
+ if (!demonio.demonio_stop()) {
+ gps.stopUpdates(true)
+ }
}
}
}
target: latitude
onGotToken: {
do_auth.enabled = false;
- do_start.enabled = true;
- do_stop.enabled = false;
+ if (demonio.demonio_status()) {
+ do_start.enabled = false;
+ do_stop.enabled = true;
+ } else {
+ do_start.enabled = true;
+ do_stop.enabled = false;
+ }
}
}
Connections {
do_auth.enabled = true;
do_start.enabled = false;
do_stop.enabled = false;
- gps.stopUpdates(true)
+ if (!demonio.demonio_stop()) {
+ gps.stopUpdates(true)
+ }
}
}
Connections {
Connections {
target: gps
- onGotUpdate: {
- pos_lat.text = gps.getCurrentLatitude()
- pos_lon.text = gps.getCurrentLongitude()
- pos_acc.text = gps.getCurrentAccuracy()
- pos_tis.text = gps.getCurrentTimestamp()
- }
- }
- Connections {
- target: gps
onGotFix: {
- pos_lat.text = gps.getCurrentLatitude()
- pos_lon.text = gps.getCurrentLongitude()
- pos_acc.text = gps.getCurrentAccuracy()
- pos_tis.text = gps.getCurrentTimestamp()
- latitude.setCurrentLocation(pos_lat.text, pos_lon.text, pos_acc.text)
+ latitude.setCurrentLocation(gps.getCurrentLatitude(),
+ gps.getCurrentLongitude(),
+ gps.getCurrentAccuracy())
latitude.sendCurrentLocation()
}
}