Example #1
0
    def __init__(self, path, member, interface, destination=None,
                 signature=None, body=None):
        """
        @param path: C{str} DBus object path of the object sending the signal
        @param member: C{str} Member name
        @param interface: C{str} DBus interface name or None
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        """
        marshal.validateMemberName(member)
        marshal.validateInterfaceName(interface)

        if destination:
            marshal.validateBusName(destination)

        self.path = path
        self.member = member
        self.interface = interface
        self.destination = destination
        self.signature = signature
        self.body = body

        self._marshal()
Example #2
0
    def __init__(self, path, member, interface, destination=None,
                 signature=None, body=None):
        """
        @param path: C{str} DBus object path of the object sending the signal
        @param member: C{str} Member name
        @param interface: C{str} DBus interface name or None
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        """
        marshal.validateMemberName(member)
        marshal.validateInterfaceName(interface)

        if destination:
            marshal.validateBusName(destination)

        self.path = path
        self.member = member
        self.interface = interface
        self.destination = destination
        self.signature = signature
        self.body = body

        self._marshal()
Example #3
0
    def __init__(self, error_name, reply_serial, destination=None,
                 signature=None, body=None, sender=None):
        """
        @param error_name: C{str} DBus error name
        @param reply_serial: C{int} serial number this message is a reply to
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        @param sender: C{str} name of the originating Bus connection
        """
        if destination:
            marshal.validateBusName(destination)

        marshal.validateInterfaceName(error_name)

        self.error_name = error_name
        self.reply_serial = marshal.UInt32(reply_serial)
        self.destination = destination
        self.signature = signature
        self.body = body
        self.sender = sender

        self._marshal()
Example #4
0
    def __init__(self, error_name, reply_serial, destination=None,
                 signature=None, body=None, sender=None):
        """
        @param error_name: C{str} DBus error name
        @param reply_serial: C{int} serial number this message is a reply to
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        @param sender: C{str} name of the originating Bus connection
        """
        if destination:
            marshal.validateBusName(destination)

        marshal.validateInterfaceName(error_name)

        self.error_name = error_name
        self.reply_serial = marshal.UInt32(reply_serial)
        self.destination = destination
        self.signature = signature
        self.body = body
        self.sender = sender

        self._marshal()
Example #5
0
    def __init__(self,
                 path,
                 member,
                 interface=None,
                 destination=None,
                 signature=None,
                 body=None,
                 expectReply=True,
                 autoStart=True,
                 oobFDs=None):
        """
        @param path: C{str} DBus object path
        @param member: C{str} Member name
        @param interface: C{str} DBus interface name or None
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        @param expectReply: True if a Method Return message should be sent
                            in reply to this message
        @param autoStart: True if the Bus should auto-start a service to handle
                          this message if the service is not already running.
        """

        marshal.validateMemberName(member)

        if interface:
            marshal.validateInterfaceName(interface)

        if destination:
            marshal.validateBusName(destination)

        if path == '/org/freedesktop/DBus/Local':
            raise error.MarshallingError(
                '/org/freedesktop/DBus/Local is a reserved path')

        self.path = path
        self.member = member
        self.interface = interface
        self.destination = destination
        self.signature = signature
        self.body = body
        self.expectReply = expectReply
        self.autoStart = autoStart
        self.oobFDs = oobFDs

        self._marshal(oobFDs=oobFDs)
Example #6
0
    def __init__(
        self,
        path,
        member,
        interface=None,
        destination=None,
        signature=None,
        body=None,
        expectReply=True,
        autoStart=True,
    ):
        """
        @param path: C{str} DBus object path
        @param member: C{str} Member name
        @param interface: C{str} DBus interface name or None
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        @param expectReply: True if a Method Return message should be sent
                            in reply to this message
        @param autoStart: True if the Bus should auto-start a service to handle
                          this message if the service is not already running.
        """

        marshal.validateMemberName(member)

        if interface:
            marshal.validateInterfaceName(interface)

        if destination:
            marshal.validateBusName(destination)

        if path == "/org/freedesktop/DBus/Local":
            raise error.MarshallingError("/org/freedesktop/DBus/Local is a reserved path")

        self.path = path
        self.member = member
        self.interface = interface
        self.destination = destination
        self.signature = signature
        self.body = body
        self.expectReply = expectReply
        self.autoStart = autoStart

        self._marshal()
Example #7
0
    def __init__(self, reply_serial, body=None, destination=None, signature=None):
        """
        @param reply_serial: C{int} serial number this message is a reply to
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        """
        if destination:
            marshal.validateBusName(destination)

        self.reply_serial = marshal.UInt32(reply_serial)
        self.destination = destination
        self.signature = signature
        self.body = body

        self._marshal()
Example #8
0
    def __init__(self, reply_serial, body=None, destination=None,
                 signature=None):
        """
        @param reply_serial: C{int} serial number this message is a reply to
        @param destination: C{str} DBus bus name for message destination or
                            None
        @param signature: C{str} DBus signature string for encoding
                          C{self.body}
        @param body: C{list} of python objects to encode. Objects must match
                     the C{self.signature}
        """
        if destination:
            marshal.validateBusName(destination)

        self.reply_serial = marshal.UInt32(reply_serial)
        self.destination = destination
        self.signature = signature
        self.body = body

        self._marshal()
