mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
fixed some presence bugs
This commit is contained in:
parent
e06cdec81a
commit
8d5dbfa691
4 changed files with 11 additions and 7 deletions
|
@ -5,9 +5,13 @@ import logging
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info < (3,0):
|
||||||
reload(sys)
|
reload(sys)
|
||||||
sys.setdefaultencoding('utf8')
|
sys.setdefaultencoding('utf8')
|
||||||
|
|
||||||
|
|
||||||
class Example(sleekxmpp.ClientXMPP):
|
class Example(sleekxmpp.ClientXMPP):
|
||||||
|
|
||||||
def __init__(self, jid, password):
|
def __init__(self, jid, password):
|
||||||
|
|
|
@ -279,15 +279,15 @@ class basexmpp(object):
|
||||||
self.roster[jid]['presence'][resource] = {'show': show, 'status': status}
|
self.roster[jid]['presence'][resource] = {'show': show, 'status': status}
|
||||||
self.roster[jid]['presence'][resource]['priority'] = priority
|
self.roster[jid]['presence'][resource]['priority'] = priority
|
||||||
name = self.roster[jid].get('name', '')
|
name = self.roster[jid].get('name', '')
|
||||||
if wasoffline and show in ('available', 'away', 'xa', 'na', 'ffc'):
|
if wasoffline and (show == 'available' or show in presence.showtypes):
|
||||||
self.event("got_online", presence)
|
self.event("got_online", presence)
|
||||||
elif not wasoffline and show == 'unavailable':
|
elif not wasoffline and show == 'unavailable':
|
||||||
self.event("got_offline", presence)
|
|
||||||
logging.debug("%s %s got offline" % (jid, resource))
|
logging.debug("%s %s got offline" % (jid, resource))
|
||||||
if len(self.roster[jid]['presence']) > 1:
|
if len(self.roster[jid]['presence']) > 1:
|
||||||
del self.roster[jid]['presence'][resource]
|
del self.roster[jid]['presence'][resource]
|
||||||
else:
|
else:
|
||||||
del self.roster[jid]
|
del self.roster[jid]
|
||||||
|
self.event("got_offline", presence)
|
||||||
elif oldroster != self.roster.get(jid, {'presence': {}})['presence'].get(resource, {}):
|
elif oldroster != self.roster.get(jid, {'presence': {}})['presence'].get(resource, {}):
|
||||||
self.event("changed_status", presence)
|
self.event("changed_status", presence)
|
||||||
name = ''
|
name = ''
|
||||||
|
|
|
@ -6,7 +6,7 @@ from . rootstanza import RootStanza
|
||||||
class Presence(RootStanza):
|
class Presence(RootStanza):
|
||||||
interfaces = set(('type', 'to', 'from', 'id', 'status', 'priority'))
|
interfaces = set(('type', 'to', 'from', 'id', 'status', 'priority'))
|
||||||
types = set(('available', 'unavailable', 'error', 'probe', 'subscribe', 'subscribed', 'unsubscribe', 'unsubscribed'))
|
types = set(('available', 'unavailable', 'error', 'probe', 'subscribe', 'subscribed', 'unsubscribe', 'unsubscribed'))
|
||||||
showtypes = set(('dnd', 'ffc', 'xa', 'away'))
|
showtypes = set(('dnd', 'chat', 'xa', 'away'))
|
||||||
sub_interfaces = set(('status', 'priority'))
|
sub_interfaces = set(('status', 'priority'))
|
||||||
name = 'presence'
|
name = 'presence'
|
||||||
namespace = 'jabber:client'
|
namespace = 'jabber:client'
|
||||||
|
|
|
@ -154,7 +154,7 @@ class XMLStream(object):
|
||||||
def _process(self):
|
def _process(self):
|
||||||
"Start processing the socket."
|
"Start processing the socket."
|
||||||
firstrun = True
|
firstrun = True
|
||||||
while firstrun or self.state['reconnect']:
|
while self.run and (firstrun or self.state['reconnect']):
|
||||||
self.state.set('processing', True)
|
self.state.set('processing', True)
|
||||||
firstrun = False
|
firstrun = False
|
||||||
try:
|
try:
|
||||||
|
@ -229,7 +229,7 @@ class XMLStream(object):
|
||||||
edepth += 1
|
edepth += 1
|
||||||
|
|
||||||
def _sendThread(self):
|
def _sendThread(self):
|
||||||
while True:
|
while self.run:
|
||||||
data = self.sendqueue.get(True)
|
data = self.sendqueue.get(True)
|
||||||
logging.debug("SEND: %s" % data)
|
logging.debug("SEND: %s" % data)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue