00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "Config.h"
00023 #include "UpgradeMessage.h"
00024 #include "TALIB.h"
00025 #include "BARS.h"
00026 #include "CUS.h"
00027 #include "ExScript.h"
00028 #include "FI.h"
00029 #include "LMS.h"
00030 #include "LOWPASS.h"
00031 #include "PP.h"
00032 #include "SINWAV.h"
00033 #include "SZ.h"
00034 #include "THERM.h"
00035 #include "VFI.h"
00036 #include "VIDYA.h"
00037 #include "VOL.h"
00038 #include "UTIL.h"
00039 #include "SYMBOL.h"
00040 #include <qobject.h>
00041 #include <qdir.h>
00042 #include <qlibrary.h>
00043 #include <qsettings.h>
00044 #include <qobject.h>
00045 #include <qfile.h>
00046 #include <qtextstream.h>
00047 #include <qapplication.h>
00048 #include <qfileinfo.h>
00049 #include <stdlib.h>
00050
00051 Config::Config ()
00052 {
00053 libs.setAutoDelete(TRUE);
00054 indicatorPlugins.setAutoDelete(TRUE);
00055 quotePlugins.setAutoDelete(TRUE);
00056 version = "0.36";
00057
00058 TALIB t;
00059 t.getIndicatorList(indicatorList);
00060
00061 indicatorList2.append("BARS");
00062 indicatorList2.append("CUS");
00063 indicatorList2.append("ExScript");
00064 indicatorList2.append("FI");
00065 indicatorList2.append("LMS");
00066 indicatorList2.append("LOWPASS");
00067 indicatorList2.append("PP");
00068 indicatorList2.append("SINWAV");
00069 indicatorList2.append("SZ");
00070 indicatorList2.append("THERM");
00071 indicatorList2.append("VFI");
00072 indicatorList2.append("VIDYA");
00073 indicatorList2.append("VOL");
00074
00075 int loop;
00076 for (loop = 0; loop < (int) indicatorList2.count(); loop++)
00077 indicatorList.append(indicatorList2[loop]);
00078
00079 indicatorList.sort();
00080 }
00081
00082 Config::~Config ()
00083 {
00084 indicatorPlugins.clear();
00085 quotePlugins.clear();
00086 libs.clear();
00087 }
00088
00089 void Config::setup ()
00090 {
00091
00092
00093 QDir dir(QDir::homeDirPath());
00094 dir.convertToAbs();
00095 QString home = dir.absPath();
00096 home.append("/.qtstalker");
00097 if (! dir.exists(home, TRUE))
00098 {
00099 if (! dir.mkdir(home, TRUE))
00100 qDebug("Unable to create ~/.qtstalker directory.");
00101 }
00102 home.append("/data1");
00103 if (! dir.exists(home, TRUE))
00104 {
00105 if (! dir.mkdir(home, TRUE))
00106 qDebug("Unable to create ~/.qtstalker/data1 directory.");
00107 }
00108 rcfile.saveData(RcFile::Home, home);
00109
00110 QString s = home + "/index";
00111 if (! dir.exists(s, TRUE))
00112 {
00113 if (! dir.mkdir(s, TRUE))
00114 qDebug("Unable to create ~/.qtstalker/data1/index directory.");
00115 }
00116 s = home + "/index/index.db";
00117 rcfile.saveData(RcFile::IndexPath, s);
00118 s = home + "/index/co.db";
00119 rcfile.saveData(RcFile::COPath, s);
00120 s = home + "/index/li.db";
00121 rcfile.saveData(RcFile::LocalIndicatorsPath, s);
00122 s = home + "/index/fund.db";
00123 rcfile.saveData(RcFile::FundamentalsPath, s);
00124
00125 s = home + "/data";
00126 if (! dir.exists(s, TRUE))
00127 {
00128 if (! dir.mkdir(s, TRUE))
00129 qDebug("Unable to create ~/.qtstalker/data1/data directory.");
00130 }
00131 rcfile.saveData(RcFile::DataPath, s);
00132
00133 s = home + "/group";
00134 if (! dir.exists(s, TRUE))
00135 {
00136 if (! dir.mkdir(s, TRUE))
00137 qDebug("Unable to create ~/.qtstalker/data1/group directory.");
00138 }
00139 rcfile.saveData(RcFile::GroupPath, s);
00140
00141 s = home + "/portfolio";
00142 if (! dir.exists(s, TRUE))
00143 {
00144 if (! dir.mkdir(s, TRUE))
00145 qDebug("Unable to create ~/.qtstalker/data1/portfolio directory.");
00146 }
00147 rcfile.saveData(RcFile::PortfolioPath, s);
00148
00149 s = home + "/test";
00150 if (! dir.exists(s, TRUE))
00151 {
00152 if (! dir.mkdir(s, TRUE))
00153 qDebug("Unable to create ~/.qtstalker/data1/test directory.");
00154 }
00155 rcfile.saveData(RcFile::TestPath, s);
00156
00157 s = home + "/scanner";
00158 if (! dir.exists(s, TRUE))
00159 {
00160 if (! dir.mkdir(s, TRUE))
00161 qDebug("Unable to create ~/.qtstalker/data1/scanner directory.");
00162 }
00163 rcfile.saveData(RcFile::ScannerPath, s);
00164
00165 s = home + "/indicator";
00166 if (! dir.exists(s, TRUE))
00167 {
00168 if (! dir.mkdir(s, TRUE))
00169 qDebug("Unable to create ~/.qtstalker/data1/indicator directory.");
00170 }
00171 rcfile.saveData(RcFile::IndicatorPath, s);
00172
00173 s = home + "/indicator/Indicators";
00174 if (! dir.exists(s, TRUE))
00175 {
00176 if (! dir.mkdir(s, TRUE))
00177 qDebug("Unable to create ~/.qtstalker/data1/indicator/Indicators directory.");
00178 else
00179 {
00180 QString str("Indicators");
00181 rcfile.saveData(RcFile::IndicatorGroup, str);
00182 QString ts = "cp /usr/local/share/qtstalker/indicator/* " + s;
00183 if (system(ts.latin1()))
00184 qDebug("setDefaultIndicators::copyFiles: error copying examples indicator files");
00185 }
00186 }
00187
00188 s = home + "/plugin";
00189 if (! dir.exists(s, TRUE))
00190 {
00191 if (! dir.mkdir(s, TRUE))
00192 qDebug("Unable to create ~/.qtstalker/data1/plugin directory.");
00193 }
00194
00195 s.append("/quote");
00196 if (! dir.exists(s, TRUE))
00197 {
00198 if (! dir.mkdir(s, TRUE))
00199 qDebug("Unable to create ~/.qtstalker/data1/plugin/quote directory.");
00200 }
00201 rcfile.saveData(RcFile::QuotePluginStorage, s);
00202
00203 s = home + "/docs";
00204 if (! dir.exists(s, TRUE))
00205 {
00206 if (! dir.mkdir(s, TRUE))
00207 qDebug("Unable to create ~/.qtstalker/data1/docs directory.");
00208 }
00209 rcfile.saveData(RcFile::UserDocsPath, s);
00210 s.append("/indicator");
00211 if (! dir.exists(s, TRUE))
00212 {
00213 if (! dir.mkdir(s, TRUE))
00214 qDebug("Unable to create ~/.qtstalker/data1/docs/indicator directory.");
00215 }
00216
00217 check034Conversion();
00218
00219
00220 rcfile.saveData(RcFile::Version, version);
00221 }
00222
00223 void Config::getData (Parm p, QString &s)
00224 {
00225 QSettings settings;
00226
00227 s.truncate(0);
00228 switch (p)
00229 {
00230 case Home:
00231 s = settings.readEntry("/Qtstalker/Home");
00232 break;
00233 case DataPath:
00234 s = settings.readEntry("/Qtstalker/DataPath");
00235 break;
00236 case GroupPath:
00237 s = settings.readEntry("/Qtstalker/GroupPath");
00238 break;
00239 case PortfolioPath:
00240 s = settings.readEntry("/Qtstalker/PortfolioPath");
00241 break;
00242 case TestPath:
00243 s = settings.readEntry("/Qtstalker/TestPath");
00244 break;
00245 case ScannerPath:
00246 s = settings.readEntry("/Qtstalker/ScannerPath");
00247 break;
00248 case IndicatorPath:
00249 s = settings.readEntry("/Qtstalker/IndicatorPath");
00250 break;
00251 case BarLength:
00252 s = settings.readEntry("/Qtstalker/Compression", "6");
00253 break;
00254 case Grid:
00255 s = settings.readEntry("/Qtstalker/Grid", "1");
00256 break;
00257 case Bars:
00258 s = settings.readEntry("/Qtstalker/Bars", "275");
00259 break;
00260 case BackgroundColor:
00261 s = settings.readEntry("/Qtstalker/BackgroundColor", "black");
00262 break;
00263 case BorderColor:
00264 s = settings.readEntry("/Qtstalker/BorderColor", "white");
00265 break;
00266 case GridColor:
00267 s = settings.readEntry("/Qtstalker/GridColor", "#626262");
00268 break;
00269 case ScaleToScreen:
00270 s = settings.readEntry("/Qtstalker/ScaleToScreen", "1");
00271 break;
00272 case QuotePluginPath:
00273 s = settings.readEntry("/Qtstalker/QuotePluginPath", "/usr/local/lib/qtstalker/quote");
00274 break;
00275 case Group:
00276 s = settings.readEntry("/Qtstalker/Group");
00277 break;
00278 case PlotFont:
00279 s = settings.readEntry("/Qtstalker/PlotFont");
00280 break;
00281 case AppFont:
00282 s = settings.readEntry("/Qtstalker/AppFont");
00283 break;
00284 case NavAreaSize:
00285 s = settings.readEntry("/Qtstalker/NavAreaSize", "20");
00286 break;
00287 case LogScale:
00288 s = settings.readEntry("/Qtstalker/LogScale", "0");
00289 break;
00290 case Height:
00291 s = settings.readEntry("/Qtstalker/Height", "640");
00292 break;
00293 case Width:
00294 s = settings.readEntry("/Qtstalker/Width", "480");
00295 break;
00296 case X:
00297 s = settings.readEntry("/Qtstalker/X", "0");
00298 break;
00299 case Y:
00300 s = settings.readEntry("/Qtstalker/Y", "0");
00301 break;
00302 case Crosshairs:
00303 s = settings.readEntry("/Qtstalker/Crosshairs", "1");
00304 break;
00305 case DrawMode:
00306 s = settings.readEntry("/Qtstalker/DrawMode", "0");
00307 break;
00308 case HelpFilePath:
00309 s = settings.readEntry("/Qtstalker/HelpFilePath", "/usr/local/share/doc/qtstalker/html");
00310 break;
00311 case UserDocsPath:
00312 s = settings.readEntry("/Qtstalker/UserDocsPath");
00313 break;
00314 case LastQuotePlugin:
00315 s = settings.readEntry("/Qtstalker/LastQuotePlugin");
00316 break;
00317 case PlotSizes:
00318 s = settings.readEntry("/Qtstalker/PlotSizes");
00319 break;
00320 case DataPanelSize:
00321 s = settings.readEntry("/Qtstalker/DataPanelSize");
00322 break;
00323 case Menubar:
00324 s = settings.readEntry("/Qtstalker/Menubar", "1");
00325 break;
00326 case IndicatorGroup:
00327 s = settings.readEntry("/Qtstalker/IndicatorGroup", "Indicators");
00328 break;
00329 case QuotePluginStorage:
00330 s = settings.readEntry("/Qtstalker/QuotePluginStorage");
00331 break;
00332 case Version:
00333 s = settings.readEntry("/Qtstalker/Version");
00334 break;
00335 case ShowUpgradeMessage:
00336 s = settings.readEntry("/Qtstalker/ShowUpgradeMessage", "1");
00337 break;
00338 case LastNewIndicator:
00339 s = settings.readEntry("/Qtstalker/LastNewIndicator", "MA");
00340 break;
00341 case PaperTradeMode:
00342 s = settings.readEntry("/Qtstalker/PaperTradeMode", "0");
00343 break;
00344 case Pixelspace:
00345 s = settings.readEntry("/Qtstalker/Pixelspace", "4");
00346 break;
00347 case PS1Button:
00348 s = settings.readEntry("/Qtstalker/PS1Button", "4");
00349 break;
00350 case PS2Button:
00351 s = settings.readEntry("/Qtstalker/PS2Button", "4");
00352 break;
00353 case PS3Button:
00354 s = settings.readEntry("/Qtstalker/PS3Button", "4");
00355 break;
00356 case IndexPath:
00357 s = settings.readEntry("/Qtstalker/IndexPath");
00358 break;
00359 case COPath:
00360 s = settings.readEntry("/Qtstalker/COPath");
00361 break;
00362 case LocalIndicatorsPath:
00363 s = settings.readEntry("/Qtstalker/LocalIndicatorsPath");
00364 break;
00365 case FundamentalsPath:
00366 s = settings.readEntry("/Qtstalker/FundamentalsPath");
00367 break;
00368 case CurrentChart:
00369 s = settings.readEntry("/Qtstalker/CurrentChart");
00370 break;
00371 default:
00372 break;
00373 }
00374 }
00375
00376 void Config::getData (QString &p, QString &s)
00377 {
00378 QSettings settings;
00379 s = settings.readEntry("/Qtstalker/" + p);
00380 }
00381
00382 void Config::setData (Parm p, QString &d)
00383 {
00384 QSettings settings;
00385
00386 switch (p)
00387 {
00388 case Home:
00389 settings.writeEntry("/Qtstalker/Home", d);
00390 break;
00391 case DataPath:
00392 settings.writeEntry("/Qtstalker/DataPath", d);
00393 break;
00394 case GroupPath:
00395 settings.writeEntry("/Qtstalker/GroupPath", d);
00396 break;
00397 case PortfolioPath:
00398 settings.writeEntry("/Qtstalker/PortfolioPath", d);
00399 break;
00400 case TestPath:
00401 settings.writeEntry("/Qtstalker/TestPath", d);
00402 break;
00403 case ScannerPath:
00404 settings.writeEntry("/Qtstalker/ScannerPath", d);
00405 break;
00406 case IndicatorPath:
00407 settings.writeEntry("/Qtstalker/IndicatorPath", d);
00408 break;
00409 case BarLength:
00410 settings.writeEntry("/Qtstalker/Compression", d);
00411 break;
00412 case Grid:
00413 settings.writeEntry("/Qtstalker/Grid", d);
00414 break;
00415 case Bars:
00416 settings.writeEntry("/Qtstalker/Bars", d);
00417 break;
00418 case BackgroundColor:
00419 settings.writeEntry("/Qtstalker/BackgroundColor", d);
00420 break;
00421 case BorderColor:
00422 settings.writeEntry("/Qtstalker/BorderColor", d);
00423 break;
00424 case GridColor:
00425 settings.writeEntry("/Qtstalker/GridColor", d);
00426 break;
00427 case ScaleToScreen:
00428 settings.writeEntry("/Qtstalker/ScaleToScreen", d);
00429 break;
00430 case QuotePluginPath:
00431 settings.writeEntry("/Qtstalker/QuotePluginPath", d);
00432 break;
00433 case Group:
00434 settings.writeEntry("/Qtstalker/Group", d);
00435 break;
00436 case PlotFont:
00437 settings.writeEntry("/Qtstalker/PlotFont", d);
00438 break;
00439 case AppFont:
00440 settings.writeEntry("/Qtstalker/AppFont", d);
00441 break;
00442 case NavAreaSize:
00443 settings.writeEntry("/Qtstalker/NavAreaSize", d);
00444 break;
00445 case LogScale:
00446 settings.writeEntry("/Qtstalker/LogScale", d);
00447 break;
00448 case Height:
00449 settings.writeEntry("/Qtstalker/Height", d);
00450 break;
00451 case Width:
00452 settings.writeEntry("/Qtstalker/Width", d);
00453 break;
00454 case X:
00455 settings.writeEntry("/Qtstalker/X", d);
00456 break;
00457 case Y:
00458 settings.writeEntry("/Qtstalker/Y", d);
00459 break;
00460 case Crosshairs:
00461 settings.writeEntry("/Qtstalker/Crosshairs", d);
00462 break;
00463 case DrawMode:
00464 settings.writeEntry("/Qtstalker/DrawMode", d);
00465 break;
00466 case HelpFilePath:
00467 settings.writeEntry("/Qtstalker/HelpFilePath", d);
00468 break;
00469 case UserDocsPath:
00470 settings.writeEntry("/Qtstalker/UserDocsPath", d);
00471 break;
00472 case LastQuotePlugin:
00473 settings.writeEntry("/Qtstalker/LastQuotePlugin", d);
00474 break;
00475 case PlotSizes:
00476 settings.writeEntry("/Qtstalker/PlotSizes", d);
00477 break;
00478 case DataPanelSize:
00479 settings.writeEntry("/Qtstalker/DataPanelSize", d);
00480 break;
00481 case Menubar:
00482 settings.writeEntry("/Qtstalker/Menubar", d);
00483 break;
00484 case IndicatorGroup:
00485 settings.writeEntry("/Qtstalker/IndicatorGroup", d);
00486 break;
00487 case QuotePluginStorage:
00488 settings.writeEntry("/Qtstalker/QuotePluginStorage", d);
00489 break;
00490 case Version:
00491 settings.writeEntry("/Qtstalker/Version", d);
00492 break;
00493 case ShowUpgradeMessage:
00494 settings.writeEntry("/Qtstalker/ShowUpgradeMessage", d);
00495 break;
00496 case LastNewIndicator:
00497 settings.writeEntry("/Qtstalker/LastNewIndicator", d);
00498 break;
00499 case PaperTradeMode:
00500 settings.writeEntry("/Qtstalker/PaperTradeMode", d);
00501 break;
00502 case Pixelspace:
00503 settings.writeEntry("/Qtstalker/Pixelspace", d);
00504 break;
00505 case PS1Button:
00506 settings.writeEntry("/Qtstalker/PS1Button", d);
00507 break;
00508 case PS2Button:
00509 settings.writeEntry("/Qtstalker/PS2Button", d);
00510 break;
00511 case PS3Button:
00512 settings.writeEntry("/Qtstalker/PS3Button", d);
00513 break;
00514 case IndexPath:
00515 settings.writeEntry("/Qtstalker/IndexPath", d);
00516 break;
00517 case COPath:
00518 settings.writeEntry("/Qtstalker/COPath", d);
00519 break;
00520 case LocalIndicatorsPath:
00521 settings.writeEntry("/Qtstalker/LocalIndicatorsPath", d);
00522 break;
00523 case FundamentalsPath:
00524 settings.writeEntry("/Qtstalker/FundamentalsPath", d);
00525 break;
00526 case CurrentChart:
00527 settings.writeEntry("/Qtstalker/CurrentChart", d);
00528 break;
00529 default:
00530 break;
00531 }
00532 }
00533
00534 void Config::setData (QString &p, QString &d)
00535 {
00536 QSettings settings;
00537 settings.writeEntry("/Qtstalker/" + p, d);
00538 }
00539
00540 void Config::loadSplitterSize (Parm p, QSplitter *sp)
00541 {
00542 QString s;
00543 getData(p, s);
00544
00545 QStringList stringList = QStringList::split(",", s, FALSE);
00546 QValueList<int> sizeList = sp->sizes();
00547
00548 int loop;
00549 for (loop = 0; loop < (int) stringList.count(); loop++)
00550 sizeList[loop] = stringList[loop].toInt();
00551
00552 sp->setSizes(sizeList);
00553 }
00554
00555 void Config::saveSplitterSize (Parm p, QSplitter *sp)
00556 {
00557 QStringList stringList;
00558 QValueList<int> sizeList = sp->sizes();
00559
00560 int loop;
00561 for (loop = 0; loop < (int) sizeList.count(); loop++)
00562 stringList.append(QString::number(sizeList[loop]));
00563
00564 QString s(stringList.join(","));
00565 setData(p,s);
00566 }
00567
00568 void Config::getIndicators (QString &d, QStringList &l)
00569 {
00570 QString s;
00571 getData(IndicatorPath, s);
00572 s.append("/" + d);
00573 l.clear();
00574 getDirList(s, TRUE, l);
00575 }
00576
00577 void Config::getIndicator (QString &d, Setting &set)
00578 {
00579 QFile f(d);
00580 if (! f.open(IO_ReadOnly))
00581 {
00582 qDebug("Config::getIndicator:can't open indicator file %s", d.latin1());
00583 return;
00584 }
00585 QTextStream stream(&f);
00586
00587 while(stream.atEnd() == 0)
00588 {
00589 QString s = stream.readLine();
00590 s = s.stripWhiteSpace();
00591 if (! s.length())
00592 continue;
00593
00594 QStringList l = QStringList::split("=", s, FALSE);
00595 if (l.count() < 2)
00596 continue;
00597
00598 s = s.remove(0, l[0].length() + 1);
00599 set.setData(l[0], s);
00600 }
00601
00602 f.close();
00603 }
00604
00605 void Config::setIndicator (QString &d, Setting &set)
00606 {
00607 QFile f(d);
00608 if (! f.open(IO_WriteOnly))
00609 {
00610 qDebug("Config::setIndicator:can't write to indicator file %s", d.latin1());
00611 return;
00612 }
00613 QTextStream stream(&f);
00614
00615 int loop;
00616 QStringList l;
00617 set.getKeyList(l);
00618 QString k;
00619 for (loop = 0; loop < (int) l.count(); loop++)
00620 {
00621 set.getData(l[loop], k);
00622 stream << l[loop] << "=" << k << "\n";
00623 }
00624
00625 f.close();
00626 }
00627
00628 void Config::deleteIndicator (QString &d)
00629 {
00630 QDir dir;
00631 dir.remove(d);
00632 }
00633
00634 void Config::getDirList (QString &path, bool flag, QStringList &l)
00635 {
00636 l.clear();
00637 QDir dir(path);
00638
00639 int loop;
00640 for (loop = 2; loop < (int) dir.count(); loop++)
00641 {
00642 QString s = dir.absPath() + "/" + dir[loop];
00643 QFileInfo fi(s);
00644 if (! fi.isDir())
00645 {
00646 if (flag)
00647 l.append(fi.absFilePath());
00648 else
00649 l.append(dir[loop]);
00650 }
00651 }
00652 }
00653
00654 void Config::getPluginList (Config::Parm d, QStringList &l2)
00655 {
00656 l2.clear();
00657 QStringList l;
00658 QString s;
00659 getData(d, s);
00660 getDirList(s, TRUE, l);
00661
00662 if (! l.count())
00663 return;
00664
00665 int loop;
00666 for (loop = 0; loop < (int) l.count(); loop++)
00667 {
00668 QFileInfo fi(l[loop]);
00669 if (! fi.fileName().contains(version))
00670 {
00671 qDebug("Config::getPluginList:wrong plugin version: %s , I need version %s",fi.fileName().ascii(), version.ascii());
00672 continue;
00673 }
00674
00675 s = fi.baseName(FALSE);
00676 s.remove(0, 3);
00677 l2.append(s);
00678 }
00679 }
00680
00681 void Config::getIndicatorList (QStringList &l)
00682 {
00683 l = indicatorList;
00684 }
00685
00686 IndicatorPlugin * Config::getIndicatorPlugin (QString &p)
00687 {
00688 IndicatorPlugin *plug = indicatorPlugins[p];
00689 if (plug)
00690 return plug;
00691
00692 int i = indicatorList2.findIndex(p);
00693 switch (i)
00694 {
00695 case Config_BARS:
00696 plug = new BARS;
00697 break;
00698 case Config_CUS:
00699 plug = new CUS;
00700 break;
00701 case Config_ExScript:
00702 plug = new ExScript;
00703 break;
00704 case Config_FI:
00705 plug = new FI;
00706 break;
00707 case Config_LMS:
00708 plug = new LMS;
00709 break;
00710 case Config_LOWPASS:
00711 plug = new LOWPASS;
00712 break;
00713 case Config_PP:
00714 plug = new PP;
00715 break;
00716 case Config_SINWAV:
00717 plug = new SINWAV;
00718 break;
00719 case Config_SZ:
00720 plug = new SZ;
00721 break;
00722 case Config_THERM:
00723 plug = new THERM;
00724 break;
00725 case Config_VFI:
00726 plug = new VFI;
00727 break;
00728 case Config_VIDYA:
00729 plug = new VIDYA;
00730 break;
00731 case Config_VOL:
00732 plug = new VOL;
00733 break;
00734 default:
00735 if (! p.compare("UTIL"))
00736 plug = new UTIL;
00737 else
00738 {
00739 if (! p.compare("SYMBOL"))
00740 plug = new SYMBOL;
00741 else
00742 plug = new TALIB;
00743 }
00744 break;
00745 }
00746
00747 if (! plug)
00748 qDebug("%s", p.latin1());
00749 else
00750 indicatorPlugins.replace(p, plug);
00751 return plug;
00752 }
00753
00754 QuotePlugin * Config::getQuotePlugin (QString &p)
00755 {
00756 QuotePlugin *plug = quotePlugins[p];
00757 if (plug)
00758 return plug;
00759
00760 QString s;
00761 getData(QuotePluginPath, s);
00762 s.append("/lib" + p + "." + version);
00763
00764 QLibrary *lib = new QLibrary(s);
00765 QuotePlugin *(*so)() = 0;
00766 so = (QuotePlugin *(*)()) lib->resolve("createQuotePlugin");
00767 if (so)
00768 {
00769 plug = (*so)();
00770 libs.replace(p, lib);
00771 quotePlugins.replace(p, plug);
00772 return plug;
00773 }
00774 else
00775 {
00776 qDebug("Config::getQuotePlugin:%s Dll error\n", s.latin1());
00777 delete lib;
00778 return 0;
00779 }
00780 }
00781
00782 void Config::closePlugins ()
00783 {
00784 indicatorPlugins.clear();
00785 quotePlugins.clear();
00786 libs.clear();
00787 }
00788
00789 void Config::closePlugin (QString &d)
00790 {
00791 indicatorPlugins.remove(d);
00792 quotePlugins.remove(d);
00793 libs.remove(d);
00794 }
00795
00796 void Config::copyIndicatorFile (QString &d, QString &d2)
00797 {
00798 QFile f(d);
00799 if (! f.open(IO_ReadOnly))
00800 {
00801 qDebug("Config::copyFile:can't open input file %s", d.latin1());
00802 return;
00803 }
00804 QTextStream stream(&f);
00805
00806 QFile f2(d2);
00807 if (! f2.open(IO_WriteOnly))
00808 {
00809 qDebug("Config::copyFile:can't open output file %s", d2.latin1());
00810 f.close();
00811 return;
00812 }
00813 QTextStream stream2(&f2);
00814
00815 while(stream.atEnd() == 0)
00816 {
00817 QString s = stream.readLine();
00818 stream2 << s << "\n";
00819 }
00820 stream2 << "enable=1\n";
00821
00822 f.close();
00823 f2.close();
00824 }
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866 void Config::check034Conversion ()
00867 {
00868 QString s;
00869 rcfile.loadData(RcFile::Version, s);
00870 if (! s.length())
00871 return;
00872
00873 if (s.toDouble() >= 0.34)
00874 return;
00875
00876 UpgradeMessage *dialog = new UpgradeMessage(UpgradeMessage::V034);
00877 dialog->exec();
00878 delete dialog;
00879 }
00880