ifdef for maemo
authorRodrigo Linfati <rodrigo@linfati.cl>
Sun, 9 May 2010 02:08:42 +0000 (04:08 +0200)
committerRodrigo Linfati <rodrigo@linfati.cl>
Sun, 9 May 2010 02:08:42 +0000 (04:08 +0200)
googlelatitude.pro
src/gps.cpp
src/gps.h
src/latitude.cpp
src/latitude.h
src/main.cpp

index 6ca7dca..8eb75e0 100644 (file)
@@ -7,6 +7,10 @@ MOC_DIR     = build
 DESTDIR     = build
 
 TEMPLATE    = app
-QT         += network webkit maemo5
-CONFIG     += link_pkgconfig
-PKGCONFIG  += glib-2.0 liblocation
+QT         += network webkit
+
+contains(QT_CONFIG, maemo5) {
+    QT          += maemo5
+    CONFIG      += link_pkgconfig
+    PKGCONFIG   += glib-2.0 liblocation
+}
index b7ed336..0fb4ba7 100644 (file)
@@ -1,5 +1,7 @@
 #include "gps.h"
 
+#ifdef Q_WS_MAEMO_5
+
 GpsMaemo5::GpsMaemo5(QObject *parent) : QObject(parent) {
     latitude = 0;
     longitude = 0;
@@ -26,3 +28,5 @@ void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps) {
         }
     }
 }
+
+#endif // Q_WS_MAEMO_5
index ca5ea9d..2d9cfdf 100644 (file)
--- a/src/gps.h
+++ b/src/gps.h
@@ -3,6 +3,8 @@
 
 #include <QObject>
 
+#ifdef Q_WS_MAEMO_5
+
 extern "C" {
 #include <location/location-gps-device.h>
 #include <location/location-gpsd-control.h>
@@ -33,4 +35,21 @@ private:
 
 void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps);
 
+#else // Q_WS_MAEMO_5
+
+class GpsMaemo5 : public QObject {
+    Q_OBJECT
+
+signals:
+    void fix();
+
+public:
+    GpsMaemo5(QObject *parent = 0) { Q_UNUSED(parent); }
+    double get_lat() { return 0; }
+    double get_lon() { return 0; }
+    double get_acc() { return 0; }
+};
+
+#endif // Q_WS_MAEMO_5
+
 #endif // GPS_H
index c215f01..aa742f1 100644 (file)
@@ -1,8 +1,10 @@
 #include "latitude.h"
 
 LatitudeGUI::LatitudeGUI(QMainWindow *parent) : QMainWindow(parent) {
+#ifdef Q_WS_MAEMO_5
     setAttribute(Qt::WA_Maemo5AutoOrientation, true);
-    setWindowTitle(tr("Google Latitude Updater"));
+#endif
+    setWindowTitle(tr("Latitude & Buzz"));
 
     setting = new QSettings();
 
@@ -41,7 +43,11 @@ LatitudeGUI::LatitudeGUI(QMainWindow *parent) : QMainWindow(parent) {
 }
 
 void LatitudeGUI::set() {
-    QMaemo5InformationBox::information(this, "New gps position", 1000);
+#ifdef Q_WS_MAEMO_5
+    QMaemo5InformationBox::information(this, "new position...", 1000);
+#else
+    qDebug() << "new position...";
+#endif
     glatitude->login(setting->value("user","my_username").toString(),
                      setting->value("pass","my_password").toString());
     glatitude->set(gps->get_lat(),
@@ -50,11 +56,19 @@ void LatitudeGUI::set() {
 }
 
 void LatitudeGUI::latitude_OK() {
-    QMaemo5InformationBox::information(this, "Location Sent!", 1000);
+#ifdef Q_WS_MAEMO_5
+    QMaemo5InformationBox::information(this, "...location Sent!", 1000);
+#else
+    qDebug() << "...location Sent!";
+#endif
 }
 
 void LatitudeGUI::latitude_ERROR() {
+#ifdef Q_WS_MAEMO_5
     QMaemo5InformationBox::information(this, "Error in Authentification !", 3000);
+#else
+    qDebug() << "Error in Authentification !";
+#endif
 }
 
 void LatitudeGUI::save_user(QString _user) {
index 7f54190..4f2362d 100644 (file)
@@ -3,9 +3,11 @@
 
 #include <QtGui>
 #include <QtWebKit>
-#include <QtMaemo5>
 #include "glatitude.h"
 #include "gps.h"
+#ifdef Q_WS_MAEMO_5
+#include <QtMaemo5>
+#endif
 
 class LatitudeGUI : public QMainWindow {
     Q_OBJECT
index a80b29c..c85dc20 100644 (file)
@@ -11,3 +11,10 @@ int main(int argc, char *argv[]) {
 
     return app.exec();
 }
+
+/*
+ TODO:
+ on auth error -> stop gps
+ on new pos, only set it
+ send new pos every 120s, only if is diferent
+ */