[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: KDE/kdebase/workspace/plasma/dataengines/weather
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2009-04-15 6:08:13
Message-ID: 1239775693.407635.30623.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 954107 by aseigo:
fetch the weather when the network is available; basically i was sick of having a \
blank wallpaper for 30 minutes after log in just because network manager hadn't \
connected in the time it takes plasma to get on its feet.
this is such a simple pattern, yet one that is pretty common (getting stuff from the \
network at regular intervals) should it be put into DataEngine, perhaps protected: \
setRequiresNetwork(bool)? or perhaps a few different levels such as "NoNetworking \
(presumably the default), NetworkOptional, NetworkRequired" so that we can at some \
point turn it on/off depending on whether or not the networking is \
expensive/cheap/etc? none/optional/required is perhaps not fine grained enough? \
discuss .... :)
CCMAIL:plasma-devel@kde.org
M +1 -1 CMakeLists.txt
M +32 -6 weatherengine.cpp
M +9 -0 weatherengine.h
--- trunk/KDE/kdebase/workspace/plasma/dataengines/weather/CMakeLists.txt \
#954106:954107 @@ -2,6 +2,6 @@
SET(weather_SRCS weatherengine.cpp)
kde4_add_plugin(plasma_engine_weather ${weather_SRCS})
-TARGET_LINK_LIBRARIES (plasma_engine_weather ${KDE4_KIO_LIBS} ${KDE4_PLASMA_LIBS} \
weather_ion) +TARGET_LINK_LIBRARIES (plasma_engine_weather ${KDE4_KIO_LIBS} \
${KDE4_SOLID_LIBS} ${KDE4_PLASMA_LIBS} weather_ion) INSTALL (TARGETS \
plasma_engine_weather DESTINATION ${PLUGIN_INSTALL_DIR}) INSTALL (FILES \
plasma-dataengine-weather.desktop DESTINATION \
${SERVICES_INSTALL_DIR})
--- trunk/KDE/kdebase/workspace/plasma/dataengines/weather/weatherengine.cpp \
#954106:954107 @@ -19,6 +19,7 @@
***************************************************************************/
#include "weatherengine.h"
+
#include <KServiceTypeTrader>
#include <KDateTime>
#include <KLocale>
@@ -30,11 +31,17 @@
class WeatherEngine::Private
{
public:
+ Private()
+ : m_networkAvailable(false)
+ {
+ }
+
/**
* Get instance of a loaded ion.
* @returns a IonInterface instance of a loaded plugin.
*/
- IonInterface* ionForSource(const QString& name) {
+ IonInterface* ionForSource(const QString& name)
+ {
int offset = name.indexOf('|');
if (offset < 1) {
@@ -60,6 +67,7 @@
KDateTime m_localTime;
QStringList m_ions;
+ bool m_networkAvailable;
};
/**
@@ -113,6 +121,10 @@
setData("ions", info.pluginName(),
QString("%1|%2").arg(info.property("Name").toString()).arg(info.pluginName()));
}
+
+ d->m_networkAvailable = Solid::Networking::status() == \
Solid::Networking::Connected; + connect(Solid::Networking::notifier(), \
SIGNAL(statusChanged(Solid::Networking::Status)), + this, \
SLOT(networkStatusChanged(Solid::Networking::Status))); }
/**
@@ -195,6 +207,11 @@
}
}
+ if (!d->m_networkAvailable) {
+ setData(source, Data());
+ return true;
+ }
+
QByteArray str = source.toLocal8Bit();
ion->connectSource(source, this);
@@ -215,18 +232,27 @@
QByteArray str = source.toLocal8Bit();
- kDebug() << "updateSourceEvent()";
+ kDebug() << "updateSourceEvent()" << ion << d->m_networkAvailable;
if (!ion) {
return false;
}
+ if (!d->m_networkAvailable) {
+ return false;
+ }
+
ion->setProperty("timezone", d->m_localTime.isUtc());
ion->setProperty("unit", KGlobal::locale()->measureSystem());
+ return ion->updateSourceEvent(source);
+}
- if (ion->updateSourceEvent(source)) {
- return true;
- } else {
- return false;
+void WeatherEngine::networkStatusChanged(Solid::Networking::Status status)
+{
+ d->m_networkAvailable = status == Solid::Networking::Connected;
+ //kDebug() << "status changed" << d->m_networkAvailable;
+
+ if (d->m_networkAvailable) {
+ updateAllSources();
}
}
--- trunk/KDE/kdebase/workspace/plasma/dataengines/weather/weatherengine.h \
#954106:954107 @@ -22,7 +22,11 @@
#include <KService>
#include <KGenericFactory>
+
+#include <Solid/Networking>
+
#include <Plasma/DataEngine>
+
#include "ions/ion.h"
class QTimer;
@@ -93,6 +97,11 @@
*/
bool updateSourceEvent(const QString& source);
+ /**
+ * Whenever networking changes, take action
+ */
+ void networkStatusChanged(Solid::Networking::Status);
+
private:
class Private;
Private *const d;
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic