summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/en/usage.txt2
-rw-r--r--src/bookmark.py53
-rw-r--r--src/connection.py16
-rw-r--r--src/core.py5
-rw-r--r--src/multiuserchat.py6
-rw-r--r--src/tabs.py12
-rw-r--r--src/xhtml.py5
-rwxr-xr-xupdate.sh15
8 files changed, 71 insertions, 43 deletions
diff --git a/doc/en/usage.txt b/doc/en/usage.txt
index dd9f924f..273ca475 100644
--- a/doc/en/usage.txt
+++ b/doc/en/usage.txt
@@ -316,8 +316,6 @@ their number will change if you close a tab on the left of the list).
*/invite <jid> <room> [reason]*:: Invite _jid_ to _room_ wit _reason_ (if
provided).
-*/decline <room> [reason]*:: Decline invitation to _room_ with _reason_.
-
*/invitations*:: Show the pending invitations.
*/activity <jid>*:: Show the last activity of a contact or a server (its
diff --git a/src/bookmark.py b/src/bookmark.py
index c9659cd2..7fc1e9c0 100644
--- a/src/bookmark.py
+++ b/src/bookmark.py
@@ -58,13 +58,9 @@ class Bookmark(object):
el['jid'] = self.jid
el['autojoin'] = 'true' if self.autojoin else 'false'
if self.nick:
- n = Nick().xml
- n.text = self.nick
- el.append(n)
+ el['nick'] = self.nick
if self.password:
- p = Password().xml
- p.text = self.password
- el.append(p)
+ el['password'] = self.password
return el
def local(self):
@@ -113,18 +109,20 @@ def remove(value):
def stanza_storage(method):
"""Generate a <storage/> stanza with the conference elements."""
- storage = Storage()
+ storage = Bookmarks()
for b in filter(lambda b: b.method == method, bookmarks):
storage.append(b.stanza())
return storage
def save_pep(xmpp):
"""Save the remote bookmarks via PEP."""
- xmpp.plugin['xep_0048'].set_bookmarks(stanza_storage('pep'))
+ xmpp.plugin['xep_0048'].set_bookmarks(stanza_storage('pep'),
+ method='xep_0223')
def save_privatexml(xmpp):
""""Save the remote bookmarks with privatexml."""
- xmpp.plugin['xep_0048'].set_bookmarks_old(stanza_storage('privatexml'))
+ xmpp.plugin['xep_0048'].set_bookmarks(stanza_storage('privatexml'),
+ method='xep_0049')
def save_remote(xmpp, method=preferred):
"""Save the remote bookmarks."""
@@ -132,9 +130,11 @@ def save_remote(xmpp, method=preferred):
try:
if method is 'privatexml':
- xmpp.plugin['xep_0048'].set_bookmarks_old(stanza_storage('privatexml'))
+ xmpp.plugin['xep_0048'].set_bookmarks(stanza_storage('privatexml'),
+ method='xep_0049')
else:
- xmpp.plugin['xep_0048'].set_bookmarks(stanza_storage('pep'))
+ xmpp.plugin['xep_0048'].set_bookmarks(stanza_storage('pep'),
+ method='xep_0223')
except:
import traceback
log.debug("Could not save the bookmarks:\n%s" % traceback.format_exc())
@@ -161,7 +161,7 @@ def save(xmpp, core=None):
def get_pep(xmpp):
"""Add the remotely stored bookmarks via pep to the list."""
try:
- iq = xmpp.plugin['xep_0048'].get_bookmarks()
+ iq = xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0223', block=True)
except:
return False
for conf in iter(iq.xml, '{storage:bookmarks}conference'):
@@ -173,7 +173,7 @@ def get_pep(xmpp):
def get_privatexml(xmpp):
"""Add the remotely stored bookmarks via privatexml to the list."""
try:
- iq = xmpp.plugin['xep_0048'].get_bookmarks_old()
+ iq = xmpp.plugin['xep_0048'].get_bookmarks(method='xep_0049', block=True)
except:
return False
for conf in iter(iq.xml, '{storage:bookmarks}conference'):
@@ -186,18 +186,25 @@ def get_remote(xmpp):
"""Add the remotely stored bookmarks to the list."""
if xmpp.anon:
return
- pep, privatexml = True, True
- for method in methods[1:]:
+ method = config.get('use_bookmarks_method', '')
+ if not method:
+ pep, privatexml = True, True
+ for method in methods[1:]:
+ if method == 'pep':
+ pep = get_pep(xmpp)
+ else:
+ privatexml = get_privatexml(xmpp)
+ if pep and not privatexml:
+ config.set_and_save('use_bookmarks_method', 'pep')
+ elif privatexml and not pep:
+ config.set_and_save('use_bookmarks_method', 'privatexml')
+ elif not pep and not privatexml:
+ config.set_and_save('use_bookmarks_method', '')
+ else:
if method == 'pep':
- pep = get_pep(xmpp)
+ get_pep(xmpp)
else:
- privatexml = get_privatexml(xmpp)
- if pep and not privatexml:
- config.set_and_save('use_bookmarks_method', 'pep')
- elif privatexml and not pep:
- config.set_and_save('use_bookmarks_method', 'privatexml')
- elif not pep and not privatexml:
- config.set_and_save('use_bookmarks_method', '')
+ get_privatexml(xmpp)
def get_local():
"""Add the locally stored bookmarks to the list."""
diff --git a/src/connection.py b/src/connection.py
index 16fb798d..b33e0aab 100644
--- a/src/connection.py
+++ b/src/connection.py
@@ -16,6 +16,7 @@ from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset,
gettext as _)
import getpass
+import sys
import sleekxmpp
from config import config, options
@@ -58,13 +59,26 @@ class Connection(sleekxmpp.ClientXMPP):
self.whitespace_keepalive_interval = int(interval)
else:
self.whitespace_keepalive_interval = 300
+ # Hack to check the sleekxmpp version
+ # TODO: Remove that when a sufficient time has passed since the move
+ try:
+ self.register_plugin('xep_0071')
+ wrong_version = True
+ except:
+ wrong_version = False
+ finally:
+ if wrong_version:
+ print("You are using the wrong sleekxmpp version. Please run "
+ "update.sh again or install the corresponding "
+ "sleekxmpp package.")
+ sys.exit()
+
self.register_plugin('xep_0012')
self.register_plugin('xep_0030')
self.register_plugin('xep_0004')
self.register_plugin('xep_0045')
self.register_plugin('xep_0060')
self.register_plugin('xep_0048')
- self.register_plugin('xep_0071')
self.register_plugin('xep_0085')
self.register_plugin('xep_0191')
if config.get('send_poezio_info', 'true') == 'true':
diff --git a/src/core.py b/src/core.py
index b2e16e85..b30e7ad6 100644
--- a/src/core.py
+++ b/src/core.py
@@ -2432,11 +2432,6 @@ class Core(object):
desc=_('Invite jid in room with reason.'),
shortdesc=_('Invite someone in a room.'),
completion=self.completion_invite)
- self.register_command('decline', self.command_decline,
- usage=_('<room> [reason]'),
- desc=_('Decline the invitation to room with or without reason.'),
- shortdesc=_('Decline an invitation.'),
- completion=self.completion_decline)
self.register_command('invitations', self.command_invitations,
shortdesc=_('Show the pending invitations.'))
self.register_command('bookmarks', self.command_bookmarks,
diff --git a/src/multiuserchat.py b/src/multiuserchat.py
index d3eb70ca..58d2771a 100644
--- a/src/multiuserchat.py
+++ b/src/multiuserchat.py
@@ -79,7 +79,7 @@ def join_groupchat(xmpp, jid, nick, passwd='', maxhistory=None, status=None, sho
stanza.append(x)
stanza.send()
xmpp.plugin['xep_0045'].rooms[jid] = {}
- xmpp.plugin['xep_0045'].our_nicks[jid] = nick
+ xmpp.plugin['xep_0045'].ourNicks[jid] = nick
def leave_groupchat(xmpp, jid, own_nick, msg):
"""
@@ -119,6 +119,8 @@ def set_user_affiliation(xmpp, muc_jid, affiliation, nick=None, jid=None, reason
jid = safeJID(jid)
muc_jid = safeJID(muc_jid)
try:
- return xmpp.plugin['xep_0045'].set_affiliation(muc_jid, jid, nick, affiliation)
+ return xmpp.plugin['xep_0045'].setAffiliation(str(muc_jid), str(jid) if jid else None, nick, affiliation)
except:
+ import traceback
+ log.debug('Error setting the affiliation: %s', traceback.format_exc())
return False
diff --git a/src/tabs.py b/src/tabs.py
index 979db8e4..5836d072 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -526,7 +526,8 @@ class ChatTab(Tab):
msg = self.core.xmpp.make_message(self.get_name())
msg['body'] = body
- msg['xhtml_im'] = arg
+ msg.enable('html')
+ msg['html']['body'] = arg
if isinstance(self, MucTab):
msg['type'] = 'groupchat'
if isinstance(self, ConversationTab):
@@ -1193,7 +1194,8 @@ class MucTab(ChatTab):
# be converted in xhtml.
self.core.events.trigger('muc_say', msg, self)
if msg['body'].find('\x19') != -1:
- msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
+ msg.enable('html')
+ msg['html']['body'] = xhtml.poezio_colors_to_html(msg['body'])
msg['body'] = xhtml.clean_text(msg['body'])
if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and self.remote_wants_chatstates is not False:
msg['chat_state'] = needed
@@ -1820,7 +1822,8 @@ class PrivateTab(ChatTab):
nick_color=get_theme().COLOR_OWN_NICK,
identifier=msg['id'])
if msg['body'].find('\x19') != -1:
- msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
+ msg.enable('html')
+ msg['html']['body'] = xhtml.poezio_colors_to_html(msg['body'])
msg['body'] = xhtml.clean_text(msg['body'])
if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and self.remote_wants_chatstates is not False:
needed = 'inactive' if self.inactive else 'active'
@@ -2950,7 +2953,8 @@ class ConversationTab(ChatTab):
nick_color=get_theme().COLOR_OWN_NICK,
identifier=msg['id'])
if msg['body'].find('\x19') != -1:
- msg['xhtml_im'] = xhtml.poezio_colors_to_html(msg['body'])
+ msg.enable('html')
+ msg['html']['body'] = xhtml.poezio_colors_to_html(msg['body'])
msg['body'] = xhtml.clean_text(msg['body'])
if config.get_by_tabname('send_chat_states', 'true', self.general_jid, True) == 'true' and self.remote_wants_chatstates is not False:
needed = 'inactive' if self.inactive else 'active'
diff --git a/src/xhtml.py b/src/xhtml.py
index a36607d2..1c9c20e7 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -191,7 +191,7 @@ def get_body_from_message_stanza(message):
the body (without any color) otherwise
"""
if config.get('enable_xhtml_im', 'true') == 'true':
- xhtml_body = message['xhtml_im']
+ xhtml_body = message['html']['body']
if xhtml_body:
content = xhtml_to_poezio_colors(xhtml_body)
content = content if content else message['body']
@@ -224,7 +224,7 @@ def ncurses_color_to_html(color):
r = g = b = color / 24 * 6
return '#%02X%02X%02X' % (r*256/6, g*256/6, b*256/6)
-def xhtml_to_poezio_colors(text):
+def xhtml_to_poezio_colors(xml):
def parse_css(css):
def get_color(value):
if value[0] == '#':
@@ -283,7 +283,6 @@ def xhtml_to_poezio_colors(text):
def trim(string):
return re.sub(whitespace_re, ' ', string)
- xml = ET.fromstring(text)
message = ''
if version_info[1] == 2:
elems = xml.iter()
diff --git a/update.sh b/update.sh
index bf526042..7aff4082 100755
--- a/update.sh
+++ b/update.sh
@@ -20,14 +20,23 @@ fi
if [ -e "SleekXMPP" ]
then
+ echo "Removing the old SleekXMPP"
+ rm -rf SleekXMPP
+ rm src/sleekxmpp
+ git clone https://github.com/fritzy/SleekXMPP.git Sleek
+fi
+
+if [ -e "Sleek" ]
+then
echo "Updating SleekXMPP"
- cd SleekXMPP
+ cd Sleek
git pull
cd ..
else
echo "Downloading SleekXMPP"
- git clone git://github.com/louiz/SleekXMPP.git
+ git clone https://github.com/fritzy/SleekXMPP.git Sleek
fi
+
if [ -e ".dnspython.tgz" ]
then
if [ -e "dnspython" ]
@@ -59,5 +68,5 @@ then
echo 'Link src/sleekxmpp already exists'
else
echo "Creating link src/sleekxmpp"
- ln -s ../SleekXMPP/sleekxmpp sleekxmpp
+ ln -s ../Sleek/sleekxmpp sleekxmpp
fi