First Commit 0.1 debianized
authorRodrigo Linfati <rodrigo@linfati.cl>
Wed, 16 Dec 2009 14:20:26 +0000 (15:20 +0100)
committerRodrigo Linfati <rodrigo@linfati.cl>
Wed, 16 Dec 2009 14:20:26 +0000 (15:20 +0100)
This use libqt4-maemo5, but can use libqt4

13 files changed:
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/rules [new file with mode: 0755]
googlelatitude.pro [new file with mode: 0644]
src/googlelatitude.cpp [new file with mode: 0644]
src/googlelatitude.desktop [new file with mode: 0644]
src/googlelatitude.h [new file with mode: 0644]
src/latitudewidget.cpp [new file with mode: 0644]
src/latitudewidget.h [new file with mode: 0644]
src/main.cpp [new file with mode: 0644]
src/src.pro [new file with mode: 0644]

diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..6de4254
--- /dev/null
@@ -0,0 +1,6 @@
+googlelatitude (0.1-1) fremantle; urgency=low
+
+  * Initial release
+
+ -- Rodrigo Linfati <rodrigo@linfati.cl>  Tue, 15 Dec 2009 20:42:16 +0100
+
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..b802459
--- /dev/null
@@ -0,0 +1,12 @@
+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
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..e772481
--- /dev/null
@@ -0,0 +1 @@
+usr/bin
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..01992f5
--- /dev/null
@@ -0,0 +1,59 @@
+#!/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
diff --git a/googlelatitude.pro b/googlelatitude.pro
new file mode 100644 (file)
index 0000000..0541317
--- /dev/null
@@ -0,0 +1,9 @@
+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
+
diff --git a/src/googlelatitude.cpp b/src/googlelatitude.cpp
new file mode 100644 (file)
index 0000000..3dbb04f
--- /dev/null
@@ -0,0 +1,84 @@
+#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();
+    }
+}
diff --git a/src/googlelatitude.desktop b/src/googlelatitude.desktop
new file mode 100644 (file)
index 0000000..4ae4d9b
--- /dev/null
@@ -0,0 +1,10 @@
+[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
+
diff --git a/src/googlelatitude.h b/src/googlelatitude.h
new file mode 100644 (file)
index 0000000..0aebc82
--- /dev/null
@@ -0,0 +1,49 @@
+#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
diff --git a/src/latitudewidget.cpp b/src/latitudewidget.cpp
new file mode 100644 (file)
index 0000000..1647fb9
--- /dev/null
@@ -0,0 +1,102 @@
+#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();
+}
diff --git a/src/latitudewidget.h b/src/latitudewidget.h
new file mode 100644 (file)
index 0000000..36f1639
--- /dev/null
@@ -0,0 +1,57 @@
+#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
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644 (file)
index 0000000..3d4f8e0
--- /dev/null
@@ -0,0 +1,10 @@
+#include <QApplication>
+#include "latitudewidget.h"
+
+int main(int argc, char *argv[]) {
+    QApplication app(argc, argv);
+
+    LatitudeWidget gui;
+
+    return app.exec();
+}
diff --git a/src/src.pro b/src/src.pro
new file mode 100644 (file)
index 0000000..a2062b9
--- /dev/null
@@ -0,0 +1,31 @@
+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
+}
+