don't use the force_nonSASL option (doesn't work in xmpp)
we can now be disconected while registering a new account, it won't TB
This commit is contained in:
parent
3f9e735f8f
commit
0758769092
|
@ -137,7 +137,8 @@ class Connection:
|
||||||
for handler in self.handlers[event]:
|
for handler in self.handlers[event]:
|
||||||
handler(self.name, data)
|
handler(self.name, data)
|
||||||
|
|
||||||
def _discover(self, ns, jid, node = None): #FIXME: this is in features.py but it is blocking
|
# this is in features.py but it is blocking
|
||||||
|
def _discover(self, ns, jid, node = None):
|
||||||
if not self.connection:
|
if not self.connection:
|
||||||
return
|
return
|
||||||
iq = common.xmpp.Iq(typ = 'get', to = jid, queryNS = ns)
|
iq = common.xmpp.Iq(typ = 'get', to = jid, queryNS = ns)
|
||||||
|
@ -227,7 +228,6 @@ class Connection:
|
||||||
|
|
||||||
def _presenceCB(self, con, prs):
|
def _presenceCB(self, con, prs):
|
||||||
"""Called when we recieve a presence"""
|
"""Called when we recieve a presence"""
|
||||||
# if prs.getXNode(common.xmpp.NS_DELAY): return
|
|
||||||
who = str(prs.getFrom())
|
who = str(prs.getFrom())
|
||||||
prio = prs.getPriority()
|
prio = prs.getPriority()
|
||||||
if not prio:
|
if not prio:
|
||||||
|
@ -583,8 +583,9 @@ class Connection:
|
||||||
gajim.log.debug('Connected to server')
|
gajim.log.debug('Connected to server')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
auth = con.auth(name, self.password, resource,
|
#FIXME: blocking
|
||||||
not gajim.config.get_per('accounts', self.name, 'force_nonSASL')) #FIXME: blocking
|
auth = con.auth(name, self.password, resource, 1) #FIXME: non SASL doesn't work currently
|
||||||
|
# not gajim.config.get_per('accounts', self.name, 'force_nonSASL'))
|
||||||
except IOError: #probably a timeout
|
except IOError: #probably a timeout
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
|
@ -600,7 +601,7 @@ class Connection:
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR', _('Authentication failed with %s, check your login and password') % name)
|
self.dispatch('ERROR', _('Authentication failed with %s, check your login and password') % name)
|
||||||
return None
|
return None
|
||||||
# END connect
|
# END connect
|
||||||
|
|
||||||
def register_handler(self, event, function):
|
def register_handler(self, event, function):
|
||||||
if event in self.handlers:
|
if event in self.handlers:
|
||||||
|
@ -786,7 +787,8 @@ class Connection:
|
||||||
def register_agent(self, agent, info):
|
def register_agent(self, agent, info):
|
||||||
if not self.connection:
|
if not self.connection:
|
||||||
return
|
return
|
||||||
common.xmpp.features.register(self.connection, agent, info) # FIXME: Blocking
|
# FIXME: Blocking
|
||||||
|
common.xmpp.features.register(self.connection, agent, info)
|
||||||
|
|
||||||
def new_account(self, name, config):
|
def new_account(self, name, config):
|
||||||
# If a connection already exist we cannot create a new account
|
# If a connection already exist we cannot create a new account
|
||||||
|
@ -797,30 +799,40 @@ class Connection:
|
||||||
'user': config['proxyuser'], 'password': config['proxypass']}
|
'user': config['proxyuser'], 'password': config['proxypass']}
|
||||||
else:
|
else:
|
||||||
proxy = None
|
proxy = None
|
||||||
c = common.xmpp.Client(server = config['hostname'], debug = [])
|
if gajim.verbose:
|
||||||
con_type = c.connect(proxy = proxy)
|
c = common.xmpp.Client(server = config['hostname'])
|
||||||
|
else:
|
||||||
|
c = common.xmpp.Client(server = config['hostname'], debug = [])
|
||||||
|
common.xmpp.dispatcher.DefaultTimeout = 45
|
||||||
|
c.UnregisterDisconnectHandler(c.DisconnectHandler)
|
||||||
|
c.RegisterDisconnectHandler(self._disconnectedCB)
|
||||||
|
port = 5222
|
||||||
|
# if usessl:
|
||||||
|
# port = 5223
|
||||||
|
#FIXME: blocking
|
||||||
|
con_type = c.connect((config['hostname'], port), proxy = proxy)
|
||||||
if not con_type:
|
if not con_type:
|
||||||
gajim.log.debug("Couldn't connect to %s" % name)
|
gajim.log.debug("Couldn't connect to %s" % name)
|
||||||
self.dispatch('ERROR', _("Couldn't connect to %s") % name)
|
self.dispatch('ERROR', _("Couldn't connect to %s") % name)
|
||||||
return False
|
return False
|
||||||
|
gajim.log.debug('Connected to server')
|
||||||
|
# FIXME! This blocks!
|
||||||
|
req = common.xmpp.features.getRegInfo(c, config['hostname']).asDict()
|
||||||
|
req['username'] = config['name']
|
||||||
|
req['password'] = config['password']
|
||||||
|
if not common.xmpp.features.register(c, config['hostname'], req):
|
||||||
|
self.dispatch('ERROR', _('Error: ') + c.lastErr)
|
||||||
|
return False
|
||||||
|
self.name = name
|
||||||
|
self.connected = 0
|
||||||
|
self.password = config['password']
|
||||||
|
if USE_GPG:
|
||||||
|
self.gpg = GnuPG.GnuPG()
|
||||||
|
gajim.config.set('usegpg', True)
|
||||||
else:
|
else:
|
||||||
gajim.log.debug('Connected to server')
|
gajim.config.set('usegpg', False)
|
||||||
req = common.xmpp.features.getRegInfo(c, config['hostname']).asDict() # FIXME! This blocks!
|
gajim.connections[name] = self
|
||||||
req['username'] = config['name']
|
self.dispatch('ACC_OK', (name, config))
|
||||||
req['password'] = config['password']
|
|
||||||
if not common.xmpp.features.register(c, config['hostname'], req): #FIXME: error
|
|
||||||
self.dispatch('ERROR', _('Error: ') + c.lastErr)
|
|
||||||
else:
|
|
||||||
self.name = name
|
|
||||||
self.connected = 0
|
|
||||||
self.password = config['password']
|
|
||||||
if USE_GPG:
|
|
||||||
self.gpg = GnuPG.GnuPG()
|
|
||||||
gajim.config.set('usegpg', True)
|
|
||||||
else:
|
|
||||||
gajim.config.set('usegpg', False)
|
|
||||||
gajim.connections[name] = self
|
|
||||||
self.dispatch('ACC_OK', (name, config))
|
|
||||||
|
|
||||||
def account_changed(self, new_name):
|
def account_changed(self, new_name):
|
||||||
self.name = new_name
|
self.name = new_name
|
||||||
|
@ -930,7 +942,8 @@ class Connection:
|
||||||
iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\
|
iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\
|
||||||
common.xmpp.NS_MUC_OWNER)
|
common.xmpp.NS_MUC_OWNER)
|
||||||
query = iq.getTag('query')
|
query = iq.getTag('query')
|
||||||
x = query.setTag(common.xmpp.NS_DATA + ' x', attrs = {'type': 'submit'}) # FIXME: should really use XData class
|
# FIXME: should really use XData class
|
||||||
|
x = query.setTag(common.xmpp.NS_DATA + ' x', attrs = {'type': 'submit'})
|
||||||
i = 0
|
i = 0
|
||||||
while config.has_key(i):
|
while config.has_key(i):
|
||||||
if not config[i].has_key('type'):
|
if not config[i].has_key('type'):
|
||||||
|
@ -1006,4 +1019,4 @@ class Connection:
|
||||||
gajim.log.debug('error appeared while processing xmpp:')
|
gajim.log.debug('error appeared while processing xmpp:')
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
self.connection = None
|
self.connection = None
|
||||||
# END GajimCore
|
# END Connection
|
||||||
|
|
Loading…
Reference in New Issue