[ create a new paste ] login | about

Link: http://codepad.org/JiFvX4vK    [ raw code | fork ]

C++, pasted on Feb 23:
using GLib;
using DBus;

public class Pronto {

    private Connection dbusConn;

    public Pronto() {
    
        try {
        
            // Get the session bus
            this.dbusConn = DBus.Bus.get(DBus.BusType.SESSION);
            
        } catch (DBus.Error dbe) {
        
            // Print out the error and run for the hills!
            stdout.printf("Unable to obtain the session bus. [%s]\n", dbe.message);
            Posix.exit(1);
        
        }
            
    }
    
    public void setup() {
            
        RawError e = new RawError();
          
        // Match only notifications
        this.dbusConn.get_connection().add_match("interface=org.freedesktop.Notifications", ref e);
                
        // Add our filter function
        this.dbusConn.get_connection().add_filter(this.messageFilter);
    
    }
    
    public RawHandlerResult messageFilter(RawConnection connection, RawMessage message) {
        
        if (message.get_interface() == "org.freedesktop.Notifications" && message.get_member() == "Notify") {
                                
            return RawHandlerResult.HANDLED;
        
        }
    
        return RawHandlerResult.NOT_YET_HANDLED;
    
    }
    
    public static int main (string[] args) {
    
        var p = new Pronto();
        p.setup();
        
        var mainLoop = new MainLoop();
        mainLoop.run();
    
        return 0;
    
    }

}


Create a new paste based on this one


Comments: