--- /dev/null
+googlelatitude (0.1-1) fremantle; urgency=low
+
+ * Initial release
+
+ -- Rodrigo Linfati <rodrigo@linfati.cl> Tue, 15 Dec 2009 20:42:16 +0100
+
--- /dev/null
+Source: googlelatitude
+Section: user/other
+Priority: optional
+Maintainer: Rodrigo Linfati <rodrigo@linfati.cl>
+Build-Depends: debhelper (>= 5), libqt4-dev
+Standards-Version: 3.7.2
+
+Package: googlelatitude
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Google Latitude Updater
+ A Google Latitude Updater in QT4
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+APPNAME := googlelatitude
+
+builddir:
+ mkdir -p builddir
+
+builddir/Makefile: builddir
+ cd builddir && /opt/qt4-maemo5/bin/qmake-qt4 PREFIX=/usr ../$(APPNAME).pro
+build: build-stamp
+
+build-stamp: builddir/Makefile
+ dh_testdir
+ cd builddir && $(MAKE)
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+ rm -rf builddir
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+ cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install
+
+binary-indep: build install
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installexamples
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+QMAKEVERSION = $$[QMAKE_VERSION]
+ISQT4 = $$find(QMAKEVERSION, ^[2-9])
+isEmpty( ISQT4 ) {
+ error("Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4");
+}
+
+TEMPLATE = subdirs
+SUBDIRS = src
+
--- /dev/null
+#include "googlelatitude.h"
+
+GoogleLatitude::GoogleLatitude() {
+ user = "";
+ pass = "";
+ latitude = 0.;
+ longitude = 0.;
+ accuracy = 0.;
+
+ worker = new QNetworkAccessManager();
+ connect(worker, SIGNAL(finished(QNetworkReply *)), this, SLOT(finishedreply(QNetworkReply *)));
+
+ 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) {
+ if ( !u.contains('@') ) u.append("@gmail.com");
+ user = u;
+ pass = p;
+}
+
+void GoogleLatitude::set(double la, double lo, double ac) {
+ latitude = la;
+ longitude = lo;
+ accuracy = 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();
+ QRegExp regexp ("type=\"hidden\".*name=\"GALX\".*value=\"(.*)\"");
+ regexp.setMinimal(1);
+ regexp.indexIn(aidis, 1);
+ QString googleGALX = regexp.capturedTexts().last();
+
+ QByteArray datalogin;
+ datalogin += "&service=friendview";
+ datalogin += "&GALX=" + googleGALX;
+ datalogin += "&Email=" + user;
+ datalogin += "&Passwd=" + pass;
+ worker->post(QNetworkRequest(urldologin), datalogin);
+ } else if ( r->url() == urldologin ) {
+ QByteArray datagps;
+ datagps += "t=ul";
+ datagps += "&lat=" + QString::number(latitude);
+ datagps += "&lng=" + QString::number(longitude);
+ datagps += "&accuracy=" + QString::number(accuracy);
+
+ QNetworkRequest request(urlupdate);
+ request.setRawHeader("X-ManualHeader", QString("true").toAscii() );
+ worker->post(request, datagps);
+ } else if ( r->url() == urlupdate ) {
+ QString output = r->readAll();
+ QRegExp regexp ("Authentication required");
+ if (regexp.indexIn(output, 1) != -1) {
+ emit setERROR();
+ } else {
+ emit setOK();
+ }
+ } 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();
+ } else {
+ qDebug() << "Error";
+ qDebug() << "url:" << r->url();
+ qDebug() << r->rawHeaderList();
+ qDebug() << r->readAll();
+ }
+}
--- /dev/null
+[Desktop Entry]
+Encoding=UTF-8
+Version=0.1
+Type=Application
+Name=Google Latitude Update
+Exec=/usr/bin/GoogleLatitude
+Icon=googlelatitude
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
+
--- /dev/null
+#ifndef GOOGLELATITUDE_H
+#define GOOGLELATITUDE_H
+
+#include <QObject>
+#include <QNetworkAccessManager>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QRegExp>
+#include <QStringList>
+#include <QDebug>
+
+class GoogleLatitude : public QObject {
+ Q_OBJECT
+
+signals:
+ void setOK();
+ void setERROR();
+ void getOK();
+
+public slots:
+ void get();
+
+public:
+ GoogleLatitude();
+ void login(QString username, QString password);
+ void set(double latitude, double longitude, double accuracy=1000.);
+ double get_lat() { return latitude; }
+ double get_lon() { return longitude; }
+ double get_acc() { return accuracy; }
+
+private slots:
+ void finishedreply(QNetworkReply *r);
+
+private:
+ // info
+ QString user;
+ QString pass;
+ double latitude;
+ double longitude;
+ double accuracy;
+ // stuff
+ QNetworkAccessManager *worker;
+ QUrl urllogin;
+ QUrl urldologin;
+ QUrl urlupdate;
+ QUrl urlloc;
+};
+
+#endif // GOOGLELATITUDE_H
--- /dev/null
+#include "latitudewidget.h"
+
+LatitudeWidget::LatitudeWidget() {
+ load();
+ glatitude.get();
+ timer = new QTimer();
+ // login
+ login_user = new QLineEdit();
+ login_user->setText(user);
+ login_pass = new QLineEdit();
+ login_pass->setText(pass);
+ login_pass->setEchoMode(QLineEdit::Password);
+ login_up = new QPushButton(tr("&Update Location"));
+ login_layout = new QFormLayout();
+ login_layout->addRow(tr("&Username"), login_user);
+ login_layout->addRow(tr("&Password"), login_pass);
+ login_layout->addRow(login_up);
+ // location
+ location_lat = new QLineEdit();
+ location_lat ->setText(QString::number(latitude));
+ location_lon = new QLineEdit();
+ location_lon->setText(QString::number(longitude));
+ location_acc = new QLineEdit();
+ location_acc->setText(QString::number(accuracy));
+ location_layout = new QFormLayout();
+ location_layout->addRow(tr("lat :"), location_lat);
+ location_layout->addRow(tr("lon :"), location_lon);
+ location_layout->addRow(tr("acc :"), location_acc);
+ // window
+ menu = new QWidget();
+ menu->setWindowTitle(tr("Google Latitude Updater"));
+ menu_layout = new QHBoxLayout();
+ menu_layout->addLayout(login_layout);
+ menu_layout->addLayout(location_layout);
+ menu->setLayout(menu_layout);
+ menu->show();
+
+ connect(login_up, SIGNAL(clicked()), this, SLOT(set()));
+ connect(timer, SIGNAL(timeout()), this, SLOT(gset()));
+ connect(&glatitude, SIGNAL(getOK()), this, SLOT(get()));
+ connect(&glatitude, SIGNAL(setOK()), this, SLOT(gsetOK()));
+ connect(&glatitude, SIGNAL(setERROR()), this, SLOT(gsetERROR()));
+}
+
+void LatitudeWidget::get() {
+ location_lat->setText(QString::number(glatitude.get_lat()));
+ location_lon->setText(QString::number(glatitude.get_lon()));
+ location_acc->setText(QString::number(glatitude.get_acc()));
+}
+
+void LatitudeWidget::set() {
+ save();
+ glatitude.login(user, pass);
+ glatitude.set(latitude, longitude, accuracy);
+}
+
+void LatitudeWidget::gsetOK() {
+ login_up->setText(tr("Location Updated !"));
+ timer->start(5000);
+}
+void LatitudeWidget::gsetERROR() {
+ login_up->setText(tr("Error in Authentification !"));
+ timer->start(2000);
+}
+
+void LatitudeWidget::gset() {
+ login_up->setText(tr("&Update Location"));
+}
+
+void LatitudeWidget::load() {
+ // from file
+ if ( QFile::exists(QDir::homePath()+"/.glatitude") ) {
+ QFile *config = new QFile(QDir::homePath()+"/.glatitude");
+ config->open(QIODevice::ReadOnly);
+ QTextStream sconfig(config);
+ sconfig >> user >> pass;
+ sconfig >> latitude >> longitude >> accuracy;
+ config->close();
+ } else {
+ user = "my_username";
+ pass = "my_password";
+ latitude = 0.;
+ longitude = 0.;
+ accuracy = 0.;
+ }
+}
+
+void LatitudeWidget::save() {
+ // extract info
+ user = login_user->text();
+ pass = login_pass->text();
+ latitude = location_lat->text().toDouble();
+ longitude = location_lon->text().toDouble();
+ accuracy = location_acc->text().toDouble();
+ // to file
+ QFile *config = new QFile(QDir::homePath()+"/.glatitude");
+ config->open(QIODevice::WriteOnly);
+ QTextStream sconfig(config);
+ sconfig << user << " " << pass << " ";
+ sconfig << latitude << " " << longitude << " " << accuracy;
+ config->close();
+}
--- /dev/null
+#ifndef LATITUDEWIDGET_H
+#define LATITUDEWIDGET_H
+
+#include <QWidget>
+#include <QHBoxLayout>
+#include <QFormLayout>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QFile>
+#include <QDir>
+#include <QTextStream>
+#include <QTimer>
+#include "googlelatitude.h"
+
+class LatitudeWidget : public QWidget {
+ Q_OBJECT
+
+public slots:
+ void get();
+ void gsetOK();
+ void gsetERROR();
+ void gset();
+
+public:
+ LatitudeWidget();
+
+private slots:
+ void set();
+ void save();
+ void load();
+
+private:
+ GoogleLatitude glatitude;
+ // info
+ QString user;
+ QString pass;
+ double latitude;
+ double longitude;
+ double accuracy;
+ // gui
+ QWidget *menu;
+ QHBoxLayout *menu_layout;
+ // login
+ QFormLayout *login_layout;
+ QLineEdit *login_user;
+ QLineEdit *login_pass;
+ QPushButton *login_up;
+ // location
+ QFormLayout *location_layout;
+ QLineEdit *location_lat;
+ QLineEdit *location_lon;
+ QLineEdit *location_acc;
+ // stuff
+ QTimer *timer;
+};
+
+#endif // LATITUDEWIDGET_H
--- /dev/null
+#include <QApplication>
+#include "latitudewidget.h"
+
+int main(int argc, char *argv[]) {
+ QApplication app(argc, argv);
+
+ LatitudeWidget gui;
+
+ return app.exec();
+}
--- /dev/null
+QT += network
+TARGET = GoogleLatitude
+TEMPLATE = app
+SOURCES += main.cpp \
+ latitudewidget.cpp \
+ googlelatitude.cpp
+HEADERS += latitudewidget.h \
+ googlelatitude.h
+
+unix {
+ isEmpty(PREFIX) {
+ PREFIX = /usr/local
+ }
+ BINDIR = $$PREFIX/bin
+ DATADIR = $$PREFIX/share
+ DEFINES += DATADIR=\"$$DATADIR\" PKGDATADIR=\"$$PKGDATADIR\"
+
+ INSTALLS += target desktop iconxpm icon26 icon40 icon64
+ target.path = $$BINDIR
+ desktop.path = $$DATADIR/applications/hildon
+ desktop.files += $${TARGET}.desktop
+ iconxpm.path = $$DATADIR/pixmap
+ iconxpm.files += ../data/maemo/$${TARGET}.xpm
+ icon26.path = $$DATADIR/icons/hicolor/26x26/apps
+ icon26.files += ../data/26x26/$${TARGET}.png
+ icon40.path = $$DATADIR/icons/hicolor/40x40/apps
+ icon40.files += ../data/40x40/$${TARGET}.png
+ icon64.path = $$DATADIR/icons/hicolor/64x64/apps
+ icon64.files += ../data/64x64/$${TARGET}.png
+}
+