Exemplo n.º 1
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;
    }
}
DbusPopupHandler::~DbusPopupHandler()
{
	QDBusConnection::sessionBus().disconnect("org.freedesktop.DBus",
											 "/org/freedesktop/DBus",
											 "org.freedesktop.DBus",
											 "NameOwnerChanged",
											 this,
											 SLOT(onNameOwnerChanged(QString, QString, QString)));
	delete FNotifyInterface;
}
DbusPopupHandler::DbusPopupHandler()
{
	FAvatars = NULL;
	FNotifications = NULL;
	FNotifyInterface = NULL;

#ifdef DEBUG_RESOURCES_DIR
	FileStorage::setResourcesDirs(FileStorage::resourcesDirs() << DEBUG_RESOURCES_DIR);
#endif

	QDBusConnection::sessionBus().connect("org.freedesktop.DBus",
										  "/org/freedesktop/DBus",
										  "org.freedesktop.DBus",
										  "NameOwnerChanged",
										  this,
										  SLOT(onNameOwnerChanged(QString, QString, QString)));
}