void tst_QDBusPerformance::initTestCase() { QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration); connect(&watcher, SIGNAL(serviceRegistered(QString)), &QTestEventLoop::instance(), SLOT(exitLoop())); #ifdef Q_OS_WIN proc.start("server"); #else proc.start("./server/server"); #endif QVERIFY(proc.waitForStarted()); QTestEventLoop::instance().enterLoop(5); QVERIFY(con.interface()->isServiceRegistered(serviceName)); remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this); QVERIFY(remote->isValid()); new ServerObject("/", con, this); local = new QDBusInterface(con.baseService(), "/", "com.trolltech.autotests.Performance", con, this); QVERIFY(local->isValid()); }
int main(int argc, char* argv[]) { adbus_set_logger(&Log); QCoreApplication app(argc, argv); QDBusConnection c = QDBusConnection::sessionBus(); if (!c.isConnected()) { qFatal("Can't connect"); return 1; } qDebug() << "Connected as" << c.baseService(); new Main(c); return app.exec(); }
NdefHandler::NdefHandler(QNearFieldManagerPrivateImpl *manager, const QString &serviceName, const QString &path, QObject *object, const QMetaMethod &method) : m_manager(manager), m_adaptor(0), m_object(object), m_method(method), m_serviceName(serviceName), m_path(path) { QDBusConnection handlerConnection = QDBusConnection::connectToBus(QDBusConnection::SystemBus, connectionUuid); if (serviceName != handlerConnection.baseService()) { handlerConnection = QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName); if (!handlerConnection.registerService(serviceName)) return; } m_adaptor = new NDEFHandlerAdaptor(this); if (!handlerConnection.registerObject(path, this)) { delete m_adaptor; m_adaptor = 0; } }