• Skip to content
  • Skip to link menu
KDE 4.1 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 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 <QDebug>
00029 #include <kurl.h>
00030 #include <kio/job.h>
00031 #include <kio/scheduler.h>
00032 #include <kdemacros.h>
00033 #include <plasma/dataengine.h>
00034 #include "ion.h"
00035 #include "formulas.h"
00036 
00037 class WeatherData
00038 {
00039 
00040 public:
00041     QString place;
00042     QString stationName;
00043     // Current observation information.
00044     QString obsTime;
00045     QString condition;
00046     QString temperature_C;
00047     QString temperature_F;
00048     QString windDirection;
00049     QString windSpeed_miles;
00050     QString humidity;
00051     QString pressure;
00052     QString pressureTendency;
00053     QString visibilityStr;
00054 
00055     // Five day forecast
00056     struct ForecastInfo {
00057         QString period;
00058         QString summary;
00059         int tempHigh;
00060         int tempLow;
00061         int windSpeed;
00062         QString windDirection;
00063     };
00064 
00065     // 5 day Forecast
00066     QVector <WeatherData::ForecastInfo *> forecasts;
00067 };
00068 
00069 class KDE_EXPORT UKMETIon : public IonInterface
00070 {
00071     Q_OBJECT
00072 
00073 public:
00074     UKMETIon(QObject *parent, const QVariantList &args);
00075     ~UKMETIon();
00076     void init();  // Setup the city location, fetching the correct URL name.
00077     bool metricUnit(void);
00078     bool timezone(void);
00079     void setMeasureUnit(const QString& unit);
00080     void setTimezoneFormat(const QString& tz);
00081     bool updateIonSource(const QString& source);
00082     void updateWeather(const QString& source);
00083 
00084     QString place(const QString& source);
00085     QString station(const QString& source);
00086     QString observationTime(const QString& source);
00087     QString condition(const QString& source);
00088     QMap<QString, QString> temperature(const QString& source);
00089     QMap<QString, QString> wind(const QString& source);
00090     QString humidity(const QString& source);
00091     QString visibility(const QString& source);
00092     QMap<QString, QString> pressure(const QString& source);
00093     QVector<QString> forecasts(const QString& source);
00094 
00095 protected slots:
00096     void setup_slotDataArrived(KIO::Job *, const QByteArray &);
00097     void setup_slotJobFinished(KJob *);
00098     void setup_slotRedirected(KIO::Job *, const KUrl &url);
00099     void observation_slotDataArrived(KIO::Job *, const QByteArray &);
00100     void observation_slotJobFinished(KJob *);
00101     void forecast_slotDataArrived(KIO::Job *, const QByteArray &);
00102     void forecast_slotJobFinished(KJob *);
00103 
00104 private:
00105     /* UKMET Methods - Internal for Ion */
00106 
00107     // Load and Parse the place search XML listings
00108     void findPlace(const QString& place, const QString& source);
00109     void validate(const QString& source); // Sync data source with Applet
00110     void getFiveDayForecast(const QString& source);
00111     void getXMLData(const QString& source);
00112     bool readSearchXMLData(const QString& source, QXmlStreamReader& xml);
00113     bool readFiveDayForecastXMLData(const QString& source, QXmlStreamReader& xml);
00114     void parseSearchLocations(const QString& source, QXmlStreamReader& xml);
00115 
00116     // Observation parsing methods
00117     bool readObservationXMLData(const QString& source, QXmlStreamReader& xml);
00118     void parsePlaceObservation(const QString& source, WeatherData& data, QXmlStreamReader& xml);
00119     void parseWeatherChannel(const QString& source, WeatherData& data, QXmlStreamReader& xml);
00120     void parseWeatherObservation(const QString& source, WeatherData& data, QXmlStreamReader& xml);
00121     void parseFiveDayForecast(const QString& source, QXmlStreamReader& xml);
00122     void parseUnknownElement(QXmlStreamReader& xml);
00123 
00124 private:
00125     class Private;
00126     Private *const d;
00127 };
00128 
00129 K_EXPORT_PLASMA_ION(bbcukmet, UKMETIon)
00130 
00131 #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
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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