daemon mode and bugs fixes
[googlelatitude] / src / main.cpp
index fd38f35..42eebdd 100644 (file)
@@ -1,21 +1,31 @@
 #include "latitude.h"
 #include "latitude.h"
+#include "daemon.h"
 
 int main(int argc, char *argv[]) {
 
 int main(int argc, char *argv[]) {
-    QApplication app(argc, argv);
     QCoreApplication::setOrganizationName("linfati");
     QCoreApplication::setOrganizationDomain("linfati.com");
     QCoreApplication::setApplicationName("GoogleLatitude");
     QCoreApplication::setOrganizationName("linfati");
     QCoreApplication::setOrganizationDomain("linfati.com");
     QCoreApplication::setApplicationName("GoogleLatitude");
+    QCoreApplication::setApplicationVersion("0.4.5");
 
 
-    LatitudeGUI *gui = new LatitudeGUI();
-    gui->show();
+    if ( QString(argv[0]).contains("GoogleLatitudeDaemon") ) {
+        QCoreApplication app(argc, argv);
+        qDebug() << "main: Daemon";
+        Daemon *demonio;
+        demonio = new Daemon();
+        app.exec();
+    } else if ( QString(argv[0]).contains("GoogleLatitudeGUI") ) {
+        QApplication app(argc, argv);
+        qDebug() << "main: GUI";
+        LatitudeGUI *gui = new LatitudeGUI();
+        gui->show();
+        app.exec();
+    } else {
+        QApplication app(argc, argv);
+        qDebug() << "main: default";
+        LatitudeGUI *gui = new LatitudeGUI();
+        gui->show();
+        app.exec();
+    }
 
 
-    return app.exec();
+    return 0;
 }
 }
-
-/*
- TODO:
- on auth error -> stop gps
- on new pos, only set it
- send new pos every 120s, only if is diferent
- no n900 -> por ip
- */