add more spacing
[personal-kdebase.git] / workspace / plasma / dataengines / weather / ions / ion_noaa.h
blob42509ec41f985bf5d451fa4a8e369c91fd3fa2de
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 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 <QDateTime>
29 #include <kurl.h>
30 #include <kio/job.h>
31 #include <kio/scheduler.h>
32 #include <kdemacros.h>
33 #include <plasma/dataengine.h>
34 #include "ion.h"
35 #include "weatherutils.h"
37 class WeatherData
40 public:
41 //QString countryName; // USA
42 QString locationName;
43 QString stationID;
44 QString stateName;
46 // Current observation information.
47 QString observationTime;
48 QString iconPeriodHour;
49 QString iconPeriodAP;
50 QString weather;
52 QString temperature_F;
53 QString temperature_C;
54 QString humidity;
55 QString windString;
56 QString windDirection;
57 QString windSpeed; // Float value
58 QString windGust; // Float value
59 QString pressure;
60 QString dewpoint_F;
61 QString dewpoint_C;
62 QString heatindex_F;
63 QString heatindex_C;
64 QString windchill_F;
65 QString windchill_C;
66 QString visibility;
69 class KDE_EXPORT NOAAIon : public IonInterface
71 Q_OBJECT
73 public:
74 NOAAIon(QObject *parent, const QVariantList &args);
75 ~NOAAIon();
76 void init(void); // Setup the city location, fetching the correct URL name.
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 */
89 QMap<QString, ConditionIcons> setupConditionIconMappings(void);
90 QMap<QString, ConditionIcons> const & conditionIcons(void);
91 QMap<QString, WindDirections> setupWindIconMappings(void);
92 QMap<QString, WindDirections> const& windIcons(void);
94 // Place information
95 QString country(const QString& source);
96 QString place(const QString& source);
97 QString station(const QString& source);
99 // Current Conditions Weather info
100 QString observationTime(const QString& source);
101 //bool night(const QString& source);
102 int periodHour(const QString& source);
103 QString condition(const QString& source);
104 QMap<QString, QString> temperature(const QString& source);
105 QString dewpoint(const QString& source);
106 QString humidity(const QString& source);
107 QMap<QString, QString> visibility(const QString& source);
108 QMap<QString, QString> pressure(const QString& source);
109 QMap<QString, QString> wind(const QString& source);
111 // Load and Parse the place XML listing
112 void getXMLSetup(void);
113 bool readXMLSetup(void);
115 // Load and parse the specific place(s)
116 void getXMLData(const QString& source);
117 bool readXMLData(const QString& source, QXmlStreamReader& xml);
119 // Check if place specified is valid or not
120 QStringList validate(const QString& source) const;
122 // Catchall for unknown XML tags
123 void parseUnknownElement(QXmlStreamReader& xml);
125 // Parse weather XML data
126 WeatherData parseWeatherSite(WeatherData& data, QXmlStreamReader& xml);
127 void parseStationID(void);
128 void parseStationList(void);
130 private:
131 class Private;
132 Private *const d;
135 K_EXPORT_PLASMA_DATAENGINE(noaa, NOAAIon)
137 #endif