Recive Signals in Python when Service was written in Java

hannehomuth hannehomuth1 at gmx.de
Fri Jul 18 07:51:44 PDT 2008


Hi again,

I've another question. I wrote my own dbus Service with Java and this
service emitting some signals. I also wrote a little "Client" in Java which
could connect to the remote object call some methods and recives some
signals. All fine. Now we wanna integrate this service into an python app
which a workmate wrote. I mean, we wanna call some methods of my service in
that python app and recive signals in there, you know. Because my workmate
is not at work today and my service is ready i thought I will try to write a
little python example. I've already called some methods from my python app
and now I want to recive the signals which were send by the daemon
(service.., whatever). My Question  is which name the signal has. Is it the
classname of the signal in java or is there something special?

Here the java class

/**
     * This class represents an Signal which will be send when the user
pressed a key
     * on the PicoLcd Keypad an the daemon was listening to that event
     */
    public static class KeyPressedSignal extends DBusSignal {

        /**
         * Contains the Integer Value of the last pressed key
         * Could be compared with the constant fields in this class
         */
        Integer whichKey;
        
        /**
         * Constant field
         */
        public static final int OK = 1;
        public static final int UP = 2;
        public static final int DOWN = 3;
        public static final int LEFT = 4;
        public static final int RIGHT = 5;
        public static final int PLUS = 6;
        public static final int SUB = 7;
        public static final int F1 = 8;
        public static final int F2 = 9;
        public static final int F3 = 10;
        public static final int F4 = 11;
        public static final int F5 = 12;
        public static final int UNKNOWN = -1;

        /**
         * Constructor. Makes an new instance of this class
         * @param objectPath
         * The ObjectPath from which this signal came from
         * @param arguments
         * The Integer Value of the last pressed key
         * @throws org.freedesktop.dbus.exceptions.DBusException
         */
        public KeyPressedSignal(String objectPath, Integer arguments) throws
DBusException {
            super(objectPath, arguments);
            whichKey = arguments;
        }

        /**
         * Gets the value of the last pressed key
         * @return
         * An Integer whichs value could be compared with the constant
fields
         */
        public Integer getWhichKey() {
            return whichKey;
        }
    }


And here the python snippet


def catchall_testservice_interface_handler(hello_string, dbus_message):
	print "de.sourcepark.PicoLccd interface says " + hello_string + " when it
sent signal " + dbus_message.get_member()
def main():
	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
		
	bus = dbus.SystemBus()
	
	bus.add_signal_receiver(catchall_testservice_interface_handler,
dbus_interface = "de.sourcepark.PicoLcd", signal_name = "KeyPressedSignal")
...
...
...
...

Thx for suggestions 
-- 
View this message in context: http://www.nabble.com/Recive-Signals-in-Python-when-Service-was-written-in-Java-tp18531021p18531021.html
Sent from the Free Desktop - dbus mailing list archive at Nabble.com.



More information about the dbus mailing list