summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-01 16:47:02 (UTC)
committer llornkcor <llornkcor>2002-11-01 16:47:02 (UTC)
commit9e5589036e37a54a70243617f38741b6c709aff1 (patch) (unidiff)
tree42fc8f6dd6c7bafb7ed2ed5ef97e67c763cf0845
parent535713ea42d091361f0ac3b14b3f44f3899a7102 (diff)
downloadopie-9e5589036e37a54a70243617f38741b6c709aff1.zip
opie-9e5589036e37a54a70243617f38741b6c709aff1.tar.gz
opie-9e5589036e37a54a70243617f38741b6c709aff1.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index 6d53a91..aabb4d2 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -1,246 +1,246 @@
1/* 1/*
2 * stocktickerpluginwidget.cpp 2 * stocktickerpluginwidget.cpp
3 * 3 *
4 * copyright : (c) 2002 by L.J. Potter 4 * copyright : (c) 2002 by L.J. Potter
5 * email : llornkcor@handhelds.org 5 * email : llornkcor@handhelds.org
6 * 6 *
7 */ 7 */
8/*************************************************************************** 8/***************************************************************************
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} 57}
58 58
59void StockTickerPluginWidget::doStocks() { 59void StockTickerPluginWidget::doStocks() {
60 60
61 Config cfg( "stockticker"); 61 Config cfg( "stockticker");
62 cfg.setGroup( "Symbols" ); 62 cfg.setGroup( "Symbols" );
63 QString symbollist; 63 QString symbollist;
64 symbollist = cfg.readEntry("Symbols", ""); 64 symbollist = cfg.readEntry("Symbols", "");
65 symbollist.replace(QRegExp(" "),"+");//seperated by + 65 symbollist.replace(QRegExp(" "),"+");//seperated by +
66// qDebug(symbollist); 66// qDebug(symbollist);
67 67
68 getStocks( symbollist.latin1()); 68 getStocks( symbollist.latin1());
69 69
70 stocktickerTicker->setText( output ); 70 stocktickerTicker->setText( output );
71} 71}
72 72
73void StockTickerPluginWidget::getStocks( const char *blah) { 73void StockTickerPluginWidget::getStocks( const char *blah) {
74 74
75 stock *stocks_quotes=NULL; 75 stock *stocks_quotes=NULL;
76 stock *stocks_tmp; 76 stock *stocks_tmp;
77 77
78 QString tempString; 78 QString tempString;
79 output = ""; 79 output = "";
80 80
81 libstocks_return_code error; 81 libstocks_return_code error;
82 82
83 Config cfg( "stockticker"); 83 Config cfg( "stockticker");
84 cfg.setGroup( "Fields" ); 84 cfg.setGroup( "Fields" );
85 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; 85 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
86 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; 86 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
87 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; 87 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
88 88
89 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; 89 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
90 90
91 dotimeCheck=cfg.readBoolEntry("timeCheck",1); 91 dotimeCheck=cfg.readBoolEntry("timeCheck",1);
92 dodateCheck=cfg.readBoolEntry("dateCheck",1); 92 dodateCheck=cfg.readBoolEntry("dateCheck",1);
93 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); 93 dosymbolCheck=cfg.readBoolEntry("symbolCheck",1);
94 donameCheck=cfg.readBoolEntry("nameCheck",1); 94 donameCheck=cfg.readBoolEntry("nameCheck",1);
95 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); 95 docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1);
96 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); 96 dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1);
97 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); 97 doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1);
98 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); 98 dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1);
99 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); 99 domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1);
100 dovariationCheck=cfg.readBoolEntry("variationCheck",1); 100 dovariationCheck=cfg.readBoolEntry("variationCheck",1);
101 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); 101 dovolumeCheck=cfg.readBoolEntry("volumeCheck",1);
102 102
103 DefProxy(); 103 DefProxy();
104 char *stock_liste = (char *)blah; 104 char *stock_liste = (char *)blah;
105 /* Get the stocks and process errors */ 105 /* Get the stocks and process errors */
106 error = get_stocks( stock_liste, &stocks_quotes); 106 error = get_stocks( stock_liste, &stocks_quotes);
107 107
108 if (error) { 108 if (error) {
109 printf("Error in getting stocks (%d)\n", error); 109 printf("Error in getting stocks (%d)\n", error);
110 tempString.sprintf("Error in getting stocks (%d)\n", error); 110 tempString.sprintf("Error in getting stocks (%d)\n", error);
111 output =tempString; 111 output =tempString;
112 return; 112 return;
113// exit(1); 113// exit(1);
114 } 114 }
115 115
116 stocks_tmp = stocks_quotes; 116 stocks_tmp = stocks_quotes;
117 117
118 /* Displays the stocks */ 118 /* Displays the stocks */
119 while(stocks_tmp!=0){ 119 while(stocks_tmp!=0){
120 120
121 if (stocks_tmp->Time) { 121 if (stocks_tmp->Time) {
122// printf("%s ", stocks_tmp->Time); 122// printf("%s ", stocks_tmp->Time);
123 tempString.sprintf("|| %s ", stocks_tmp->Time); 123 tempString.sprintf("|| %s ", stocks_tmp->Time);
124 tempString.replace(QRegExp("\""),""); 124 tempString.replace(QRegExp("\""),"");
125 if( dotimeCheck) 125 if( dotimeCheck)
126 output +=tempString; 126 output +=tempString;
127 } 127 }
128 if (stocks_tmp->Date) { 128 if (stocks_tmp->Date) {
129// printf("%s ", stocks_tmp->Date); 129// printf("%s ", stocks_tmp->Date);
130 tempString.sprintf("| %s ", stocks_tmp->Date); 130 tempString.sprintf("| %s ", stocks_tmp->Date);
131 tempString.replace(QRegExp("\""),""); 131 tempString.replace(QRegExp("\""),"");
132 if(dodateCheck) 132 if(dodateCheck)
133 output +=tempString; 133 output +=tempString;
134 } 134 }
135// printf("\n"); 135// printf("\n");
136 136
137// printf("----------------------------------------\n"); 137// printf("----------------------------------------\n");
138 138
139 if ( strlen(stocks_tmp->Symbol) > 20 ) { 139 if ( strlen(stocks_tmp->Symbol) > 20 ) {
140// printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); 140// printf("| Symbol | %.20s |\n",stocks_tmp->Symbol);
141 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); 141 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
142 if(dosymbolCheck) 142 if(dosymbolCheck)
143 output +=tempString; 143 output +=tempString;
144 } 144 }
145 else { 145 else {
146// printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); 146// printf("| Symbol | %-20s |\n",stocks_tmp->Symbol);
147 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); 147 tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol);
148 if(dosymbolCheck) 148 if(dosymbolCheck)
149 output +=tempString; 149 output +=tempString;
150 } 150 }
151 151
152 if (stocks_tmp->Name) { 152 if (stocks_tmp->Name) {
153 if ( strlen(stocks_tmp->Name) > 20 ) { 153 if ( strlen(stocks_tmp->Name) > 20 ) {
154// printf("| Name %.20s |\n",stocks_tmp->Name); 154// printf("| Name %.20s |\n",stocks_tmp->Name);
155 tempString.sprintf("| Name %s ",stocks_tmp->Name); 155 tempString.sprintf("| Name %s ",stocks_tmp->Name);
156 tempString.stripWhiteSpace(); 156 tempString.stripWhiteSpace();
157 if(donameCheck) 157 if(donameCheck)
158 output +=tempString; 158 output +=tempString;
159 } else { 159 } else {
160// printf("| Name | %-20s |\n",stocks_tmp->Name); 160// printf("| Name | %-20s |\n",stocks_tmp->Name);
161 tempString.sprintf("| Name %s ",stocks_tmp->Name); 161 tempString.sprintf("| Name %s ",stocks_tmp->Name);
162 tempString.stripWhiteSpace(); 162 tempString.stripWhiteSpace();
163 if(donameCheck) 163 if(donameCheck)
164 output +=tempString; 164 output +=tempString;
165 } 165 }
166 } 166 }
167 else { 167 else {
168// printf("| Name | |\n"); 168// printf("| Name | |\n");
169 tempString.sprintf("| Name | |"); 169 tempString.sprintf("| Name | |");
170 if(donameCheck) 170 if(donameCheck)
171 output +=tempString; 171 output +=tempString;
172 } 172 }
173 173
174// printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); 174// printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice);
175 tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); 175 tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice);
176 if(docurrentPriceCheck) 176 if(docurrentPriceCheck)
177 output +=tempString; 177 output +=tempString;
178 178
179// printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); 179// printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice);
180 tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); 180 tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice);
181 if(dolastPriceCheck) 181 if(dolastPriceCheck)
182 output +=tempString; 182 output +=tempString;
183 183
184// printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); 184// printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice);
185 tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); 185 tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice);
186 if(doopenPriceCheck) 186 if(doopenPriceCheck)
187 output +=tempString; 187 output +=tempString;
188 188
189// printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); 189// printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice);
190 tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); 190 tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice);
191 if(dominPriceCheck) 191 if(dominPriceCheck)
192 output +=tempString; 192 output +=tempString;
193 193
194// printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); 194// printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice);
195 tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); 195 tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice);
196 if(domaxPriceCheck) 196 if(domaxPriceCheck)
197 output +=tempString; 197 output +=tempString;
198 198
199// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); 199// printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage);
200 tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); 200 tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage);
201 if(dovariationCheck) 201 if(dovariationCheck)
202 output +=tempString; 202 output +=tempString;
203 203
204// printf("| Volume | %-9d |\n", stocks_tmp->Volume); 204// printf("| Volume | %-9d |\n", stocks_tmp->Volume);
205 tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); 205 tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume);
206 if(dovolumeCheck) 206 if(dovolumeCheck)
207 output +=tempString; 207 output +=tempString;
208 208
209// printf("----------------------------------------\n\n"); 209// printf("----------------------------------------\n\n");
210 tempString.sprintf("||==++=="); 210 tempString.sprintf("||==++==|");
211 output +=tempString; 211 output +=tempString;
212 212
213 /* Simple function which help to browse in the stocks list */ 213 /* Simple function which help to browse in the stocks list */
214 stocks_tmp = next_stock(stocks_tmp); 214 stocks_tmp = next_stock(stocks_tmp);
215 } 215 }
216 216
217 /* frees stocks */ 217 /* frees stocks */
218 free_stocks(stocks_quotes); 218 free_stocks(stocks_quotes);
219 219
220} 220}
221 221
222void StockTickerPluginWidget::DefProxy(void) { 222void StockTickerPluginWidget::DefProxy(void) {
223 char *proxy; 223 char *proxy;
224 libstocks_return_code error; 224 libstocks_return_code error;
225 225
226 /* Proxy support */ 226 /* Proxy support */
227 /* Checks for "http_proxy" environment variable */ 227 /* Checks for "http_proxy" environment variable */
228 proxy = getenv("http_proxy"); 228 proxy = getenv("http_proxy");
229 if(proxy) { 229 if(proxy) {
230 /* printf("proxy set\n"); */ 230 /* printf("proxy set\n"); */
231 error = set_proxy(proxy); 231 error = set_proxy(proxy);
232 if (error) { 232 if (error) {
233// printf("Proxy error (%d)\n", error); 233// printf("Proxy error (%d)\n", error);
234 QString tempString; 234 QString tempString;
235 tempString.sprintf("Proxy error (%d)\n", error); 235 tempString.sprintf("Proxy error (%d)\n", error);
236 output = tempString; 236 output = tempString;
237 return; 237 return;
238// exit(1); 238// exit(1);
239 } 239 }
240 } 240 }
241} 241}
242 242
243void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { 243void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
244 killTimer(e->timerId()); 244 killTimer(e->timerId());
245 doStocks(); 245 doStocks();
246} 246}