Merge branch 'master' into develop
This commit is contained in:
commit
060c9ab679
@ -45,7 +45,7 @@ The latest source code for SleekXMPP may be found on `Github
|
|||||||
``develop`` branch.
|
``develop`` branch.
|
||||||
|
|
||||||
**Latest Release**
|
**Latest Release**
|
||||||
- `1.1.8 <http://github.com/fritzy/SleekXMPP/zipball/1.1.8>`_
|
- `1.1.9 <http://github.com/fritzy/SleekXMPP/zipball/1.1.9>`_
|
||||||
|
|
||||||
**Develop Releases**
|
**Develop Releases**
|
||||||
- `Latest Develop Version <http://github.com/fritzy/SleekXMPP/zipball/develop>`_
|
- `Latest Develop Version <http://github.com/fritzy/SleekXMPP/zipball/develop>`_
|
||||||
@ -74,6 +74,7 @@ help with SleekXMPP.
|
|||||||
**Chat**
|
**Chat**
|
||||||
`sleek@conference.jabber.org <xmpp:sleek@conference.jabber.org?join>`_
|
`sleek@conference.jabber.org <xmpp:sleek@conference.jabber.org?join>`_
|
||||||
|
|
||||||
|
|
||||||
Documentation and Testing
|
Documentation and Testing
|
||||||
-------------------------
|
-------------------------
|
||||||
Documentation can be found both inline in the code, and as a Sphinx project in ``/docs``.
|
Documentation can be found both inline in the code, and as a Sphinx project in ``/docs``.
|
||||||
|
@ -91,13 +91,13 @@ class BaseXMPP(XMLStream):
|
|||||||
#: owner JIDs, as in the case for components. For clients
|
#: owner JIDs, as in the case for components. For clients
|
||||||
#: which only have a single JID, see :attr:`client_roster`.
|
#: which only have a single JID, see :attr:`client_roster`.
|
||||||
self.roster = roster.Roster(self)
|
self.roster = roster.Roster(self)
|
||||||
self.roster.add(self.boundjid.bare)
|
self.roster.add(self.boundjid)
|
||||||
|
|
||||||
#: The single roster for the bound JID. This is the
|
#: The single roster for the bound JID. This is the
|
||||||
#: equivalent of::
|
#: equivalent of::
|
||||||
#:
|
#:
|
||||||
#: self.roster[self.boundjid.bare]
|
#: self.roster[self.boundjid.bare]
|
||||||
self.client_roster = self.roster[self.boundjid.bare]
|
self.client_roster = self.roster[self.boundjid]
|
||||||
|
|
||||||
#: The distinction between clients and components can be
|
#: The distinction between clients and components can be
|
||||||
#: important, primarily for choosing how to handle the
|
#: important, primarily for choosing how to handle the
|
||||||
@ -691,17 +691,13 @@ class BaseXMPP(XMLStream):
|
|||||||
msg['to'] = self.boundjid
|
msg['to'] = self.boundjid
|
||||||
self.event('message', msg)
|
self.event('message', msg)
|
||||||
|
|
||||||
def _handle_available(self, presence):
|
def _handle_available(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_available(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_available(presence)
|
|
||||||
|
|
||||||
def _handle_unavailable(self, presence):
|
def _handle_unavailable(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_unavailable(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_unavailable(presence)
|
|
||||||
|
|
||||||
def _handle_new_subscription(self, stanza):
|
def _handle_new_subscription(self, pres):
|
||||||
"""Attempt to automatically handle subscription requests.
|
"""Attempt to automatically handle subscription requests.
|
||||||
|
|
||||||
Subscriptions will be approved if the request is from
|
Subscriptions will be approved if the request is from
|
||||||
@ -713,8 +709,8 @@ class BaseXMPP(XMLStream):
|
|||||||
If a subscription is accepted, a request for a mutual
|
If a subscription is accepted, a request for a mutual
|
||||||
subscription will be sent if :attr:`auto_subscribe` is ``True``.
|
subscription will be sent if :attr:`auto_subscribe` is ``True``.
|
||||||
"""
|
"""
|
||||||
roster = self.roster[stanza['to'].bare]
|
roster = self.roster[pres['to']]
|
||||||
item = self.roster[stanza['to'].bare][stanza['from'].bare]
|
item = self.roster[pres['to']][pres['from']]
|
||||||
if item['whitelisted']:
|
if item['whitelisted']:
|
||||||
item.authorize()
|
item.authorize()
|
||||||
elif roster.auto_authorize:
|
elif roster.auto_authorize:
|
||||||
@ -724,30 +720,20 @@ class BaseXMPP(XMLStream):
|
|||||||
elif roster.auto_authorize == False:
|
elif roster.auto_authorize == False:
|
||||||
item.unauthorize()
|
item.unauthorize()
|
||||||
|
|
||||||
def _handle_removed_subscription(self, presence):
|
def _handle_removed_subscription(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_unauthorize(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].unauthorize()
|
|
||||||
|
|
||||||
def _handle_subscribe(self, presence):
|
def _handle_subscribe(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_subscribe(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_subscribe(presence)
|
|
||||||
|
|
||||||
def _handle_subscribed(self, presence):
|
def _handle_subscribed(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_subscribed(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_subscribed(presence)
|
|
||||||
|
|
||||||
def _handle_unsubscribe(self, presence):
|
def _handle_unsubscribe(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_unsubscribe(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_unsubscribe(presence)
|
|
||||||
|
|
||||||
def _handle_unsubscribed(self, presence):
|
def _handle_unsubscribed(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_unsubscribed(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_unsubscribed(presence)
|
|
||||||
|
|
||||||
def _handle_presence(self, presence):
|
def _handle_presence(self, presence):
|
||||||
"""Process incoming presence stanzas.
|
"""Process incoming presence stanzas.
|
||||||
|
@ -158,10 +158,8 @@ class ComponentXMPP(BaseXMPP):
|
|||||||
"""
|
"""
|
||||||
self.session_bind_event.set()
|
self.session_bind_event.set()
|
||||||
self.session_started_event.set()
|
self.session_started_event.set()
|
||||||
self.event("session_bind", self.xmpp.boundjid.full, direct=True)
|
self.event("session_bind", self.xmpp.boundjid, direct=True)
|
||||||
self.event("session_start")
|
self.event("session_start")
|
||||||
|
|
||||||
def _handle_probe(self, presence):
|
def _handle_probe(self, pres):
|
||||||
pto = presence['to'].bare
|
self.roster[pres['to']][pres['from']].handle_probe(pres)
|
||||||
pfrom = presence['from'].bare
|
|
||||||
self.roster[pto][pfrom].handle_probe(presence)
|
|
||||||
|
@ -50,7 +50,7 @@ class FeatureBind(BasePlugin):
|
|||||||
|
|
||||||
self.xmpp.set_jid(response['bind']['jid'])
|
self.xmpp.set_jid(response['bind']['jid'])
|
||||||
self.xmpp.bound = True
|
self.xmpp.bound = True
|
||||||
self.xmpp.event('session_bind', self.xmpp.boundjid.full, direct=True)
|
self.xmpp.event('session_bind', self.xmpp.boundjid, direct=True)
|
||||||
self.xmpp.session_bind_event.set()
|
self.xmpp.session_bind_event.set()
|
||||||
|
|
||||||
self.xmpp.features.add('bind')
|
self.xmpp.features.add('bind')
|
||||||
|
@ -47,7 +47,7 @@ __all__ = [
|
|||||||
'xep_0172', # User Nickname
|
'xep_0172', # User Nickname
|
||||||
'xep_0184', # Message Receipts
|
'xep_0184', # Message Receipts
|
||||||
'xep_0186', # Invisible Command
|
'xep_0186', # Invisible Command
|
||||||
'xep_0191', # Simple Communications Blocking
|
'xep_0191', # Blocking Command
|
||||||
'xep_0198', # Stream Management
|
'xep_0198', # Stream Management
|
||||||
'xep_0199', # Ping
|
'xep_0199', # Ping
|
||||||
'xep_0202', # Entity Time
|
'xep_0202', # Entity Time
|
||||||
|
@ -22,7 +22,7 @@ log = logging.getLogger(__name__)
|
|||||||
class XEP_0191(BasePlugin):
|
class XEP_0191(BasePlugin):
|
||||||
|
|
||||||
name = 'xep_0191'
|
name = 'xep_0191'
|
||||||
description = 'XEP-0191: Simple Communications Blocking'
|
description = 'XEP-0191: Blocking Command'
|
||||||
dependencies = set(['xep_0030'])
|
dependencies = set(['xep_0030'])
|
||||||
stanza = stanza
|
stanza = stanza
|
||||||
|
|
||||||
|
@ -94,10 +94,12 @@ class Roster(object):
|
|||||||
Arguments:
|
Arguments:
|
||||||
key -- Return the roster for this JID.
|
key -- Return the roster for this JID.
|
||||||
"""
|
"""
|
||||||
if isinstance(key, JID):
|
|
||||||
key = key.bare
|
|
||||||
if key is None:
|
if key is None:
|
||||||
key = self.xmpp.boundjid.bare
|
key = self.xmpp.boundjid
|
||||||
|
if not isinstance(key, JID):
|
||||||
|
key = JID(key)
|
||||||
|
key = key.bare
|
||||||
|
|
||||||
if key not in self._rosters:
|
if key not in self._rosters:
|
||||||
self.add(key)
|
self.add(key)
|
||||||
self._rosters[key].auto_authorize = self.auto_authorize
|
self._rosters[key].auto_authorize = self.auto_authorize
|
||||||
@ -119,8 +121,10 @@ class Roster(object):
|
|||||||
Arguments:
|
Arguments:
|
||||||
node -- The JID for the new roster node.
|
node -- The JID for the new roster node.
|
||||||
"""
|
"""
|
||||||
if isinstance(node, JID):
|
if not isinstance(node, JID):
|
||||||
node = node.bare
|
node = JID(node)
|
||||||
|
|
||||||
|
node = node.bare
|
||||||
if node not in self._rosters:
|
if node not in self._rosters:
|
||||||
self._rosters[node] = RosterNode(self.xmpp, node, self.db)
|
self._rosters[node] = RosterNode(self.xmpp, node, self.db)
|
||||||
|
|
||||||
|
@ -89,8 +89,11 @@ class RosterNode(object):
|
|||||||
|
|
||||||
A new item entry will be created if one does not already exist.
|
A new item entry will be created if one does not already exist.
|
||||||
"""
|
"""
|
||||||
if isinstance(key, JID):
|
if key is None:
|
||||||
key = key.bare
|
key = JID('')
|
||||||
|
if not isinstance(key, JID):
|
||||||
|
key = JID(key)
|
||||||
|
key = key.bare
|
||||||
if key not in self._jids:
|
if key not in self._jids:
|
||||||
self.add(key, save=True)
|
self.add(key, save=True)
|
||||||
return self._jids[key]
|
return self._jids[key]
|
||||||
@ -101,8 +104,11 @@ class RosterNode(object):
|
|||||||
|
|
||||||
To remove an item from the server, use the remove() method.
|
To remove an item from the server, use the remove() method.
|
||||||
"""
|
"""
|
||||||
if isinstance(key, JID):
|
if key is None:
|
||||||
key = key.bare
|
key = JID('')
|
||||||
|
if not isinstance(key, JID):
|
||||||
|
key = JID(key)
|
||||||
|
key = key.bare
|
||||||
if key in self._jids:
|
if key in self._jids:
|
||||||
del self._jids[key]
|
del self._jids[key]
|
||||||
|
|
||||||
|
@ -9,5 +9,5 @@
|
|||||||
# We don't want to have to import the entire library
|
# We don't want to have to import the entire library
|
||||||
# just to get the version info for setup.py
|
# just to get the version info for setup.py
|
||||||
|
|
||||||
__version__ = '1.1.8'
|
__version__ = '1.1.9'
|
||||||
__version_info__ = (1, 1, 8, '', 0)
|
__version_info__ = (1, 1, 9, '', 0)
|
||||||
|
@ -143,3 +143,6 @@ class JID(object):
|
|||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
"""Hash a JID based on the string version of its full JID."""
|
"""Hash a JID based on the string version of its full JID."""
|
||||||
return hash(self.full)
|
return hash(self.full)
|
||||||
|
|
||||||
|
def __copy__(self):
|
||||||
|
return JID(self.jid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user