summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/weather/weatherpluginwidget.cpp
Unidiff
Diffstat (limited to 'noncore/todayplugins/weather/weatherpluginwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/todayplugins/weather/weatherpluginwidget.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/todayplugins/weather/weatherpluginwidget.cpp b/noncore/todayplugins/weather/weatherpluginwidget.cpp
index fe54051..27624c5 100644
--- a/noncore/todayplugins/weather/weatherpluginwidget.cpp
+++ b/noncore/todayplugins/weather/weatherpluginwidget.cpp
@@ -83,49 +83,50 @@ void WeatherPluginWidget::retreiveData()
83 location = config.readEntry( "Location", "" ); 83 location = config.readEntry( "Location", "" );
84 useMetric = config.readBoolEntry( "Metric", true ); 84 useMetric = config.readBoolEntry( "Metric", true );
85 frequency = config.readNumEntry( "Frequency", 5 ); 85 frequency = config.readNumEntry( "Frequency", 5 );
86 86
87 startTimer( frequency * 60000 ); 87 startTimer( frequency * 60000 );
88 88
89 localFile = "/tmp/"; 89 localFile = "/tmp/";
90 localFile.append( location ); 90 localFile.append( location );
91 localFile.append( ".TXT" ); 91 localFile.append( ".TXT" );
92 92
93 remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/"; 93 remoteFile = "http://weather.noaa.gov/pub/data/observations/metar/stations/";
94 remoteFile.append( location ); 94 remoteFile.append( location );
95 remoteFile.append( ".TXT" ); 95 remoteFile.append( ".TXT" );
96 96
97 QFile file( localFile ); 97 QFile file( localFile );
98 if ( file.exists() ) 98 if ( file.exists() )
99 { 99 {
100 file.remove(); 100 file.remove();
101 } 101 }
102 102
103 OProcess *proc = new OProcess; 103 OProcess *proc = new OProcess;
104 104
105 *proc << "wget" << "-q" << remoteFile << "-O" << localFile; 105 *proc << "wget" << "-q" << remoteFile << "-O" << localFile;
106 connect( proc, SIGNAL( processExited(Opie::Core::OProcess*) ), this, SLOT( dataRetrieved(Opie::Core::OProcess*) ) ); 106 connect( proc, SIGNAL( processExited(Opie::Core::OProcess*) ), this, SLOT( dataRetrieved(Opie::Core::OProcess*) ) );
107 proc->start(); 107 if ( !proc->start() )
108 weatherLabel->setText( tr( "Could not start wget process." ) );
108} 109}
109 110
110void WeatherPluginWidget::displayWeather() 111void WeatherPluginWidget::displayWeather()
111{ 112{
112 weatherData = QString::null; 113 weatherData = QString::null;
113 114
114 QFile file( localFile ); 115 QFile file( localFile );
115 116
116 if ( file.size() > 0 && file.open( IO_ReadOnly ) ) 117 if ( file.size() > 0 && file.open( IO_ReadOnly ) )
117 { 118 {
118 QTextStream data( &file ); 119 QTextStream data( &file );
119 while ( !data.eof() ) 120 while ( !data.eof() )
120 { 121 {
121 weatherData.append( data.readLine() ); 122 weatherData.append( data.readLine() );
122 } 123 }
123 file.close(); 124 file.close();
124 weatherData = weatherData.simplifyWhiteSpace(); 125 weatherData = weatherData.simplifyWhiteSpace();
125 126
126 QString tmpstr; 127 QString tmpstr;
127 128
128 tmpstr.append( tr( "Temp: " ) ); 129 tmpstr.append( tr( "Temp: " ) );
129 getTemp( weatherData ); 130 getTemp( weatherData );
130 tmpstr.append( dataStr ); 131 tmpstr.append( dataStr );
131 132