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