python uses unicode internally

This commit is contained in:
Yann Leboulanger 2013-01-01 19:44:25 +01:00
parent e71188a6fa
commit 414e349345
38 changed files with 482 additions and 504 deletions

View File

@ -452,7 +452,7 @@ class CommandWindow:
note = command.getTag('note')
if note:
self.notes_label.set_text(note.getData().decode('utf-8'))
self.notes_label.set_text(note.getData())
self.notes_label.set_no_show_all(False)
self.notes_label.show()
else:
@ -510,7 +510,7 @@ class CommandWindow:
try:
errorname = nbxmpp.NS_STANZAS + ' ' + str(errorid)
errordesc = nbxmpp.ERRORS[errorname][2]
error = errordesc.decode('utf-8')
error = errordesc
del errorname, errordesc
except KeyError: # when stanza doesn't have error description
error = _('Service returned an error.')

View File

@ -141,8 +141,7 @@ class AdvancedConfigurationWindow(object):
"""
optname = model[iter_][C_PREFNAME]
opttype = model[iter_][C_TYPE]
if opttype.decode('utf-8') == self.types['boolean'] or optname == 'password':
if opttype == self.types['boolean'] or optname == 'password':
cell.set_property('editable', False)
else:
cell.set_property('editable', True)
@ -153,10 +152,10 @@ class AdvancedConfigurationWindow(object):
# path[1] is the key name
# path[2] is the root of tree
# last two is optional
path = [model[iter_][0].decode('utf-8')]
path = [model[iter_][0]]
parent = model.iter_parent(iter_)
while parent:
path.append(model[parent][0].decode('utf-8'))
path.append(model[parent][0])
parent = model.iter_parent(parent)
return path
@ -194,17 +193,17 @@ class AdvancedConfigurationWindow(object):
def on_advanced_treeview_row_activated(self, treeview, path, column):
modelpath = self.modelfilter.convert_path_to_child_path(path)
modelrow = self.model[modelpath]
option = modelrow[0].decode('utf-8')
if modelrow[2].decode('utf-8') == self.types['boolean']:
option = modelrow[0]
if modelrow[2] == self.types['boolean']:
for key in self.right_true_dict.keys():
if self.right_true_dict[key] == modelrow[1].decode('utf-8'):
if self.right_true_dict[key] == modelrow[1]:
modelrow[1] = str(key)
newval = {'False': True, 'True': False}[modelrow[1]]
if len(modelpath.get_indices()) > 1:
optnamerow = self.model[modelpath.get_indices()[0]]
optname = optnamerow[0].decode('utf-8')
optname = optnamerow[0]
keyrow = self.model[modelpath.get_indices()[:2]]
key = keyrow[0].decode('utf-8')
key = keyrow[0]
self.remember_option(option + '\n' + key + '\n' + optname,
modelrow[1], newval)
gajim.config.set_per(optname, key, option, newval)
@ -234,13 +233,12 @@ class AdvancedConfigurationWindow(object):
modelpath = self.modelfilter.convert_path_to_child_path(path)
modelrow = self.model[modelpath]
modelpath = modelpath.get_indices()
option = modelrow[0].decode('utf-8')
text = text.decode('utf-8')
option = modelrow[0]
if len(modelpath) > 1:
optnamerow = self.model[modelpath[0]]
optname = optnamerow[0].decode('utf-8')
optname = optnamerow[0]
keyrow = self.model[modelpath[:2]]
key = keyrow[0].decode('utf-8')
key = keyrow[0]
self.remember_option(option + '\n' + key + '\n' + optname, modelrow[1],
text)
gajim.config.set_per(optname, key, option, text)
@ -269,12 +267,12 @@ class AdvancedConfigurationWindow(object):
return
modelpath = self.modelfilter.convert_path_to_child_path(path)
modelrow = self.model[modelpath]
option = modelrow[0].decode('utf-8')
option = modelrow[0]
if len(modelpath) > 1:
optnamerow = self.model[modelpath[0]]
optname = optnamerow[0].decode('utf-8')
optname = optnamerow[0]
keyrow = self.model[modelpath[:2]]
key = keyrow[0].decode('utf-8')
key = keyrow[0]
self.remember_option(option + '\n' + key + '\n' + optname,
modelrow[C_VALUE], default)
gajim.config.set_per(optname, key, option, default)
@ -317,7 +315,7 @@ class AdvancedConfigurationWindow(object):
self.model.append(parent, [name, value, type_])
def visible_func(self, model, treeiter, data):
search_string = self.entry.get_text().decode('utf-8').lower()
search_string = self.entry.get_text().lower()
for it in tree_model_pre_order(model, treeiter):
if model[it][C_TYPE] != '':
opt_path = self.get_option_path(model, it)

View File

@ -84,20 +84,20 @@ class AtomWindow:
# fill the fields
if newentry.feed_link is not None:
self.feed_title_label.set_markup(
u'<span foreground="blue" underline="single">%s</span>' % \
'<span foreground="blue" underline="single">%s</span>' % \
GObject.markup_escape_text(newentry.feed_title))
else:
self.feed_title_label.set_markup(
GObject.markup_escape_text(newentry.feed_title))
self.feed_tagline_label.set_markup(
u'<small>%s</small>' % \
'<small>%s</small>' % \
GObject.markup_escape_text(newentry.feed_tagline))
if newentry.title:
if newentry.uri is not None:
self.entry_title_label.set_markup(
u'<span foreground="blue" underline="single">%s</span>' % \
'<span foreground="blue" underline="single">%s</span>' % \
GObject.markup_escape_text(newentry.title))
else:
self.entry_title_label.set_markup(

View File

@ -620,7 +620,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
message_buffer = self.msg_textview.get_buffer()
start_iter = message_buffer.get_start_iter()
end_iter = message_buffer.get_end_iter()
message = message_buffer.get_text(start_iter, end_iter, False).decode('utf-8')
message = message_buffer.get_text(start_iter, end_iter, False)
xhtml = self.msg_textview.get_xhtml()
# send the message
@ -2842,7 +2842,7 @@ class ChatControl(ChatControlBase):
type_ = model[iter_][2]
if type_ != 'contact': # source is not a contact
return
dropped_jid = data.decode('utf-8')
dropped_jid = data
dropped_transport = gajim.get_transport_name_from_jid(dropped_jid)
c_transport = gajim.get_transport_name_from_jid(c.jid)

View File

@ -100,13 +100,13 @@ class OldEntry(nbxmpp.Node, object):
if main_feed is not None and source_feed is not None:
return u'%s: %s' % (main_feed, source_feed)
return '%s: %s' % (main_feed, source_feed)
elif main_feed is not None:
return main_feed
elif source_feed is not None:
return source_feed
else:
return u''
return ''
feed_title = property(get_feed_title, None, None,
''' Title of feed. It is built from entry''s original feed title and title of feed
@ -173,4 +173,4 @@ class OldEntry(nbxmpp.Node, object):
updated = property(get_updated, None, None,
''' Last significant modification time. ''')
feed_tagline = u''
feed_tagline = ''

View File

@ -133,11 +133,11 @@ def split_db():
try:
import configpaths
OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse(
os.environ[u'appdata']), u'Gajim')
os.environ['appdata']), 'Gajim')
except KeyError:
OLD_LOG_DB_FOLDER = u'.'
OLD_LOG_DB_FOLDER = '.'
else:
OLD_LOG_DB_FOLDER = os.path.expanduser(u'~/.gajim')
OLD_LOG_DB_FOLDER = os.path.expanduser('~/.gajim')
tmp = logger.CACHE_DB_PATH
logger.CACHE_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, 'cache.db')
@ -148,7 +148,7 @@ def split_db():
os.chdir(back)
cur = con.cursor()
cur.execute('''SELECT name FROM sqlite_master WHERE type = 'table';''')
tables = cur.fetchall() # we get [(u'jids',), (u'unread_messages',), ...
tables = cur.fetchall() # we get [('jids',), ('unread_messages',), ...
tables = [t[0] for t in tables]
cur.execute("ATTACH DATABASE '%s' AS cache" % logger.CACHE_DB_PATH)
for table in ('caps_cache', 'rooms_last_message_time', 'roster_entry',
@ -189,22 +189,22 @@ def check_and_possibly_move_config():
if os.name == 'nt':
try:
OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse(
os.environ[u'appdata']), u'Gajim')
os.environ['appdata']), 'Gajim')
except KeyError:
OLD_LOG_DB_FOLDER = u'.'
OLD_LOG_DB_FOLDER = '.'
else:
OLD_LOG_DB_FOLDER = os.path.expanduser(u'~/.gajim')
OLD_LOG_DB_FOLDER = os.path.expanduser('~/.gajim')
if not os.path.exists(OLD_LOG_DB_FOLDER):
return
OLD_LOG_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, u'logs.db')
OLD_CACHE_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, u'cache.db')
vars['OLD_VCARD_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'vcards')
vars['OLD_AVATAR_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'avatars')
vars['OLD_MY_EMOTS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'emoticons')
vars['OLD_MY_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'iconsets')
vars['OLD_MY_MOOD_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'moods')
OLD_LOG_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, 'logs.db')
OLD_CACHE_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, 'cache.db')
vars['OLD_VCARD_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'vcards')
vars['OLD_AVATAR_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'avatars')
vars['OLD_MY_EMOTS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'emoticons')
vars['OLD_MY_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'iconsets')
vars['OLD_MY_MOOD_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'moods')
vars['OLD_MY_ACTIVITY_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER,
u'activities')
'activities')
OLD_CONFIG_FILES = []
OLD_DATA_FILES = []
for f in os.listdir(OLD_LOG_DB_FOLDER):
@ -345,7 +345,7 @@ def check_and_possibly_create_paths():
print(_('%s is a directory but should be a file') % CACHE_DB_PATH)
print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(XTLS_CERTS):
create_path(XTLS_CERTS)
if not os.path.exists(LOCAL_XTLS_CERTS):

View File

@ -104,12 +104,12 @@ class ChangeStatusCommand(AdHocCommand):
var = 'presence-type',
label = 'Type of presence:',
options = [
(u'chat', _('Free for chat')),
(u'online', _('Online')),
(u'away', _('Away')),
(u'xa', _('Extended away')),
(u'dnd', _('Do not disturb')),
(u'offline', _('Offline - disconnect'))],
('chat', _('Free for chat')),
('online', _('Online')),
('away', _('Away')),
('xa', _('Extended away')),
('dnd', _('Do not disturb')),
('offline', _('Offline - disconnect'))],
value = 'online',
required = True),
dataforms.Field('text-multi',
@ -146,7 +146,7 @@ class ChangeStatusCommand(AdHocCommand):
try:
presencedesc = form['presence-desc'].value
except Exception: # same exceptions as in last comment
presencedesc = u''
presencedesc = ''
response, cmd = self.buildResponse(request, status = 'completed')
cmd.addChild('note', {}, _('The status has been changed.'))
@ -197,7 +197,7 @@ class LeaveGroupchatsCommand(AdHocCommand):
options = []
account = self.connection.name
for gc in find_current_groupchats(account):
options.append((u'%s' %(gc[0]), _('%(nickname)s on %(room_jid)s') % \
options.append(('%s' %(gc[0]), _('%(nickname)s on %(room_jid)s') % \
{'nickname': gc[1], 'room_jid': gc[0]}))
if not len(options):
response, cmd = self.buildResponse(request, status = 'completed')
@ -367,7 +367,7 @@ class ConnectionCommands:
if cmd.isVisibleFor(self.isSameJID(jid)):
q.addChild('item', {
# TODO: find the jid
'jid': self.getOurBareJID() + u'/' + self.server_resource,
'jid': self.getOurBareJID() + '/' + self.server_resource,
'node': node,
'name': cmd.commandname})

View File

@ -82,10 +82,10 @@ class ConfigPaths:
# variable 'appdata' is in? Assuming it to be in filesystem
# encoding.
self.config_root = self.cache_root = self.data_root = \
os.path.join(fse(os.environ[u'appdata']), u'Gajim')
os.path.join(fse(os.environ['appdata']), 'Gajim')
except KeyError:
# win9x, in cwd
self.config_root = self.cache_root = self.data_root = u'.'
self.config_root = self.cache_root = self.data_root = '.'
else: # Unices
# Pass in an Unicode string, and hopefully get one back.
if HAVE_XDG:
@ -93,23 +93,23 @@ class ConfigPaths:
if not self.config_root:
# Folder doesn't exist yet.
self.config_root = os.path.join(xdg.BaseDirectory.\
xdg_config_dirs[0], u'gajim')
xdg_config_dirs[0], 'gajim')
self.cache_root = os.path.join(xdg.BaseDirectory.xdg_cache_home,
u'gajim')
'gajim')
self.data_root = xdg.BaseDirectory.save_data_path('gajim')
if not self.data_root:
self.data_root = os.path.join(xdg.BaseDirectory.\
xdg_data_dirs[0], u'gajim')
xdg_data_dirs[0], 'gajim')
else:
expand = os.path.expanduser
base = os.getenv('XDG_CONFIG_HOME') or expand(u'~/.config')
self.config_root = os.path.join(base, u'gajim')
base = os.getenv('XDG_CACHE_HOME') or expand(u'~/.cache')
self.cache_root = os.path.join(base, u'gajim')
base = os.getenv('XDG_DATA_HOME') or expand(u'~/.local/share')
self.data_root = os.path.join(base, u'gajim')
base = os.getenv('XDG_CONFIG_HOME') or expand('~/.config')
self.config_root = os.path.join(base, 'gajim')
base = os.getenv('XDG_CACHE_HOME') or expand('~/.cache')
self.cache_root = os.path.join(base, 'gajim')
base = os.getenv('XDG_DATA_HOME') or expand('~/.local/share')
self.data_root = os.path.join(base, 'gajim')
def add(self, name, type_, path):
self.paths[name] = (type_, path)
@ -138,27 +138,27 @@ class ConfigPaths:
if root is not None:
self.config_root = self.cache_root = self.data_root = root
d = {'MY_DATA': '', 'LOG_DB': u'logs.db', 'MY_CACERTS': u'cacerts.pem',
'MY_EMOTS': u'emoticons', 'MY_ICONSETS': u'iconsets',
'MY_MOOD_ICONSETS': u'moods', 'MY_ACTIVITY_ICONSETS': u'activities',
'PLUGINS_USER': u'plugins', 'MY_PEER_CERTS': u'certs'}
d = {'MY_DATA': '', 'LOG_DB': 'logs.db', 'MY_CACERTS': 'cacerts.pem',
'MY_EMOTS': 'emoticons', 'MY_ICONSETS': 'iconsets',
'MY_MOOD_ICONSETS': 'moods', 'MY_ACTIVITY_ICONSETS': 'activities',
'PLUGINS_USER': 'plugins', 'MY_PEER_CERTS': 'certs'}
for name in d:
self.add(name, TYPE_DATA, windowsify(d[name]))
d = {'MY_CACHE': '', 'CACHE_DB': u'cache.db', 'VCARD': u'vcards',
'AVATAR': u'avatars'}
d = {'MY_CACHE': '', 'CACHE_DB': 'cache.db', 'VCARD': 'vcards',
'AVATAR': 'avatars'}
for name in d:
self.add(name, TYPE_CACHE, windowsify(d[name]))
self.add('MY_CONFIG', TYPE_CONFIG, '')
self.add('MY_CERT', TYPE_CONFIG, '')
basedir = fse(os.environ.get(u'GAJIM_BASEDIR', defs.basedir))
self.add('DATA', None, os.path.join(basedir, windowsify(u'data')))
self.add('ICONS', None, os.path.join(basedir, windowsify(u'icons')))
basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir))
self.add('DATA', None, os.path.join(basedir, windowsify('data')))
self.add('ICONS', None, os.path.join(basedir, windowsify('icons')))
self.add('HOME', None, fse(os.path.expanduser('~')))
self.add('PLUGINS_BASE', None, os.path.join(basedir,
windowsify(u'plugins')))
windowsify('plugins')))
try:
self.add('TMP', None, fse(tempfile.gettempdir()))
except IOError, e:
@ -173,17 +173,17 @@ class ConfigPaths:
pass
def init_profile(self, profile=''):
conffile = windowsify(u'config')
pidfile = windowsify(u'gajim')
secretsfile = windowsify(u'secrets')
pluginsconfdir = windowsify(u'pluginsconfig')
conffile = windowsify('config')
pidfile = windowsify('gajim')
secretsfile = windowsify('secrets')
pluginsconfdir = windowsify('pluginsconfig')
if len(profile) > 0:
conffile += u'.' + profile
pidfile += u'.' + profile
secretsfile += u'.' + profile
pluginsconfdir += u'.' + profile
pidfile += u'.pid'
conffile += '.' + profile
pidfile += '.' + profile
secretsfile += '.' + profile
pluginsconfdir += '.' + profile
pidfile += '.pid'
self.add('CONFIG_FILE', TYPE_CONFIG, conffile)
self.add('PID_FILE', TYPE_CACHE, pidfile)
self.add('SECRETS_FILE', TYPE_DATA, secretsfile)

View File

@ -1017,7 +1017,7 @@ class ConnectionHandlersBase:
gc_contact = gajim.contacts.get_gc_contact(self.name, obj.jid, nick)
if obj.receipt_request_tag and gajim.config.get_per('accounts',
self.name, 'answer_receipts') and ((contact and contact.sub \
not in (u'to', u'none')) or gc_contact) and obj.mtype != 'error':
not in ('to', 'none')) or gc_contact) and obj.mtype != 'error':
receipt = nbxmpp.Message(to=obj.fjid, typ='chat')
receipt.setID(obj.id_)
receipt.setTag('received', namespace='urn:xmpp:receipts',

View File

@ -195,7 +195,7 @@ class DataField(ExtendedNode):
Human-readable description of field meaning
"""
def fget(self):
return self.getTagData('desc') or u''
return self.getTagData('desc') or ''
def fset(self, value):
assert isinstance(value, basestring)
@ -348,7 +348,7 @@ class StringField(DataField):
Value of field. May be any unicode string
"""
def fget(self):
return self.getTagData('value') or u''
return self.getTagData('value') or ''
def fset(self, value):
assert isinstance(value, basestring)
@ -494,7 +494,7 @@ class TextMultiField(DataField):
Value held in field
"""
def fget(self):
value = u''
value = ''
for element in self.iterTags('value'):
value += '\n' + element.getData()
return value[1:]
@ -643,7 +643,7 @@ class DataForm(ExtendedNode):
"""
# TODO: the same code is in TextMultiField. join them
def fget(self):
value = u''
value = ''
for valuenode in self.getTags('instructions'):
value += '\n' + valuenode.getData()
return value[1:]

View File

@ -144,7 +144,7 @@ def parse_resource(resource):
if resource:
try:
from nbxmpp.stringprepare import resourceprep
return resourceprep.prepare(unicode(resource))
return resourceprep.prepare(resource)
except UnicodeError:
raise InvalidFormat, 'Invalid character in resource.'
@ -159,7 +159,7 @@ def prep(user, server, resource):
raise InvalidFormat, _('Username must be between 1 and 1023 chars')
try:
from nbxmpp.stringprepare import nodeprep
user = nodeprep.prepare(unicode(user))
user = nodeprep.prepare(unicode(user)).encode('utf-8')
except UnicodeError:
raise InvalidFormat, _('Invalid character in username.')
else:
@ -170,7 +170,7 @@ def prep(user, server, resource):
raise InvalidFormat, _('Server must be between 1 and 1023 chars')
try:
from nbxmpp.stringprepare import nameprep
server = nameprep.prepare(unicode(server))
server = nameprep.prepare(unicode(server)).encode('utf-8')
except UnicodeError:
raise InvalidFormat, _('Invalid character in hostname.')
else:
@ -181,7 +181,7 @@ def prep(user, server, resource):
raise InvalidFormat, _('Resource must be between 1 and 1023 chars')
try:
from nbxmpp.stringprepare import resourceprep
resource = resourceprep.prepare(unicode(resource))
resource = resourceprep.prepare(unicode(resource)).encode('utf-8')
except UnicodeError:
raise InvalidFormat, _('Invalid character in resource.')
else:
@ -264,7 +264,7 @@ def get_uf_show(show, use_mnemonic = False):
uf_show = Q_('?contact has status:Unknown')
else:
uf_show = Q_('?contact has status:Has errors')
return unicode(uf_show)
return uf_show
def get_uf_sub(sub):
if sub == 'none':
@ -278,7 +278,7 @@ def get_uf_sub(sub):
else:
uf_sub = sub
return unicode(uf_sub)
return uf_sub
def get_uf_ask(ask):
if ask is None:
@ -288,7 +288,7 @@ def get_uf_ask(ask):
else:
uf_ask = ask
return unicode(uf_ask)
return uf_ask
def get_uf_role(role, plural = False):
''' plural determines if you get Moderators or Moderator'''
@ -577,9 +577,6 @@ def reduce_chars_newlines(text, max_chars = 0, max_lines = 0):
string = string[:max_chars - 3] + '...'
return string
if isinstance(text, str):
text = text.decode('utf-8')
if max_lines == 0:
lines = text.split('\n')
else:
@ -1431,7 +1428,7 @@ def get_proxy_info(account):
login = ['', '']
addr = env_http_proxy[0].split(':')
proxy = {'host': addr[0], 'type' : u'http', 'user':login[0]}
proxy = {'host': addr[0], 'type' : 'http', 'user':login[0]}
if len(addr) == 2:
proxy['port'] = addr[1]
@ -1442,7 +1439,7 @@ def get_proxy_info(account):
proxy['pass'] = login[1]
proxy['useauth'] = True
else:
proxy['pass'] = u''
proxy['pass'] = ''
return proxy
except Exception:

View File

@ -37,11 +37,11 @@ def paragraph_direction_mark(text):
for char in text:
bidi = unicodedata.bidirectional(char)
if bidi == 'L':
return u'\u200E'
return '\u200E'
elif bidi == 'AL' or bidi == 'R':
return u'\u200F'
return '\u200F'
return u'\u200E'
return '\u200E'
APP = 'gajim'
DIR = defs.localedir
@ -61,7 +61,7 @@ if os.name == 'nt':
if lang:
os.environ['LANG'] = lang
gettext.install(APP, DIR, unicode = True)
gettext.install(APP, DIR, unicode=False)
if gettext._translations:
_translation = gettext._translations.values()[0]
else:

View File

@ -53,7 +53,7 @@ def kwallet_get(folder, entry):
"-e", entry.encode('utf-8')], stdout=subprocess.PIPE)
pw = p.communicate()[0]
if p.returncode == 0:
return unicode(pw.decode('utf-8'))
return pw
if p.returncode == 1 or p.returncode == 4:
# ENOENT
return False

View File

@ -188,7 +188,7 @@ class Logger:
def get_jids_already_in_db(self):
try:
self.cur.execute('SELECT jid FROM jids')
# list of tupples: [(u'aaa@bbb',), (u'cc@dd',)]
# list of tupples: [('aaa@bbb',), ('cc@dd',)]
rows = self.cur.fetchall()
except sqlite.DatabaseError:
raise exceptions.DatabaseMalformed
@ -1048,6 +1048,8 @@ class Logger:
FROM roster_entry re, jids j
WHERE re.account_jid_id=? AND j.jid_id=re.jid_id''', (account_jid_id,))
for jid, jid_id, name, subscription, ask in self.cur:
jid = jid.encode('utf-8')
name = name.encode('utf-8')
data[jid] = {}
if name:
data[jid]['name'] = name
@ -1071,6 +1073,7 @@ class Logger:
WHERE account_jid_id=? AND jid_id=?''',
(account_jid_id, data[jid]['id']))
for (group_name,) in self.cur:
group_name = group_name.encode('utf-8')
data[jid]['groups'].append(group_name)
del data[jid]['id']

View File

@ -61,7 +61,7 @@ class OptionsParser:
for line in fd:
try:
line = line.decode('utf-8')
line = helpers.ensure_utf8_string(line)
except UnicodeDecodeError:
line = line.decode(locale.getpreferredencoding())
optname, key, subname, value = regex.match(line).groups()
@ -715,7 +715,7 @@ class OptionsParser:
"""
dirs = ['../data', gajim.gajimpaths.data_root, gajim.DATA_DIR]
if os.name != 'nt':
dirs.append(os.path.expanduser(u'~/.gajim'))
dirs.append(os.path.expanduser('~/.gajim'))
for evt in gajim.config.get_per('soundevents'):
path = gajim.config.get_per('soundevents', evt, 'path')
# absolute and relative passes are necessary

View File

@ -120,7 +120,7 @@ else:
# in the JEP
# &nbsp; == u"\u00a0"
self.pub.writer.translator_class.attribution_formats['dash'] = (
u'\u2014', '')
'\u2014', '')
self.pub.process_programmatic_settings(settings_spec,
settings_overrides,
config_section)
@ -137,7 +137,7 @@ else:
output = self.pub.publish(enable_exit_status=enable_exit_status)
# kludge until we can get docutils to stop generating (rare) &nbsp;
# entities
return u'\u00a0'.join(self.pub.writer.parts['fragment'].strip().split(
return '\u00a0'.join(self.pub.writer.parts['fragment'].strip().split(
'&nbsp;'))
Generator = HTMLGenerator()

View File

@ -684,7 +684,7 @@ class PreferencesWindow:
def on_emoticons_combobox_changed(self, widget):
active = widget.get_active()
model = widget.get_model()
emot_theme = model[active][0].decode('utf-8')
emot_theme = model[active][0]
if emot_theme == _('Disabled'):
gajim.config.set('emoticons_theme', '')
else:
@ -770,7 +770,7 @@ class PreferencesWindow:
def on_theme_combobox_changed(self, widget):
model = widget.get_model()
active = widget.get_active()
config_theme = model[active][0].decode('utf-8').replace(' ', '_')
config_theme = model[active][0].replace(' ', '_')
gajim.config.set('roster_theme', config_theme)
@ -800,7 +800,7 @@ class PreferencesWindow:
def on_iconset_combobox_changed(self, widget):
model = widget.get_model()
active = widget.get_active()
icon_string = model[active][1].decode('utf-8')
icon_string = model[active][1]
gajim.config.set('iconset', icon_string)
gtkgui_helpers.reload_jabber_state_images()
@ -1019,7 +1019,7 @@ class PreferencesWindow:
gajim.config.get('autoxatime') * 60)
def on_auto_away_message_entry_changed(self, widget):
gajim.config.set('autoaway_message', widget.get_text().decode('utf-8'))
gajim.config.set('autoaway_message', widget.get_text())
def on_auto_xa_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'autoxa',
@ -1033,7 +1033,7 @@ class PreferencesWindow:
gajim.config.get('autoxatime') * 60)
def on_auto_xa_message_entry_changed(self, widget):
gajim.config.set('autoxa_message', widget.get_text().decode('utf-8'))
gajim.config.set('autoxa_message', widget.get_text())
def on_prompt_online_status_message_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'ask_online_status')
@ -1067,7 +1067,7 @@ class PreferencesWindow:
def on_default_msg_treemodel_row_changed(self, model, path, iter_):
status = model[iter_][0]
message = model[iter_][2].decode('utf-8')
message = model[iter_][2]
message = helpers.to_one_line(message)
gajim.config.set_per('defaultstatusmsg', status, 'enabled',
model[iter_][3])
@ -1084,20 +1084,18 @@ class PreferencesWindow:
gajim.config.del_per('statusmsg', msg)
iter_ = model.get_iter_first()
while iter_:
val = model[iter_][0].decode('utf-8')
val = model[iter_][0]
if model[iter_][1]: # we have a preset message
if not val: # no title, use message text for title
val = model[iter_][1]
gajim.config.add_per('statusmsg', val)
msg = helpers.to_one_line(model[iter_][1].decode('utf-8'))
msg = helpers.to_one_line(model[iter_][1])
gajim.config.set_per('statusmsg', val, 'message', msg)
i = 2
# store mood / activity
for subname in ('activity', 'subactivity', 'activity_text',
'mood', 'mood_text'):
val = model[iter_][i]
if val:
val = val.decode('utf-8')
gajim.config.set_per('statusmsg', val, subname, val)
i += 1
iter_ = model.iter_next(iter_)
@ -1111,7 +1109,7 @@ class PreferencesWindow:
def on_av_combobox_changed(self, combobox, config_name):
model = combobox.get_model()
active = combobox.get_active()
device = model[active][1].decode('utf-8')
device = model[active][1]
gajim.config.set(config_name, device)
def on_audio_input_combobox_changed(self, widget):
@ -1137,7 +1135,7 @@ class PreferencesWindow:
[self.xml.get_object('stun_server_entry')])
def stun_server_entry_changed(self, widget):
gajim.config.set('stun_server', widget.get_text().decode('utf-8'))
gajim.config.set('stun_server', widget.get_text())
def on_applications_combobox_changed(self, widget):
if widget.get_active() == 0:
@ -1148,13 +1146,13 @@ class PreferencesWindow:
self.xml.get_object('custom_apps_frame').show()
def on_custom_browser_entry_changed(self, widget):
gajim.config.set('custombrowser', widget.get_text().decode('utf-8'))
gajim.config.set('custombrowser', widget.get_text())
def on_custom_mail_client_entry_changed(self, widget):
gajim.config.set('custommailapp', widget.get_text().decode('utf-8'))
gajim.config.set('custommailapp', widget.get_text())
def on_custom_file_manager_entry_changed(self, widget):
gajim.config.set('custom_file_manager', widget.get_text().decode('utf-8'))
gajim.config.set('custom_file_manager', widget.get_text())
def on_log_show_changes_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'log_contact_status_changes')
@ -1260,7 +1258,7 @@ class PreferencesWindow:
def on_proxies_combobox_changed(self, widget):
active = widget.get_active()
proxy = widget.get_model()[active][0].decode('utf-8')
proxy = widget.get_model()[active][0]
if proxy == _('None'):
proxy = ''
@ -1371,7 +1369,7 @@ class ManageProxiesWindow:
(model, iter_) = sel.get_selected()
if not iter_:
return
proxy = model[iter_][0].decode('utf-8')
proxy = model[iter_][0]
model.remove(iter_)
gajim.config.del_per('proxies', proxy)
self.xml.get_object('remove_proxy_button').set_sensitive(False)
@ -1386,7 +1384,7 @@ class ManageProxiesWindow:
if self.block_signal:
return
act = widget.get_active()
proxy = self.proxyname_entry.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'useauth', act)
self.xml.get_object('proxyuser_entry').set_sensitive(act)
self.xml.get_object('proxypass_entry').set_sensitive(act)
@ -1395,7 +1393,7 @@ class ManageProxiesWindow:
if self.block_signal:
return
act = widget.get_active()
proxy = self.proxyname_entry.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'bosh_useproxy', act)
self.xml.get_object('proxyhost_entry').set_sensitive(act)
self.xml.get_object('proxyport_entry').set_sensitive(act)
@ -1484,8 +1482,8 @@ class ManageProxiesWindow:
(model, iter_) = sel.get_selected()
if not iter_:
return
old_name = model.get_value(iter_, 0).decode('utf-8')
new_name = widget.get_text().decode('utf-8')
old_name = model.get_value(iter_, 0)
new_name = widget.get_text()
if new_name == '':
return
if new_name == old_name:
@ -1503,42 +1501,42 @@ class ManageProxiesWindow:
types = ['http', 'socks5', 'bosh']
type_ = self.proxytype_combobox.get_active()
self.show_bosh_fields(types[type_]=='bosh')
proxy = self.proxyname_entry.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'type', types[type_])
def on_proxyhost_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8')
value = widget.get_text()
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'host', value)
def on_proxyport_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8')
value = widget.get_text()
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'port', value)
def on_proxyuser_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8')
value = widget.get_text()
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'user', value)
def on_boshuri_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8')
value = widget.get_text()
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'bosh_uri', value)
def on_proxypass_entry_changed(self, widget):
if self.block_signal:
return
value = widget.get_text().decode('utf-8')
proxy = self.proxyname_entry.get_text().decode('utf-8')
value = widget.get_text()
proxy = self.proxyname_entry.get_text()
gajim.config.set_per('proxies', proxy, 'pass', value)
@ -1613,7 +1611,7 @@ class AccountsWindow:
model = self.accounts_treeview.get_model()
iter_ = model.get_iter_first()
while iter_:
acct = model[iter_][0].decode('utf-8')
acct = model[iter_][0]
if account == acct:
self.accounts_treeview.set_cursor(model.get_path(iter_))
return
@ -1693,7 +1691,7 @@ class AccountsWindow:
if sel:
(model, iter_) = sel.get_selected()
if iter_:
account = model[iter_][0].decode('utf-8')
account = model[iter_][0]
else:
account = None
else:
@ -2342,7 +2340,7 @@ class AccountsWindow:
def on_proxies_combobox1_changed(self, widget):
active = widget.get_active()
proxy = widget.get_model()[active][0].decode('utf-8')
proxy = widget.get_model()[active][0]
if proxy == _('None'):
proxy = ''
@ -2384,7 +2382,7 @@ class AccountsWindow:
def on_custom_host_entry1_changed(self, widget):
if self.ignore_events:
return
host = widget.get_text().decode('utf-8')
host = widget.get_text()
if self.option_changed('custom_host', host):
self.need_relogin = True
gajim.config.set_per('accounts', self.current_account, 'custom_host',
@ -2655,7 +2653,7 @@ class AccountsWindow:
def on_first_name_entry2_changed(self, widget):
if self.ignore_events:
return
name = widget.get_text().decode('utf-8')
name = widget.get_text()
if self.option_changed('zeroconf_first_name', name):
self.need_relogin = True
gajim.config.set_per('accounts', self.current_account,
@ -2664,7 +2662,7 @@ class AccountsWindow:
def on_last_name_entry2_changed(self, widget):
if self.ignore_events:
return
name = widget.get_text().decode('utf-8')
name = widget.get_text()
if self.option_changed('zeroconf_last_name', name):
self.need_relogin = True
gajim.config.set_per('accounts', self.current_account,
@ -2673,7 +2671,7 @@ class AccountsWindow:
def on_jabber_id_entry2_changed(self, widget):
if self.ignore_events:
return
id_ = widget.get_text().decode('utf-8')
id_ = widget.get_text()
if self.option_changed('zeroconf_jabber_id', id_):
self.need_relogin = True
gajim.config.set_per('accounts', self.current_account,
@ -2682,7 +2680,7 @@ class AccountsWindow:
def on_email_entry2_changed(self, widget):
if self.ignore_events:
return
email = widget.get_text().decode('utf-8')
email = widget.get_text()
if self.option_changed('zeroconf_email', email):
self.need_relogin = True
gajim.config.set_per('accounts', self.current_account,
@ -2733,7 +2731,7 @@ class FakeDataForm(Gtk.Table, object):
def get_infos(self):
for name in self.entries.keys():
self.infos[name] = self.entries[name].get_text().decode('utf-8')
self.infos[name] = self.entries[name].get_text()
return self.infos
class ServiceRegistrationWindow:
@ -2906,7 +2904,7 @@ class GroupchatConfigWindow:
def on_cell_edited(self, cell, path, new_text):
model = self.affiliation_treeview['outcast'].get_model()
new_text = new_text.decode('utf-8')
new_text = new_text
iter_ = model.get_iter(path)
model[iter_][1] = new_text
@ -2984,12 +2982,12 @@ class GroupchatConfigWindow:
iter_ = model.get_iter_first()
# add new jid
while iter_:
jid = model[iter_][0].decode('utf-8')
jid = model[iter_][0]
actual_jid_list.append(jid)
if jid not in self.start_users_dict[affiliation] or \
(affiliation == 'outcast' and 'reason' in self.start_users_dict[
affiliation][jid] and self.start_users_dict[affiliation][jid]\
['reason'] != model[iter_][1].decode('utf-8')):
['reason'] != model[iter_][1]):
users_dict[jid] = {'affiliation': affiliation}
if affiliation == 'outcast':
users_dict[jid]['reason'] = model[iter_][1].decode(
@ -3236,7 +3234,7 @@ class ManageBookmarksWindow:
# No parent, so we got an account -> add to this.
add_to = iter_
account = model[add_to][1].decode('utf-8')
account = model[add_to][1]
nick = gajim.nicks[account]
iter_ = self.treestore.append(add_to, [account, _('New Group Chat'),
'@', False, False, '', nick, 'in_and_out'])
@ -3269,8 +3267,8 @@ class ManageBookmarksWindow:
#Account data can't be changed
return
if self.server_entry.get_text().decode('utf-8') == '' or \
self.room_entry.get_text().decode('utf-8') == '':
if self.server_entry.get_text() == '' or \
self.room_entry.get_text() == '':
dialogs.ErrorDialog(_('This bookmark has invalid data'),
_('Please be sure to fill out server and room fields or remove this'
' bookmark.'))
@ -3290,7 +3288,7 @@ class ManageBookmarksWindow:
return
for account in self.treestore:
account_unicode = account[1].decode('utf-8')
account_unicode = account[1]
gajim.connections[account_unicode].bookmarks = []
for bm in account.iterchildren():
@ -3298,17 +3296,9 @@ class ManageBookmarksWindow:
autojoin = unicode(int(bm[3]))
minimize = unicode(int(bm[4]))
name = bm[1]
if name:
name = name.decode('utf-8')
jid = bm[2]
if jid:
jid = jid.decode('utf-8')
pw = bm[5]
if pw:
pw = pw.decode('utf-8')
nick = bm[6]
if nick:
nick = nick.decode('utf-8')
# create the bookmark-dict
bmdict = { 'name': name, 'jid': jid, 'autojoin': autojoin,
@ -3353,7 +3343,7 @@ class ManageBookmarksWindow:
# Fill in the data for childs
self.title_entry.set_text(model[iter_][1])
room_jid = model[iter_][2].decode('utf-8')
room_jid = model[iter_][2]
(room, server) = room_jid.split('@')
self.room_entry.set_text(room)
self.server_entry.set_text(server)
@ -3364,7 +3354,7 @@ class ManageBookmarksWindow:
self.minimize_checkbutton.set_sensitive(model[iter_][3])
if model[iter_][5] is not None:
password = model[iter_][5].decode('utf-8')
password = model[iter_][5]
else:
password = None
@ -3374,7 +3364,6 @@ class ManageBookmarksWindow:
self.pass_entry.set_text('')
nick = model[iter_][6]
if nick:
nick = nick.decode('utf-8')
self.nick_entry.set_text(nick)
else:
self.nick_entry.set_text('')
@ -3393,7 +3382,7 @@ class ManageBookmarksWindow:
def on_nick_entry_changed(self, widget):
(model, iter_) = self.selection.get_selected()
if iter_:
nick = self.nick_entry.get_text().decode('utf-8')
nick = self.nick_entry.get_text()
try:
nick = helpers.parse_resource(nick)
except helpers.InvalidFormat, e:
@ -3407,12 +3396,12 @@ class ManageBookmarksWindow:
(model, iter_) = self.selection.get_selected()
if not iter_:
return
server = widget.get_text().decode('utf-8')
server = widget.get_text()
if '@' in server:
dialogs.ErrorDialog(_('Invalid server'), _('Character not allowed'))
widget.set_text(server.replace('@', ''))
room_jid = self.room_entry.get_text().decode('utf-8').strip() + '@' + \
room_jid = self.room_entry.get_text().strip() + '@' + \
server.strip()
try:
room_jid = helpers.parse_resource(room_jid)
@ -3427,12 +3416,12 @@ class ManageBookmarksWindow:
(model, iter_) = self.selection.get_selected()
if not iter_:
return
room = widget.get_text().decode('utf-8')
room = widget.get_text()
if '@' in room:
dialogs.ErrorDialog(_('Invalid server'), _('Character not allowed'))
widget.set_text(room.replace('@', ''))
room_jid = room.strip() + '@' + \
self.server_entry.get_text().decode('utf-8').strip()
self.server_entry.get_text().strip()
try:
room_jid = helpers.parse_resource(room_jid)
except helpers.InvalidFormat, e:
@ -3641,7 +3630,7 @@ class AccountCreationWizardWindow:
dialogs.ErrorDialog(pritext, sectext)
return
server = self.xml.get_object('server_comboboxentry').get_child().\
get_text().decode('utf-8').strip()
get_text().strip()
savepass = self.xml.get_object('save_password_checkbutton').\
get_active()
password = self.xml.get_object('password_entry').get_text().decode(
@ -3675,7 +3664,7 @@ class AccountCreationWizardWindow:
elif cur_page == 2:
# We are creating a new account
server = self.xml.get_object('server_comboboxentry1').get_child().\
get_text().decode('utf-8')
get_text()
if not server:
dialogs.ErrorDialog(_('Invalid server'),
@ -3691,7 +3680,7 @@ class AccountCreationWizardWindow:
# Get advanced options
proxies_combobox = self.xml.get_object('proxies_combobox')
active = proxies_combobox.get_active()
proxy = proxies_combobox.get_model()[active][0].decode('utf-8')
proxy = proxies_combobox.get_model()[active][0]
if proxy == _('None'):
proxy = ''
config['proxy'] = proxy
@ -3707,7 +3696,7 @@ class AccountCreationWizardWindow:
return
config['custom_port'] = custom_port
config['custom_host'] = self.xml.get_object(
'custom_host_entry').get_text().decode('utf-8')
'custom_host_entry').get_text()
if self.xml.get_object('anonymous_checkbutton2').get_active():
self.modify = True
@ -4161,11 +4150,11 @@ class ManageSoundsWindow:
self.window.show_all()
def on_sounds_treemodel_row_changed(self, model, path, iter_):
sound_event = model[iter_][3].decode('utf-8')
sound_event = model[iter_][3]
gajim.config.set_per('soundevents', sound_event, 'enabled',
bool(model[path][0]))
bool(model[path][0]))
gajim.config.set_per('soundevents', sound_event, 'path',
model[iter_][2].decode('utf-8'))
model[iter_][2])
def sound_toggled_cb(self, cell, path):
model = self.sound_tree.get_model()
@ -4238,7 +4227,7 @@ class ManageSoundsWindow:
def on_cancel(widget):
self.dialog.destroy()
path_to_snd_file = model[iter_][2].decode('utf-8')
path_to_snd_file = model[iter_][2]
self.dialog = dialogs.SoundChooserDialog(path_to_snd_file, on_ok,
on_cancel)

View File

@ -114,12 +114,12 @@ class DataFormWidget(Gtk.Alignment, object):
def get_title(self):
"""
Get the title of data form, as a unicode object. If no title or no form,
returns u''. Useful for setting window title
returns ''. Useful for setting window title
"""
if self._data_form is not None:
if self._data_form.title is not None:
return self._data_form.title
return u''
return ''
title = property(get_title, None, None, 'Data form title')
@ -540,7 +540,7 @@ class SingleForm(Gtk.Table, object):
field)
widget.set_sensitive(readwrite)
if field.value is None:
field.value = u''
field.value = ''
widget.set_text(field.value)
else:
commonwidget=False

View File

@ -127,7 +127,7 @@ class EditGroupsDialog:
gajim.interface.roster.draw_group(_('General'), account)
def on_add_button_clicked(self, widget):
group = self.xml.get_object('group_entry').get_text().decode('utf-8')
group = self.xml.get_object('group_entry').get_text()
if not group:
return
# Do not allow special groups
@ -137,7 +137,7 @@ class EditGroupsDialog:
model = self.treeview.get_model()
iter_ = model.get_iter_first()
while iter_:
if model.get_value(iter_, 0).decode('utf-8') == group:
if model.get_value(iter_, 0) == group:
return
iter_ = model.iter_next(iter_)
self.changes_made = True
@ -153,7 +153,7 @@ class EditGroupsDialog:
model[path][1] = True
else:
model[path][1] = not model[path][1]
group = model[path][0].decode('utf-8')
group = model[path][0]
if model[path][1]:
self.add_group(group)
else:
@ -251,7 +251,7 @@ class PassphraseDialog:
if not self.ok_handler:
return
passph = self.passphrase_entry.get_text().decode('utf-8')
passph = self.passphrase_entry.get_text()
if self.check:
checked = self.xml.get_object('save_passphrase_checkbutton').\
@ -325,8 +325,7 @@ class ChooseGPGKeyDialog:
selection = self.keys_treeview.get_selection()
(model, iter_) = selection.get_selected()
if iter_ and response == Gtk.ResponseType.OK:
keyID = [ model[iter_][0].decode('utf-8'),
model[iter_][1].decode('utf-8') ]
keyID = [ model[iter_][0], model[iter_][1] ]
else:
keyID = None
self.on_response(keyID)
@ -458,7 +457,7 @@ class ChangeActivityDialog:
"""
if self.checkbutton.get_active():
self.on_response(self.activity, self.subactivity,
self.entry.get_text().decode('utf-8'))
self.entry.get_text())
else:
self.on_response(None, None, '')
self.window.destroy()
@ -541,7 +540,7 @@ class ChangeMoodDialog:
def on_ok_button_clicked(self, widget):
'''Return mood and messsage (None if no mood selected)'''
message = self.entry.get_text().decode('utf-8')
message = self.entry.get_text()
self.on_response(self.mood, message)
self.window.destroy()
@ -713,8 +712,7 @@ class ChangeStatusMessageDialog(TimeoutDialog):
def on_dialog_response(self, dialog, response):
if response == Gtk.ResponseType.OK:
beg, end = self.message_buffer.get_bounds()
message = self.message_buffer.get_text(beg, end, True).decode('utf-8')\
.strip()
message = self.message_buffer.get_text(beg, end, True).strip()
message = helpers.remove_invalid_xml_chars(message)
msg = helpers.to_one_line(message)
if self.show:
@ -742,7 +740,7 @@ class ChangeStatusMessageDialog(TimeoutDialog):
active = widget.get_active()
if active < 0:
return None
name = model[active][0].decode('utf-8')
name = model[active][0]
self.message_buffer.set_text(self.preset_messages_dict[name][0])
self.pep_dict['activity'] = self.preset_messages_dict[name][1]
self.pep_dict['subactivity'] = self.preset_messages_dict[name][2]
@ -778,10 +776,10 @@ class ChangeStatusMessageDialog(TimeoutDialog):
status_message_to_save_as_preset = self.message_buffer.get_text(
start_iter, finish_iter, True)
def on_ok(msg_name):
msg_text = status_message_to_save_as_preset.decode('utf-8')
msg_text = status_message_to_save_as_preset
msg_text_1l = helpers.to_one_line(msg_text)
if not msg_name: # msg_name was ''
msg_name = msg_text_1l.decode('utf-8')
msg_name = msg_text_1l
def on_ok2():
self.preset_messages_dict[msg_name] = [
@ -1034,7 +1032,7 @@ class AddNewContactWindow:
self._nec_gateway_prompt_received)
def on_register_button_clicked(self, widget):
jid = self.protocol_jid_combobox.get_active_text().decode('utf-8')
jid = self.protocol_jid_combobox.get_active_text()
gajim.connections[self.account].request_register_agent_info(jid)
def on_add_new_contact_window_key_press_event(self, widget, event):
@ -1051,7 +1049,7 @@ class AddNewContactWindow:
"""
When Subscribe button is clicked
"""
jid = self.uid_entry.get_text().decode('utf-8').strip()
jid = self.uid_entry.get_text().strip()
if not jid:
return
@ -1091,7 +1089,7 @@ class AddNewContactWindow:
ErrorDialog(pritext, _('You cannot add yourself to your roster.'))
return
nickname = self.nickname_entry.get_text().decode('utf-8') or ''
nickname = self.nickname_entry.get_text() or ''
# get value of account combobox, if account was not specified
if not self.account:
model = self.account_combobox.get_model()
@ -1110,14 +1108,14 @@ class AddNewContactWindow:
message_buffer = self.message_textview.get_buffer()
start_iter = message_buffer.get_start_iter()
end_iter = message_buffer.get_end_iter()
message = message_buffer.get_text(start_iter, end_iter, True).decode('utf-8')
message = message_buffer.get_text(start_iter, end_iter, True)
if self.save_message_checkbutton.get_active():
msg = helpers.to_one_line(message)
gajim.config.set_per('accounts', self.account,
'subscription_request_msg', msg)
else:
message= ''
group = self.group_comboboxentry.get_child().get_text().decode('utf-8')
group = self.group_comboboxentry.get_child().get_text()
groups = []
if group:
groups = [group]
@ -1268,7 +1266,7 @@ class AboutDialog:
dlg.set_transient_for(gajim.interface.roster.window)
dlg.set_name('Gajim')
dlg.set_version(gajim.version)
s = u'Copyright © 2003-2012 Gajim Team'
s = 'Copyright © 2003-2012 Gajim Team'
dlg.set_copyright(s)
copying_file_path = self.get_path('COPYING')
if copying_file_path:
@ -2006,7 +2004,7 @@ class InputDialog(CommonInputDialog):
self.input_entry.select_region(0, -1) # select all
def get_text(self):
return self.input_entry.get_text().decode('utf-8')
return self.input_entry.get_text()
class InputDialogCheck(InputDialog):
"""
@ -2032,7 +2030,7 @@ class InputDialogCheck(InputDialog):
def on_okbutton_clicked(self, widget):
user_input = self.get_text()
if user_input:
user_input = user_input.decode('utf-8')
user_input = user_input
self.cancel_handler = None
self.dialog.destroy()
if isinstance(self.ok_handler, tuple):
@ -2041,7 +2039,7 @@ class InputDialogCheck(InputDialog):
self.ok_handler(user_input, self.is_checked())
def get_text(self):
return self.input_entry.get_text().decode('utf-8')
return self.input_entry.get_text()
def is_checked(self):
"""
@ -2110,7 +2108,7 @@ class ChangeNickDialog(InputDialogCheck):
def on_okbutton_clicked(self, widget):
nick = self.get_text()
if nick:
nick = nick.decode('utf-8')
nick = nick
# send presence to room
try:
nick = helpers.parse_resource(nick)
@ -2162,7 +2160,7 @@ class InputTextDialog(CommonInputDialog):
def get_text(self):
start_iter, end_iter = self.input_buffer.get_bounds()
return self.input_buffer.get_text(start_iter, end_iter, True).decode('utf-8')
return self.input_buffer.get_text(start_iter, end_iter, True)
class DoubleInputDialog:
"""
@ -2207,8 +2205,8 @@ class DoubleInputDialog:
self.cancel_handler()
def on_okbutton_clicked(self, widget):
user_input1 = self.input_entry1.get_text().decode('utf-8')
user_input2 = self.input_entry2.get_text().decode('utf-8')
user_input1 = self.input_entry1.get_text()
user_input2 = self.input_entry2.get_text()
self.cancel_handler = None
self.dialog.destroy()
if not self.ok_handler:
@ -2457,7 +2455,7 @@ class JoinGroupchatWindow:
def on_account_combobox_changed(self, widget):
model = widget.get_model()
iter_ = widget.get_active_iter()
self.account = model[iter_][0].decode('utf-8')
self.account = model[iter_][0]
self.on_required_entry_changed(self._nickname_entry)
def _set_room_jid(self, room_jid):
@ -2468,11 +2466,11 @@ class JoinGroupchatWindow:
def on_recently_combobox_changed(self, widget):
model = widget.get_model()
iter_ = widget.get_active_iter()
room_jid = model[iter_][0].decode('utf-8')
room_jid = model[iter_][0]
self._set_room_jid(room_jid)
def on_browse_rooms_button_clicked(self, widget):
server = self.server_comboboxentry.get_child().get_text().decode('utf-8')
server = self.server_comboboxentry.get_child().get_text()
if server in gajim.interface.instances[self.account]['disco']:
gajim.interface.instances[self.account]['disco'][server].window.\
present()
@ -2508,12 +2506,11 @@ class JoinGroupchatWindow:
_('You have to choose an account from which you want to join the '
'groupchat.'))
return
nickname = self._nickname_entry.get_text().decode('utf-8')
server = self.server_comboboxentry.get_child().get_text().decode('utf-8').\
strip()
room = self._room_jid_entry.get_text().decode('utf-8').strip()
nickname = self._nickname_entry.get_text()
server = self.server_comboboxentry.get_child().get_text().strip()
room = self._room_jid_entry.get_text().strip()
room_jid = room + '@' + server
password = self._password_entry.get_text().decode('utf-8')
password = self._password_entry.get_text()
try:
nickname = helpers.parse_resource(nickname)
except Exception:
@ -2613,7 +2610,7 @@ class SynchroniseSelectAccountDialog:
(model, iter_) = sel.get_selected()
if not iter_:
return
remote_account = model.get_value(iter_, 0).decode('utf-8')
remote_account = model.get_value(iter_, 0)
if gajim.connections[remote_account].connected < 2:
ErrorDialog(_('This account is not connected to the server'),
@ -2686,7 +2683,7 @@ class SynchroniseSelectContactsDialog:
while iter_:
if model[iter_][0]:
# it is selected
remote_jid = model[iter_][1].decode('utf-8')
remote_jid = model[iter_][1]
message = 'I\'m synchronizing my contacts from my %s account, could you please add this address to your contact list?' % \
gajim.get_hostname_from_account(self.remote_account)
remote_contact = gajim.contacts.get_first_contact_from_jid(
@ -2773,11 +2770,11 @@ class ChangePasswordDialog:
dialog.destroy()
self.on_response(None)
return
password1 = self.password1_entry.get_text().decode('utf-8')
password1 = self.password1_entry.get_text()
if not password1:
ErrorDialog(_('Invalid password'), _('You must enter a password.'))
return
password2 = self.password2_entry.get_text().decode('utf-8')
password2 = self.password2_entry.get_text()
if password1 != password2:
ErrorDialog(_('Passwords do not match'),
_('The passwords typed in both fields must be identical.'))
@ -3129,7 +3126,7 @@ class SingleMessageWindow:
else:
sender_list.append(i[0].jid)
else:
sender_list = [self.to_entry.get_text().decode('utf-8')]
sender_list = [self.to_entry.get_text()]
for to_whom_jid in sender_list:
if to_whom_jid in self.completion_dict:
@ -3142,9 +3139,9 @@ class SingleMessageWindow:
'valid.') % to_whom_jid)
return True
subject = self.subject_entry.get_text().decode('utf-8')
subject = self.subject_entry.get_text()
begin, end = self.message_tv_buffer.get_bounds()
message = self.message_tv_buffer.get_text(begin, end, True).decode('utf-8')
message = self.message_tv_buffer.get_text(begin, end, True)
if '/announce/' in to_whom_jid:
gajim.connections[self.account].send_motd(to_whom_jid, subject,
@ -3551,14 +3548,14 @@ class RosterItemExchangeWindow:
if model[iter_][0]:
a+=1
# it is selected
#remote_jid = model[iter_][1].decode('utf-8')
#remote_jid = model[iter_][1]
message = _('%s suggested me to add you in my roster.'
% self.jid_from)
# keep same groups and same nickname
groups = model[iter_][3].split(', ')
if groups == ['']:
groups = []
jid = model[iter_][1].decode('utf-8')
jid = model[iter_][1]
if gajim.jid_is_transport(self.jid_from):
gajim.connections[self.account].automatically_added.append(
jid)
@ -3574,7 +3571,7 @@ class RosterItemExchangeWindow:
if model[iter_][0]:
a+=1
# it is selected
jid = model[iter_][1].decode('utf-8')
jid = model[iter_][1]
# keep same groups and same nickname
groups = model[iter_][3].split(', ')
if groups == ['']:
@ -3599,7 +3596,7 @@ class RosterItemExchangeWindow:
if model[iter_][0]:
a+=1
# it is selected
jid = model[iter_][1].decode('utf-8')
jid = model[iter_][1]
gajim.connections[self.account].unsubscribe(jid)
gajim.interface.roster.remove_contact(jid, self.account)
gajim.contacts.remove_jid(self.account, jid)
@ -4154,7 +4151,7 @@ class PrivacyListWindow:
self.active_rule = ''
else:
self.active_rule = \
self.list_of_rules_combobox.get_active_text().decode('utf-8')
self.list_of_rules_combobox.get_active_text()
if self.active_rule != '':
rule_info = self.global_rules[self.active_rule]
self.edit_order_spinbutton.set_value(int(rule_info['order']))
@ -4952,7 +4949,7 @@ class TransformChatToMUC:
guests = self.guests_treeview.get_selection().get_selected_rows()
for guest in guests[1]:
iter_ = self.store.get_iter(guest)
guest_list.append(self.store[iter_][2].decode('utf-8'))
guest_list.append(self.store[iter_][2])
for guest in self.auto_jids:
guest_list.append(guest)
room_jid = obj.room_id + '@' + obj.server

View File

@ -800,7 +800,7 @@ _('This type of service does not contain any items to browse.'))
def on_address_comboboxentry_changed(self, widget):
if self.address_comboboxentry.get_active() != -1:
# user selected one of the entries so do auto-visit
jid = self.address_comboboxentry.get_child().get_text().decode('utf-8')
jid = self.address_comboboxentry.get_child().get_text()
try:
jid = helpers.parse_jid(jid)
except helpers.InvalidFormat, s:
@ -810,7 +810,7 @@ _('This type of service does not contain any items to browse.'))
self.travel(jid, '')
def on_go_button_clicked(self, widget):
jid = self.address_comboboxentry.get_child().get_text().decode('utf-8')
jid = self.address_comboboxentry.get_child().get_text()
try:
jid = helpers.parse_jid(jid)
except helpers.InvalidFormat, s:
@ -998,9 +998,9 @@ class AgentBrowser:
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
jid = model[iter_][0].decode('utf-8')
jid = model[iter_][0]
if jid:
node = model[iter_][1].decode('utf-8')
node = model[iter_][1]
self.window.open(jid, node)
def update_actions(self):
@ -1012,8 +1012,8 @@ class AgentBrowser:
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
jid = model[iter_][0].decode('utf-8')
node = model[iter_][1].decode('utf-8')
jid = model[iter_][0]
node = model[iter_][1]
if jid:
self.cache.get_info(jid, node, self._update_actions, nofetch = True)
@ -1035,8 +1035,8 @@ class AgentBrowser:
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
jid = model[iter_][0].decode('utf-8')
node = model[iter_][1].decode('utf-8')
jid = model[iter_][0]
node = model[iter_][1]
if jid:
self.cache.get_info(jid, node, self._default_action, nofetch = True)
@ -1077,8 +1077,8 @@ class AgentBrowser:
"""
iter_ = self.model.get_iter_first()
while iter_:
cjid = self.model.get_value(iter_, 0).decode('utf-8')
cnode = self.model.get_value(iter_, 1).decode('utf-8')
cjid = self.model.get_value(iter_, 0)
cnode = self.model.get_value(iter_, 1)
if jid == cjid and node == cnode:
break
iter_ = self.model.iter_next(iter_)
@ -1226,10 +1226,10 @@ class ToplevelAgentBrowser(AgentBrowser):
# These can be None, apparently
descr1 = model.get_value(iter1, 3)
if descr1:
descr1 = descr1.decode('utf-8')
descr1 = descr1
descr2 = model.get_value(iter2, 3)
if descr2:
descr2 = descr2.decode('utf-8')
descr2 = descr2
# Compare strings
return cmp(descr1, descr2)
return statecmp
@ -1402,7 +1402,7 @@ class ToplevelAgentBrowser(AgentBrowser):
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
service = model[iter_][0].decode('utf-8')
service = model[iter_][0]
if service in gajim.interface.instances[self.account]['search']:
gajim.interface.instances[self.account]['search'][service].window.\
present()
@ -1428,8 +1428,8 @@ class ToplevelAgentBrowser(AgentBrowser):
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
service = model[iter_][0].decode('utf-8')
node = model[iter_][1].decode('utf-8')
service = model[iter_][0]
node = model[iter_][1]
adhoc_commands.CommandWindow(self.account, service, commandnode=node)
def on_register_button_clicked(self, widget = None):
@ -1440,7 +1440,7 @@ class ToplevelAgentBrowser(AgentBrowser):
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
jid = model[iter_][0].decode('utf-8')
jid = model[iter_][0]
if jid:
gajim.connections[self.account].request_register_agent_info(jid)
self.window.destroy(chain = True)
@ -1453,7 +1453,7 @@ class ToplevelAgentBrowser(AgentBrowser):
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
service = model[iter_][0].decode('utf-8')
service = model[iter_][0]
if 'join_gc' not in gajim.interface.instances[self.account]:
try:
dialogs.JoinGroupchatWindow(self.account, service)
@ -1486,7 +1486,7 @@ class ToplevelAgentBrowser(AgentBrowser):
self.register_button.set_sensitive(True)
# Guess what kind of service we're dealing with
if self.browse_button:
jid = model[iter_][0].decode('utf-8')
jid = model[iter_][0]
type_ = gajim.get_transport_name_from_jid(jid,
use_config_setting = False)
if type_:
@ -1614,7 +1614,7 @@ class ToplevelAgentBrowser(AgentBrowser):
cat = self._friendly_category(cat, type_)[0]
iter_ = self.model.get_iter_first()
while iter_:
if self.model.get_value(iter_, 3).decode('utf-8') == cat:
if self.model.get_value(iter_, 3) == cat:
break
iter_ = self.model.iter_next(iter_)
if iter_:
@ -1627,8 +1627,8 @@ class ToplevelAgentBrowser(AgentBrowser):
while cat_iter and not iter_:
iter_ = self.model.iter_children(cat_iter)
while iter_:
cjid = self.model.get_value(iter_, 0).decode('utf-8')
cnode = self.model.get_value(iter_, 1).decode('utf-8')
cjid = self.model.get_value(iter_, 0)
cnode = self.model.get_value(iter_, 1)
if jid == cjid and node == cnode:
break
iter_ = self.model.iter_next(iter_)
@ -1699,7 +1699,7 @@ class ToplevelAgentBrowser(AgentBrowser):
# Check if we have to move categories
old_cat_iter = self.model.iter_parent(iter_)
old_cat = self.model.get_value(old_cat_iter, 3).decode('utf-8')
old_cat = self.model.get_value(old_cat_iter, 3)
if self.model.get_value(old_cat_iter, 3) == cat:
# Already in the right category, just update
self.model[iter_][2] = pix
@ -1819,7 +1819,7 @@ class MucBrowser(AgentBrowser):
if not iter:
return
name = gajim.config.get_per('accounts', self.account, 'name')
room_jid = model[iter][0].decode('utf-8')
room_jid = model[iter][0]
bm = {
'name': room_jid.split('@')[0],
'jid': room_jid,
@ -1853,7 +1853,7 @@ class MucBrowser(AgentBrowser):
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
service = model[iter_][0].decode('utf-8')
service = model[iter_][0]
if 'join_gc' not in gajim.interface.instances[self.account]:
try:
dialogs.JoinGroupchatWindow(self.account, service)
@ -1926,8 +1926,8 @@ class MucBrowser(AgentBrowser):
pass
while iter_ and self.model.get_path(iter_) != end:
if not self.model.get_value(iter_, 6):
jid = self.model.get_value(iter_, 0).decode('utf-8')
node = self.model.get_value(iter_, 1).decode('utf-8')
jid = self.model.get_value(iter_, 0)
node = self.model.get_value(iter_, 1)
self.cache.get_info(jid, node, self._agent_info)
self._fetch_source = True
return

View File

@ -149,7 +149,7 @@ class FeaturesWindow:
if not rows:
return
path = rows[0]
feature = self.model[path][0].decode('utf-8')
feature = self.model[path][0]
text = self.features[feature][1] + '\n'
if os.name == 'nt':
text = text + self.features[feature][3]

View File

@ -484,7 +484,7 @@ class FileTransfersWindow:
iter_ = self.get_iter_by_sid(file_props.type_, file_props.sid)
if iter_ is None:
return
self.model[iter_][C_SID].decode('utf-8')
self.model[iter_][C_SID]
if status == 'stop':
file_props.stopped = True
elif status == 'ok':
@ -677,7 +677,7 @@ class FileTransfersWindow:
"""
iter_ = self.model.get_iter_first()
while iter_:
if typ + sid == self.model[iter_][C_SID].decode('utf-8'):
if typ + sid == self.model[iter_][C_SID]:
return iter_
iter_ = self.model.iter_next(iter_)
@ -769,7 +769,7 @@ class FileTransfersWindow:
except Exception:
self.tooltip.hide_tooltip()
return
sid = self.model[iter_][C_SID].decode('utf-8')
sid = self.model[iter_][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
if file_props is not None:
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
@ -824,7 +824,7 @@ class FileTransfersWindow:
self.set_all_insensitive()
return
current_iter = self.model.get_iter(path)
sid = self.model[current_iter][C_SID].decode('utf-8')
sid = self.model[current_iter][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
self.remove_menuitem.set_sensitive(is_row_selected)
self.open_folder_menuitem.set_sensitive(is_row_selected)
@ -882,7 +882,7 @@ class FileTransfersWindow:
i = len(self.model) - 1
while i >= 0:
iter_ = self.model.get_iter((i))
sid = self.model[iter_][C_SID].decode('utf-8')
sid = self.model[iter_][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
if is_transfer_stopped(file_props):
self._remove_transfer(iter_, sid, file_props)
@ -917,7 +917,7 @@ class FileTransfersWindow:
if selected is None or selected[1] is None:
return
s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8')
sid = self.model[s_iter][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
if is_transfer_paused(file_props):
file_props.last_time = time.time()
@ -939,7 +939,7 @@ class FileTransfersWindow:
if selected is None or selected[1] is None:
return
s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8')
sid = self.model[s_iter][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
account = file_props.tt_account
if account not in gajim.connections:
@ -958,7 +958,7 @@ class FileTransfersWindow:
# as it was before setting the timeout
if props and self.tooltip.id == props[0]:
iter_ = self.model.get_iter(props[0])
sid = self.model[iter_][C_SID].decode('utf-8')
sid = self.model[iter_][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
# bounding rectangle of coordinates for the cell within the treeview
rect = self.tree.get_cell_area(props[0], props[1])
@ -1046,7 +1046,7 @@ class FileTransfersWindow:
if not selected or not selected[1]:
return
s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8')
sid = self.model[s_iter][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
if not file_props.file_name:
return
@ -1068,7 +1068,7 @@ class FileTransfersWindow:
if not selected or not selected[1]:
return
s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8')
sid = self.model[s_iter][C_SID]
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
self._remove_transfer(s_iter, sid, file_props)
self.set_all_insensitive()

View File

@ -89,8 +89,7 @@ class GajimThemesWindow:
def on_theme_cell_edited(self, cell, row, new_name):
model = self.themes_tree.get_model()
iter_ = model.get_iter_from_string(row)
old_name = model.get_value(iter_, 0).decode('utf-8')
new_name = new_name.decode('utf-8')
old_name = model.get_value(iter_, 0)
if old_name == new_name:
return
if old_name == 'default':
@ -150,7 +149,7 @@ class GajimThemesWindow:
self.theme_options_vbox.set_sensitive(False)
self.theme_options_table.set_sensitive(False)
return
self.current_theme = model.get_value(iter_, 0).decode('utf-8')
self.current_theme = model.get_value(iter_, 0)
self.current_theme = self.current_theme.replace(' ', '_')
self.set_theme_options(self.current_theme)
if self.current_theme == 'default':

View File

@ -364,7 +364,7 @@ class GroupchatControl(ChatControlBase):
self.handlers[id_] = widget
self.room_jid = self.contact.jid
self.nick = contact.name.decode('utf-8')
self.nick = contact.name
self.new_nick = ''
self.name = ''
for bm in gajim.connections[self.account].bookmarks:
@ -528,8 +528,6 @@ class GroupchatControl(ChatControlBase):
nick2 = model[iter2][C_NICK]
if not nick1 or not nick2:
return 0
nick1 = nick1.decode('utf-8')
nick2 = nick2.decode('utf-8')
if type1 == 'role':
return locale.strcoll(nick1, nick2)
if type1 == 'contact':
@ -631,7 +629,7 @@ class GroupchatControl(ChatControlBase):
"""
# Get the room_jid from treeview
for contact in self.iter_contact_rows():
nick = contact[C_NICK].decode('utf-8')
nick = contact[C_NICK]
self.draw_contact(nick)
def on_list_treeview_selection_changed(self, selection):
@ -643,7 +641,7 @@ class GroupchatControl(ChatControlBase):
self._last_selected_contact = None
return
contact = model[selected_iter]
nick = contact[C_NICK].decode('utf-8')
nick = contact[C_NICK]
self._last_selected_contact = nick
if contact[C_TYPE] != 'contact':
return
@ -1042,7 +1040,7 @@ class GroupchatControl(ChatControlBase):
while role_iter:
user_iter = self.model.iter_children(role_iter)
while user_iter:
if nick == self.model[user_iter][C_NICK].decode('utf-8'):
if nick == self.model[user_iter][C_NICK]:
return user_iter
else:
user_iter = self.model.iter_next(user_iter)
@ -1379,7 +1377,7 @@ class GroupchatControl(ChatControlBase):
contact in a room
"""
if nick is None:
nick = model[iter_][C_NICK].decode('utf-8')
nick = model[iter_][C_NICK]
ctrl = self._start_private_message(nick)
if ctrl and msg:
@ -1832,7 +1830,7 @@ class GroupchatControl(ChatControlBase):
def get_role_iter(self, role):
role_iter = self.model.get_iter_first()
while role_iter:
role_name = self.model[role_iter][C_NICK].decode('utf-8')
role_name = self.model[role_iter][C_NICK]
if role == role_name:
return role_iter
role_iter = self.model.iter_next(role_iter)
@ -2137,7 +2135,7 @@ class GroupchatControl(ChatControlBase):
type_ = model[iter_][2]
if type_ != 'contact': # source is not a contact
return
contact_jid = data.decode('utf-8')
contact_jid = data
gajim.connections[self.account].send_invite(self.room_jid, contact_jid)
self.print_conversation(_('%(jid)s has been invited in this room') % {
'jid': contact_jid}, graphics=False)
@ -2311,7 +2309,7 @@ class GroupchatControl(ChatControlBase):
"""
Make contact's popup menu
"""
nick = self.model[iter_][C_NICK].decode('utf-8')
nick = self.model[iter_][C_NICK]
c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
fjid = self.room_jid + '/' + nick
jid = c.jid
@ -2478,7 +2476,7 @@ class GroupchatControl(ChatControlBase):
else:
widget.expand_row(path, False)
else: # We want to send a private message
nick = self.model[path][C_NICK].decode('utf-8')
nick = self.model[path][C_NICK]
self._start_private_message(nick)
def on_list_treeview_row_activated(self, widget, path, col=0):
@ -2511,7 +2509,7 @@ class GroupchatControl(ChatControlBase):
widget.get_selection().select_path(path)
iter_ = self.model.get_iter(path)
if len(path) == 2:
nick = self.model[iter_][C_NICK].decode('utf-8')
nick = self.model[iter_][C_NICK]
self._start_private_message(nick)
return True
@ -2521,7 +2519,7 @@ class GroupchatControl(ChatControlBase):
return True
else:
iter_ = self.model.get_iter(path)
nick = self.model[iter_][C_NICK].decode('utf-8')
nick = self.model[iter_][C_NICK]
if not nick in gajim.contacts.get_nick_list(self.account,
self.room_jid):
# it's a group
@ -2564,13 +2562,13 @@ class GroupchatControl(ChatControlBase):
except Exception:
self.tooltip.hide_tooltip()
return
typ = self.model[iter_][C_TYPE].decode('utf-8')
typ = self.model[iter_][C_TYPE]
if typ == 'contact':
account = self.account
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row
nick = self.model[iter_][C_NICK].decode('utf-8')
nick = self.model[iter_][C_NICK]
self.tooltip.timeout = GObject.timeout_add(500,
self.show_tooltip, gajim.contacts.get_gc_contact(
account, self.room_jid, nick))
@ -2707,8 +2705,8 @@ class GroupchatControl(ChatControlBase):
connection = gajim.connections[self.account]
if fjid in connection.blocked_contacts:
return
new_rule = {'order': u'1', 'type': u'jid', 'action': u'deny',
'value' : fjid, 'child': [u'message', u'iq', u'presence-out']}
new_rule = {'order': '1', 'type': 'jid', 'action': 'deny',
'value' : fjid, 'child': ['message', 'iq', 'presence-out']}
connection.blocked_list.append(new_rule)
connection.blocked_contacts.append(fjid)
self.draw_contact(nick)

View File

@ -195,7 +195,7 @@ def get_default_font():
for line in open(xfce_config_file):
if line.find('name="Gtk/FontName"') != -1:
start = line.find('value="') + 7
return line[start:line.find('"', start)].decode('utf-8')
return line[start:line.find('"', start)]
except Exception:
#we talk about file
print(_('Error: cannot open %s for reading') % xfce_config_file,
@ -211,7 +211,7 @@ def get_default_font():
font_name = values[0]
font_size = values[1]
font_string = '%s %s' % (font_name, font_size) # Verdana 9
return font_string.decode('utf-8')
return font_string
except Exception:
#we talk about file
print(_('Error: cannot open %s for reading') % kde_config_file,
@ -684,7 +684,7 @@ def decode_filechooser_file_paths(file_paths):
file_path = file_path.decode(sys.getfilesystemencoding())
except Exception:
try:
file_path = file_path.decode('utf-8')
file_path = file_path
except Exception:
pass
file_paths_list.append(file_path)

View File

@ -1906,8 +1906,8 @@ class Interface:
self.sth_at_sth_dot_sth = r'\S+@\S+\.\S*[^\s)?]'
# Invalid XML chars
self.invalid_XML_chars = u'[\x00-\x08]|[\x0b-\x0c]|[\x0e-\x1f]|'\
u'[\ud800-\udfff]|[\ufffe-\uffff]'
self.invalid_XML_chars = '[\x00-\x08]|[\x0b-\x0c]|[\x0e-\x1f]|'\
'[\ud800-\udfff]|[\ufffe-\uffff]'
def popup_emoticons_under_button(self, button, parent_win):
"""
@ -1969,7 +1969,7 @@ class Interface:
if not self.image_is_ok(emot_file):
continue
for emot in emots[emot_filename]:
emot = emot.decode('utf-8')
emot = emot
# This avoids duplicated emoticons with the same image eg. :)
# and :-)
if not emot_file in self.emoticons.values():

View File

@ -65,12 +65,12 @@ def parseOpts():
longargs = 'help config_path='
opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0]
except getopt.error, msg:
print str(msg)
print 'for help use --help'
print(str(msg))
print('for help use --help')
sys.exit(2)
for o, a in opts:
if o in ('-h', '--help'):
print 'history_manager [--help] [--config-path]'
print('history_manager [--help] [--config-path]')
sys.exit()
elif o in ('-c', '--config-path'):
config_path = a
@ -264,7 +264,7 @@ class HistoryManager:
# get those jids that have at least one entry in logs
self.cur.execute('SELECT jid, jid_id FROM jids WHERE jid_id IN ('
'SELECT distinct logs.jid_id FROM logs) ORDER BY jid')
# list of tupples: [(u'aaa@bbb',), (u'cc@dd',)]
# list of tupples: [('aaa@bbb',), ('cc@dd',)]
rows = self.cur.fetchall()
for row in rows:
self.jids_already_in.append(row[0]) # jid
@ -291,7 +291,7 @@ class HistoryManager:
path = rowref.get_path()
if path is None:
continue
jid = liststore[path][0].decode('utf-8') # jid
jid = liststore[path][0] # jid
self._fill_logs_listview(jid)
def _get_jid_id(self, jid):
@ -642,7 +642,7 @@ class HistoryManager:
dialog.set_transient_for(self.window)
def on_search_db_button_clicked(self, widget):
text = self.search_entry.get_text().decode('utf-8')
text = self.search_entry.get_text()
if not text:
return
@ -655,7 +655,7 @@ class HistoryManager:
def on_search_results_listview_row_activated(self, widget, path, column):
# get log_line_id, jid_id from row we double clicked
log_line_id = self.search_results_liststore[path][0]
jid = self.search_results_liststore[path][1].decode('utf-8')
jid = self.search_results_liststore[path][1]
# make it string as in gtk liststores I have them all as strings
# as this is what db returns so I don't have to fight with types
jid_id = self._get_jid_id(jid)

View File

@ -165,7 +165,7 @@ class HistoryWindow:
keys = completion_dict.keys()
# Move the actual jid at first so we load history faster
actual_jid = self.jid_entry.get_text().decode('utf-8')
actual_jid = self.jid_entry.get_text()
if actual_jid in keys:
keys.remove(actual_jid)
keys.insert(0, actual_jid)
@ -244,7 +244,7 @@ class HistoryWindow:
# Don't disable querybox when we have changed the combobox
# to GC or All and hit enter
return
jid = self.jid_entry.get_text().decode('utf-8')
jid = self.jid_entry.get_text()
account = None # we don't know the account, could be any. Search for it!
self._load_history(jid, account)
self.results_window.set_property('visible', False)

View File

@ -762,7 +762,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
try:
self.textbuf.insert_pixbuf(self.iter,
self.textview.focus_out_line_pixbuf)
#self._insert_text(u'\u2550'*40)
#self._insert_text('\u2550'*40)
self._jump_line()
except Exception, e:
log.debug(str('Error in hr'+e))
@ -913,7 +913,7 @@ class HtmlTextView(Gtk.TextView):
while (search_iter.compare(end)):
character = search_iter.get_char()
if character == u'\ufffc':
if character == '\ufffc':
anchor = search_iter.get_child_anchor()
if anchor:
text = anchor.get_data('plaintext')

View File

@ -237,7 +237,7 @@ class PluginsWindow(object):
model, iter = selection.get_selected()
if iter:
plugin = model.get_value(iter, PLUGIN)
plugin_name = model.get_value(iter, NAME).decode('utf-8')
plugin_name = model.get_value(iter, NAME)
is_active = model.get_value(iter, ACTIVE)
try:
gajim.plugin_manager.remove_plugin(plugin)

View File

@ -40,7 +40,7 @@ class GajimPlugin(object):
'''
Base class for implementing Gajim plugins.
'''
name = u''
name = ''
'''
Name of plugin.
@ -48,7 +48,7 @@ class GajimPlugin(object):
:type: unicode
'''
short_name = u''
short_name = ''
'''
Short name of plugin.
@ -59,7 +59,7 @@ class GajimPlugin(object):
:todo: decide whether we really need this one, because class name (with
module name) can act as such short name
'''
version = u''
version = ''
'''
Version of plugin.
@ -71,7 +71,7 @@ class GajimPlugin(object):
same plugin class but with different version and we want only the newest
one to be active - is such policy good?
'''
description = u''
description = ''
'''
Plugin description.
@ -88,7 +88,7 @@ class GajimPlugin(object):
:todo: should we decide on any particular format of author strings?
Especially: should we force format of giving author's e-mail?
'''
homepage = u''
homepage = ''
'''
URL to plug-in's homepage.

View File

@ -344,7 +344,7 @@ class ProfileWindow:
'ADR_WORK_REGION', 'ADR_WORK_PCODE', 'ADR_WORK_CTRY']
vcard_ = {}
for e in entries:
txt = self.xml.get_object(e + '_entry').get_text().decode('utf-8')
txt = self.xml.get_object(e + '_entry').get_text()
if txt != '':
vcard_ = self.add_to_vcard(vcard_, e, txt)
@ -354,7 +354,7 @@ class ProfileWindow:
end_iter = buff.get_end_iter()
txt = buff.get_text(start_iter, end_iter, False)
if txt != '':
vcard_['DESC'] = txt.decode('utf-8')
vcard_['DESC'] = txt
# Avatar
if self.avatar_encoded:

View File

@ -459,7 +459,7 @@ class RosterWindow:
account_group = 'MERGED'
else:
account_group = account
group = self.model[parent_i][C_JID].decode('utf-8')
group = self.model[parent_i][C_JID]
if group in gajim.groups[account]:
del gajim.groups[account][group]
to_be_removed = parent_i
@ -1144,8 +1144,8 @@ class RosterWindow:
if self.model[parent_iter][C_TYPE] != 'contact':
# parent is not a contact
return
parent_jid = self.model[parent_iter][C_JID].decode('utf-8')
parent_account = self.model[parent_iter][C_ACCOUNT].decode('utf-8')
parent_jid = self.model[parent_iter][C_JID]
parent_account = self.model[parent_iter][C_ACCOUNT]
self.draw_contact(parent_jid, parent_account)
return False
@ -1203,7 +1203,7 @@ class RosterWindow:
if nb_connected_contact > 1:
# switch back to default writing direction
name += i18n.paragraph_direction_mark(unicode(name))
name += u' (%d)' % nb_connected_contact
name += ' (%d)' % nb_connected_contact
# add status msg, if not empty, under contact name in
# the treeview
@ -1256,8 +1256,8 @@ class RosterWindow:
iterC = self.model.iter_children(child_iter)
while iterC:
# a child has awaiting messages?
jidC = self.model[iterC][C_JID].decode('utf-8')
accountC = self.model[iterC][C_ACCOUNT].decode('utf-8')
jidC = self.model[iterC][C_JID]
accountC = self.model[iterC][C_ACCOUNT]
if len(gajim.events.get_events(accountC, jidC)):
icon_name = 'event'
break
@ -1350,7 +1350,7 @@ class RosterWindow:
iters = self._get_contact_iter(jid, account, model=self.model)
if not iters or not gajim.config.get('show_avatars_in_roster'):
return
jid = self.model[iters[0]][C_JID].decode('utf-8')
jid = self.model[iters[0]][C_JID]
pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid)
if pixbuf in (None, 'ask'):
scaled_pixbuf = empty_pixbuf
@ -1496,8 +1496,8 @@ class RosterWindow:
def _readjust_expand_collapse_state(self):
def func(model, path, iter_):
type_ = model[iter_][C_TYPE]
acct = model[iter_][C_ACCOUNT].decode('utf-8')
jid = model[iter_][C_JID].decode('utf-8')
acct = model[iter_][C_ACCOUNT]
jid = model[iter_][C_JID]
key = None
if type_ == 'account':
key = acct
@ -1507,7 +1507,7 @@ class RosterWindow:
parent_iter = model.iter_parent(iter_)
ptype = model[parent_iter][C_TYPE]
if ptype == 'group':
grp = model[parent_iter][C_JID].decode('utf-8')
grp = model[parent_iter][C_JID]
key = acct + grp + jid
if key:
if key in self.collapsed_rows:
@ -1611,11 +1611,10 @@ class RosterWindow:
if not account:
return False
account = account.decode('utf-8')
jid = model[titer][C_JID]
if not jid:
return False
jid = jid.decode('utf-8')
if type_ == 'group':
group = jid
if group == _('Transports'):
@ -1713,8 +1712,8 @@ class RosterWindow:
name2 = model[iter2][C_NAME]
if not name1 or not name2:
return 0
name1 = name1.decode('utf-8')
name2 = name2.decode('utf-8')
name1 = name1
name2 = name2
type1 = model[iter1][C_TYPE]
type2 = model[iter2][C_TYPE]
if type1 == 'self_contact':
@ -1724,10 +1723,10 @@ class RosterWindow:
if type1 == 'group':
name1 = model[iter1][C_JID]
if name1:
name1 = name1.decode('utf-8')
name1 = name1
name2 = model[iter2][C_JID]
if name2:
name2 = name2.decode('utf-8')
name2 = name2
if name1 == _('Transports'):
return 1
if name2 == _('Transports'):
@ -1744,12 +1743,12 @@ class RosterWindow:
account2 = model[iter2][C_ACCOUNT]
if not account1 or not account2:
return 0
account1 = account1.decode('utf-8')
account2 = account2.decode('utf-8')
account1 = account1
account2 = account2
if type1 == 'account':
return locale.strcoll(account1, account2)
jid1 = model[iter1][C_JID].decode('utf-8')
jid2 = model[iter2][C_JID].decode('utf-8')
jid1 = model[iter1][C_JID]
jid2 = model[iter2][C_JID]
if type1 == 'contact':
lcontact1 = gajim.contacts.get_contacts(account1, jid1)
contact1 = gajim.contacts.get_first_contact_from_jid(account1, jid1)
@ -2861,8 +2860,8 @@ class RosterWindow:
if model[titer][C_TYPE] in ('contact', 'self_contact'):
# we're on a contact entry in the roster
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT]
jid = model[titer][C_JID]
self.tooltip.id = row
contacts = gajim.contacts.get_contacts(account, jid)
connected_contacts = []
@ -2877,8 +2876,8 @@ class RosterWindow:
self.show_tooltip, connected_contacts)
elif model[titer][C_TYPE] == 'groupchat':
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT]
jid = model[titer][C_JID]
self.tooltip.id = row
contact = gajim.contacts.get_contacts(account, jid)
self.tooltip.account = account
@ -2887,7 +2886,7 @@ class RosterWindow:
elif model[titer][C_TYPE] == 'account':
# we're on an account entry in the roster
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
account = model[titer][C_ACCOUNT].decode('utf-8')
account = model[titer][C_ACCOUNT]
if account == 'all':
self.tooltip.id = row
self.tooltip.account = None
@ -3025,9 +3024,9 @@ class RosterWindow:
continue
accounts.append(account)
self.send_status(account, 'offline', msg, to=contact.jid)
new_rule = {'order': u'1', 'type': u'jid',
'action': u'deny', 'value' : contact.jid,
'child': [u'message', u'iq', u'presence-out']}
new_rule = {'order': '1', 'type': 'jid',
'action': 'deny', 'value' : contact.jid,
'child': ['message', 'iq', 'presence-out']}
gajim.connections[account].blocked_list.append(new_rule)
# needed for draw_contact:
gajim.connections[account].blocked_contacts.append(
@ -3045,9 +3044,9 @@ class RosterWindow:
self.draw_group(group, account)
self.send_status(account, 'offline', msg, to=contact.jid)
self.draw_contact(contact.jid, account)
new_rule = {'order': u'1', 'type': u'group', 'action': u'deny',
'value' : group, 'child': [u'message', u'iq',
u'presence-out']}
new_rule = {'order': '1', 'type': 'group', 'action': 'deny',
'value' : group, 'child': ['message', 'iq',
'presence-out']}
# account is the same for all when we block a group
gajim.connections[list_[0][1]].blocked_list.append(new_rule)
for account in accounts:
@ -3485,8 +3484,8 @@ class RosterWindow:
path = list_of_paths[0]
type_ = model[path][C_TYPE]
if type_ in ('contact', 'group', 'agent'):
jid = model[path][C_JID].decode('utf-8')
account = model[path][C_ACCOUNT].decode('utf-8')
jid = model[path][C_JID]
account = model[path][C_ACCOUNT]
self.on_rename(widget, type_, jid, account)
elif event.keyval == Gdk.KEY_Delete:
@ -3495,7 +3494,7 @@ class RosterWindow:
if not len(list_of_paths):
return
type_ = model[list_of_paths[0]][C_TYPE]
account = model[list_of_paths[0]][C_ACCOUNT].decode('utf-8')
account = model[list_of_paths[0]][C_ACCOUNT]
if type_ in ('account', 'group', 'self_contact') or \
account == gajim.ZEROCONF_ACC_NAME:
return
@ -3503,8 +3502,8 @@ class RosterWindow:
for path in list_of_paths:
if model[path][C_TYPE] != type_:
return
jid = model[path][C_JID].decode('utf-8')
account = model[path][C_ACCOUNT].decode('utf-8')
jid = model[path][C_JID]
account = model[path][C_ACCOUNT]
contact = gajim.contacts.get_contact_with_highest_priority(
account, jid)
list_.append((contact, account))
@ -3616,7 +3615,7 @@ class RosterWindow:
if type_ in ('agent', 'contact', 'self_contact', 'groupchat'):
self.on_row_activated(widget, path)
elif type_ == 'account':
account = model[path][C_ACCOUNT].decode('utf-8')
account = model[path][C_ACCOUNT]
if account != 'all':
show = gajim.connections[account].connected
if show > 1: # We are connected
@ -3830,7 +3829,7 @@ class RosterWindow:
'contacts.'))
self.update_status_combobox()
return
status = model[active][2].decode('utf-8')
status = model[active][2]
# status "desync'ed" or not
statuses_unified = helpers.statuses_unified()
if (active == 7 and statuses_unified) or (active == 9 and \
@ -4047,7 +4046,7 @@ class RosterWindow:
"""
jid = contact.jid
if resource is not None:
jid = jid + u'/' + resource
jid = jid + '/' + resource
adhoc_commands.CommandWindow(account, jid)
def on_roster_window_focus_in_event(self, widget, event):
@ -4095,8 +4094,8 @@ class RosterWindow:
for path in list_of_paths:
type_ = model[path][C_TYPE]
if type_ in ('contact', 'agent'):
jid = model[path][C_JID].decode('utf-8')
account = model[path][C_ACCOUNT].decode('utf-8')
jid = model[path][C_JID]
account = model[path][C_ACCOUNT]
contact = gajim.contacts.get_first_contact_from_jid(account,
jid)
self.on_info(widget, contact, account)
@ -4109,8 +4108,8 @@ class RosterWindow:
path = list_of_paths[0]
type_ = model[path][C_TYPE]
if type_ in ('contact', 'agent'):
jid = model[path][C_JID].decode('utf-8')
account = model[path][C_ACCOUNT].decode('utf-8')
jid = model[path][C_JID]
account = model[path][C_ACCOUNT]
contact = gajim.contacts.get_first_contact_from_jid(account,
jid)
self.on_history(widget, contact, account)
@ -4125,7 +4124,7 @@ class RosterWindow:
this way)
"""
model = self.modelfilter
account = model[path][C_ACCOUNT].decode('utf-8')
account = model[path][C_ACCOUNT]
type_ = model[path][C_TYPE]
if type_ in ('group', 'account'):
if self.tree.row_expanded(path):
@ -4133,7 +4132,7 @@ class RosterWindow:
else:
self.tree.expand_row(path, False)
return
jid = model[path][C_JID].decode('utf-8')
jid = model[path][C_JID]
resource = None
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
titer = model.get_iter(path)
@ -4160,7 +4159,7 @@ class RosterWindow:
if not first_ev and model.iter_has_child(titer):
child_iter = model.iter_children(titer)
while not first_ev and child_iter:
child_jid = model[child_iter][C_JID].decode('utf-8')
child_jid = model[child_iter][C_JID]
first_ev = gajim.events.get_first_event(account, child_jid)
if first_ev:
jid = child_jid
@ -4205,11 +4204,11 @@ class RosterWindow:
if self.regroup: # merged accounts
accounts = gajim.connections.keys()
else:
accounts = [model[titer][C_ACCOUNT].decode('utf-8')]
accounts = [model[titer][C_ACCOUNT]]
type_ = model[titer][C_TYPE]
if type_ == 'group':
group = model[titer][C_JID].decode('utf-8')
group = model[titer][C_JID]
child_model[child_iter][C_IMG] = \
gajim.interface.jabber_state_images['16']['opened']
if self.rfilter_enabled:
@ -4242,8 +4241,8 @@ class RosterWindow:
self.tree.expand_row(path, False)
elif type_ == 'contact':
# Metacontact got toggled, update icon
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
contact = gajim.contacts.get_contact(account, jid)
for group in contact.groups:
if account + group + jid in self.collapsed_rows:
@ -4269,7 +4268,7 @@ class RosterWindow:
if self.regroup: # merged accounts
accounts = gajim.connections.keys()
else:
accounts = [model[titer][C_ACCOUNT].decode('utf-8')]
accounts = [model[titer][C_ACCOUNT]]
type_ = model[titer][C_TYPE]
if type_ == 'group':
@ -4277,7 +4276,7 @@ class RosterWindow:
jabber_state_images['16']['closed']
if self.rfilter_enabled:
return
group = model[titer][C_JID].decode('utf-8')
group = model[titer][C_JID]
for account in accounts:
if group in gajim.groups[account]: # This account has this group
gajim.groups[account][group]['expand'] = False
@ -4290,8 +4289,8 @@ class RosterWindow:
self.draw_account(account)
elif type_ == 'contact':
# Metacontact got toggled, update icon
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
contact = gajim.contacts.get_contact(account, jid)
groups = contact.groups
if not groups:
@ -4323,8 +4322,6 @@ class RosterWindow:
if not account:
return
account = account.decode('utf-8')
if type_ == 'contact':
child_iter = model.convert_iter_to_child_iter(titer)
if self.model.iter_has_child(child_iter):
@ -4332,10 +4329,10 @@ class RosterWindow:
# redraw us to show/hide expand icon
if self.filtering:
# Prevent endless loops
jid = model[titer][C_JID].decode('utf-8')
jid = model[titer][C_JID]
GObject.idle_add(self.draw_contact, jid, account)
elif type_ == 'group':
group = model[titer][C_JID].decode('utf-8')
group = model[titer][C_JID]
self._adjust_group_expand_collapse_state(group, account)
elif type_ == 'account':
self._adjust_account_expand_collapse_state(account)
@ -4365,8 +4362,8 @@ class RosterWindow:
# if row[C_TYPE] != 'contact':
# self._last_selected_contact = []
# return
# jid = row[C_JID].decode('utf-8')
# account = row[C_ACCOUNT].decode('utf-8')
# jid = row[C_JID]
# account = row[C_ACCOUNT]
# self._last_selected_contact.append((jid, account))
# GObject.idle_add(self.draw_contact, jid, account, True)
@ -4704,9 +4701,9 @@ class RosterWindow:
path_dest = (path_dest[0], path_dest[1]-1)
# destination: the row something got dropped on
iter_dest = model.get_iter(path_dest)
type_dest = model[iter_dest][C_TYPE].decode('utf-8')
jid_dest = model[iter_dest][C_JID].decode('utf-8')
account_dest = model[iter_dest][C_ACCOUNT].decode('utf-8')
type_dest = model[iter_dest][C_TYPE]
jid_dest = model[iter_dest][C_JID]
account_dest = model[iter_dest][C_ACCOUNT]
# drop on account row in merged mode, we cannot know the desired account
if account_dest == 'all':
@ -4770,7 +4767,7 @@ class RosterWindow:
path_source = treeview.get_selection().get_selected_rows()[1][0]
iter_source = model.get_iter(path_source)
type_source = model[iter_source][C_TYPE]
account_source = model[iter_source][C_ACCOUNT].decode('utf-8')
account_source = model[iter_source][C_ACCOUNT]
if gajim.config.get_per('accounts', account_source, 'is_zeroconf'):
return
@ -4788,14 +4785,14 @@ class RosterWindow:
if account_source != account_dest:
# drop on another account
return
grp_source = model[iter_source][C_JID].decode('utf-8')
grp_source = model[iter_source][C_JID]
delimiter = gajim.connections[account_source].nested_group_delimiter
grp_source_list = grp_source.split(delimiter)
new_grp = None
if type_dest == 'account':
new_grp = grp_source_list[-1]
elif type_dest == 'group':
new_grp = model[iter_dest][C_JID].decode('utf-8') + delimiter +\
new_grp = model[iter_dest][C_JID] + delimiter +\
grp_source_list[-1]
if new_grp:
self.move_group(grp_source, new_grp, account_source)
@ -4817,26 +4814,26 @@ class RosterWindow:
it = iter_source
while model[it][C_TYPE] == 'contact':
it = model.iter_parent(it)
grp_source = model[it][C_JID].decode('utf-8')
grp_source = model[it][C_JID]
if grp_source in helpers.special_groups and \
grp_source not in ('Not in Roster', 'Observers'):
# a transport or a minimized groupchat was dragged
# we can add it to other accounts but not move it to another group,
# see below
return
jid_source = data.decode('utf-8')
jid_source = data
c_source = gajim.contacts.get_contact_with_highest_priority(
account_source, jid_source)
# Get destination group
grp_dest = None
if type_dest == 'group':
grp_dest = model[iter_dest][C_JID].decode('utf-8')
grp_dest = model[iter_dest][C_JID]
elif type_dest in ('contact', 'agent'):
it = iter_dest
while model[it][C_TYPE] != 'group':
it = model.iter_parent(it)
grp_dest = model[it][C_JID].decode('utf-8')
grp_dest = model[it][C_JID]
if grp_dest in helpers.special_groups:
return
@ -5092,8 +5089,8 @@ class RosterWindow:
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
# This can append when at the moment we add the row
return
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
self._set_contact_row_background_color(renderer, jid, account)
parent_iter = model.iter_parent(titer)
if model[parent_iter][C_TYPE] == 'contact':
@ -5141,8 +5138,8 @@ class RosterWindow:
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
# This can append when at the moment we add the row
return
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
color = None
if type_ == 'groupchat':
ctrl = gajim.interface.minimized_controls[account].get(jid,
@ -5190,8 +5187,8 @@ class RosterWindow:
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
# This can append at the moment we add the row
return
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
self._set_contact_row_background_color(renderer, jid, account)
def _fill_avatar_pixbuf_renderer(self, column, renderer, model, titer,
@ -5217,8 +5214,8 @@ class RosterWindow:
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
# This can append at the moment we add the row
return
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
self._set_contact_row_background_color(renderer, jid, account)
else:
renderer.set_property('visible', False)
@ -5727,7 +5724,7 @@ class RosterWindow:
Make account's popup menu
"""
model = self.modelfilter
account = model[titer][C_ACCOUNT].decode('utf-8')
account = model[titer][C_ACCOUNT]
if account != 'all': # not in merged mode
menu = self.build_account_menu(account)
@ -5762,8 +5759,8 @@ class RosterWindow:
"""
model = self.modelfilter
path = model.get_path(titer)
group = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
group = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
list_ = [] # list of (jid, account) tuples
list_online = [] # list of (jid, account) tuples
@ -5923,8 +5920,8 @@ class RosterWindow:
Make contact's popup menu
"""
model = self.modelfilter
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
menu = gui_menu_builder.get_contact_menu(contact, account)
event_button = gtkgui_helpers.get_possible_button_event(event)
@ -5941,8 +5938,8 @@ class RosterWindow:
is_blocked = True
privacy_rules_supported = True
for titer in iters:
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
if gajim.connections[account].connected < 2:
one_account_offline = True
if not gajim.connections[account].privacy_rules_supported:
@ -6040,9 +6037,9 @@ class RosterWindow:
Make transport's popup menu
"""
model = self.modelfilter
jid = model[titer][C_JID].decode('utf-8')
jid = model[titer][C_JID]
path = model.get_path(titer)
account = model[titer][C_ACCOUNT].decode('utf-8')
account = model[titer][C_ACCOUNT]
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
menu = Gtk.Menu()
@ -6177,8 +6174,8 @@ class RosterWindow:
def make_groupchat_menu(self, event, titer):
model = self.modelfilter
jid = model[titer][C_JID].decode('utf-8')
account = model[titer][C_ACCOUNT].decode('utf-8')
jid = model[titer][C_JID]
account = model[titer][C_ACCOUNT]
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
menu = Gtk.Menu()

View File

@ -477,7 +477,7 @@ class StatusIcon:
def on_change_status_message_activate(self, widget):
model = gajim.interface.roster.status_combobox.get_model()
active = gajim.interface.roster.status_combobox.get_active()
status = model[active][2].decode('utf-8')
status = model[active][2]
def on_response(message, pep_dict):
if message is None: # None if user press Cancel
return

View File

@ -186,13 +186,13 @@ class TestRosterWindowMetaContacts(TestRosterWindowRegrouped):
def test_connect_new_metacontact(self):
self.test_fill_roster_model()
jid = u'coolstuff@gajim.org'
jid = 'coolstuff@gajim.org'
contact = gajim.contacts.create_contact(jid, account1)
gajim.contacts.add_contact(account1, contact)
self.roster.add_contact(jid, account1)
self.roster.chg_contact_status(contact, 'offline', '', account1)
gajim.contacts.add_metacontact(account1, u'samejid@gajim.org',
gajim.contacts.add_metacontact(account1, 'samejid@gajim.org',
account1, jid)
self.roster.chg_contact_status(contact, 'online', '', account1)

View File

@ -1,77 +1,77 @@
# -*- coding: utf-8 -*-
account1 = u'acc1'
account2 = u'Cool"chârßéµö'
account3 = u'dingdong.org'
account1 = 'acc1'
account2 = 'Cool"chârßéµö'
account3 = 'dingdong.org'
contacts = {}
contacts[account1] = {
u'myjid@'+account1: {
'myjid@'+account1: {
'ask': None, 'groups': [], 'name': None, 'resources': {},
'subscription': u'both'},
u'default1@gajim.org': {
'subscription': 'both'},
'default1@gajim.org': {
'ask': None, 'groups': [], 'name': None, 'resources': {},
'subscription': u'both'},
u'default2@gajim.org': {
'ask': None, 'groups': [u'GroupA',], 'name': None, 'resources': {},
'subscription': u'both'},
u'Cool"chârßéµö@gajim.org': {
'ask': None, 'groups': [u'<Cool"chârßéµö', u'GroupB'],
'name': None, 'resources': {}, 'subscription': u'both'},
u'samejid@gajim.org': {
'ask': None, 'groups': [u'GroupA',], 'name': None, 'resources': {},
'subscription': u'both'}
'subscription': 'both'},
'default2@gajim.org': {
'ask': None, 'groups': ['GroupA',], 'name': None, 'resources': {},
'subscription': 'both'},
'Cool"chârßéµö@gajim.org': {
'ask': None, 'groups': ['<Cool"chârßéµö', 'GroupB'],
'name': None, 'resources': {}, 'subscription': 'both'},
'samejid@gajim.org': {
'ask': None, 'groups': ['GroupA',], 'name': None, 'resources': {},
'subscription': 'both'}
}
contacts[account2] = {
u'myjid@'+account2: {
'myjid@'+account2: {
'ask': None, 'groups': [], 'name': None, 'resources': {},
'subscription': u'both'},
u'default3@gajim.org': {
'ask': None, 'groups': [u'GroupC',], 'name': None, 'resources': {},
'subscription': u'both'},
u'asksubfrom@gajim.org': {
'ask': u'subscribe', 'groups': [u'GroupA',], 'name': None,
'resources': {}, 'subscription': u'from'},
u'subto@gajim.org': {
'ask': None, 'groups': [u'GroupB'], 'name': None, 'resources': {},
'subscription': u'to'},
u'samejid@gajim.org': {
'ask': None, 'groups': [u'GroupA', u'GroupB'], 'name': None,
'resources': {}, 'subscription': u'both'}
'subscription': 'both'},
'default3@gajim.org': {
'ask': None, 'groups': ['GroupC',], 'name': None, 'resources': {},
'subscription': 'both'},
'asksubfrom@gajim.org': {
'ask': 'subscribe', 'groups': ['GroupA',], 'name': None,
'resources': {}, 'subscription': 'from'},
'subto@gajim.org': {
'ask': None, 'groups': ['GroupB'], 'name': None, 'resources': {},
'subscription': 'to'},
'samejid@gajim.org': {
'ask': None, 'groups': ['GroupA', 'GroupB'], 'name': None,
'resources': {}, 'subscription': 'both'}
}
contacts[account3] = {
#u'guypsych0\\40h.com@msn.dingdong.org': {
#'guypsych0\\40h.com@msn.dingdong.org': {
# 'ask': None, 'groups': [], 'name': None, 'resources': {},
# 'subscription': u'both'},
u'guypsych0%h.com@msn.delx.cjb.net': {
'ask': u'subscribe', 'groups': [], 'name': None,
'resources': {}, 'subscription': u'from'},
#u'guypsych0%h.com@msn.jabber.wiretrip.org': {
# 'subscription': 'both'},
'guypsych0%h.com@msn.delx.cjb.net': {
'ask': 'subscribe', 'groups': [], 'name': None,
'resources': {}, 'subscription': 'from'},
#'guypsych0%h.com@msn.jabber.wiretrip.org': {
# 'ask': None, 'groups': [], 'name': None, 'resources': {},
# 'subscription': u'to'},
#u'guypsycho\\40g.com@gtalk.dingdong.org': {
# 'subscription': 'to'},
#'guypsycho\\40g.com@gtalk.dingdong.org': {
# 'ask': None, 'groups': [], 'name': None,
# 'resources': {}, 'subscription': u'both'}
# 'resources': {}, 'subscription': 'both'}
}
# We have contacts that are not in roster but only specified in the metadata
metacontact_data = [
[{'account': account3,
'jid': u'guypsych0\\40h.com@msn.dingdong.org',
'jid': 'guypsych0\\40h.com@msn.dingdong.org',
'order': 0},
{'account': account3,
'jid': u'guypsych0%h.com@msn.delx.cjb.net',
'jid': 'guypsych0%h.com@msn.delx.cjb.net',
'order': 0},
{'account': account3,
'jid': u'guypsych0%h.com@msn.jabber.wiretrip.org',
'jid': 'guypsych0%h.com@msn.jabber.wiretrip.org',
'order': 0},
{'account': account3,
'jid': u'guypsycho\\40g.com@gtalk.dingdong.org',
'jid': 'guypsycho\\40g.com@gtalk.dingdong.org',
'order': 0}],
[{'account': account1,
'jid': u'samejid@gajim.org',
'jid': 'samejid@gajim.org',
'order': 0},
{'account': account2,
'jid': u'samejid@gajim.org',
'jid': 'samejid@gajim.org',
'order': 0}]
]

View File

@ -17,7 +17,7 @@ from common.socks5 import SocksQueue
import common
session_init = '''
session_init = '''
<iq xmlns="jabber:client" to="jingleft@thiessen.im/Gajim" type="set" id="43">
<jingle xmlns="urn:xmpp:jingle:1" action="session-initiate" initiator="jtest@thiessen.im/Gajim" sid="38">
<content name="fileWL1Y2JIPTM5RAD68" creator="initiator">
@ -38,10 +38,10 @@ session_init = '''
</transport>
</content>
</jingle>
</iq>
</iq>
'''
transport_info = '''
<iq from='jtest@thiessen.im/Gajim'
id='hjdi8'
@ -64,19 +64,19 @@ transport_info = '''
class Connection(Mock, ConnectionJingle, ConnectionSocks5Bytestream,
ConnectionIBBytestream):
def __init__(self):
Mock.__init__(self)
ConnectionJingle.__init__(self)
ConnectionSocks5Bytestream.__init__(self)
ConnectionIBBytestream.__init__(self)
self.connected = 2 # This tells gajim we are connected
def send(self, stanza=None, when=None):
# Called when gajim wants to send something
print str(stanza)
print(str(stanza))
class TestJingle(unittest.TestCase):
def setUp(self):
@ -92,33 +92,33 @@ class TestJingle(unittest.TestCase):
self.con = self.client.Connection
self.con.server_resource = None
self.con.connection = Connection()
'''
'''
Fake file_props when we recieve a file. Gajim creates a file_props
out of a FileRequestRecieve event and from then on it changes in
a lot of places. It is easier to just copy it in here.
If the session_initiate stanza changes, this also must change.
a lot of places. It is easier to just copy it in here.
If the session_initiate stanza changes, this also must change.
'''
self.recieve_file = {'stream-methods':
'http://jabber.org/protocol/bytestreams',
'sender': u'jtest@thiessen.im/Gajim',
'file-name': u'test_recieved_file',
'request-id': u'43', 'sid': u'39',
'session-sid': u'38', 'session-type': 'jingle',
'transfered_size': [], 'receiver':
u'jingleft@thiessen.im/Gajim', 'desc': '',
u'size': u'2273', 'type': 'r',
'streamhosts': [{'initiator':
u'jtest@thiessen.im/Gajim',
'target': u'jingleft@thiessen.im/Gajim',
'cid': u'41', 'state': 0, 'host': u'192.168.2.100',
'type': u'direct', 'port': u'28011'},
{'initiator': u'jtest@thiessen.im/Gajim',
'target': u'jingleft@thiessen.im/Gajim',
'cid': u'42', 'state': 0, 'host': u'192.168.2.100',
'type': u'proxy', 'port': u'5000'}],
u'name': u'to'}
self.recieve_file = {'stream-methods':
'http://jabber.org/protocol/bytestreams',
'sender': 'jtest@thiessen.im/Gajim',
'file-name': 'test_recieved_file',
'request-id': '43', 'sid': '39',
'session-sid': '38', 'session-type': 'jingle',
'transfered_size': [], 'receiver':
'jingleft@thiessen.im/Gajim', 'desc': '',
'size': '2273', 'type': 'r',
'streamhosts': [{'initiator':
'jtest@thiessen.im/Gajim',
'target': 'jingleft@thiessen.im/Gajim',
'cid': '41', 'state': 0, 'host': '192.168.2.100',
'type': 'direct', 'port': '28011'},
{'initiator': 'jtest@thiessen.im/Gajim',
'target': 'jingleft@thiessen.im/Gajim',
'cid': '42', 'state': 0, 'host': '192.168.2.100',
'type': 'proxy', 'port': '5000'}],
'name': 'to'}
def tearDown(self):
# Unplug if needed
if hasattr(self.dispatcher, '_owner'):
@ -126,12 +126,12 @@ class TestJingle(unittest.TestCase):
def _simulate_connect(self):
self.dispatcher.PlugIn(self.client) # client is owner
# Simulate that we have established a connection
# Simulate that we have established a connection
self.dispatcher.StreamInit()
self.dispatcher.ProcessNonBlocking("<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client'>")
def _simulate_jingle_session(self):
self.dispatcher.RegisterHandler('iq', self.con._JingleCB, 'set'
, common.xmpp.NS_JINGLE)
self.dispatcher.ProcessNonBlocking(session_init)
@ -142,15 +142,15 @@ class TestJingle(unittest.TestCase):
# we have to manually simulate this behavior
session.approve_session()
self.con.send_file_approval(self.recieve_file)
self.dispatcher.ProcessNonBlocking(transport_info)
def test_jingle_session(self):
self._simulate_connect()
self._simulate_jingle_session()
if __name__ == '__main__':

View File

@ -40,38 +40,38 @@ class TestModuleLevelFunctions(unittest.TestCase):
self.assertEqual(_user, user)
self.assertEqual(_passwd, passwd)
bosh_dict = {'bosh_content': u'text/xml; charset=utf-8',
bosh_dict = {'bosh_content': 'text/xml; charset=utf-8',
'bosh_hold': 2,
'bosh_http_pipelining': False,
'bosh_uri': u'http://gajim.org:5280/http-bind',
'bosh_uri': 'http://gajim.org:5280/http-bind',
'bosh_useproxy': False,
'bosh_wait': 30,
'bosh_wait_for_restart_response': False,
'host': u'172.16.99.11',
'pass': u'pass',
'host': '172.16.99.11',
'pass': 'pass',
'port': 3128,
'type': u'bosh',
'type': 'bosh',
'useauth': True,
'user': u'user'}
check_dict(bosh_dict, host=u'gajim.org', port=5280, user=u'user',
passwd=u'pass')
'user': 'user'}
check_dict(bosh_dict, host='gajim.org', port=5280, user='user',
passwd='pass')
proxy_dict = {'bosh_content': u'text/xml; charset=utf-8',
proxy_dict = {'bosh_content': 'text/xml; charset=utf-8',
'bosh_hold': 2,
'bosh_http_pipelining': False,
'bosh_port': 5280,
'bosh_uri': u'',
'bosh_uri': '',
'bosh_useproxy': True,
'bosh_wait': 30,
'bosh_wait_for_restart_response': False,
'host': u'172.16.99.11',
'pass': u'pass',
'host': '172.16.99.11',
'pass': 'pass',
'port': 3128,
'type': 'socks5',
'useauth': True,
'user': u'user'}
check_dict(proxy_dict, host=u'172.16.99.11', port=3128, user=u'user',
passwd=u'pass')
'user': 'user'}
check_dict(proxy_dict, host='172.16.99.11', port=3128, user='user',
passwd='pass')
if __name__ == '__main__':