1 /***************************************************************************
2 * Copyright (C) 2007 by Shawn Starr <shawn.starr@rogers.com> *
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. *
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. *
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>
27 #include <QtCore/QStringList>
31 #include <kio/scheduler.h>
32 #include <kdemacros.h>
33 #include <plasma/dataengine.h>
43 // Current observation information.
46 QString temperature_C
;
47 QString temperature_F
;
48 QString windDirection
;
49 QString windSpeed_miles
;
52 QString pressureTendency
;
53 QString visibilityStr
;
62 QString windDirection
;
66 QVector
<WeatherData::ForecastInfo
*> forecasts
;
69 class KDE_EXPORT UKMETIon
: public IonInterface
74 UKMETIon(QObject
*parent
, const QVariantList
&args
);
76 void init(); // Setup the city location, fetching the correct URL name.
77 bool metricUnit(void);
79 void setMeasureUnit(const QString
& unit
);
80 void setTimezoneFormat(const QString
& tz
);
81 bool updateIonSource(const QString
& source
);
82 void updateWeather(const QString
& source
);
84 QString
place(const QString
& source
);
85 QString
station(const QString
& source
);
86 QString
observationTime(const QString
& source
);
87 QString
condition(const QString
& source
);
88 QMap
<QString
, QString
> temperature(const QString
& source
);
89 QMap
<QString
, QString
> wind(const QString
& source
);
90 QString
humidity(const QString
& source
);
91 QString
visibility(const QString
& source
);
92 QMap
<QString
, QString
> pressure(const QString
& source
);
93 QVector
<QString
> forecasts(const QString
& source
);
96 void setup_slotDataArrived(KIO::Job
*, const QByteArray
&);
97 void setup_slotJobFinished(KJob
*);
98 void setup_slotRedirected(KIO::Job
*, const KUrl
&url
);
99 void observation_slotDataArrived(KIO::Job
*, const QByteArray
&);
100 void observation_slotJobFinished(KJob
*);
101 void forecast_slotDataArrived(KIO::Job
*, const QByteArray
&);
102 void forecast_slotJobFinished(KJob
*);
105 /* UKMET Methods - Internal for Ion */
107 // Load and Parse the place search XML listings
108 void findPlace(const QString
& place
, const QString
& source
);
109 void validate(const QString
& source
); // Sync data source with Applet
110 void getFiveDayForecast(const QString
& source
);
111 void getXMLData(const QString
& source
);
112 bool readSearchXMLData(const QString
& source
, QXmlStreamReader
& xml
);
113 bool readFiveDayForecastXMLData(const QString
& source
, QXmlStreamReader
& xml
);
114 void parseSearchLocations(const QString
& source
, QXmlStreamReader
& xml
);
116 // Observation parsing methods
117 bool readObservationXMLData(const QString
& source
, QXmlStreamReader
& xml
);
118 void parsePlaceObservation(const QString
& source
, WeatherData
& data
, QXmlStreamReader
& xml
);
119 void parseWeatherChannel(const QString
& source
, WeatherData
& data
, QXmlStreamReader
& xml
);
120 void parseWeatherObservation(const QString
& source
, WeatherData
& data
, QXmlStreamReader
& xml
);
121 void parseFiveDayForecast(const QString
& source
, QXmlStreamReader
& xml
);
122 void parseUnknownElement(QXmlStreamReader
& xml
);
129 K_EXPORT_PLASMA_ION(bbcukmet
, UKMETIon
)