4 files changed, 6 insertions, 6 deletions
diff --git a/noncore/todayplugins/stockticker/opie-today-stocktickerplugin.control b/noncore/todayplugins/stockticker/opie-today-stocktickerplugin.control index ddfe9b0..128b7cd 100644 --- a/noncore/todayplugins/stockticker/opie-today-stocktickerplugin.control +++ b/noncore/todayplugins/stockticker/opie-today-stocktickerplugin.control | |||
@@ -1,8 +1,8 @@ | |||
1 | Files: plugins/today/libtodaystocktickerplugin.so* bin/stockticker | 1 | Files: plugins/today/libtodaystocktickerplugin.so* bin/stockticker pics/stockticker/stockticker.png |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: ljp <llornkcor@handhelds.org> | 4 | Maintainer: ljp <llornkcor@handhelds.org> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: qt-embedded (>=$QTE_VERSION), opie-today | 7 | Depends: qt-embedded (>=$QTE_VERSION), opie-today |
8 | Description: stockticker plugin for today | 8 | Description: stockticker plugin for today |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp index 2eb1697..628431c 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerplugin.cpp | |||
@@ -1,60 +1,60 @@ | |||
1 | /* | 1 | /* |
2 | * stocktickerplugin.cpp | 2 | * stocktickerplugin.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 | 17 | ||
18 | #include "stocktickerplugin.h" | 18 | #include "stocktickerplugin.h" |
19 | #include "stocktickerpluginwidget.h" | 19 | #include "stocktickerpluginwidget.h" |
20 | #include "stocktickerconfig.h" | 20 | #include "stocktickerconfig.h" |
21 | 21 | ||
22 | StockTickerPlugin::StockTickerPlugin() { | 22 | StockTickerPlugin::StockTickerPlugin() { |
23 | } | 23 | } |
24 | 24 | ||
25 | StockTickerPlugin::~StockTickerPlugin() { | 25 | StockTickerPlugin::~StockTickerPlugin() { |
26 | } | 26 | } |
27 | 27 | ||
28 | QString StockTickerPlugin::pluginName() const { | 28 | QString StockTickerPlugin::pluginName() const { |
29 | return QObject::tr( "StockTicker plugin" ); | 29 | return QObject::tr( "StockTicker plugin" ); |
30 | } | 30 | } |
31 | 31 | ||
32 | double StockTickerPlugin::versionNumber() const { | 32 | double StockTickerPlugin::versionNumber() const { |
33 | return 0.6; | 33 | return 0.6; |
34 | } | 34 | } |
35 | 35 | ||
36 | QString StockTickerPlugin::pixmapNameWidget() const { | 36 | QString StockTickerPlugin::pixmapNameWidget() const { |
37 | return "pass"; | 37 | return "stockticker/stockticker"; |
38 | } | 38 | } |
39 | 39 | ||
40 | QWidget* StockTickerPlugin::widget( QWidget * wid ) { | 40 | QWidget* StockTickerPlugin::widget( QWidget * wid ) { |
41 | return new StockTickerPluginWidget( wid, "StockTicker " ); | 41 | return new StockTickerPluginWidget( wid, "StockTicker " ); |
42 | } | 42 | } |
43 | 43 | ||
44 | QString StockTickerPlugin::pixmapNameConfig() const { | 44 | QString StockTickerPlugin::pixmapNameConfig() const { |
45 | return 0l; | 45 | return "stockticker/stockticker"; |
46 | } | 46 | } |
47 | 47 | ||
48 | TodayConfigWidget* StockTickerPlugin::configWidget( QWidget* wid ) { | 48 | TodayConfigWidget* StockTickerPlugin::configWidget( QWidget* wid ) { |
49 | return new StocktickerPluginConfig( wid , "Stockticker" ); | 49 | return new StocktickerPluginConfig( wid , "Stockticker" ); |
50 | } | 50 | } |
51 | 51 | ||
52 | QString StockTickerPlugin::appName() const { | 52 | QString StockTickerPlugin::appName() const { |
53 | return "stockticker"; | 53 | return "stockticker"; |
54 | } | 54 | } |
55 | 55 | ||
56 | bool StockTickerPlugin::excludeFromRefresh() const { | 56 | bool StockTickerPlugin::excludeFromRefresh() const { |
57 | 57 | ||
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | 60 | ||
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp index 572a720..1d53344 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | |||
@@ -1,329 +1,329 @@ | |||
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 <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 | ||
36 | extern "C" { | 36 | extern "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 | ||
44 | QString output; | 44 | QString output; |
45 | OTicker *stocktickerTicker; | 45 | OTicker *stocktickerTicker; |
46 | 46 | ||
47 | void getStocks( const QString *blah) { | 47 | void getStocks( const QString *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 | qDebug("%s", blah->latin1()); |
53 | QString tempString; | 53 | QString tempString; |
54 | output = ""; | 54 | output = ""; |
55 | 55 | ||
56 | libstocks_return_code error; | 56 | libstocks_return_code error; |
57 | 57 | ||
58 | Config cfg( "stockticker"); | 58 | Config cfg( "stockticker"); |
59 | cfg.setGroup( "Fields" ); | 59 | cfg.setGroup( "Fields" ); |
60 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | 60 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; |
61 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | 61 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; |
62 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | 62 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; |
63 | 63 | ||
64 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; | 64 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; |
65 | 65 | ||
66 | dotimeCheck=cfg.readBoolEntry("timeCheck",1); | 66 | dotimeCheck=cfg.readBoolEntry("timeCheck",1); |
67 | dodateCheck=cfg.readBoolEntry("dateCheck",1); | 67 | dodateCheck=cfg.readBoolEntry("dateCheck",1); |
68 | dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); | 68 | dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); |
69 | donameCheck=cfg.readBoolEntry("nameCheck",1); | 69 | donameCheck=cfg.readBoolEntry("nameCheck",1); |
70 | docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); | 70 | docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); |
71 | dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); | 71 | dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); |
72 | doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); | 72 | doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); |
73 | dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); | 73 | dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); |
74 | domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); | 74 | domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); |
75 | dovariationCheck=cfg.readBoolEntry("variationCheck",1); | 75 | dovariationCheck=cfg.readBoolEntry("variationCheck",1); |
76 | dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); | 76 | dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); |
77 | 77 | ||
78 | // DefProxy(); | 78 | // DefProxy(); |
79 | { | 79 | { |
80 | char *proxy; | 80 | char *proxy; |
81 | libstocks_return_code error; | 81 | libstocks_return_code error; |
82 | 82 | ||
83 | /* Proxy support */ | 83 | /* Proxy support */ |
84 | /* Checks for "http_proxy" environment variable */ | 84 | /* Checks for "http_proxy" environment variable */ |
85 | proxy = getenv("http_proxy"); | 85 | proxy = getenv("http_proxy"); |
86 | if(proxy) { | 86 | if(proxy) { |
87 | /* printf("proxy set\n"); */ | 87 | /* printf("proxy set\n"); */ |
88 | error = set_proxy(proxy); | 88 | error = set_proxy(proxy); |
89 | if (error) { | 89 | if (error) { |
90 | printf("Proxy error (%d)\n", error); | 90 | printf("Proxy error (%d)\n", error); |
91 | QString tempString; | 91 | QString tempString; |
92 | tempString.sprintf("Proxy error (%d)\n", error); | 92 | tempString.sprintf("Proxy error (%d)\n", error); |
93 | output = tempString; | 93 | output = tempString; |
94 | return; | 94 | return; |
95 | // exit(1); | 95 | // exit(1); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | } | 98 | } |
99 | char *stock_liste = (char *)blah->latin1(); | 99 | char *stock_liste = (char *)blah->latin1(); |
100 | // char *stock_liste = (char *)blah; | 100 | // char *stock_liste = (char *)blah; |
101 | /* Get the stocks and process errors */ | 101 | /* Get the stocks and process errors */ |
102 | error = get_stocks( stock_liste, &stocks_quotes); | 102 | error = get_stocks( stock_liste, &stocks_quotes); |
103 | 103 | ||
104 | if (error) { | 104 | if (error) { |
105 | printf("Error in getting stocks (%d)\n", error); | 105 | printf("Error in getting stocks (%d)\n", error); |
106 | tempString.sprintf("Error in getting stocks (%d)\n", error); | 106 | tempString.sprintf("Error in getting stocks (%d)\n", error); |
107 | output =tempString; | 107 | output =tempString; |
108 | return; | 108 | return; |
109 | // exit(1); | 109 | // exit(1); |
110 | } | 110 | } |
111 | 111 | ||
112 | stocks_tmp = stocks_quotes; | 112 | stocks_tmp = stocks_quotes; |
113 | 113 | ||
114 | /* Displays the stocks */ | 114 | /* Displays the stocks */ |
115 | while(stocks_tmp!=0){ | 115 | while(stocks_tmp!=0){ |
116 | 116 | ||
117 | if (stocks_tmp->Time) { | 117 | if (stocks_tmp->Time) { |
118 | // printf("%s ", stocks_tmp->Time); | 118 | // printf("%s ", stocks_tmp->Time); |
119 | tempString.sprintf("| %s ", stocks_tmp->Time); | 119 | tempString.sprintf("| %s ", stocks_tmp->Time); |
120 | tempString.replace(QRegExp("\""),""); | 120 | tempString.replace(QRegExp("\""),""); |
121 | if( dotimeCheck) | 121 | if( dotimeCheck) |
122 | output +=tempString; | 122 | output +=tempString; |
123 | } | 123 | } |
124 | if (stocks_tmp->Date) { | 124 | if (stocks_tmp->Date) { |
125 | // printf("%s ", stocks_tmp->Date); | 125 | // printf("%s ", stocks_tmp->Date); |
126 | tempString.sprintf("| %s ", stocks_tmp->Date); | 126 | tempString.sprintf("| %s ", stocks_tmp->Date); |
127 | tempString.replace(QRegExp("\""),""); | 127 | tempString.replace(QRegExp("\""),""); |
128 | if(dodateCheck) | 128 | if(dodateCheck) |
129 | output +=tempString; | 129 | output +=tempString; |
130 | } | 130 | } |
131 | // printf("\n"); | 131 | // printf("\n"); |
132 | 132 | ||
133 | // printf("----------------------------------------\n"); | 133 | // printf("----------------------------------------\n"); |
134 | 134 | ||
135 | if ( strlen(stocks_tmp->Symbol) > 20 ) { | 135 | if ( strlen(stocks_tmp->Symbol) > 20 ) { |
136 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); | 136 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); |
137 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 137 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
138 | if(dosymbolCheck) | 138 | if(dosymbolCheck) |
139 | output +=tempString; | 139 | output +=tempString; |
140 | } | 140 | } |
141 | else { | 141 | else { |
142 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); | 142 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); |
143 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 143 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
144 | if(dosymbolCheck) | 144 | if(dosymbolCheck) |
145 | output +=tempString; | 145 | output +=tempString; |
146 | } | 146 | } |
147 | 147 | ||
148 | if (stocks_tmp->Name) { | 148 | if (stocks_tmp->Name) { |
149 | if ( strlen(stocks_tmp->Name) > 20 ) { | 149 | if ( strlen(stocks_tmp->Name) > 20 ) { |
150 | // printf("| Name %.20s |\n",stocks_tmp->Name); | 150 | // printf("| Name %.20s |\n",stocks_tmp->Name); |
151 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 151 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
152 | tempString.stripWhiteSpace(); | 152 | tempString.stripWhiteSpace(); |
153 | if(donameCheck) | 153 | if(donameCheck) |
154 | output +=tempString; | 154 | output +=tempString; |
155 | } else { | 155 | } else { |
156 | // printf("| Name | %-20s |\n",stocks_tmp->Name); | 156 | // printf("| Name | %-20s |\n",stocks_tmp->Name); |
157 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 157 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
158 | tempString.stripWhiteSpace(); | 158 | tempString.stripWhiteSpace(); |
159 | if(donameCheck) | 159 | if(donameCheck) |
160 | output +=tempString; | 160 | output +=tempString; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | else { | 163 | else { |
164 | // printf("| Name | |\n"); | 164 | // printf("| Name | |\n"); |
165 | tempString.sprintf("| Name | |"); | 165 | tempString.sprintf("| Name | |"); |
166 | if(donameCheck) | 166 | if(donameCheck) |
167 | output +=tempString; | 167 | output +=tempString; |
168 | } | 168 | } |
169 | 169 | ||
170 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); | 170 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); |
171 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); | 171 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); |
172 | if(docurrentPriceCheck) | 172 | if(docurrentPriceCheck) |
173 | output +=tempString; | 173 | output +=tempString; |
174 | 174 | ||
175 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); | 175 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); |
176 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); | 176 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); |
177 | if(dolastPriceCheck) | 177 | if(dolastPriceCheck) |
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 | QString symbollist; |
243 | symbollist = cfg.readEntry("Symbols", ""); | 243 | symbollist = cfg.readEntry("Symbols", ""); |
244 | symbollist.replace(QRegExp(" "),"+");//seperated by + | 244 | symbollist.replace(QRegExp(" "),"+");//seperated by + |
245 | 245 | ||
246 | // qDebug(symbollist); | 246 | // qDebug(symbollist); |
247 | if (!symbollist.isEmpty()) { | 247 | if (!symbollist.isEmpty()) { |
248 | pthread_t thread1; | 248 | pthread_t thread1; |
249 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist); | 249 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, &symbollist); |
250 | } | 250 | } |
251 | // pthread_join(thread1,NULL); | 251 | // pthread_join(thread1,NULL); |
252 | // getStocks( symbollist.latin1() ); | 252 | // getStocks( symbollist.latin1() ); |
253 | } | 253 | } |
254 | 254 | ||
255 | void StockTickerPluginWidget::DefProxy(void) { | 255 | //void StockTickerPluginWidget::DefProxy(void) { |
256 | // char *proxy; | 256 | // char *proxy; |
257 | // libstocks_return_code error; | 257 | // libstocks_return_code error; |
258 | 258 | ||
259 | // /* Proxy support */ | 259 | // /* Proxy support */ |
260 | // /* Checks for "http_proxy" environment variable */ | 260 | // /* Checks for "http_proxy" environment variable */ |
261 | // proxy = getenv("http_proxy"); | 261 | // proxy = getenv("http_proxy"); |
262 | // if(proxy) { | 262 | // if(proxy) { |
263 | // /* printf("proxy set\n"); */ | 263 | // /* printf("proxy set\n"); */ |
264 | // error = set_proxy(proxy); | 264 | // error = set_proxy(proxy); |
265 | // if (error) { | 265 | // if (error) { |
266 | // // printf("Proxy error (%d)\n", error); | 266 | // // printf("Proxy error (%d)\n", error); |
267 | // QString tempString; | 267 | // QString tempString; |
268 | // tempString.sprintf("Proxy error (%d)\n", error); | 268 | // tempString.sprintf("Proxy error (%d)\n", error); |
269 | // output = tempString; | 269 | // output = tempString; |
270 | // return; | 270 | // return; |
271 | // // exit(1); | 271 | // // exit(1); |
272 | // } | 272 | // } |
273 | // } | 273 | // } |
274 | } | 274 | //} |
275 | 275 | ||
276 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | 276 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { |
277 | killTimer(e->timerId()); | 277 | killTimer(e->timerId()); |
278 | checkConnection(); | 278 | checkConnection(); |
279 | } | 279 | } |
280 | 280 | ||
281 | void StockTickerPluginWidget::checkConnection() { | 281 | void StockTickerPluginWidget::checkConnection() { |
282 | // qDebug("checking connection"); | 282 | // qDebug("checking connection"); |
283 | // Sock = new QSocket( this ); | 283 | // Sock = new QSocket( this ); |
284 | 284 | ||
285 | // if( wasError) | 285 | // if( wasError) |
286 | // stocktickerTicker->setText("Checking connection"); | 286 | // stocktickerTicker->setText("Checking connection"); |
287 | 287 | ||
288 | // if(Sock->state() == QSocket::Idle) { | 288 | // if(Sock->state() == QSocket::Idle) { |
289 | // Sock->connectToHost("finance.yahoo.com", 80); | 289 | // Sock->connectToHost("finance.yahoo.com", 80); |
290 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); | 290 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); |
291 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | 291 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); |
292 | // } else { | 292 | // } else { |
293 | // qDebug("State is not Idle"); | 293 | // qDebug("State is not Idle"); |
294 | isConnected(); | 294 | isConnected(); |
295 | // } | 295 | // } |
296 | } | 296 | } |
297 | 297 | ||
298 | void StockTickerPluginWidget::isConnected() { | 298 | void StockTickerPluginWidget::isConnected() { |
299 | // qDebug("We connect, so ok to grab stocks"); | 299 | // qDebug("We connect, so ok to grab stocks"); |
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 | qDebug("timer set for %d",(timerDelay*60000)/60000); |
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 | } |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h index c8de806..970a561 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.h | |||
@@ -1,61 +1,61 @@ | |||
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 | bool wasError; | 53 | bool wasError; |
54 | QSocket *Sock; | 54 | QSocket *Sock; |
55 | void timerEvent( QTimerEvent * ); | 55 | void timerEvent( QTimerEvent * ); |
56 | void init(); | 56 | void init(); |
57 | void DefProxy(void); | 57 | // void DefProxy(void); |
58 | int timerDelay; | 58 | int timerDelay; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | #endif | 61 | #endif |