示例#1
0
/////////////////////////////////////// PUBLIC FUNCTIONS ////////////////////////////////
//
// Function to connect to a notification server.
void NotifyClient::connectToServer()
{
	// return now if we already have a valid connection
  if (b_validconnection) return;

  notifyclient = new QDBusInterface(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, QDBusConnection::sessionBus(), this); 
  if (notifyclient->isValid() ) {
    b_validconnection = true;
    getServerInformation();
    getCapabilities();  
    QDBusConnection::sessionBus().connect(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, "NotificationClosed", this, SLOT(notificationClosed(quint32, quint32)));
    QDBusConnection::sessionBus().connect(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, "ActionInvoked", this, SLOT(actionInvoked(quint32, QString)));
    } // if connection is valid 
  else {
    notifyclient->deleteLater();
    b_validconnection = false;
  }	// else connection not valid
}
示例#2
0
void dbus_poll(int timeout)
{
        DBusMessage *dbus_msg;

        dbus_connection_read_write(dbus_conn, timeout);

        dbus_msg = dbus_connection_pop_message(dbus_conn);

        while (dbus_msg) {
                if (dbus_message_is_method_call
                    (dbus_msg, "org.freedesktop.DBus.Introspectable", "Introspect")) {
                        dbus_introspect(dbus_msg);
                }

                if (dbus_message_is_method_call(dbus_msg,
                                                "org.freedesktop.Notifications",
                                                "Notify")) {
                        notify(dbus_msg);
                }
                if (dbus_message_is_method_call(dbus_msg,
                                                "org.freedesktop.Notifications",
                                                "GetCapabilities")) {
                        getCapabilities(dbus_msg);
                }
                if (dbus_message_is_method_call(dbus_msg,
                                                "org.freedesktop.Notifications",
                                                "GetServerInformation")) {
                        getServerInformation(dbus_msg);
                }
                if (dbus_message_is_method_call(dbus_msg,
                                                "org.freedesktop.Notifications",
                                                "CloseNotification")) {
                        closeNotification(dbus_msg);
                }
                dbus_message_unref(dbus_msg);
                dbus_msg = dbus_connection_pop_message(dbus_conn);
        }
}
示例#3
0
文件: dunst_dbus.c 项目: wm4/dunst
void
dbus_poll(void) {
    DBusMessage *dbus_msg;

    /* make timeout smaller if we are displaying a message
     * to improve responsivness for mouse clicks
     */
    if(msgqueue == NULL) {
        dbus_connection_read_write(dbus_conn, DBUS_POLL_TIMEOUT);
    } else {
        dbus_connection_read_write(dbus_conn, 100);
    }

    dbus_msg = dbus_connection_pop_message(dbus_conn);
    /* we don't have a new message */
    if(dbus_msg == NULL) {
        return;
    }

    if(dbus_message_is_method_call(dbus_msg,
                "org.freedesktop.Notifications","Notify")) {
        notify(dbus_msg);
    }
    if(dbus_message_is_method_call(dbus_msg,
                "org.freedesktop.Notifications", "GetCapabilities")) {
        getCapabilities(dbus_msg);
    }
    if(dbus_message_is_method_call(dbus_msg,
                "org.freedesktop.Notifications", "GetServerInformation")) {
        getServerInformation(dbus_msg);
    }
    if(dbus_message_is_method_call(dbus_msg,
                "org.freedesktop.Notifications", "CloseNotification")) {
        closeNotification(dbus_msg);
    }
    dbus_message_unref(dbus_msg);
}