bool QDBusAbstractInterfacePrivate::canMakeCalls() const { // recheck only if we have a wildcard (i.e. empty) service or path // if any are empty, set the error message according to QDBusUtil if (service.isEmpty() && connectionPrivate()->mode != QDBusConnectionPrivate::PeerMode) return QDBusUtil::checkBusName(service, QDBusUtil::EmptyNotAllowed, &lastError); if (path.isEmpty()) return QDBusUtil::checkObjectPath(path, QDBusUtil::EmptyNotAllowed, &lastError); return true; }
QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv, const QString &p, const QString &iface, const QDBusConnection& con, bool isDynamic) : connection(con), service(serv), path(p), interface(iface), lastError(checkIfValid(serv, p, iface, isDynamic)), isValid(!lastError.isValid()) { if (!isValid) return; if (!connection.isConnected()) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Not connected to D-Bus server")); } else if (!service.isEmpty()) { currentOwner = connectionPrivate()->getNameOwner(service); // verify the name owner if (currentOwner.isEmpty()) { lastError = connectionPrivate()->lastError; } } }
QDBusInterfacePrivate::QDBusInterfacePrivate(const QString &serv, const QString &p, const QString &iface, const QDBusConnection &con) : QDBusAbstractInterfacePrivate(serv, p, iface, con, true), metaObject(0) { // QDBusAbstractInterfacePrivate's constructor checked the parameters for us if (connection.isConnected()) { metaObject = connectionPrivate()->findMetaObject(service, path, interface, lastError); if (!metaObject) { // creation failed, somehow // most common causes are that the service doesn't exist or doesn't support introspection // those are not fatal errors, so we continue working if (!lastError.isValid()) lastError = QDBusError(QDBusError::InternalError, QLatin1String("Unknown error")); } } }
QT_BEGIN_NAMESPACE QDBusInterfacePrivate::QDBusInterfacePrivate(const QString &serv, const QString &p, const QString &iface, const QDBusConnection &con) : QDBusAbstractInterfacePrivate(serv, p, iface, con, true), metaObject(0) { // QDBusAbstractInterfacePrivate's constructor checked the parameters for us if (connection.isConnected()) { metaObject = connectionPrivate()->findMetaObject(service, path, interface, lastError); if (!metaObject) { // creation failed, somehow isValid = false; if (!lastError.isValid()) lastError = QDBusError(QDBusError::InternalError, QLatin1String("Unknown error")); } } }
QT_BEGIN_NAMESPACE QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv, const QString &p, const QString &iface, const QDBusConnection& con, bool isDynamic) : connection(con), service(serv), path(p), interface(iface), isValid(true) { if (isDynamic) { // QDBusInterface: service and object path can't be empty, but interface can #if 0 Q_ASSERT_X(QDBusUtil::isValidBusName(service), "QDBusInterface::QDBusInterface", "Invalid service name"); Q_ASSERT_X(QDBusUtil::isValidObjectPath(path), "QDBusInterface::QDBusInterface", "Invalid object path given"); Q_ASSERT_X(interface.isEmpty() || QDBusUtil::isValidInterfaceName(interface), "QDBusInterface::QDBusInterface", "Invalid interface name"); #else if (!QDBusUtil::isValidBusName(service)) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Invalid service name")); isValid = false; } else if (!QDBusUtil::isValidObjectPath(path)) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Invalid object name given")); isValid = false; } else if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Invalid interface name")); isValid = false; } #endif } else { // all others: service and path can be empty here, but interface can't #if 0 Q_ASSERT_X(service.isEmpty() || QDBusUtil::isValidBusName(service), "QDBusAbstractInterface::QDBusAbstractInterface", "Invalid service name"); Q_ASSERT_X(path.isEmpty() || QDBusUtil::isValidObjectPath(path), "QDBusAbstractInterface::QDBusAbstractInterface", "Invalid object path given"); Q_ASSERT_X(QDBusUtil::isValidInterfaceName(interface), "QDBusAbstractInterface::QDBusAbstractInterface", "Invalid interface class!"); #else if (!service.isEmpty() && !QDBusUtil::isValidBusName(service)) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Invalid service name")); isValid = false; } else if (!path.isEmpty() && !QDBusUtil::isValidObjectPath(path)) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Invalid object path given")); isValid = false; } else if (!QDBusUtil::isValidInterfaceName(interface)) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Invalid interface class")); isValid = false; } #endif } if (!isValid) return; if (!connection.isConnected()) { lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Not connected to D-Bus server")); isValid = false; } else if (!service.isEmpty()) { currentOwner = connectionPrivate()->getNameOwner(service); // verify the name owner if (currentOwner.isEmpty()) { isValid = false; lastError = connectionPrivate()->lastError; } } }