summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index 0d90d0f..5ddf03c 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -15,117 +15,118 @@
15 ***************************************************************************/ 15 ***************************************************************************/
16 16
17#include <qsocket.h> 17#include <qsocket.h>
18#include <qvaluelist.h> 18#include <qvaluelist.h>
19#include <qtl.h> 19#include <qtl.h>
20#include <qstring.h> 20#include <qstring.h>
21#include <qstringlist.h> 21#include <qstringlist.h>
22#include <qobject.h> 22#include <qobject.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28 28
29#include <qpe/config.h> 29#include <qpe/config.h>
30#include <qpe/timestring.h> 30#include <qpe/timestring.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32#include <qpe/network.h> 32#include <qpe/network.h>
33 33
34#include <opie/oticker.h> 34#include <opie/oticker.h>
35 35
36extern "C" { 36extern "C" {
37#include "libstocks/stocks.h" 37#include "libstocks/stocks.h"
38} 38}
39 39
40#include <pthread.h> 40#include <pthread.h>
41 41
42#include "stocktickerpluginwidget.h" 42#include "stocktickerpluginwidget.h"
43 43
44QString output; 44QString output;
45OTicker *stocktickerTicker; 45OTicker *stocktickerTicker;
46 46
47void getStocks( const QString *blah) { 47void getStocks( const char *blah) {
48 48
49// stocktickerTicker->setText( "Downloading stock data."); 49// stocktickerTicker->setText( "Downloading stock data.");
50 stock *stocks_quotes=NULL; 50 stock *stocks_quotes=NULL;
51 stock *stocks_tmp; 51 stock *stocks_tmp;
52 qDebug("%s", blah->latin1()); 52 char *stock_liste = blah;
53 // char *stock_liste = (char *)blah->latin1();
54 qDebug("%s", stock_liste );
53 QString tempString; 55 QString tempString;
54 output = ""; 56 output = "";
55 57
56 libstocks_return_code error; 58 libstocks_return_code error;
57 59
58 Config cfg( "stockticker"); 60 Config cfg( "stockticker");
59 cfg.setGroup( "Fields" ); 61 cfg.setGroup( "Fields" );
60 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; 62 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
61 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; 63 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
62 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; 64 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
63 65
64 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; 66 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
65 67
66 dotimeCheck=cfg.readBoolEntry("timeCheck",1); 68 dotimeCheck=cfg.readBoolEntry("timeCheck",1);
67 dodateCheck=cfg.readBoolEntry("dateCheck",1); 69 dodateCheck=cfg.readBoolEntry("dateCheck",1);
68 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); 70 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1);
69 donameCheck=cfg.readBoolEntry("nameCheck",1); 71 donameCheck=cfg.readBoolEntry("nameCheck",1);
70 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); 72 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1);
71 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); 73 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1);
72 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); 74 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1);
73 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); 75 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1);
74 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); 76 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1);
75 dovariationCheck=cfg.readBoolEntry("variationCheck",1); 77 dovariationCheck=cfg.readBoolEntry("variationCheck",1);
76 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); 78 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1);
77 79
78// DefProxy(); 80// DefProxy();
79 { 81 {
80 char *proxy; 82 char *proxy;
81 libstocks_return_code error; 83 libstocks_return_code error;
82 84
83 /* Proxy support */ 85 /* Proxy support */
84 /* Checks for "http_proxy" environment variable */ 86 /* Checks for "http_proxy" environment variable */
85 proxy = getenv("http_proxy"); 87 proxy = getenv("http_proxy");
86 if(proxy) { 88 if(proxy) {
87 /* printf("proxy set\n"); */ 89 /* printf("proxy set\n"); */
88 error = set_proxy(proxy); 90 error = set_proxy(proxy);
89 if (error) { 91 if (error) {
90 printf("Proxy error (%d)\n", error); 92 printf("Proxy error (%d)\n", error);
91 QString tempString; 93 QString tempString;
92 tempString.sprintf("Proxy error (%d)\n", error); 94 tempString.sprintf("Proxy error (%d)\n", error);
93 output = tempString; 95 output = tempString;
94 return; 96 return;
95// exit(1); 97// exit(1);
96 } 98 }
97 } 99 }
98 } 100 }
99 char *stock_liste = (char *)blah->latin1();
100// char *stock_liste = (char *)blah; 101// char *stock_liste = (char *)blah;
101 /* Get the stocks and process errors */ 102 /* Get the stocks and process errors */
102 error = get_stocks( stock_liste, &stocks_quotes); 103 error = get_stocks( stock_liste, &stocks_quotes);
103 104
104 if (error) { 105 if (error) {
105 printf("Error in getting stocks (%d)\n", error); 106 printf("Error in getting stocks (%d)\n", error);
106 tempString.sprintf("Error in getting stocks (%d)\n", error); 107 tempString.sprintf("Error in getting stocks (%d)\n", error);
107 output =tempString; 108 output =tempString;
108 return; 109 return;
109// exit(1); 110// exit(1);
110 } 111 }
111 112
112 stocks_tmp = stocks_quotes; 113 stocks_tmp = stocks_quotes;
113 114
114 /* Displays the stocks */ 115 /* Displays the stocks */
115 while(stocks_tmp!=0){ 116 while(stocks_tmp!=0){
116 117
117 if (stocks_tmp->Time) { 118 if (stocks_tmp->Time) {
118// printf("%s ", stocks_tmp->Time); 119// printf("%s ", stocks_tmp->Time);
119 tempString.sprintf("| %s ", stocks_tmp->Time); 120 tempString.sprintf("| %s ", stocks_tmp->Time);
120 tempString.replace(QRegExp("\""),""); 121 tempString.replace(QRegExp("\""),"");
121 if( dotimeCheck) 122 if( dotimeCheck)
122 output +=tempString; 123 output +=tempString;
123 } 124 }
124 if (stocks_tmp->Date) { 125 if (stocks_tmp->Date) {
125// printf("%s ", stocks_tmp->Date); 126// printf("%s ", stocks_tmp->Date);
126 tempString.sprintf("| %s ", stocks_tmp->Date); 127 tempString.sprintf("| %s ", stocks_tmp->Date);
127 tempString.replace(QRegExp("\""),""); 128 tempString.replace(QRegExp("\""),"");
128 if(dodateCheck) 129 if(dodateCheck)
129 output +=tempString; 130 output +=tempString;
130 } 131 }
131// printf("\n"); 132// printf("\n");
@@ -222,65 +223,66 @@ StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char*
222 startTimer(1000); 223 startTimer(1000);
223 224
224 stocktickerTicker->setTextFormat(Qt::RichText); 225 stocktickerTicker->setTextFormat(Qt::RichText);
225// checkConnection(); 226// checkConnection();
226} 227}
227 228
228StockTickerPluginWidget::~StockTickerPluginWidget() { 229StockTickerPluginWidget::~StockTickerPluginWidget() {
229} 230}
230 231
231void StockTickerPluginWidget::init() { 232void StockTickerPluginWidget::init() {
232 233
233 QHBoxLayout* layout = new QHBoxLayout( this ); 234 QHBoxLayout* layout = new QHBoxLayout( this );
234 stocktickerTicker = new OTicker(this); 235 stocktickerTicker = new OTicker(this);
235// stocktickerTicker->setMinimumHeight(15); 236// stocktickerTicker->setMinimumHeight(15);
236 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); 237 connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() ));
237 layout->addWidget( stocktickerTicker); 238 layout->addWidget( stocktickerTicker);
238 wasError = true; 239 wasError = true;
239} 240}
240 241
241void StockTickerPluginWidget::doStocks() { 242void StockTickerPluginWidget::doStocks() {
242 Config cfg( "stockticker"); 243 Config cfg( "stockticker");
243 cfg.setGroup( "Symbols" ); 244 cfg.setGroup( "Symbols" );
244 symbollist=""; 245 symbollist="";
245 symbollist = cfg.readEntry("Symbols", ""); 246 symbollist = cfg.readEntry("Symbols", "");
246 symbollist.replace(QRegExp(" "),"+");//seperated by + 247 symbollist.replace(QRegExp(" "),"+");//seperated by +
247 248
248 cfg.setGroup("Timer"); 249 cfg.setGroup("Timer");
249 stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); 250 stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50));
250 stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); 251 stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10));
251 252
252 if (!symbollist.isEmpty()) { 253 if (!symbollist.isEmpty()) {
253 pthread_t thread1; 254 pthread_t thread1;
254 pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist); 255 char *blah = symbollist.latin1();
256 pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, blah);
255 } 257 }
256} 258}
257 259
258void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { 260void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
259 killTimer(e->timerId()); 261 killTimer(e->timerId());
260 checkConnection(); 262 checkConnection();
261} 263}
262 264
263void StockTickerPluginWidget::checkConnection() { 265void StockTickerPluginWidget::checkConnection() {
264// qDebug("checking connection"); 266// qDebug("checking connection");
265// Sock = new QSocket( this ); 267// Sock = new QSocket( this );
266 268
267// if( wasError) 269// if( wasError)
268// stocktickerTicker->setText("Checking connection"); 270// stocktickerTicker->setText("Checking connection");
269 271
270// if(Sock->state() == QSocket::Idle) { 272// if(Sock->state() == QSocket::Idle) {
271// Sock->connectToHost("finance.yahoo.com", 80); 273// Sock->connectToHost("finance.yahoo.com", 80);
272// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); 274// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) );
273// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); 275// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) );
274// } else { 276// } else {
275// qDebug("State is not Idle"); 277// qDebug("State is not Idle");
276 isConnected(); 278 isConnected();
277// } 279// }
278} 280}
279 281
280void StockTickerPluginWidget::isConnected() { 282void StockTickerPluginWidget::isConnected() {
281// qDebug("We connect, so ok to grab stocks"); 283// qDebug("We connect, so ok to grab stocks");
282 doStocks(); 284 doStocks();
283 285
284 Config cfg( "stockticker"); 286 Config cfg( "stockticker");
285 cfg.setGroup("Timer"); 287 cfg.setGroup("Timer");
286 timerDelay= cfg.readNumEntry("Delay",0); 288 timerDelay= cfg.readNumEntry("Delay",0);