ConflictResolutionScreen::ConflictResolutionScreen()
{
    setStyleSheet( "background-color: white;" );

    new OneclickinstallerAdaptor( this );
    QDBusConnection connection = QDBusConnection::systemBus();
    if ( !connection.isConnected() ) {
        qFatal( "Cannot connect to the D-Bus system bus" );
        exit( 1 );
    }
    connection.registerObject( "/OCI", this );
    if ( !connection.registerService("org.opensuse.oneclickinstaller") ) {
        qFatal( qPrintable( QDBusConnection::systemBus().lastError().message() ) );
        exit( 1 );
    }

    m_mainLayout = new QVBoxLayout;

    //QObject::connect( m_ociHelper, SIGNAL( displayProblemAndSolutions( QString, QString ) ), this, SLOT( problemSolutionWidget( QString, QString ) ) );
    QDBusConnection sysBus = QDBusConnection::systemBus();
    if ( !sysBus.isConnected() ) {
        qFatal( "Cannot connect to the D-Bus system bus" );
        exit( 1 );
    }
    sysBus.connect( QString(), QString(), "org.opensuse.OCIHelper", "displayProblemAndSolutions", this, SLOT( problemSolutionWidget( QString, QStringList ) ) );

    setLayout ( m_mainLayout );
}
Пример #2
0
 // ---------------------------------------------------------------------------------
 bool detail::service_to_register_with_dbus::at_system_bus()
 {
   QDBusConnection con = dbus().system_bus();
   if ( !con.isConnected() )
   {
     qWarning() << "not connected to system bus";
     return false;
   }
   if ( _M_op == REGISTER )
   {
     bool result = con.registerService ( _M_service );
     if ( result == false )
     {
       qDebug() << "something went wrong when trying to register the DBUS service: " << _M_service;
       qDebug() << con.lastError();
       return false;
     }
     return true;
   }
   else
   {
     if ( con.interface()->isServiceRegistered ( _M_service ) )
     {
       return con.unregisterService ( _M_service );
     }
   }
   return true;
 }
Пример #3
0
bool registerInstance(Gui::MainWindow *window, QString &error)
{
    QDBusConnection conn = QDBusConnection::sessionBus();
    if (!conn.isConnected()) {
        error = conn.lastError().message();
        return false;
    }

    bool serviceOk = conn.registerService(service());
    if (!serviceOk) {
        error = conn.lastError().message();
        return false;
    }

    MainWindowBridge *object = new MainWindowBridge(window);
    bool objectOk = conn.registerObject(path, object, QDBusConnection::ExportAllSlots);
    if (!objectOk) {
        error = conn.lastError().message();
        delete object;
        conn.unregisterService(service());
        return false;
    }

    return true;
}
Пример #4
0
UDiskProvider::UDiskProvider(QObject *parent):
    RzMountProvider(parent)
{
    QDBusConnection system = QDBusConnection::systemBus();

    if (!system.isConnected())
    {
        return;
    }

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceAdded",
                    this,
                    SLOT(dbusDeviceAdded(QDBusObjectPath)));

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceRemoved",
                    this,
                    SLOT(dbusDeviceRemoved(QDBusObjectPath)));

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceChanged",
                    this,
                    SLOT(dbusDeviceChanged(QDBusObjectPath)));

    mIsValid = true;
}
Пример #5
0
MprisPlayer::MprisPlayer(QObject *parent)
    : QObject(parent)
    , QDBusContext()
    , m_mprisRootAdaptor(new MprisRootAdaptor(this))
    , m_mprisPlayerAdaptor(new MprisPlayerAdaptor(this))
    , m_canQuit(false)
    , m_canRaise(false)
    , m_canSetFullscreen(false)
    , m_fullscreen(false)
    , m_hasTrackList(false)
    , m_canControl(false)
    , m_canGoNext(false)
    , m_canGoPrevious(false)
    , m_canPause(false)
    , m_canPlay(false)
    , m_canSeek(false)
    , m_loopStatus(Mpris::None)
    , m_maximumRate(1)
    , m_minimumRate(1)
    , m_playbackStatus(Mpris::Stopped)
    , m_position(0)
    , m_rate(1)
    , m_shuffle(false)
    , m_volume(0)
{
    QDBusConnection connection = QDBusConnection::sessionBus();

    if (!connection.isConnected()) {
//        qmlInfo(this) << "Failed attempting to connect to DBus";
    } else if (!connection.registerObject(mprisObjectPath, this)) {
//        qmlInfo(this) << "Failed attempting to register object path. Already registered?";
    }
}
Пример #6
0
MprisManager::MprisManager(QObject *parent)
    : QObject(parent)
    , m_singleService(false)
    , m_playbackStatusMapper(new QSignalMapper(this))
{
    QDBusConnection connection = QDBusConnection::sessionBus();

    if (!connection.isConnected()) {
//        qmlInfo(this) << "Failed attempting to connect to DBus";
        return;
    }

    connection.connect(dBusService, dBusObjectPath, dBusInterface, dBusNameOwnerChangedSignal,
                       QStringList(), QString(),
                       this, SLOT(onNameOwnerChanged(QString, QString, QString)));

    QStringList serviceNames = connection.interface()->registeredServiceNames();
    QStringList::const_iterator i = serviceNames.constBegin();
    while (i != serviceNames.constEnd()) {
        QRegExp rx(mprisNameSpace);
        rx.setPatternSyntax(QRegExp::Wildcard);
        if (rx.exactMatch(*i)) {
            onServiceAppeared(*i);
        }

        ++i;
    }
}
Пример #7
0
void runGUI(const QString &dbusAddr, const QStringList &files, const QString &title, const QString &options, uint count)
{
    QDBusConnection dbus = QDBusConnection::connectToBus(dbusAddr, "boomaga");
    if (!dbus.isConnected())
    {
        error("Can't connect to org.boomaga DBus");
    }

    QDBusMessage msg = QDBusMessage::createMethodCall(
                "org.boomaga",
                "/boomaga",
                "org.boomaga",
                "add");

    foreach (QString file, files)
    {
        QList<QVariant> args;
        args << file;
        args << title;
        args << true;
        args << options;
        args << count;
        msg.setArguments(args);

        QStringList sl;
        foreach (const QVariant &arg, args)
        {
            sl << "'" + arg.toString() +"'";
        }
Пример #8
0
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());
}
Пример #9
0
 Pinger getPingerPeer(const QString &path = "/", const QString &service = "")
 {
     QDBusConnection con = QDBusConnection("peer");
     if (!con.isConnected())
         return Pinger();
     return Pinger(new com::trolltech::QtDBus::Pinger(service, path, con));
 }
Пример #10
0
void MprisPlayer::notifyPropertiesChanged(const QString& interfaceName, const QVariantMap &changedProperties, const QStringList &invalidatedProperties) const
{
    if (m_serviceName.isEmpty()) {
        return;
    }

    QDBusConnection connection = QDBusConnection::sessionBus();

    if (!connection.isConnected()) {
//        qmlInfo(this) << "Failed attempting to connect to DBus";
        return;
    }

    QDBusMessage message = QDBusMessage::createSignal(mprisObjectPath,
                                                      dBusPropertiesInterface,
                                                      dBusPropertiesChangedSignal);

    QList<QVariant> arguments;
    arguments << QVariant(interfaceName) << QVariant(changedProperties) << QVariant(invalidatedProperties);
    message.setArguments(arguments);

    if (!connection.send(message)) {
//        qmlInfo(this) << "Failed to send DBus property notification signal";
    }
}
Пример #11
0
void Launcher::startup(const QString &app)
{
    QDBusConnection dbc = QDBus::sessionBus();

    if (!dbc.isConnected()) {
        fprintf(stderr, "QtopiaLauncher: Could not connect to DBUS bus\n");
        exit(1);
    }

    bool r = dbc.connect(QString(),                           // Service
                         "/DBusLauncher",                     // Path
                         "com.trolltech.qtopia.DBusLauncher", // Interface
                         "launched",                          // Name
                         this,
                         SLOT(handleSignalReceived(QString,QDBusMessage)));

    QDBusMessage message =
            QDBusMessage::methodCall("com.trolltech.qtopia.DBusLauncher",
                                     "/DBusLauncher",
                                     "com.trolltech.qtopia.DBusLauncher",
                                     "launch", dbc);
    message << app;

    bool ret = dbc.send(message);
    if (!ret)
        fprintf(stderr, "Unable to send message: %s", dbc.lastError().message().toAscii().constData());

    m_app = app;
}
Пример #12
0
UdisksManager::UdisksManager(QObject *parent)
    : QObject(parent)
{
    QDBusConnection system = QDBusConnection::systemBus();

    if (!system.isConnected())
    {
        emit error(tr("Cannot connect to Udisks daemon"));
    }

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceAdded",
                    this,
                    SLOT(onDeviceAdded(QDBusObjectPath)));
    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceRemoved",
                    this,
                    SLOT(onDeviceRemoved(QDBusObjectPath)));
    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceChanged",
                    this,
                    SLOT(onDeviceChanged(QDBusObjectPath)));

    QDBusInterface devEnum("org.freedesktop.UDisks",
                           "/org/freedesktop/UDisks",
                           "org.freedesktop.UDisks",
                           QDBusConnection::systemBus());

    QDBusMessage enumRes = devEnum.call("EnumerateDevices");
    // TODO/FIXME: error checking
//    if (enumRes.type() == QDBusMessage::ErrorMessage)
//    {
//        fprintf(stderr, "ERROR: Can't call EnumerateDevices\n");
//        fprintf(stderr, "       %s : %s\n", qPrintable(enumRes.errorName()), qPrintable(enumRes.errorMessage()));
//    }
//
//    if (enumRes.type() != QDBusMessage::ReplyMessage || !enumRes.arguments().at(0).canConvert<QDBusArgument>())
//    {
//        fprintf(stderr, "ERROR: Unexpected result type of EnumerateDevices call\n");
//    }
//
    const QDBusArgument enumArg = enumRes.arguments().at(0).value<QDBusArgument>();
//    if (enumArg.currentType() != QDBusArgument::ArrayType)
//    {
//        fprintf(stderr, "ERROR: Unexpected argument type of EnumerateDevices call\n");
//    }

    enumArg.beginArray();
    while (!enumArg.atEnd())
    {
        addDevice(qdbus_cast<QDBusObjectPath>(enumArg));
    }
    enumArg.endArray();
}
Пример #13
0
/*!
    Destroy this QCop service handling object.
*/
QtopiaAbstractService::~QtopiaAbstractService()
{
#if defined(QTOPIA_DBUS_IPC)
    QDBusConnection dbc = QDBus::sessionBus();
    if (!dbc.isConnected()) {
        qWarning() << "Unable to connect to D-BUS:" << dbc.lastError();
        return;
    }

    qLog(Services) << "Unregistering service" << m_data->m_service;

    QString path = dbusPathBase;
    path.append(m_data->m_service);
    dbc.unregisterObject(path);

    QDBusConnectionInterface *iface = dbc.interface();
    QString service = dbusInterface;
    service.append(".");
    service.append(m_data->m_service);

    iface->unregisterService(service);
#endif

    if (m_data)
        delete m_data;
}
Пример #14
0
void tst_QDBusServer::callMethod()
{
    QDBusConnection connection = QDBusConnection::connectToBus(bus, "test-connection");
    QTest::qWait(100);
    QVERIFY(connection.isConnected());
    //QDBusMessage msg = QDBusMessage::createMethodCall(bus, path, /*service*/"", "method");
    //QDBusMessage reply = connection.call(msg, QDBus::Block);
}
Пример #15
0
void MainWindow::addCustomBusTab(const QString &busAddress)
{
    QDBusConnection connection = QDBusConnection::connectToBus(busAddress, "QDBusViewer");
    if (connection.isConnected()) {
        QDBusViewer *customBusViewer = new QDBusViewer(connection);
        tabWidget->addTab(customBusViewer, tr("Custom Bus"));
    }
}
PackageKitProxy::PackageKitProxy(QObject *parent):
    QObject(parent)
{
    QDBusConnection bus = QDBusConnection::systemBus();
    qDebug() << "DBus System Connection: " << bus.isConnected();
    qDebug() << "DBus PackageKit transactionListChanged connected" <<
    bus.connect(PKG_SERVICE, PKG_PATH, PKG_IFACE, "TransactionListChanged", this, SLOT(d_onTransactionListChanged(QStringList)));
    qDebug() << "DBus PackageKit updatesChanged connected" <<
    bus.connect(PKG_SERVICE, PKG_PATH, PKG_IFACE, "UpdatesChanged", this, SLOT(d_onUpdatesChanged()));
    qDebug() << "DBus PackageKit repoListChanged connect" <<
    bus.connect(PKG_SERVICE, PKG_PATH, PKG_IFACE, "RepoListChanged", this, SLOT(d_onRepoListChanged()));
    qDebug() << "DBus PackageKit restartScheduled connect" <<
    bus.connect(PKG_SERVICE, PKG_PATH, PKG_IFACE, "RestartScheduled", this, SLOT(d_onRestartScheduled()));

    PackageKit::Daemon *daemon = PackageKit::Daemon::global();
    qDebug() << "Found backend" << daemon->backendName();
    /*
     *  Bugged and dont work DBus used instead
     *
    qDebug() << "connect repoListChanged" <<
    connect(daemon,SIGNAL(repoListChanged()), SLOT(d_onRepoListChanged()));
    qDebug() << "connect restartScheduled" <<
    connect(daemon,SIGNAL(restartScheduled()), SLOT(d_onRestartScheduled()));
    qDebug() << "connect transactionListChanged" <<
    connect(daemon,SIGNAL(transactionListChanged(const QStringList&)), SLOT(d_onTransactionListChanged(const QStringList&)));
    qDebug() << "connect updatesChanged" <<
    connect(daemon,SIGNAL(updatesChanged()), SLOT(d_onUpdatesChanged()));
    */
    qDebug() << "connect daemonQuit" <<
    connect(daemon,SIGNAL(daemonQuit()), SLOT(d_onDaemonQuit()));

    /*
    qDebug() << "packageArch test" << PackageKit::Daemon::packageArch("ownNotes;1.1.2-1;i586;installed");
    qDebug() << "packageData test" << PackageKit::Daemon::packageData("ownNotes;1.1.2-1;i586;installed");
    qDebug() << "packageIcon test" << PackageKit::Daemon::packageIcon("ownNotes;1.1.2-1;i586;installed");
    qDebug() << "packageName test" << PackageKit::Daemon::packageName("ownNotes;1.1.2-1;i586;installed");
    qDebug() << "packageVersion test" << PackageKit::Daemon::packageVersion("ownNotes;1.1.2-1;i586;installed");

    qDebug() << "packageArch test2" << PackageKit::Daemon::packageArch("ownNotes;1.1.1-1;i586;openrepos-Khertan");
    qDebug() << "packageData test2" << PackageKit::Daemon::packageData("ownNotes;1.1.1-1;i586;openrepos-Khertan");
    qDebug() << "packageIcon test2" << PackageKit::Daemon::packageIcon("ownNotes;1.1.1-1;i586;openrepos-Khertan");
    qDebug() << "packageName test2" << PackageKit::Daemon::packageName("ownNotes;1.1.1-1;i586;openrepos-Khertan");
    qDebug() << "packageVersion test2" << PackageKit::Daemon::packageVersion("ownNotes;1.1.1-1;i586;openrepos-Khertan");
    */

    /*
    qDebug() << "Test install transaction";
    PackageKit::Transaction* tester = createTransaction();
    tester->installPackage("ownNotes;1.1.0-1;i586;openrepos-Khertan");
    /**/

    /*
    qDebug() << "Test remove transaction";
    TransactionProxy* tester = createTransaction();
    //tester->searchNames("ownNotes",PackageKit::Transaction::FilterInstalled);
    tester->removePackage("ownNotes;1.1.0-1;i586;installed");
    /**/
}
Пример #17
0
 // ---------------------------------------------------------------------------------
 void detail::object_to_unregister_from_dbus::from ( QDBusConnection con )
 {
   if ( !con.isConnected() )
   {
     return;
   }
   if ( con.objectRegisteredAt ( _M_path ) != 0 )
   {
     con.unregisterObject ( _M_path );
   }
 }
Пример #18
0
static QDBusConnectionInterface *tryToInitDBusConnection()
{
    // Check the D-Bus connection health
    QDBusConnectionInterface *dbusService = 0;
    QDBusConnection sessionBus = QDBusConnection::sessionBus();
    if (!sessionBus.isConnected() || !(dbusService = sessionBus.interface())) {
        kError() << "KUniqueApplication: Cannot find the D-Bus session server: " << sessionBus.lastError().message() << endl;
        ::exit(255);
    }
    return dbusService;
}
Пример #19
0
/**
 * Construct a new DBusProxy object.
 *
 * \param dbusConnection QDBusConnection to use.
 * \param busName D-Bus bus name of the service that provides the remote object.
 * \param objectPath The object path.
 * \param featureCore The object core feature.
 */
DBusProxy::DBusProxy(const QDBusConnection &dbusConnection,
        const QString &busName, const QString &objectPath, const Feature &featureCore)
    : Object(),
      ReadyObject(this, featureCore),
      mPriv(new Private(dbusConnection, busName, objectPath))
{
    if (!dbusConnection.isConnected()) {
        invalidate(TP_QT_ERROR_DISCONNECTED,
                QLatin1String("DBus connection disconnected"));
    }
}
Пример #20
0
static QDBusConnection tryToInitDBusConnection()
{
  // Check the D-Bus connection health, and connect - but not using QDBusConnection::sessionBus()
  // since we can't close that one before forking.
  QDBusConnection connection = QDBusConnection::connectToBus(
    QDBusConnection::SessionBus, _k_sessionBusName );
  if ( !connection.isConnected() ) {
    kError() << "Cannot find the D-Bus session server" << endl; //krazy:exclude=kdebug
    ::exit( 255 );
  }
  return connection;
}
Пример #21
0
void FlightToggle::onToggleLongPressed()
{
    QDBusMessage message = QDBusMessage::createMethodCall("com.nokia.DuiControlPanel", "/",
                                                          "com.nokia.DuiControlPanelIf", "appletPage");
    QList<QVariant> args;
    args.append(QVariant("Phone network"));
    message.setArguments(args);

    QDBusConnection bus = QDBusConnection::sessionBus();

    if (bus.isConnected())
        bus.send(message);
}
Пример #22
0
int main(int argc, char *argv[])
{
    QCoreApplication::setOrganizationName("Hangish");
    QCoreApplication::setApplicationName("Hangish");
    QCoreApplication::setApplicationVersion("0.6.0");

    QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
    QScopedPointer<QQuickView> view(SailfishApp::createView());
    ConversationModel *conversationModel = new ConversationModel();
    RosterModel *rosterModel = new RosterModel();
    ContactsModel *contactsModel = new ContactsModel();
    FileModel *fileModel = new FileModel();
    Client *c = new Client(rosterModel, conversationModel, contactsModel);
    ImageHandler *ih = new ImageHandler();
    ih->setAuthenticator(c->getAuthenticator());
    //Do this once when app is launching
    ih->cleanCache();

    view->rootContext()->setContextProperty("conversationModel", conversationModel);
    view->rootContext()->setContextProperty("rosterModel", rosterModel);
    view->rootContext()->setContextProperty("contactsModel", contactsModel);
    view->rootContext()->setContextProperty("fileModel", fileModel);
    view->engine()->rootContext()->setContextProperty("Client", c);
    view->engine()->rootContext()->setContextProperty("ImageHandler", ih);


    QDBusConnection system = QDBusConnection::systemBus();
    if (!system.isConnected())
    {
        qFatal("Cannot connect to the D-Bus session bus.");
        return 1;
    }
    system.connect("net.connman",
                   "/net/connman/technology/wifi",
                   "net.connman.Technology",
                   "PropertyChanged",
                   c,
                   SLOT(connectivityChanged(QString,QDBusVariant))
                  );
    system.connect("net.connman",
                   "/net/connman/technology/cellular",
                   "net.connman.Technology",
                   "PropertyChanged",
                   c,
                   SLOT(connectivityChanged(QString,QDBusVariant))
                  );

    view->setSource(SailfishApp::pathTo("qml/harbour-hangish.qml"));
    view->showFullScreen();
    app->exec();
}
Пример #23
0
int main(int argc, char *argv[])
{
	/*
	 * Description:
	 *
	 *This program tries to find the TIM gateway from Quby makeing use of Upnp.
	 *After this it will fetch the information from all sensors and publish it
	 *on the dbus
	 *
	 *UPNP code: https://garage.maemo.org/frs/download.php/8365/libbrisa_0.1.1.tar.gz
	*/

	QCoreApplication app(argc, argv);
	Arguments arg;

	usage(arg);
	if (arg.contains("h")) {
		arg.help();
		exit(0);
	}

	initLogger(QsLogging::InfoLevel);
	if (arg.contains("d"))
		logger.setLoggingLevel((QsLogging::Level)arg.value("d").toInt());

	if (arg.contains("dbus"))
		VBusItems::setDBusAddress(arg.value("dbus"));
	else
		VBusItems::setConnectionType(QDBusConnection::SystemBus);

	QDBusConnection dbus = VBusItems::getConnection("settings");
	if (!dbus.isConnected()) {
		QLOG_ERROR() << "DBus connection failed.";
		exit(EXIT_FAILURE);
	}

	// Wait for local settings to become available on the DBus
	QLOG_INFO() << "Wait for local settings on DBus... ";
	BusItemCons settings("com.victronenergy.settings", "/Settings", dbus);
	QVariant reply = settings.getValue();
	while (reply.isValid() == false) {
		reply = settings.getValue();
		usleep(500000);
		QLOG_INFO() << "Wait...";
	}
	QLOG_INFO() << "Local settings found!";

	Qwacs qwacs(&app, arg.value("g"));

	return app.exec();
}
Пример #24
0
void DBusSender::createInterface()
{
	QDBusConnection	sessionBus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, m_receiverName);

	if (!sessionBus.isConnected()) {
		qDebug() << m_receiverName << "connectToBus() failed";
		return;
	}

	iface = new com::servicename::ifname(m_pathNameBase + m_receiverName,	//target's service name
										 m_objNameBase + m_receiverName,	//target's path name
										 sessionBus,						//connection
										 this);								//parent
}
Пример #25
0
QTM_BEGIN_NAMESPACE

#if defined(BACKEND_NM)
static bool NetworkManagerAvailable()
{
    QDBusConnection dbusConnection = QDBusConnection::systemBus();
    if (dbusConnection.isConnected()) {
        QDBusConnectionInterface *dbiface = dbusConnection.interface();
        QDBusReply<bool> reply = dbiface->isServiceRegistered("org.freedesktop.NetworkManager");
        if (reply.isValid())
            return reply.value();
    }
    return false;
}
Пример #26
0
Callbacks::Callbacks()
{
    new MediaCallbacksAdaptor( this );
    QDBusConnection connection = QDBusConnection::systemBus();
    if ( !connection.isConnected() ) {
	qFatal( "Cannot connect to the D-Bus system bus" );
	exit( 1 );
    }
    connection.registerObject( "/Media", this );
    if ( !connection.registerService( "org.opensuse.MediaCallbacks" ) ) {
	qDebug() << qPrintable( connection.lastError().message() );
	exit( 1 );
    }
}
Пример #27
0
int main(int argc, char *argv[])
{
    QCoreApplication app(argc, argv);

    QDBusConnection con = QDBusConnection::sessionBus();
    if (!con.isConnected())
        exit(1);

    if (!con.registerService(serviceName))
        exit(2);

    ServerObject obj(objectPath, con);
    printf("ready.\n");
    return app.exec();
}
Пример #28
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QMainWindow mw;
#ifndef Q_OS_MAC
    app.setWindowIcon(QIcon(QLatin1String(":/qt-project.org/qdbusviewer/images/qdbusviewer.png")));
