client: wob zip tzone elam
cd src && $(QMAKE) $(QMAKEFLAGS) && $(MAKE)
+ cd mainapp && $(QMAKE) $(QMAKEFLAGS) && $(MAKE)
zip:
cd zip && $(QMAKE) $(QMCFG) $(QMAKEFLAGS) && $(MAKE)
--- /dev/null
+#include "main.h"
+
+int main(int ac,char**av)
+{
+ return MApplication::main(ac,av);
+}
\ No newline at end of file
--- /dev/null
+#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\'
+}
-Subproject commit 01e32564337c5a177110bef33032b5b498375eda
+Subproject commit 4ccb7a2b5d235d5dadf502a82990fb77a467db78
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());
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());
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());
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"<<fd.fileName();
if(d->mprofiledoc.setContent(&fd))
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
-# 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
return lang;
}
-QString dataDir;
+static QString dataDir;
#include <stdlib.h>
-static void initDataDir()
+static inline void initDataDir()
{
#ifdef Q_OS_WIN32
dataDir=getenv("APPDATA");
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()
}
}
-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 <<QApplication::applicationDirPath() <<QLibraryInfo::location(QLibraryInfo::TranslationsPath);
for(int i=0;i<lpath.size();i++){
- bool ok=trans.load(prog+"_"+lang,lpath[i]);
+ bool ok=trans->load(prog+"_"+lang,lpath[i]);
QString msg=QString("...loading %1_%2 from %3 ...%4")
.arg(prog).arg(lang)
.arg(lpath[i])
}
}
-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();
/**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 <QApplication>
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<MApplication*>(qApp))
+
#endif
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
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)
#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 \
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
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")