remove the warnings caused by the new version of sleekxmpp, and update the...

remove the warnings caused by the new version of sleekxmpp, and update the connection method (changed also in sleek)
parent 3a66bc99
......@@ -27,7 +27,6 @@ import sleekxmpp
from config import config
from logger import logger
from handler import Handler
from common import jid_get_node, jid_get_domain, is_jid_the_same
class Connection(sleekxmpp.ClientXMPP):
"""
......@@ -35,23 +34,21 @@ class Connection(sleekxmpp.ClientXMPP):
appropriate signals
"""
def __init__(self):
resource = config.get('resource', '')
if config.get('jid', ''):
self.anon = False # Field used to know if we are anonymous or not.
# many features will be handled diferently
# depending on this setting
jid = config.get('jid', '')
jid = '%s/%s' % (config.get('jid', ''), resource)
password = config.get('password', '')
else: # anonymous auth
else: # anonymous auth
self.anon = True
jid = None
jid = '%s/%s' % (config.get('server', 'anon.louiz.org'), resource)
password = None
sleekxmpp.ClientXMPP.__init__(self, jid, password, ssl=True,
resource=config.get('resource', 'poezio'))
sleekxmpp.ClientXMPP.__init__(self, jid, password, ssl=True)
self.registerPlugin('xep_0045')
def start(self):
# TODO, try multiple servers
if self.connect((config.get('server', 'anon.louiz.org'),
config.get('port', 5222))):
if self.connect((config.get('server', 'anon.louiz.org'), config.get('port', 5222))):
self.process(threaded=True)
......@@ -44,7 +44,7 @@ from contact import Contact
from message import Message
from text_buffer import TextBuffer
from keyboard import read_char
from common import is_jid_the_same, jid_get_domain, jid_get_resource, is_jid
from common import jid_get_domain, is_jid
from common import debug
# http://xmpp.org/extensions/xep-0045.html#errorstatus
......@@ -196,13 +196,13 @@ class Gui(object):
Called when we are connected and authenticated
"""
self.information(_("Welcome on Poezio \o/!"))
self.information(_("Your JID is %s") % self.xmpp.fulljid)
self.information(_("Your JID is %s") % self.xmpp.boundjid.full)
if not self.xmpp.anon:
# request the roster
self.xmpp.getRoster()
# send initial presence
self.xmpp.makePresence(pfrom=self.xmpp.jid).send()
self.xmpp.makePresence(pfrom=self.xmpp.boundjid.bare).send()
rooms = config.get('rooms', '')
if rooms == '' or not isinstance(rooms, str):
return
......@@ -426,7 +426,7 @@ class Gui(object):
We received a Private Message (from someone in a Muc)
"""
jid = message['from']
nick_from = jid.resource
nick_from = jid.boundjid.resource
room_from = jid.bare
room = self.get_room_by_name(jid.full) # get the tab with the private conversation
if not room: # It's the first message we receive: create the tab
......@@ -692,7 +692,7 @@ class Gui(object):
"""
open a new conversation tab and focus it if needed
"""
r = Room(room_name, self.xmpp.fulljid)
r = Room(room_name, self.xmpp.boundjid.full)
new_tab = ConversationTab(self.stdscr, r, self.information_win_size)
# insert it in the rooms
if self.current_tab().nb == 0:
......
......@@ -49,7 +49,7 @@ def change_show(xmpp, jid, own_nick, show, status):
Change our 'Show'
"""
pres = xmpp.makePresence(pto='%s/%s' % (jid, own_nick),
pfrom=xmpp.fulljid)
pfrom=xmpp.boundjid.full)
if show: # if show is None, don't put a <show /> tag. It means "online"
pres['type'] = show
if status:
......@@ -64,7 +64,7 @@ def change_subject(xmpp, jid, subject):
msg = xmpp.makeMessage(jid)
msg['type'] = 'groupchat'
msg['subject'] = subject
msg['from'] = xmpp.jid
msg['from'] = xmpp.boundjid.bare
msg.send()
def change_nick(xmpp, jid, nick):
......@@ -72,7 +72,7 @@ def change_nick(xmpp, jid, nick):
Change our own nick in a room
"""
xmpp.makePresence(pto='%s/%s' % (jid, nick),
pfrom=xmpp.jid).send()
pfrom=xmpp.boundjid.bare).send()
def join_groupchat(xmpp, jid, nick, password=None):
"""
......
......@@ -21,7 +21,7 @@ Starting point of poezio. Launches both the Connection and Gui
"""
import os
# chdir in the source directory, so that import are never failed
# chdir in the source directory, to import the modules
# also, no need to use a sh script to "cd" in this directoy
# before launching poezio.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment