From: Enar Väikene Date: Wed, 27 Jul 2011 07:51:25 +0000 (+0300) Subject: Merged the Common::iEnv interface into Common::iApp X-Git-Url: https://vaikene.ee/gitweb/pswgen07.html?a=commitdiff_plain;h=be0e791df48f5a8c9bb4c16f65b62e41e1149552;p=evaf Merged the Common::iEnv interface into Common::iApp We had a chicken-egg problem here where functions in the iApp interface depended on the iEnv interface and vice versa. The easiest solution was to merge them into one. --- diff --git a/src/apps/PswGen/Storage/module.cpp b/src/apps/PswGen/Storage/module.cpp index ab591b7..e867a0e 100644 --- a/src/apps/PswGen/Storage/module.cpp +++ b/src/apps/PswGen/Storage/module.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -108,7 +108,7 @@ bool StorageImpl::init() if (!QSqlDatabase::contains(DbConnectionName)) { // No database connection yet mDb = QSqlDatabase::addDatabase("QSQLITE", DbConnectionName); - mDb.setDatabaseName(Common::iEnv::instance()->dataRootDir() + DbName); + mDb.setDatabaseName(Common::iApp::instance()->dataRootDir() + DbName); if (!mDb.open()) { QSqlError err = mDb.lastError(); EVAF_ERROR("Failed to open database : %s", qPrintable(err.text())); diff --git a/src/libs/Common/CMakeLists.txt b/src/libs/Common/CMakeLists.txt index 83b5cd6..31fc634 100644 --- a/src/libs/Common/CMakeLists.txt +++ b/src/libs/Common/CMakeLists.txt @@ -17,7 +17,6 @@ set(eVaf_LIBRARIES) # Source files set(SRCS app.cpp - env.cpp event.cpp eventqueue.cpp globals.cpp @@ -29,12 +28,10 @@ set(SRCS # Header files for the meta-object compiler set(MOC_HDRS iapp.h - ienv.h ieventqueue.h ilogger.h iregistry.h app.h - env.h eventqueue.h logger.h registry.h diff --git a/src/libs/Common/app.cpp b/src/libs/Common/app.cpp index 3956548..53efce9 100644 --- a/src/libs/Common/app.cpp +++ b/src/libs/Common/app.cpp @@ -20,7 +20,6 @@ #include "app.h" #include "globals.h" #include "registry.h" -#include "ienv.h" #include "version.h" #include @@ -71,6 +70,24 @@ bool App::init() // Clear the XML file name mXmlFile.clear(); + // Set initial bin and root directories + mRootDir = mBinDir = qApp->applicationDirPath(); + int t = mBinDir.lastIndexOf(QChar('/'), -1); + if (t >= 0) + mRootDir = mBinDir.left(t); + + if (!mBinDir.endsWith('/')) + mBinDir.append('/'); + if (!mRootDir.endsWith('/')) + mRootDir.append('/'); + + // Clear other directories + mDataRootDir.clear(); + mQtPluginsDir.clear(); + mEtcDir.clear(); + mLogDir.clear(); + mDocDir.clear(); + // Process environment variables QStringList env = QProcess::systemEnvironment(); for (int i = 0; i < env.size(); ++i) { @@ -82,6 +99,36 @@ bool App::init() mName = value; else if (name == "EVAF_LANGUAGE") mLanguage = value; + else if (name == "EVAF_ROOT_DIR") { + mRootDir = value; + if (!mRootDir.endsWith('/')) + mRootDir.append('/'); + } + else if (name == "EVAF_DATA_ROOT_DIR") { + mDataRootDir = value; + if (!mDataRootDir.endsWith('/')) + mDataRootDir.append('/'); + } + else if (name == "EVAF_ETC_DIR") { + mEtcDir = value; + if (!mEtcDir.endsWith('/')) + mEtcDir.append('/'); + } + else if (name == "EVAF_LOG_DIR") { + mLogDir = value; + if (!mLogDir.endsWith('/')) + mLogDir.append('/'); + } + else if (name == "EVAF_DOC_DIR") { + mDocDir = value; + if (!mDocDir.endsWith('/')) + mDocDir.append('/'); + } + else if (name == "EVAF_QT_PLUGINS_DIR") { + mQtPluginsDir = value; + if (!mQtPluginsDir.endsWith('/')) + mQtPluginsDir.append('/'); + } } // Then process command-line arguments @@ -94,11 +141,88 @@ bool App::init() mName = arg.at(1); else if (QRegExp("-[-]?lang(uage)?").exactMatch(arg.at(0)) && arg.size() > 1) mLanguage = arg.at(1); + else if (QRegExp("-[-]?root(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { + mRootDir = arg.at(1); + if (!mRootDir.endsWith('/')) + mRootDir.append('/'); + } + else if (QRegExp("-[-]?dataroot(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { + mDataRootDir = arg.at(1); + if (!mDataRootDir.endsWith('/')) + mDataRootDir.append('/'); + } + else if (QRegExp("-[-]?etc(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { + mEtcDir = arg.at(1); + if (!mEtcDir.endsWith('/')) + mEtcDir.append('/'); + } + else if (QRegExp("-[-]?log(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { + mLogDir = arg.at(1); + if (!mLogDir.endsWith('/')) + mLogDir.append('/'); + } + else if (QRegExp("-[-]?doc(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { + mDocDir = arg.at(1); + if (!mDocDir.endsWith('/')) + mDocDir.append('/'); + } + else if (QRegExp("-[-]?qtplugins(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { + mQtPluginsDir = arg.at(1); + if (!mQtPluginsDir.endsWith('/')) + mQtPluginsDir.append('/'); + } } return true; } +QString const App::dataRootDir() const +{ + if (mDataRootDir.isEmpty()) { +#ifdef Q_OS_LINUX + QString dataLoc = QDir::homePath(); + if (!dataLoc.endsWith('/')) + dataLoc.append('/'); + dataLoc.append(".local/share/data/"); + mDataRootDir = dataLoc + name(); + if (!mDataRootDir.endsWith('/')) + mDataRootDir.append('/'); +#endif + /// @TODO: Needs local data directory on Windows + mDataRootDir = rootDir(); + } + + return mDataRootDir; +} + +QString const App::etcDir() const +{ + if (mEtcDir.isEmpty()) + mEtcDir = dataRootDir() + "etc/"; + return mEtcDir; +} + +QString const App::logDir() const +{ + if (mLogDir.isEmpty()) + mLogDir = dataRootDir() + "log/"; + return mLogDir; +} + +QString const App::docDir() const +{ + if (mDocDir.isEmpty()) + mDocDir = rootDir() + "doc/"; + return mDocDir; +} + +QString const App::qtPluginsDir() const +{ + if (mQtPluginsDir.isEmpty()) + mQtPluginsDir = binDir(); + return mQtPluginsDir; +} + QString const App::xmlFileName() const { if (mXmlFile.isEmpty()) { @@ -106,13 +230,13 @@ QString const App::xmlFileName() const // Try the full application name + country + language combination QString name = mName + "_" + mLanguage + ".xml"; - fi.setFile(iEnv::instance()->etcDir() + name); + fi.setFile(etcDir() + name); if (fi.isReadable()) mXmlFile = name; else { // Try application name + country name = mName + "_" + mLanguage.left(2) + ".xml"; - fi.setFile(iEnv::instance()->etcDir() + name); + fi.setFile(etcDir() + name); if (fi.isReadable()) mXmlFile = name; else diff --git a/src/libs/Common/app.h b/src/libs/Common/app.h index 5d8886e..3bcde5a 100644 --- a/src/libs/Common/app.h +++ b/src/libs/Common/app.h @@ -63,6 +63,20 @@ public: virtual bool isReady() const { return mReady; } + virtual QString const rootDir() const { return mRootDir; } + + virtual QString const dataRootDir() const; + + virtual QString const binDir() const { return mBinDir; } + + virtual QString const etcDir() const; + + virtual QString const logDir() const; + + virtual QString const docDir() const; + + virtual QString const qtPluginsDir() const; + private: @@ -78,6 +92,27 @@ private: /// Name of the application's XML file mutable QString mXmlFile; + /// Name of the root directry + QString mRootDir; + + /// Name of the data root directory + mutable QString mDataRootDir; + + /// Name of the binary directory + QString mBinDir; + + /// Name of the Qt plugins directory + mutable QString mQtPluginsDir; + + /// Name of the configuration files directory + mutable QString mEtcDir; + + /// Name of the log files directory + mutable QString mLogDir; + + /// Name of the documentation directory + mutable QString mDocDir; + }; } // namespace eVaf::Common::Internal diff --git a/src/libs/Common/env.cpp b/src/libs/Common/env.cpp deleted file mode 100644 index 9f72a8c..0000000 --- a/src/libs/Common/env.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @file Common/env.cpp - * @brief iEnv interface implementation - * @author Enar Vaikene - * - * Copyright (c) 2011 Enar Vaikene - * - * This file is part of the eVaf C++ cross-platform application development framework. - * - * This file can be used under the terms of the GNU General Public License - * version 3.0 as published by the Free Software Foundation and appearing in - * the file LICENSE included in the packaging of this file. Please review the - * the following information to ensure the GNU General Public License version - * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. - * - * Alternatively, this file may be used in accordance with the Commercial License - * Agreement provided with the Software. - */ - -#include "env.h" -#include "iregistry.h" -#include "globals.h" -#include "version.h" -#include "iapp.h" - -#include - - -//------------------------------------------------------------------- - -using namespace eVaf::Common; - -iEnv * iEnv::instance() -{ - static eVaf::Common::Internal::Env singleton; - return &singleton; -} - - -//------------------------------------------------------------------- - -using namespace eVaf::Common::Internal; - -Env::Env() - : iEnv() -{ - setObjectName(QString("%1-iEnv").arg(VER_MODULE_NAME_STR)); -} - -Env::~Env() -{ -} - -bool Env::init() -{ - // Register out interface - iRegistry::instance()->registerInterface("iEnv", this); - - // Set initial bin and root directories - mRootDir = mBinDir = qApp->applicationDirPath(); - int t = mBinDir.lastIndexOf(QChar('/'), -1); - if (t >= 0) - mRootDir = mBinDir.left(t); - - if (!mBinDir.endsWith('/')) - mBinDir.append('/'); - if (!mRootDir.endsWith('/')) - mRootDir.append('/'); - - // Clear other directories - mDataRootDir.clear(); - mQtPluginsDir.clear(); - mEtcDir.clear(); - mLogDir.clear(); - mDocDir.clear(); - - // Set the data root directory -#ifdef Q_OS_LINUX - QString dataLoc = QDir::homePath(); - if (!dataLoc.endsWith('/')) - dataLoc.append('/'); - dataLoc.append(".local/share/data/"); - mDataRootDir = dataLoc + iApp::instance()->name(); - if (!mDataRootDir.endsWith('/')) - mDataRootDir.append('/'); -#endif - /// @TODO: Needs local data directory on Windows - - // Process the environment - QStringList env = QProcessEnvironment::systemEnvironment().toStringList(); - int sz = env.size(); - for (int i = 0; i < sz; ++i) { - // Get the name/value pair - QString name = env.at(i).section('=', 0, 0).trimmed(); - QString value = env.at(i).section('=', 1).trimmed(); - - if (name == "EVAF_ROOT_DIR") { - mRootDir = value; - if (!mRootDir.endsWith('/')) - mRootDir.append('/'); - } - else if (name == "EVAF_DATA_ROOT_DIR") { - mDataRootDir = value; - if (!mDataRootDir.endsWith('/')) - mDataRootDir.append('/'); - } - else if (name == "EVAF_ETC_DIR") { - mEtcDir = value; - if (!mEtcDir.endsWith('/')) - mEtcDir.append('/'); - } - else if (name == "EVAF_LOG_DIR") { - mLogDir = value; - if (!mLogDir.endsWith('/')) - mLogDir.append('/'); - } - else if (name == "EVAF_DOC_DIR") { - mDocDir = value; - if (!mDocDir.endsWith('/')) - mDocDir.append('/'); - } - else if (name == "EVAF_QT_PLUGINS_DIR") { - mQtPluginsDir = value; - if (!mQtPluginsDir.endsWith('/')) - mQtPluginsDir.append('/'); - } - } - - // Then process comman-line arguments - env = QCoreApplication::arguments(); - sz = env.size(); - for (int i = 0; i < sz; ++i) { - // Get the name and optional value - QStringList arg = env.at(i).simplified().split(QChar('=')); - - if (QRegExp("-[-]?root(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { - mRootDir = arg.at(1); - if (!mRootDir.endsWith('/')) - mRootDir.append('/'); - } - else if (QRegExp("-[-]?dataroot(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { - mDataRootDir = arg.at(1); - if (!mDataRootDir.endsWith('/')) - mDataRootDir.append('/'); - } - else if (QRegExp("-[-]?etc(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { - mEtcDir = arg.at(1); - if (!mEtcDir.endsWith('/')) - mEtcDir.append('/'); - } - else if (QRegExp("-[-]?log(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { - mLogDir = arg.at(1); - if (!mLogDir.endsWith('/')) - mLogDir.append('/'); - } - else if (QRegExp("-[-]?doc(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { - mDocDir = arg.at(1); - if (!mDocDir.endsWith('/')) - mDocDir.append('/'); - } - else if (QRegExp("-[-]?qtplugins(dir)?").exactMatch(arg.at(0)) && arg.size() > 1) { - mQtPluginsDir = arg.at(1); - if (!mQtPluginsDir.endsWith('/')) - mQtPluginsDir.append('/'); - } - } - - return true; -} - -QString const Env::dataRootDir() const -{ - // Fall-back to the application's root directory if the data root directory is empty - if (mDataRootDir.isEmpty()) - mDataRootDir = rootDir(); - return mDataRootDir; -} - -QString const Env::etcDir() const -{ - if (mEtcDir.isEmpty()) - mEtcDir = dataRootDir() + "etc/"; - return mEtcDir; -} - -QString const Env::logDir() const -{ - if (mLogDir.isEmpty()) - mLogDir = dataRootDir() + "log/"; - return mLogDir; -} - -QString const Env::docDir() const -{ - if (mDocDir.isEmpty()) - mDocDir = rootDir() + "doc/"; - return mDocDir; -} - -QString const Env::qtPluginsDir() const -{ - if (mQtPluginsDir.isEmpty()) - mQtPluginsDir = binDir(); - return mQtPluginsDir; -} diff --git a/src/libs/Common/env.h b/src/libs/Common/env.h deleted file mode 100644 index 592db2c..0000000 --- a/src/libs/Common/env.h +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file Common/env.h - * @brief iEnv interface implementation - * @author Enar Vaikene - * - * Copyright (c) 2011 Enar Vaikene - * - * This file is part of the eVaf C++ cross-platform application development framework. - * - * This file can be used under the terms of the GNU General Public License - * version 3.0 as published by the Free Software Foundation and appearing in - * the file LICENSE included in the packaging of this file. Please review the - * the following information to ensure the GNU General Public License version - * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. - * - * Alternatively, this file may be used in accordance with the Commercial License - * Agreement provided with the Software. - */ - -#ifndef __COMMON_ENV_H -#define __COMMON_ENV_H - -#include "ienv.h" - -#include -#include - -namespace eVaf { -namespace Common { -namespace Internal { - -/** - * iEnv interface implementation - */ -class Env : public iEnv -{ - Q_OBJECT - -public: - - Env(); - - virtual ~Env(); - - /** - * Initializes the iEnv interface implementation - * @return True if ok; false if the initialization fails - */ - bool init(); - - /* - iEnv interface - */ - - virtual QString const rootDir() const { return mRootDir; } - - virtual QString const dataRootDir() const; - - virtual QString const binDir() const { return mBinDir; } - - virtual QString const etcDir() const; - - virtual QString const logDir() const; - - virtual QString const docDir() const; - - virtual QString const qtPluginsDir() const; - - -private: // Members - - QString mRootDir; - mutable QString mDataRootDir; - QString mBinDir; - mutable QString mQtPluginsDir; - mutable QString mEtcDir; - mutable QString mLogDir; - mutable QString mDocDir; - -}; - -} // namespace eVaf::Common::Internal -} // namespace eVaf::Common -} // namespace eVaf - -#endif // env.h diff --git a/src/libs/Common/globals.cpp b/src/libs/Common/globals.cpp index e494908..63d4bce 100644 --- a/src/libs/Common/globals.cpp +++ b/src/libs/Common/globals.cpp @@ -18,7 +18,6 @@ */ #include "globals.h" -#include "env.h" #include "app.h" #include "logger.h" #include "version.h" @@ -40,10 +39,10 @@ bool eVaf::Common::init() // Initialize all the common interface implementations in the proper sequence - eVaf::Common::Internal::Env * env = - qobject_cast(eVaf::Common::iEnv::instance()); - if (env) { - if (!env->init()) + eVaf::Common::Internal::App * app = + qobject_cast(eVaf::Common::iApp::instance()); + if (app) { + if (!app->init()) return false; } eVaf::Common::Internal::Logger * logger = @@ -52,12 +51,6 @@ bool eVaf::Common::init() if (!logger->init()) return false; } - eVaf::Common::Internal::App * app = - qobject_cast(eVaf::Common::iApp::instance()); - if (app) { - if (!app->init()) - return false; - } EVAF_INFO("%s-Globals initialized", VER_MODULE_NAME_STR); diff --git a/src/libs/Common/iEnv b/src/libs/Common/iEnv deleted file mode 100644 index 9c2cb25..0000000 --- a/src/libs/Common/iEnv +++ /dev/null @@ -1 +0,0 @@ -#include "ienv.h" diff --git a/src/libs/Common/iapp.h b/src/libs/Common/iapp.h index 4c7caed..098abaf 100644 --- a/src/libs/Common/iapp.h +++ b/src/libs/Common/iapp.h @@ -32,9 +32,18 @@ namespace Common { * eVaf application interface * @code#include @endcode * - * The iApp interface provides information about current eVaf application. + * The iApp interface provides information about current eVaf application. Functions in this interface return + * the name of the application, names of directories where different recources are located etc. Modules should + * always use the iApp interface for directory names and locations. + * + * For example, all the configuration files should be located in the eVaf::Common::iApp::instance()->etcDir() directory. + * + * Directory names returned by functions in this interface are UNIX path names and they are quaranteed to + * end with the '/' character. * * All the resources returned by this interface have default values, that should work in most of the cases. + * Fox example, the binary directory is set to the same directory where the application's main executable is found. + * The root directory is the parent of the binary directory etc. * * Default values can be overwritten with environment variables and command line arguments. If both are used, * then command line arguments have higher priorities. @@ -141,6 +150,88 @@ public: */ virtual bool isReady() const = 0; + /** + * Returns the name of the eVaf root directory + * + * The root directory is the base directory where the eVaf application is installed. The default root + * directory is the parent of the binary directory. + * + * Write access to the root directory is not required to run the application. + * + * This directory can be changed with the EVAF_ROOT_DIR environment variable or with the -root[dir]=<directory> + * command line argument. + */ + virtual QString const rootDir() const = 0; + + /** + * Returns the name of the eVaf data directory. + * + * The data root directory is the base directory for all the directories that require write access. + * + * The default data directory on Windows is \%APPDATA\%/\%EVAF_APP_NAME\%. The default data directory + * on Linux is ${HOME}/.${EVAF_APP_NAME}. + * + * This directory can be changed with the EVAF_DATA_ROOT_DIR environment variable or with the + * -dataroot[dir]=<directory> command line argument. + */ + virtual QString const dataRootDir() const = 0; + + /** + * Returns the name of the binary files directory. + * + * The binary directory is the directory where all the application's binary files (main executable and + * modules) are located. The default binary directory is where the main executable is located. + * + * NB! Changing the application's root directory does not change the location of the binary directory. + */ + virtual QString const binDir() const = 0; + + /** + * Returns the configuration files directory. + * + * This is the directory where all the application's configuration files are located. The default + * configuration files directory is 'etc' in the data root directory. + * + * This directory can be changed with the EVAF_ETC_DIR environment variable or with the -etc[dir]=<directory> + * command line argument. + */ + virtual QString const etcDir() const = 0; + + /** + * Returns the log files directory. + * + * This is the directory where the application outputs all the log files. The default log files + * directory is 'log' in the data root directory. + * + * This directory can be changed with the EVAF_LOG_DIR environment variable or with the + * -log[dir]=<directory> command line argument. + */ + virtual QString const logDir() const = 0; + + /** + * Returns the documentation directory. + * + * This is the directory where all the documentation and help files are located. The default + * documentation directory is 'doc' in the root directory. + * + * This directory can be changed with the EVAF_DOC_DIR environment variable or with the + * -doc[dir]=<directory> command line argument. + */ + virtual QString const docDir() const = 0; + + /** + * Returns the Qt plugins directory. + * + * The Qt plugins directory is where additional Qt plugins are located. These Qt plugins + * are loaded manually by the application and specified in the application's XML file. + * + * Changing this directory does not affect the way how Qt itself loads its plugins. + * + * This directory can be changed with the EVAF_QT_PLUGINS_DIR environment variable or with the + * -qtplugins[dir]=<directory> command line argument. + */ + virtual QString const qtPluginsDir() const = 0; + signals: diff --git a/src/libs/Common/ienv.h b/src/libs/Common/ienv.h deleted file mode 100644 index 2effd2c..0000000 --- a/src/libs/Common/ienv.h +++ /dev/null @@ -1,158 +0,0 @@ -/** - * @file Common/ienv.h - * @brief Environment interface - * @author Enar Vaikene - * - * Copyright (c) 2011 Enar Vaikene - * - * This file is part of the eVaf C++ cross-platform application development framework. - * - * This file can be used under the terms of the GNU General Public License - * version 3.0 as published by the Free Software Foundation and appearing in - * the file LICENSE included in the packaging of this file. Please review the - * the following information to ensure the GNU General Public License version - * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. - * - * Alternatively, this file may be used in accordance with the Commercial License - * Agreement provided with the Software. - */ - -#ifndef __COMMON_IENV_H -#define __COMMON_IENV_H - -#include "libcommon.h" - -#include -#include - -namespace eVaf { -namespace Common { - -/** - * Environment interface for eVaf applications - * @code#include @endcode - * - * The iEnv interface provides information about the environment where the application is running. - * Functions in this interface return names of directories where different resources are located. - * Modules should always use the iEnv interface for directory names and locations. - * - * Directory names returned by functions in this interface are UNIX path names and they are quaranteed - * to end with the '/' character. - * - * All the directories have reasonable default values, that should work in most of the cases. For example, - * the binary directory is set to the same directory where the application's main executable is located. - * The root directory is the parent of the binary directory etc. - * - * Default values can be overwritten with environment variables and command line arguments. If both are used, - * then command line arguments have higher priorities. - */ -class COMMON_EXPORT iEnv : public QObject -{ - Q_OBJECT - -public: - - /// Interface constructor - iEnv() : QObject() {} - - /// Empty virtual destructor - virtual ~iEnv() {} - - /** - * Returns the iEnv interface instance - * @return The iEnv interface - * - * This function returns the global iEnv interface instance. As all the eVaf modules and applications - * are expected to be linked against the common library, then this is the preferred method of obtaining - * the iEnv interface. The other method is by using the iRegistry interface. - */ - static iEnv * instance(); - - /** - * Returns the name of the eVaf root directory - * - * The root directory is the base directory where the eVaf application is installed. The default root - * directory is the parent of the binary directory. - * - * Write access to the root directory is not required to run the application. - * - * This directory can be changed with the EVAF_ROOT_DIR environment variable or with the -root[dir]=<directory> - * command line argument. - */ - virtual QString const rootDir() const = 0; - - /** - * Returns the name of the eVaf data directory. - * - * The data root directory is the base directory for all the directories that require write access. - * - * The default data directory on Windows is \%APPDATA\%/\%EVAF_APP_NAME\%. The default data directory - * on Linux is ${HOME}/.${EVAF_APP_NAME}. - * - * This directory can be changed with the EVAF_DATA_ROOT_DIR environment variable or with the - * -dataroot[dir]=<directory> command line argument. - */ - virtual QString const dataRootDir() const = 0; - - /** - * Returns the name of the binary files directory. - * - * The binary directory is the directory where all the application's binary files (main executable and - * modules) are located. The default binary directory is where the main executable is located. - * - * NB! Changing the application's root directory does not change the location of the binary directory. - */ - virtual QString const binDir() const = 0; - - /** - * Returns the configuration files directory. - * - * This is the directory where all the application's configuration files are located. The default - * configuration files directory is 'etc' in the data root directory. - * - * This directory can be changed with the EVAF_ETC_DIR environment variable or with the -etc[dir]=<directory> - * command line argument. - */ - virtual QString const etcDir() const = 0; - - /** - * Returns the log files directory. - * - * This is the directory where the application outputs all the log files. The default log files - * directory is 'log' in the data root directory. - * - * This directory can be changed with the EVAF_LOG_DIR environment variable or with the - * -log[dir]=<directory> command line argument. - */ - virtual QString const logDir() const = 0; - - /** - * Returns the documentation directory. - * - * This is the directory where all the documentation and help files are located. The default - * documentation directory is 'doc' in the root directory. - * - * This directory can be changed with the EVAF_DOC_DIR environment variable or with the - * -doc[dir]=<directory> command line argument. - */ - virtual QString const docDir() const = 0; - - /** - * Returns the Qt plugins directory. - * - * The Qt plugins directory is where additional Qt plugins are located. These Qt plugins - * are loaded manually by the application and specified in the application's XML file. - * - * Changing this directory does not affect the way how Qt itself loads its plugins. - * - * This directory can be changed with the EVAF_QT_PLUGINS_DIR environment variable or with the - * -qtplugins[dir]=<directory> command line argument. - */ - virtual QString const qtPluginsDir() const = 0; - -}; - -} // namespace eVaf::Common -} // namespace eVaf - -#endif diff --git a/src/libs/Common/logger.cpp b/src/libs/Common/logger.cpp index 8ccb013..c7a50dd 100644 --- a/src/libs/Common/logger.cpp +++ b/src/libs/Common/logger.cpp @@ -19,7 +19,7 @@ #include "logger.h" #include "iregistry.h" -#include "ienv.h" +#include "iapp.h" #include "version.h" #include @@ -445,7 +445,7 @@ LoggerSource * Logger::getSource(QString const & source) mSources.insert(source, src); // Initialize the new source - src->init(source.isEmpty() ? mDefaultSource : source, iEnv::instance()->logDir(), iEnv::instance()->etcDir()); + src->init(source.isEmpty() ? mDefaultSource : source, iApp::instance()->logDir(), iApp::instance()->etcDir()); return src.data(); } diff --git a/src/libs/Plugins/pluginmanager.cpp b/src/libs/Plugins/pluginmanager.cpp index 2d8e269..643cad2 100644 --- a/src/libs/Plugins/pluginmanager.cpp +++ b/src/libs/Plugins/pluginmanager.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -145,7 +144,7 @@ void PluginManagerPrivate::done() bool PluginManagerPrivate::loadPlugins() { // Get the name of the application's XML file - QString xmlFileName = Common::iEnv::instance()->etcDir() + Common::iApp::instance()->xmlFileName(); + QString xmlFileName = Common::iApp::instance()->etcDir() + Common::iApp::instance()->xmlFileName(); // Open the XML file QFile xmlFile(xmlFileName); @@ -355,18 +354,18 @@ bool PluginManagerPrivate::loadQtPlugin(QString const & name) const QString fileName; #ifdef Q_OS_LINUX - fileName = QString("%1libq%2.so").arg(Common::iEnv::instance()->qtPluginsDir()).arg(name); + fileName = QString("%1libq%2.so").arg(Common::iApp::instance()->qtPluginsDir()).arg(name); # ifndef QT_NO_DEBUG - QString t = QString("%1libq%2.so.debug").arg(Common::iEnv::instance()->qtPluginsDir()).arg(name); + QString t = QString("%1libq%2.so.debug").arg(Common::iApp::instance()->qtPluginsDir()).arg(name); if (QFile::exists(t)) fileName = t; # endif #endif #ifdef Q_OS_WIN32 - fileName = QString("%2q%2%3").arg(Common::iEnv::instance()->qtPluginsDir()).arg(name).arg("4.dll"); + fileName = QString("%2q%2%3").arg(Common::iApp::instance()->qtPluginsDir()).arg(name).arg("4.dll"); # ifndef QT_NO_DEBUG - QString t = QString("%1q%2%3").arg(Common::iEnv::instance()->qtPluginsDir()).arg(name).arg("d4.dll"); + QString t = QString("%1q%2%3").arg(Common::iApp::instance()->qtPluginsDir()).arg(name).arg("d4.dll"); if (!QFile::exists(t)) fileName = t; # endif @@ -414,7 +413,7 @@ Module::~Module() bool Module::load() { // The real file name with path - QString fileName = Common::iEnv::instance()->binDir() + expandPluginName(mName); + QString fileName = Common::iApp::instance()->binDir() + expandPluginName(mName); // Try to load the module QScopedPointer p(new QPluginLoader(fileName)); diff --git a/src/main/CLI/main.cpp b/src/main/CLI/main.cpp index 3c1ec3b..51d5f51 100644 --- a/src/main/CLI/main.cpp +++ b/src/main/CLI/main.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -209,7 +208,6 @@ void Application::printHelp() " -lang[uage]=xx[_CC] Specifies the language, where xx is the ISO 639\n" " language code followed by an optional ISO 3166 country\n" " code.\n" - // Handled by the iEnv interface implementation " -root[dir]=DIR Specifies the application's root directory.\n" " -dataroot[dir]=DIR Specifies the data root directory.\n" " -etc[dir]=DIR Specifies the configuration files directory.\n" diff --git a/src/main/GUI/main.cpp b/src/main/GUI/main.cpp index 6806246..30f1500 100644 --- a/src/main/GUI/main.cpp +++ b/src/main/GUI/main.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include @@ -263,7 +262,6 @@ void Application::printHelp() " -lang[uage]=xx[_CC] Specifies the language, where xx is the ISO 639\n" " language code followed by an optional ISO 3166 country\n" " code.\n" - // Handled by the iEnv interface implementation " -root[dir]=DIR Specifies the application's root directory.\n" " -dataroot[dir]=DIR Specifies the data root directory.\n" " -etc[dir]=DIR Specifies the configuration files directory.\n"