mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:38:15 +08:00
Ref T192, DBus utility functions, Service name empty for P2P
This commit is contained in:
@@ -361,7 +361,7 @@ namespace BlackCore
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString name("BlackBoxRuntime");
|
||||
const QString name(CDBusServer::p2pConnectionName() + " " + address);
|
||||
QDBusConnection::disconnectFromPeer(name);
|
||||
m_dbusConnection = QDBusConnection::connectToPeer(address, name);
|
||||
}
|
||||
|
||||
@@ -93,11 +93,23 @@ namespace BlackMisc
|
||||
return sn;
|
||||
}
|
||||
|
||||
const QString &CDBusServer::coreServiceName(const QDBusConnection &connection)
|
||||
{
|
||||
static const QString empty;
|
||||
return CDBusServer::isP2PConnection(connection) ? empty : CDBusServer::coreServiceName();
|
||||
}
|
||||
|
||||
bool CDBusServer::isP2PAddress(const QString &address)
|
||||
{
|
||||
return modeOfAddress(address) == SERVERMODE_P2P;
|
||||
}
|
||||
|
||||
bool CDBusServer::isP2PConnection(const QDBusConnection &connection)
|
||||
{
|
||||
if (CDBusServer::isQtDefaultConnection(connection)) { return false; }
|
||||
return connection.name().contains(p2pConnectionName());
|
||||
}
|
||||
|
||||
bool CDBusServer::dBusAddressToHostAndPort(QString address, QString &host, int &port)
|
||||
{
|
||||
address = address.trimmed().toLower().replace(' ', "");
|
||||
@@ -170,6 +182,12 @@ namespace BlackMisc
|
||||
return "";
|
||||
}
|
||||
|
||||
QDBusConnection::RegisterOptions CDBusServer::registerOptions()
|
||||
{
|
||||
return QDBusConnection::ExportAdaptors | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAllSlots;
|
||||
// return QDBusConnection::ExportAllContents;
|
||||
}
|
||||
|
||||
bool CDBusServer::registerObjectsWithP2PConnection(QDBusConnection connection)
|
||||
{
|
||||
Q_ASSERT(! m_objects.isEmpty());
|
||||
|
||||
@@ -44,6 +44,9 @@ namespace BlackMisc
|
||||
//! Default service name
|
||||
static const QString &coreServiceName();
|
||||
|
||||
//! Service name, empty if is P2P connection
|
||||
static const QString &coreServiceName(const QDBusConnection &connection);
|
||||
|
||||
//! Server mode
|
||||
enum ServerMode
|
||||
{
|
||||
@@ -119,6 +122,9 @@ namespace BlackMisc
|
||||
//! False if address is session or system bus address
|
||||
static bool isP2PAddress(const QString &address);
|
||||
|
||||
//! False if address is session or system bus connection
|
||||
static bool isP2PConnection(const QDBusConnection &connection);
|
||||
|
||||
//! Extract host and port from a DBus address
|
||||
static bool dBusAddressToHostAndPort(QString dbusAddress, QString &o_host, int &o_port);
|
||||
|
||||
@@ -143,6 +149,7 @@ namespace BlackMisc
|
||||
QMap<QString, QObject *> m_objects;
|
||||
QMap<QString, QDBusConnection> m_connections;
|
||||
|
||||
//! Interface name/value to class name
|
||||
static QString getDBusInterfaceFromClassInfo(QObject *object);
|
||||
|
||||
//! Register options with connection
|
||||
|
||||
Reference in New Issue
Block a user