1 | #ifndef __WEATHER_H_ |
---|
2 | #define __WEATHER_H_ |
---|
3 | |
---|
4 | /* $Id: weather.h,v 1.1.1.2 2004-10-04 03:07:16 ghudson Exp $ */ |
---|
5 | |
---|
6 | /* |
---|
7 | * Papadimitriou Spiros <spapadim+@cs.cmu.edu> |
---|
8 | * |
---|
9 | * This code released under the GNU GPL. |
---|
10 | * Read the file COPYING for more information. |
---|
11 | * |
---|
12 | * Weather server functions (METAR and IWIN) |
---|
13 | * |
---|
14 | */ |
---|
15 | |
---|
16 | #include <time.h> |
---|
17 | #include <panel-applet.h> |
---|
18 | #include <panel-applet-gconf.h> |
---|
19 | #include <libgnomevfs/gnome-vfs.h> |
---|
20 | #include "gweather.h" |
---|
21 | |
---|
22 | /* |
---|
23 | * Location |
---|
24 | */ |
---|
25 | |
---|
26 | G_BEGIN_DECLS |
---|
27 | |
---|
28 | #define WEATHER_LOCATION_CODE_LEN 4 |
---|
29 | |
---|
30 | struct _WeatherLocation { |
---|
31 | gchar *untrans_name; |
---|
32 | gchar *trans_name; |
---|
33 | gchar *code; |
---|
34 | gchar *zone; |
---|
35 | gchar *radar; |
---|
36 | gboolean zone_valid; |
---|
37 | }; |
---|
38 | |
---|
39 | |
---|
40 | |
---|
41 | extern WeatherLocation *weather_location_new (const gchar *untrans_name, const gchar *trans_name, const gchar *code, const gchar *zone, const gchar *radar); |
---|
42 | extern WeatherLocation *weather_location_clone (const WeatherLocation *location); |
---|
43 | extern void weather_location_free (WeatherLocation *location); |
---|
44 | extern gboolean weather_location_equal (const WeatherLocation *location1, const WeatherLocation *location2); |
---|
45 | |
---|
46 | extern void weather_location_config_write (gchar *prefix, WeatherLocation *location); |
---|
47 | extern WeatherLocation *weather_location_config_read (PanelApplet *applet); |
---|
48 | |
---|
49 | |
---|
50 | /* |
---|
51 | * Weather information |
---|
52 | */ |
---|
53 | |
---|
54 | enum _WeatherWindDirection { |
---|
55 | WIND_VARIABLE, |
---|
56 | WIND_N, WIND_NNE, WIND_NE, WIND_ENE, |
---|
57 | WIND_E, WIND_ESE, WIND_SE, WIND_SSE, |
---|
58 | WIND_S, WIND_SSW, WIND_SW, WIND_WSW, |
---|
59 | WIND_W, WIND_WNW, WIND_NW, WIND_NNW |
---|
60 | }; |
---|
61 | |
---|
62 | typedef enum _WeatherWindDirection WeatherWindDirection; |
---|
63 | |
---|
64 | extern const gchar *weather_wind_direction_string (WeatherWindDirection wind); |
---|
65 | |
---|
66 | enum _WeatherSky { |
---|
67 | SKY_CLEAR, |
---|
68 | SKY_BROKEN, |
---|
69 | SKY_SCATTERED, |
---|
70 | SKY_FEW, |
---|
71 | SKY_OVERCAST |
---|
72 | }; |
---|
73 | |
---|
74 | typedef enum _WeatherSky WeatherSky; |
---|
75 | |
---|
76 | extern const gchar *weather_sky_string (WeatherSky sky); |
---|
77 | |
---|
78 | enum _WeatherConditionPhenomenon { |
---|
79 | PHENOMENON_NONE, |
---|
80 | |
---|
81 | PHENOMENON_DRIZZLE, |
---|
82 | PHENOMENON_RAIN, |
---|
83 | PHENOMENON_SNOW, |
---|
84 | PHENOMENON_SNOW_GRAINS, |
---|
85 | PHENOMENON_ICE_CRYSTALS, |
---|
86 | PHENOMENON_ICE_PELLETS, |
---|
87 | PHENOMENON_HAIL, |
---|
88 | PHENOMENON_SMALL_HAIL, |
---|
89 | PHENOMENON_UNKNOWN_PRECIPITATION, |
---|
90 | |
---|
91 | PHENOMENON_MIST, |
---|
92 | PHENOMENON_FOG, |
---|
93 | PHENOMENON_SMOKE, |
---|
94 | PHENOMENON_VOLCANIC_ASH, |
---|
95 | PHENOMENON_SAND, |
---|
96 | PHENOMENON_HAZE, |
---|
97 | PHENOMENON_SPRAY, |
---|
98 | PHENOMENON_DUST, |
---|
99 | |
---|
100 | PHENOMENON_SQUALL, |
---|
101 | PHENOMENON_SANDSTORM, |
---|
102 | PHENOMENON_DUSTSTORM, |
---|
103 | PHENOMENON_FUNNEL_CLOUD, |
---|
104 | PHENOMENON_TORNADO, |
---|
105 | PHENOMENON_DUST_WHIRLS |
---|
106 | }; |
---|
107 | |
---|
108 | typedef enum _WeatherConditionPhenomenon WeatherConditionPhenomenon; |
---|
109 | |
---|
110 | enum _WeatherConditionQualifier { |
---|
111 | QUALIFIER_NONE, |
---|
112 | |
---|
113 | QUALIFIER_VICINITY, |
---|
114 | |
---|
115 | QUALIFIER_LIGHT, |
---|
116 | QUALIFIER_MODERATE, |
---|
117 | QUALIFIER_HEAVY, |
---|
118 | QUALIFIER_SHALLOW, |
---|
119 | QUALIFIER_PATCHES, |
---|
120 | QUALIFIER_PARTIAL, |
---|
121 | QUALIFIER_THUNDERSTORM, |
---|
122 | QUALIFIER_BLOWING, |
---|
123 | QUALIFIER_SHOWERS, |
---|
124 | QUALIFIER_DRIFTING, |
---|
125 | QUALIFIER_FREEZING |
---|
126 | }; |
---|
127 | |
---|
128 | typedef enum _WeatherConditionQualifier WeatherConditionQualifier; |
---|
129 | |
---|
130 | struct _WeatherConditions { |
---|
131 | gboolean significant; |
---|
132 | WeatherConditionPhenomenon phenomenon; |
---|
133 | WeatherConditionQualifier qualifier; |
---|
134 | }; |
---|
135 | |
---|
136 | typedef struct _WeatherConditions WeatherConditions; |
---|
137 | |
---|
138 | extern const gchar *weather_conditions_string (WeatherConditions cond); |
---|
139 | |
---|
140 | enum _WeatherForecastType { |
---|
141 | FORECAST_STATE, |
---|
142 | FORECAST_ZONE |
---|
143 | }; |
---|
144 | |
---|
145 | typedef enum _WeatherForecastType WeatherForecastType; |
---|
146 | |
---|
147 | typedef gdouble WeatherTemperature; |
---|
148 | typedef gdouble WeatherHumidity; |
---|
149 | typedef gint WeatherWindSpeed; |
---|
150 | typedef gdouble WeatherPressure; |
---|
151 | typedef gdouble WeatherVisibility; |
---|
152 | |
---|
153 | |
---|
154 | extern void weather_forecast_set (WeatherForecastType forecast); |
---|
155 | extern WeatherForecastType weather_forecast_get (void); |
---|
156 | |
---|
157 | extern void weather_radar_set (gboolean enable); |
---|
158 | extern gboolean weather_radar_get (void); |
---|
159 | |
---|
160 | extern void weather_proxy_set (const gchar *url, const gchar *user, const gchar *passwd); |
---|
161 | |
---|
162 | typedef time_t WeatherUpdate; |
---|
163 | |
---|
164 | struct _WeatherInfo { |
---|
165 | gboolean valid; |
---|
166 | WeatherLocation *location; |
---|
167 | WeatherUpdate update; |
---|
168 | WeatherSky sky; |
---|
169 | WeatherConditions cond; |
---|
170 | WeatherTemperature temp; |
---|
171 | WeatherTemperature dew; |
---|
172 | WeatherWindDirection wind; |
---|
173 | WeatherWindSpeed windspeed; |
---|
174 | WeatherPressure pressure; |
---|
175 | WeatherVisibility visibility; |
---|
176 | gchar *forecast; |
---|
177 | gchar *metar_buffer; |
---|
178 | gchar *iwin_buffer; |
---|
179 | gchar *met_buffer; |
---|
180 | gchar *bom_buffer; |
---|
181 | gchar *radar_buffer; |
---|
182 | gchar *radar_url; |
---|
183 | GdkPixbufLoader *radar_loader; |
---|
184 | GdkPixmap *radar; |
---|
185 | GdkBitmap *radar_mask; |
---|
186 | GnomeVFSAsyncHandle *metar_handle; |
---|
187 | GnomeVFSAsyncHandle *iwin_handle; |
---|
188 | GnomeVFSAsyncHandle *wx_handle; |
---|
189 | GnomeVFSAsyncHandle *met_handle; |
---|
190 | GnomeVFSAsyncHandle *bom_handle; |
---|
191 | gboolean requests_pending; |
---|
192 | GWeatherApplet *applet; |
---|
193 | }; |
---|
194 | |
---|
195 | |
---|
196 | |
---|
197 | typedef void (*WeatherInfoFunc) (WeatherInfo *info); |
---|
198 | |
---|
199 | extern gboolean _weather_info_fill (GWeatherApplet *applet, WeatherInfo *info, WeatherLocation *location, WeatherInfoFunc cb); |
---|
200 | #define weather_info_new(applet, location,cb) _weather_info_fill((applet), NULL, (location), (cb)) |
---|
201 | #define weather_info_update(applet, info,cb) _weather_info_fill((applet), (info), NULL, (cb)); |
---|
202 | extern WeatherInfo *weather_info_clone (const WeatherInfo *info); |
---|
203 | extern void weather_info_free (WeatherInfo *info); |
---|
204 | |
---|
205 | extern void weather_info_config_write (WeatherInfo *info); |
---|
206 | extern WeatherInfo *weather_info_config_read (PanelApplet *applet); |
---|
207 | |
---|
208 | extern void weather_info_to_metric (WeatherInfo *info); |
---|
209 | extern void weather_info_to_imperial (WeatherInfo *info); |
---|
210 | |
---|
211 | extern const gchar *weather_info_get_location (WeatherInfo *info); |
---|
212 | extern const gchar *weather_info_get_update (WeatherInfo *info); |
---|
213 | extern const gchar *weather_info_get_sky (WeatherInfo *info); |
---|
214 | extern const gchar *weather_info_get_conditions (WeatherInfo *info); |
---|
215 | extern const gchar *weather_info_get_temp (WeatherInfo *info); |
---|
216 | extern const gchar *weather_info_get_dew (WeatherInfo *info); |
---|
217 | extern const gchar *weather_info_get_humidity (WeatherInfo *info); |
---|
218 | extern const gchar *weather_info_get_wind (WeatherInfo *info); |
---|
219 | extern const gchar *weather_info_get_pressure (WeatherInfo *info); |
---|
220 | extern const gchar *weather_info_get_visibility (WeatherInfo *info); |
---|
221 | extern const gchar *weather_info_get_apparent (WeatherInfo *info); |
---|
222 | extern const gchar *weather_info_get_forecast (WeatherInfo *info); |
---|
223 | extern GdkPixmap *weather_info_get_radar (WeatherInfo *info); |
---|
224 | |
---|
225 | extern const gchar *weather_info_get_temp_summary (WeatherInfo *info); |
---|
226 | extern gchar *weather_info_get_weather_summary (WeatherInfo *info); |
---|
227 | |
---|
228 | extern void update_finish (WeatherInfo *info); |
---|
229 | |
---|
230 | extern time_t make_time (gint date, gint hour, gint min); |
---|
231 | |
---|
232 | extern void _weather_info_get_pixbuf (WeatherInfo *info, gboolean mini, GdkPixbuf **pixbuf); |
---|
233 | #define weather_info_get_pixbuf_mini(info,pixbuf) _weather_info_get_pixbuf((info), TRUE, (pixbuf)) |
---|
234 | #define weather_info_get_pixbuf(info,pixbuf) _weather_info_get_pixbuf((info), FALSE, (pixbuf)) |
---|
235 | |
---|
236 | G_END_DECLS |
---|
237 | |
---|
238 | #endif /* __WEATHER_H_ */ |
---|