Files
pilotclient/src/xswiftbus/main.cpp
Roland Winklmeier f53ec46d20 Change the operating system name from OSX to MacOS everywhere
Summary:
- Changed the name in all build artifacts
- Everywhere in C++

Reviewers: #swift_pilot_client, kbasan

Reviewed By: #swift_pilot_client, kbasan

Subscribers: jenkins

Maniphest Tasks: T205

Differential Revision: https://dev.swift-project.org/D69
2017-12-06 22:50:19 +01:00

94 lines
2.7 KiB
C++

/* Copyright (C) 2013
* 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.
*/
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include "plugin.h"
#include "utils.h"
#include "traffic.h"
#include "service.h"
#include "blackmisc/dbus.h"
#include <XPLM/XPLMPlanes.h>
#if ! defined(XPLM210)
#define XPLM_MSG_LIVERY_LOADED 108
#endif
// Change QSharedPointer<QCoreApplication> to QSharedPointer<QApplication> below
// in case you want to have Qt Gui components inside a X-Plane plugin. The current
// default was used since QApplication causes an infinite loop in X-Plane on MacOS
// platforms. X-Plane is allocating an NSApplication but never calling run(), rather
// it controls the main loop itself and pumps the event Q as needed. This causes
// unusual start conditions for QCocoaEventDispatcher and ends up in the infinite
// loop. Since QCoreApplication is not using QCocoaEventDispatcher it works fine
// and is used as a workaround.
// See https://dev.vatsim-germany.org/issues/293 for more information.
QSharedPointer<QCoreApplication> g_qApp;
XSwiftBus::CPlugin *g_plugin;
PLUGIN_API int XPluginStart(char *o_name, char *o_sig, char *o_desc)
{
std::strcpy(o_name, "XSwiftBus");
std::strcpy(o_sig, "org.swift-project.xswiftbus");
std::strcpy(o_desc, "Allows swift to connect to X-Plane via D-Bus IPC");
XSwiftBus::CTraffic::initLegacyData();
return 1;
}
PLUGIN_API void XPluginStop()
{
}
PLUGIN_API int XPluginEnable()
{
qRegisterMetaType<QDoubleList>();
qDBusRegisterMetaType<QDoubleList>();
QXPlaneMessageHandler::install();
g_qApp = QSharedApplication::sharedInstance();
QXPlaneEventLoop::exec();
g_plugin = new XSwiftBus::CPlugin;
// Here we can be safely assume that QtDBus was loaded by the process
preventQtDBusDllUnload();
return 1;
}
PLUGIN_API void XPluginDisable()
{
delete g_plugin;
g_qApp.reset();
}
PLUGIN_API void XPluginReceiveMessage(XPLMPluginID from, long msg, void *param)
{
if (from == XPLM_PLUGIN_XPLANE)
{
switch (msg)
{
case XPLM_MSG_PLANE_LOADED:
case XPLM_MSG_LIVERY_LOADED:
if (reinterpret_cast<intptr_t>(param) == XPLM_USER_AIRCRAFT)
{
g_plugin->onAircraftModelChanged();
}
break;
case XPLM_MSG_AIRPORT_LOADED:
g_plugin->onAircraftRepositioned();
break;
}
}
}