LatitudeGUI::LatitudeGUI(QMainWindow *parent) : QMainWindow(parent) {
glatitude = new GoogleLatitude(this);
+ gps = new GpsMaemo5(this);
setting = new QSettings();
urllogin = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude");
show_lat();
connect(glatitude, SIGNAL(getOK()), this, SLOT(get_loc()));
+ connect(gps, SIGNAL(getOK()), this, SLOT(get_maemo5()));
+ connect(gps, SIGNAL(getOK_acwp()), this, SLOT(get_acwp()));
+ connect(gps, SIGNAL(getOK_agnss()), this, SLOT(get_agnss()));
connect(glatitude, SIGNAL(setOK()), this, SLOT(set_OK()));
connect(glatitude, SIGNAL(setERROR()), this, SLOT(set_ERROR()));
+ connect(this, SIGNAL(newpos()), this, SLOT(set()));
+
}
void LatitudeGUI::get_loc() {
location_lat->setText(QString::number(glatitude->get_lat()));
location_lon->setText(QString::number(glatitude->get_lon()));
location_acc->setText(QString::number(glatitude->get_acc()));
- statusBar()->showMessage(tr("Using google.com/loc"),2000);
+ status->setText(tr("Using google.com/loc, ip-based" ));
+ emit newpos();
+}
+
+void LatitudeGUI::get_maemo5() {
+ location_lat->setText(QString::number(gps->get_lat()));
+ location_lon->setText(QString::number(gps->get_lon()));
+ location_acc->setText(QString::number(gps->get_acc()));
+ status->setText(tr("Using liblocation "));
+ emit newpos();
}
-void LatitudeGUI::get_cell() {
- statusBar()->showMessage(tr("Using cell... TODO"),2000);
+void LatitudeGUI::get_acwp() {
+ location_lat->setText(QString::number(gps->get_lat()));
+ location_lon->setText(QString::number(gps->get_lon()));
+ location_acc->setText(QString::number(gps->get_acc()));
+ status->setText(tr("Using acwp, cell-based "));
+ emit newpos();
}
-void LatitudeGUI::get_gps() {
- statusBar()->showMessage(tr("Using gps... TODO"),2000);
+void LatitudeGUI::get_agnss() {
+ location_lat->setText(QString::number(gps->get_lat()));
+ location_lon->setText(QString::number(gps->get_lon()));
+ location_acc->setText(QString::number(gps->get_acc()));
+ status->setText(tr("Using agnss, gps-based "));
+ emit newpos();
}
void LatitudeGUI::set() {
glatitude->set(location_lat->text().toDouble(),
location_lon->text().toDouble(),
location_acc->text().toDouble());
- statusBar()->showMessage(tr("Setting location..."),2000);
}
void LatitudeGUI::set_OK() {
- statusBar()->showMessage(tr("Location Updated !"),5000);
+ status->setText(tr("Updated Location !"));
}
void LatitudeGUI::set_ERROR() {
- statusBar()->showMessage(tr("Error in Authentification !"),5000);
+ status->setText(tr("Error in Authentification !"));
}
void LatitudeGUI::save() {
}
void LatitudeGUI::show_map() {
+ // no scrash and stop gps
+ location_lat = new QLineEdit(QString::number(0));
+ location_lon = new QLineEdit(QString::number(0));
+ location_acc = new QLineEdit(QString::number(0));
+ status = new QLineEdit("Ready");
+ login_user = new QLineEdit(setting->value("user","my_username").toString());
+ login_pass = new QLineEdit(setting->value("pass","my_password").toString());
+ gps->stop();
+
+ // webkit magic
maps = new QWebView();
connect(maps, SIGNAL(loadFinished(bool)), this, SLOT(maps_login()));
maps->load(urllogin);
+ // set widget
setCentralWidget(maps);
setWindowTitle(tr("Google Maps"));
+ // menu
menuBar()->clear();
menuBar()->addAction(tr("&Latitude") ,this, SLOT(show_lat()));
}
void LatitudeGUI::show_lat() {
+ // login input
+ login_user = new QLineEdit(setting->value("user","my_username").toString());
+ login_pass = new QLineEdit(setting->value("pass","my_password").toString());
+ login_pass->setEchoMode(QLineEdit::Password);
+ QPushButton *button_update = new QPushButton(tr("Manual &Update"));
+ // login layout
+ QFormLayout *layout_login = new QFormLayout();
+ layout_login->addRow(tr("&Username"), login_user);
+ layout_login->addRow(tr("&Password"), login_pass);
+ layout_login->addRow(button_update);
+ // login connect
+ connect(login_user, SIGNAL(editingFinished()), this, SLOT(save()));
+ connect(login_pass, SIGNAL(editingFinished()), this, SLOT(save()));
+ connect(login_user, SIGNAL(returnPressed()), login_pass, SLOT(setFocus()));
+ connect(login_pass, SIGNAL(returnPressed()), this, SLOT(set()));
+ connect(button_update, SIGNAL(clicked()), this, SLOT(set()));
+
+ // location input
+ location_lat = new QLineEdit(QString::number(0));
+ location_lon = new QLineEdit(QString::number(0));
+ location_acc = new QLineEdit(QString::number(0));
+ // location layout
+ QFormLayout *layout_location = new QFormLayout();
+ layout_location->addRow(tr("lat :"), location_lat);
+ layout_location->addRow(tr("lon :"), location_lon);
+ layout_location->addRow(tr("acc :"), location_acc);
+
+ // source button
+ QPushButton *source_loc = new QPushButton(tr("Update with &IP"));
+ QPushButton *source_cell = new QPushButton(tr("Update with &Cell"));
+ QPushButton *source_gps = new QPushButton(tr("Update with &Gps"));
+ // source layout
+ QHBoxLayout *layout_source = new QHBoxLayout();
+ layout_source->addWidget(source_loc);
+ layout_source->addWidget(source_cell);
+ layout_source->addWidget(source_gps);
+ // source connect
+ connect(source_loc, SIGNAL(clicked()), glatitude, SLOT(get()));
+ connect(source_cell, SIGNAL(clicked()), gps, SLOT(get_acwp()));
+ connect(source_gps, SIGNAL(clicked()), gps, SLOT(get_agnss()));
+
+ // main layout
location = new QWidget();
- QHBoxLayout *layout = new QHBoxLayout();
- layout->addLayout(do_login());
- layout->addLayout(do_location());
+ QHBoxLayout *layout_form = new QHBoxLayout();
+ layout_form->addLayout(layout_login);
+ layout_form->addLayout(layout_location);
+ QVBoxLayout *layout = new QVBoxLayout();
+ status = new QLineEdit("Ready");
+ status->setReadOnly(true);
+ status->setDisabled(true);
+ layout->addLayout(layout_form);
+ layout->addWidget(status);
+ layout->addLayout(layout_source);
location->setLayout(layout);
+ // set widget
setCentralWidget(location);
setWindowTitle(tr("Google Latitude Updater"));
+ // menu
menuBar()->clear();
menuBar()->addAction(tr("&Maps") ,this, SLOT(show_map()));
- menuBar()->addAction(tr("&loc"), glatitude, SLOT(get()));
- menuBar()->addAction(tr("&cell"), this, SLOT(get_cell()));
- menuBar()->addAction(tr("&gps"), this, SLOT(get_gps()));
}
void LatitudeGUI::maps_login() {
maps->page()->mainFrame()->evaluateJavaScript("document.getElementById('gaia_loginform').submit();");
}
}
-
-QFormLayout *LatitudeGUI::do_login() {
- login_user = new QLineEdit(setting->value("user","my_username").toString());
- login_pass = new QLineEdit(setting->value("pass","my_password").toString());
- login_pass->setEchoMode(QLineEdit::Password);
- QPushButton *login_up = new QPushButton(tr("Update Location"));
-
- QFormLayout *layout = new QFormLayout();
- layout->addRow(tr("&Username"), login_user);
- layout->addRow(tr("&Password"), login_pass);
- layout->addRow(login_up);
-
- connect(login_user, SIGNAL(editingFinished()), this, SLOT(save()));
- connect(login_pass, SIGNAL(editingFinished()), this, SLOT(save()));
- connect(login_user, SIGNAL(returnPressed()), login_pass, SLOT(setFocus()));
- connect(login_pass, SIGNAL(returnPressed()), this, SLOT(set()));
- connect(login_up, SIGNAL(clicked()), this, SLOT(set()));
-
- return layout;
-}
-
-QFormLayout *LatitudeGUI::do_location() {
- location_lat = new QLineEdit(QString::number(0));
- location_lon = new QLineEdit(QString::number(0));
- location_acc = new QLineEdit(QString::number(0));
-
- QFormLayout *layout = new QFormLayout();
- layout->addRow(tr("lat :"), location_lat);
- layout->addRow(tr("lon :"), location_lon);
- layout->addRow(tr("acc :"), location_acc);
-
- return layout;
-}