Example #1
0
 def test_invalid_message_type(self):
     class E(message.ErrorMessage):
         _messageType=99
     try:
         message.parseMessage(E('foo.bar', 5).rawMessage)
         self.assertTrue(False)
     except Exception, e:
         self.assertEquals(str(e), 'Unknown Message Type: 99')
Example #2
0
    def test_invalid_message_type(self):
        class E(message.ErrorMessage):
            _messageType = 99

        try:
            message.parseMessage(E('foo.bar', 5).rawMessage)
            self.assertTrue(False)
        except Exception, e:
            self.assertEquals(str(e), 'Unknown Message Type: 99')
Example #3
0
    def rawDBusMessageReceived(self, rawMsg):
        """
        Called when the raw bytes for a complete DBus message are received

        @param rawMsg: Byte-string containing the complete message
        @type rawMsg: C{str}
        """
        m = message.parseMessage(rawMsg, self._receivedFDs)
        mt = m._messageType

        # only clear self._receivedFDs when the signature contains a unix fd
        # helps avoid a race condition where another message can be received
        # after we receive the unix fd but before the associated unix fd
        # message is received
        if m.signature and 'h' in m.signature:
            self._receivedFDs = []

        if mt == 1:
            self.methodCallReceived(m)
        elif mt == 2:
            self.methodReturnReceived(m)
        elif mt == 3:
            self.errorReceived(m)
        elif mt == 4:
            self.signalReceived(m)
Example #4
0
    def rawDBusMessageReceived(self, raw_msg):
        msg = message.parseMessage( raw_msg )
        mt  = msg._messageType
        
        if not self.uniqueName:
            self.bus.clientConnected(self)

        if not self._called_hello and mt == 1:
            if msg.destination == 'org.freedesktop.DBus':
                if msg.member == 'Hello':
        
                    r = message.MethodReturnMessage( msg.serial,
                                           body        = [ self.uniqueName ],
                                           signature   = 's' )

                    self._called_hello = True
                    self.sendMessage( r )
        
                    return

            else:
                self.transport.loseConnection()
                
        msg.sender = self.uniqueName

        msg._marshal(False) # re-marshal with the sender set and same serial number

        self.bus.messageReceived( self, msg )
Example #5
0
    def rawDBusMessageReceived(self, rawMsg):
        """
        Called when the raw bytes for a complete DBus message are received

        @param rawMsg: Byte-string containing the complete message
        @type rawMsg: C{str}
        """
        m = message.parseMessage(rawMsg, self._receivedFDs)
        mt = m._messageType

        # only remove the number of unix fds used by a message. This helps
        # avoid a race condition where another message can be received after
        # we receive the unix fd but before the associated unix fd message
        # is received
        if hasattr(m, 'unix_fds'):
            self._receivedFDs = self._receivedFDs[m.unix_fds:]

        if mt == 1:
            self.methodCallReceived(m)
        elif mt == 2:
            self.methodReturnReceived(m)
        elif mt == 3:
            self.errorReceived(m)
        elif mt == 4:
            self.signalReceived(m)
Example #6
0
    def rawDBusMessageReceived(self, raw_msg):
        msg = message.parseMessage(raw_msg)
        mt = msg._messageType

        if not self.uniqueName:
            self.bus.clientConnected(self)

        if not self._called_hello and mt == 1:
            if msg.destination == 'org.freedesktop.DBus':
                if msg.member == 'Hello':

                    r = message.MethodReturnMessage(msg.serial,
                                                    body=[self.uniqueName],
                                                    signature='s')

                    self._called_hello = True
                    self.sendMessage(r)

                    return

            else:
                self.transport.loseConnection()

        msg.sender = self.uniqueName

        msg._marshal(
            False)  # re-marshal with the sender set and same serial number

        self.bus.messageReceived(self, msg)
Example #7
0
    def rawDBusMessageReceived(self, rawMsg):
        """
        Called when the raw bytes for a complete DBus message are received

        @param rawMsg: Byte-string containing the complete message
        @type rawMsg: C{str}
        """
        m  = message.parseMessage( rawMsg )
        mt = m._messageType
            
        if mt == 1:
            self.methodCallReceived( m )
        elif mt == 2:
            self.methodReturnReceived( m )
        elif mt == 3:
            self.errorReceived( m )
        elif mt == 4:
            self.signalReceived( m )
Example #8
0
    def rawDBusMessageReceived(self, rawMsg):
        """
        Called when the raw bytes for a complete DBus message are received

        @param rawMsg: Byte-string containing the complete message
        @type rawMsg: C{str}
        """
        m = message.parseMessage(rawMsg)
        mt = m._messageType

        if mt == 1:
            self.methodCallReceived(m)
        elif mt == 2:
            self.methodReturnReceived(m)
        elif mt == 3:
            self.errorReceived(m)
        elif mt == 4:
            self.signalReceived(m)