summaryrefslogtreecommitdiff
path: root/noncore/todayplugins
Unidiff
Diffstat (limited to 'noncore/todayplugins') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/weather/weatherpluginwidget.cpp65
-rw-r--r--noncore/todayplugins/weather/weatherpluginwidget.h8
2 files changed, 39 insertions, 34 deletions
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.cpp b/noncore/todayplugins/weather/weatherpluginwidget.cpp
index 0fd8e57..6444ebf 100644
--- a/noncore/todayplugins/weather/weatherpluginwidget.cpp
+++ b/noncore/todayplugins/weather/weatherpluginwidget.cpp
@@ -27,3 +27,2 @@
27*/ 27*/
28#include <stdio.h>
29 28
@@ -36,2 +35,4 @@
36 35
36#include <opie/oprocess.h>
37
37#include <qpe/config.h> 38#include <qpe/config.h>
@@ -44,17 +45,2 @@ WeatherPluginWidget::WeatherPluginWidget( QWidget *parent, const char* name )
44{ 45{
45 Config config( "todayweatherplugin");
46 config.setGroup( "Config" );
47
48 location = config.readEntry( "Location", "" );
49 useMetric = config.readBoolEntry( "Metric", TRUE );
50 frequency = config.readNumEntry( "Frequency", 5 );
51
52 localFile = "/tmp/";
53 localFile.append( location );
54 localFile.append( ".TXT" );
55
56 remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/";
57 remoteFile.append( location );
58 remoteFile.append( ".TXT" );
59
60 QHBoxLayout *layout = new QHBoxLayout( this ); 46 QHBoxLayout *layout = new QHBoxLayout( this );
@@ -74,3 +60,2 @@ WeatherPluginWidget::WeatherPluginWidget( QWidget *parent, const char* name )
74 startTimer(1000); 60 startTimer(1000);
75 //retreiveData();
76} 61}
@@ -98,2 +83,17 @@ void WeatherPluginWidget::retreiveData()
98 83
84 Config config( "todayweatherplugin");
85 config.setGroup( "Config" );
86
87 location = config.readEntry( "Location", "" );
88 useMetric = config.readBoolEntry( "Metric", TRUE );
89 frequency = config.readNumEntry( "Frequency", 5 );
90
91 localFile = "/tmp/";
92 localFile.append( location );
93 localFile.append( ".TXT" );
94
95 remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/";
96 remoteFile.append( location );
97 remoteFile.append( ".TXT" );
98
99 QFile file( localFile ); 99 QFile file( localFile );
@@ -104,16 +104,7 @@ void WeatherPluginWidget::retreiveData()
104 104
105 QString command = "wget -q "; 105 OProcess *proc = new OProcess;
106 command.append( remoteFile ); 106
107 command.append( " -O " ); 107 *proc << "wget" << "-q" << remoteFile << "-O" << localFile;
108 command.append( localFile ); 108 connect( proc, SIGNAL( processExited( OProcess * ) ), this, SLOT( dataRetrieved( OProcess * ) ) );
109 FILE *get = popen( command.latin1(), "r" ); 109 proc->start();
110 if ( get )
111 {
112 pclose( get );
113 displayWeather();
114 }
115 else
116 {
117 weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) );
118 }
119} 110}
@@ -321 +312,13 @@ void WeatherPluginWidget::getIcon(const QString &data )
321} 312}
313
314void WeatherPluginWidget::dataRetrieved( OProcess *process )
315{
316 if ( process->normalExit() )
317 {
318 displayWeather();
319 }
320 else
321 {
322 weatherLabel->setText( tr( "Current weather data not available.\nTry looking out the window." ) );
323 }
324}
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.h b/noncore/todayplugins/weather/weatherpluginwidget.h
index 2c0238d..d2bbd8b 100644
--- a/noncore/todayplugins/weather/weatherpluginwidget.h
+++ b/noncore/todayplugins/weather/weatherpluginwidget.h
@@ -34,4 +34,3 @@
34 34
35#include <unistd.h> 35class OProcess;
36
37class QLabel; 36class QLabel;
@@ -58,3 +57,3 @@ class WeatherPluginWidget : public QWidget {
58 QLabel *weatherIcon; 57 QLabel *weatherIcon;
59 58
60 void timerEvent( QTimerEvent * ); 59 void timerEvent( QTimerEvent * );
@@ -66,2 +65,5 @@ class WeatherPluginWidget : public QWidget {
66 void getIcon( const QString & ); 65 void getIcon( const QString & );
66
67 private slots:
68 void dataRetrieved( OProcess * );
67}; 69};