diff --git a/src/xbus/plugin.cpp b/src/xbus/plugin.cpp index ce386f629..ee97e812e 100644 --- a/src/xbus/plugin.cpp +++ b/src/xbus/plugin.cpp @@ -11,6 +11,8 @@ #include "service.h" #include "traffic.h" #include "weather.h" +#include "utils.h" +#include "blackmisc/librarypath.h" namespace { inline QString xbusServiceName() { @@ -34,7 +36,15 @@ namespace XBus Q_ASSERT(! m_server); for (auto &item : m_startServerMenuItems) { item.setEnabled(false); } + auto previousLibraryPath = BlackMisc::getCustomLibraryPath(); + auto libraryPath = g_xplanePath + "Resources" + g_sep + "plugins" + g_sep + "xbus"; + #if !defined (Q_OS_MAC) && defined(WORD_SIZE_64) + libraryPath = libraryPath + g_sep + "64"; + #endif + BlackMisc::setCustomLibraryPath(libraryPath); m_server = new BlackMisc::CDBusServer(xbusServiceName(), address, this); + BlackMisc::setCustomLibraryPath(previousLibraryPath); + m_service = new CService(this); m_traffic = new CTraffic(this); m_weather = new CWeather(this); diff --git a/src/xbus/traffic.cpp b/src/xbus/traffic.cpp index 755ef407d..a835904f0 100644 --- a/src/xbus/traffic.cpp +++ b/src/xbus/traffic.cpp @@ -13,6 +13,7 @@ #define NOMINMAX #endif #include "traffic.h" +#include "utils.h" #include "XPMPMultiplayer.h" #include "XPMPMultiplayerCSL.h" #include @@ -40,24 +41,6 @@ namespace XBus surfaces.lights.timeOffset = static_cast(qrand() % 0xffff); } - - QString g_xplanePath; - QString g_sep; - - //! Init global xplane path - void initXPlanePath() - { - char xplanePath[512]; - XPLMGetSystemPath(xplanePath); -#ifdef Q_OS_MAC - HFS2PosixPath(xplanePath, xplanePath, sizeof(xplanePath)); - g_sep = "/"; -#else - g_sep = XPLMGetDirectorySeparator(); -#endif - g_xplanePath = xplanePath; - } - CTraffic::CTraffic(QObject *parent) : QObject(parent) { } diff --git a/src/xbus/utils.cpp b/src/xbus/utils.cpp new file mode 100644 index 000000000..553ad44d9 --- /dev/null +++ b/src/xbus/utils.cpp @@ -0,0 +1,45 @@ +/* Copyright (C) 2016 + * swift Project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \cond PRIVATE + +#ifndef NOMINMAX +#define NOMINMAX +#endif + +#include "utils.h" +#include +#include +#include + +namespace XBus +{ + + QString g_xplanePath; + QString g_sep; + + //! Init global xplane path + void initXPlanePath() + { + if (!g_xplanePath.isEmpty() && !g_sep.isEmpty()) {} + + char xplanePath[512]; + XPLMGetSystemPath(xplanePath); +#ifdef Q_OS_MAC + HFS2PosixPath(xplanePath, xplanePath, sizeof(xplanePath)); + g_sep = "/"; +#else + g_sep = XPLMGetDirectorySeparator(); +#endif + g_xplanePath = xplanePath; + } + +} + +//! \endcond diff --git a/src/xbus/utils.h b/src/xbus/utils.h index db114b8e0..0bd593172 100644 --- a/src/xbus/utils.h +++ b/src/xbus/utils.h @@ -167,4 +167,16 @@ public: } }; +namespace XBus +{ + //! Absolute xplane path + extern QString g_xplanePath; + + //! Platform specific dir separator + extern QString g_sep; + + //! Init global xplane path + void initXPlanePath(); +} + #endif // guard diff --git a/src/xbus/xbus.pro b/src/xbus/xbus.pro index 571fc69b3..a0237d7fa 100644 --- a/src/xbus/xbus.pro +++ b/src/xbus/xbus.pro @@ -74,8 +74,13 @@ macx { XBUS_DIR = xbus XBUS_DESTDIR = $$DestRoot/$$XBUS_DIR } else { - equals(WORD_SIZE,64): XBUS_DIR = xbus/64 - equals(WORD_SIZE,32): XBUS_DIR = xbus + equals(WORD_SIZE,64) { + XBUS_DIR = xbus/64 + DEFINES += WORD_SIZE_64 + } + equals(WORD_SIZE,32) { + XBUS_DIR = xbus + } XBUS_DESTDIR = $$DestRoot/$$XBUS_DIR }