コード例 #1
0
SubscriptionStatus DBusServiceRegistry::onSignalDBusMessage(const DBusMessage& dbusMessage) {
    const std::string& dbusServiceUniqueName = dbusMessage.getSenderName();

    assert(dbusMessage.isSignalType());
    assert(dbusMessage.hasInterfaceName("org.freedesktop.DBus.ObjectManager"));
    assert(dbusMessage.hasMemberName("InterfacesAdded") || dbusMessage.hasMemberName("InterfacesRemoved"));

    DBusInputStream dbusInputStream(dbusMessage);
    std::string dbusObjectPath;
    std::unordered_set<std::string> dbusInterfaceNames;
    DBusRecordState dbusInterfaceNameState;

    dbusInputStream >> dbusObjectPath;

    if (dbusMessage.hasMemberName("InterfacesAdded")) {
        dbusInterfaceNameState = DBusRecordState::AVAILABLE;

        typedef std::unordered_map<std::string, bool> DBusPropertiesChangedDict;
        typedef std::unordered_map<std::string, DBusPropertiesChangedDict> DBusInterfacesAndPropertiesDict;
        typedef std::unordered_map<std::string, DBusInterfacesAndPropertiesDict> DBusObjectPathAndInterfacesDict;
        DBusObjectPathAndInterfacesDict dbusObjectPathAndInterfacesDict;
        dbusInputStream >> dbusObjectPathAndInterfacesDict;

        for (auto& dbusInterfaceIterator : dbusObjectPathAndInterfacesDict) {
            const auto& dbusInterfaceName = dbusInterfaceIterator.first;
            dbusInterfaceNames.insert(dbusInterfaceName);
        }
    } else {
コード例 #2
0
bool DBusObjectManager::handleMessage(const DBusMessage& dbusMessage) {
    const char* objectPath = dbusMessage.getObjectPath();
    const char* interfaceName = dbusMessage.getInterface();

    assert(objectPath);
    assert(interfaceName);

    DBusInterfaceHandlerPath handlerPath(objectPath, interfaceName);

    objectPathLock_.lock();
    auto handlerIterator = dbusRegisteredObjectsTable_.find(handlerPath);
    const bool foundDBusInterfaceHandler = handlerIterator != dbusRegisteredObjectsTable_.end();
    bool dbusMessageHandled = false;

    if (foundDBusInterfaceHandler) {
        std::shared_ptr<DBusInterfaceHandler> dbusStubAdapterBase = handlerIterator->second;
        dbusMessageHandled = dbusStubAdapterBase->onInterfaceDBusMessage(dbusMessage);
    } else if (dbusMessage.hasInterfaceName("org.freedesktop.DBus.Introspectable")) {
        dbusMessageHandled = onIntrospectableInterfaceDBusMessage(dbusMessage);
    }
    objectPathLock_.unlock();

    return dbusMessageHandled;
}