From db8cddf85fc69e795cb3cf149a50c440f46d486f Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sun, 10 Mar 2013 14:50:25 +0100 Subject: [PATCH] change main project into DLL --- Makefile | 1 + mainapp/icon.ico | Bin 0 -> 9662 bytes mainapp/main.cpp | 6 ++ mainapp/mainapp.pro | 41 ++++++++++++++ pack | 2 +- src/dialogs/configdialog.cpp | 5 +- src/dialogs/orderauditdlg.cpp | 2 +- src/iface/msinterface.cpp | 4 +- src/images/icon.ico | Bin 9662 -> 0 bytes src/libs.pri | 10 ++-- src/main.cpp | 122 ++++++++++++++++++++++++----------------- src/main.h | 34 ++++++++++-- src/misc/debug.cpp | 1 + src/script/jsengine.cpp | 2 +- src/smoke.pro | 24 +------- 15 files changed, 164 insertions(+), 90 deletions(-) create mode 100644 mainapp/icon.ico create mode 100644 mainapp/main.cpp create mode 100644 mainapp/mainapp.pro delete mode 100644 src/images/icon.ico diff --git a/Makefile b/Makefile index e750ddf..0b03180 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,7 @@ server: wob client: wob zip tzone elam cd src && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) + cd mainapp && $(QMAKE) $(QMAKEFLAGS) && $(MAKE) zip: cd zip && $(QMAKE) $(QMCFG) $(QMAKEFLAGS) && $(MAKE) diff --git a/mainapp/icon.ico b/mainapp/icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..773f47f191881a434d3a500539579fe9fc456ddb GIT binary patch literal 9662 zcmeHNcT`tbw)Xus^XAP=OzavJdquFIf)!N6f;IMnVn;uug#w@-OpRvzv&P^wAdhR zpSHKy^qXBWhUP2LZP591%pa|f?F-D+Rl_guv~lEKun!|1xwiOO^nAoG*eUYvQ~V>^ z{aN9celnJPr^%<|e~R&++kfM;hF$Q>yi`TI7_p9(wmXdE8d`3r?TBg_w1 zPvqcQ(J@>u$ovQV@{MML=oLJ}+qKMryc4~mPjHJ}BBD?5%XgaprQh%M%d>{Hg*z=g zmG4@(`J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b/mainapp/main.cpp new file mode 100644 index 0000000..e0642ac --- /dev/null +++ b/mainapp/main.cpp @@ -0,0 +1,6 @@ +#include "main.h" + +int main(int ac,char**av) +{ + return MApplication::main(ac,av); +} \ No newline at end of file diff --git a/mainapp/mainapp.pro b/mainapp/mainapp.pro new file mode 100644 index 0000000..19b543d --- /dev/null +++ b/mainapp/mainapp.pro @@ -0,0 +1,41 @@ +#Project File for MagicSmoke +# (c) Konrad Rosenbaum, 2007-2011 + +TEMPLATE = app +TARGET = magicsmoke +DESTDIR = $$PWD/../bin + +#make sure the correct Qt DLLs are used +CONFIG += qt thread link_prl separate_debug_info +QT += xml network script scripttools +QT += widgets printsupport + +#add the icon for windoze +win32-* { + #RC-File containing the icon: + RC_FILE += win.rc +} + +#compilation output: +OBJECTS_DIR = .ctmp +MOC_DIR = .ctmp +RCC_DIR = .ctmp + +#main source files +SOURCES = main.cpp +INCLUDEPATH += . ../src + +#make sure dependencies are found +DEPENDPATH += $$INCLUDEPATH +LIBS += -L$$PWD/../bin -lmagicsmoke +include (../src/libs.pri) + +#security features +linux-g++* { + message("activating ASLR and friends") + QMAKE_CFLAGS += -fPIE + QMAKE_CXXFLAGS += -fPIE + QMAKE_LFLAGS += -pie + #make sure we find our libs + QMAKE_LFLAGS += -Wl,-rpath,\'\$$ORIGIN\' +} diff --git a/pack b/pack index 01e3256..4ccb7a2 160000 --- a/pack +++ b/pack @@ -1 +1 @@ -Subproject commit 01e32564337c5a177110bef33032b5b498375eda +Subproject commit 4ccb7a2b5d235d5dadf502a82990fb77a467db78 diff --git a/src/dialogs/configdialog.cpp b/src/dialogs/configdialog.cpp index afecf02..896bad9 100644 --- a/src/dialogs/configdialog.cpp +++ b/src/dialogs/configdialog.cpp @@ -224,6 +224,7 @@ void MConfigDialog::loadProfile() if(!idx.isValid())return; oldrow=idx.row(); QString key=profilemodel->data(idx,Qt::UserRole).toString(); + const QString&dataDir=MApplication::dataDir(); QSettings set; set.beginGroup("profiles/"+key); hostname->setText(set.value("hostname").toString()); @@ -239,7 +240,7 @@ void MConfigDialog::loadProfile() proxyuser->setEnabled(useproxy->isChecked()); proxypass->setEnabled(useproxy->isChecked()); username->setText(set.value("username").toString()); - sslexcept=new MSslExceptions(::dataDir+"/profile."+key+"/sslexceptions.xml"); + sslexcept=new MSslExceptions(dataDir+"/profile."+key+"/sslexceptions.xml"); sslFillModel(); abiscript->setChecked(set.value("script/allowbuiltin",true).toBool()); ausscript->setChecked(set.value("script/allowuser",false).toBool()); @@ -265,7 +266,7 @@ void MConfigDialog::saveProfile() set.setValue("proxyuser",proxyuser->text()); set.setValue("proxypass",proxypass->text()); set.setValue("username",username->text()); - QDir(::dataDir).mkdir("profile."+key); + QDir(MApplication::dataDir()).mkdir("profile."+key); if(sslexcept)sslexcept->savesslexcept(); set.setValue("script/allowbuiltin",abiscript->isChecked()); set.setValue("script/allowuser",ausscript->isChecked()); diff --git a/src/dialogs/orderauditdlg.cpp b/src/dialogs/orderauditdlg.cpp index 88c575f..96a5b55 100644 --- a/src/dialogs/orderauditdlg.cpp +++ b/src/dialogs/orderauditdlg.cpp @@ -263,7 +263,7 @@ void MOrderAuditDialog::calcPrices() void MOrderAuditDialog::getProfiles() { - QFile fd(dataDir+"/orderaudit.xml"); + QFile fd(MApplication::dataDir()+"/orderaudit.xml"); if(fd.exists() && fd.open(QIODevice::ReadOnly)){ qDebug()<<"loading main config"<mprofiledoc.setContent(&fd)) diff --git a/src/iface/msinterface.cpp b/src/iface/msinterface.cpp index 5df2fc1..6d1e0af 100644 --- a/src/iface/msinterface.cpp +++ b/src/iface/msinterface.cpp @@ -147,11 +147,11 @@ QMap MSInterface::headers(QString s)const QString MSInterface::dataDir()const { QString dd="profile."+profileid; - QDir dir(::dataDir); + QDir dir(MApplication::dataDir()); if(!dir.exists(dd)) if(!dir.mkpath(dd)) qDebug("Warning: oh dir! Can't create my data directory!"); - return ::dataDir+"/"+dd; + return MApplication::dataDir()+"/"+dd; } QString MSInterface::settingsGroup()const diff --git a/src/images/icon.ico b/src/images/icon.ico deleted file mode 100644 index 773f47f191881a434d3a500539579fe9fc456ddb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9662 zcmeHNcT`tbw)Xus^XAP=OzavJdquFIf)!N6f;IMnVn;uug#w@-OpRvzv&P^wAdhR zpSHKy^qXBWhUP2LZP591%pa|f?F-D+Rl_guv~lEKun!|1xwiOO^nAoG*eUYvQ~V>^ z{aN9celnJPr^%<|e~R&++kfM;hF$Q>yi`TI7_p9(wmXdE8d`3r?TBg_w1 zPvqcQ(J@>u$ovQV@{MML=oLJ}+qKMryc4~mPjHJ}BBD?5%XgaprQh%M%d>{Hg*z=g zmG4@(`J3ORP4tT%xeE3bCWgq42tY$w0Un<%!_(Sw-WRGdWnB42bco2k_)+*{(EiWr zD&uH+#3%AjY}4?|chXm`s*T@^ehq`Px8VQBxYTUY#@4WlZ{*uiU0Sdo4fR#npVn63 z&8>@gbF&`bU9SBn{DNDvK`Z@_1IG6m-_|?}kmf#cYGPZUVpN{F&G6#ZN^vPA)HGhl$HCwfDK8>B!K?ba5nCK-`4 zUbtD5qvEvr>N(=BBj+#T#ntn;Ra$_IaDQx^Ia$q>_)f+X5j>(#+T<#jrxU+Pm(~i8 z)@L-a8ZtJdpZH&}N}J4&hUHiM98<%p?BTQE*09SMf_;3qc34g9Y4qz=a^qgb2{e=E zZ*E+`^ZGMrtUHZ+RVPspy9d@^&BSa2U8Ps}CRi2rkN8E8j4Rjioj=2zo^2F9g_m=XRjdH4|qCvzZe+Oy!7 zXYs%ALz^41Ny97OXya+IrD31fw-eS*9;2{d%t^(CtYo~nbe7obnJX{hoBFf3S$+a1 z4#vRKY7N%UnTB<Dg923;v1Z zm$b?Ea&N?#7r)3jf?e9h&vMoLBxBDZ_RXe@)nNMlSSoH6AH%crl`2oZCiWLMFX4Vo z1*)=+AkxhdZd*2B_olUQ-MSG0jyr!HTXczj(I-9^TST8=7d;D!-Ev?j7=PJXaZUOz z>eF7~l=^dC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KEgUJXoy_vWJ)0PGWr;MO$QV8Nl@}deT6) z86ueLhxG9ot)uE$7mm4u`N4_jFg|7maGy6B7G@Kbzo+W;$5`UiYbU>(@i%aFj?nV| zMJPMCC)aELSB&i14&(ZCgYm##m_%Dl`JLI&ftYD91UrXxf*tdYgZO_0@lxMzUY$8F zvbMP}K74s5<-^$U9!*|xPcOE_aGw(<+#*&F)=fd2E7|wR8H?1ha^~X9Z-t+>tg*HZ zY!4frA=&VJNzQ*|&n+0`_h9k2+=~tJTY_eXJP-Puzc07t?@%3E!+>^-?%okbJ-c9R V@2(i%w>$pb{}=TC?f)4M{4e>FM&$qi diff --git a/src/libs.pri b/src/libs.pri index 41b1518..242e829 100644 --- a/src/libs.pri +++ b/src/libs.pri @@ -1,19 +1,19 @@ -# Libraries for Magic Smoke by (c) Konrad Rosenbaum, 2007-2010 +# Libraries for Magic Smoke by (c) Konrad Rosenbaum, 2007-2013 # ZIP library -LIBS += -L../zip -lQtZipHelper +LIBS += -lQtZipHelper INCLUDEPATH += ../zip/include # PACK library -LIBS += -L../pack/qtbase -lqwbase +LIBS += -lqwbase INCLUDEPATH += ../pack/qtbase/include # Time Zone DB library -LIBS += -L../tzone -lQtTzData +LIBS += -lQtTzData INCLUDEPATH += ../tzone/include # ELAM library -LIBS += -L../elam -lelam +LIBS += -lelam INCLUDEPATH += ../elam/include # Chester DPtr library diff --git a/src/main.cpp b/src/main.cpp index 3798b72..5d87374 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -67,11 +67,11 @@ QString choseLanguage(bool warn) return lang; } -QString dataDir; +static QString dataDir; #include -static void initDataDir() +static inline void initDataDir() { #ifdef Q_OS_WIN32 dataDir=getenv("APPDATA"); @@ -224,6 +224,22 @@ void MApplication::help(int idx) MApplication::MApplication(int&ac,char**av) :QApplication(ac,av) { + //locate settings + setOrganizationName("MagicSmoke"); + setApplicationName("MagicSmoke2"); + + //set icon + setWindowIcon(QIcon(":/icon.png")); + + //install event filter for random generator + installEventFilter(ef=new EFilter); + + //data directory + initDataDir(); + //initialize log file + initDebug(); + //init help menu layout + initHelpUrl(); } void MApplication::setMyStyle() @@ -240,12 +256,12 @@ void MApplication::setMyStyle() } } -static inline void loadTranslation(QTranslator&trans,const QString&lang,const QString&prog) +static inline void loadTranslation(QTranslator*trans,const QString&lang,const QString&prog) { QStringList lpath; lpath <load(prog+"_"+lang,lpath[i]); QString msg=QString("...loading %1_%2 from %3 ...%4") .arg(prog).arg(lang) .arg(lpath[i]) @@ -255,57 +271,61 @@ static inline void loadTranslation(QTranslator&trans,const QString&lang,const QS } } -int main(int argc,char**argv) +void MApplication::initLanguage() +{ + //try to find appropriate locale + QString lang=QSettings().value("lang","--").toString(); + if(lang=="--"){ + lang=choseLanguage(false); + } + qDebug("Loading language %s",lang.toLatin1().data()); + //load Qt translation + loadTranslation(qttrans=new QTranslator(this),lang,"qt"); + installTranslator(qttrans); + //load magicSmoke translation + loadTranslation(mstrans=new QTranslator(this),lang,"smoke"); + installTranslator(mstrans); + //defaults + if(lang!="--"&&lang!=""){ + QLocale::setDefault(lang); + setenv("LANG",lang.toLatin1().data(),1); + }else{ + setenv("LANG","C",1); + } +} + +void MApplication::initialize() +{ + setMyStyle(); + initLanguage(); + initProfile(); +} + +QString MApplication::dataDir() +{ + return ::dataDir; +} + +void MApplication::initProfile() +{ + //check/generate profile + if(!QSettings().childGroups().contains("profiles")){ + QMessageBox::warning(0,translate("initprofile","Initial Profile Warning"), translate("initprofile","You need a profile to work with Magic Smoke. Please create one now.")); + MConfigDialog().exec(); + } +} + + + +int MApplication::main(int argc,char**argv) { //create global app MApplication app(argc,argv); - //locate settings - app.setOrganizationName("MagicSmoke"); - app.setApplicationName("MagicSmoke2"); - - //set icon - app.setWindowIcon(QIcon(":/icon.png")); - - //set styling - app.setMyStyle(); - - //install event filter for random generator - EFilter ef; - app.installEventFilter(&ef); - - //try to find appropriate locale - QString lang=QSettings().value("lang","--").toString(); - if(lang=="--"){ - lang=choseLanguage(false); - } - QLocale::setDefault(QLocale(lang)); - qDebug("Loading language %s",lang.toLatin1().data()); - QTranslator qttrans; - loadTranslation(qttrans,lang,"qt"); - app.installTranslator(&qttrans); - QTranslator mstrans; - loadTranslation(mstrans,lang,"smoke"); - app.installTranslator(&mstrans); - if(lang!="--"&&lang!="") - QLocale::setDefault(lang); - - //try to find data dir - initDataDir(); - - //initialize log file - initDebug(); - - //init help menu layout - initHelpUrl(); - - //check/generate profile - if(!QSettings().childGroups().contains("profiles")){ - QMessageBox::warning(0,app.translate("initprofile","Initial Profile Warning"), app.translate("initprofile","You need a profile to work with Magic Smoke. Please create one now.")); - MConfigDialog().exec(); - } - - //open main window + //init + app.initialize(); + + //open main window MLogin mmw; mmw.show(); diff --git a/src/main.h b/src/main.h index 6b61c0d..b03a1f0 100644 --- a/src/main.h +++ b/src/main.h @@ -18,27 +18,51 @@ /**show a dialog to change the language*/ QString choseLanguage(bool warn=true); -/**contains the directory that is used for external data storage*/ -extern QString dataDir; #include class QMenu; +class EFilter; +///Main application object of MagicSmoke class MApplication:public QApplication { Q_OBJECT public: + ///create MagicSmoke application MApplication(int&ac,char**av); - void setMyStyle(); - + ///return the standard help menu static QMenu*helpMenu(); + + ///shortcut: the main function + static int main(int,char**); + /**contains the directory that is used for external data storage*/ + static QString dataDir(); public slots: - //help menu + ///complete initialization: style, language, data dir + void initialize(); + ///set the configured application style + void setMyStyle(); + ///initialize the localization + void initLanguage(); + ///initialize the profiles + void initProfile(); + + ///show about dialog void aboutMS(); + ///show version info void versionDlg(); + ///start a browser with the help page void help(); + private slots: + ///jump to a specific help page void help(int); + + private: + EFilter *ef; + QTranslator*qttrans,*mstrans; }; +#define mApp (qobject_cast(qApp)) + #endif diff --git a/src/misc/debug.cpp b/src/misc/debug.cpp index 6d1aa49..f2f92a8 100644 --- a/src/misc/debug.cpp +++ b/src/misc/debug.cpp @@ -39,6 +39,7 @@ void initDebug() qDebug()<<"-nolog argument was given, will not create a log file"; } //create new log file + const QString&dataDir=MApplication::dataDir(); QDir(dataDir).mkpath("debuglog"); mylogFile=new QFile(dataDir+"/debuglog/log-"+QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss.zzz")+".txt"); //...open it diff --git a/src/script/jsengine.cpp b/src/script/jsengine.cpp index 8bacc8e..c482c2b 100644 --- a/src/script/jsengine.cpp +++ b/src/script/jsengine.cpp @@ -194,7 +194,7 @@ void MScriptEngine::initScriptPath() if(set.value("allowbuiltin",true).toBool()) paths.insert(set.value("priobuiltin",10).toInt(),":/scripts"); if(set.value("allowuser",false).toBool()) - paths.insert(set.value("priouser",0).toInt(), set.value("userpath",dataDir+"/userscripts").toString()); + paths.insert(set.value("priouser",0).toInt(), set.value("userpath",MApplication::dataDir()+"/userscripts").toString()); bool allowserver=set.value("allowserver",false).toBool(); QString mydir=req->dataDir()+"/scripts"; if(allowserver) diff --git a/src/smoke.pro b/src/smoke.pro index 5607d58..bdf69f3 100644 --- a/src/smoke.pro +++ b/src/smoke.pro @@ -1,14 +1,10 @@ #Project File for MagicSmoke -# (c) Konrad Rosenbaum, 2007-2011 +# (c) Konrad Rosenbaum, 2007-2013 -TEMPLATE = app +TEMPLATE = lib TARGET = magicsmoke DESTDIR = $$PWD/../bin -#build for debug or release? -#CONFIG += release -CONFIG += debug - #Localization TRANSLATIONS = \ smoke_de.ts \ @@ -20,12 +16,6 @@ CONFIG += qt thread link_prl separate_debug_info QT += xml network script scripttools QT += widgets printsupport -#add the icon for windoze -win32-* { - #RC-File containing the icon: - RC_FILE += win.rc -} - #compilation output: OBJECTS_DIR = .ctmp MOC_DIR = .ctmp @@ -58,16 +48,6 @@ include(wob/wob.pri) DEPENDPATH += $$INCLUDEPATH LIBS += -L$$PWD/../bin -#security features -linux-g++* { - message("activating ASLR and friends") - QMAKE_CFLAGS += -fPIE - QMAKE_CXXFLAGS += -fPIE - QMAKE_LFLAGS += -pie - #make sure we find our libs - QMAKE_LFLAGS += -Wl,-rpath,\'\$$ORIGIN\' -} - #activate C++11 for g++ gcc { message("detected GCC, activating C++11 with GNU extensions") -- 1.7.2.5