summaryrefslogtreecommitdiff
path: root/noncore/todayplugins/stockticker
Unidiff
Diffstat (limited to 'noncore/todayplugins/stockticker') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/todayplugins/stockticker/stockticker/inputDialog.cpp18
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/config.in2
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro5
-rw-r--r--noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp10
4 files changed, 18 insertions, 17 deletions
diff --git a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
index ce35256..ae219d7 100644
--- a/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
+++ b/noncore/todayplugins/stockticker/stockticker/inputDialog.cpp
@@ -1,88 +1,90 @@
1#include "inputDialog.h" 1#include "inputDialog.h"
2#include "helpwindow.h"
3
4/* OPIE */
5#include <opie2/odebug.h>
6#include <qpe/config.h>
7using namespace Opie::Core;
2 8
9/* QT */
3#include <qapplication.h> 10#include <qapplication.h>
4#include <qlayout.h> 11#include <qlayout.h>
5#include <qcheckbox.h> 12#include <qcheckbox.h>
6#include <qlineedit.h> 13#include <qlineedit.h>
7#include <qvariant.h> 14#include <qvariant.h>
8#include <qpushbutton.h> 15#include <qpushbutton.h>
9#include <qwhatsthis.h> 16#include <qwhatsthis.h>
10#include <qlabel.h> 17#include <qlabel.h>
11#include <qlayout.h> 18#include <qlayout.h>
12#include <qpe/config.h>
13#include <qstringlist.h> 19#include <qstringlist.h>
14using namespace Opie::Core;
15using namespace Opie::Core;
16#include <qmainwindow.h> 20#include <qmainwindow.h>
17#include "helpwindow.h"
18 21
22/* STD */
19#include <stdlib.h> 23#include <stdlib.h>
20// #include <sys/stat.h>
21// #include <unistd.h>
22 24
23InputDialog::InputDialog( ) 25InputDialog::InputDialog( )
24 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) { 26 : QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) {
25 setCaption( tr("Symbol Lookup")); 27 setCaption( tr("Symbol Lookup"));
26 28
27 QGridLayout *layout = new QGridLayout( this ); 29 QGridLayout *layout = new QGridLayout( this );
28 layout->setSpacing(6); 30 layout->setSpacing(6);
29 layout->setMargin( 2); 31 layout->setMargin( 2);
30 32
31 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 33 LineEdit1 = new QLineEdit( this, "LineEdit1" );
32 LineEdit1->setFocus(); 34 LineEdit1->setFocus();
33 35
34 layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3); 36 layout->addMultiCellWidget( LineEdit1, 0, 0, 0, 3);
35 37
36 QLabel *label; 38 QLabel *label;
37 label = new QLabel(this); 39 label = new QLabel(this);
38 label->setText( tr("Enter something to lookup / search.")); 40 label->setText( tr("Enter something to lookup / search."));
39 label->setMaximumHeight(60); 41 label->setMaximumHeight(60);
40 layout->addMultiCellWidget( label, 1, 1, 0, 3); 42 layout->addMultiCellWidget( label, 1, 1, 0, 3);
41 43
42 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup())); 44 connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(doLookup()));
43 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding ); 45 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
44 layout->addItem( spacer, 8, 0 ); 46 layout->addItem( spacer, 8, 0 );
45 47
46} 48}
47 49
48InputDialog::~InputDialog() { 50InputDialog::~InputDialog() {
49} 51}
50 52
51void InputDialog::doLookup() { 53void InputDialog::doLookup() {
52// http://finance.yahoo.com/l?m=&s=siemens&t= 54// http://finance.yahoo.com/l?m=&s=siemens&t=
53 55
54 QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\""; 56 QString url = "\"http://finance.yahoo.com/l?m=&s="+LineEdit1->text()+"\"";
55 QString tempHtml = "/tmp/stockticker.html"; 57 QString tempHtml = "/tmp/stockticker.html";
56 QString cmd = "wget -O "+tempHtml+" "+url; 58 QString cmd = "wget -O "+tempHtml+" "+url;
57 qDebug(cmd); 59 odebug << cmd << oendl;
58 60
59 61
60/* 62/*
61 OProcess proc; 63 OProcess proc;
62 proc << "/usr/bin/wget"; 64 proc << "/usr/bin/wget";
63 proc<<"-O"<< tempHtml<< url; 65 proc<<"-O"<< tempHtml<< url;
64 66
65 connect( &proc, SIGNAL( processExited(Opie::Core::OProcess*)),this, SLOT( showBrowser(Opie::Core::OProcess*))); 67 connect( &proc, SIGNAL( processExited(Opie::Core::OProcess*)),this, SLOT( showBrowser(Opie::Core::OProcess*)));
66 proc.start( OProcess::NotifyOnExit); 68 proc.start( OProcess::NotifyOnExit);
67*/ 69*/
68 system(cmd.latin1()); 70 system(cmd.latin1());
69 HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); 71 HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup");
70 StockLookup->setCaption("Symbol"); 72 StockLookup->setCaption("Symbol");
71 StockLookup->showMaximized(); 73 StockLookup->showMaximized();
72 StockLookup->show(); 74 StockLookup->show();
73 LineEdit1->text(); 75 LineEdit1->text();
74 76
75 77
76} 78}
77 79
78void InputDialog::showBrowser(OProcess*) { 80void InputDialog::showBrowser(OProcess*) {
79 qDebug("BLAH"); 81 odebug << "BLAH" << oendl;
80 QString tempHtml = "/tmp/stockticker.html"; 82 QString tempHtml = "/tmp/stockticker.html";
81 83
82 HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup"); 84 HelpWindow *StockLookup = new HelpWindow( tempHtml,".",this, "SymbolLookup");
83 StockLookup->setCaption("Symbol"); 85 StockLookup->setCaption("Symbol");
84 StockLookup->showMaximized(); 86 StockLookup->showMaximized();
85 StockLookup->show(); 87 StockLookup->show();
86 LineEdit1->text(); 88 LineEdit1->text();
87 89
88} 90}
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/config.in b/noncore/todayplugins/stockticker/stocktickerlib/config.in
index 4d589f9..7dbe03a 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/config.in
+++ b/noncore/todayplugins/stockticker/stocktickerlib/config.in
@@ -1,4 +1,4 @@
1config TODAY_STOCKTICKERLIB 1config TODAY_STOCKTICKERLIB
2 boolean 2 boolean
3 default "y" if TODAY_STOCKTICKER 3 default "y" if TODAY_STOCKTICKER
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && LIBOPIE2PIM && TODAY 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2PIM && TODAY
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro
index e70d1c0..6dcf945 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerlib.pro
@@ -1,29 +1,28 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG -= moc
3CONFIG += qt plugin 2CONFIG += qt plugin
4 3
5HEADERS = stocktickerplugin.h stocktickerpluginimpl.h stocktickerpluginwidget.h stocktickerconfig.h \ 4HEADERS = stocktickerplugin.h stocktickerpluginimpl.h stocktickerpluginwidget.h stocktickerconfig.h \
6 ../libstocks/csv.h \ 5 ../libstocks/csv.h \
7 ../libstocks/http.h \ 6 ../libstocks/http.h \
8 ../libstocks/lists.h \ 7 ../libstocks/lists.h \
9 ../libstocks/stocks.h 8 ../libstocks/stocks.h
10SOURCES = stocktickerplugin.cpp stocktickerpluginimpl.cpp stocktickerpluginwidget.cpp stocktickerconfig.cpp \ 9SOURCES = stocktickerplugin.cpp stocktickerpluginimpl.cpp stocktickerpluginwidget.cpp stocktickerconfig.cpp \
11 ../libstocks/csv.c \ 10 ../libstocks/csv.c \
12 ../libstocks/currency.c \ 11 ../libstocks/currency.c \
13 ../libstocks/history.c \ 12 ../libstocks/history.c \
14 ../libstocks/http.c \ 13 ../libstocks/http.c \
15 ../libstocks/lists.c \ 14 ../libstocks/lists.c \
16 ../libstocks/stocks.c 15 ../libstocks/stocks.c
17 16
18INCLUDEPATH += $(OPIEDIR)/include \ 17INCLUDEPATH += $(OPIEDIR)/include \
19 ../ ../library 18 ../ ../library
20DEPENDPATH += $(OPIEDIR)/include \ 19DEPENDPATH += $(OPIEDIR)/include \
21 ../ ../library 20 ../ ../library
22 21
23LIBS+= -lqpe -lopieui2 -lopiepim2 -lpthread 22LIBS += -lqpe -lopiecore2 -lopieui2 -lopiepim2 -lpthread
24TMAKE_CFLAGS += -D__UNIX__ 23DEFINES += __UNIX__
25 24
26DESTDIR = $(OPIEDIR)/plugins/today 25DESTDIR = $(OPIEDIR)/plugins/today
27TARGET = todaystocktickerplugin 26TARGET = todaystocktickerplugin
28 27
29include ( $(OPIEDIR)/include.pro ) 28include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
index aaeb5ee..4855ac6 100644
--- a/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
+++ b/noncore/todayplugins/stockticker/stocktickerlib/stocktickerpluginwidget.cpp
@@ -24,49 +24,49 @@ using namespace Opie::Ui;
24using namespace Opie::Ui; 24using namespace Opie::Ui;
25extern "C" { 25extern "C" {
26 #include "libstocks/stocks.h" 26 #include "libstocks/stocks.h"
27 } 27 }
28 28
29 #include <pthread.h> 29 #include <pthread.h>
30 30
31 #include "stocktickerpluginwidget.h" 31 #include "stocktickerpluginwidget.h"
32 32
33 QString output; 33 QString output;
34 OTicker *stocktickerTicker; 34 OTicker *stocktickerTicker;
35 QCString stock_liste; 35 QCString stock_liste;
36 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; 36 bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
37 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; 37 bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
38 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; 38 bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
39 39
40void getStocks(char *blah) { 40void getStocks(char *blah) {
41 41
42 // stocktickerTicker->setText( "Downloading stock data."); 42 // stocktickerTicker->setText( "Downloading stock data.");
43 stock *stocks_quotes=NULL; 43 stock *stocks_quotes=NULL;
44 stock *stocks_tmp; 44 stock *stocks_tmp;
45 stock_liste = blah; 45 stock_liste = blah;
46 ::free ( blah ); 46 ::free ( blah );
47 // char *stock_liste = (char *)blah->latin1(); 47 // char *stock_liste = (char *)blah->latin1();
48 // qDebug("%s", stock_liste.data() ); 48 // odebug << "" << stock_liste.data() << "" << oendl;
49 output = ""; 49 output = "";
50 QString tempString; 50 QString tempString;
51 libstocks_return_code error; 51 libstocks_return_code error;
52 52
53// Config cfg( "stockticker"); 53// Config cfg( "stockticker");
54// cfg.setGroup( "Fields" ); 54// cfg.setGroup( "Fields" );
55// bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck; 55// bool dotimeCheck, dodateCheck, dosymbolCheck, donameCheck;
56// bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck; 56// bool docurrentPriceCheck, dolastPriceCheck, doopenPriceCheck;
57// bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck; 57// bool dominPriceCheck, domaxPriceCheck, dovariationCheck, dovolumeCheck;
58 58
59 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false; 59 dotimeCheck=dodateCheck=dosymbolCheck=donameCheck= docurrentPriceCheck=dolastPriceCheck=doopenPriceCheck=dominPriceCheck=domaxPriceCheck=dovariationCheck=dovolumeCheck=false;
60 60
61 dotimeCheck=1; 61 dotimeCheck=1;
62 dodateCheck=1; 62 dodateCheck=1;
63 dosymbolCheck=1; 63 dosymbolCheck=1;
64 donameCheck=1; 64 donameCheck=1;
65 docurrentPriceCheck=1; 65 docurrentPriceCheck=1;
66 dolastPriceCheck=1; 66 dolastPriceCheck=1;
67 doopenPriceCheck=1; 67 doopenPriceCheck=1;
68 dominPriceCheck=1; 68 dominPriceCheck=1;
69 domaxPriceCheck=1; 69 domaxPriceCheck=1;
70 dovariationCheck=1; 70 dovariationCheck=1;
71 dovolumeCheck=1; 71 dovolumeCheck=1;
72 72
@@ -257,73 +257,73 @@ void getStocks(char *blah) {
257 symbollist = cfg.readEntry("Symbols", ""); 257 symbollist = cfg.readEntry("Symbols", "");
258 symbollist.replace(QRegExp(" "),"+");//seperated by + 258 symbollist.replace(QRegExp(" "),"+");//seperated by +
259 259
260 cfg.setGroup("Timer"); 260 cfg.setGroup("Timer");
261 stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50)); 261 stocktickerTicker->setUpdateTime( cfg.readNumEntry("ScrollSpeed",50));
262 stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10)); 262 stocktickerTicker->setScrollLength( cfg.readNumEntry("ScrollLength",10));
263 263
264 if (!symbollist.isEmpty()) { 264 if (!symbollist.isEmpty()) {
265 pthread_t thread1; 265 pthread_t thread1;
266 char *blah = ::strdup(symbollist.latin1()); 266 char *blah = ::strdup(symbollist.latin1());
267 pthread_create( &thread1, NULL, (void * (*)(void *))getStocks, (void *) blah); 267 pthread_create( &thread1, NULL, (void * (*)(void *))getStocks, (void *) blah);
268 pthread_detach( thread1); 268 pthread_detach( thread1);
269 269
270 //::free((void*)thread1); 270 //::free((void*)thread1);
271 //getStocks(blah); 271 //getStocks(blah);
272 } 272 }
273 } 273 }
274 274
275 void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) { 275 void StockTickerPluginWidget::timerEvent( QTimerEvent *e ) {
276 killTimer(e->timerId()); 276 killTimer(e->timerId());
277 checkConnection(); 277 checkConnection();
278 } 278 }
279 279
280 void StockTickerPluginWidget::checkConnection() { 280 void StockTickerPluginWidget::checkConnection() {
281 // qDebug("checking connection"); 281 // odebug << "checking connection" << oendl;
282 // Sock = new QSocket( this ); 282 // Sock = new QSocket( this );
283 283
284 // if( wasError) 284 // if( wasError)
285 // stocktickerTicker->setText("Checking connection"); 285 // stocktickerTicker->setText("Checking connection");
286 286
287 // if(Sock->state() == QSocket::Idle) { 287 // if(Sock->state() == QSocket::Idle) {
288 // Sock->connectToHost("finance.yahoo.com", 80); 288 // Sock->connectToHost("finance.yahoo.com", 80);
289 // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) ); 289 // connect( Sock, SIGNAL( error(int) ), SLOT(socketError(int)) );
290 // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) ); 290 // connect( Sock, SIGNAL( hostFound() ), SLOT(isConnected()) );
291 // } else { 291 // } else {
292 // qDebug("State is not Idle"); 292 // odebug << "State is not Idle" << oendl;
293 isConnected(); 293 isConnected();
294 // } 294 // }
295 } 295 }
296 296
297 void StockTickerPluginWidget::isConnected() { 297 void StockTickerPluginWidget::isConnected() {
298 // qDebug("We connect, so ok to grab stocks"); 298 // odebug << "We connect, so ok to grab stocks" << oendl;
299 if(this->isVisible()) 299 if(this->isVisible())
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 // odebug << "timer set for " << (timerDelay*60000)/60000 << "" << oendl;
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 }