OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """A bare-bones and non-compliant XMPP server. | 5 """A bare-bones and non-compliant XMPP server. |
6 | 6 |
7 Just enough of the protocol is implemented to get it to work with | 7 Just enough of the protocol is implemented to get it to work with |
8 Chrome's sync notification system. | 8 Chrome's sync notification system. |
9 """ | 9 """ |
10 | 10 |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 Args: | 566 Args: |
567 channel: The channel on which to send the notification. | 567 channel: The channel on which to send the notification. |
568 data: The notification payload. | 568 data: The notification payload. |
569 """ | 569 """ |
570 notification_stanza = self.MakeNotification(channel, data) | 570 notification_stanza = self.MakeNotification(channel, data) |
571 self.ForwardNotification(None, notification_stanza) | 571 self.ForwardNotification(None, notification_stanza) |
572 notification_stanza.unlink() | 572 notification_stanza.unlink() |
573 | 573 |
574 def SetAuthenticated(self, auth_valid): | 574 def SetAuthenticated(self, auth_valid): |
575 self._authenticated = auth_valid | 575 self._authenticated = auth_valid |
576 if not self._authenticated: | |
akalin
2013/05/24 22:58:46
why did this become necessary?
rlarocque
2013/05/29 00:37:55
This was written a while ago, so I don't remember
akalin
2013/06/04 19:23:54
Can you add a comment to this effect in this file?
| |
577 for connection in self._handshake_done_connections: | |
578 connection.close() | |
576 | 579 |
577 def GetAuthenticated(self): | 580 def GetAuthenticated(self): |
578 return self._authenticated | 581 return self._authenticated |
579 | 582 |
580 # XmppConnection delegate methods. | 583 # XmppConnection delegate methods. |
581 def OnXmppHandshakeDone(self, xmpp_connection): | 584 def OnXmppHandshakeDone(self, xmpp_connection): |
582 self._handshake_done_connections.add(xmpp_connection) | 585 self._handshake_done_connections.add(xmpp_connection) |
583 | 586 |
584 def OnXmppConnectionClosed(self, xmpp_connection): | 587 def OnXmppConnectionClosed(self, xmpp_connection): |
585 self._connections.discard(xmpp_connection) | 588 self._connections.discard(xmpp_connection) |
586 self._handshake_done_connections.discard(xmpp_connection) | 589 self._handshake_done_connections.discard(xmpp_connection) |
587 | 590 |
588 def ForwardNotification(self, unused_xmpp_connection, notification_stanza): | 591 def ForwardNotification(self, unused_xmpp_connection, notification_stanza): |
589 if self._notifications_enabled: | 592 if self._notifications_enabled: |
590 for connection in self._handshake_done_connections: | 593 for connection in self._handshake_done_connections: |
591 print 'Sending notification to %s' % connection | 594 print 'Sending notification to %s' % connection |
592 connection.ForwardNotification(notification_stanza) | 595 connection.ForwardNotification(notification_stanza) |
593 else: | 596 else: |
594 print 'Notifications disabled; dropping notification' | 597 print 'Notifications disabled; dropping notification' |
OLD | NEW |