summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
Unidiff
Diffstat (limited to 'noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index 572a720..1d53344 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -207,116 +207,116 @@ void getStocks( const QString *blah) {
207 output +=tempString; 207 output +=tempString;
208 208
209 /* Simple function which help to browse in the stocks list */ 209 /* Simple function which help to browse in the stocks list */
210 stocks_tmp = next_stock(stocks_tmp); 210 stocks_tmp = next_stock(stocks_tmp);
211 } 211 }
212 212
213 /* frees stocks */ 213 /* frees stocks */
214 free_stocks(stocks_quotes); 214 free_stocks(stocks_quotes);
215 stocktickerTicker->setText( output ); 215 stocktickerTicker->setText( output );
216 216
217} 217}
218 218
219StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) 219StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name)
220 : QWidget(parent, name ) { 220 : QWidget(parent, name ) {
221 init(); 221 init();
222 startTimer(1000); 222 startTimer(1000);
223// checkConnection(); 223// checkConnection();
224} 224}
225 225
226StockTickerPluginWidget::~StockTickerPluginWidget() { 226StockTickerPluginWidget::~StockTickerPluginWidget() {
227} 227}
228 228
229void StockTickerPluginWidget::init() { 229void StockTickerPluginWidget::init() {
230 230
231 QHBoxLayout* layout = new QHBoxLayout( this ); 231 QHBoxLayout* layout = new QHBoxLayout( this );
232 stocktickerTicker = new OTicker(this); 232 stocktickerTicker = new OTicker(this);
233 stocktickerTicker->setMinimumHeight(15); 233 stocktickerTicker->setMinimumHeight(15);
234 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); 234 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() ));
235 layout->addWidget( stocktickerTicker); 235 layout->addWidget( stocktickerTicker);
236 wasError = true; 236 wasError = true;
237} 237}
238 238
239void StockTickerPluginWidget::doStocks() { 239void StockTickerPluginWidget::doStocks() {
240 Config cfg( "stockticker"); 240 Config cfg( "stockticker");
241 cfg.setGroup( "Symbols" ); 241 cfg.setGroup( "Symbols" );
242 QString symbollist; 242 QString symbollist;
243 symbollist = cfg.readEntry("Symbols", ""); 243 symbollist = cfg.readEntry("Symbols", "");
244 symbollist.replace(QRegExp(" "),"+");//seperated by + 244 symbollist.replace(QRegExp(" "),"+");//seperated by +
245 245
246// qDebug(symbollist); 246// qDebug(symbollist);
247 if (!symbollist.isEmpty()) { 247 if (!symbollist.isEmpty()) {
248 pthread_t thread1; 248 pthread_t thread1;
249 pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist); 249 pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist);
250 } 250 }
251// pthread_join(thread1,NULL); 251// pthread_join(thread1,NULL);
252// getStocks( symbollist.latin1() ); 252// getStocks( symbollist.latin1() );
253} 253}
254 254
255void StockTickerPluginWidget::DefProxy(void) { 255//void StockTickerPluginWidget::DefProxy(void) {
256// char *proxy; 256// char *proxy;
257// libstocks_return_code error; 257// libstocks_return_code error;
258 258
259// /* Proxy support */ 259// /* Proxy support */
260// /* Checks for "http_proxy" environment variable */ 260// /* Checks for "http_proxy" environment variable */
261// proxy = getenv("http_proxy"); 261// proxy = getenv("http_proxy");
262// if(proxy) { 262// if(proxy) {
263// /* printf("proxy set\n"); */ 263// /* printf("proxy set\n"); */
264// error = set_proxy(proxy); 264// error = set_proxy(proxy);
265// if (error) { 265// if (error) {
266// // printf("Proxy error (%d)\n", error); 266// // printf("Proxy error (%d)\n", error);
267// QString tempString; 267// QString tempString;
268// tempString.sprintf("Proxy error (%d)\n", error); 268// tempString.sprintf("Proxy error (%d)\n", error);
269// output = tempString; 269// output = tempString;
270// return; 270// return;
271// // exit(1); 271// // exit(1);
272// } 272// }
273// } 273// }
274} 274//}
275 275
276void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { 276void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
277 killTimer(e->timerId()); 277 killTimer(e->timerId());
278 checkConnection(); 278 checkConnection();
279} 279}
280 280
281void StockTickerPluginWidget::checkConnection() { 281void StockTickerPluginWidget::checkConnection() {
282// qDebug("checking connection"); 282// qDebug("checking connection");
283// Sock = new QSocket( this ); 283// Sock = new QSocket( this );
284 284
285// if( wasError) 285// if( wasError)
286// stocktickerTicker->setText("Checking connection"); 286// stocktickerTicker->setText("Checking connection");
287 287
288// if(Sock->state() == QSocket::Idle) { 288// if(Sock->state() == QSocket::Idle) {
289// Sock->connectToHost("finance.yahoo.com", 80); 289// Sock->connectToHost("finance.yahoo.com", 80);
290// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); 290// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) );
291// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); 291// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) );
292// } else { 292// } else {
293// qDebug("State is not Idle"); 293// qDebug("State is not Idle");
294 isConnected(); 294 isConnected();
295// } 295// }
296} 296}
297 297
298void StockTickerPluginWidget::isConnected() { 298void StockTickerPluginWidget::isConnected() {
299// qDebug("We connect, so ok to grab stocks"); 299// qDebug("We connect, so ok to grab stocks");
300 doStocks(); 300 doStocks();
301 301
302 Config cfg( "stockticker"); 302 Config cfg( "stockticker");
303 cfg.setGroup("Timer"); 303 cfg.setGroup("Timer");
304 timerDelay= cfg.readNumEntry("Delay",0); 304 timerDelay= cfg.readNumEntry("Delay",0);
305 if(timerDelay > 0) 305 if(timerDelay > 0)
306 startTimer(timerDelay*60000); 306 startTimer(timerDelay*60000);
307 qDebug("timer set for %d",(timerDelay*60000)/60000); 307 qDebug("timer set for %d",(timerDelay*60000)/60000);
308 wasError = false; 308 wasError = false;
309 309
310// Sock->close(); 310// Sock->close();
311} 311}
312 312
313void StockTickerPluginWidget::socketError(int errcode) { 313void StockTickerPluginWidget::socketError(int errcode) {
314 switch(errcode) { 314 switch(errcode) {
315 case QSocket::ErrConnectionRefused: 315 case QSocket::ErrConnectionRefused:
316 output = tr("Connection refused."); 316 output = tr("Connection refused.");
317 break; 317 break;
318 case QSocket::ErrHostNotFound: 318 case QSocket::ErrHostNotFound:
319 output = tr("Could not find server."); 319 output = tr("Could not find server.");
320 break; 320 break;
321 case QSocket::ErrSocketRead : 321 case QSocket::ErrSocketRead :
322 output = tr("Socket read error."); 322 output = tr("Socket read error.");