Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / plasma / dataengines / weather / ions / ion_noaa.h
blob175b01ca0280a2df0b8271db616e97f573e01874
1 /***************************************************************************
2 * Copyright (C) 2007 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 NOAA's National Weather Service XML data */
22 #ifndef _ION_NOAA_H
23 #define _ION_NOAA_H
25 #include <QtXml/QXmlStreamReader>
26 #include <QtCore/QStringList>
27 #include <QDebug>
28 #include <kurl.h>
29 #include <kio/job.h>
30 #include <kio/scheduler.h>
31 #include <kdemacros.h>
32 #include <plasma/dataengine.h>
33 #include "ion.h"
34 #include "formulas.h"
36 class WeatherData
39 public:
40 //QString countryName; // USA
41 QString locationName;
42 QString stationID;
43 QString stateName;
45 // Current observation information.
46 QString observationTime;
47 QString weather;
48 QString temperature_F;
49 QString temperature_C;
50 QString humidity;
51 QString windString;
52 QString windDirection;
53 QString windSpeed; // Float value
54 QString windGust; // Float value
55 QString pressure;
56 QString dewpoint_F;
57 QString dewpoint_C;
58 QString heatindex_F;
59 QString heatindex_C;
60 QString windchill_F;
61 QString windchill_C;
62 QString visibility;
65 class KDE_EXPORT NOAAIon : public IonInterface
67 Q_OBJECT
69 public:
70 NOAAIon(QObject *parent, const QVariantList &args);
71 ~NOAAIon();
72 void init(void); // Setup the city location, fetching the correct URL name.
73 bool metricUnit(void);
74 bool timezone(void);
75 void setMeasureUnit(const QString& unit);
76 void setTimezoneFormat(const QString& tz);
77 bool updateIonSource(const QString& source); // Sync data source with Applet
78 void updateWeather(const QString& source);
80 protected slots:
81 void setup_slotDataArrived(KIO::Job *, const QByteArray &);
82 void setup_slotJobFinished(KJob *);
84 void slotDataArrived(KIO::Job *, const QByteArray &);
85 void slotJobFinished(KJob *);
87 private:
88 /* NOAA Methods - Internal for Ion */
90 // Place information
91 QString country(const QString& source);
92 QString place(const QString& source);
93 QString station(const QString& source);
95 // Current Conditions Weather info
96 QString observationTime(const QString& source);
97 QString condition(const QString& source);
98 QMap<QString, QString> temperature(const QString& source);
99 QString dewpoint(const QString& source);
100 QString humidity(const QString& source);
101 QMap<QString, QString> visibility(const QString& source);
102 QMap<QString, QString> pressure(const QString& source);
103 QMap<QString, QString> wind(const QString& source);
105 // Load and Parse the place XML listing
106 void getXMLSetup(void);
107 bool readXMLSetup(void);
109 // Load and parse the specific place(s)
110 void getXMLData(const QString& source);
111 bool readXMLData(const QString& source, QXmlStreamReader& xml);
113 // Check if place specified is valid or not
114 QStringList validate(const QString& source) const;
116 // Catchall for unknown XML tags
117 void parseUnknownElement(QXmlStreamReader& xml);
119 // Parse weather XML data
120 WeatherData parseWeatherSite(WeatherData& data, QXmlStreamReader& xml);
121 void parseStationID(void);
122 void parseStationList(void);
124 private:
125 class Private;
126 Private *const d;
129 K_EXPORT_PLASMA_ION(noaa, NOAAIon)
131 #endif