remove call to unicode()
This commit is contained in:
parent
414e349345
commit
069bddbbcb
|
@ -281,8 +281,6 @@ class CommandWindow:
|
||||||
# close old stage
|
# close old stage
|
||||||
self.stage_finish()
|
self.stage_finish()
|
||||||
|
|
||||||
assert isinstance(self.commandnode, unicode)
|
|
||||||
|
|
||||||
self.form_status = None
|
self.form_status = None
|
||||||
|
|
||||||
self.stages_notebook.set_current_page(
|
self.stages_notebook.set_current_page(
|
||||||
|
@ -608,7 +606,6 @@ class CommandWindow:
|
||||||
Send the command with data form. Wait for reply
|
Send the command with data form. Wait for reply
|
||||||
"""
|
"""
|
||||||
# create the stanza
|
# create the stanza
|
||||||
assert isinstance(self.commandnode, unicode)
|
|
||||||
assert action in ('execute', 'prev', 'next', 'complete')
|
assert action in ('execute', 'prev', 'next', 'complete')
|
||||||
|
|
||||||
stanza = nbxmpp.Iq(typ='set', to=self.jid)
|
stanza = nbxmpp.Iq(typ='set', to=self.jid)
|
||||||
|
|
|
@ -2505,7 +2505,7 @@ class ChatControl(ChatControlBase):
|
||||||
if num_unread == 1 and not gajim.config.get('show_unread_tab_icon'):
|
if num_unread == 1 and not gajim.config.get('show_unread_tab_icon'):
|
||||||
unread = '*'
|
unread = '*'
|
||||||
elif num_unread > 1:
|
elif num_unread > 1:
|
||||||
unread = '[' + unicode(num_unread) + ']'
|
unread = '[' + str(num_unread) + ']'
|
||||||
|
|
||||||
# Draw tab label using chatstate
|
# Draw tab label using chatstate
|
||||||
theme = gajim.config.get('roster_theme')
|
theme = gajim.config.get('roster_theme')
|
||||||
|
|
|
@ -32,7 +32,7 @@ over the process.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from types import NoneType
|
from types import NoneType
|
||||||
from tools import remove
|
from .tools import remove
|
||||||
|
|
||||||
COMMANDS = {}
|
COMMANDS = {}
|
||||||
CONTAINERS = {}
|
CONTAINERS = {}
|
||||||
|
|
|
@ -23,10 +23,10 @@ import re
|
||||||
from types import FunctionType
|
from types import FunctionType
|
||||||
from inspect import getargspec, getdoc
|
from inspect import getargspec, getdoc
|
||||||
|
|
||||||
from dispatcher import Host, Container
|
from .dispatcher import Host, Container
|
||||||
from dispatcher import get_command, list_commands
|
from .dispatcher import get_command, list_commands
|
||||||
from mapping import parse_arguments, adapt_arguments
|
from mmapping import parse_arguments, adapt_arguments
|
||||||
from errors import DefinitionError, CommandError, NoCommandError
|
from .errors import DefinitionError, CommandError, NoCommandError
|
||||||
|
|
||||||
class CommandHost(object):
|
class CommandHost(object):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -35,7 +35,7 @@ detected.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from ..framework import CommandContainer, command, doc
|
from ..framework import CommandContainer, command, doc
|
||||||
from hosts import *
|
from .hosts import *
|
||||||
|
|
||||||
class CustomCommonCommands(CommandContainer):
|
class CustomCommonCommands(CommandContainer):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -38,7 +38,7 @@ from os.path import expanduser
|
||||||
from glib import timeout_add
|
from glib import timeout_add
|
||||||
|
|
||||||
from ..framework import CommandContainer, command, doc
|
from ..framework import CommandContainer, command, doc
|
||||||
from hosts import *
|
from .hosts import *
|
||||||
|
|
||||||
class Execute(CommandContainer):
|
class Execute(CommandContainer):
|
||||||
AUTOMATIC = True
|
AUTOMATIC = True
|
||||||
|
|
|
@ -30,8 +30,8 @@ from ..errors import CommandError
|
||||||
from ..framework import CommandContainer, command, doc
|
from ..framework import CommandContainer, command, doc
|
||||||
from ..mapping import generate_usage
|
from ..mapping import generate_usage
|
||||||
|
|
||||||
from hosts import *
|
from .hosts import *
|
||||||
import execute
|
from . import execute
|
||||||
|
|
||||||
# This holds constants fron the logger, which we'll be using in some of our
|
# This holds constants fron the logger, which we'll be using in some of our
|
||||||
# commands.
|
# commands.
|
||||||
|
|
|
@ -26,7 +26,7 @@ import re
|
||||||
from types import BooleanType, UnicodeType
|
from types import BooleanType, UnicodeType
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
from errors import DefinitionError, CommandError
|
from .errors import DefinitionError, CommandError
|
||||||
|
|
||||||
# Quite complex piece of regular expression logic to parse options and
|
# Quite complex piece of regular expression logic to parse options and
|
||||||
# arguments. Might need some tweaking along the way.
|
# arguments. Might need some tweaking along the way.
|
||||||
|
@ -269,12 +269,6 @@ def adapt_arguments(command, arguments, args, opts):
|
||||||
if not isinstance(value, BooleanType):
|
if not isinstance(value, BooleanType):
|
||||||
raise CommandError("%s: Switch can not take an argument" % key, command)
|
raise CommandError("%s: Switch can not take an argument" % key, command)
|
||||||
|
|
||||||
# We need to encode every keyword argument to a simple string, not
|
|
||||||
# the unicode one, because ** expansion does not support it.
|
|
||||||
for index, (key, value) in enumerate(opts):
|
|
||||||
if isinstance(key, UnicodeType):
|
|
||||||
opts[index] = (key.encode(KEY_ENCODING), value)
|
|
||||||
|
|
||||||
# Inject the source arguments as a string as a first argument, if
|
# Inject the source arguments as a string as a first argument, if
|
||||||
# command has enabled the corresponding option.
|
# command has enabled the corresponding option.
|
||||||
if command.source:
|
if command.source:
|
||||||
|
|
|
@ -29,7 +29,7 @@ import sys
|
||||||
import stat
|
import stat
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
import logger
|
from common import logger
|
||||||
from common import jingle_xtls
|
from common import jingle_xtls
|
||||||
|
|
||||||
# DO NOT MOVE ABOVE OF import gajim
|
# DO NOT MOVE ABOVE OF import gajim
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
##
|
##
|
||||||
|
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
import helpers
|
from common import helpers
|
||||||
import dataforms
|
from common import dataforms
|
||||||
import gajim
|
from common import gajim
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger('gajim.c.commands')
|
log = logging.getLogger('gajim.c.commands')
|
||||||
|
|
|
@ -61,7 +61,7 @@ def fse(s):
|
||||||
"""
|
"""
|
||||||
Convert from filesystem encoding if not already Unicode
|
Convert from filesystem encoding if not already Unicode
|
||||||
"""
|
"""
|
||||||
return unicode(s, sys.getfilesystemencoding())
|
return s
|
||||||
|
|
||||||
def windowsify(s):
|
def windowsify(s):
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
|
|
|
@ -616,7 +616,7 @@ class CommonConnection:
|
||||||
if realm == '':
|
if realm == '':
|
||||||
if event == nbxmpp.transports_nb.DATA_RECEIVED:
|
if event == nbxmpp.transports_nb.DATA_RECEIVED:
|
||||||
gajim.nec.push_incoming_event(StanzaReceivedEvent(None,
|
gajim.nec.push_incoming_event(StanzaReceivedEvent(None,
|
||||||
conn=self, stanza_str=unicode(data, errors='ignore')))
|
conn=self, stanza_str=data))
|
||||||
elif event == nbxmpp.transports_nb.DATA_SENT:
|
elif event == nbxmpp.transports_nb.DATA_SENT:
|
||||||
gajim.nec.push_incoming_event(StanzaSentEvent(None, conn=self,
|
gajim.nec.push_incoming_event(StanzaSentEvent(None, conn=self,
|
||||||
stanza_str=data))
|
stanza_str=data))
|
||||||
|
@ -1446,7 +1446,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
self.connection.send(' ')
|
self.connection.send(' ')
|
||||||
|
|
||||||
def _on_xmpp_ping_answer(self, iq_obj):
|
def _on_xmpp_ping_answer(self, iq_obj):
|
||||||
id_ = unicode(iq_obj.getAttr('id'))
|
id_ = iq_obj.getAttr('id')
|
||||||
assert id_ == self.awaiting_xmpp_ping_id
|
assert id_ == self.awaiting_xmpp_ping_id
|
||||||
self.awaiting_xmpp_ping_id = None
|
self.awaiting_xmpp_ping_id = None
|
||||||
|
|
||||||
|
@ -1607,7 +1607,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
self.activate_privacy_rule('invisible')
|
self.activate_privacy_rule('invisible')
|
||||||
self.connected = gajim.SHOW_LIST.index('invisible')
|
self.connected = gajim.SHOW_LIST.index('invisible')
|
||||||
self.status = msg
|
self.status = msg
|
||||||
priority = unicode(gajim.get_priority(self.name, 'invisible'))
|
priority = gajim.get_priority(self.name, 'invisible')
|
||||||
p = nbxmpp.Presence(priority=priority)
|
p = nbxmpp.Presence(priority=priority)
|
||||||
p = self.add_sha(p, True)
|
p = self.add_sha(p, True)
|
||||||
if msg:
|
if msg:
|
||||||
|
@ -1781,7 +1781,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
p.setStatus(msg)
|
p.setStatus(msg)
|
||||||
else:
|
else:
|
||||||
signed = self.get_signed_presence(msg)
|
signed = self.get_signed_presence(msg)
|
||||||
priority = unicode(gajim.get_priority(self.name, sshow))
|
priority = gajim.get_priority(self.name, sshow)
|
||||||
p = nbxmpp.Presence(typ=None, priority=priority, show=sshow, to=jid)
|
p = nbxmpp.Presence(typ=None, priority=priority, show=sshow, to=jid)
|
||||||
p = self.add_sha(p)
|
p = self.add_sha(p)
|
||||||
if msg:
|
if msg:
|
||||||
|
@ -1805,7 +1805,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
|
|
||||||
def _update_status(self, show, msg):
|
def _update_status(self, show, msg):
|
||||||
xmpp_show = helpers.get_xmpp_show(show)
|
xmpp_show = helpers.get_xmpp_show(show)
|
||||||
priority = unicode(gajim.get_priority(self.name, xmpp_show))
|
priority = gajim.get_priority(self.name, xmpp_show)
|
||||||
p = nbxmpp.Presence(typ=None, priority=priority, show=xmpp_show)
|
p = nbxmpp.Presence(typ=None, priority=priority, show=xmpp_show)
|
||||||
p = self.add_sha(p)
|
p = self.add_sha(p)
|
||||||
if msg:
|
if msg:
|
||||||
|
|
|
@ -39,7 +39,7 @@ from time import (altzone, daylight, gmtime, localtime, mktime, strftime,
|
||||||
from calendar import timegm
|
from calendar import timegm
|
||||||
|
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
import common.caps_cache as capscache
|
from common import caps_cache as capscache
|
||||||
|
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
@ -181,8 +181,8 @@ class ConnectionDisco:
|
||||||
if not self.connection or self.connected < 2:
|
if not self.connection or self.connected < 2:
|
||||||
return
|
return
|
||||||
frm = helpers.get_full_jid_from_iq(iq_obj)
|
frm = helpers.get_full_jid_from_iq(iq_obj)
|
||||||
to = unicode(iq_obj.getAttr('to'))
|
to = iq_obj.getAttr('to')
|
||||||
id_ = unicode(iq_obj.getAttr('id'))
|
id_ = iq_obj.getAttr('id')
|
||||||
iq = nbxmpp.Iq(to=frm, typ='result', queryNS=nbxmpp.NS_DISCO, frm=to)
|
iq = nbxmpp.Iq(to=frm, typ='result', queryNS=nbxmpp.NS_DISCO, frm=to)
|
||||||
iq.setAttr('id', id_)
|
iq.setAttr('id', id_)
|
||||||
query = iq.setTag('query')
|
query = iq.setTag('query')
|
||||||
|
@ -235,7 +235,7 @@ class ConnectionDisco:
|
||||||
if self.commandInfoQuery(con, iq_obj):
|
if self.commandInfoQuery(con, iq_obj):
|
||||||
raise nbxmpp.NodeProcessed
|
raise nbxmpp.NodeProcessed
|
||||||
|
|
||||||
id_ = unicode(iq_obj.getAttr('id'))
|
id_ = iq_obj.getAttr('id')
|
||||||
if id_[:6] == 'Gajim_':
|
if id_[:6] == 'Gajim_':
|
||||||
# We get this request from echo.server
|
# We get this request from echo.server
|
||||||
raise nbxmpp.NodeProcessed
|
raise nbxmpp.NodeProcessed
|
||||||
|
|
|
@ -39,7 +39,7 @@ from nbxmpp.protocol import NS_CHATSTATES
|
||||||
from common.jingle_transport import JingleTransportSocks5
|
from common.jingle_transport import JingleTransportSocks5
|
||||||
from common.file_props import FilesProp
|
from common.file_props import FilesProp
|
||||||
|
|
||||||
import gtkgui_helpers
|
from . import gtkgui_helpers
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger('gajim.c.connection_handlers_events')
|
log = logging.getLogger('gajim.c.connection_handlers_events')
|
||||||
|
@ -1169,7 +1169,6 @@ class ZeroconfMessageReceivedEvent(MessageReceivedEvent):
|
||||||
self.fjid = key
|
self.fjid = key
|
||||||
break
|
break
|
||||||
|
|
||||||
self.fjid = unicode(self.fjid)
|
|
||||||
self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid)
|
self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid)
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
@ -1986,7 +1985,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
self.FT_content.session.ourjid)
|
self.FT_content.session.ourjid)
|
||||||
self.FT_content.transport.set_connection(
|
self.FT_content.transport.set_connection(
|
||||||
self.FT_content.session.connection)
|
self.FT_content.session.connection)
|
||||||
sid = unicode(self.stanza.getTag('jingle').getAttr('sid'))
|
sid = self.stanza.getTag('jingle').getAttr('sid')
|
||||||
self.file_props = FilesProp.getNewFileProp(self.conn.name, sid)
|
self.file_props = FilesProp.getNewFileProp(self.conn.name, sid)
|
||||||
self.file_props.transport_sid = self.FT_content.transport.sid
|
self.file_props.transport_sid = self.FT_content.transport.sid
|
||||||
self.FT_content.file_props = self.file_props
|
self.FT_content.file_props = self.file_props
|
||||||
|
@ -2033,8 +2032,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
else:
|
else:
|
||||||
si = self.stanza.getTag('si')
|
si = self.stanza.getTag('si')
|
||||||
self.file_props = FilesProp.getNewFileProp(self.conn.name,
|
self.file_props = FilesProp.getNewFileProp(self.conn.name,
|
||||||
unicode(si.getAttr('id'))
|
si.getAttr('id'))
|
||||||
)
|
|
||||||
profile = si.getAttr('profile')
|
profile = si.getAttr('profile')
|
||||||
if profile != nbxmpp.NS_FILE:
|
if profile != nbxmpp.NS_FILE:
|
||||||
self.conn.send_file_rejection(self.file_props, code='400',
|
self.conn.send_file_rejection(self.file_props, code='400',
|
||||||
|
|
|
@ -27,7 +27,7 @@ information how to use them, read documentation
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
import helpers
|
from common import helpers
|
||||||
|
|
||||||
# exceptions used in this module
|
# exceptions used in this module
|
||||||
# base class
|
# base class
|
||||||
|
@ -345,7 +345,7 @@ class StringField(DataField):
|
||||||
@nested_property
|
@nested_property
|
||||||
def value():
|
def value():
|
||||||
"""
|
"""
|
||||||
Value of field. May be any unicode string
|
Value of field. May be any string
|
||||||
"""
|
"""
|
||||||
def fget(self):
|
def fget(self):
|
||||||
return self.getTagData('value') or ''
|
return self.getTagData('value') or ''
|
||||||
|
|
|
@ -31,10 +31,10 @@ import sys
|
||||||
import logging
|
import logging
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
import config
|
from common import config
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
import defs
|
from common import defs
|
||||||
import common.ged
|
from common import ged
|
||||||
|
|
||||||
interface = None # The actual interface (the gtk one for the moment)
|
interface = None # The actual interface (the gtk one for the moment)
|
||||||
thread_interface = None # Interface to run a thread and then a callback
|
thread_interface = None # Interface to run a thread and then a callback
|
||||||
|
@ -280,13 +280,8 @@ def get_jid_without_resource(jid):
|
||||||
return jid.split('/')[0]
|
return jid.split('/')[0]
|
||||||
|
|
||||||
def construct_fjid(room_jid, nick):
|
def construct_fjid(room_jid, nick):
|
||||||
"""
|
|
||||||
Nick is in UTF-8 (taken from treeview); room_jid is in unicode
|
|
||||||
"""
|
|
||||||
# fake jid is the jid for a contact in a room
|
# fake jid is the jid for a contact in a room
|
||||||
# gaim@conference.jabber.org/nick
|
# gaim@conference.jabber.org/nick
|
||||||
if isinstance(nick, str):
|
|
||||||
nick = unicode(nick, 'utf-8')
|
|
||||||
return room_jid + '/' + nick
|
return room_jid + '/' + nick
|
||||||
|
|
||||||
def get_resource_from_jid(jid):
|
def get_resource_from_jid(jid):
|
||||||
|
|
|
@ -26,7 +26,7 @@ from gajim import HAVE_GPG
|
||||||
import os
|
import os
|
||||||
|
|
||||||
if HAVE_GPG:
|
if HAVE_GPG:
|
||||||
import gnupg
|
from common import gnupg
|
||||||
|
|
||||||
class GnuPG(gnupg.GPG):
|
class GnuPG(gnupg.GPG):
|
||||||
def __init__(self, use_agent=False):
|
def __init__(self, use_agent=False):
|
||||||
|
|
|
@ -42,7 +42,7 @@ import select
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import shlex
|
import shlex
|
||||||
import caps_cache
|
from common import caps_cache
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ def prep(user, server, resource):
|
||||||
raise InvalidFormat, _('Username must be between 1 and 1023 chars')
|
raise InvalidFormat, _('Username must be between 1 and 1023 chars')
|
||||||
try:
|
try:
|
||||||
from nbxmpp.stringprepare import nodeprep
|
from nbxmpp.stringprepare import nodeprep
|
||||||
user = nodeprep.prepare(unicode(user)).encode('utf-8')
|
user = nodeprep.prepare(user)
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise InvalidFormat, _('Invalid character in username.')
|
raise InvalidFormat, _('Invalid character in username.')
|
||||||
else:
|
else:
|
||||||
|
@ -170,7 +170,7 @@ def prep(user, server, resource):
|
||||||
raise InvalidFormat, _('Server must be between 1 and 1023 chars')
|
raise InvalidFormat, _('Server must be between 1 and 1023 chars')
|
||||||
try:
|
try:
|
||||||
from nbxmpp.stringprepare import nameprep
|
from nbxmpp.stringprepare import nameprep
|
||||||
server = nameprep.prepare(unicode(server)).encode('utf-8')
|
server = nameprep.prepare(server)
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise InvalidFormat, _('Invalid character in hostname.')
|
raise InvalidFormat, _('Invalid character in hostname.')
|
||||||
else:
|
else:
|
||||||
|
@ -181,7 +181,7 @@ def prep(user, server, resource):
|
||||||
raise InvalidFormat, _('Resource must be between 1 and 1023 chars')
|
raise InvalidFormat, _('Resource must be between 1 and 1023 chars')
|
||||||
try:
|
try:
|
||||||
from nbxmpp.stringprepare import resourceprep
|
from nbxmpp.stringprepare import resourceprep
|
||||||
resource = resourceprep.prepare(unicode(resource)).encode('utf-8')
|
resource = resourceprep.prepare(resource)
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise InvalidFormat, _('Invalid character in resource.')
|
raise InvalidFormat, _('Invalid character in resource.')
|
||||||
else:
|
else:
|
||||||
|
@ -448,43 +448,43 @@ def get_output_of_command(command):
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def decode_string(string):
|
#def decode_string(string):
|
||||||
"""
|
#"""
|
||||||
Try to decode (to make it Unicode instance) given string
|
#Try to decode (to make it Unicode instance) given string
|
||||||
"""
|
#"""
|
||||||
if isinstance(string, unicode):
|
#if isinstance(string, unicode):
|
||||||
return string
|
#return string
|
||||||
# by the time we go to iso15 it better be the one else we show bad characters
|
## by the time we go to iso15 it better be the one else we show bad characters
|
||||||
encodings = (locale.getpreferredencoding(), 'utf-8', 'iso-8859-15')
|
#encodings = (locale.getpreferredencoding(), 'utf-8', 'iso-8859-15')
|
||||||
for encoding in encodings:
|
#for encoding in encodings:
|
||||||
try:
|
#try:
|
||||||
string = string.decode(encoding)
|
#string = string.decode(encoding)
|
||||||
except UnicodeError:
|
#except UnicodeError:
|
||||||
continue
|
#continue
|
||||||
break
|
#break
|
||||||
|
|
||||||
return string
|
#return string
|
||||||
|
|
||||||
def ensure_utf8_string(string):
|
#def ensure_utf8_string(string):
|
||||||
"""
|
#"""
|
||||||
Make sure string is in UTF-8
|
#Make sure string is in UTF-8
|
||||||
"""
|
#"""
|
||||||
try:
|
#try:
|
||||||
string = decode_string(string).encode('utf-8')
|
#string = decode_string(string).encode('utf-8')
|
||||||
except Exception:
|
#except Exception:
|
||||||
pass
|
#pass
|
||||||
return string
|
#return string
|
||||||
|
|
||||||
def wrapped_ensure_utf8_string(fn):
|
#def wrapped_ensure_utf8_string(fn):
|
||||||
def wrapped(n):
|
#def wrapped(n):
|
||||||
return ensure_utf8_string(n)
|
#return ensure_utf8_string(n)
|
||||||
return wrapped
|
#return wrapped
|
||||||
|
|
||||||
@wrapped_ensure_utf8_string
|
#@wrapped_ensure_utf8_string
|
||||||
def escape_text(text):
|
#def escape_text(text):
|
||||||
return GObject.markup_escape_text(text)
|
#return GObject.markup_escape_text(text)
|
||||||
|
|
||||||
GObject.markup_escape_text = escape_text
|
#GObject.markup_escape_text = escape_text
|
||||||
|
|
||||||
def get_windows_reg_env(varname, default=''):
|
def get_windows_reg_env(varname, default=''):
|
||||||
"""
|
"""
|
||||||
|
@ -645,13 +645,13 @@ def convert_bytes(string):
|
||||||
# but do we use the standard?
|
# but do we use the standard?
|
||||||
use_kib_mib = gajim.config.get('use_kib_mib')
|
use_kib_mib = gajim.config.get('use_kib_mib')
|
||||||
align = 1024.
|
align = 1024.
|
||||||
bytes = float(string)
|
bytes_ = float(string)
|
||||||
if bytes >= align:
|
if bytes_ >= align:
|
||||||
bytes = round(bytes/align, 1)
|
bytes_ = round(bytes_/align, 1)
|
||||||
if bytes >= align:
|
if bytes_ >= align:
|
||||||
bytes = round(bytes/align, 1)
|
bytes_ = round(bytes_/align, 1)
|
||||||
if bytes >= align:
|
if bytes_ >= align:
|
||||||
bytes = round(bytes/align, 1)
|
bytes_ = round(bytes_/align, 1)
|
||||||
if use_kib_mib:
|
if use_kib_mib:
|
||||||
#GiB means gibibyte
|
#GiB means gibibyte
|
||||||
suffix = _('%s GiB')
|
suffix = _('%s GiB')
|
||||||
|
@ -675,7 +675,7 @@ def convert_bytes(string):
|
||||||
else:
|
else:
|
||||||
#B means bytes
|
#B means bytes
|
||||||
suffix = _('%s B')
|
suffix = _('%s B')
|
||||||
return suffix % unicode(bytes)
|
return suffix % str(bytes_)
|
||||||
|
|
||||||
def get_contact_dict_for_account(account):
|
def get_contact_dict_for_account(account):
|
||||||
"""
|
"""
|
||||||
|
@ -901,13 +901,13 @@ def get_icon_name_to_show(contact, account = None):
|
||||||
|
|
||||||
def get_full_jid_from_iq(iq_obj):
|
def get_full_jid_from_iq(iq_obj):
|
||||||
"""
|
"""
|
||||||
Return the full jid (with resource) from an iq as unicode
|
Return the full jid (with resource) from an iq
|
||||||
"""
|
"""
|
||||||
return parse_jid(str(iq_obj.getFrom()))
|
return parse_jid(iq_obj.getFrom())
|
||||||
|
|
||||||
def get_jid_from_iq(iq_obj):
|
def get_jid_from_iq(iq_obj):
|
||||||
"""
|
"""
|
||||||
Return the jid (without resource) from an iq as unicode
|
Return the jid (without resource) from an iq
|
||||||
"""
|
"""
|
||||||
jid = get_full_jid_from_iq(iq_obj)
|
jid = get_full_jid_from_iq(iq_obj)
|
||||||
return gajim.get_jid_without_resource(jid)
|
return gajim.get_jid_without_resource(jid)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
import locale
|
import locale
|
||||||
import gettext
|
import gettext
|
||||||
import os
|
import os
|
||||||
import defs
|
from common import defs
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
def paragraph_direction_mark(text):
|
def paragraph_direction_mark(text):
|
||||||
|
@ -61,7 +61,7 @@ if os.name == 'nt':
|
||||||
if lang:
|
if lang:
|
||||||
os.environ['LANG'] = lang
|
os.environ['LANG'] = lang
|
||||||
|
|
||||||
gettext.install(APP, DIR, unicode=False)
|
gettext.install(APP, DIR)
|
||||||
if gettext._translations:
|
if gettext._translations:
|
||||||
_translation = gettext._translations.values()[0]
|
_translation = gettext._translations.values()[0]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -158,7 +158,7 @@ def send_cert_request(con, to_jid):
|
||||||
pubkey = iq.setTag('pubkeys')
|
pubkey = iq.setTag('pubkeys')
|
||||||
pubkey.setNamespace(nbxmpp.NS_PUBKEY_PUBKEY)
|
pubkey.setNamespace(nbxmpp.NS_PUBKEY_PUBKEY)
|
||||||
con.connection.send(iq)
|
con.connection.send(iq)
|
||||||
return unicode(id_)
|
return str(id_)
|
||||||
|
|
||||||
# the following code is partly due to pyopenssl examples
|
# the following code is partly due to pyopenssl examples
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ def kwallet_get(folder, entry):
|
||||||
• folder: The top-level category to use (normally the programme name)
|
• folder: The top-level category to use (normally the programme name)
|
||||||
• entry: The key of the entry to retrieve
|
• entry: The key of the entry to retrieve
|
||||||
|
|
||||||
Returns the passphrase as unicode, False if it cannot be found,
|
Returns the passphrase, False if it cannot be found,
|
||||||
or None if an error occured.
|
or None if an error occured.
|
||||||
"""
|
"""
|
||||||
p = subprocess.Popen(["kwalletcli", "-q", "-f", folder.encode('utf-8'),
|
p = subprocess.Popen(["kwalletcli", "-q", "-f", folder.encode('utf-8'),
|
||||||
|
|
|
@ -884,8 +884,7 @@ class Logger:
|
||||||
# ..., 'FEAT', feature1, feature2, ...).join(' '))
|
# ..., 'FEAT', feature1, feature2, ...).join(' '))
|
||||||
# NOTE: if there's a need to do more gzip, put that to a function
|
# NOTE: if there's a need to do more gzip, put that to a function
|
||||||
try:
|
try:
|
||||||
data = GzipFile(fileobj=StringIO(str(data))).read().decode(
|
data = GzipFile(fileobj=StringIO(str(data))).read().split('\0')
|
||||||
'utf-8').split('\0')
|
|
||||||
except IOError:
|
except IOError:
|
||||||
# This data is corrupted. It probably contains non-ascii chars
|
# This data is corrupted. It probably contains non-ascii chars
|
||||||
to_be_removed.append((hash_method, hash_))
|
to_be_removed.append((hash_method, hash_))
|
||||||
|
@ -927,7 +926,6 @@ class Logger:
|
||||||
# if there's a need to do more gzip, put that to a function
|
# if there's a need to do more gzip, put that to a function
|
||||||
string = StringIO()
|
string = StringIO()
|
||||||
gzip = GzipFile(fileobj=string, mode='w')
|
gzip = GzipFile(fileobj=string, mode='w')
|
||||||
data = data.encode('utf-8') # the gzip module can't handle unicode objects
|
|
||||||
gzip.write(data)
|
gzip.write(data)
|
||||||
gzip.close()
|
gzip.close()
|
||||||
data = string.getvalue()
|
data = string.getvalue()
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
##
|
##
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import i18n
|
from common import i18n
|
||||||
|
|
||||||
def parseLogLevel(arg):
|
def parseLogLevel(arg):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -96,7 +96,7 @@ class ConnectionArchive:
|
||||||
|
|
||||||
def get_item_pref(self, jid):
|
def get_item_pref(self, jid):
|
||||||
jid = nbxmpp.JID(jid)
|
jid = nbxmpp.JID(jid)
|
||||||
if unicode(jid) in self.items:
|
if str(jid) in self.items:
|
||||||
return self.items[jid]
|
return self.items[jid]
|
||||||
|
|
||||||
if jid.getStripped() in self.items:
|
if jid.getStripped() in self.items:
|
||||||
|
|
|
@ -87,19 +87,12 @@ class OptionsParser:
|
||||||
if value is None:
|
if value is None:
|
||||||
return
|
return
|
||||||
# convert to utf8 before writing to file if needed
|
# convert to utf8 before writing to file if needed
|
||||||
if isinstance(value, unicode):
|
|
||||||
value = value.encode('utf-8')
|
|
||||||
else:
|
|
||||||
value = str(value)
|
value = str(value)
|
||||||
if isinstance(opt, unicode):
|
|
||||||
opt = opt.encode('utf-8')
|
|
||||||
s = ''
|
s = ''
|
||||||
if parents:
|
if parents:
|
||||||
if len(parents) == 1:
|
if len(parents) == 1:
|
||||||
return
|
return
|
||||||
for p in parents:
|
for p in parents:
|
||||||
if isinstance(p, unicode):
|
|
||||||
p = p.encode('utf-8')
|
|
||||||
s += p + '.'
|
s += p + '.'
|
||||||
s += opt
|
s += opt
|
||||||
fd.write(s + ' = ' + value + '\n')
|
fd.write(s + ' = ' + value + '\n')
|
||||||
|
|
|
@ -163,7 +163,7 @@ class ConnectionBytestream:
|
||||||
session.approve_content('file', content.name)
|
session.approve_content('file', content.name)
|
||||||
return
|
return
|
||||||
|
|
||||||
iq = nbxmpp.Iq(to=unicode(file_props.sender), typ='result')
|
iq = nbxmpp.Iq(to=file_props.sender, typ='result')
|
||||||
iq.setAttr('id', file_props.request_id)
|
iq.setAttr('id', file_props.request_id)
|
||||||
si = iq.setTag('si', namespace=nbxmpp.NS_SI)
|
si = iq.setTag('si', namespace=nbxmpp.NS_SI)
|
||||||
if file_props.offset:
|
if file_props.offset:
|
||||||
|
@ -195,7 +195,7 @@ class ConnectionBytestream:
|
||||||
jingle = self._sessions[file_props.sid]
|
jingle = self._sessions[file_props.sid]
|
||||||
jingle.cancel_session()
|
jingle.cancel_session()
|
||||||
return
|
return
|
||||||
iq = nbxmpp.Iq(to=unicode(file_props.sender), typ='error')
|
iq = nbxmpp.Iq(to=file_props.sender, typ='error')
|
||||||
iq.setAttr('id', file_props.request_id)
|
iq.setAttr('id', file_props.request_id)
|
||||||
if code == '400' and typ in ('stream', 'profile'):
|
if code == '400' and typ in ('stream', 'profile'):
|
||||||
name = 'bad-request'
|
name = 'bad-request'
|
||||||
|
@ -296,7 +296,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
for file_props in FilesProp.getAllFileProp():
|
for file_props in FilesProp.getAllFileProp():
|
||||||
if is_transfer_stopped(file_props):
|
if is_transfer_stopped(file_props):
|
||||||
continue
|
continue
|
||||||
receiver_jid = unicode(file_props.receiver)
|
receiver_jid = file_props.receiver
|
||||||
if contact.get_full_jid() == receiver_jid:
|
if contact.get_full_jid() == receiver_jid:
|
||||||
file_props.error = -5
|
file_props.error = -5
|
||||||
self.remove_transfer(file_props)
|
self.remove_transfer(file_props)
|
||||||
|
@ -305,7 +305,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
gajim.nec.push_incoming_event(FileRequestErrorEvent(None,
|
gajim.nec.push_incoming_event(FileRequestErrorEvent(None,
|
||||||
conn=self, jid=contact.jid, file_props=file_props,
|
conn=self, jid=contact.jid, file_props=file_props,
|
||||||
error_msg=''))
|
error_msg=''))
|
||||||
sender_jid = unicode(file_props.sender)
|
sender_jid = file_props.sender
|
||||||
if contact.get_full_jid() == sender_jid:
|
if contact.get_full_jid() == sender_jid:
|
||||||
file_props.error = -3
|
file_props.error = -3
|
||||||
self.remove_transfer(file_props)
|
self.remove_transfer(file_props)
|
||||||
|
@ -354,11 +354,11 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
file_props.error = -5
|
file_props.error = -5
|
||||||
from common.connection_handlers_events import FileRequestErrorEvent
|
from common.connection_handlers_events import FileRequestErrorEvent
|
||||||
gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self,
|
gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self,
|
||||||
jid=unicode(receiver), file_props=file_props, error_msg=''))
|
jid=receiver, file_props=file_props, error_msg=''))
|
||||||
self._connect_error(unicode(receiver), file_props.sid,
|
self._connect_error(receiver, file_props.sid,
|
||||||
file_props.sid, code=406)
|
file_props.sid, code=406)
|
||||||
else:
|
else:
|
||||||
iq = nbxmpp.Iq(to=unicode(receiver), typ='set')
|
iq = nbxmpp.Iq(to=receiver, typ='set')
|
||||||
file_props.request_id = 'id_' + file_props.sid
|
file_props.request_id = 'id_' + file_props.sid
|
||||||
iq.setID(file_props.request_id)
|
iq.setID(file_props.request_id)
|
||||||
query = iq.setTag('query', namespace=nbxmpp.NS_BYTESTREAM)
|
query = iq.setTag('query', namespace=nbxmpp.NS_BYTESTREAM)
|
||||||
|
@ -374,7 +374,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
streamhost = nbxmpp.Node(tag='streamhost')
|
streamhost = nbxmpp.Node(tag='streamhost')
|
||||||
query.addChild(node=streamhost)
|
query.addChild(node=streamhost)
|
||||||
streamhost.setAttr('port', unicode(port))
|
streamhost.setAttr('port', str(port))
|
||||||
streamhost.setAttr('host', host)
|
streamhost.setAttr('host', host)
|
||||||
streamhost.setAttr('jid', sender)
|
streamhost.setAttr('jid', sender)
|
||||||
|
|
||||||
|
@ -489,8 +489,8 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
def _add_proxy_streamhosts_to_query(self, query, file_props):
|
def _add_proxy_streamhosts_to_query(self, query, file_props):
|
||||||
proxyhosts = self._get_file_transfer_proxies_from_config(file_props)
|
proxyhosts = self._get_file_transfer_proxies_from_config(file_props)
|
||||||
if proxyhosts:
|
if proxyhosts:
|
||||||
file_props.proxy_receiver = unicode(file_props.receiver)
|
file_props.proxy_receiver = file_props.receiver
|
||||||
file_props.proxy_sender = unicode(file_props.sender)
|
file_props.proxy_sender = file_props.sender
|
||||||
file_props.proxyhosts = proxyhosts
|
file_props.proxyhosts = proxyhosts
|
||||||
|
|
||||||
for proxyhost in proxyhosts:
|
for proxyhost in proxyhosts:
|
||||||
|
@ -518,12 +518,12 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
continue
|
continue
|
||||||
host_dict = {
|
host_dict = {
|
||||||
'state': 0,
|
'state': 0,
|
||||||
'target': unicode(file_props.receiver),
|
'target': file_props.receiver,
|
||||||
'id': file_props.sid,
|
'id': file_props.sid,
|
||||||
'sid': file_props.sid,
|
'sid': file_props.sid,
|
||||||
'initiator': proxy,
|
'initiator': proxy,
|
||||||
'host': host,
|
'host': host,
|
||||||
'port': unicode(_port),
|
'port': str(_port),
|
||||||
'jid': jid
|
'jid': jid
|
||||||
}
|
}
|
||||||
proxyhost_dicts.append(host_dict)
|
proxyhost_dicts.append(host_dict)
|
||||||
|
@ -563,7 +563,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
iq = nbxmpp.Iq(to=to, typ='error')
|
iq = nbxmpp.Iq(to=to, typ='error')
|
||||||
iq.setAttr('id', file_props.sid)
|
iq.setAttr('id', file_props.sid)
|
||||||
err = iq.setTag('error')
|
err = iq.setTag('error')
|
||||||
err.setAttr('code', unicode(code))
|
err.setAttr('code', str(code))
|
||||||
err.setData(msg)
|
err.setData(msg)
|
||||||
self.connection.send(iq)
|
self.connection.send(iq)
|
||||||
if code == 404:
|
if code == 404:
|
||||||
|
@ -593,7 +593,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
|
|
||||||
# register xmpppy handlers for bytestream and FT stanzas
|
# register xmpppy handlers for bytestream and FT stanzas
|
||||||
def _bytestreamErrorCB(self, con, iq_obj):
|
def _bytestreamErrorCB(self, con, iq_obj):
|
||||||
id_ = unicode(iq_obj.getAttr('id'))
|
id_ = iq_obj.getAttr('id')
|
||||||
frm = helpers.get_full_jid_from_iq(iq_obj)
|
frm = helpers.get_full_jid_from_iq(iq_obj)
|
||||||
query = iq_obj.getTag('query')
|
query = iq_obj.getTag('query')
|
||||||
gajim.proxy65_manager.error_cb(frm, query)
|
gajim.proxy65_manager.error_cb(frm, query)
|
||||||
|
@ -609,10 +609,10 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
raise nbxmpp.NodeProcessed
|
raise nbxmpp.NodeProcessed
|
||||||
|
|
||||||
def _bytestreamSetCB(self, con, iq_obj):
|
def _bytestreamSetCB(self, con, iq_obj):
|
||||||
target = unicode(iq_obj.getAttr('to'))
|
target = iq_obj.getAttr('to')
|
||||||
id_ = unicode(iq_obj.getAttr('id'))
|
id_ = iq_obj.getAttr('id')
|
||||||
query = iq_obj.getTag('query')
|
query = iq_obj.getTag('query')
|
||||||
sid = unicode(query.getAttr('sid'))
|
sid = query.getAttr('sid')
|
||||||
file_props = FilesProp.getFileProp(self.name, sid)
|
file_props = FilesProp.getFileProp(self.name, sid)
|
||||||
streamhosts = []
|
streamhosts = []
|
||||||
for item in query.getChildren():
|
for item in query.getChildren():
|
||||||
|
@ -657,7 +657,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
def _ResultCB(self, con, iq_obj):
|
def _ResultCB(self, con, iq_obj):
|
||||||
# if we want to respect xep-0065 we have to check for proxy
|
# if we want to respect xep-0065 we have to check for proxy
|
||||||
# activation result in any result iq
|
# activation result in any result iq
|
||||||
real_id = unicode(iq_obj.getAttr('id'))
|
real_id = iq_obj.getAttr('id')
|
||||||
if not real_id.startswith('au_'):
|
if not real_id.startswith('au_'):
|
||||||
return
|
return
|
||||||
frm = self._ft_get_from(iq_obj)
|
frm = self._ft_get_from(iq_obj)
|
||||||
|
@ -671,7 +671,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
|
|
||||||
def _bytestreamResultCB(self, con, iq_obj):
|
def _bytestreamResultCB(self, con, iq_obj):
|
||||||
frm = self._ft_get_from(iq_obj)
|
frm = self._ft_get_from(iq_obj)
|
||||||
real_id = unicode(iq_obj.getAttr('id'))
|
real_id = iq_obj.getAttr('id')
|
||||||
query = iq_obj.getTag('query')
|
query = iq_obj.getTag('query')
|
||||||
gajim.proxy65_manager.resolve_result(frm, query)
|
gajim.proxy65_manager.resolve_result(frm, query)
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
|
||||||
raise nbxmpp.NodeProcessed
|
raise nbxmpp.NodeProcessed
|
||||||
for host in file_props.proxyhosts:
|
for host in file_props.proxyhosts:
|
||||||
if host['initiator'] == frm and \
|
if host['initiator'] == frm and \
|
||||||
unicode(query.getAttr('sid')) == file_props.sid:
|
query.getAttr('sid') == file_props.sid:
|
||||||
gajim.socks5queue.activate_proxy(host['idx'])
|
gajim.socks5queue.activate_proxy(host['idx'])
|
||||||
break
|
break
|
||||||
raise nbxmpp.NodeProcessed
|
raise nbxmpp.NodeProcessed
|
||||||
|
@ -983,7 +983,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
|
||||||
class ConnectionSocks5BytestreamZeroconf(ConnectionSocks5Bytestream):
|
class ConnectionSocks5BytestreamZeroconf(ConnectionSocks5Bytestream):
|
||||||
|
|
||||||
def _ft_get_from(self, iq_obj):
|
def _ft_get_from(self, iq_obj):
|
||||||
return unicode(iq_obj.getFrom())
|
return iq_obj.getFrom()
|
||||||
|
|
||||||
def _ft_get_our_jid(self):
|
def _ft_get_our_jid(self):
|
||||||
return gajim.get_jid_from_account(self.name)
|
return gajim.get_jid_from_account(self.name)
|
||||||
|
|
|
@ -117,7 +117,7 @@ class ProxyResolver:
|
||||||
"""
|
"""
|
||||||
self.host = str(host)
|
self.host = str(host)
|
||||||
self.port = int(port)
|
self.port = int(port)
|
||||||
self.jid = unicode(jid)
|
self.jid = str(jid)
|
||||||
if not self.testit:
|
if not self.testit:
|
||||||
self.state = S_FINISHED
|
self.state = S_FINISHED
|
||||||
return
|
return
|
||||||
|
|
|
@ -418,19 +418,12 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
"""
|
"""
|
||||||
Append stanza to the queue of messages to be send if now is False, else
|
Append stanza to the queue of messages to be send if now is False, else
|
||||||
send it instantly
|
send it instantly
|
||||||
|
|
||||||
If supplied data is unicode string, encode it to UTF-8.
|
|
||||||
"""
|
"""
|
||||||
if self.state <= 0:
|
if self.state <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
r = packet
|
r = packet
|
||||||
|
|
||||||
if isinstance(r, unicode):
|
|
||||||
r = r.encode('utf-8')
|
|
||||||
elif not isinstance(r, str):
|
|
||||||
r = ustr(r).encode('utf-8')
|
|
||||||
|
|
||||||
if now:
|
if now:
|
||||||
self.sendqueue.insert(0, (r, is_message))
|
self.sendqueue.insert(0, (r, is_message))
|
||||||
self._do_send()
|
self._do_send()
|
||||||
|
@ -737,7 +730,7 @@ class ClientZeroconf:
|
||||||
def send(self, stanza, is_message=False, now=False, on_ok=None,
|
def send(self, stanza, is_message=False, now=False, on_ok=None,
|
||||||
on_not_ok=None):
|
on_not_ok=None):
|
||||||
stanza.setFrom(self.roster.zeroconf.name)
|
stanza.setFrom(self.roster.zeroconf.name)
|
||||||
to = unicode(stanza.getTo())
|
to = stanza.getTo()
|
||||||
to = gajim.get_jid_without_resource(to)
|
to = gajim.get_jid_without_resource(to)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -802,7 +795,7 @@ class ClientZeroconf:
|
||||||
def on_ok(_waitid):
|
def on_ok(_waitid):
|
||||||
# if timeout:
|
# if timeout:
|
||||||
# self._owner.set_timeout(timeout)
|
# self._owner.set_timeout(timeout)
|
||||||
to = unicode(stanza.getTo())
|
to = stanza.getTo()
|
||||||
to = gajim.get_jid_without_resource(to)
|
to = gajim.get_jid_without_resource(to)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
|
||||||
'is_zeroconf', True)
|
'is_zeroconf', True)
|
||||||
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME,
|
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME,
|
||||||
'use_ft_proxies', False)
|
'use_ft_proxies', False)
|
||||||
self.host = unicode(socket.gethostname(), locale.getpreferredencoding())
|
self.host = socket.gethostname()
|
||||||
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname',
|
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname',
|
||||||
self.host)
|
self.host)
|
||||||
self.port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME,
|
self.port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME,
|
||||||
|
@ -110,8 +110,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
|
||||||
'zeroconf_email')
|
'zeroconf_email')
|
||||||
|
|
||||||
if not self.username:
|
if not self.username:
|
||||||
self.username = unicode(getpass.getuser(),
|
self.username = getpass.getuser()
|
||||||
locale.getpreferredencoding())
|
|
||||||
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name',
|
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name',
|
||||||
self.username)
|
self.username)
|
||||||
else:
|
else:
|
||||||
|
@ -427,7 +426,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
|
||||||
if realm == '':
|
if realm == '':
|
||||||
if event == nbxmpp.transports_nb.DATA_ERROR:
|
if event == nbxmpp.transports_nb.DATA_ERROR:
|
||||||
thread_id = data[1]
|
thread_id = data[1]
|
||||||
frm = unicode(data[0])
|
frm = data[0]
|
||||||
session = self.get_or_create_session(frm, thread_id)
|
session = self.get_or_create_session(frm, thread_id)
|
||||||
gajim.nec.push_incoming_event(MessageErrorEvent(
|
gajim.nec.push_incoming_event(MessageErrorEvent(
|
||||||
None, conn=self, fjid=frm, error_code=-1, error_msg=_(
|
None, conn=self, fjid=frm, error_code=-1, error_msg=_(
|
||||||
|
|
|
@ -224,14 +224,7 @@ class Zeroconf:
|
||||||
return show
|
return show
|
||||||
|
|
||||||
def avahi_txt(self):
|
def avahi_txt(self):
|
||||||
utf8_dict = {}
|
return self.avahi.dict_to_txt_array(self.txt)
|
||||||
for key in self.txt:
|
|
||||||
val = self.txt[key]
|
|
||||||
if isinstance(val, unicode):
|
|
||||||
utf8_dict[key] = val.encode('utf-8')
|
|
||||||
else:
|
|
||||||
utf8_dict[key] = val
|
|
||||||
return self.avahi.dict_to_txt_array(utf8_dict)
|
|
||||||
|
|
||||||
def create_service(self):
|
def create_service(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1355,11 +1355,11 @@ class ManageProxiesWindow:
|
||||||
model = self.proxies_treeview.get_model()
|
model = self.proxies_treeview.get_model()
|
||||||
proxies = gajim.config.get_per('proxies')
|
proxies = gajim.config.get_per('proxies')
|
||||||
i = 1
|
i = 1
|
||||||
while ('proxy' + unicode(i)) in proxies:
|
while ('proxy' + str(i)) in proxies:
|
||||||
i += 1
|
i += 1
|
||||||
iter_ = model.append()
|
iter_ = model.append()
|
||||||
model.set(iter_, 0, 'proxy' + unicode(i))
|
model.set(iter_, 0, 'proxy' + str(i))
|
||||||
gajim.config.add_per('proxies', 'proxy' + unicode(i))
|
gajim.config.add_per('proxies', 'proxy' + str(i))
|
||||||
self.proxies_treeview.set_cursor(model.get_path(iter_))
|
self.proxies_treeview.set_cursor(model.get_path(iter_))
|
||||||
|
|
||||||
def on_remove_proxy_button_clicked(self, widget):
|
def on_remove_proxy_button_clicked(self, widget):
|
||||||
|
@ -1453,7 +1453,7 @@ class ManageProxiesWindow:
|
||||||
self.xml.get_object('proxy_table').set_sensitive(True)
|
self.xml.get_object('proxy_table').set_sensitive(True)
|
||||||
proxyhost_entry.set_text(gajim.config.get_per('proxies', proxy,
|
proxyhost_entry.set_text(gajim.config.get_per('proxies', proxy,
|
||||||
'host'))
|
'host'))
|
||||||
proxyport_entry.set_text(unicode(gajim.config.get_per('proxies',
|
proxyport_entry.set_text(str(gajim.config.get_per('proxies',
|
||||||
proxy, 'port')))
|
proxy, 'port')))
|
||||||
proxyuser_entry.set_text(gajim.config.get_per('proxies', proxy,
|
proxyuser_entry.set_text(gajim.config.get_per('proxies', proxy,
|
||||||
'user'))
|
'user'))
|
||||||
|
@ -1955,7 +1955,7 @@ class AccountsWindow:
|
||||||
if not custom_port:
|
if not custom_port:
|
||||||
custom_port = 5222
|
custom_port = 5222
|
||||||
gajim.config.set_per('accounts', account, 'custom_port', custom_port)
|
gajim.config.set_per('accounts', account, 'custom_port', custom_port)
|
||||||
self.xml.get_object('custom_port_entry1').set_text(unicode(custom_port))
|
self.xml.get_object('custom_port_entry1').set_text(str(custom_port))
|
||||||
|
|
||||||
# Personal tab
|
# Personal tab
|
||||||
gpg_key_label = self.xml.get_object('gpg_key_label1')
|
gpg_key_label = self.xml.get_object('gpg_key_label1')
|
||||||
|
@ -3288,13 +3288,13 @@ class ManageBookmarksWindow:
|
||||||
return
|
return
|
||||||
|
|
||||||
for account in self.treestore:
|
for account in self.treestore:
|
||||||
account_unicode = account[1]
|
acct = account[1]
|
||||||
gajim.connections[account_unicode].bookmarks = []
|
gajim.connections[acct].bookmarks = []
|
||||||
|
|
||||||
for bm in account.iterchildren():
|
for bm in account.iterchildren():
|
||||||
# Convert True/False/None to '1' or '0'
|
# Convert True/False/None to '1' or '0'
|
||||||
autojoin = unicode(int(bm[3]))
|
autojoin = str(int(bm[3]))
|
||||||
minimize = unicode(int(bm[4]))
|
minimize = str(int(bm[4]))
|
||||||
name = bm[1]
|
name = bm[1]
|
||||||
jid = bm[2]
|
jid = bm[2]
|
||||||
pw = bm[5]
|
pw = bm[5]
|
||||||
|
@ -3305,9 +3305,9 @@ class ManageBookmarksWindow:
|
||||||
'minimize': minimize, 'password': pw, 'nick': nick,
|
'minimize': minimize, 'password': pw, 'nick': nick,
|
||||||
'print_status': bm[7]}
|
'print_status': bm[7]}
|
||||||
|
|
||||||
gajim.connections[account_unicode].bookmarks.append(bmdict)
|
gajim.connections[acct].bookmarks.append(bmdict)
|
||||||
|
|
||||||
gajim.connections[account_unicode].store_bookmarks()
|
gajim.connections[acct].store_bookmarks()
|
||||||
gajim.interface.roster.set_actions_menu_needs_rebuild()
|
gajim.interface.roster.set_actions_menu_needs_rebuild()
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
|
|
|
@ -1313,10 +1313,6 @@ class ConversationTextview(GObject.GObject):
|
||||||
timestamp_str = helpers.from_one_line(timestamp_str)
|
timestamp_str = helpers.from_one_line(timestamp_str)
|
||||||
format_ += timestamp_str
|
format_ += timestamp_str
|
||||||
tim_format = time.strftime(format_, tim)
|
tim_format = time.strftime(format_, tim)
|
||||||
if locale.getpreferredencoding() not in ('KOI8-R', 'cp1251'):
|
|
||||||
# if tim_format comes as unicode because of day_str.
|
|
||||||
# we convert it to the encoding that we want (and that is utf-8)
|
|
||||||
tim_format = helpers.ensure_utf8_string(tim_format)
|
|
||||||
return tim_format
|
return tim_format
|
||||||
|
|
||||||
def detect_other_text_tag(self, text, kind):
|
def detect_other_text_tag(self, text, kind):
|
||||||
|
|
|
@ -113,7 +113,7 @@ class DataFormWidget(Gtk.Alignment, object):
|
||||||
|
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
"""
|
"""
|
||||||
Get the title of data form, as a unicode object. If no title or no form,
|
Get the title of data form. If no title or no form,
|
||||||
returns ''. Useful for setting window title
|
returns ''. Useful for setting window title
|
||||||
"""
|
"""
|
||||||
if self._data_form is not None:
|
if self._data_form is not None:
|
||||||
|
|
|
@ -3110,7 +3110,7 @@ class SingleMessageWindow:
|
||||||
|
|
||||||
def update_char_counter(self, widget):
|
def update_char_counter(self, widget):
|
||||||
characters_no = self.message_tv_buffer.get_char_count()
|
characters_no = self.message_tv_buffer.get_char_count()
|
||||||
self.count_chars_label.set_text(unicode(characters_no))
|
self.count_chars_label.set_text(characters_no)
|
||||||
|
|
||||||
def send_single_message(self):
|
def send_single_message(self):
|
||||||
if gajim.connections[self.account].connected <= 1:
|
if gajim.connections[self.account].connected <= 1:
|
||||||
|
|
|
@ -153,12 +153,12 @@ class FileTransfersWindow:
|
||||||
for file_props in allfp:
|
for file_props in allfp:
|
||||||
if file_props.type_ == 's' and file_props.tt_account == account:
|
if file_props.type_ == 's' and file_props.tt_account == account:
|
||||||
# 'account' is the sender
|
# 'account' is the sender
|
||||||
receiver_jid = unicode(file_props.receiver).split('/')[0]
|
receiver_jid = file_props.receiver.split('/')[0]
|
||||||
if jid == receiver_jid and not is_transfer_stopped(file_props):
|
if jid == receiver_jid and not is_transfer_stopped(file_props):
|
||||||
active_transfers[0].append(file_props)
|
active_transfers[0].append(file_props)
|
||||||
elif file_props.type_ == 'r' and file_props.tt_account == account:
|
elif file_props.type_ == 'r' and file_props.tt_account == account:
|
||||||
# 'account' is the recipient
|
# 'account' is the recipient
|
||||||
sender_jid = unicode(file_props.sender).split('/')[0]
|
sender_jid = file_props.sender.split('/')[0]
|
||||||
if jid == sender_jid and not is_transfer_stopped(file_props):
|
if jid == sender_jid and not is_transfer_stopped(file_props):
|
||||||
active_transfers[1].append(file_props)
|
active_transfers[1].append(file_props)
|
||||||
else:
|
else:
|
||||||
|
@ -188,7 +188,7 @@ class FileTransfersWindow:
|
||||||
sectext += '\n\t' + _('Size: %s') % \
|
sectext += '\n\t' + _('Size: %s') % \
|
||||||
helpers.convert_bytes(file_props.size)
|
helpers.convert_bytes(file_props.size)
|
||||||
if file_props.type_ == 'r':
|
if file_props.type_ == 'r':
|
||||||
jid = unicode(file_props.sender).split('/')[0]
|
jid = file_props.sender.split('/')[0]
|
||||||
sender_name = gajim.contacts.get_first_contact_from_jid(
|
sender_name = gajim.contacts.get_first_contact_from_jid(
|
||||||
file_props.tt_account, jid).get_shown_name()
|
file_props.tt_account, jid).get_shown_name()
|
||||||
sender = sender_name
|
sender = sender_name
|
||||||
|
@ -198,7 +198,7 @@ class FileTransfersWindow:
|
||||||
sectext += '\n\t' + _('Sender: %s') % sender
|
sectext += '\n\t' + _('Sender: %s') % sender
|
||||||
sectext += '\n\t' + _('Recipient: ')
|
sectext += '\n\t' + _('Recipient: ')
|
||||||
if file_props.type_ == 's':
|
if file_props.type_ == 's':
|
||||||
jid = unicode(file_props.receiver).split('/')[0]
|
jid = file_props.receiver.split('/')[0]
|
||||||
receiver_name = gajim.contacts.get_first_contact_from_jid(
|
receiver_name = gajim.contacts.get_first_contact_from_jid(
|
||||||
file_props.tt_account, jid).get_shown_name()
|
file_props.tt_account, jid).get_shown_name()
|
||||||
recipient = receiver_name
|
recipient = receiver_name
|
||||||
|
@ -533,7 +533,7 @@ class FileTransfersWindow:
|
||||||
_str += ' '
|
_str += ' '
|
||||||
if percent < 10:
|
if percent < 10:
|
||||||
_str += ' '
|
_str += ' '
|
||||||
_str += unicode(percent) + '% \n'
|
_str += str(percent) + '% \n'
|
||||||
return _str
|
return _str
|
||||||
|
|
||||||
def _format_time(self, _time):
|
def _format_time(self, _time):
|
||||||
|
@ -585,7 +585,7 @@ class FileTransfersWindow:
|
||||||
other = file_props.sender
|
other = file_props.sender
|
||||||
else: # we send a file
|
else: # we send a file
|
||||||
other = file_props.receiver
|
other = file_props.receiver
|
||||||
if isinstance(other, unicode):
|
if isinstance(other, str):
|
||||||
jid = gajim.get_jid_without_resource(other)
|
jid = gajim.get_jid_without_resource(other)
|
||||||
else: # It's a Contact instance
|
else: # It's a Contact instance
|
||||||
jid = other.jid
|
jid = other.jid
|
||||||
|
@ -713,7 +713,7 @@ class FileTransfersWindow:
|
||||||
file_props.type_ = 's'
|
file_props.type_ = 's'
|
||||||
file_props.desc = file_desc
|
file_props.desc = file_desc
|
||||||
file_props.elapsed_time = 0
|
file_props.elapsed_time = 0
|
||||||
file_props.size = unicode(stat[6])
|
file_props.size = str(stat[6])
|
||||||
file_props.sender = account
|
file_props.sender = account
|
||||||
file_props.receiver = contact
|
file_props.receiver = contact
|
||||||
file_props.tt_account = account
|
file_props.tt_account = account
|
||||||
|
|
|
@ -354,9 +354,6 @@ class GajimRemote:
|
||||||
elif self.command == 'list_accounts':
|
elif self.command == 'list_accounts':
|
||||||
if isinstance(res, list):
|
if isinstance(res, list):
|
||||||
for account in res:
|
for account in res:
|
||||||
if isinstance(account, unicode):
|
|
||||||
print(account.encode(PREFERRED_ENCODING))
|
|
||||||
else:
|
|
||||||
print(account)
|
print(account)
|
||||||
elif self.command == 'account_info':
|
elif self.command == 'account_info':
|
||||||
if res:
|
if res:
|
||||||
|
@ -368,14 +365,11 @@ class GajimRemote:
|
||||||
pref_keys = sorted(res.keys())
|
pref_keys = sorted(res.keys())
|
||||||
for pref_key in pref_keys:
|
for pref_key in pref_keys:
|
||||||
result = '%s = %s' % (pref_key, res[pref_key])
|
result = '%s = %s' % (pref_key, res[pref_key])
|
||||||
if isinstance(result, unicode):
|
|
||||||
print(result.encode(PREFERRED_ENCODING))
|
|
||||||
else:
|
|
||||||
print(result)
|
print(result)
|
||||||
elif self.command == 'contact_info':
|
elif self.command == 'contact_info':
|
||||||
print(self.print_info(0, res, True))
|
print(self.print_info(0, res, True))
|
||||||
elif res:
|
elif res:
|
||||||
print(unicode(res).encode(PREFERRED_ENCODING))
|
print(res)
|
||||||
|
|
||||||
def check_gajim_running(self):
|
def check_gajim_running(self):
|
||||||
if not self.sbus:
|
if not self.sbus:
|
||||||
|
@ -470,7 +464,7 @@ class GajimRemote:
|
||||||
ret_str +='\t'
|
ret_str +='\t'
|
||||||
elif isinstance(val, int):
|
elif isinstance(val, int):
|
||||||
ret_str +='\t' + str(val)
|
ret_str +='\t' + str(val)
|
||||||
elif isinstance(val, (str, unicode)):
|
elif isinstance(val, str):
|
||||||
ret_str +='\t' + val
|
ret_str +='\t' + val
|
||||||
elif isinstance(val, (list, tuple)):
|
elif isinstance(val, (list, tuple)):
|
||||||
res = ''
|
res = ''
|
||||||
|
@ -485,7 +479,7 @@ class GajimRemote:
|
||||||
for key in prop_dict.keys():
|
for key in prop_dict.keys():
|
||||||
val = prop_dict[key]
|
val = prop_dict[key]
|
||||||
spacing = ' ' * level * 4
|
spacing = ' ' * level * 4
|
||||||
if isinstance(val, (unicode, int, str)):
|
if isinstance(val, (int, str)):
|
||||||
if val is not None:
|
if val is not None:
|
||||||
val = val.strip()
|
val = val.strip()
|
||||||
ret_str += '%s%-10s: %s\n' % (spacing, key, val)
|
ret_str += '%s%-10s: %s\n' % (spacing, key, val)
|
||||||
|
|
|
@ -84,7 +84,7 @@ if os.name == 'nt':
|
||||||
os.environ['LANG'] = lang
|
os.environ['LANG'] = lang
|
||||||
gettext.bindtextdomain(APP, DIR)
|
gettext.bindtextdomain(APP, DIR)
|
||||||
gettext.textdomain(APP)
|
gettext.textdomain(APP)
|
||||||
gettext.install(APP, DIR, unicode=True)
|
gettext.install(APP, DIR)
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
import ctypes
|
import ctypes
|
||||||
|
@ -155,12 +155,8 @@ def parseOpts():
|
||||||
|
|
||||||
import locale
|
import locale
|
||||||
profile, config_path = parseOpts()
|
profile, config_path = parseOpts()
|
||||||
if config_path:
|
|
||||||
config_path = unicode(config_path, locale.getpreferredencoding())
|
|
||||||
del parseOpts
|
del parseOpts
|
||||||
|
|
||||||
profile = unicode(profile, locale.getpreferredencoding())
|
|
||||||
|
|
||||||
import common.configpaths
|
import common.configpaths
|
||||||
common.configpaths.gajimpaths.init(config_path)
|
common.configpaths.gajimpaths.init(config_path)
|
||||||
del config_path
|
del config_path
|
||||||
|
|
|
@ -168,10 +168,10 @@ class GajimThemesWindow:
|
||||||
# don't confuse translators
|
# don't confuse translators
|
||||||
theme_name = _('theme name')
|
theme_name = _('theme name')
|
||||||
theme_name_ns = theme_name.replace(' ', '_')
|
theme_name_ns = theme_name.replace(' ', '_')
|
||||||
while theme_name_ns + unicode(i) in gajim.config.get_per('themes'):
|
while theme_name_ns + str(i) in gajim.config.get_per('themes'):
|
||||||
i += 1
|
i += 1
|
||||||
model.set_value(iter_, 0, theme_name + unicode(i))
|
model.set_value(iter_, 0, theme_name + str(i))
|
||||||
gajim.config.add_per('themes', theme_name_ns + unicode(i))
|
gajim.config.add_per('themes', theme_name_ns + str(i))
|
||||||
self.themes_tree.get_selection().select_iter(iter_)
|
self.themes_tree.get_selection().select_iter(iter_)
|
||||||
col = self.themes_tree.get_column(0)
|
col = self.themes_tree.get_column(0)
|
||||||
path = model.get_path(iter_)
|
path = model.get_path(iter_)
|
||||||
|
|
|
@ -687,7 +687,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
if num_unread == 1:
|
if num_unread == 1:
|
||||||
unread = '*'
|
unread = '*'
|
||||||
elif num_unread > 1:
|
elif num_unread > 1:
|
||||||
unread = '[' + unicode(num_unread) + ']'
|
unread = '[' + str(num_unread) + ']'
|
||||||
label_str = unread + label_str
|
label_str = unread + label_str
|
||||||
return (label_str, color)
|
return (label_str, color)
|
||||||
|
|
||||||
|
@ -1049,8 +1049,6 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
def print_old_conversation(self, text, contact='', tim=None, xhtml = None,
|
def print_old_conversation(self, text, contact='', tim=None, xhtml = None,
|
||||||
displaymarking=None):
|
displaymarking=None):
|
||||||
if isinstance(text, str):
|
|
||||||
text = unicode(text, 'utf-8')
|
|
||||||
if contact:
|
if contact:
|
||||||
if contact == self.nick: # it's us
|
if contact == self.nick: # it's us
|
||||||
kind = 'outgoing'
|
kind = 'outgoing'
|
||||||
|
@ -1076,8 +1074,6 @@ class GroupchatControl(ChatControlBase):
|
||||||
(contact = 'info' in such a case).
|
(contact = 'info' in such a case).
|
||||||
If contact is not set: it's a message from the server or help.
|
If contact is not set: it's a message from the server or help.
|
||||||
"""
|
"""
|
||||||
if isinstance(text, str):
|
|
||||||
text = unicode(text, 'utf-8')
|
|
||||||
other_tags_for_name = []
|
other_tags_for_name = []
|
||||||
other_tags_for_text = []
|
other_tags_for_text = []
|
||||||
if contact:
|
if contact:
|
||||||
|
@ -2200,7 +2196,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.nick_hits = [] # clear the hit list
|
self.nick_hits = [] # clear the hit list
|
||||||
list_nick = gajim.contacts.get_nick_list(self.account,
|
list_nick = gajim.contacts.get_nick_list(self.account,
|
||||||
self.room_jid)
|
self.room_jid)
|
||||||
list_nick.sort(key=unicode.lower) # case-insensitive sort
|
list_nick.sort(key=str.lower) # case-insensitive sort
|
||||||
if begin == '':
|
if begin == '':
|
||||||
# empty message, show lasts nicks that highlighted us first
|
# empty message, show lasts nicks that highlighted us first
|
||||||
for nick in self.attention_list:
|
for nick in self.attention_list:
|
||||||
|
|
|
@ -164,7 +164,7 @@ class Interface:
|
||||||
|
|
||||||
def handle_event_iq_error(self, obj):
|
def handle_event_iq_error(self, obj):
|
||||||
#('ERROR_ANSWER', account, (id_, fjid, errmsg, errcode))
|
#('ERROR_ANSWER', account, (id_, fjid, errmsg, errcode))
|
||||||
if unicode(obj.errcode) in ('400', '403', '406') and obj.id_:
|
if str(obj.errcode) in ('400', '403', '406') and obj.id_:
|
||||||
# show the error dialog
|
# show the error dialog
|
||||||
ft = self.instances['file_transfers']
|
ft = self.instances['file_transfers']
|
||||||
sid = obj.id_
|
sid = obj.id_
|
||||||
|
@ -172,7 +172,7 @@ class Interface:
|
||||||
sid = obj.id_[3:]
|
sid = obj.id_[3:]
|
||||||
file_props = FilesProp.getFileProp(obj.conn.name, sid)
|
file_props = FilesProp.getFileProp(obj.conn.name, sid)
|
||||||
if file_props :
|
if file_props :
|
||||||
if unicode(obj.errcode) == '400':
|
if str(obj.errcode) == '400':
|
||||||
file_props.error = -3
|
file_props.error = -3
|
||||||
else:
|
else:
|
||||||
file_props.error = -4
|
file_props.error = -4
|
||||||
|
@ -181,7 +181,7 @@ class Interface:
|
||||||
error_msg=obj.errmsg))
|
error_msg=obj.errmsg))
|
||||||
obj.conn.disconnect_transfer(file_props)
|
obj.conn.disconnect_transfer(file_props)
|
||||||
return
|
return
|
||||||
elif unicode(obj.errcode) == '404':
|
elif str(obj.errcode) == '404':
|
||||||
sid = obj.id_
|
sid = obj.id_
|
||||||
if len(obj.id_) > 3 and obj.id_[2] == '_':
|
if len(obj.id_) > 3 and obj.id_[2] == '_':
|
||||||
sid = obj.id_[3:]
|
sid = obj.id_[3:]
|
||||||
|
@ -951,7 +951,7 @@ class Interface:
|
||||||
ft_win = self.instances['file_transfers']
|
ft_win = self.instances['file_transfers']
|
||||||
if not file_props.hash_:
|
if not file_props.hash_:
|
||||||
# We disn't get the hash, sender probably don't support that
|
# We disn't get the hash, sender probably don't support that
|
||||||
jid = unicode(file_props.sender)
|
jid = file_props.sender
|
||||||
self.popup_ft_result(account, jid, file_props)
|
self.popup_ft_result(account, jid, file_props)
|
||||||
ft_win.set_status(file_props, 'ok')
|
ft_win.set_status(file_props, 'ok')
|
||||||
h = Hashes()
|
h = Hashes()
|
||||||
|
@ -963,7 +963,7 @@ class Interface:
|
||||||
file_.close()
|
file_.close()
|
||||||
# If the hash we received and the hash of the file are the same,
|
# If the hash we received and the hash of the file are the same,
|
||||||
# then the file is not corrupt
|
# then the file is not corrupt
|
||||||
jid = unicode(file_props.sender)
|
jid = file_props.sender
|
||||||
if file_props.hash_ == hash_:
|
if file_props.hash_ == hash_:
|
||||||
GObject.idle_add(self.popup_ft_result, account, jid, file_props)
|
GObject.idle_add(self.popup_ft_result, account, jid, file_props)
|
||||||
GObject.idle_add(ft_win.set_status, file_props, 'ok')
|
GObject.idle_add(ft_win.set_status, file_props, 'ok')
|
||||||
|
@ -995,7 +995,7 @@ class Interface:
|
||||||
self.hashThread.start()
|
self.hashThread.start()
|
||||||
gajim.socks5queue.remove_receiver(file_props.sid, True, True)
|
gajim.socks5queue.remove_receiver(file_props.sid, True, True)
|
||||||
else: # we send a file
|
else: # we send a file
|
||||||
jid = unicode(file_props.receiver)
|
jid = file_props.receiver
|
||||||
gajim.socks5queue.remove_sender(file_props.sid, True, True)
|
gajim.socks5queue.remove_sender(file_props.sid, True, True)
|
||||||
self.popup_ft_result(account, jid, file_props)
|
self.popup_ft_result(account, jid, file_props)
|
||||||
|
|
||||||
|
@ -1042,7 +1042,7 @@ class Interface:
|
||||||
if file_props is not None:
|
if file_props is not None:
|
||||||
if file_props.type_ == 'r':
|
if file_props.type_ == 'r':
|
||||||
# get the name of the sender, as it is in the roster
|
# get the name of the sender, as it is in the roster
|
||||||
sender = unicode(file_props.sender).split('/')[0]
|
sender = file_props.sender.split('/')[0]
|
||||||
name = gajim.contacts.get_first_contact_from_jid(account,
|
name = gajim.contacts.get_first_contact_from_jid(account,
|
||||||
sender).get_shown_name()
|
sender).get_shown_name()
|
||||||
filename = os.path.basename(file_props.file_name)
|
filename = os.path.basename(file_props.file_name)
|
||||||
|
|
|
@ -498,7 +498,7 @@ class MessageWindow(object):
|
||||||
|
|
||||||
unread_str = ''
|
unread_str = ''
|
||||||
if unread > 1:
|
if unread > 1:
|
||||||
unread_str = '[' + unicode(unread) + '] '
|
unread_str = '[' + str(unread) + '] '
|
||||||
elif unread == 1:
|
elif unread == 1:
|
||||||
unread_str = '* '
|
unread_str = '* '
|
||||||
else:
|
else:
|
||||||
|
@ -693,10 +693,8 @@ class MessageWindow(object):
|
||||||
Return the MessageControl for jid or n, where n is a notebook page index.
|
Return the MessageControl for jid or n, where n is a notebook page index.
|
||||||
When key is an int index acct may be None
|
When key is an int index acct may be None
|
||||||
"""
|
"""
|
||||||
if isinstance(key, str):
|
|
||||||
key = unicode(key, 'utf-8')
|
|
||||||
|
|
||||||
if isinstance(key, unicode):
|
if isinstance(key, str):
|
||||||
jid = key
|
jid = key
|
||||||
try:
|
try:
|
||||||
return self._controls[acct][jid]
|
return self._controls[acct][jid]
|
||||||
|
|
|
@ -46,7 +46,7 @@ class GajimPlugin(object):
|
||||||
|
|
||||||
Will be shown in plugins management GUI.
|
Will be shown in plugins management GUI.
|
||||||
|
|
||||||
:type: unicode
|
:type: str
|
||||||
'''
|
'''
|
||||||
short_name = ''
|
short_name = ''
|
||||||
'''
|
'''
|
||||||
|
@ -54,7 +54,7 @@ class GajimPlugin(object):
|
||||||
|
|
||||||
Used for quick indentification of plugin.
|
Used for quick indentification of plugin.
|
||||||
|
|
||||||
:type: unicode
|
:type: str
|
||||||
|
|
||||||
:todo: decide whether we really need this one, because class name (with
|
:todo: decide whether we really need this one, because class name (with
|
||||||
module name) can act as such short name
|
module name) can act as such short name
|
||||||
|
@ -63,7 +63,7 @@ class GajimPlugin(object):
|
||||||
'''
|
'''
|
||||||
Version of plugin.
|
Version of plugin.
|
||||||
|
|
||||||
:type: unicode
|
:type: str
|
||||||
|
|
||||||
:todo: decide how to compare version between each other (which one
|
:todo: decide how to compare version between each other (which one
|
||||||
is higher). Also rethink: do we really need to compare versions
|
is higher). Also rethink: do we really need to compare versions
|
||||||
|
@ -75,7 +75,7 @@ class GajimPlugin(object):
|
||||||
'''
|
'''
|
||||||
Plugin description.
|
Plugin description.
|
||||||
|
|
||||||
:type: unicode
|
:type: str
|
||||||
|
|
||||||
:todo: should be allow rich text here (like HTML or reStructuredText)?
|
:todo: should be allow rich text here (like HTML or reStructuredText)?
|
||||||
'''
|
'''
|
||||||
|
@ -83,7 +83,7 @@ class GajimPlugin(object):
|
||||||
'''
|
'''
|
||||||
Plugin authors.
|
Plugin authors.
|
||||||
|
|
||||||
:type: [] of unicode
|
:type: [] of str
|
||||||
|
|
||||||
:todo: should we decide on any particular format of author strings?
|
:todo: should we decide on any particular format of author strings?
|
||||||
Especially: should we force format of giving author's e-mail?
|
Especially: should we force format of giving author's e-mail?
|
||||||
|
@ -92,7 +92,7 @@ class GajimPlugin(object):
|
||||||
'''
|
'''
|
||||||
URL to plug-in's homepage.
|
URL to plug-in's homepage.
|
||||||
|
|
||||||
:type: unicode
|
:type: str
|
||||||
|
|
||||||
:todo: should we check whether provided string is valid URI? (Maybe
|
:todo: should we check whether provided string is valid URI? (Maybe
|
||||||
using 'property')
|
using 'property')
|
||||||
|
@ -120,7 +120,7 @@ class GajimPlugin(object):
|
||||||
|
|
||||||
Values are tuples: (default_value, option_description). The first one can
|
Values are tuples: (default_value, option_description). The first one can
|
||||||
be anything (this is the advantage of using shelve/pickle instead of
|
be anything (this is the advantage of using shelve/pickle instead of
|
||||||
custom-made config I/O handling); the second one should be unicode (gettext
|
custom-made config I/O handling); the second one should be str (gettext
|
||||||
can be used if need and/or translation is planned).
|
can be used if need and/or translation is planned).
|
||||||
|
|
||||||
:type: {} of 2-element tuples
|
:type: {} of 2-element tuples
|
||||||
|
|
|
@ -158,7 +158,7 @@ class PluginManager(object):
|
||||||
active yet).
|
active yet).
|
||||||
|
|
||||||
:param gui_extpoint_name: name of GUI extension point.
|
:param gui_extpoint_name: name of GUI extension point.
|
||||||
:type gui_extpoint_name: unicode
|
:type gui_extpoint_name: str
|
||||||
:param args: parameters to be passed to extension point handlers
|
:param args: parameters to be passed to extension point handlers
|
||||||
(typically and object that invokes `gui_extension_point`;
|
(typically and object that invokes `gui_extension_point`;
|
||||||
however, this can be practically anything)
|
however, this can be practically anything)
|
||||||
|
@ -209,7 +209,7 @@ class PluginManager(object):
|
||||||
freedom, but is this necessary?
|
freedom, but is this necessary?
|
||||||
|
|
||||||
:param gui_extpoint_name: name of GUI extension point.
|
:param gui_extpoint_name: name of GUI extension point.
|
||||||
:type gui_extpoint_name: unicode
|
:type gui_extpoint_name: str
|
||||||
:param args: arguments that `PluginManager.gui_extension_point` was
|
:param args: arguments that `PluginManager.gui_extension_point` was
|
||||||
called with for this extension point. This is used (along with
|
called with for this extension point. This is used (along with
|
||||||
extension point name) to identify element to be removed.
|
extension point name) to identify element to be removed.
|
||||||
|
@ -394,7 +394,7 @@ class PluginManager(object):
|
||||||
Scans given directory for plugin classes.
|
Scans given directory for plugin classes.
|
||||||
|
|
||||||
:param path: directory to scan for plugins
|
:param path: directory to scan for plugins
|
||||||
:type path: unicode
|
:type path: str
|
||||||
|
|
||||||
:return: list of found plugin classes (subclasses of `GajimPlugin`
|
:return: list of found plugin classes (subclasses of `GajimPlugin`
|
||||||
:rtype: [] of class objects
|
:rtype: [] of class objects
|
||||||
|
|
|
@ -72,7 +72,7 @@ def get_dbus_struct(obj):
|
||||||
"""
|
"""
|
||||||
if obj is None:
|
if obj is None:
|
||||||
return DBUS_NONE()
|
return DBUS_NONE()
|
||||||
if isinstance(obj, (unicode, str)):
|
if isinstance(obj, str):
|
||||||
return DBUS_STRING(obj)
|
return DBUS_STRING(obj)
|
||||||
if isinstance(obj, int):
|
if isinstance(obj, int):
|
||||||
return DBUS_INT32(obj)
|
return DBUS_INT32(obj)
|
||||||
|
@ -613,8 +613,8 @@ class SignalObject(dbus.service.Object):
|
||||||
"""
|
"""
|
||||||
Get vcard info for a contact. Return cached value of the vcard
|
Get vcard info for a contact. Return cached value of the vcard
|
||||||
"""
|
"""
|
||||||
if not isinstance(jid, unicode):
|
if not isinstance(jid, str):
|
||||||
jid = unicode(jid)
|
jid = str(jid)
|
||||||
if not jid:
|
if not jid:
|
||||||
raise dbus_support.MissingArgument()
|
raise dbus_support.MissingArgument()
|
||||||
jid = self._get_real_jid(jid)
|
jid = self._get_real_jid(jid)
|
||||||
|
@ -652,9 +652,9 @@ class SignalObject(dbus.service.Object):
|
||||||
result['name'] = DBUS_STRING(con.name)
|
result['name'] = DBUS_STRING(con.name)
|
||||||
result['jid'] = DBUS_STRING(gajim.get_jid_from_account(con.name))
|
result['jid'] = DBUS_STRING(gajim.get_jid_from_account(con.name))
|
||||||
result['message'] = DBUS_STRING(con.status)
|
result['message'] = DBUS_STRING(con.status)
|
||||||
result['priority'] = DBUS_STRING(unicode(con.priority))
|
result['priority'] = DBUS_STRING(str(con.priority))
|
||||||
result['resource'] = DBUS_STRING(unicode(gajim.config.get_per(
|
result['resource'] = DBUS_STRING(gajim.config.get_per('accounts',
|
||||||
'accounts', con.name, 'resource')))
|
con.name, 'resource'))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@dbus.service.method(INTERFACE, in_signature='s', out_signature='aa{sv}')
|
@dbus.service.method(INTERFACE, in_signature='s', out_signature='aa{sv}')
|
||||||
|
|
|
@ -1202,7 +1202,7 @@ class RosterWindow:
|
||||||
nb_connected_contact += 1
|
nb_connected_contact += 1
|
||||||
if nb_connected_contact > 1:
|
if nb_connected_contact > 1:
|
||||||
# switch back to default writing direction
|
# switch back to default writing direction
|
||||||
name += i18n.paragraph_direction_mark(unicode(name))
|
name += i18n.paragraph_direction_mark(name)
|
||||||
name += ' (%d)' % nb_connected_contact
|
name += ' (%d)' % nb_connected_contact
|
||||||
|
|
||||||
# add status msg, if not empty, under contact name in
|
# add status msg, if not empty, under contact name in
|
||||||
|
@ -3512,8 +3512,8 @@ class RosterWindow:
|
||||||
elif type_ == 'agent':
|
elif type_ == 'agent':
|
||||||
self.on_remove_agent(widget, list_)
|
self.on_remove_agent(widget, list_)
|
||||||
|
|
||||||
elif not (event.get_state() & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)) and\
|
elif not (event.get_state() & (Gdk.ModifierType.CONTROL_MASK | \
|
||||||
Gdk.keyval_to_unicode(event.keyval):
|
Gdk.ModifierType.MOD1_MASK)) and Gdk.keyval_to_unicode(event.keyval):
|
||||||
# if we got unicode symbol without ctrl / alt
|
# if we got unicode symbol without ctrl / alt
|
||||||
num = Gdk.keyval_to_unicode(event.keyval)
|
num = Gdk.keyval_to_unicode(event.keyval)
|
||||||
self.enable_rfilter(unichr(num))
|
self.enable_rfilter(unichr(num))
|
||||||
|
|
|
@ -235,13 +235,10 @@ class StatusTable:
|
||||||
self.current_row + 1)
|
self.current_row + 1)
|
||||||
|
|
||||||
def get_status_info(self, resource, priority, show, status):
|
def get_status_info(self, resource, priority, show, status):
|
||||||
str_status = resource + ' (' + unicode(priority) + ')'
|
str_status = resource + ' (' + str(priority) + ')'
|
||||||
if status:
|
if status:
|
||||||
status = status.strip()
|
status = status.strip()
|
||||||
if status != '':
|
if status != '':
|
||||||
# make sure 'status' is unicode before we send to to reduce_chars
|
|
||||||
if isinstance(status, str):
|
|
||||||
status = unicode(status, encoding='utf-8')
|
|
||||||
# reduce to 100 chars, 1 line
|
# reduce to 100 chars, 1 line
|
||||||
status = helpers.reduce_chars_newlines(status, 100, 1)
|
status = helpers.reduce_chars_newlines(status, 100, 1)
|
||||||
str_status = GObject.markup_escape_text(str_status)
|
str_status = GObject.markup_escape_text(str_status)
|
||||||
|
@ -301,10 +298,6 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
||||||
file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
|
file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
|
||||||
for acct in accounts:
|
for acct in accounts:
|
||||||
message = acct['message']
|
message = acct['message']
|
||||||
# before reducing the chars we should assure we send unicode, else
|
|
||||||
# there are possible pango TBs on 'set_markup'
|
|
||||||
if isinstance(message, str):
|
|
||||||
message = unicode(message, encoding = 'utf-8')
|
|
||||||
message = helpers.reduce_chars_newlines(message, 100, 1)
|
message = helpers.reduce_chars_newlines(message, 100, 1)
|
||||||
message = GObject.markup_escape_text(message)
|
message = GObject.markup_escape_text(message)
|
||||||
if acct['name'] in gajim.con_types and \
|
if acct['name'] in gajim.con_types and \
|
||||||
|
@ -606,7 +599,7 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
if num_resources == 1 and contact.resource:
|
if num_resources == 1 and contact.resource:
|
||||||
properties.append((_('Resource: '),
|
properties.append((_('Resource: '),
|
||||||
GObject.markup_escape_text(contact.resource) +\
|
GObject.markup_escape_text(contact.resource) +\
|
||||||
' (' + unicode(contact.priority) + ')'))
|
' (' + str(contact.priority) + ')'))
|
||||||
|
|
||||||
if self.account and prim_contact.sub and prim_contact.sub != 'both' and\
|
if self.account and prim_contact.sub and prim_contact.sub != 'both' and\
|
||||||
prim_contact.jid not in gajim.gc_connected[self.account]:
|
prim_contact.jid not in gajim.gc_connected[self.account]:
|
||||||
|
@ -670,7 +663,7 @@ class RosterTooltip(NotificationAreaTooltip):
|
||||||
vcard_current_row + 1, Gtk.AttachOptions.EXPAND | \
|
vcard_current_row + 1, Gtk.AttachOptions.EXPAND | \
|
||||||
Gtk.AttachOptions.FILL, vertical_fill, 0, 0)
|
Gtk.AttachOptions.FILL, vertical_fill, 0, 0)
|
||||||
else:
|
else:
|
||||||
if isinstance(property_[0], (unicode, str)): # FIXME: rm unicode?
|
if isinstance(property_[0], str):
|
||||||
label.set_markup(property_[0])
|
label.set_markup(property_[0])
|
||||||
label.set_line_wrap(True)
|
label.set_line_wrap(True)
|
||||||
else:
|
else:
|
||||||
|
@ -743,7 +736,7 @@ class FileTransfersTooltip(BaseTooltip):
|
||||||
if file_props.type_ == 'r':
|
if file_props.type_ == 'r':
|
||||||
type_ = _('Download')
|
type_ = _('Download')
|
||||||
actor = _('Sender: ')
|
actor = _('Sender: ')
|
||||||
sender = unicode(file_props.sender).split('/')[0]
|
sender = file_props.sender.split('/')[0]
|
||||||
name = gajim.contacts.get_first_contact_from_jid(
|
name = gajim.contacts.get_first_contact_from_jid(
|
||||||
file_props.tt_account, sender).get_shown_name()
|
file_props.tt_account, sender).get_shown_name()
|
||||||
else:
|
else:
|
||||||
|
|
12
src/vcard.py
12
src/vcard.py
|
@ -408,10 +408,10 @@ class VcardWindow:
|
||||||
tt_text = _("There is no pending subscription request.")
|
tt_text = _("There is no pending subscription request.")
|
||||||
eb.set_tooltip_text(tt_text)
|
eb.set_tooltip_text(tt_text)
|
||||||
|
|
||||||
resources = '%s (%s)' % (self.contact.resource, unicode(
|
resources = '%s (%s)' % (self.contact.resource, str(
|
||||||
self.contact.priority))
|
self.contact.priority))
|
||||||
uf_resources = self.contact.resource + _(' resource with priority ')\
|
uf_resources = self.contact.resource + _(' resource with priority ')\
|
||||||
+ unicode(self.contact.priority)
|
+ str(self.contact.priority)
|
||||||
if not self.contact.status:
|
if not self.contact.status:
|
||||||
self.contact.status = ''
|
self.contact.status = ''
|
||||||
|
|
||||||
|
@ -462,9 +462,9 @@ class VcardWindow:
|
||||||
for c in contact_list:
|
for c in contact_list:
|
||||||
if c.resource != self.contact.resource:
|
if c.resource != self.contact.resource:
|
||||||
resources += '\n%s (%s)' % (c.resource,
|
resources += '\n%s (%s)' % (c.resource,
|
||||||
unicode(c.priority))
|
str(c.priority))
|
||||||
uf_resources += '\n' + c.resource + \
|
uf_resources += '\n' + c.resource + \
|
||||||
_(' resource with priority ') + unicode(c.priority)
|
_(' resource with priority ') + str(c.priority)
|
||||||
if c.show not in ('offline', 'error'):
|
if c.show not in ('offline', 'error'):
|
||||||
GObject.idle_add(
|
GObject.idle_add(
|
||||||
gajim.connections[self.account].request_os_info, c.jid,
|
gajim.connections[self.account].request_os_info, c.jid,
|
||||||
|
@ -584,10 +584,10 @@ class ZeroconfVcardWindow:
|
||||||
'</span></b>')
|
'</span></b>')
|
||||||
self.xml.get_object('local_jid_label').set_text(self.contact.jid)
|
self.xml.get_object('local_jid_label').set_text(self.contact.jid)
|
||||||
|
|
||||||
resources = '%s (%s)' % (self.contact.resource, unicode(
|
resources = '%s (%s)' % (self.contact.resource, str(
|
||||||
self.contact.priority))
|
self.contact.priority))
|
||||||
uf_resources = self.contact.resource + _(' resource with priority ')\
|
uf_resources = self.contact.resource + _(' resource with priority ')\
|
||||||
+ unicode(self.contact.priority)
|
+ str(self.contact.priority)
|
||||||
if not self.contact.status:
|
if not self.contact.status:
|
||||||
self.contact.status = ''
|
self.contact.status = ''
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue