server on /join can be omitted, fixed #1525 Also reorganize various functions in common.py and update CHANGELOG

This commit is contained in:
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 2010-07-01 21:32:44 +00:00
parent 450c234cd3
commit 33c291c9a9
6 changed files with 73 additions and 35 deletions

View file

@ -2,6 +2,12 @@ This file describes the new features in each poezio release.
For more detailed changelog, see the roadmap:
http://codingteam.net/project/poezio/roadmap
* Poezio 0.6.2 - dev
- Lines are now broken between words and not in the middle of them
- /unquery command
- default nickname is now $USER
- Server on /join command can be omitted
* Poezio 0.6.1 - 13 Jun 2010
- Enable tracebacks

View file

@ -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',

View file

@ -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)

View file

@ -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)

View file

@ -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):
"""

View file

@ -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: