From: Rodrigo Linfati Date: Wed, 5 May 2010 14:09:04 +0000 (+0200) Subject: new version X-Git-Url: http://git.maemo.org/git/?p=googlelatitude;a=commitdiff_plain;h=b5c1cf9c738640b0be7d4d0a8545116a97012319;hp=dca480d9cde6b49db25fee8e173cdaf1277af899 new version --- diff --git a/data/googlelatitude.desktop b/data/googlelatitude.desktop index 9926c62..80f40a7 100644 --- a/data/googlelatitude.desktop +++ b/data/googlelatitude.desktop @@ -1,9 +1,9 @@ [Desktop Entry] Encoding=UTF-8 -Version=0.1 +Version=1.0 Type=Application Name=Google Latitude Update -Exec=/opt/linfati.cl/googlelatitude +Exec=/opt/linfati.com/googlelatitude Icon=googlelatitude X-HildonDesk-ShowInToolbar=true X-Osso-Type=application/x-executable diff --git a/debian/changelog b/debian/changelog index 9bcb3d0..4327623 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,10 @@ googlelatitude (0.3-9) unstable; urgency=low * Cleanup, preparation for pr1.2 + * Now Google Location and Buzz + * TODO: geolocation on webkit - -- Rodrigo Linfati Wed, 05 May 2010 11:21:28 +0200 + -- Rodrigo Linfati Wed, 05 May 2010 16:05:51 +0200 googlelatitude (0.3-8) unstable; urgency=low diff --git a/debian/control b/debian/control index a8023c2..3ec395b 100644 --- a/debian/control +++ b/debian/control @@ -10,17 +10,21 @@ XSBC-Bugtracker: mailto:rodrigo@linfati.cl Package: googlelatitude Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Google Latitude Updater - A Google Latitude Updater written in QT4 with a map and updater mode. +Description: Google Latitude and Buzz + Google Latitude Updater is written in QT4. Features: - - Retrieve location using: - * IP - * Cell Tower (gsm/wcdma) - * Gps - - Manual Update + - Retrieve location using Cell Tower and send to Google Latitude - View Location of Friends + - View Buzz of Friends + - View and Search on Google Maps +XB-Maemo-Display-Name: Google Latitude and Buzz +XB-Description: Google Latitude and Buzz Client + Google Latitude Updater is written in QT4. + Features: + - Retrieve location using Cell Tower and send to Google Latitude + - View Location of Friends + - View Buzz of Friends - View and Search on Google Maps -XB-Maemo-Display-Name: Google Latitude Updater XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAAEgBckRAAAAB3RJTUUH2gEC ARA3G6WpuwAAAAlwSFlzAAAN1gAADdYBkG95nAAAAARnQU1BAACxjwv8YQUA diff --git a/debian/googlelatitude.install b/debian/googlelatitude.install index a18a247..51f5a6a 100644 --- a/debian/googlelatitude.install +++ b/debian/googlelatitude.install @@ -1,3 +1,3 @@ data/googlelatitude.desktop usr/share/applications/hildon data/googlelatitude.png usr/share/icons/hicolor/64x64/apps -build/googlelatitude opt/linfati.cl +build/googlelatitude opt/linfati.com diff --git a/googlelatitude.pro b/googlelatitude.pro index 61e9af5..6ca7dca 100644 --- a/googlelatitude.pro +++ b/googlelatitude.pro @@ -1,5 +1,5 @@ TARGET = googlelatitude -HEADERS += src/latitude.h src/glatitude.h src/gps.h src/gpsfake.h +HEADERS += src/latitude.h src/glatitude.h src/gps.h SOURCES += src/main.cpp src/latitude.cpp src/glatitude.cpp src/gps.cpp OBJECTS_DIR = build @@ -7,11 +7,6 @@ MOC_DIR = build DESTDIR = build TEMPLATE = app -QT += network webkit - -contains(QT_CONFIG, maemo5) { - CONFIG += link_pkgconfig - PKGCONFIG += glib-2.0 liblocation - DEFINES += LIBLOCATION - message(maemo5) -} +QT += network webkit maemo5 +CONFIG += link_pkgconfig +PKGCONFIG += glib-2.0 liblocation diff --git a/src/glatitude.cpp b/src/glatitude.cpp index 7d8881a..a00f7c9 100644 --- a/src/glatitude.cpp +++ b/src/glatitude.cpp @@ -13,7 +13,6 @@ GoogleLatitude::GoogleLatitude(QObject *parent) : QObject(parent) { urllogin = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview"); urldologin = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLoginAuth?service=friendview"); urlupdate = QUrl::fromEncoded("http://maps.google.com/glm/mmap/mwmfr?hl=en"); - urlloc = QUrl::fromEncoded("http://www.google.com/loc/json"); } void GoogleLatitude::login(QString u, QString p) { @@ -31,11 +30,6 @@ void GoogleLatitude::set(double la, double lo, double ac) { worker->get(QNetworkRequest(urllogin)); } -void GoogleLatitude::get() { - QByteArray postloc = QByteArray("{version:\"1.1.0\"}"); - worker->post(QNetworkRequest(urlloc),postloc); -} - void GoogleLatitude::finishedreply(QNetworkReply *r) { if ( r->url() == urllogin ) { QString aidis = r->readAll(); @@ -64,21 +58,11 @@ void GoogleLatitude::finishedreply(QNetworkReply *r) { QString output = r->readAll(); QRegExp regexp ("Authentication required"); if (regexp.indexIn(output, 1) != -1) { - emit setERROR(); + emit ERROR(); } else { - emit setOK(); + emit OK(); } qDebug() << output; - } else if ( r->url() == urlloc ) { - QString loc = r->readAll(); - QRegExp regexp ("\\{\"latitude\":(.*),\"longitude\":(.*),\"accuracy\":(.*)\\}"); - regexp.setMinimal(1); - regexp.indexIn(loc, 1); - latitude = regexp.capturedTexts().at(1).toDouble(); - longitude = regexp.capturedTexts().at(2).toDouble(); - accuracy = regexp.capturedTexts().at(3).toDouble(); - emit getOK(); - qDebug() << "lat = " + QString::number(latitude) + " lng = " + QString::number(longitude) + " acc = " + QString::number(accuracy); } else { qDebug() << "Error"; qDebug() << "url:" << r->url(); diff --git a/src/glatitude.h b/src/glatitude.h index b752c81..3083696 100644 --- a/src/glatitude.h +++ b/src/glatitude.h @@ -7,12 +7,8 @@ class GoogleLatitude : public QObject { Q_OBJECT signals: - void setOK(); - void setERROR(); - void getOK(); - -public slots: - void get(); + void OK(); + void ERROR(); public: GoogleLatitude(QObject *parent = 0); @@ -37,7 +33,6 @@ private: QUrl urllogin; QUrl urldologin; QUrl urlupdate; - QUrl urlloc; }; #endif // GLATITUDE_H diff --git a/src/gps.cpp b/src/gps.cpp index 99080f9..49506aa 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -1,59 +1,27 @@ #include "gps.h" -#ifdef LIBLOCATION - GpsMaemo5::GpsMaemo5(QObject *parent) : QObject(parent) { latitude = 0; longitude = 0; accuracy = 0; - usegps = -1; control = location_gpsd_control_get_default(); device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL); - g_signal_connect(device, "changed", G_CALLBACK(GpsMaemo5_changed), this); -} -void GpsMaemo5::get_acwp() { + g_signal_connect(device, "changed", G_CALLBACK(GpsMaemo5_changed), this); g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL); - usegps = 0; - restart(); -} -void GpsMaemo5::get_agnss() { - g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL); - usegps = 1; - restart(); -} - -void GpsMaemo5::stop() { - location_gpsd_control_stop(control); -} - -void GpsMaemo5::restart() { - location_gpsd_control_stop(control); location_gpsd_control_start(control); } void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps) { - if (gps->device->fix) { - if (gps->device->fix->fields) { + if (device->fix) { + if (device->fix->fields) { g_print("lat = %f, long = %f, eph = %f\n", gps->device->fix->latitude, gps->device->fix->longitude, gps->device->fix->eph/100.); gps->latitude = gps->device->fix->latitude; gps->longitude = gps->device->fix->longitude; gps->accuracy = gps->device->fix->eph/100.; - - if ( gps->usegps == 0) { - emit gps->getOK_acwp(); - if ( gps->accuracy < 10*1000 ) gps->stop(); - } else if ( gps->usegps == 1 ) { - emit gps->getOK_agnss(); - // if ( device->satellites_in_use > 0 ) gps->stop(); - if ( gps->device->fix->mode == LOCATION_GPS_DEVICE_MODE_3D ) gps->stop(); - } else { - emit gps->getOK(); - } + emit gps->fix(); } } } - -#endif diff --git a/src/gps.h b/src/gps.h index 45c9cbb..ca5ea9d 100644 --- a/src/gps.h +++ b/src/gps.h @@ -1,8 +1,6 @@ #ifndef GPS_H #define GPS_H -#ifdef LIBLOCATION - #include extern "C" { @@ -14,21 +12,13 @@ class GpsMaemo5 : public QObject { Q_OBJECT signals: - void getOK(); - void getOK_acwp(); - void getOK_agnss(); - -public slots: - void get_acwp(); - void get_agnss(); + void fix(); public: GpsMaemo5(QObject *parent = 0); double get_lat() { return latitude; } double get_lon() { return longitude; } double get_acc() { return accuracy; } - void stop(); - void restart(); friend void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps); private: @@ -36,15 +26,11 @@ private: double longitude; double accuracy; - int usegps; - GMainLoop *loop; LocationGPSDControl *control; LocationGPSDevice *device; - }; void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps); -#endif #endif // GPS_H diff --git a/src/gpsfake.h b/src/gpsfake.h deleted file mode 100644 index 0a8cdad..0000000 --- a/src/gpsfake.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef GPSFAKE_H -#define GPSFAKE_H - -#ifndef LIBLOCATION - -#include - -class GpsMaemo5 : public QObject { - Q_OBJECT - -signals: - void getOK(); - void getOK_acwp(); - void getOK_agnss(); - -public slots: - void get_acwp() { accuracy = 1; emit getOK_acwp(); } - void get_agnss() { accuracy = 2; emit getOK_agnss(); } - -public: - GpsMaemo5(QObject *parent = 0) : QObject(parent) { - latitude=0; - longitude=0; - accuracy=0; - } - double get_lat() { return latitude; } - double get_lon() { return longitude; } - double get_acc() { return accuracy; } - void stop() {} - void restart() {} - -private: - double latitude; - double longitude; - double accuracy; -}; - -#endif -#endif // GPSFAKE_H diff --git a/src/latitude.cpp b/src/latitude.cpp index 37a6176..c215f01 100644 --- a/src/latitude.cpp +++ b/src/latitude.cpp @@ -1,168 +1,79 @@ #include "latitude.h" 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"); - // buzz http://www.google.com/maps/m?l-view=map&l-lci=m,com.google.latitudepublicupdates&ac=f,s,l - - 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())); + setAttribute(Qt::WA_Maemo5AutoOrientation, true); + setWindowTitle(tr("Google Latitude Updater")); -} + setting = new QSettings(); -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())); - status->setText(tr("Using google.com/loc, ip-based" )); - emit newpos(); -} + // login input + QDialog *dialoglogin = new QDialog(this); + QLineEdit *login_user = new QLineEdit(setting->value("user","my_username").toString()); + QLineEdit *login_pass = new QLineEdit(setting->value("pass","my_password").toString()); + login_pass->setEchoMode(QLineEdit::Password); + QFormLayout *layout_login = new QFormLayout(); + layout_login->addRow(tr("&Username"), login_user); + layout_login->addRow(tr("&Password"), login_pass); + connect(login_user, SIGNAL(textEdited(QString)), this, SLOT(save_user(QString))); + connect(login_pass, SIGNAL(textEdited(QString)), this, SLOT(save_pass(QString))); + connect(login_user, SIGNAL(returnPressed()), login_pass, SLOT(setFocus())); + connect(login_pass, SIGNAL(returnPressed()), dialoglogin, SLOT(accept())); + dialoglogin->setLayout(layout_login); + dialoglogin->exec(); -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(); -} + // GUI + url = QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude"); + maps = new QWebView(); + connect(maps, SIGNAL(loadFinished(bool)), this, SLOT(maps_login())); + maps->load(url); + menuBar()->addAction(tr("&Latitude"), this, SLOT(mode_latitude())); + menuBar()->addAction(tr("&Buzz"), this, SLOT(mode_buzz())); -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(); -} + // updater + glatitude = new GoogleLatitude(this); + gps = new GpsMaemo5(this); + connect(gps, SIGNAL(fix()), this, SLOT(set())); + connect(glatitude, SIGNAL(OK()), this, SLOT(latitude_OK())); + connect(glatitude, SIGNAL(ERROR()), this, SLOT(latitude_ERROR())); -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(); + // show it + setCentralWidget(maps); } void LatitudeGUI::set() { - glatitude->login(login_user->text(), - login_pass->text()); - glatitude->set(location_lat->text().toDouble(), - location_lon->text().toDouble(), - location_acc->text().toDouble()); + QMaemo5InformationBox::information(this, "New gps position", 1000); + glatitude->login(setting->value("user","my_username").toString(), + setting->value("pass","my_password").toString()); + glatitude->set(gps->get_lat(), + gps->get_lon(), + gps->get_acc()); } -void LatitudeGUI::set_OK() { - status->setText(tr("Updated Location !")); +void LatitudeGUI::latitude_OK() { + QMaemo5InformationBox::information(this, "Location Sent!", 1000); } -void LatitudeGUI::set_ERROR() { - status->setText(tr("Error in Authentification !")); +void LatitudeGUI::latitude_ERROR() { + QMaemo5InformationBox::information(this, "Error in Authentification !", 3000); } -void LatitudeGUI::save() { - setting->setValue("user", login_user->text()); - setting->setValue("pass", login_pass->text()); +void LatitudeGUI::save_user(QString _user) { + setting->setValue("user", _user); } - -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::save_pass(QString _pass) { + setting->setValue("pass", _pass); } -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_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")); +void LatitudeGUI::mode_buzz() { + maps->load(QUrl::fromEncoded("http://www.google.com/maps/m?l-view=map&l-lci=m,com.google.latitudepublicupdates&ac=f,s,l")); +} - // menu - menuBar()->clear(); - menuBar()->addAction(tr("&Maps") ,this, SLOT(show_map())); +void LatitudeGUI::mode_latitude() { + maps->load(QUrl::fromEncoded("https://www.google.com/accounts/ServiceLogin?service=friendview&continue=http://www.google.com/maps/m?mode=latitude")); } void LatitudeGUI::maps_login() { - if ( maps->url() == urllogin ) { + if ( maps->url() == url ) { maps->page()->mainFrame()->evaluateJavaScript( QString("document.getElementById('Email').value = \"%1\";").arg( setting->value("user").toString())); diff --git a/src/latitude.h b/src/latitude.h index bfb5067..7f54190 100644 --- a/src/latitude.h +++ b/src/latitude.h @@ -3,9 +3,9 @@ #include #include +#include #include "glatitude.h" #include "gps.h" -#include "gpsfake.h" class LatitudeGUI : public QMainWindow { Q_OBJECT @@ -17,33 +17,21 @@ public: LatitudeGUI(QMainWindow *parent = 0); private slots: - void get_loc(); - void get_acwp(); - void get_agnss(); - void get_maemo5(); void set(); - void set_OK(); - void set_ERROR(); - void save(); - void show_map(); - void show_lat(); + void latitude_OK(); + void latitude_ERROR(); + void save_user(QString); + void save_pass(QString); void maps_login(); + void mode_buzz(); + void mode_latitude(); private: GoogleLatitude *glatitude; GpsMaemo5 *gps; QSettings *setting; QWebView *maps; - QWidget *location; - QUrl urllogin; - - QLineEdit *login_user; - QLineEdit *login_pass; - QLineEdit *location_lat; - QLineEdit *location_lon; - QLineEdit *location_acc; - - QLineEdit *status; + QUrl url; }; #endif // LATITUDE_H