refs #205, allows to select DBusServer type (session, peer, system) in core

This commit is contained in:
Klaus Basan
2014-04-12 03:10:46 +02:00
parent b2acd3e476
commit bfcdf5ed9a

View File

@@ -8,12 +8,14 @@
#include "blackcore/context_settings.h" #include "blackcore/context_settings.h"
#include "blackcore/context_application.h" #include "blackcore/context_application.h"
#include "blackcore/context_application_impl.h" #include "blackcore/context_application_impl.h"
#include "blackmisc/networkutils.h"
#include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h"
#include <QtConcurrent/QtConcurrent> #include <QtConcurrent/QtConcurrent>
#include <QMetaType> #include <QMetaType>
#include <QMetaMethod> #include <QMetaMethod>
#include <QApplication> #include <QApplication>
#include <QIcon> #include <QIcon>
#include <QTextStream>
/*! /*!
* DBus tests, tests marshalling / unmarshalling of many value classes. * DBus tests, tests marshalling / unmarshalling of many value classes.
@@ -25,7 +27,32 @@ int main(int argc, char *argv[])
QApplication a(argc, argv); // not QCoreApplication because of icon, http://qt-project.org/forums/viewthread/15412 QApplication a(argc, argv); // not QCoreApplication because of icon, http://qt-project.org/forums/viewthread/15412
QIcon icon(":/blackcore/icons/tower.png"); QIcon icon(":/blackcore/icons/tower.png");
QApplication::setWindowIcon(icon); QApplication::setWindowIcon(icon);
BlackCore::CRuntime *core = new BlackCore::CRuntime(BlackCore::CRuntimeConfig::forCore(), &a); QTextStream cin(stdin);
qDebug() << "1 + la/ra .. session DBus server (default)";
qDebug() << "2 + la/ra .. system DBus server";
qDebug() << "3 + la/ra .. P2P DBus server";
qDebug() << "la .. local audio, audio runs in this core here (default)";
qDebug() << "ra .. remote audio, audio runs in the GUI or elsewhere";
QString input = cin.readLine().toLower();
// configure DBus server
QString dBusAddress = BlackCore::CDBusServer::sessionDBusServer();
if (input.startsWith("2"))
dBusAddress = BlackCore::CDBusServer::systemDBusServer();
else if (input.startsWith("3"))
{
qDebug() << "found: " << BlackMisc::CNetworkUtils::getKnownIpAddresses();
qDebug() << "enter ip/port, e.g. 127.0.0.1:45000 (default)";
dBusAddress = cin.readLine().toLower();
dBusAddress = BlackCore::CDBusServer::p2pAddress(dBusAddress);
}
// with remote audio
bool remoteAudio = input.contains("ra");
BlackCore::CRuntime *core = remoteAudio ?
new BlackCore::CRuntime(BlackCore::CRuntimeConfig::forCoreAllLocalInDBusNoAudio(dBusAddress), &a) :
new BlackCore::CRuntime(BlackCore::CRuntimeConfig::forCoreAllLocalInDBus(dBusAddress), &a);
QtConcurrent::run(BlackMiscTest::Tool::serverLoop, core); // QFuture<void> future QtConcurrent::run(BlackMiscTest::Tool::serverLoop, core); // QFuture<void> future
qDebug() << "Server event loop, pid:" << BlackMiscTest::Tool::getPid(); qDebug() << "Server event loop, pid:" << BlackMiscTest::Tool::getPid();