author | llornkcor <llornkcor> | 2002-11-05 13:32:56 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-05 13:32:56 (UTC) |
commit | 320c8020a112dff1bc1d43bee9b103a423e0ac35 (patch) (unidiff) | |
tree | 1de3fdcdfe26c9555d4356a18702f274a1217422 | |
parent | 0750e839e1d10069dbde7e669a345800f0ec088f (diff) | |
download | opie-320c8020a112dff1bc1d43bee9b103a423e0ac35.zip opie-320c8020a112dff1bc1d43bee9b103a423e0ac35.tar.gz opie-320c8020a112dff1bc1d43bee9b103a423e0ac35.tar.bz2 |
dont trust Qt to initialize QStrings correctly always
-rw-r--r-- | noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | 3 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h | 1 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp index 45c5c53..2f35f7f 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | |||
@@ -178,130 +178,129 @@ void getStocks( const QString *blah) { | |||
178 | output +=tempString; | 178 | output +=tempString; |
179 | 179 | ||
180 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); | 180 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); |
181 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); | 181 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); |
182 | if(doopenPriceCheck) | 182 | if(doopenPriceCheck) |
183 | output +=tempString; | 183 | output +=tempString; |
184 | 184 | ||
185 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); | 185 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); |
186 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); | 186 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); |
187 | if(dominPriceCheck) | 187 | if(dominPriceCheck) |
188 | output +=tempString; | 188 | output +=tempString; |
189 | 189 | ||
190 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); | 190 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); |
191 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); | 191 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); |
192 | if(domaxPriceCheck) | 192 | if(domaxPriceCheck) |
193 | output +=tempString; | 193 | output +=tempString; |
194 | 194 | ||
195 | // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); | 195 | // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); |
196 | tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); | 196 | tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); |
197 | if(dovariationCheck) | 197 | if(dovariationCheck) |
198 | output +=tempString; | 198 | output +=tempString; |
199 | 199 | ||
200 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); | 200 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); |
201 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); | 201 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); |
202 | if(dovolumeCheck) | 202 | if(dovolumeCheck) |
203 | output +=tempString; | 203 | output +=tempString; |
204 | 204 | ||
205 | // printf("----------------------------------------\n\n"); | 205 | // printf("----------------------------------------\n\n"); |
206 | tempString.sprintf("||==++==|"); | 206 | tempString.sprintf("||==++==|"); |
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 | ||
219 | StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) | 219 | StockTickerPluginWidget::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 | ||
226 | StockTickerPluginWidget::~StockTickerPluginWidget() { | 226 | StockTickerPluginWidget::~StockTickerPluginWidget() { |
227 | } | 227 | } |
228 | 228 | ||
229 | void StockTickerPluginWidget::init() { | 229 | void 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 | ||
239 | void StockTickerPluginWidget::doStocks() { | 239 | void StockTickerPluginWidget::doStocks() { |
240 | Config cfg( "stockticker"); | 240 | Config cfg( "stockticker"); |
241 | cfg.setGroup( "Symbols" ); | 241 | cfg.setGroup( "Symbols" ); |
242 | QString symbollist; | 242 | symbollist=""; |
243 | symbollist = cfg.readEntry("Symbols", ""); | ||
244 | symbollist = cfg.readEntry("Symbols", ""); | 243 | symbollist = cfg.readEntry("Symbols", ""); |
245 | symbollist.replace(QRegExp(" "),"+");//seperated by + | 244 | symbollist.replace(QRegExp(" "),"+");//seperated by + |
246 | 245 | ||
247 | // qDebug(symbollist); | 246 | // qDebug(symbollist); |
248 | if (!symbollist.isEmpty()) { | 247 | if (!symbollist.isEmpty()) { |
249 | pthread_t thread1; | 248 | pthread_t thread1; |
250 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist); | 249 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist); |
251 | } | 250 | } |
252 | // pthread_join(thread1,NULL); | 251 | // pthread_join(thread1,NULL); |
253 | // getStocks( symbollist.latin1() ); | 252 | // getStocks( symbollist.latin1() ); |
254 | } | 253 | } |
255 | 254 | ||
256 | //void StockTickerPluginWidget::DefProxy(void) { | 255 | //void StockTickerPluginWidget::DefProxy(void) { |
257 | // char *proxy; | 256 | // char *proxy; |
258 | // libstocks_return_code error; | 257 | // libstocks_return_code error; |
259 | 258 | ||
260 | // /* Proxy support */ | 259 | // /* Proxy support */ |
261 | // /* Checks for "http_proxy" environment variable */ | 260 | // /* Checks for "http_proxy" environment variable */ |
262 | // proxy = getenv("http_proxy"); | 261 | // proxy = getenv("http_proxy"); |
263 | // if(proxy) { | 262 | // if(proxy) { |
264 | // /* printf("proxy set\n"); */ | 263 | // /* printf("proxy set\n"); */ |
265 | // error = set_proxy(proxy); | 264 | // error = set_proxy(proxy); |
266 | // if (error) { | 265 | // if (error) { |
267 | // // printf("Proxy error (%d)\n", error); | 266 | // // printf("Proxy error (%d)\n", error); |
268 | // QString tempString; | 267 | // QString tempString; |
269 | // tempString.sprintf("Proxy error (%d)\n", error); | 268 | // tempString.sprintf("Proxy error (%d)\n", error); |
270 | // output = tempString; | 269 | // output = tempString; |
271 | // return; | 270 | // return; |
272 | // // exit(1); | 271 | // // exit(1); |
273 | // } | 272 | // } |
274 | // } | 273 | // } |
275 | //} | 274 | //} |
276 | 275 | ||
277 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | 276 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { |
278 | killTimer(e->timerId()); | 277 | killTimer(e->timerId()); |
279 | checkConnection(); | 278 | checkConnection(); |
280 | } | 279 | } |
281 | 280 | ||
282 | void StockTickerPluginWidget::checkConnection() { | 281 | void StockTickerPluginWidget::checkConnection() { |
283 | // qDebug("checking connection"); | 282 | // qDebug("checking connection"); |
284 | // Sock = new QSocket( this ); | 283 | // Sock = new QSocket( this ); |
285 | 284 | ||
286 | // if( wasError) | 285 | // if( wasError) |
287 | // stocktickerTicker->setText("Checking connection"); | 286 | // stocktickerTicker->setText("Checking connection"); |
288 | 287 | ||
289 | // if(Sock->state() == QSocket::Idle) { | 288 | // if(Sock->state() == QSocket::Idle) { |
290 | // Sock->connectToHost("finance.yahoo.com", 80); | 289 | // Sock->connectToHost("finance.yahoo.com", 80); |
291 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); | 290 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); |
292 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | 291 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); |
293 | // } else { | 292 | // } else { |
294 | // qDebug("State is not Idle"); | 293 | // qDebug("State is not Idle"); |
295 | isConnected(); | 294 | isConnected(); |
296 | // } | 295 | // } |
297 | } | 296 | } |
298 | 297 | ||
299 | void StockTickerPluginWidget::isConnected() { | 298 | void StockTickerPluginWidget::isConnected() { |
300 | // qDebug("We connect, so ok to grab stocks"); | 299 | // qDebug("We connect, so ok to grab stocks"); |
301 | doStocks(); | 300 | doStocks(); |
302 | 301 | ||
303 | Config cfg( "stockticker"); | 302 | Config cfg( "stockticker"); |
304 | cfg.setGroup("Timer"); | 303 | cfg.setGroup("Timer"); |
305 | timerDelay= cfg.readNumEntry("Delay",0); | 304 | timerDelay= cfg.readNumEntry("Delay",0); |
306 | if(timerDelay > 0) | 305 | if(timerDelay > 0) |
307 | startTimer(timerDelay*60000); | 306 | startTimer(timerDelay*60000); |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h index 970a561..8776bff 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h | |||
@@ -1,61 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * stocktickerpluginwidget.h | 2 | * stocktickerpluginwidget.h |
3 | * | 3 | * |
4 | * copyright : (c) 2002 by L.J. Potter | 4 | * copyright : (c) 2002 by L.J. Potter |
5 | * email : lornkcor@handhelds.org | 5 | * email : lornkcor@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 | 17 | ||
18 | #ifndef STOCKTICKERL_PLUGIN_WIDGET_H | 18 | #ifndef STOCKTICKERL_PLUGIN_WIDGET_H |
19 | #define STOCKTICKERL_PLUGIN_WIDGET_H | 19 | #define STOCKTICKERL_PLUGIN_WIDGET_H |
20 | 20 | ||
21 | #include <qsocket.h> | 21 | #include <qsocket.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
25 | 25 | ||
26 | #include <opie/tododb.h> | 26 | #include <opie/tododb.h> |
27 | #include <opie/oclickablelabel.h> | 27 | #include <opie/oclickablelabel.h> |
28 | #include <opie/oticker.h> | 28 | #include <opie/oticker.h> |
29 | 29 | ||
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <sys/uio.h> | 31 | #include <sys/uio.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <stdio.h> | 33 | #include <stdio.h> |
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <string.h> | 35 | #include <string.h> |
36 | 36 | ||
37 | class QTimer; | 37 | class QTimer; |
38 | 38 | ||
39 | class StockTickerPluginWidget : public QWidget { | 39 | class StockTickerPluginWidget : public QWidget { |
40 | 40 | ||
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | 42 | ||
43 | public: | 43 | public: |
44 | StockTickerPluginWidget( QWidget *parent, const char *name ); | 44 | StockTickerPluginWidget( QWidget *parent, const char *name ); |
45 | ~StockTickerPluginWidget(); | 45 | ~StockTickerPluginWidget(); |
46 | 46 | ||
47 | protected slots: | 47 | protected slots: |
48 | void doStocks(); | 48 | void doStocks(); |
49 | void isConnected(); | 49 | void isConnected(); |
50 | void socketError(int); | 50 | void socketError(int); |
51 | void checkConnection(); | 51 | void checkConnection(); |
52 | private: | 52 | private: |
53 | QString symbollist; | ||
53 | bool wasError; | 54 | bool wasError; |
54 | QSocket *Sock; | 55 | QSocket *Sock; |
55 | void timerEvent( QTimerEvent * ); | 56 | void timerEvent( QTimerEvent * ); |
56 | void init(); | 57 | void init(); |
57 | // void DefProxy(void); | 58 | // void DefProxy(void); |
58 | int timerDelay; | 59 | int timerDelay; |
59 | }; | 60 | }; |
60 | 61 | ||
61 | #endif | 62 | #endif |