summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-15 16:24:46 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-15 16:24:46 +0200
commitcf54773b561c324596b25739888b8ab5b4b45bd1 (patch)
tree40f210f39cbb296a51473fcaa6e5b1f61f3ab998
parent2ecf718cc9d460ad192de196aac8d13e30a7ab4c (diff)
downloadsowatch-cf54773b561c324596b25739888b8ab5b4b45bd1.tar.gz
sowatch-cf54773b561c324596b25739888b8ab5b4b45bd1.zip
preparing meecastplugin
-rw-r--r--harmaccuweather/harmaccuplugin.h6
-rw-r--r--harmaccuweather/harmaccuweather.pro2
-rw-r--r--meecastweather/meecastplugin.cpp26
-rw-r--r--meecastweather/meecastplugin.h12
-rw-r--r--meecastweather/meecastprovider.cpp21
-rw-r--r--meecastweather/meecastprovider.h14
-rw-r--r--meecastweather/meecastweather.cpp47
-rw-r--r--meecastweather/meecastweather.h12
-rw-r--r--meecastweather/meecastweather.pro5
9 files changed, 70 insertions, 75 deletions
diff --git a/harmaccuweather/harmaccuplugin.h b/harmaccuweather/harmaccuplugin.h
index 535b4a2..6896ad0 100644
--- a/harmaccuweather/harmaccuplugin.h
+++ b/harmaccuweather/harmaccuplugin.h
@@ -1,5 +1,5 @@
-#ifndef CKITCALLPLUGIN_H
-#define CKITCALLPLUGIN_H
+#ifndef HARMACCUPLUGIN_H
+#define HARMACCUPLUGIN_H
#include <sowatch.h>
@@ -22,4 +22,4 @@ public:
}
-#endif // CKITCALLPLUGIN_H
+#endif // HARMACCUPLUGIN_H
diff --git a/harmaccuweather/harmaccuweather.pro b/harmaccuweather/harmaccuweather.pro
index 9f60ba2..954d0b0 100644
--- a/harmaccuweather/harmaccuweather.pro
+++ b/harmaccuweather/harmaccuweather.pro
@@ -1,8 +1,6 @@
TARGET = harmaccuweather
TEMPLATE = lib
CONFIG += plugin
-CONFIG += mobility
-MOBILITY += systeminfo
SOURCES += harmaccuplugin.cpp harmaccuprovider.cpp harmaccuweather.cpp
diff --git a/meecastweather/meecastplugin.cpp b/meecastweather/meecastplugin.cpp
index ff7b6cf..4530db7 100644
--- a/meecastweather/meecastplugin.cpp
+++ b/meecastweather/meecastplugin.cpp
@@ -1,37 +1,37 @@
-#include "harmaccuprovider.h"
-#include "harmaccuplugin.h"
+#include "meecastprovider.h"
+#include "meecastplugin.h"
using namespace sowatch;
-HarmAccuPlugin::HarmAccuPlugin(QObject *parent) :
+MeeCastPlugin::MeeCastPlugin(QObject *parent) :
QObject(parent)
{
}
-HarmAccuPlugin::~HarmAccuPlugin()
+MeeCastPlugin::~MeeCastPlugin()
{
}
-QStringList HarmAccuPlugin::providers()
+QStringList MeeCastPlugin::providers()
{
QStringList providers;
- providers << "harmaccu";
+ providers << MeeCastProvider::myId;
return providers;
}
-NotificationPluginInterface::NotificationProviderInfo HarmAccuPlugin::describeProvider(const QString &driver)
+NotificationPluginInterface::NotificationProviderInfo MeeCastPlugin::describeProvider(const QString &driver)
{
NotificationProviderInfo info;
- if (driver != "harmaccu") return info;
- info.name = "Accuweather";
+ if (driver != MeeCastProvider::myId) return info;
+ info.name = "MeeCast";
return info;
}
-NotificationProvider* HarmAccuPlugin::getProvider(const QString& id, ConfigKey *settings, QObject *parent)
+NotificationProvider* MeeCastPlugin::getProvider(const QString& id, ConfigKey *settings, QObject *parent)
{
Q_UNUSED(settings);
- if (id != "harmaccu") return 0;
- return new HarmAccuProvider(parent);
+ if (id != MeeCastProvider::myId) return 0;
+ return new MeeCastProvider(parent);
}
-Q_EXPORT_PLUGIN2(harmaccuweather, HarmAccuPlugin)
+Q_EXPORT_PLUGIN2(meecastweather, MeeCastPlugin)
diff --git a/meecastweather/meecastplugin.h b/meecastweather/meecastplugin.h
index 535b4a2..82d8684 100644
--- a/meecastweather/meecastplugin.h
+++ b/meecastweather/meecastplugin.h
@@ -1,19 +1,19 @@
-#ifndef CKITCALLPLUGIN_H
-#define CKITCALLPLUGIN_H
+#ifndef MEECASTPLUGIN_H
+#define MEECASTPLUGIN_H
#include <sowatch.h>
namespace sowatch
{
-class HarmAccuPlugin : public QObject, public NotificationPluginInterface
+class MeeCastPlugin : public QObject, public NotificationPluginInterface
{
Q_OBJECT
Q_INTERFACES(sowatch::NotificationPluginInterface)
public:
- HarmAccuPlugin(QObject *parent = 0);
- ~HarmAccuPlugin();
+ MeeCastPlugin(QObject *parent = 0);
+ ~MeeCastPlugin();
QStringList providers();
NotificationProviderInfo describeProvider(const QString &driver);
@@ -22,4 +22,4 @@ public:
}
-#endif // CKITCALLPLUGIN_H
+#endif // MEECASTPLUGIN_H
diff --git a/meecastweather/meecastprovider.cpp b/meecastweather/meecastprovider.cpp
index 2c26b67..0da042a 100644
--- a/meecastweather/meecastprovider.cpp
+++ b/meecastweather/meecastprovider.cpp
@@ -1,29 +1,26 @@
#include <QtCore/QtDebug>
#include <QtCore/QTimer>
-#include "harmaccuweather.h"
-#include "harmaccuprovider.h"
+#include "meecastweather.h"
+#include "meecastprovider.h"
using namespace sowatch;
-HarmAccuProvider::HarmAccuProvider(QObject *parent) :
+const QLatin1String MeeCastProvider::myId("meecast");
+
+MeeCastProvider::MeeCastProvider(QObject *parent) :
NotificationProvider(parent)
{
// Give some time to send the first notification
QTimer::singleShot(2000, this, SLOT(generateNotification()));
}
-HarmAccuProvider::~HarmAccuProvider()
+MeeCastProvider::~MeeCastProvider()
{
}
-void HarmAccuProvider::generateNotification()
+void MeeCastProvider::generateNotification()
{
- QSettings* s = HarmAccuWeather::getAccuweatherData();
- if (s->contains("LastUpdate")) {
- qDebug() << "generating harmaccuweather notification";
- emit incomingNotification(new HarmAccuWeather(this));
- } else {
- qWarning() << "Accuweather config file does not seem to exist";
+ if (QFile::exists(MeeCastWeather::configFilePath())) {
+ emit incomingNotification(new MeeCastWeather(this));
}
- delete s;
}
diff --git a/meecastweather/meecastprovider.h b/meecastweather/meecastprovider.h
index 4524e12..ae2589a 100644
--- a/meecastweather/meecastprovider.h
+++ b/meecastweather/meecastprovider.h
@@ -1,20 +1,22 @@
-#ifndef HARMACCUPROVIDER_H
-#define HARMACCUPROVIDER_H
+#ifndef MEECASTPROVIDER_H
+#define MEECASTPROVIDER_H
#include <sowatch.h>
namespace sowatch
{
-class HarmAccuWeather;
+class MeeCastWeather;
-class HarmAccuProvider : public NotificationProvider
+class MeeCastProvider : public NotificationProvider
{
Q_OBJECT
public:
- explicit HarmAccuProvider(QObject *parent = 0);
- ~HarmAccuProvider();
+ explicit MeeCastProvider(QObject *parent = 0);
+ ~MeeCastProvider();
+
+ static const QLatin1String myId;
public slots:
void generateNotification();
diff --git a/meecastweather/meecastweather.cpp b/meecastweather/meecastweather.cpp
index c4daeb9..407e359 100644
--- a/meecastweather/meecastweather.cpp
+++ b/meecastweather/meecastweather.cpp
@@ -1,18 +1,17 @@
-#include "harmaccuweather.h"
+#include <QtCore/QDir>
+#include <QtCore/QDebug>
-using namespace sowatch;
+#include "meecastweather.h"
-#define ACCUWEATHER_FILE_PATH "/home/user/.config/AccuWeather, Inc./awxapp.conf"
+using namespace sowatch;
-HarmAccuWeather::HarmAccuWeather(QObject *parent) :
+MeeCastWeather::MeeCastWeather(QObject *parent) :
WeatherNotification(parent),
_watcher(new QFileSystemWatcher(this)),
_timer(new QTimer(this)),
_lastUpdate(QDateTime::fromTime_t(0))
{
- // This only works on Harmattan either way, so I guess
- // hardcoding the path is OK.
- _watcher->addPath(ACCUWEATHER_FILE_PATH);
+ _watcher->addPath(configFilePath());
connect(_watcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
_timer->setInterval(5000);
@@ -23,32 +22,32 @@ HarmAccuWeather::HarmAccuWeather(QObject *parent) :
update();
}
-QSettings* HarmAccuWeather::getAccuweatherData()
+QString MeeCastWeather::configFilePath()
{
- return new QSettings(ACCUWEATHER_FILE_PATH, QSettings::IniFormat);
+ return QDir::home().absoluteFilePath(".config/com.meecast.omweather/config.xml");
}
-Notification::Type HarmAccuWeather::type() const
+Notification::Type MeeCastWeather::type() const
{
return Notification::WeatherNotification;
}
-uint HarmAccuWeather::count() const
+uint MeeCastWeather::count() const
{
return 1;
}
-QDateTime HarmAccuWeather::dateTime() const
+QDateTime MeeCastWeather::dateTime() const
{
return _lastUpdate;
}
-QString HarmAccuWeather::title() const
+QString MeeCastWeather::title() const
{
return _lastLocation;
}
-QString HarmAccuWeather::body() const
+QString MeeCastWeather::body() const
{
switch (_lastWxCode) {
case 1:
@@ -131,7 +130,7 @@ QString HarmAccuWeather::body() const
}
}
-WeatherNotification::WeatherType HarmAccuWeather::forecast()
+WeatherNotification::WeatherType MeeCastWeather::forecast()
{
switch (_lastWxCode) {
case 1:
@@ -198,37 +197,36 @@ WeatherNotification::WeatherType HarmAccuWeather::forecast()
}
}
-int HarmAccuWeather::temperature()
+int MeeCastWeather::temperature()
{
return _lastTemp;
}
-WeatherNotification::Unit HarmAccuWeather::temperatureUnits()
+WeatherNotification::Unit MeeCastWeather::temperatureUnits()
{
return _metric ? Celsius : Fahrenheit;
}
-void HarmAccuWeather::activate()
+void MeeCastWeather::activate()
{
// Launch accuweather?
}
-void HarmAccuWeather::dismiss()
+void MeeCastWeather::dismiss()
{
// Do nothing
}
-void HarmAccuWeather::fileChanged(const QString &path)
+void MeeCastWeather::fileChanged(const QString &path)
{
Q_UNUSED(path);
- qDebug() << "accuweather config file changed";
+ qDebug() << "meecast config file changed: " << path;
_timer->start();
}
-void HarmAccuWeather::update()
+void MeeCastWeather::update()
{
- QSettings* s = getAccuweatherData();
-
+#if 0
qDebug() << "reading accuweather config file";
QDateTime lastUpdate = s->value("LastUpdate").toDateTime();
@@ -269,4 +267,5 @@ void HarmAccuWeather::update()
}
delete s;
+#endif
}
diff --git a/meecastweather/meecastweather.h b/meecastweather/meecastweather.h
index 8b403b9..7bd1561 100644
--- a/meecastweather/meecastweather.h
+++ b/meecastweather/meecastweather.h
@@ -1,5 +1,5 @@
-#ifndef HARMACCUWEATHER_H
-#define HARMACCUWEATHER_H
+#ifndef MEECASTWEATHER_H
+#define MEECASTWEATHER_H
#include <QtCore/QFileSystemWatcher>
#include <QtCore/QTimer>
@@ -9,14 +9,14 @@
namespace sowatch
{
-class HarmAccuWeather : public WeatherNotification
+class MeeCastWeather : public WeatherNotification
{
Q_OBJECT
public:
- explicit HarmAccuWeather(QObject *parent = 0);
+ explicit MeeCastWeather(QObject *parent = 0);
- static QSettings* getAccuweatherData();
+ static QString configFilePath();
Type type() const;
uint count() const;
@@ -49,4 +49,4 @@ private:
}
-#endif // HARMACCUWEATHER_H
+#endif // MEECASTWEATHER_H
diff --git a/meecastweather/meecastweather.pro b/meecastweather/meecastweather.pro
index bccc255..86b1efb 100644
--- a/meecastweather/meecastweather.pro
+++ b/meecastweather/meecastweather.pro
@@ -1,8 +1,7 @@
-TARGET = meecastweather
+TARGET = meecastweather
TEMPLATE = lib
CONFIG += plugin
-CONFIG += mobility
-MOBILITY += systeminfo
+QT += xml
SOURCES += meecastplugin.cpp meecastprovider.cpp meecastweather.cpp