Moved location update logic to new class called UpdateLocation.
[situare] / src / engine / updatelocation.h
diff --git a/src/engine/updatelocation.h b/src/engine/updatelocation.h
new file mode 100644 (file)
index 0000000..8140644
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+    Situare - A location system for Facebook
+    Copyright (C) 2010  Ixonos Plc. Authors:
+
+        Sami Rämö - sami.ramo@ixonos.com
+
+    Situare is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License
+    version 2 as published by the Free Software Foundation.
+
+    Situare is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Situare; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+    USA.
+*/
+
+
+#ifndef UPDATELOCATION_H
+#define UPDATELOCATION_H
+
+#include <QObject>
+
+/**
+  * @brief Controller for location update
+  *
+  * @author Sami Rämö (at) ixonos.com
+  */
+class UpdateLocation : public QObject
+{
+    Q_OBJECT
+
+    /**
+    * @brief Message text
+    *
+    * @property message
+    */
+    Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged)
+
+    /**
+    * @brief Publish on FB wall setting
+    *
+    * @property publish
+    */
+    Q_PROPERTY(bool publish READ publish WRITE setPublish NOTIFY publishChanged)
+
+public:
+    /**
+      * @brief Constructor
+      *
+      * Read unsent message from settigs.
+      */
+    explicit UpdateLocation(QObject *parent = 0);
+
+    /**
+      * @brief Destructor
+      *
+      * Save unsent message to settings.
+      */
+    ~UpdateLocation();
+
+    /**
+      * @brief Getter for message.
+      *
+      * @returns Message
+      */
+    QString message() const;
+
+    /**
+      * @brief Getter for publish setting
+      *
+      * @returns True is update should be published on FB wall.
+      */
+    bool publish() const;
+
+public slots:
+    /**
+      * @brief Clear data.
+      */
+    void clear();
+
+    /**
+      * @brief Send location update
+      *
+      * Emits locationUpdate() signal.
+      */
+    void send();
+
+    /**
+      * @brief Setter for message
+      *
+      * @param message New message.
+      */
+    void setMessage(const QString &message);
+
+    /**
+      * @brief Setter for publish setting
+      *
+      * @param publish True is update should be published on FB wall.
+      */
+    void setPublish(bool publish);
+
+signals:
+    /**
+    * @brief Send location update
+    *
+    * @param status Status message
+    * @param publish Publish on Facebook?
+    */
+    void locationUpdate(const QString &status, bool publish);
+
+    /**
+      * @brief Notifies that message has changed
+      */
+    void messageChanged();
+
+    /**
+      * @brief Notifies that publish setting has changed
+      */
+    void publishChanged();
+
+private:
+    bool m_publish;         ///< Should the update be published on FB wall
+    QString m_message;      ///< Location update message
+};
+
+#endif // UPDATELOCATION_H