summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-05 13:51:30 (UTC)
committer llornkcor <llornkcor>2002-11-05 13:51:30 (UTC)
commit86d934b18fb8878b80f6c5e7d66453adb90b08a0 (patch) (unidiff)
tree56d807f1155dbf9b4f5a828b6ab5ba43e7e532e4
parent320c8020a112dff1bc1d43bee9b103a423e0ac35 (diff)
downloadopie-86d934b18fb8878b80f6c5e7d66453adb90b08a0.zip
opie-86d934b18fb8878b80f6c5e7d66453adb90b08a0.tar.gz
opie-86d934b18fb8878b80f6c5e7d66453adb90b08a0.tar.bz2
remove commentedout code
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp23
1 files changed, 1 insertions, 22 deletions
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index 2f35f7f..18c9e51 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -105,225 +105,204 @@ void getStocks( const QString *blah) {
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
219StockTickerPluginWidget::StockTickerPluginWidget( QWidget *parent, const char* name) 219StockTickerPluginWidget::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
226StockTickerPluginWidget::~StockTickerPluginWidget() { 226StockTickerPluginWidget::~StockTickerPluginWidget() {
227} 227}
228 228
229void StockTickerPluginWidget::init() { 229void 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
239void StockTickerPluginWidget::doStocks() { 239void StockTickerPluginWidget::doStocks() {
240 Config cfg( "stockticker"); 240 Config cfg( "stockticker");
241 cfg.setGroup( "Symbols" ); 241 cfg.setGroup( "Symbols" );
242 symbollist=""; 242 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) {
256// char *proxy;
257// libstocks_return_code error;
258
259// /* Proxy support */
260// /* Checks for "http_proxy" environment variable */
261// proxy = getenv("http_proxy");
262// if(proxy) {
263// /* printf("proxy set\n"); */
264// error = set_proxy(proxy);
265// if (error) {
266// // printf("Proxy error (%d)\n", error);
267// QString tempString;
268// tempString.sprintf("Proxy error (%d)\n", error);
269// output = tempString;
270// return;
271// // exit(1);
272// }
273// }
274//}
275
276void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { 255void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
277 killTimer(e->timerId()); 256 killTimer(e->timerId());
278 checkConnection(); 257 checkConnection();
279} 258}
280 259
281void StockTickerPluginWidget::checkConnection() { 260void StockTickerPluginWidget::checkConnection() {
282// qDebug("checking connection"); 261// qDebug("checking connection");
283// Sock = new QSocket( this ); 262// Sock = new QSocket( this );
284 263
285// if( wasError) 264// if( wasError)
286// stocktickerTicker->setText("Checking connection"); 265// stocktickerTicker->setText("Checking connection");
287 266
288// if(Sock->state() == QSocket::Idle) { 267// if(Sock->state() == QSocket::Idle) {
289// Sock->connectToHost("finance.yahoo.com", 80); 268// Sock->connectToHost("finance.yahoo.com", 80);
290// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); 269// connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) );
291// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); 270// connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) );
292// } else { 271// } else {
293// qDebug("State is not Idle"); 272// qDebug("State is not Idle");
294 isConnected(); 273 isConnected();
295// } 274// }
296} 275}
297 276
298void StockTickerPluginWidget::isConnected() { 277void StockTickerPluginWidget::isConnected() {
299// qDebug("We connect, so ok to grab stocks"); 278// qDebug("We connect, so ok to grab stocks");
300 doStocks(); 279 doStocks();
301 280
302 Config cfg( "stockticker"); 281 Config cfg( "stockticker");
303 cfg.setGroup("Timer"); 282 cfg.setGroup("Timer");
304 timerDelay= cfg.readNumEntry("Delay",0); 283 timerDelay= cfg.readNumEntry("Delay",0);
305 if(timerDelay > 0) 284 if(timerDelay > 0)
306 startTimer(timerDelay*60000); 285 startTimer(timerDelay*60000);
307 qDebug("timer set for %d",(timerDelay*60000)/60000); 286 qDebug("timer set for %d",(timerDelay*60000)/60000);
308 wasError = false; 287 wasError = false;
309 288
310// Sock->close(); 289// Sock->close();
311} 290}
312 291
313void StockTickerPluginWidget::socketError(int errcode) { 292void StockTickerPluginWidget::socketError(int errcode) {
314 switch(errcode) { 293 switch(errcode) {
315 case QSocket::ErrConnectionRefused: 294 case QSocket::ErrConnectionRefused:
316 output = tr("Connection refused."); 295 output = tr("Connection refused.");
317 break; 296 break;
318 case QSocket::ErrHostNotFound: 297 case QSocket::ErrHostNotFound:
319 output = tr("Could not find server."); 298 output = tr("Could not find server.");
320 break; 299 break;
321 case QSocket::ErrSocketRead : 300 case QSocket::ErrSocketRead :
322 output = tr("Socket read error."); 301 output = tr("Socket read error.");
323 break; 302 break;
324 }; 303 };
325 stocktickerTicker->setText( output ); 304 stocktickerTicker->setText( output );
326 wasError = true; 305 wasError = true;
327// Sock->close(); 306// Sock->close();
328 307
329} 308}