5 files changed, 328 insertions, 300 deletions
diff --git a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp index 71dd7eb..73f8bb3 100644 --- a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp +++ b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp | |||
@@ -11,2 +11,3 @@ | |||
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | #include <qlayout.h> | ||
12 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp index d740b6f..915233a 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.cpp | |||
@@ -123,3 +123,3 @@ StocktickerPluginConfig::StocktickerPluginConfig( QWidget *parent, const char* | |||
123 | cfg.setGroup("Timer"); | 123 | cfg.setGroup("Timer"); |
124 | timerDelaySpin->setValue( cfg.readNumEntry("Delay",0)); | 124 | timerDelaySpin->setValue( cfg.readNumEntry("Delay",15)); |
125 | layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0); | 125 | layout->addMultiCellWidget( timerDelaySpin , 6, 6, 0, 0); |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h index 2b67a8b..10f9678 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerconfig.h | |||
@@ -30,3 +30,3 @@ class QSpinBox; | |||
30 | class StocktickerPluginConfig : public TodayConfigWidget { | 30 | class StocktickerPluginConfig : public TodayConfigWidget { |
31 | //Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp index c3ca52d..fedc79c 100644 --- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp +++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp | |||
@@ -1,33 +1,37 @@ | |||
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 <qlayout.h> | 17 | #include <qlayout.h> |
18 | 18 | ||
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | 20 | ||
21 | #include <opie/oticker.h> | 21 | #include <opie/oticker.h> |
22 | 22 | ||
23 | extern "C" { | 23 | extern "C" { |
24 | #include "libstocks/stocks.h" | 24 | #include "libstocks/stocks.h" |
25 | } | 25 | } |
26 | 26 | ||
27 | #include <pthread.h> | 27 | #include <pthread.h> |
28 | 28 | ||
29 | #include "stocktickerpluginwidget.h" | 29 | #include "stocktickerpluginwidget.h" |
30 | 30 | ||
31 | QString output; | 31 | QString output; |
32 | OTicker *stocktickerTicker; | 32 | OTicker *stocktickerTicker; |
33 | QCString stock_liste; | ||
34 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | ||
35 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | ||
36 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | ||
33 | 37 | ||
@@ -35,267 +39,289 @@ void getStocks(char *blah) { | |||
35 | 39 | ||
36 | // stocktickerTicker->setText( "Downloading stock data."); | 40 | // stocktickerTicker->setText( "Downloading stock data."); |
37 | stock *stocks_quotes=NULL; | 41 | stock *stocks_quotes=NULL; |
38 | stock *stocks_tmp; | 42 | stock *stocks_tmp; |
39 | QCString stock_liste = blah; | 43 | stock_liste = blah; |
40 | ::free ( blah ); | 44 | ::free ( blah ); |
41 | // char *stock_liste = (char *)blah->latin1(); | 45 | // char *stock_liste = (char *)blah->latin1(); |
42 | qDebug("%s", stock_liste.data() ); | 46 | // qDebug("%s", stock_liste.data() ); |
43 | QString tempString; | 47 | output = ""; |
44 | output = ""; | 48 | QString tempString; |
45 | 49 | libstocks_return_code error; | |
46 | libstocks_return_code error; | 50 | |
47 | 51 | // Config cfg( "stockticker"); | |
48 | Config cfg( "stockticker"); | 52 | // cfg.setGroup( "Fields" ); |
49 | cfg.setGroup( "Fields" ); | 53 | // bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; |
50 | bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; | 54 | // bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; |
51 | bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; | 55 | // bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; |
52 | bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; | 56 | |
53 | 57 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; | |
54 | dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; | 58 | |
55 | 59 | dotimeCheck=1; | |
56 | dotimeCheck=cfg.readBoolEntry("timeCheck",1); | 60 | dodateCheck=1; |
57 | dodateCheck=cfg.readBoolEntry("dateCheck",1); | 61 | dosymbolCheck=1; |
58 | dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); | 62 | donameCheck=1; |
59 | donameCheck=cfg.readBoolEntry("nameCheck",1); | 63 | docurrentPriceCheck=1; |
60 | docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); | 64 | dolastPriceCheck=1; |
61 | dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); | 65 | doopenPriceCheck=1; |
62 | doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); | 66 | dominPriceCheck=1; |
63 | dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); | 67 | domaxPriceCheck=1; |
64 | domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); | 68 | dovariationCheck=1; |
65 | dovariationCheck=cfg.readBoolEntry("variationCheck",1); | 69 | dovolumeCheck=1; |
66 | dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); | 70 | |
67 | 71 | // dotimeCheck=cfg.readBoolEntry("timeCheck",1); | |
68 | // DefProxy(); | 72 | // dodateCheck=cfg.readBoolEntry("dateCheck",1); |
69 | { | 73 | // dosymbolCheck=cfg.readBoolEntry("symbolCheck",1); |
70 | char *proxy; | 74 | // donameCheck=cfg.readBoolEntry("nameCheck",1); |
71 | libstocks_return_code error; | 75 | // docurrentPriceCheck=cfg.readBoolEntry("currentPriceCheck",1); |
72 | 76 | // dolastPriceCheck=cfg.readBoolEntry("lastPriceCheck",1); | |
73 | /* Proxy support */ | 77 | // doopenPriceCheck=cfg.readBoolEntry("openPriceCheck",1); |
74 | /* Checks for "http_proxy" environment variable */ | 78 | // dominPriceCheck=cfg.readBoolEntry("minPriceCheck",1); |
75 | proxy = getenv("http_proxy"); | 79 | // domaxPriceCheck=cfg.readBoolEntry("maxPriceCheck",1); |
76 | if(proxy) { | 80 | // dovariationCheck=cfg.readBoolEntry("variationCheck",1); |
77 | /* printf("proxy set\n"); */ | 81 | // dovolumeCheck=cfg.readBoolEntry("volumeCheck",1); |
78 | error = set_proxy(proxy); | 82 | |
79 | if (error) { | 83 | // DefProxy(); |
80 | printf("Proxy error (%d)\n", error); | 84 | // { |
81 | QString tempString; | 85 | char *proxy; |
82 | tempString.sprintf("Proxy error (%d)\n", error); | 86 | // libstocks_return_code error; |
83 | output = tempString; | 87 | |
84 | return; | 88 | /* Proxy support */ |
85 | // exit(1); | 89 | /* Checks for "http_proxy" environment variable */ |
86 | } | 90 | proxy = getenv("http_proxy"); |
87 | } | 91 | if(proxy) { |
88 | } | 92 | /* printf("proxy set\n"); */ |
89 | // char *stock_liste = (char *)blah; | 93 | error = set_proxy(proxy); |
90 | /* Get the stocks and process errors */ | 94 | if (error) { |
91 | error = get_stocks( stock_liste.data(), &stocks_quotes); | 95 | // printf("Proxy error (%d)\n", error); |
92 | 96 | // QString tempString2; | |
93 | if (error) { | 97 | // tempString2.sprintf("Proxy error (%d)\n", error); |
94 | printf("Error in getting stocks (%d)\n", error); | 98 | // output = tempString2; |
95 | tempString.sprintf("Error in getting stocks (%d)\n", error); | 99 | // delete tempString2; |
96 | output =tempString; | 100 | return; |
97 | return; | 101 | // exit(1); |
98 | // exit(1); | 102 | } |
99 | } | 103 | } |
100 | 104 | ::free(proxy); | |
101 | stocks_tmp = stocks_quotes; | 105 | // } |
102 | 106 | /* Get the stocks and process errors */ | |
103 | /* Displays the stocks */ | 107 | error = get_stocks( stock_liste.data(), &stocks_quotes); |
104 | while(stocks_tmp!=0){ | 108 | |
105 | 109 | if (error) { | |
106 | if (stocks_tmp->Time) { | 110 | printf("Error in getting stocks (%d)\n", error); |
107 | // printf("%s ", stocks_tmp->Time); | 111 | tempString.sprintf("Error in getting stocks (%d)\n", error); |
108 | tempString.sprintf("| %s ", stocks_tmp->Time); | 112 | output =tempString; |
109 | tempString.replace(QRegExp("\""),""); | 113 | return; |
110 | if( dotimeCheck) | 114 | } |
111 | output +=tempString; | 115 | |
112 | } | 116 | stocks_tmp = stocks_quotes; |
113 | if (stocks_tmp->Date) { | 117 | |
114 | // printf("%s ", stocks_tmp->Date); | 118 | /* Displays the stocks */ |
115 | tempString.sprintf("| %s ", stocks_tmp->Date); | 119 | while(stocks_tmp!=0){ |
116 | tempString.replace(QRegExp("\""),""); | 120 | |
117 | if(dodateCheck) | 121 | if (stocks_tmp->Time) { |
118 | output +=tempString; | 122 | // printf("%s ", stocks_tmp->Time); |
119 | } | 123 | tempString.sprintf("| %s ", stocks_tmp->Time); |
120 | // printf("\n"); | 124 | tempString.replace(QRegExp("\""),""); |
121 | 125 | if( dotimeCheck) | |
122 | // printf("----------------------------------------\n"); | 126 | output +=tempString; |
123 | 127 | } | |
124 | if ( strlen(stocks_tmp->Symbol) > 20 ) { | 128 | if (stocks_tmp->Date) { |
125 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); | 129 | // printf("%s ", stocks_tmp->Date); |
126 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 130 | tempString.sprintf("| %s ", stocks_tmp->Date); |
127 | if(dosymbolCheck) | 131 | tempString.replace(QRegExp("\""),""); |
128 | output +=tempString; | 132 | if(dodateCheck) |
129 | } | 133 | output +=tempString; |
130 | else { | 134 | } |
131 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); | 135 | // printf("\n"); |
132 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); | 136 | |
133 | if(dosymbolCheck) | 137 | // printf("----------------------------------------\n"); |
134 | output +=tempString; | 138 | |
135 | } | 139 | if ( strlen(stocks_tmp->Symbol) > 20 ) { |
136 | 140 | // printf("| Symbol | %.20s |\n",stocks_tmp->Symbol); | |
137 | if (stocks_tmp->Name) { | 141 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
138 | if ( strlen(stocks_tmp->Name) > 20 ) { | 142 | if(dosymbolCheck) |
139 | // printf("| Name %.20s |\n",stocks_tmp->Name); | 143 | output +=tempString; |
140 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 144 | } |
141 | tempString.stripWhiteSpace(); | 145 | else { |
142 | if(donameCheck) | 146 | // printf("| Symbol | %-20s |\n",stocks_tmp->Symbol); |
143 | output +=tempString; | 147 | tempString.sprintf("| Symbol %s ",stocks_tmp->Symbol); |
144 | } else { | 148 | if(dosymbolCheck) |
145 | // printf("| Name | %-20s |\n",stocks_tmp->Name); | 149 | output +=tempString; |
146 | tempString.sprintf("| Name %s ",stocks_tmp->Name); | 150 | } |
147 | tempString.stripWhiteSpace(); | 151 | |
148 | if(donameCheck) | 152 | if (stocks_tmp->Name) { |
149 | output +=tempString; | 153 | if ( strlen(stocks_tmp->Name) > 20 ) { |
150 | } | 154 | // printf("| Name %.20s |\n",stocks_tmp->Name); |
151 | } | 155 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
152 | else { | 156 | tempString.stripWhiteSpace(); |
153 | // printf("| Name | |\n"); | 157 | if(donameCheck) |
154 | tempString.sprintf("| Name | |"); | 158 | output +=tempString; |
155 | if(donameCheck) | 159 | } else { |
156 | output +=tempString; | 160 | // printf("| Name | %-20s |\n",stocks_tmp->Name); |
157 | } | 161 | tempString.sprintf("| Name %s ",stocks_tmp->Name); |
158 | 162 | tempString.stripWhiteSpace(); | |
159 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); | 163 | if(donameCheck) |
160 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); | 164 | output +=tempString; |
161 | if(docurrentPriceCheck) | 165 | } |
162 | output +=tempString; | 166 | } |
163 | 167 | else { | |
164 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); | 168 | // printf("| Name | |\n"); |
165 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); | 169 | tempString.sprintf("| Name | |"); |
166 | if(dolastPriceCheck) | 170 | if(donameCheck) |
167 | output +=tempString; | 171 | output +=tempString; |
168 | 172 | } | |
169 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); | 173 | |
170 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); | 174 | // printf("| Price | %-7.2f |\n", stocks_tmp->CurrentPrice); |
171 | if(doopenPriceCheck) | 175 | tempString.sprintf("| Price %-7.2f ", stocks_tmp->CurrentPrice); |
172 | output +=tempString; | 176 | if(docurrentPriceCheck) |
173 | 177 | output +=tempString; | |
174 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); | 178 | |
175 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); | 179 | // printf("| Yesterday | %-7.2f |\n",stocks_tmp->LastPrice); |
176 | if(dominPriceCheck) | 180 | tempString.sprintf("| Yesterday %-7.2f ",stocks_tmp->LastPrice); |
177 | output +=tempString; | 181 | if(dolastPriceCheck) |
178 | 182 | output +=tempString; | |
179 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); | 183 | |
180 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); | 184 | // printf("| Open | %-7.2f |\n",stocks_tmp->OpenPrice); |
181 | if(domaxPriceCheck) | 185 | tempString.sprintf("| Open %-7.2f ",stocks_tmp->OpenPrice); |
182 | output +=tempString; | 186 | if(doopenPriceCheck) |
183 | 187 | output +=tempString; | |
184 | // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); | 188 | |
185 | tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); | 189 | // printf("| Min | %-7.2f |\n", stocks_tmp->MinPrice); |
186 | if(dovariationCheck) | 190 | tempString.sprintf("| Min %-7.2f ", stocks_tmp->MinPrice); |
187 | output +=tempString; | 191 | if(dominPriceCheck) |
188 | 192 | output +=tempString; | |
189 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); | 193 | |
190 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); | 194 | // printf("| Max | %-7.2f |\n",stocks_tmp->MaxPrice); |
191 | if(dovolumeCheck) | 195 | tempString.sprintf("| Max %-7.2f ",stocks_tmp->MaxPrice); |
192 | output +=tempString; | 196 | if(domaxPriceCheck) |
193 | 197 | output +=tempString; | |
194 | // printf("----------------------------------------\n\n"); | 198 | |
195 | tempString.sprintf("||==++==|"); | 199 | // printf("| Var | %-6.2f (%5.2f %%) |\n", stocks_tmp->Variation, stocks_tmp->Pourcentage); |
196 | output +=tempString; | 200 | tempString.sprintf("| Var %-6.2f (%5.2f %%) ", stocks_tmp->Variation, stocks_tmp->Pourcentage); |
197 | 201 | if(dovariationCheck) | |
198 | /* Simple function which help to browse in the stocks list */ | 202 | output +=tempString; |
199 | stocks_tmp = next_stock(stocks_tmp); | 203 | |
200 | } | 204 | // printf("| Volume | %-9d |\n", stocks_tmp->Volume); |
201 | 205 | tempString.sprintf("| Volume %-9d ", stocks_tmp->Volume); | |
202 | /* frees stocks */ | 206 | if(dovolumeCheck) |
203 | free_stocks(stocks_quotes); | 207 | output +=tempString; |
204 | stocktickerTicker->setText( output.latin1() ); | 208 | |
205 | 209 | // printf("----------------------------------------\n\n"); | |
206 | } | 210 | tempString.sprintf("||==++==|"); |
207 | 211 | output +=tempString; | |
208 | StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) | 212 | |
209 | : QWidget(parent, name ) { | 213 | /* Simple function which help to browse in the stocks list */ |
210 | init(); | 214 | stocks_tmp = next_stock(stocks_tmp); |
211 | startTimer(1000); | 215 | } |
212 | 216 | ||
213 | stocktickerTicker->setTextFormat(Qt::RichText); | 217 | stocktickerTicker->setText( output.latin1() ); |
214 | // checkConnection(); | 218 | |
215 | } | 219 | /* frees stocks */ |
216 | 220 | free_stocks(stocks_quotes); | |
217 | StockTickerPluginWidget::~StockTickerPluginWidget() { | 221 | free_stocks(stocks_tmp); |
218 | } | 222 | |
219 | 223 | stock_liste=""; | |
220 | void StockTickerPluginWidget::init() { | 224 | //delete stock_liste; |
221 | 225 | tempString=""; | |
222 | QHBoxLayout* layout = new QHBoxLayout( this ); | 226 | output=""; |
223 | stocktickerTicker = new OTicker(this); | 227 | } |
224 | // stocktickerTicker->setMinimumHeight(15); | 228 | |
225 | connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); | 229 | StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) |
226 | layout->addWidget( stocktickerTicker); | 230 | : QWidget(parent, name ) { |
227 | wasError = true; | 231 | init(); |
228 | } | 232 | startTimer(1000); |
229 | 233 | ||
230 | void StockTickerPluginWidget::doStocks() { | 234 | stocktickerTicker->setTextFormat(Qt::RichText); |
231 | Config cfg( "stockticker"); | 235 | // checkConnection(); |
232 | cfg.setGroup( "Symbols" ); | 236 | } |
233 | symbollist=""; | 237 | |
234 | symbollist = cfg.readEntry("Symbols", ""); | 238 | StockTickerPluginWidget::~StockTickerPluginWidget() { |
235 | symbollist.replace(QRegExp(" "),"+");//seperated by + | 239 | } |
236 | 240 | ||
237 | cfg.setGroup("Timer"); | 241 | void StockTickerPluginWidget::init() { |
238 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); | 242 | |
239 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); | 243 | QHBoxLayout* layout = new QHBoxLayout( this ); |
240 | 244 | stocktickerTicker = new OTicker(this); | |
241 | if (!symbollist.isEmpty()) { | 245 | // stocktickerTicker->setMinimumHeight(15); |
242 | pthread_t thread1; | 246 | connect( stocktickerTicker, SIGNAL( mousePressed()), this, SLOT( checkConnection() )); |
243 | char *blah = ::strdup(symbollist.latin1()); | 247 | layout->addWidget( stocktickerTicker); |
244 | pthread_create(&thread1,NULL, (void * (*)(void *))getStocks, (void *) blah); | 248 | wasError = true; |
245 | } | 249 | } |
246 | } | 250 | |
247 | 251 | void StockTickerPluginWidget::doStocks() { | |
248 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | 252 | Config cfg( "stockticker"); |
249 | killTimer(e->timerId()); | 253 | cfg.setGroup( "Symbols" ); |
250 | checkConnection(); | 254 | symbollist=""; |
251 | } | 255 | symbollist = cfg.readEntry("Symbols", ""); |
252 | 256 | symbollist.replace(QRegExp(" "),"+");//seperated by + | |
253 | void StockTickerPluginWidget::checkConnection() { | 257 | |
254 | // qDebug("checking connection"); | 258 | cfg.setGroup("Timer"); |
255 | // Sock = new QSocket( this ); | 259 | stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); |
256 | 260 | stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); | |
257 | // if( wasError) | 261 | |
258 | // stocktickerTicker->setText("Checking connection"); | 262 | if (!symbollist.isEmpty()) { |
259 | 263 | pthread_t thread1; | |
260 | // if(Sock->state() == QSocket::Idle) { | 264 | char *blah = ::strdup(symbollist.latin1()); |
261 | // Sock->connectToHost("finance.yahoo.com", 80); | 265 | pthread_create( &thread1, NULL, (void * (*)(void *))getStocks, (void *) blah); |
262 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); | 266 | pthread_detach( thread1); |
263 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | 267 | |
264 | // } else { | 268 | //::free((void*)thread1); |
265 | // qDebug("State is not Idle"); | 269 | //getStocks(blah); |
266 | isConnected(); | 270 | } |
267 | // } | 271 | } |
268 | } | 272 | |
269 | 273 | void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { | |
270 | void StockTickerPluginWidget::isConnected() { | 274 | killTimer(e->timerId()); |
271 | // qDebug("We connect, so ok to grab stocks"); | 275 | checkConnection(); |
272 | doStocks(); | 276 | } |
273 | 277 | ||
274 | Config cfg( "stockticker"); | 278 | void StockTickerPluginWidget::checkConnection() { |
275 | cfg.setGroup("Timer"); | 279 | // qDebug("checking connection"); |
276 | timerDelay= cfg.readNumEntry("Delay",0); | 280 | // Sock = new QSocket( this ); |
277 | if(timerDelay > 0) | 281 | |
278 | startTimer(timerDelay*60000); | 282 | // if( wasError) |
279 | qDebug("timer set for %d",(timerDelay*60000)/60000); | 283 | // stocktickerTicker->setText("Checking connection"); |
280 | wasError = false; | 284 | |
281 | 285 | // if(Sock->state() == QSocket::Idle) { | |
282 | // Sock->close(); | 286 | // Sock->connectToHost("finance.yahoo.com", 80); |
283 | } | 287 | // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); |
284 | 288 | // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); | |
285 | void StockTickerPluginWidget::socketError(int errcode) { | 289 | // } else { |
286 | switch(errcode) { | 290 | // qDebug("State is not Idle"); |
287 | case QSocket::ErrConnectionRefused: | 291 | isConnected(); |
288 | output = tr("Connection refused."); | 292 | // } |
289 | break; | 293 | } |
290 | case QSocket::ErrHostNotFound: | 294 | |
291 | output = tr("Could not find server."); | 295 | void StockTickerPluginWidget::isConnected() { |
292 | break; | 296 | // qDebug("We connect, so ok to grab stocks"); |
293 | case QSocket::ErrSocketRead : | 297 | if(this->isVisible()) |
294 | output = tr("Socket read error."); | 298 | doStocks(); |
295 | break; | 299 | |
296 | }; | 300 | Config cfg( "stockticker"); |
297 | stocktickerTicker->setText( output ); | 301 | cfg.setGroup("Timer"); |
298 | wasError = true; | 302 | timerDelay= cfg.readNumEntry("Delay",0); |
299 | // Sock->close(); | 303 | if(timerDelay > 0) |
300 | 304 | startTimer(timerDelay*60000); | |
301 | } | 305 | // qDebug("timer set for %d",(timerDelay*60000)/60000); |
306 | wasError = false; | ||
307 | |||
308 | // Sock->close(); | ||
309 | } | ||
310 | |||
311 | void StockTickerPluginWidget::socketError(int errcode) { | ||
312 | switch(errcode) { | ||
313 | case QSocket::ErrConnectionRefused: | ||
314 | output = tr("Connection refused."); | ||
315 | break; | ||
316 | case QSocket::ErrHostNotFound: | ||
317 | output = tr("Could not find server."); | ||
318 | break; | ||
319 | case QSocket::ErrSocketRead : | ||
320 | output = tr("Socket read error."); | ||
321 | break; | ||
322 | }; | ||
323 | stocktickerTicker->setText( output ); | ||
324 | wasError = true; | ||
325 | // Sock->close(); | ||
326 | |||
327 | } | ||
diff --git a/noncore/todayplugins/weather/weatherconfig.h b/noncore/todayplugins/weather/weatherconfig.h index 3877818..d9ffec2 100644 --- a/noncore/todayplugins/weather/weatherconfig.h +++ b/noncore/todayplugins/weather/weatherconfig.h | |||
@@ -43,2 +43,3 @@ class WeatherPluginConfig : public TodayConfigWidget | |||
43 | { | 43 | { |
44 | Q_OBJECT | ||
44 | public: | 45 | public: |