Remove trailing whitespaces.

This commit is contained in:
Emmanuel Gil Peyrot 2013-01-18 17:55:34 +01:00
commit 27b3592e16

View file

@ -28,7 +28,7 @@ from calendar import timegm
class SatXMPPClient(client.XMPPClient):
def __init__(self, host_app, profile, user_jid, password, host=None, port=5222):
client.XMPPClient.__init__(self, user_jid, password, host, port)
self.factory.clientConnectionLost = self.connectionLost
@ -39,7 +39,7 @@ class SatXMPPClient(client.XMPPClient):
self.conn_deferred = defer.Deferred()
self._waiting_conf = {} #callback called when a confirmation is received
self._progress_cb_map = {} #callback called when a progress is requested (key = progress id)
def getConnectionDeferred(self):
"""Return a deferred which fire when the client is connected"""
@ -53,28 +53,28 @@ class SatXMPPClient(client.XMPPClient):
info (_("********** [%s] CONNECTED **********") % self.profile)
self.streamInitialized()
self.host_app.bridge.connected(self.profile) #we send the signal to the clients
def streamInitialized(self):
"""Called after _authd"""
debug (_("XML stream is initialized"))
self.keep_alife = task.LoopingCall(self.xmlstream.send, " ") #Needed to avoid disconnection (specially with openfire)
self.keep_alife.start(180)
self.disco = SatDiscoProtocol(self)
self.disco.setHandlerParent(self)
self.discoHandler = disco.DiscoHandler()
self.discoHandler.setHandlerParent(self)
if not self.host_app.trigger.point("Disco Handled", self.profile):
return
self.roster.requestRoster()
self.presence.available()
self.disco.requestInfo(jid.JID(self.jid.host)).addCallback(self.host_app.serverDisco, self.profile) #FIXME: use these informations
self.disco.requestItems(jid.JID(self.jid.host)).addCallback(self.host_app.serverDiscoItems, self.disco, self.profile, self.client_initialized)
self.conn_deferred.callback(None)
@ -90,7 +90,7 @@ class SatXMPPClient(client.XMPPClient):
def isConnected(self):
return self.__connected
def connectionLost(self, connector, unused_reason):
self.__connected=False
info (_("********** [%s] DISCONNECTED **********") % self.profile)
@ -103,7 +103,7 @@ class SatXMPPClient(client.XMPPClient):
class SatMessageProtocol(xmppim.MessageProtocol):
def __init__(self, host):
xmppim.MessageProtocol.__init__(self)
self.host = host
@ -128,7 +128,7 @@ class SatMessageProtocol(xmppim.MessageProtocol):
self.host.memory.addToHistory(jid.JID(message["from"]), jid.JID(message["to"]), mess_body, mess_type, profile=self.parent.profile)
self.host.bridge.newMessage(message["from"], mess_body, mess_type, message['to'], extra, profile=self.parent.profile)
break
class SatRosterProtocol(xmppim.RosterClientProtocol):
def __init__(self, host):
@ -138,7 +138,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
#XXX: the two following dicts keep a local copy of the roster
self._groups = {} #map from groups to bare jids: key=group value=set of bare jids
self._jids = {} #map from bare jids to RosterItem: key=jid value=RosterItem
def rosterCb(self, roster):
for raw_jid, item in roster.iteritems():
self.onRosterSet(item)
@ -153,7 +153,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
"""Remove a contact from roster list"""
xmppim.RosterClientProtocol.removeItem(self, to)
#TODO: check IQ result
#XXX: disabled (cf http://wokkel.ik.nu/ticket/56))
#def addItem(self, to):
#"""Add a contact to roster list"""
@ -187,7 +187,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
if item.name:
item_attr['name'] = item.name
return item_attr
def onRosterSet(self, item):
"""Called when a new/update roster item is received"""
#TODO: send a signal to frontends
@ -199,13 +199,13 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
return
info (_("new contact in roster list: %s"), item.jid.full())
#self.host.memory.addContact(item.jid, item_attr, item.groups, self.parent.profile)
bare_jid = item.jid.userhost()
self._jids[bare_jid] = item
for group in item.groups:
self._groups.setdefault(group,set()).add(bare_jid)
self.host.bridge.newContact(item.jid.full(), self.getAttributes(item), item.groups, self.parent.profile)
def onRosterRemove(self, entity):
"""Called when a roster removal event is received"""
print _("removing %s from roster list") % entity.full()
@ -226,7 +226,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
except KeyError:
log.warning("there is not cache for the group [%(groups)s] of the removed roster item [%(jid)s]" %
{"group": group, "jid": bare_jid})
#then we send the bridge signal
self.host.bridge.contactDeleted(entity.userhost(), self.parent.profile)
@ -247,7 +247,7 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
def isJidInRoster(self, entity_jid):
"""Return True if jid is in roster"""
return entity_jid.userhost() in self._jids
def getItems(self):
"""Return all items of the roster"""
return self._jids.values()
@ -257,20 +257,20 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
return self._groups[group]
except KeyError:
return exceptions.UnknownGroupError
class SatPresenceProtocol(xmppim.PresenceClientProtocol):
def __init__(self, host):
xmppim.PresenceClientProtocol.__init__(self)
self.host = host
def availableReceived(self, entity, show=None, statuses=None, priority=0):
debug (_("presence update for [%(entity)s] (available, show=%(show)s statuses=%(statuses)s priority=%(priority)d)") % {'entity':entity, 'show':show, 'statuses':statuses, 'priority':priority})
if not statuses:
statuses = {}
if statuses.has_key(None): #we only want string keys
statuses["default"] = statuses[None]
del statuses[None]
@ -281,13 +281,13 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
#now it's time to notify frontends
self.host.bridge.presenceUpdate(entity.full(), show or "",
int(priority), statuses, self.parent.profile)
def unavailableReceived(self, entity, statuses=None):
debug (_("presence update for [%(entity)s] (unavailable, statuses=%(statuses)s)") % {'entity':entity, 'statuses':statuses})
if not statuses:
statuses = {}
if statuses.has_key(None): #we only want string keys
statuses["default"] = statuses[None]
del statuses[None]
@ -295,13 +295,13 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
#now it's time to notify frontends
self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile)
def available(self, entity=None, show=None, statuses=None, priority=0):
if not statuses:
statuses = {}
# default for us is None for wokkel
# so we must temporarily switch to wokkel's convention...
# so we must temporarily switch to wokkel's convention...
if 'default' in statuses:
statuses[None] = statuses['default']
@ -380,10 +380,10 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
self.answer_id = answer_id
self.profile = profile
print _("Registration asked for"),user_login, user_pass, jabber_host
def connectionMade(self):
print "connectionMade"
self.xmlstream.namespace = "jabber:client"
self.xmlstream.sendHeader()
@ -405,7 +405,7 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
answer_data={"message":_("Registration successfull")}
self.host.bridge.actionResult(answer_type, self.answer_id, answer_data, self.profile)
self.xmlstream.sendFooter()
def registrationFailure(self, failure):
info (_("Registration failure: %s") % str(failure.value))
answer_type = "ERROR"