summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-01 17:40:40 (UTC)
committer llornkcor <llornkcor>2002-11-01 17:40:40 (UTC)
commit75909e820818cc792e42d9c68fd50d05151b311d (patch) (unidiff)
treec8b9b7e153db85785ad446bd8ae0f7b74a457f77
parent47d6a3119a7b46d25ce35fb2abda9c2bf3fa3f69 (diff)
downloadopie-75909e820818cc792e42d9c68fd50d05151b311d.zip
opie-75909e820818cc792e42d9c68fd50d05151b311d.tar.gz
opie-75909e820818cc792e42d9c68fd50d05151b311d.tar.bz2
another timer fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index cc1bbbb..a7f98be 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -9,108 +9,108 @@
9 * * 9 * *
10 * This program is free software; you can redistribute it and/or modify * 10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by * 11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or * 12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. * 13 * (at your option) any later version. *
14 * * 14 * *
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include <qvaluelist.h> 17#include <qvaluelist.h>
18#include <qtl.h> 18#include <qtl.h>
19#include <qstring.h> 19#include <qstring.h>
20#include <qstringlist.h> 20#include <qstringlist.h>
21#include <qobject.h> 21#include <qobject.h>
22#include <qlayout.h> 22#include <qlayout.h>
23#include <qlineedit.h> 23#include <qlineedit.h>
24#include <qregexp.h> 24#include <qregexp.h>
25#include <qtimer.h> 25#include <qtimer.h>
26 26
27#include <qpe/config.h> 27#include <qpe/config.h>
28#include <qpe/timestring.h> 28#include <qpe/timestring.h>
29#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
30 30
31#include "ticker.h" 31#include "ticker.h"
32 32
33extern "C" { 33extern "C" {
34#include "libstocks/stocks.h" 34#include "libstocks/stocks.h"
35} 35}
36 36
37#include "stocktickerpluginwidget.h" 37#include "stocktickerpluginwidget.h"
38 38
39StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) 39StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name)
40 : QWidget(parent, name ) { 40 : QWidget(parent, name ) {
41 init(); 41 init();
42 startTimer(1000); 42 startTimer(1000);
43} 43}
44 44
45StockTickerPluginWidget::~StockTickerPluginWidget() { 45StockTickerPluginWidget::~StockTickerPluginWidget() {
46} 46}
47 47
48void StockTickerPluginWidget::init() { 48void StockTickerPluginWidget::init() {
49 49
50 QHBoxLayout* layout = new QHBoxLayout( this ); 50 QHBoxLayout* layout = new QHBoxLayout( this );
51 51
52 stocktickerTicker = new Ticker(this); 52 stocktickerTicker = new Ticker(this);
53 stocktickerTicker->setMinimumHeight(15); 53 stocktickerTicker->setMinimumHeight(15);
54 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( doStocks() )); 54 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( doStocks() ));
55 55
56 layout->addWidget( stocktickerTicker); 56 layout->addWidget( stocktickerTicker);
57// Config cfg( "stockticker");
58// cfg.setGroup("Timer");
59// timerDelay= cfg.readNumEntry("Delay",0);
60// if(timerDelay > 0 )
61// startTimer(timerDelay*60000);
62// qDebug("timer ^ set for %d",(timerDelay*60000)/60000);
57 63
58 Config cfg( "stockticker");
59 cfg.setGroup("Timer");
60 timerDelay= cfg.readNumEntry("Delay",0);
61 if(timerDelay > 0)
62 startTimer(timerDelay*60000);
63
64} 64}
65 65
66void StockTickerPluginWidget::doStocks() { 66void StockTickerPluginWidget::doStocks() {
67
68 Config cfg( "stockticker"); 67 Config cfg( "stockticker");
68
69 cfg.setGroup( "Symbols" ); 69 cfg.setGroup( "Symbols" );
70 QString symbollist; 70 QString symbollist;
71 symbollist = cfg.readEntry("Symbols", ""); 71 symbollist = cfg.readEntry("Symbols", "");
72 symbollist.replace(QRegExp(" "),"+");//seperated by + 72 symbollist.replace(QRegExp(" "),"+");//seperated by +
73// qDebug(symbollist); 73// qDebug(symbollist);
74 74
75 getStocks( symbollist.latin1()); 75 getStocks( symbollist.latin1());
76 76
77 stocktickerTicker->setText( output ); 77 stocktickerTicker->setText( output );
78} 78}
79 79
80void StockTickerPluginWidget::getStocks( const char *blah) { 80void StockTickerPluginWidget::getStocks( const char *blah) {
81 81
82 stock *stocks_quotes=NULL; 82 stock *stocks_quotes=NULL;
83 stock *stocks_tmp; 83 stock *stocks_tmp;
84 84
85 QString tempString; 85 QString tempString;
86 output = ""; 86 output = "";
87 87
88 libstocks_return_code error; 88 libstocks_return_code error;
89 89
90 Config cfg( "stockticker"); 90 Config cfg( "stockticker");
91 cfg.setGroup( "Fields" ); 91 cfg.setGroup( "Fields" );
92 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; 92 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
93 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; 93 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
94 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; 94 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
95 95
96 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; 96 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
97 97
98 dotimeCheck=cfg.readBoolEntry("timeCheck",1); 98 dotimeCheck=cfg.readBoolEntry("timeCheck",1);
99 dodateCheck=cfg.readBoolEntry("dateCheck",1); 99 dodateCheck=cfg.readBoolEntry("dateCheck",1);
100 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); 100 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1);
101 donameCheck=cfg.readBoolEntry("nameCheck",1); 101 donameCheck=cfg.readBoolEntry("nameCheck",1);
102 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); 102 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1);
103 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); 103 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1);
104 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); 104 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1);
105 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); 105 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1);
106 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); 106 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1);
107 dovariationCheck=cfg.readBoolEntry("variationCheck",1); 107 dovariationCheck=cfg.readBoolEntry("variationCheck",1);
108 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); 108 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1);
109 109
110 DefProxy(); 110 DefProxy();
111 char *stock_liste = (char *)blah; 111 char *stock_liste = (char *)blah;
112 /* Get the stocks and process errors */ 112 /* Get the stocks and process errors */
113 error = get_stocks( stock_liste, &stocks_quotes); 113 error = get_stocks( stock_liste, &stocks_quotes);
114 114
115 if (error) { 115 if (error) {
116 printf("Error in getting stocks (%d)\n", error); 116 printf("Error in getting stocks (%d)\n", error);
@@ -203,54 +203,58 @@ void StockTickerPluginWidget::getStocks( const char *blah) {
203 if(domaxPriceCheck) 203 if(domaxPriceCheck)
204 output +=tempString; 204 output +=tempString;
205 205
206// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); 206// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage);
207 tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); 207 tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage);
208 if(dovariationCheck) 208 if(dovariationCheck)
209 output +=tempString; 209 output +=tempString;
210 210
211// printf("| Volume | %-9d |\n", stocks_tmp->Volume); 211// printf("| Volume | %-9d |\n", stocks_tmp->Volume);
212 tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); 212 tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume);
213 if(dovolumeCheck) 213 if(dovolumeCheck)
214 output +=tempString; 214 output +=tempString;
215 215
216// printf("----------------------------------------\n\n"); 216// printf("----------------------------------------\n\n");
217 tempString.sprintf("||==++==|"); 217 tempString.sprintf("||==++==|");
218 output +=tempString; 218 output +=tempString;
219 219
220 /* Simple function which help to browse in the stocks list */ 220 /* Simple function which help to browse in the stocks list */
221 stocks_tmp = next_stock(stocks_tmp); 221 stocks_tmp = next_stock(stocks_tmp);
222 } 222 }
223 223
224 /* frees stocks */ 224 /* frees stocks */
225 free_stocks(stocks_quotes); 225 free_stocks(stocks_quotes);
226 226
227} 227}
228 228
229void StockTickerPluginWidget::DefProxy(void) { 229void StockTickerPluginWidget::DefProxy(void) {
230 char *proxy; 230 char *proxy;
231 libstocks_return_code error; 231 libstocks_return_code error;
232 232
233 /* Proxy support */ 233 /* Proxy support */
234 /* Checks for "http_proxy" environment variable */ 234 /* Checks for "http_proxy" environment variable */
235 proxy = getenv("http_proxy"); 235 proxy = getenv("http_proxy");
236 if(proxy) { 236 if(proxy) {
237 /* printf("proxy set\n"); */ 237 /* printf("proxy set\n"); */
238 error = set_proxy(proxy); 238 error = set_proxy(proxy);
239 if (error) { 239 if (error) {
240// printf("Proxy error (%d)\n", error); 240// printf("Proxy error (%d)\n", error);
241 QString tempString; 241 QString tempString;
242 tempString.sprintf("Proxy error (%d)\n", error); 242 tempString.sprintf("Proxy error (%d)\n", error);
243 output = tempString; 243 output = tempString;
244 return; 244 return;
245// exit(1); 245// exit(1);
246 } 246 }
247 } 247 }
248} 248}
249 249
250void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { 250void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
251 qDebug("timer");
252 killTimer(e->timerId()); 251 killTimer(e->timerId());
253 doStocks(); 252 doStocks();
253 Config cfg( "stockticker");
254 cfg.setGroup("Timer");
255 timerDelay= cfg.readNumEntry("Delay",0);
254 if(timerDelay > 0) 256 if(timerDelay > 0)
255 startTimer(timerDelay*60000); 257 startTimer(timerDelay*60000);
258 qDebug("timer set for %d",(timerDelay*60000)/60000);
259
256} 260}