diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-07-01 21:32:44 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-07-01 21:32:44 +0000 |
commit | 33c291c9a945da009ab6849855dc3c66ecc103fa (patch) | |
tree | e2381d3dd80c4487d58e454a1d3c3e6685683367 /src | |
parent | 450c234cd3c21032fe7dd10f754fbda0855ef2ac (diff) | |
download | poezio-33c291c9a945da009ab6849855dc3c66ecc103fa.tar.gz poezio-33c291c9a945da009ab6849855dc3c66ecc103fa.tar.bz2 poezio-33c291c9a945da009ab6849855dc3c66ecc103fa.tar.xz poezio-33c291c9a945da009ab6849855dc3c66ecc103fa.zip |
server on /join can be omitted, fixed #1525 Also reorganize various functions in common.py and update CHANGELOG
Diffstat (limited to 'src')
-rw-r--r-- | src/common.py | 52 | ||||
-rw-r--r-- | src/connection.py | 20 | ||||
-rw-r--r-- | src/gui.py | 15 | ||||
-rw-r--r-- | src/multiuserchat.py | 12 | ||||
-rw-r--r-- | src/window.py | 3 |
5 files changed, 67 insertions, 35 deletions
diff --git a/src/common.py b/src/common.py index d5851bed..3edc9e14 100644 --- a/src/common.py +++ b/src/common.py @@ -43,6 +43,7 @@ import curses import sys import select import errno +import xmpp def debug(string): """ @@ -103,6 +104,57 @@ def is_in_path(command, return_abs_path=False): pass return False +def get_stripped_jid(jid): + """ + Return the stripped JID (bare representation) + nick@server/resource -> nick@server + """ + if isinstance(jid, basestring): + jid = xmpp.JID(jid) + return jid.getStripped() + +def is_jid(jid): + """ + Return True if this is a valid JID + """ + if xmpp.JID(jid).getNode() != '': + return True + return False + +def jid_get_node(jid): + """ + nick@server/resource -> nick + """ + if isinstance(jid, basestring): + jid = xmpp.JID(jid) + return jid.getNode() + +def jid_get_domain(jid): + """ + nick@server/resource -> server + """ + if isinstance(jid, basestring): + jid = xmpp.JID(jid) + return jid.getDomain() + +def jid_get_resource(jid): + """ + nick@server/resource -> resource + """ + if isinstance(jid, basestring): + jid = xmpp.JID(jid) + return jid.getResource() + +def is_jid_the_same(a, b): + """ + Compare two bare jids + """ + if isinstance(a, basestring): + a = xmpp.JID(a) + if isinstance(b, basestring): + b = xmpp.JID(b) + return a.bareMatch(b) + DISTRO_INFO = { 'Arch Linux': '/etc/arch-release', 'Aurox Linux': '/etc/aurox-release', diff --git a/src/connection.py b/src/connection.py index 3b4e6e21..f24403a8 100644 --- a/src/connection.py +++ b/src/connection.py @@ -25,12 +25,13 @@ from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) import sys +import threading import xmpp from config import config from logging import logger from handler import Handler -import threading +from common import jid_get_node, jid_get_domain, is_jid_the_same class Connection(threading.Thread): """ @@ -194,20 +195,3 @@ 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() - -def is_jid_the_same(a, b): - if isinstance(a, basestring): - a = xmpp.JID(a) - if isinstance(b, basestring): - b = xmpp.JID(b) - return a.bareMatch(b) @@ -38,7 +38,7 @@ from user import User from room import Room from message import Message -from connection import is_jid_the_same +from common import is_jid_the_same, jid_get_domain, is_jid def doupdate(): curses.doupdate() @@ -600,13 +600,18 @@ class Gui(object): nick = r.own_nick else: room = info[0] - # if len(room.split('@')) == 1: # no server is provided, like "/join hello" - # serv = self.current_room().name.split('/')[0] - # room += '@' + self.current_room. + if not is_jid(room): # no server is provided, like "/join hello" + # use the server of the current room if available + # check if the current room's name has a server + if is_jid(self.current_room().name): + room += '@%s' % jid_get_domain(self.current_room().name) + else: # no server could be found, print a message and return + self.information(_("You didn't specify a server for the room you want to join")) + return r = self.get_room_by_name(room) if len(args) == 2: # a password is provided password = args[1] - if r and r.joined: # if we are already in the room + if r and r.joined: # if we are already in the room self.information(_("already in room [%s]") % room) return self.muc.join_room(room, nick, password) diff --git a/src/multiuserchat.py b/src/multiuserchat.py index 0ac52725..4fb0d389 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -29,16 +29,8 @@ from time import (altzone, gmtime, localtime, strftime, timezone) from handler import Handler from config import config -def get_stripped_jid(jid): - """Return the stripped JID (bare representation)""" - if isinstance(jid, basestring): - jid = JID(jid) - return jid.getStripped() - -def is_jid(jid): - """Return True if this is a valid JID""" - if JID(jid).getNode() != '': - return True +from common import get_stripped_jid +from common import is_jid class VcardSender(threading.Thread): """ diff --git a/src/window.py b/src/window.py index 2ee52b5e..9b3d9ce1 100644 --- a/src/window.py +++ b/src/window.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with Poezio. If not, see <http://www.gnu.org/licenses/>. - from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) from os.path import isfile @@ -100,7 +99,7 @@ class UserList(Win): self.win.addnstr(y, 0, " ", 1) self.win.attroff(curses.color_pair(show_col)) self.win.attron(curses.color_pair(role_col)) - self.win.addnstr(y, 1, user.nick, self.width-2) + self.win.addnstr(y, 1, user.nick, self.width-1) self.win.attroff(curses.color_pair(role_col)) y += 1 if y == self.height: |