Example #9
0
    def dbus_RequestName(self, name, flags, dbusCaller=None):
        caller = self.clients[ dbusCaller ]

        allow_replacement = bool(flags & 0x1)
        replace_existing  = bool(flags & 0x2)
        do_not_queue      = bool(flags & 0x4)

        if not name:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs',
                         'Empty string is not a valid bus name')

        if name[0] == ':':
           raise DError('org.freedesktop.DBus.Error.InvalidArgs',
                        'Cannot acquire a service starting with \':\' such as "%s"' %
                        (name,))

        try:
            marshal.validateBusName(name)
        except error.MarshallingError, e:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs', str(e))
Example #10
0
    def dbus_RequestName(self, name, flags, dbusCaller=None):
        caller = self.clients[dbusCaller]

        allow_replacement = bool(flags & 0x1)
        replace_existing = bool(flags & 0x2)
        do_not_queue = bool(flags & 0x4)

        if not name:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs',
                         'Empty string is not a valid bus name')

        if name[0] == ':':
            raise DError(
                'org.freedesktop.DBus.Error.InvalidArgs',
                'Cannot acquire a service starting with \':\' such as "%s"' %
                (name, ))

        try:
            marshal.validateBusName(name)
        except error.MarshallingError, e:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs', str(e))
Example #11
0
    def dbus_RequestName(self, name, flags, dbusCaller=None):
        caller = self.clients[ dbusCaller ]

        allow_replacement = bool(flags & 0x1)
        replace_existing  = bool(flags & 0x2)
        do_not_queue      = bool(flags & 0x4)

        if not name:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs',
                         'Empty string is not a valid bus name')

        if name[0] == ':':
           raise DError('org.freedesktop.DBus.Error.InvalidArgs',
                        'Cannot acquire a service starting with \':\' such as "%s"' %
                        (name,))

        try:
            marshal.validateBusName(name)
        except error.MarshallingError as e:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs', str(e))


        def signalAcq(old_owner_name):
            self.sendSignal( caller, 'NameAcquired', 's', name )
            self.broadcastSignal('NameOwnerChanged', 'sss',
                                 [name, old_owner_name, caller.uniqueName])
            

        if not name in self.busNames:
            self.busNames[ name ] = [caller,]
            caller.busNames[ name ] =  allow_replacement

            signalAcq( '' )
            
            return client.NAME_ACQUIRED
        else:
            queue = self.busNames[ name ]
            owner = queue[0]

            if owner is caller:
                # Update the replacement flag
                owner.busNames[ name ] = allow_replacement

                return client.NAME_ALREADY_OWNER
            else:
                if not replace_existing:
                    return client.NAME_IN_USE
                
                if owner.busNames[name]:
                    del queue[0]
                    queue.insert(0,caller)
                    del owner.busNames[ name ]
                    caller.busNames[ name ] = allow_replacement
                    self.sendSignal( owner,  'NameLost',     's', name )
                    signalAcq( owner.uniqueName )
                    return client.NAME_ACQUIRED
                else:
                    if do_not_queue:
                        return client.NAME_IN_USE
                    
                    queue.append(caller)
                    caller.busNames[ name ] = allow_replacement
                    
                    return client.NAME_IN_QUEUE
Example #12
0
File: bus.py Project: pliu6/txdbus
    def dbus_RequestName(self, name, flags, dbusCaller=None):
        caller = self.clients[dbusCaller]

        allow_replacement = bool(flags & 0x1)
        replace_existing = bool(flags & 0x2)
        do_not_queue = bool(flags & 0x4)

        if not name:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs',
                         'Empty string is not a valid bus name')

        if name[0] == ':':
            raise DError(
                'org.freedesktop.DBus.Error.InvalidArgs',
                'Cannot acquire a service starting with \':\' such as "%s"' %
                (name, ))

        try:
            marshal.validateBusName(name)
        except error.MarshallingError as e:
            raise DError('org.freedesktop.DBus.Error.InvalidArgs', str(e))

        def signalAcq(old_owner_name):
            self.sendSignal(caller, 'NameAcquired', 's', name)
            self.broadcastSignal('NameOwnerChanged', 'sss',
                                 [name, old_owner_name, caller.uniqueName])

        if not name in self.busNames:
            self.busNames[name] = [
                caller,
            ]
            caller.busNames[name] = allow_replacement

            signalAcq('')

            return client.NAME_ACQUIRED
        else:
            queue = self.busNames[name]
            owner = queue[0]

            if owner is caller:
                # Update the replacement flag
                owner.busNames[name] = allow_replacement

                return client.NAME_ALREADY_OWNER
            else:
                if not replace_existing:
                    return client.NAME_IN_USE

                if owner.busNames[name]:
                    del queue[0]
                    queue.insert(0, caller)
                    del owner.busNames[name]
                    caller.busNames[name] = allow_replacement
                    self.sendSignal(owner, 'NameLost', 's', name)
                    signalAcq(owner.uniqueName)
                    return client.NAME_ACQUIRED
                else:
                    if do_not_queue:
                        return client.NAME_IN_USE

                    queue.append(caller)
                    caller.busNames[name] = allow_replacement

                    return client.NAME_IN_QUEUE