Qt IVI Generator Remote Objects Example

/**************************************************************************** ** Generated from 'Example.IVI.Remote.qface' ** ** Created by: The QFace generator (QtAS 5.12.8) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/
#include "core.h" #include "remotemodule.h" #include <QCoreApplication> #include <QSettings> Core* Core::s_instance(nullptr); Core::Core(QObject *parent) : QObject(parent) , m_host(nullptr) { init(); } Core::~Core() { } void Core::init() { RemoteModule::registerTypes(); QString configPath(QStringLiteral("./server.conf")); if (qEnvironmentVariableIsSet("SERVER_CONF_PATH")) configPath = QString::fromLocal8Bit(qgetenv("SERVER_CONF_PATH")); else qDebug() << "Environment variable SERVER_CONF_PATH not defined, using " << configPath; QSettings settings(configPath, QSettings::IniFormat); settings.beginGroup(QStringLiteral("remote")); QUrl url = QUrl(settings.value(QStringLiteral("Registry"), QStringLiteral("local:remote")).toString()); m_host = new QRemoteObjectRegistryHost(url); qDebug() << "registry at: " << m_host->registryUrl().toString(); connect(m_host, &QRemoteObjectNode::error, this, &Core::reportError); } Core* Core::instance() { if (!s_instance) s_instance = new Core(QCoreApplication::instance()); Q_ASSERT(s_instance); return s_instance; } QRemoteObjectRegistryHost* Core::host() const { Q_ASSERT(m_host); return m_host; } void Core::reportError(QRemoteObjectNode::ErrorCode code) { qWarning() << "QRemoteObjects Error: " << code; }