4 #include <QtGui/QWidget>
5 #include <QtGui/QPushButton>
6 #include <QtGui/QLabel>
7 #include <QtGui/QButtonGroup>
8 #include <QtGui/QRadioButton>
9 #include <QtGui/QSlider>
10 #include <QtGui/QVBoxLayout>
11 #include <QtGui/QHBoxLayout>
12 #include <QtGui/QDesktopServices>
13 #include <QtCore/QProcess>
14 #include <QtCore/QCoreApplication>
15 #include <QtCore/QDir>
16 #include <QtCore/QFile>
17 #include "googlelatitude.h"
18 #include "gpscontrol.h"
20 class LatitudeGUI : public QWidget {
23 LatitudeGUI(QWidget *parent = 0);
31 qDebug() << "* LatitudeGUI::gl_GotToken";
32 do_oauth->setDisabled(true);
33 if (system("killall -0 LatitudeUpdaterDaemon 2> /dev/null" )) {
34 do_start->setEnabled(true);
35 do_stop->setDisabled(true);
37 do_start->setDisabled(true);
38 do_stop->setEnabled(true);
42 qDebug() << "* LatitudeGUI::gl_NotToken";
43 do_oauth->setEnabled(true);
44 do_start->setDisabled(true);
45 do_stop->setDisabled(true);
46 gps.stopUpdates(true);
49 qDebug() << "* LatitudeGUI::gl_needAuth";
50 do_oauth->setEnabled(true);
53 qDebug() << "* LatitudeGUI::gl_webauth";
54 QDesktopServices::openUrl(latitude.getUserAuthorization());
57 qDebug() << "* LatitudeGUI::gps_start";
58 do_start->setDisabled(true);
59 do_stop->setEnabled(true);
60 if (demonioOpt.exists()) {
61 qDebug() << "* LatitudeGUI:: demonio opt";
62 cli.startDetached(demonioOpt.fileName());
63 } else if (demonioSdk.exists()) {
64 qDebug() << "* LatitudeGUI:: demonio sdk";
65 cli.startDetached(demonioSdk.fileName());
67 qDebug() << "* LatitudeGUI:: demonio none";
72 qDebug() << "* LatitudeGUI::gps_stop";
73 do_start->setEnabled(true);
74 do_stop->setDisabled(true);
75 if (demonioOpt.exists() || demonioSdk.exists() ) {
76 qDebug() << "* LatitudeGUI:: demonio kill" << system("killall LatitudeUpdaterDaemon 2> /dev/null");
78 gps.stopUpdates(true);
82 qDebug() << "* LatitudeGUI::set_latitude";
83 latitude.setCurrentLocation(gps.getCurrentLatitude(),
84 gps.getCurrentLongitude(),
85 gps.getCurrentAccuracy());
86 latitude.sendCurrentLocation();
89 qDebug() << "* LatitudeGUI::set_method";
90 if (gps_cell->isChecked()) gps.setPositioningMethod("cell");
91 if (gps_both->isChecked()) gps.setPositioningMethod("all");
92 if (gps_agps->isChecked()) gps.setPositioningMethod("gps");
94 void set_to(int value) {
95 qDebug() << "* LatitudeGUI::set_to()" << value;
96 gps.setTimeOut(value);
97 gps_to_slider_value->setText(QString("%1 sec.").arg(value));
100 void set_i(int value) {
101 qDebug() << "* LatitudeGUI::set_i()" << value;
102 gps.setInterval(value*60);
103 gps_i_slider_value->setText(QString("%1 min.").arg(value));
106 qDebug() << "* LatitudeGUI::set_ac_yes";
107 latitude.setAutoConnect(true);
110 qDebug() << "* LatitudeGUI::set_ac_not";
111 latitude.setAutoConnect(false);
115 GoogleLatitude latitude;
121 QHBoxLayout *layout_row1;
122 QPushButton *do_oauth;
123 QPushButton *do_start;
124 QPushButton *do_stop;
126 QHBoxLayout *layout_row2;
128 QButtonGroup *gps_group;
129 QRadioButton *gps_cell;
130 QRadioButton *gps_both;
131 QRadioButton *gps_agps;
133 QHBoxLayout *layout_row3;
134 QLabel *gps_to_label;
135 QSlider *gps_to_slider;
136 QLabel *gps_to_slider_value;
138 QHBoxLayout *layout_row4;
140 QSlider *gps_i_slider;
141 QLabel *gps_i_slider_value;
143 QHBoxLayout *layout_row5;
144 QLabel *gps_ac_label;
145 QButtonGroup *gps_ac_group;
146 QRadioButton *gps_ac_yes;
147 QRadioButton *gps_ac_not;
149 QVBoxLayout *layout_gui;
152 #endif // LATITUDEGUI_H