#else
    mw.setWindowTitle(qApp->translate("QtDBusViewer", "Qt D-Bus Viewer"));
#endif


    QTabWidget *mainWidget = new QTabWidget;
    mw.setCentralWidget(mainWidget);
    QDBusViewer *sessionBusViewer = new QDBusViewer(QDBusConnection::sessionBus());
    QDBusViewer *systemBusViewer = new QDBusViewer(QDBusConnection::systemBus());
    mainWidget->addTab(sessionBusViewer, QObject::tr("Session Bus"));
    mainWidget->addTab(systemBusViewer, QObject::tr("System Bus"));

    QStringList args = app.arguments();
    while (args.count()) {
        QString arg = args.takeFirst();
        if (arg == QLatin1String("--bus")) {
            QDBusConnection connection = QDBusConnection::connectToBus(args.takeFirst(), "QDBusViewer");
            if (connection.isConnected()) {
                QDBusViewer *customBusViewer = new QDBusViewer(connection);
                mainWidget->addTab(customBusViewer, QObject::tr("Custom Bus"));
            }
        }
    }

    QMenu *fileMenu = mw.menuBar()->addMenu(QObject::tr("&File"));
    QAction *quitAction = fileMenu->addAction(QObject::tr("&Quit"), &mw, SLOT(close()));
    quitAction->setShortcut(QKeySequence::Quit);
    quitAction->setMenuRole(QAction::QuitRole);

    QMenu *helpMenu = mw.menuBar()->addMenu(QObject::tr("&Help"));
    QAction *aboutAction = helpMenu->addAction(QObject::tr("&About"));
    aboutAction->setMenuRole(QAction::AboutRole);
    QObject::connect(aboutAction, SIGNAL(triggered()), sessionBusViewer, SLOT(about()));

    QAction *aboutQtAction = helpMenu->addAction(QObject::tr("About &Qt"));
    aboutQtAction->setMenuRole(QAction::AboutQtRole);
    QObject::connect(aboutQtAction, SIGNAL(triggered()), &app, SLOT(aboutQt()));

    mw.show();

    return app.exec();
}
void DBusConnection::init()
{
    QDBusConnection c = QDBusConnection::sessionBus();
    if (!c.isConnected()) {
        qWarning("Could not connect to DBus session bus.");
        return;
    }

    QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String("org.a11y.Bus"),
                                                    QLatin1String("/org/a11y/bus"),
                                                    QLatin1String("org.a11y.Bus"), QLatin1String("GetAddress"));

    QDBusPendingCall async = c.asyncCall(m);
    m_initWatcher = new QDBusPendingCallWatcher(async, this);
    connect(m_initWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(initFinished()));
}
Пример #30
0
/**
 * main
 */
int main(int argc, char ** argv) {

  QCoreApplication app(argc, argv);
  DBusWatcher * watcher = new DBusWatcher;
  QDBusConnection conn = QDBusConnection::connectToBus(
    QDBusConnection::SystemBus, "org.freedesktop.NetworkManager");
  if(!conn.isConnected()) {
    qDebug() << "Oh. Connection failed:" << conn.lastError();
    return -1;
  }
  conn.connect("org.freedesktop.NetworkManager",
    "/org/freedesktop/NetworkManager", "org.freedesktop.NetworkManager",
    "StateChanged", "u", watcher, SLOT(watch(uint)));

  return app.exec();
}