Changed the old code to work as a daemon
[googlelatitude] / src / daemon / glatitude.h
diff --git a/src/daemon/glatitude.h b/src/daemon/glatitude.h
new file mode 100644 (file)
index 0000000..0085504
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef GLATITUDE_H
+#define GLATITUDE_H
+
+#include <QtNetwork>
+
+class GoogleLatitude : public QObject {
+    Q_OBJECT
+
+signals:
+    void OK();
+    void ERROR();
+
+public:
+    GoogleLatitude(QObject *parent = 0);
+    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; }
+
+public slots:
+    void disableUpdates() { on = false; }
+    void enableUpdates() { on = true; }
+    void setUpdates(bool u) { on = u; }
+
+private slots:
+    void finishedreply(QNetworkReply *r);
+
+private:
+    // info
+    bool networkConnected();
+    QString user;
+    QString pass;
+    double latitude;
+    double longitude;
+    double accuracy;
+    // stuff
+    QNetworkAccessManager *worker;
+    QUrl urllogin;
+    QUrl urldologin;
+    QUrl urlupdate;
+    bool on;
+};
+
+#endif // GLATITUDE_H