Diffstat (limited to 'noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp index aaeb5ee..4855ac6 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | |||
@@ -16,65 +16,65 @@ | |||
16 | 16 | ||
17 | #include <opie2/oticker.h> | 17 | #include <opie2/oticker.h> |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | 22 | ||
23 | using namespace Opie::Ui; | 23 | using namespace Opie::Ui; |
24 | using namespace Opie::Ui; | 24 | using namespace Opie::Ui; |
25 | extern "C" { | 25 | extern "C" { |
26 | #include "libstocks/stocks.h" | 26 | #include "libstocks/stocks.h" |
27 | } | 27 | } |
28 | 28 | ||
29 | #include <pthread.h> | 29 | #include <pthread.h> |
30 | 30 | ||
31 | #include "stocktickerpluginwidget.h" | 31 | #include "stocktickerpluginwidget.h" |
32 | 32 | ||
33 | QString output; | 33 | QString output; |
34 | OTicker *stocktickerTicker; | 34 | OTicker *stocktickerTicker; |
35 | QCString stock_liste; | 35 | QCString stock_liste; |
36 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | 36 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; |
37 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | 37 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; |
38 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | 38 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; |
39 | 39 | ||
40 | void getStocks(char *blah) { | 40 | void getStocks(char *blah) { |
41 | 41 | ||
42 | // stocktickerTicker->setText( "Downloading stock data."); | 42 | // stocktickerTicker->setText( "Downloading stock data."); |
43 | stock *stocks_quotes=NULL; | 43 | stock *stocks_quotes=NULL; |
44 | stock *stocks_tmp; | 44 | stock *stocks_tmp; |
45 | stock_liste = blah; | 45 | stock_liste = blah; |
46 | ::free ( blah ); | 46 | ::free ( blah ); |
47 | // char *stock_liste = (char *)blah->latin1(); | 47 | // char *stock_liste = (char *)blah->latin1(); |
48 | // qDebug("%s", stock_liste.data() ); | 48 | // odebug << "" << stock_liste.data() << "" << oendl; |
49 | output = ""; | 49 | output = ""; |
50 | QString tempString; | 50 | QString tempString; |
51 | libstocks_return_code error; | 51 | libstocks_return_code error; |
52 | 52 | ||
53 | // Config cfg( "stockticker"); | 53 | // Config cfg( "stockticker"); |
54 | // cfg.setGroup( "Fields" ); | 54 | // cfg.setGroup( "Fields" ); |
55 | // bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | 55 | // bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; |
56 | // bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | 56 | // bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; |
57 | // bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | 57 | // bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; |
58 | 58 | ||
59 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; | 59 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; |
60 | 60 | ||
61 | dotimeCheck=1; | 61 | dotimeCheck=1; |
62 | dodateCheck=1; | 62 | dodateCheck=1; |
63 | dosymbolCheck=1; | 63 | dosymbolCheck=1; |
64 | donameCheck=1; | 64 | donameCheck=1; |
65 | docurrentPriceCheck=1; | 65 | docurrentPriceCheck=1; |
66 | dolastPriceCheck=1; | 66 | dolastPriceCheck=1; |
67 | doopenPriceCheck=1; | 67 | doopenPriceCheck=1; |
68 | dominPriceCheck=1; | 68 | dominPriceCheck=1; |
69 | domaxPriceCheck=1; | 69 | domaxPriceCheck=1; |
70 | dovariationCheck=1; | 70 | dovariationCheck=1; |
71 | dovolumeCheck=1; | 71 | dovolumeCheck=1; |
72 | 72 | ||
73 | // dotimeCheck=cfg.readBoolEntry("timeCheck",1); | 73 | // dotimeCheck=cfg.readBoolEntry("timeCheck",1); |
74 | // dodateCheck=cfg.readBoolEntry("dateCheck",1); | 74 | // dodateCheck=cfg.readBoolEntry("dateCheck",1); |
75 | // dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); | 75 | // dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); |
76 | // donameCheck=cfg.readBoolEntry("nameCheck",1); | 76 | // donameCheck=cfg.readBoolEntry("nameCheck",1); |
77 | // docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); | 77 | // docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); |
78 | // dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); | 78 | // dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); |
79 | // doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); | 79 | // doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); |
80 | // dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); | 80 | // dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); |
@@ -249,81 +249,81 @@ void getStocks(char *blah) { | |||
249 | layout->addWidget( stocktickerTicker); | 249 | layout->addWidget( stocktickerTicker); |
250 | wasError = true; | 250 | wasError = true; |
251 | } | 251 | } |
252 | 252 | ||
253 | void StockTickerPluginWidget::doStocks() { | 253 | void StockTickerPluginWidget::doStocks() { |
254 | Config cfg( "stockticker"); | 254 | Config cfg( "stockticker"); |
255 | cfg.setGroup( "Symbols" ); | 255 | cfg.setGroup( "Symbols" ); |
256 | symbollist=""; | 256 | symbollist=""; |
257 | symbollist = cfg.readEntry("Symbols", ""); | 257 | symbollist = cfg.readEntry("Symbols", ""); |
258 | symbollist.replace(QRegExp(" "),"+");//seperated by + | 258 | symbollist.replace(QRegExp(" "),"+");//seperated by + |
259 | 259 | ||
260 | cfg.setGroup("Timer"); | 260 | cfg.setGroup("Timer"); |
261 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); | 261 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); |
262 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); | 262 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); |
263 | 263 | ||
264 | if (!symbollist.isEmpty()) { | 264 | if (!symbollist.isEmpty()) { |
265 | pthread_t thread1; | 265 | pthread_t thread1; |
266 | char *blah = ::strdup(symbollist.latin1()); | 266 | char *blah = ::strdup(symbollist.latin1()); |
267 | pthread_create( &thread1, NULL, (void * (*)(void *))getStocks, (void *) blah); | 267 | pthread_create( &thread1, NULL, (void * (*)(void *))getStocks, (void *) blah); |
268 | pthread_detach( thread1); | 268 | pthread_detach( thread1); |
269 | 269 | ||
270 | //::free((void*)thread1); | 270 | //::free((void*)thread1); |
271 | //getStocks(blah); | 271 | //getStocks(blah); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | 275 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { |
276 | killTimer(e->timerId()); | 276 | killTimer(e->timerId()); |
277 | checkConnection(); | 277 | checkConnection(); |
278 | } | 278 | } |
279 | 279 | ||
280 | void StockTickerPluginWidget::checkConnection() { | 280 | void StockTickerPluginWidget::checkConnection() { |
281 | // qDebug("checking connection"); | 281 | // odebug << "checking connection" << oendl; |
282 | // Sock = new QSocket( this ); | 282 | // Sock = new QSocket( this ); |
283 | 283 | ||
284 | // if( wasError) | 284 | // if( wasError) |
285 | // stocktickerTicker->setText("Checking connection"); | 285 | // stocktickerTicker->setText("Checking connection"); |
286 | 286 | ||
287 | // if(Sock->state() == QSocket::Idle) { | 287 | // if(Sock->state() == QSocket::Idle) { |
288 | // Sock->connectToHost("finance.yahoo.com", 80); | 288 | // Sock->connectToHost("finance.yahoo.com", 80); |
289 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); | 289 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); |
290 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | 290 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); |
291 | // } else { | 291 | // } else { |
292 | // qDebug("State is not Idle"); | 292 | // odebug << "State is not Idle" << oendl; |
293 | isConnected(); | 293 | isConnected(); |
294 | // } | 294 | // } |
295 | } | 295 | } |
296 | 296 | ||
297 | void StockTickerPluginWidget::isConnected() { | 297 | void StockTickerPluginWidget::isConnected() { |
298 | // qDebug("We connect, so ok to grab stocks"); | 298 | // odebug << "We connect, so ok to grab stocks" << oendl; |
299 | if(this->isVisible()) | 299 | if(this->isVisible()) |
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 | // odebug << "timer set for " << (timerDelay*60000)/60000 << "" << oendl; |
308 | wasError = false; | 308 | wasError = false; |
309 | 309 | ||
310 | // Sock->close(); | 310 | // Sock->close(); |
311 | } | 311 | } |
312 | 312 | ||
313 | void StockTickerPluginWidget::socketError(int errcode) { | 313 | void 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."); |
323 | break; | 323 | break; |
324 | }; | 324 | }; |
325 | stocktickerTicker->setText( output ); | 325 | stocktickerTicker->setText( output ); |
326 | wasError = true; | 326 | wasError = true; |
327 | // Sock->close(); | 327 | // Sock->close(); |
328 | 328 | ||
329 | } | 329 | } |