• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

ion_bbcukmet.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007-2008 by Shawn Starr <shawn.starr@rogers.com>       *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU General Public License     *
00015  *   along with this program; if not, write to the                         *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
00018  ***************************************************************************/
00019 
00020 /* Ion for BBC Weather from UKMET Office */
00021 
00022 #ifndef _ION_BBCUKMET_H
00023 #define _ION_BBCUKMET_H
00024 
00025 #include <QtXml/QXmlStreamReader>
00026 #include <QRegExp>
00027 #include <QtCore/QStringList>
00028 #include <QDateTime>
00029 #include <QDebug>
00030 #include <kurl.h>
00031 #include <kio/job.h>
00032 #include <kio/scheduler.h>
00033 #include <kdemacros.h>
00034 #include <plasma/dataengine.h>
00035 #include "ion.h"
00036 #include "weatherutils.h"
00037 
00038 class WeatherData
00039 {
00040 
00041 public:
00042     QString place;
00043     QString stationName;
00044     // Current observation information.
00045     QString obsTime;
00046     int iconPeriodHour;
00047     //QString iconPeriodAP;
00048 
00049     QString condition;
00050     QString conditionIcon;
00051     QString temperature_C;
00052     QString temperature_F;
00053     QString windDirection;
00054     QString windSpeed_miles;
00055     QString humidity;
00056     QString pressure;
00057     QString pressureTendency;
00058     QString visibilityStr;
00059 
00060     // Five day forecast
00061     struct ForecastInfo {
00062         QString period;
00063         QString iconName;
00064         QString summary;
00065         int tempHigh;
00066         int tempLow;
00067         int windSpeed;
00068         QString windDirection;
00069     };
00070 
00071     // 5 day Forecast
00072     QVector <WeatherData::ForecastInfo *> forecasts;
00073 };
00074 
00075 class KDE_EXPORT UKMETIon : public IonInterface
00076 {
00077     Q_OBJECT
00078 
00079 public:
00080     UKMETIon(QObject *parent, const QVariantList &args);
00081     ~UKMETIon();
00082     void init();  // Setup the city location, fetching the correct URL name.
00083     bool updateIonSource(const QString& source);
00084     void updateWeather(const QString& source);
00085 
00086     QString place(const QString& source);
00087     QString station(const QString& source);
00088     QString observationTime(const QString& source);
00089     //bool night(const QString& source);
00090     int periodHour(const QString& source);
00091     QString condition(const QString& source);
00092     QMap<QString, QString> temperature(const QString& source);
00093     QMap<QString, QString> wind(const QString& source);
00094     QString humidity(const QString& source);
00095     QString visibility(const QString& source);
00096     QMap<QString, QString> pressure(const QString& source);
00097     QVector<QString> forecasts(const QString& source);
00098 
00099 protected slots:
00100     void setup_slotDataArrived(KIO::Job *, const QByteArray &);
00101     void setup_slotJobFinished(KJob *);
00102     void setup_slotRedirected(KIO::Job *, const KUrl &url);
00103     void observation_slotDataArrived(KIO::Job *, const QByteArray &);
00104     void observation_slotJobFinished(KJob *);
00105     void forecast_slotDataArrived(KIO::Job *, const QByteArray &);
00106     void forecast_slotJobFinished(KJob *);
00107 
00108 private:
00109     /* UKMET Methods - Internal for Ion */
00110 
00111     QMap<QString, ConditionIcons> setupDayIconMappings(void);
00112     QMap<QString, ConditionIcons> setupNightIconMappings(void);
00113 
00114     QMap<QString, ConditionIcons> const& nightIcons(void);
00115     QMap<QString, ConditionIcons> const& dayIcons(void);
00116 
00117     // Load and Parse the place search XML listings
00118     void findPlace(const QString& place, const QString& source);
00119     void validate(const QString& source); // Sync data source with Applet
00120     void getFiveDayForecast(const QString& source);
00121     void getXMLData(const QString& source);
00122     bool readSearchXMLData(const QString& source, QXmlStreamReader& xml);
00123     bool readFiveDayForecastXMLData(const QString& source, QXmlStreamReader& xml);
00124     void parseSearchLocations(const QString& source, QXmlStreamReader& xml);
00125 
00126     // Observation parsing methods
00127     bool readObservationXMLData(const QString& source, QXmlStreamReader& xml);
00128     void parsePlaceObservation(const QString& source, WeatherData& data, QXmlStreamReader& xml);
00129     void parseWeatherChannel(const QString& source, WeatherData& data, QXmlStreamReader& xml);
00130     void parseWeatherObservation(const QString& source, WeatherData& data, QXmlStreamReader& xml);
00131     void parseFiveDayForecast(const QString& source, QXmlStreamReader& xml);
00132     void parseUnknownElement(QXmlStreamReader& xml);
00133 
00134 private:
00135     class Private;
00136     Private *const d;
00137 };
00138 
00139 K_EXPORT_PLASMA_DATAENGINE(bbcukmet, UKMETIon)
00140 
00141 #endif

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal