3 LatitudeGUI::LatitudeGUI(QMainWindow *parent) : QMainWindow(parent) {
4 glatitude = new GoogleLatitude(this);
5 gps = new GpsMaemo5(this);
6 setting = new QSettings();
7 urllogin = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude");
11 connect(glatitude, SIGNAL(getOK()), this, SLOT(get_loc()));
12 connect(gps, SIGNAL(getOK()), this, SLOT(get_maemo5()));
13 connect(gps, SIGNAL(getOK_acwp()), this, SLOT(get_acwp()));
14 connect(gps, SIGNAL(getOK_agnss()), this, SLOT(get_agnss()));
15 connect(glatitude, SIGNAL(setOK()), this, SLOT(set_OK()));
16 connect(glatitude, SIGNAL(setERROR()), this, SLOT(set_ERROR()));
17 connect(this, SIGNAL(newpos()), this, SLOT(set()));
21 void LatitudeGUI::get_loc() {
22 location_lat->setText(QString::number(glatitude->get_lat()));
23 location_lon->setText(QString::number(glatitude->get_lon()));
24 location_acc->setText(QString::number(glatitude->get_acc()));
25 status->setText(tr("Using google.com/loc, ip-based" ));
29 void LatitudeGUI::get_maemo5() {
30 location_lat->setText(QString::number(gps->get_lat()));
31 location_lon->setText(QString::number(gps->get_lon()));
32 location_acc->setText(QString::number(gps->get_acc()));
33 status->setText(tr("Using liblocation "));
37 void LatitudeGUI::get_acwp() {
38 location_lat->setText(QString::number(gps->get_lat()));
39 location_lon->setText(QString::number(gps->get_lon()));
40 location_acc->setText(QString::number(gps->get_acc()));
41 status->setText(tr("Using acwp, cell-based "));
45 void LatitudeGUI::get_agnss() {
46 location_lat->setText(QString::number(gps->get_lat()));
47 location_lon->setText(QString::number(gps->get_lon()));
48 location_acc->setText(QString::number(gps->get_acc()));
49 status->setText(tr("Using agnss, gps-based "));
53 void LatitudeGUI::set() {
54 glatitude->login(login_user->text(),
56 glatitude->set(location_lat->text().toDouble(),
57 location_lon->text().toDouble(),
58 location_acc->text().toDouble());
61 void LatitudeGUI::set_OK() {
62 status->setText(tr("Updated Location !"));
65 void LatitudeGUI::set_ERROR() {
66 status->setText(tr("Error in Authentification !"));
69 void LatitudeGUI::save() {
70 setting->setValue("user", login_user->text());
71 setting->setValue("pass", login_pass->text());
74 void LatitudeGUI::show_map() {
75 // no scrash and stop gps
76 location_lat = new QLineEdit(QString::number(0));
77 location_lon = new QLineEdit(QString::number(0));
78 location_acc = new QLineEdit(QString::number(0));
79 status = new QLineEdit("Ready");
80 login_user = new QLineEdit(setting->value("user","my_username").toString());
81 login_pass = new QLineEdit(setting->value("pass","my_password").toString());
85 maps = new QWebView();
86 connect(maps, SIGNAL(loadFinished(bool)), this, SLOT(maps_login()));
90 setCentralWidget(maps);
91 setWindowTitle(tr("Google Maps"));
95 menuBar()->addAction(tr("&Latitude") ,this, SLOT(show_lat()));
98 void LatitudeGUI::show_lat() {
100 login_user = new QLineEdit(setting->value("user","my_username").toString());
101 login_pass = new QLineEdit(setting->value("pass","my_password").toString());
102 login_pass->setEchoMode(QLineEdit::Password);
103 QPushButton *button_update = new QPushButton(tr("Manual &Update"));
105 QFormLayout *layout_login = new QFormLayout();
106 layout_login->addRow(tr("&Username"), login_user);
107 layout_login->addRow(tr("&Password"), login_pass);
108 layout_login->addRow(button_update);
110 connect(login_user, SIGNAL(editingFinished()), this, SLOT(save()));
111 connect(login_pass, SIGNAL(editingFinished()), this, SLOT(save()));
112 connect(login_user, SIGNAL(returnPressed()), login_pass, SLOT(setFocus()));
113 connect(login_pass, SIGNAL(returnPressed()), this, SLOT(set()));
114 connect(button_update, SIGNAL(clicked()), this, SLOT(set()));
117 location_lat = new QLineEdit(QString::number(0));
118 location_lon = new QLineEdit(QString::number(0));
119 location_acc = new QLineEdit(QString::number(0));
121 QFormLayout *layout_location = new QFormLayout();
122 layout_location->addRow(tr("lat :"), location_lat);
123 layout_location->addRow(tr("lon :"), location_lon);
124 layout_location->addRow(tr("acc :"), location_acc);
127 QPushButton *source_loc = new QPushButton(tr("Update with &IP"));
128 QPushButton *source_cell = new QPushButton(tr("Update with &Cell"));
129 QPushButton *source_gps = new QPushButton(tr("Update with &Gps"));
131 QHBoxLayout *layout_source = new QHBoxLayout();
132 layout_source->addWidget(source_loc);
133 layout_source->addWidget(source_cell);
134 layout_source->addWidget(source_gps);
136 connect(source_loc, SIGNAL(clicked()), glatitude, SLOT(get()));
137 connect(source_cell, SIGNAL(clicked()), gps, SLOT(get_acwp()));
138 connect(source_gps, SIGNAL(clicked()), gps, SLOT(get_agnss()));
141 location = new QWidget();
142 QHBoxLayout *layout_form = new QHBoxLayout();
143 layout_form->addLayout(layout_login);
144 layout_form->addLayout(layout_location);
145 QVBoxLayout *layout = new QVBoxLayout();
146 status = new QLineEdit("Ready");
147 status->setReadOnly(true);
148 status->setDisabled(true);
149 layout->addLayout(layout_form);
150 layout->addWidget(status);
151 layout->addLayout(layout_source);
152 location->setLayout(layout);
155 setCentralWidget(location);
156 setWindowTitle(tr("Google Latitude Updater"));
160 menuBar()->addAction(tr("&Maps") ,this, SLOT(show_map()));
163 void LatitudeGUI::maps_login() {
164 if ( maps->url() == urllogin ) {
165 maps->page()->mainFrame()->evaluateJavaScript(
166 QString("document.getElementById('Email').value = \"%1\";").arg(
167 setting->value("user").toString()));
168 maps->page()->mainFrame()->evaluateJavaScript(
169 QString("document.getElementById('Passwd').value = \"%1\";").arg(
170 setting->value("pass").toString()));
171 maps->page()->mainFrame()->evaluateJavaScript("document.getElementById('gaia_loginform').submit();");