diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-05-21 13:16:40 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-05-21 13:16:40 +0000 |
commit | 36c5269b0ef1773eb1b578e8d288785c19581bbf (patch) | |
tree | eadfc816be725d8f4a92d1ea8081627c54995972 /src | |
parent | 45e0615cd0e8818422ea709295a6d9485b3b3612 (diff) | |
download | poezio-36c5269b0ef1773eb1b578e8d288785c19581bbf.tar.gz poezio-36c5269b0ef1773eb1b578e8d288785c19581bbf.tar.bz2 poezio-36c5269b0ef1773eb1b578e8d288785c19581bbf.tar.xz poezio-36c5269b0ef1773eb1b578e8d288785c19581bbf.zip |
non-anonymous authentication, fixed #1185
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.py | 32 | ||||
-rw-r--r-- | src/gui.py | 2 |
2 files changed, 28 insertions, 6 deletions
diff --git a/src/connection.py b/src/connection.py index b7326291..7b000cf5 100644 --- a/src/connection.py +++ b/src/connection.py @@ -49,7 +49,10 @@ class Connection(threading.Thread): threading.Thread.__init__(self) self.handler = Handler() self.daemon = True # exit the program when this thread exits - self.server = server + if config.get('jid', '') == '': + self.server = server + else: + self.server = jid_get_domain(config.get('jid', '')) self.resource = resource self.online = 0 # 1:connected, 2:auth confirmed self.jid = '' # we don't know our jid yet (anon account) @@ -65,9 +68,10 @@ class Connection(threading.Thread): if not self.connect_to_server(self.server, self.port): self.handler.emit('error', msg='Could not connect to server') sys.exit(-1) - if not self.authenticate(): + if not self.authenticate(config.get('jid', '') == ''): self.handler.emit('error', msg='Could not authenticate to server') sys.exit(-1) + # TODO, become invisible before sendInitPresence self.client.sendInitPresence(requestRoster=0) self.online = 1 # 2 when confirmation of our auth is received self.register_handlers() @@ -75,6 +79,9 @@ class Connection(threading.Thread): self.process() def connect_to_server(self, server, port): + """ + Connect to the server + """ if config.get('use_proxy','false') == 'true': return self.client.connect((server, port), {'host': config.get("proxy_server", ""), @@ -99,10 +106,15 @@ class Connection(threading.Thread): authenticate. Please make sure the server you chose \ (%s) supports anonymous authentication' % (config.get('server', '')))) - return None + return False else: - logger.error('Non-anonymous connections not handled currently') - return None + password = config.get('password', '') + jid = config.get('jid', '') + from common import debug + debug(config.get('server', '')) + auth = self.client.auth(jid_get_node(jid), password, "salut") + debug(repr(auth)) + return auth def register_handlers(self): """ @@ -194,3 +206,13 @@ class Connection(threading.Thread): if not connection: return self.handler.emit('send-time', iq_obj=iq) + +def jid_get_node(jid): + if isinstance(jid, basestring): + jid = xmpp.JID(jid) + return jid.getNode() + +def jid_get_domain(jid): + if isinstance(jid, basestring): + jid = xmpp.JID(jid) + return jid.getDomain() @@ -306,7 +306,7 @@ Avail: Sets your availability to available and (optional) sets your status code = error.getAttr('code') typ = error.getAttr('type') body = error.getTag('text').getData() - self.add_info(r, _('Error: %(code)s-%(msg)s: %(body)s' % + self.add_info(room, _('Error: %(code)s-%(msg)s: %(body)s' % {'msg':msg, 'code':code, 'body':body})) if code == '401': self.add_info(room, _("""To provide a password in order |