Changeset 49:537d1413b661 in ralphm-patches for roster_server.patch


Ignore:
Timestamp:
May 25, 2011, 9:50:21 AM (10 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Save work after moving stuff to keep from wokkel.xmppim to wokkel.im.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roster_server.patch

    r37 r49  
    1 diff -r 7b9f484b0b44 wokkel/xmppim.py
    2 --- a/wokkel/xmppim.py  Fri Feb 12 19:49:36 2010 +0100
    3 +++ b/wokkel/xmppim.py  Sat Feb 13 18:57:26 2010 +0100
    4 @@ -12,6 +12,7 @@
    5  All of it should eventually move to Twisted.
    6  """
     1diff -r 3c5fb05162e1 wokkel/im.py
     2--- a/wokkel/im.py      Wed May 25 09:39:42 2011 +0200
     3+++ b/wokkel/im.py      Wed May 25 09:40:28 2011 +0200
     4@@ -14,7 +14,7 @@
    75 
     6 from twisted.internet import defer
     7 from twisted.words.protocols.jabber.jid import JID, internJID
     8-from twisted.words.protocols.jabber import error
    89+from twisted.words.protocols.jabber import error, xmlstream
    9  from twisted.words.protocols.jabber.jid import JID
    1010 from twisted.words.xish import domish
    1111 
    12 @@ -22,6 +23,9 @@
    13  NS_XML = 'http://www.w3.org/XML/1998/namespace'
     12 from wokkel.compat import IQ
     13@@ -25,6 +25,7 @@
    1414 NS_ROSTER = 'jabber:iq:roster'
    1515 
    16 +XPATH_ROSTER_GET = "//iq[@type='get']/query[@xmlns='%s']" % NS_ROSTER
    17 +XPATH_ROSTER_SET = "//iq[@type='set']/query[@xmlns='%s']" % NS_ROSTER
    18 +
    19  class Presence(domish.Element):
    20      def __init__(self, to=None, type=None):
    21          domish.Element.__init__(self, (None, "presence"))
    22 @@ -636,6 +640,7 @@
     16 XPATH_ROSTER_SET = "/iq[@type='set']/query[@xmlns='%s']" % NS_ROSTER
     17+XPATH_ROSTER_GET = "/iq[@type='get']/query[@xmlns='%s']" % NS_ROSTER
    2318 
    2419 
    2520 
    26 +
    27  class RosterClientProtocol(XMPPHandler):
    28      """
    29      Client side XMPP roster protocol.
    30 @@ -645,6 +650,7 @@
    31          ROSTER_SET = "/iq[@type='set']/query[@xmlns='%s']" % NS_ROSTER
    32          self.xmlstream.addObserver(ROSTER_SET, self._onRosterSet)
    33  
    34 +
    35      def _parseRosterItem(self, element):
    36          jid = JID(element['jid'])
    37          item = RosterItem(jid)
    38 @@ -659,6 +665,7 @@
    39  
    40          return item
    41  
    42 +
    43      def getRoster(self):
    44          """
    45          Retrieve contact list.
    46 @@ -713,6 +720,7 @@
    47              item = self._parseRosterItem(iq.query.item)
    48              self.onRosterSet(item)
    49  
    50 +
    51      def onRosterSet(self, item):
    52          """
    53          Called when a roster push for a new or update item was received.
    54 @@ -721,6 +729,7 @@
    55          @type item: L{RosterItem}
    56          """
    57  
    58 +
    59      def onRosterRemove(self, entity):
    60          """
    61          Called when a roster push for the removal of an item was received.
    62 @@ -729,6 +738,48 @@
     21@@ -579,3 +580,43 @@
     22         @param entity: The entity for which the roster item has been removed.
    6323         @type entity: L{JID}
    6424         """
    65  
     25+
    6626+
    6727+
     
    8949+        iq.handled = True
    9050+
    91 +        d = self.getRoster(JID(iq["from"]))
     51+        d = self.getRoster(internJID(iq["from"]))
    9252+        d.addCallback(self._toRosterReply, iq)
    9353+        d.addErrback(lambda _: error.ErrorStanza('internal-error').toResponse(iq))
     
    10363+    def getRoster(self, entity):
    10464+        raise NotImplemented
    105 +
    106 +
    107 +
    108  class MessageProtocol(XMPPHandler):
    109      """
    110      Generic XMPP subprotocol handler for incoming message stanzas.
Note: See TracChangeset for help on using the changeset viewer.