add more spacing
[personal-kdebase.git] / workspace / plasma / dataengines / weather / ions / ion_bbcukmet.h
blob3b7e645cb7cdf505d4111bb58a0f563555b2b5fe
1 /***************************************************************************
2 * Copyright (C) 2007-2008 by Shawn Starr <shawn.starr@rogers.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
18 ***************************************************************************/
20 /* Ion for BBC Weather from UKMET Office */
22 #ifndef _ION_BBCUKMET_H
23 #define _ION_BBCUKMET_H
25 #include <QtXml/QXmlStreamReader>
26 #include <QRegExp>
27 #include <QtCore/QStringList>
28 #include <QDateTime>
29 #include <QDebug>
30 #include <kurl.h>
31 #include <kio/job.h>
32 #include <kio/scheduler.h>
33 #include <kdemacros.h>
34 #include <plasma/dataengine.h>
35 #include "ion.h"
36 #include "weatherutils.h"
38 class WeatherData
41 public:
42 QString place;
43 QString stationName;
44 // Current observation information.
45 QString obsTime;
46 int iconPeriodHour;
47 //QString iconPeriodAP;
49 QString condition;
50 QString conditionIcon;
51 QString temperature_C;
52 QString temperature_F;
53 QString windDirection;
54 QString windSpeed_miles;
55 QString humidity;
56 QString pressure;
57 QString pressureTendency;
58 QString visibilityStr;
60 // Five day forecast
61 struct ForecastInfo {
62 QString period;
63 QString iconName;
64 QString summary;
65 int tempHigh;
66 int tempLow;
67 int windSpeed;
68 QString windDirection;
71 // 5 day Forecast
72 QVector <WeatherData::ForecastInfo *> forecasts;
75 class KDE_EXPORT UKMETIon : public IonInterface
77 Q_OBJECT
79 public:
80 UKMETIon(QObject *parent, const QVariantList &args);
81 ~UKMETIon();
82 void init(); // Setup the city location, fetching the correct URL name.
83 bool updateIonSource(const QString& source);
84 void updateWeather(const QString& source);
86 QString place(const QString& source);
87 QString station(const QString& source);
88 QString observationTime(const QString& source);
89 //bool night(const QString& source);
90 int periodHour(const QString& source);
91 QString condition(const QString& source);
92 QMap<QString, QString> temperature(const QString& source);
93 QMap<QString, QString> wind(const QString& source);
94 QString humidity(const QString& source);
95 QString visibility(const QString& source);
96 QMap<QString, QString> pressure(const QString& source);
97 QVector<QString> forecasts(const QString& source);
99 protected slots:
100 void setup_slotDataArrived(KIO::Job *, const QByteArray &);
101 void setup_slotJobFinished(KJob *);
102 void setup_slotRedirected(KIO::Job *, const KUrl &url);
103 void observation_slotDataArrived(KIO::Job *, const QByteArray &);
104 void observation_slotJobFinished(KJob *);
105 void forecast_slotDataArrived(KIO::Job *, const QByteArray &);
106 void forecast_slotJobFinished(KJob *);
108 private:
109 /* UKMET Methods - Internal for Ion */
111 QMap<QString, ConditionIcons> setupDayIconMappings(void);
112 QMap<QString, ConditionIcons> setupNightIconMappings(void);
114 QMap<QString, ConditionIcons> const& nightIcons(void);
115 QMap<QString, ConditionIcons> const& dayIcons(void);
117 // Load and Parse the place search XML listings
118 void findPlace(const QString& place, const QString& source);
119 void validate(const QString& source); // Sync data source with Applet
120 void getFiveDayForecast(const QString& source);
121 void getXMLData(const QString& source);
122 bool readSearchXMLData(const QString& source, QXmlStreamReader& xml);
123 bool readFiveDayForecastXMLData(const QString& source, QXmlStreamReader& xml);
124 void parseSearchLocations(const QString& source, QXmlStreamReader& xml);
126 // Observation parsing methods
127 bool readObservationXMLData(const QString& source, QXmlStreamReader& xml);
128 void parsePlaceObservation(const QString& source, WeatherData& data, QXmlStreamReader& xml);
129 void parseWeatherChannel(const QString& source, WeatherData& data, QXmlStreamReader& xml);
130 void parseWeatherObservation(const QString& source, WeatherData& data, QXmlStreamReader& xml);
131 void parseFiveDayForecast(const QString& source, QXmlStreamReader& xml);
132 void parseUnknownElement(QXmlStreamReader& xml);
134 private:
135 class Private;
136 Private *const d;
139 K_EXPORT_PLASMA_DATAENGINE(bbcukmet, UKMETIon)
141 #endif